/* ============================================================================
   Aurenza — Logistics decision-support console (loads AFTER tokens.css)
   Deep neutral surfaces, one purposeful green accent, amber/red for warnings.
   Professional data-visualization aesthetic. Desktop / tablet / mobile.
   ============================================================================ */

/* ---------- Dashboard-specific token overrides (dark mode base) ---------- */
:root {
  /* Dark mode surfaces (base) */
  --bg: #080b11;
  --surface: #0e131c;
  --surface-2: #121926;
  --surface-3: #17202e;
  --line: #1d2735;
  --line-2: #283444;

  /* Dark mode text */
  --text: #e9eef6;
  --muted: #9bacc2;
  --faint: #6d7f95;

  /* Dark mode semantic accents */
  --accent: #2fbf7f;
  --accent-2: #5ee0a8;
  --accent-3: #1ea05f;
  --accent-soft: rgba(47, 191, 127, 0.12);
  --accent-line: rgba(47, 191, 127, 0.38);
  --warn: #e2a53a;
  --warn-soft: rgba(226, 165, 58, 0.12);
  --warn-line: rgba(226, 165, 58, 0.32);
  --bad: #e5717a;
  --bad-soft: rgba(229, 113, 122, 0.13);
  --bad-line: rgba(229, 113, 122, 0.4);
  --base: #8aa0b8;
  --plan: #2fbf7f;

  /* Geometry */
  --r-sm: 7px;
  --r: 10px;
  --r-lg: 16px;
  --maxw: 1200px;

  /* Spacing */
  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px;
  --sp5: 24px; --sp6: 32px; --sp7: 48px;

  /* Shadows */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 14px 34px -16px rgba(0, 0, 0, 0.65);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light mode overrides */
[data-theme="light"] {
  --bg: #faf5ea;
  --surface: #ffffff;
  --surface-2: #f3ede2;
  --surface-3: #e8e0d1;
  --line: #e5ddd0;
  --line-2: #ddd5c4;
  --text: #14120e;
  --muted: #6b655a;
  --faint: #9b9486;
  --accent: #0a7a34;
  --accent-2: #0f9d46;
  --accent-3: #085e28;
  --accent-soft: rgba(15, 157, 70, 0.1);
  --accent-line: rgba(15, 157, 70, 0.3);
  --warn: #d4a01e;
  --warn-soft: rgba(212, 160, 30, 0.12);
  --warn-line: rgba(212, 160, 30, 0.35);
  --bad: #d94a4a;
  --bad-soft: rgba(217, 74, 74, 0.12);
  --bad-line: rgba(217, 74, 74, 0.35);
  --base: #5a7f9e;
  --plan: #0a7a34;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 12px 28px -12px rgba(0, 0, 0, 0.12);
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(10, 14, 20, 0.82);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
[data-theme="light"] .appbar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}

.appbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--sp4);
  height: 62px;
  display: flex;
  align-items: center;
  gap: var(--sp4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--accent-2);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 10px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewswitch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  margin-left: var(--sp2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.vtab {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.vtab:hover {
  color: var(--text);
}
.vtab[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
[data-theme="light"] .vtab[aria-selected="true"] {
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.badge-synthetic {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-synthetic .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(226, 165, 58, 0.16);
}

/* Theme toggle in appbar */
.appbar .theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.appbar .theme-toggle:hover {
  background: var(--surface-3);
  border-color: var(--accent-line);
  color: var(--accent);
}
.appbar .theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}
.appbar .theme-toggle .tt-sun {
  display: none;
}
.appbar .theme-toggle[aria-pressed="true"] .tt-moon {
  display: none;
}
.appbar .theme-toggle[aria-pressed="true"] .tt-sun {
  display: block;
}

/* ---------- Body background with subtle radial gradients (dark mode) ---------- */
body {
  background: var(--bg);
  background-image:
    radial-gradient(1100px 460px at 82% -10%, rgba(47, 191, 127, 0.06), transparent 60%),
    radial-gradient(900px 420px at -5% 0%, rgba(90, 120, 160, 0.05), transparent 55%);
}
[data-theme="light"] body {
  background-image: none;
}

/* ---------- Shell ---------- */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp5) var(--sp4) var(--sp7);
}

.view {
  animation: rise var(--dur-3) var(--ease-out) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp4);
  flex-wrap: wrap;
  margin-bottom: var(--sp4);
}
.view-head h1 {
  font-size: clamp(20px, 2.4vw, 26px);
  margin: 0 0 3px;
  font-weight: 680;
}
.view-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.verdict {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--muted);
}
.verdict.up {
  color: var(--accent-2);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.verdict.down {
  color: var(--bad);
  border-color: var(--bad-line);
  background: var(--bad-soft);
}
.verdict.flat {
  color: var(--muted);
}

/* ---------- Notes ---------- */
.notes {
  display: grid;
  gap: var(--sp2);
  margin-bottom: var(--sp4);
}
.note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
}
.note strong {
  font-variant-numeric: tabular-nums;
}
.note.good {
  border-left-color: var(--accent);
}
.note.warn {
  border-left-color: var(--warn);
  background: linear-gradient(90deg, var(--warn-soft), transparent 42%), var(--surface);
}
.note.info {
  border-left-color: var(--base);
}
.note code {
  font-size: 0.86em;
}

