:root {
  color-scheme: light;
  --teal-700: #087f76;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-100: #d7f7f2;
  --copper-700: #96592f;
  --copper-600: #b96f3d;
  --copper-500: #d98a4a;
  --ink-950: #171512;
  --ink-800: #2e2a25;
  --ink-650: #575047;
  --ink-500: #756d62;
  --line: #e6ded4;
  --page: #f8f5f0;
  --surface: #fffdf9;
  --surface-2: #f1ebe3;
  --success: #16845f;
  --warning: #c47a1f;
  --danger: #c24b45;
  --info: #347b9c;
  --shadow: 0 18px 42px rgba(49, 36, 22, 0.12);
  --sidebar-width: 282px;
  --sidebar-collapsed: 78px;
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --teal-700: #53d8c7;
  --teal-600: #2cc6b6;
  --teal-500: #1ba99a;
  --teal-100: rgba(44, 198, 182, 0.16);
  --copper-700: #f3b37b;
  --copper-600: #dc9155;
  --copper-500: #bd7541;
  --ink-950: #f8f3eb;
  --ink-800: #ebe1d3;
  --ink-650: #c9baaa;
  --ink-500: #a99b8d;
  --line: #38312b;
  --page: #171512;
  --surface: #211d19;
  --surface-2: #2a251f;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink-950);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 28px rgba(43, 31, 20, 0.06);
  transition: width 180ms ease, transform 180ms ease;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong {
  color: var(--teal-600);
  font-size: 17px;
  line-height: 1;
  text-transform: uppercase;
}

.brand-copy span {
  color: var(--copper-600);
  font-size: 13px;
  font-weight: 700;
}

.nav-menu {
  display: grid;
  gap: 5px;
}

.nav-link {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-650);
  text-align: left;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-link svg,
.icon-button svg,
.search-box svg,
.metric-icon svg,
.button svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--teal-100);
  border-color: rgba(13, 148, 136, 0.16);
  color: var(--teal-700);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-650);
  font-size: 12px;
}

.sidebar-footer strong,
.sidebar-footer span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(22, 132, 95, 0.12);
  flex: 0 0 auto;
}

.content-shell {
  width: 100%;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left 180ms ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.search-box {
  flex: 1 1 auto;
  min-width: 130px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-500);
}

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

.topbar-actions,
.workspace-actions,
.button-row,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.chip-button {
  min-width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-650);
}

.icon-button:hover,
.chip-button:hover,
.profile-chip:hover,
.button:hover {
  border-color: var(--teal-500);
  color: var(--teal-700);
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-800);
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--teal-600);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px 24px 42px;
}

.workspace-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--copper-600);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

h3 {
  margin-bottom: 7px;
  font-size: 15px;
}

.workspace-header p {
  color: var(--ink-650);
}

.view-stage {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.panel,
.metric-card,
.data-table,
.item-card,
.kanban-column,
.phone-frame,
.map-panel,
.report-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel,
.metric-card,
.item-card,
.report-card {
  padding: 16px;
}

.metric-card {
  display: grid;
  gap: 11px;
  min-height: 138px;
}

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

.metric-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal-100);
  color: var(--teal-700);
}

.metric-card strong {
  font-size: 28px;
  line-height: 1;
}

.metric-card span,
.muted,
.table-meta {
  color: var(--ink-650);
  font-size: 13px;
}

.trend {
  color: var(--success);
  font-weight: 800;
}

.trend.down {
  color: var(--danger);
}

.button,
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-800);
  font-weight: 700;
}

.button.primary {
  background: var(--teal-600);
  border-color: var(--teal-600);
  color: white;
}

.button.copper {
  background: var(--copper-600);
  border-color: var(--copper-600);
  color: white;
}

.button.ghost {
  background: transparent;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  border-color: transparent;
  background: transparent;
}

.segmented button.is-active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--teal-700);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.success {
  background: rgba(22, 132, 95, 0.13);
  color: var(--success);
}

.status.warning {
  background: rgba(196, 122, 31, 0.14);
  color: var(--warning);
}

.status.danger {
  background: rgba(194, 75, 69, 0.14);
  color: var(--danger);
}

.status.info {
  background: rgba(52, 123, 156, 0.14);
  color: var(--info);
}

.status.neutral {
  background: var(--surface-2);
  color: var(--ink-650);
}

.data-table {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--ink-500);
  font-size: 12px;
  text-transform: uppercase;
}

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

.cell-title {
  display: grid;
  gap: 2px;
}

