:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-muted: #e8f4ff;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #e5e7eb;
  --line-strong: #cbd5e1;
  --brand: #00b0ff;
  --brand-dark: #002769;
  --brand-soft: #e8f4ff;
  --amber: #b7791f;
  --amber-soft: #fff0cd;
  --rose: #b84c4c;
  --rose-soft: #ffe3df;
  --blue: #005fbe;
  --blue-soft: #e0eef6;
  --violet: #6c5a8e;
  --green-soft: #e3f4d7;
  --shadow: 0 20px 50px rgba(0, 39, 105, 0.14);
  --radius: 8px;
  --sidebar: 272px;
  --topbar: 82px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% -10%, rgba(0, 176, 255, 0.15), transparent 34rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(245, 248, 252, 0) 290px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 18px;
  color: #f7fbf7;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
    #002769;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  margin-bottom: 26px;
}

.brand-logo-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 118px;
  height: 44px;
  padding: 8px 10px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(0, 176, 255, 0.2);
}

.brand-logo-tile img {
  display: block;
  width: 100%;
  height: auto;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
}

.brand span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
}

.main-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.12);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #42d5ff;
  font-weight: 700;
}

.role-panel {
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
}

.role-panel label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
}

.role-panel select {
  width: 100%;
  padding: 9px 10px;
  color: #11241f;
  background: #ffffff;
  border: 0;
  border-radius: 6px;
}

.role-panel p {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  line-height: 1.35;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: var(--topbar);
  padding: 14px 28px;
  background: rgba(246, 244, 239, 0.9);
  border-bottom: 1px solid rgba(222, 216, 204, 0.85);
  backdrop-filter: blur(16px);
}

.menu-toggle {
  display: none;
}

.title-block {
  min-width: 0;
}

.eyebrow {
  display: block;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.08;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.12rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 38vw);
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.content {
  max-width: 1580px;
  padding: 24px 28px 52px;
}

.section-stack {
  display: grid;
  gap: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand) 70%, #42d5ff);
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(0, 176, 255, 0.2);
}

.secondary-button {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-color: #c7e8ff;
}

.danger-button {
  color: #8b2d2d;
  background: var(--rose-soft);
  border-color: #efc1bc;
}

.ghost-button {
  background: transparent;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled,
.icon-button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.kpi-card,
.panel,
.table-card,
.detail-panel,
.list-panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.kpi-card {
  min-height: 106px;
  padding: 16px;
}

.kpi-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 850;
  line-height: 1;
}