/* ---------- Hero (primary metric) ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: var(--sp5);
  align-items: center;
  margin-bottom: var(--sp4);
}
@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; }
}
.eyebrow {
  margin: 0 0 var(--sp3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  font-weight: 700;
  font-family: var(--mono);
}
.hero-figs {
  display: flex;
  align-items: baseline;
  gap: var(--sp5);
  flex-wrap: wrap;
}
.hf {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hf-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-family: var(--mono);
}
.hf-value {
  font-size: clamp(26px, 3.6vw, 40px);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.hf.primary .hf-value {
  color: var(--accent-2);
}
.hf.secondary .hf-value {
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 24px);
}
.hero-delta {
  margin-top: var(--sp4);
  display: flex;
  align-items: center;
  gap: var(--sp2);
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13.5px;
}

.bars-mini {
  display: grid;
  gap: var(--sp3);
}
.bars-mini .bm-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: var(--sp3);
  align-items: center;
}
.bm-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  font-family: var(--mono);
}
.bm-track {
  height: 12px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.bm-fill {
  height: 100%;
  border-radius: 999px;
  transition: width var(--dur-4) var(--ease-out);
}
.bm-fill.baseline {
  background: var(--base);
}
.bm-fill.planner {
  background: linear-gradient(90deg, #17a06b, var(--accent-2));
}

/* ---------- KPI cards ---------- */
.kpi-row {
  display: grid;
  gap: var(--sp4);
  margin-bottom: var(--sp4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp4);
  box-shadow: var(--shadow);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 24px 48px -24px rgba(0, 0, 0, 0.3);
  border-color: var(--line-2);
}
.card-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  margin: 0 0 var(--sp3);
  font-weight: 700;
  font-family: var(--mono);
}
.compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp2);
}
.compare .side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.compare .side .label {
  font-size: 10.5px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
}
.compare .side .value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.compare .side.baseline .value {
  color: var(--base);
}
.compare .side.planner .value {
  color: var(--plan);
}
.compare .arrow {
  color: var(--faint);
  font-size: 16px;
  text-align: center;
}
.delta {
  margin-top: var(--sp3);
  display: flex;
  align-items: center;
  gap: var(--sp2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.stat-big {
  font-size: 24px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.card .sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 6px;
}

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
  font-family: var(--mono);
}
.chip.up {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.chip.down {
  background: var(--bad-soft);
  color: var(--bad);
}
.chip.flat {
  background: rgba(155, 172, 194, 0.14);
  color: var(--muted);
}
.tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.tag.win {
  color: var(--accent-2);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.tag.loss {
  color: var(--bad);
  border-color: var(--bad-line);
  background: var(--bad-soft);
}
.tag.tie {
  color: var(--muted);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
caption {
  text-align: left;
  color: var(--faint);
  font-size: 12px;
  padding-bottom: var(--sp2);
}
th, td {
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--faint);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  font-family: var(--mono);
}
td {
  vertical-align: top;
  white-space: nowrap;
}
td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
tbody tr {
  transition: background var(--dur-1) var(--ease);
}
tbody tr:hover {
  background: var(--surface-2);
}
tbody tr:last-child td {
  border-bottom: 0;
}
td.reason {
  white-space: normal;
  min-width: 240px;
  max-width: 420px;
  color: var(--muted);
  line-height: 1.45;
}
td.wrap {
  white-space: normal;
}
.neg {
  color: var(--bad);
}
.pos {
  color: var(--accent-2);
}
.strong {
  font-weight: 700;
}
.batch-cell {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}
.empty {
  color: var(--faint);
  font-style: italic;
  padding: var(--sp3) 0;
}
.pill-disc {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
}
.pill-none {
  font-size: 11.5px;
  color: var(--faint);
}

/* Responsive table -> stacked cards on narrow screens */
@media (max-width: 720px) {
  table.responsive thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td {
    display: block;
    width: 100%;
  }
  table.responsive tr {
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: var(--sp2);
    padding: var(--sp1) var(--sp2);
    background: var(--surface-2);
  }
  table.responsive td {
    display: flex;
    justify-content: space-between;
    gap: var(--sp3);
    border-bottom: 1px dashed var(--line);
    padding: 7px 4px;
    white-space: normal;
    text-align: right;
  }
  table.responsive td:last-child {
    border-bottom: 0;
  }
  table.responsive td::before {
    content: attr(data-label);
    text-align: left;
    color: var(--faint);
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.05em;
    font-weight: 700;
    flex: none;
    font-family: var(--mono);
  }
  table.responsive td.reason {
    min-width: 0;
  }
}

/* ---------- Skeleton loaders ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--surface-2); }
}
.skeleton-text {
  height: 1em;
  margin-bottom: var(--sp2);
}
.skeleton-title {
  height: 1.5em;
  width: 60%;
  margin-bottom: var(--sp3);
}
.skeleton-card {
  height: 120px;
  border-radius: var(--r-lg);
}
.skeleton-row {
  height: 40px;
  margin-bottom: var(--sp2);
}
.skeleton-kpi {
  height: 100px;
}

/* ---------- Empty states ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp8) var(--sp4);
  text-align: center;
  color: var(--muted);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp3);
  opacity: 0.5;
}
.empty-state h3 {
  margin: 0 0 var(--sp2);
  font-size: 18px;
  color: var(--text);
}
.empty-state p {
  margin: 0;
  max-width: 300px;
}

/* ---------- Reconciliation ---------- */
.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp4);
  align-items: start;
  margin-bottom: var(--sp4);
}
@media (max-width: 980px) {
  .panel-grid { grid-template-columns: 1fr; }
}
.panel-grid > .panel {
  margin-bottom: 0;
}
.recon-row {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  flex-wrap: wrap;
}
.recon-row:last-child {
  border-bottom: 0;
}
.ok {
  color: var(--accent-2);
  font-weight: 700;
}
.bad {
  color: var(--bad);
  font-weight: 700;
}
.recon-row .detail {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

/* ---------- Charts (SVG-based) ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp4);
  margin-bottom: var(--sp4);
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.chart-title {
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 var(--sp1);
}
.chart-note {
  font-size: 12px;
  color: var(--faint);
  margin: 0 0 var(--sp4);
}

/* Stacked bar chart */
.stack {
  display: flex;
  height: 16px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.stack .seg {
  height: 100%;
  transition: width var(--dur-4) var(--ease-out);
}
.seg.win {
  background: linear-gradient(90deg, #17a06b, var(--accent-2));
}
.seg.tie {
  background: #3a4b60;
}
.seg.loss {
  background: var(--bad);
}
.stack-row {
  margin-bottom: var(--sp3);
}
.stack-head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp2);
  font-size: 12.5px;
  margin-bottom: 6px;
}
.stack-head .lbl {
  color: var(--text);
  font-weight: 600;
}
.stack-head .val {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.legend {
  display: flex;
  gap: var(--sp4);
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--sp2);
}
.legend .k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.legend .sw.win {
  background: var(--accent-2);
}
.legend .sw.tie {
  background: #3a4b60;
}
.legend .sw.loss {
  background: var(--bad);
}

/* Histogram SVG */
.hist {
  width: 100%;
  height: auto;
  display: block;
}
.hist .bar {
  fill: var(--accent);
  opacity: 0.85;
}
.hist .bar.neg {
  fill: var(--bad);
  opacity: 0.8;
}
.hist .axis {
  stroke: var(--line-2);
}
.hist .zero {
  stroke: var(--faint);
}
.hist .tick {
  fill: var(--faint);
  font-size: 10px;
  font-family: var(--sans);
}

/* ---------- Scenario explorer ---------- */
.field {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  font-size: 12.5px;
  color: var(--muted);
}
.field > span {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  color: var(--faint);
  font-weight: 700;
  font-family: var(--mono);
}
select {
  appearance: none;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 8px 34px 8px 12px;
  font: inherit;
  font-size: 13px;
  max-width: min(420px, 68vw);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236d7f95' stroke-width='2.4' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
select:hover {
  border-color: var(--accent-line);
}
[data-theme="light"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239b9486' stroke-width='2.4' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
}

.scenario-meta {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  flex-wrap: wrap;
  margin-bottom: var(--sp4);
}
.bars {
  display: grid;
  gap: var(--sp4);
}
.bar-group .bar-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin: 4px 0;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width var(--dur-4) var(--ease-out);
}
.bar .fill-baseline {
  background: var(--base);
}
.bar .fill-planner {
  background: linear-gradient(90deg, #17a06b, var(--accent-2));
}
.bar-row {
  display: grid;
  grid-template-columns: 74px 1fr 100px;
  align-items: center;
  gap: var(--sp3);
  font-size: 12.5px;
}
.bar-row .who {
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--mono);
}
.bar-row .amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- States ---------- */
.state {
  border-radius: var(--r-lg);
  padding: var(--sp5);
  font-size: 14px;
  margin-bottom: var(--sp4);
}
.state-loading {
  display: flex;
  align-items: center;
  gap: var(--sp3);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.state-error {
  border: 1px solid var(--bad-line);
  background: var(--bad-soft);
  color: #ffd9dc;
}
.state-error code {
  background: rgba(0,0,0,.25);
  border-color: rgba(255,255,255,.12);
  color: #ffd9dc;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--sp4) var(--sp6);
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.7;
}

/* ---------- Keyboard shortcuts hint ---------- */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--sp1);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.kbd-hint kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 4px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 3px;
}

/* ---------- Panel base ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp5);
  margin-bottom: var(--sp4);
  min-width: 0;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 9px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp3);
  flex-wrap: wrap;
  margin-bottom: var(--sp4);
}
.panel-sub {
  font-size: 12.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}
.swatch.planner,
.swatch.plan {
  background: var(--plan);
}
.swatch.baseline {
  background: var(--base);
}
.accent-planner {
  border-top: 2px solid var(--accent-line);
}
.accent-baseline {
  border-top: 2px solid var(--base);
}

/* ---------- Screen reader only ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Narrow screens ---------- */
@media (max-width: 620px) {
  .appbar-inner {
    height: auto;
    padding: var(--sp3) var(--sp4);
    flex-wrap: wrap;
    row-gap: var(--sp2);
  }
  .viewswitch {
    order: 3;
    margin-left: 0;
    width: 100%;
  }
  .vtab {
    flex: 1;
  }
  .badge-synthetic {
    margin-left: auto;
  }
  .shell {
    padding: var(--sp4) var(--sp4) var(--sp6);
  }
  .panel {
    padding: var(--sp4);
  }
  .recon-row .detail {
    margin-left: 0;
    width: 100%;
  }
  .kpi-row {
    grid-template-columns: 1fr;
  }
  .compare {
    grid-template-columns: 1fr;
    gap: var(--sp3);
  }
  .compare .arrow {
    display: none;
  }
}