.cell-title strong {
  font-size: 14px;
}

.cell-title span {
  color: var(--ink-650);
  font-size: 12px;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--teal-600);
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(32px, 1fr));
  align-items: end;
  gap: 9px;
  min-height: 216px;
  padding-top: 8px;
}

.bar {
  display: grid;
  align-content: end;
  gap: 8px;
  min-width: 0;
  color: var(--ink-650);
  font-size: 12px;
  text-align: center;
}

.bar span {
  display: block;
  min-height: 26px;
  border-radius: 7px 7px 2px 2px;
  background: var(--teal-600);
}

.bar:nth-child(even) span {
  background: var(--copper-600);
}

.sparkline {
  width: 100%;
  height: 52px;
}

.sparkline polyline {
  fill: none;
  stroke: var(--teal-600);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mini-list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.item-card {
  display: grid;
  gap: 12px;
}

.item-media {
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--teal-700);
}

.item-media svg {
  width: 34px;
  height: 34px;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.kanban-column {
  min-width: 220px;
  padding: 12px;
  box-shadow: none;
}

.kanban-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 800;
}

.task-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 9px;
}

.map-panel {
  position: relative;
  min-height: 348px;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 31px, rgba(13, 148, 136, 0.13) 32px),
    linear-gradient(transparent 31px, rgba(185, 111, 61, 0.12) 32px),
    var(--surface);
  background-size: 64px 64px;
}

.route-line {
  position: absolute;
  inset: 72px 54px 72px 64px;
  border: 3px solid var(--teal-600);
  border-left-color: transparent;
  border-bottom-color: var(--copper-600);
  border-radius: 55% 45% 52% 40%;
  transform: rotate(-4deg);
}

.pin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 7px;
  transform: rotate(-45deg);
  background: var(--teal-600);
  color: white;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.26);
}

.pin span {
  transform: rotate(45deg);
  font-size: 12px;
  font-weight: 900;
}

.pin.copper {
  background: var(--copper-600);
  box-shadow: 0 8px 20px rgba(185, 111, 61, 0.26);
}

.phone-frame {
  width: min(320px, 100%);
  min-height: 560px;
  margin-inline: auto;
  padding: 14px;
  background: var(--surface);
}

.phone-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 14px;
}

.phone-card-preview {
  min-height: 154px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--teal-600);
  color: white;
}

.phone-products {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

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

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

.field label {
  color: var(--ink-650);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-950);
  padding: 9px 10px;
}

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

.role-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.role-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink-950);
  color: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.mobile-only {
  display: none;
}

.mobile-backdrop {
  display: none;
}

body.nav-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

body.nav-collapsed .content-shell {
  margin-left: var(--sidebar-collapsed);
}

body.nav-collapsed .brand-copy,
body.nav-collapsed .nav-link span,
body.nav-collapsed .sidebar-footer div {
  display: none;
}

body.nav-collapsed .brand-block,
body.nav-collapsed .nav-link {
  justify-content: center;
}

body.nav-collapsed .sidebar-footer {
  justify-content: center;
}

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

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: auto;
  }

  .kanban-board {
    grid-template-columns: repeat(4, 270px);
  }
}

@media (max-width: 780px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    border: 0;
    background: rgba(23, 21, 18, 0.42);
  }

  .mobile-backdrop.is-visible {
    display: block;
  }

  .content-shell,
  body.nav-collapsed .content-shell {
    margin-left: 0;
  }

  .mobile-only {
    display: inline-flex;
  }

  .desktop-only {
    display: none;
  }

  .topbar {
    padding: 12px 14px;
    gap: 9px;
  }

  .profile-text {
    display: none;
  }

  .profile-chip {
    padding-right: 4px;
  }

  .workspace {
    padding: 20px 14px 34px;
  }

  h1 {
    font-size: 30px;
  }

  .workspace-header {
    display: grid;
    align-items: start;
  }

  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 11px 10px;
  }

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

  table {
    min-width: 680px;
  }

  .search-box input::placeholder {
    color: transparent;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    gap: 6px;
  }

  h1 {
    font-size: 28px;
  }

  .icon-button,
  .chip-button {
    min-width: 40px;
    height: 40px;
  }

  .workspace-actions {
    width: 100%;
  }

  .workspace-actions .button,
  .workspace-actions .segmented {
    flex: 1 1 auto;
  }

  .button {
    min-width: 0;
  }

  .bar-chart {
    grid-template-columns: repeat(7, minmax(24px, 1fr));
    gap: 6px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