.kpi-foot {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.panel {
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.85fr);
  gap: 16px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.table-card {
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  background: var(--surface-soft);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr.is-selected td {
  background: #eef8ff;
}

.nowrap {
  white-space: nowrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.status-badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 8px;
  color: var(--brand-dark);
  font-size: 0.76rem;
  font-weight: 800;
  background: var(--brand-soft);
  border: 1px solid #c7e8ff;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge[data-tone="amber"],
.pill[data-tone="amber"] {
  color: #7a4d00;
  background: var(--amber-soft);
  border-color: #f0cf8d;
}

.status-badge[data-tone="rose"],
.pill[data-tone="rose"] {
  color: #8b2d2d;
  background: var(--rose-soft);
  border-color: #efc1bc;
}

.status-badge[data-tone="blue"],
.pill[data-tone="blue"] {
  color: #24536f;
  background: var(--blue-soft);
  border-color: #bdd5e4;
}

.status-badge[data-tone="violet"],
.pill[data-tone="violet"] {
  color: #4d3c72;
  background: #eee6f8;
  border-color: #d6c6eb;
}

.status-badge[data-tone="green"],
.pill[data-tone="green"] {
  color: #38651b;
  background: var(--green-soft);
  border-color: #c4e8ac;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(330px, 0.82fr) minmax(0, 1.45fr);
  gap: 16px;
  align-items: start;
}

.list-panel,
.detail-panel {
  min-width: 0;
  overflow: hidden;
}

.list-panel {
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

.detail-panel {
  padding: 18px;
}

.offer-list-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.offer-list-item:hover,
.offer-list-item.is-selected {
  background: #eef8ff;
}

.offer-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.offer-number {
  font-weight: 850;
}

.offer-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.detail-title h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric-card {
  padding: 12px;
}

.metric-card span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.75rem;
}

.metric-card strong {
  font-size: 1rem;
}

.warning-box,
.info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
}

.warning-box {
  color: #7a4d00;
  background: var(--amber-soft);
  border: 1px solid #f0cf8d;
}

.info-box {
  color: #24536f;
  background: var(--blue-soft);
  border: 1px solid #bdd5e4;
}

.product-thumb {
  display: block;
  width: 58px;
  height: 42px;
  object-fit: cover;
  background: #ebe5d9;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.product-cell strong {
  display: block;
  margin-bottom: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea,
.inline-input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline-color: var(--brand);
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.inline-input {
  width: 92px;
}

.offer-text-input {
  width: 100%;
  min-width: 128px;
  padding: 8px 9px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.offer-item-stack {
  display: grid;
  gap: 7px;
  min-width: 190px;
}

.offer-items-table {
  min-width: 1320px;
}

.offer-import-card {
  margin: 0 0 12px;
}

.product-import-card {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid rgba(0, 176, 255, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #ffffff, #f8fbff);
}

.product-import-card label {
  gap: 9px;
  color: var(--brand-dark);
  font-weight: 800;
}

.product-import-card label span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.product-import-card textarea {
  min-height: 48px;
}

.inline-select {
  min-width: 108px;
  padding: 8px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.add-line {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
  margin-top: 12px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-left: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.timeline li:last-child {
  border-bottom: 0;
}

.timeline time {
  color: var(--muted);
  font-size: 0.78rem;
}

.timeline strong {
  display: block;
  margin-bottom: 2px;
}

.bar-list {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
}

.bar-track {
  height: 10px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--amber));
  border-radius: inherit;
}

.projects-layout {
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.9fr);
}

.calendar-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.project-calendar {
  display: grid;
  grid-template-columns: 82px repeat(7, minmax(132px, 1fr));
  min-width: 1010px;
}

.calendar-head,
.calendar-time,
.calendar-cell {
  min-height: 76px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.calendar-head {
  min-height: 58px;
  color: var(--brand-dark);
  background: var(--surface-soft);
}

.calendar-head strong,
.calendar-head span {
  display: block;
}

.calendar-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.calendar-time-head,
.calendar-time {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #ffffff;
}

.calendar-time {
  display: flex;
  align-items: flex-start;
  color: var(--muted);
  font-weight: 850;
}

.calendar-cell {
  display: grid;
  align-content: start;
  gap: 7px;
  background: #ffffff;
}

.calendar-cell.is-busy {
  background: #fff8f7;
}

.calendar-cell.is-free {
  background: #fbfdff;
}

.calendar-booking,
.slot-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 56px;
  padding: 9px;
  text-align: left;
  border-radius: 7px;
}

.calendar-booking {
  color: #8b2d2d;
  background: var(--rose-soft);
  border: 1px solid #efc1bc;
}

.calendar-booking strong,
.calendar-booking span,
.calendar-booking small,
.slot-button strong,
.slot-button span {
  display: block;
}

.calendar-booking strong,
.slot-button strong {
  font-size: 0.78rem;
}

.calendar-booking span,
.calendar-booking small,
.slot-button span {
  font-size: 0.74rem;
}

.calendar-booking small {
  color: #9a4a41;
}

.slot-button {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px dashed #9bdcff;
}

.slot-button:hover {
  border-style: solid;
  background: #dff3ff;
}

.slot-empty {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.modal-root:empty,
.toast-root:empty {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(27, 28, 25, 0.44);
}

.modal {
  width: min(760px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 18px;
}

.modal h2 {
  margin-bottom: 0;
}

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #ffffff;
  background: #20342f;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.mobile-scrim {
  display: none;
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .two-col,
  .split-panel {
    grid-template-columns: 1fr;
  }

  .list-panel {
    max-height: none;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, 88vw);
    transform: translateX(-104%);
    transition: transform 180ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  body.menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 18;
    background: rgba(21, 22, 19, 0.42);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 12px 16px;
  }

  .top-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .search-box {
    flex: 1;
    width: auto;
  }

  .content {
    padding: 18px 16px 40px;
  }

  .three-col,
  .notes-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .data-table {
    min-width: 760px;
  }

  .table-card {
    overflow-x: auto;
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

@media (max-width: 560px) {
  .kpi-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }

  .detail-actions,
  .toolbar,
  .toolbar-group {
    align-items: stretch;
    flex-direction: column;
  }

  .add-line {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}
