/* ==========================================================================
   SOLERA — Run Ledger
   Self-contained: no external fonts, no CDN, no build step.
   ========================================================================== */

:root {
  --paper:        #FAF8F5;
  --surface:      #FFFFFF;
  --surface-2:    #F4F1EC;
  --surface-3:    #EDE8E0;
  --ink:          #191512;
  --ink-2:        #4A423B;
  --ink-3:        #7A7169;
  --ink-4:        #A79E95;
  --line:         #E3DCD1;
  --line-2:       #D2C9BB;

  /* --brand is the exact copper from the Proximo logo lockup. It is used
     for the mark, chart fills and bars, where large-area contrast rules apply.
     --accent is the text-safe companion: on a light background the brand
     copper only reaches ~3:1 against white, so small UI text uses a deepened
     shade of the same hue. */
  --brand:        #C77A50;
  --accent:       #9F5530;
  --accent-ink:   #FFFFFF;
  --accent-soft:  #FBF1EA;
  --accent-line:  #E7CCB9;

  --up:           #15803D;
  --up-soft:      #E8F4EC;
  --down:         #B0243C;
  --down-soft:    #FBEAEE;
  --warn:         #A16207;
  --warn-soft:    #FBF3E0;

  --shadow-1: 0 1px 2px rgba(25,21,18,.05), 0 1px 3px rgba(25,21,18,.04);
  --shadow-2: 0 2px 4px rgba(25,21,18,.05), 0 8px 24px rgba(25,21,18,.07);
  --shadow-3: 0 8px 16px rgba(25,21,18,.08), 0 24px 60px rgba(25,21,18,.14);

  --r-sm: 5px; --r-md: 8px; --r-lg: 12px;
  --rail-w: 244px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo,
          Consolas, monospace;
}

:root[data-theme="dark"] {
  --paper:        #110E0C;
  --surface:      #1A1613;
  --surface-2:    #221D19;
  --surface-3:    #2C2620;
  --ink:          #F5F1EB;
  --ink-2:        #C9C0B5;
  --ink-3:        #9A9086;
  --ink-4:        #6F665D;
  --line:         #332C25;
  --line-2:       #443B32;

  /* On the dark ground the brand copper clears 6:1, so it is used directly. */
  --brand:        #C77A50;
  --accent:       #C77A50;
  --accent-ink:   #16100C;
  --accent-soft:  #2B1E15;
  --accent-line:  #4C3524;

  --up:           #4ADE80;
  --up-soft:      #16281D;
  --down:         #FB7185;
  --down-soft:    #2E1720;
  --warn:         #FBBF24;
  --warn-soft:    #2A2113;

  --shadow-1: 0 1px 2px rgba(0,0,0,.34);
  --shadow-2: 0 2px 6px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.34);
  --shadow-3: 0 10px 20px rgba(0,0,0,.44), 0 30px 70px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

/* The UA stylesheet's [hidden] { display: none } is beaten by any author rule
   that sets `display` (e.g. .tray is display:flex), which left the review-pack
   tray on screen with nothing in it. Make `hidden` win everywhere. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -0.014em; }

.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;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ══════════════════════════ LAYOUT ══════════════════════════ */

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

/* ── sidebar ── */
.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}

.rail-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.mark { width: 32px; height: 32px; flex: none; }
.mark svg { width: 100%; height: 100%; display: block; }
.mark rect { fill: var(--brand); }
.mark path { stroke: #fff; }
.brand-name {
  font-size: 15px; font-weight: 700; letter-spacing: .13em; line-height: 1.1;
}
.brand-sub { font-size: 10.5px; color: var(--ink-3); letter-spacing: .04em; }

.rail-client-brand {
  padding: 18px 18px 14px; border-bottom: 1px solid var(--line);
}
.client-logo { display: block; width: 100%; max-width: 168px; height: auto; }
.client-logo-fallback { display: flex; align-items: center; gap: 9px; }
.clf-mark {
  width: 18px; height: 22px; flex: none;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  border: 3px solid var(--brand); border-right-color: transparent;
  border-bottom-color: transparent; transform: rotate(18deg);
}
.clf-word {
  font-size: 17px; font-weight: 300; letter-spacing: .21em; color: var(--ink);
}
.rail-client-brand .client-meta { margin-top: 9px; }

.rail-stats {
  display: flex; flex-direction: column; gap: 7px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.rstat { display: flex; align-items: baseline; gap: 8px; }
.rstat-v {
  font-size: 13px; font-weight: 680; color: var(--brand);
  font-variant-numeric: tabular-nums; min-width: 46px;
}
.rstat-l { font-size: 10.5px; color: var(--ink-3); }

.rail-foot-note {
  font-size: 9.5px; color: var(--ink-4); line-height: 1.55; margin-top: 8px;
}

.rail-client { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.client-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-4); font-weight: 600;
}
.client-name { font-size: 14px; font-weight: 640; margin-top: 3px; }
.client-meta { font-size: 11px; color: var(--ink-3); }

.rail-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-heading {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-4); font-weight: 650; padding: 12px 8px 6px;
}
.nav-heading:first-child { padding-top: 2px; }

.nav-item {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 8px 9px; border-radius: var(--r-md);
  text-decoration: none; color: var(--ink-2);
  transition: background .13s, color .13s;
}
a.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--accent-soft); color: var(--ink); }
.nav-item.is-active .nav-num { color: var(--accent); }
.nav-item.is-next { opacity: .5; cursor: default; }

.nav-num {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--ink-4); padding-top: 2px; min-width: 20px;
}
.nav-text { display: flex; flex-direction: column; min-width: 0; }
.nav-text strong { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.nav-text em {
  font-style: normal; font-size: 10.5px; color: var(--ink-3); line-height: 1.35;
}

.rail-foot { padding: 12px; border-top: 1px solid var(--line); }
.rail-build {
  font-family: var(--mono); font-size: 9.5px; color: var(--ink-4);
  margin-top: 8px; line-height: 1.5;
}
.theme-icon {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  border: 1.5px solid var(--ink-2); display: inline-block;
}

/* ── main ── */
.main {
  flex: 1; min-width: 0; padding: 0 26px 96px;
  max-width: 1760px;
}

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; padding: 26px 0 18px;
  position: sticky; top: 0; z-index: 20;
  /* Solid, not a fade. A gradient to transparent let scrolled content
     (the cause legend's layer labels) show through behind the header. */
  background: var(--paper);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%;
  height: 14px; pointer-events: none;
  background: linear-gradient(var(--paper), transparent);
}
.page-title { font-size: 25px; letter-spacing: -0.02em; }
.page-sub {
  margin: 4px 0 0; color: var(--ink-3); font-size: 12.5px; max-width: 680px;
}
.topbar-right { display: flex; gap: 8px; flex: none; }

/* ── demo banner ── */
.demo-banner {
  position: relative;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r-md); padding: 10px 40px 10px 13px;
  font-size: 11.5px; color: var(--ink-2); line-height: 1.55;
  margin-bottom: 16px;
}
.demo-banner strong { color: var(--ink); }
.banner-x {
  position: absolute; top: 6px; right: 8px;
  background: none; border: 0; font-size: 17px; line-height: 1;
  color: var(--ink-3); cursor: pointer; padding: 3px 6px; border-radius: 4px;
}
.banner-x:hover { background: rgba(0,0,0,.06); color: var(--ink); }

/* ══════════════════════════ BUTTONS ══════════════════════════ */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2);
  font-family: inherit; font-size: 12.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn-accent {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-accent:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.ico { width: 13px; height: 13px; flex: none; }

/* ══════════════════════════ RUN STRIP ══════════════════════════ */

.runstrip {
  display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  margin-bottom: 14px; overflow: hidden;
}
.runcard { padding: 13px 18px; flex: 0 0 auto; }
.runcard + .runcard { border-left: 1px solid var(--line); }
.runcard-grow { flex: 1; }
.run-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-4); font-weight: 650;
}
.run-value { font-size: 14px; font-weight: 640; margin-top: 3px; }
.run-meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.run-arrow {
  display: flex; align-items: center; padding: 0 4px; color: var(--ink-4);
}
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
}
.pill-live { background: var(--up-soft); color: var(--up); }
.pill-closed { background: var(--surface-3); color: var(--ink-3); }
.pill-dot {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.run-select {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 5px 8px; cursor: pointer; margin-top: 2px;
}

/* ══════════════════════════ KPI TILES ══════════════════════════ */

.kpis {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 13px 15px 14px;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; min-width: 0;
}
.kpi-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-4); font-weight: 650;
}
.kpi-value {
  font-size: 24px; font-weight: 660; letter-spacing: -0.028em;
  margin-top: 6px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 13px; font-weight: 550; color: var(--ink-3); }
.kpi-sub {
  font-size: 11px; color: var(--ink-3); margin-top: 5px; line-height: 1.45;
}
.kpi-up .kpi-value { color: var(--up); }
.kpi-down .kpi-value { color: var(--down); }
.kpi-flag { border-color: var(--accent-line); background: var(--accent-soft); }
.kpi-flag .kpi-value { color: var(--accent); }

/* ══════════════════════════ PANELS ══════════════════════════ */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  margin-bottom: 14px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; padding: 14px 18px 12px;
}
.panel-head h2 { font-size: 14.5px; }
.panel-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-3); }
.panel-head-right {
  display: flex; align-items: center; gap: 10px; flex: none;
  font-size: 11.5px; color: var(--ink-3);
}
.panel-cause { padding-bottom: 6px; }

/* ── cause mix bar ── */
.cause-mix { padding: 0 18px 16px; }
.cause-bar {
  display: flex; height: 30px; border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface-3); margin-bottom: 12px;
}
.cause-seg {
  border: 0; cursor: pointer; padding: 0; position: relative;
  transition: filter .13s, opacity .13s;
  min-width: 2px;
}
.cause-seg:hover { filter: brightness(1.14); }
.cause-seg.is-dim { opacity: .28; }
.cause-seg span {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 10.5px; font-weight: 650;
  text-shadow: 0 1px 2px rgba(0,0,0,.28); pointer-events: none;
}
.cause-legend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 8px 16px;
}
.legend-item {
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  background: none; border: 0; padding: 4px 6px; border-radius: var(--r-sm);
  cursor: pointer; font-family: inherit; color: inherit;
  transition: background .13s;
}
.legend-item:hover { background: var(--surface-2); }
.legend-item.is-on { background: var(--surface-3); }
.legend-swatch {
  width: 10px; height: 10px; border-radius: 3px; flex: none; margin-top: 3px;
}
/* These are spans inside a span, so they need an explicit block display —
   without it the label and its value render on one run-on line. */
.legend-body { min-width: 0; display: block; }
.legend-name {
  display: block; font-size: 12px; font-weight: 600; line-height: 1.35;
}
.legend-val {
  display: block; font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; line-height: 1.4;
}
.legend-layer {
  display: block; font-size: 9.5px; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: .07em; font-weight: 600;
  margin-top: 1px;
}

/* ══════════════════════════ TABS ══════════════════════════ */

.tabs {
  display: flex; gap: 2px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 14px; margin-bottom: -1px;
  font-family: inherit; font-size: 13px; font-weight: 570;
  color: var(--ink-3); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.tabpane { display: none; }
.tabpane.is-active { display: block; }

/* ══════════════════════════ FILTERS ══════════════════════════ */

.filters {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 13px 16px;
  margin-bottom: 12px; box-shadow: var(--shadow-1);
}
.filter-row {
  display: grid;
  grid-template-columns: 1.45fr .92fr .92fr 1.02fr .92fr 1.02fr .95fr;
  gap: 10px;
}
.filter-row-2 {
  grid-template-columns: 1.25fr 1fr 1fr 1.8fr auto;
  margin-top: 10px;
}
.field { display: flex; flex-direction: column; min-width: 0; }
.field > label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .085em;
  color: var(--ink-4); font-weight: 650; margin-bottom: 4px;
}
/* ── multi-select ─────────────────────────────────────────────────────── */
.ms { position: relative; }
.ms-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; font-family: inherit; font-size: 12.5px; text-align: left;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 7px 9px; cursor: pointer; min-width: 0;
}
.ms-btn:hover { border-color: var(--ink-4); }
.ms.is-open .ms-btn { outline: 2px solid var(--accent); outline-offset: -1px; }
.ms.is-set .ms-btn { background: var(--accent-soft); border-color: var(--accent-line); }
.ms-btn-l {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-3);
}
.ms-btn-l.is-set { color: var(--ink); font-weight: 570; }
.ms-caret { width: 9px; height: 6px; flex: none; color: var(--ink-4); }

.ms-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 100%; width: max-content; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  padding: 7px; display: flex; flex-direction: column;
}
.ms-panel.is-up { top: auto; bottom: calc(100% + 4px); }
.ms-search {
  font-family: inherit; font-size: 12px; width: 100%;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 8px; margin-bottom: 5px;
}
.ms-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ms-opts { max-height: 246px; overflow-y: auto; overscroll-behavior: contain; }
.ms-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 12.5px; white-space: nowrap;
}
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input { accent-color: var(--accent); width: 13px; height: 13px; margin: 0; flex: none; }
.ms-opt-l { flex: 1; }
.ms-opt-g { font-size: 10px; color: var(--ink-4); }
.ms-empty { padding: 12px 8px; font-size: 12px; color: var(--ink-4); text-align: center; }
.ms-foot {
  display: flex; gap: 4px; padding-top: 6px; margin-top: 5px;
  border-top: 1px solid var(--line);
}
.ms-link {
  flex: 1; background: none; border: 0; font-family: inherit; font-size: 11.5px;
  color: var(--ink-3); cursor: pointer; padding: 4px; border-radius: var(--r-sm);
}
.ms-link:hover { background: var(--surface-2); color: var(--ink); }

.field select, .field input[type="search"] {
  font-family: inherit; font-size: 12.5px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 7px 9px; width: 100%; min-width: 0;
}
.field select:focus, .field input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
  background: var(--surface);
}
.search-wrap { position: relative; }
.search-ico {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: var(--ink-4); pointer-events: none;
}
.search-wrap input { padding-left: 28px !important; }

.field-checks .checks { display: flex; gap: 14px; padding-top: 7px; }
.chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.chk input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
.field-reset { justify-content: flex-end; }

.active-filters {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.active-filters:empty { display: none; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3); border: 1px solid var(--line-2);
  border-radius: 99px; padding: 3px 5px 3px 10px;
  font-size: 11px; color: var(--ink-2);
}
.fchip b { font-weight: 640; color: var(--ink); }
.fchip button {
  background: none; border: 0; cursor: pointer; color: var(--ink-3);
  font-size: 13px; line-height: 1; padding: 1px 4px; border-radius: 50%;
}
.fchip button:hover { background: rgba(0,0,0,.09); color: var(--ink); }

/* ══════════════════════════ TABLE ══════════════════════════ */

.tablewrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1);
}
.panel .tablewrap { border: 0; border-radius: 0; box-shadow: none; }

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

.ledger thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 9px 12px; text-align: left;
  font-size: 10px; text-transform: uppercase; letter-spacing: .075em;
  font-weight: 680; color: var(--ink-3); white-space: nowrap;
  position: sticky; top: 0; z-index: 4;
}
.ledger thead th.c-num { text-align: right; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--ink); }
.sortable.is-sorted { color: var(--accent); }
.sortable.is-sorted::after { content: " ↓"; font-size: 9px; }
.sortable.is-sorted.is-asc::after { content: " ↑"; }

.ledger tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .1s;
}
.ledger tbody tr:last-child { border-bottom: 0; }
.ledger tbody tr:hover { background: var(--surface-2); }
.ledger tbody tr.is-open { background: var(--accent-soft); }
.ledger td { padding: 9px 12px; vertical-align: middle; }
.ledger td.c-num {
  text-align: right; font-variant-numeric: tabular-nums;
  white-space: nowrap; font-size: 12.5px;
}

.c-pack { width: 34px; padding-right: 0 !important; }
.pack-all {
  width: 14px; height: 14px; margin: 0; cursor: pointer;
  accent-color: var(--accent); vertical-align: middle;
}
.pack-all:disabled { opacity: .4; cursor: default; }
.pack-btn {
  width: 20px; height: 20px; border-radius: 4px;
  border: 1.5px solid var(--line-2); background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 12px; line-height: 1; padding: 0;
}
.pack-btn:hover { border-color: var(--accent); color: var(--ink-4); }
.pack-btn.is-on {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.cell-market { display: flex; flex-direction: column; gap: 1px; }
.mk-name { font-size: 12.5px; font-weight: 570; }
.mk-meta { font-size: 10.5px; color: var(--ink-4); }

.cell-sku { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sku-desc {
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 330px;
}
.sku-code {
  font-family: var(--mono); font-size: 10px; color: var(--ink-4);
  letter-spacing: -.01em;
}

.c-period { white-space: nowrap; font-size: 12.5px; }
.prior-val { color: var(--ink-3); }

.delta { font-weight: 640; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }
.delta-pct { font-size: 12px; }

.c-attr { width: 290px; }
.attr-cell { display: flex; flex-direction: column; gap: 5px; }
.attr-bar {
  display: flex; height: 5px; border-radius: 3px; overflow: hidden;
  background: var(--surface-3); width: 100%; max-width: 250px;
}
.attr-seg { min-width: 2px; }
.attr-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 1.5px 7px;
  border-radius: 99px; border: 1px solid transparent; white-space: nowrap;
}
.chip-dot { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.chip-warn {
  background: var(--down-soft); color: var(--down);
  border-color: color-mix(in srgb, var(--down) 25%, transparent);
}
.chip-new {
  background: var(--up-soft); color: var(--up);
  border-color: color-mix(in srgb, var(--up) 25%, transparent);
}

.table-empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.table-empty p { margin: 0 0 4px; font-size: 13px; }

/* ── pager ── */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 2px 0; font-size: 12px; color: var(--ink-3);
}
.pager-btns { display: flex; gap: 6px; align-items: center; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:disabled:hover { background: var(--surface); border-color: var(--line-2); }

/* ══════════════════════════ OVERRIDE TABLE ══════════════════════════ */

.ledger-ovr td { font-size: 12.5px; }
.c-reason { max-width: 320px; }
.reason-text {
  font-size: 11.5px; color: var(--ink-2); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.reason-none {
  font-size: 11px; font-weight: 650; color: var(--down);
  background: var(--down-soft); padding: 2px 8px; border-radius: 99px;
  display: inline-block;
}
.reason-cat {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-4); font-weight: 650;
}
.who { display: flex; flex-direction: column; gap: 1px; }
.who-name { font-size: 12.5px; font-weight: 550; }
.who-role { font-size: 10.5px; color: var(--ink-4); }

/* ══════════════════════════ ROLLUP ══════════════════════════ */

.rollup-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
}
.rollup-list { padding: 4px 18px 16px; }
.roll-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.roll-row:last-child { border-bottom: 0; }
.roll-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 5px;
}
.roll-name { font-size: 12.5px; font-weight: 570; }
.roll-nums {
  font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.roll-bar {
  display: flex; height: 7px; border-radius: 4px; overflow: hidden;
  background: var(--surface-3);
}

/* ══════════════════════════ DRAWER ══════════════════════════ */

.drawer-scrim {
  position: fixed; inset: 0; background: rgba(20,17,14,.34);
  z-index: 60; animation: fade .16s ease;
  backdrop-filter: blur(1.5px);
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(680px, 94vw);
  background: var(--paper); z-index: 61;
  box-shadow: var(--shadow-3);
  overflow-y: auto; overscroll-behavior: contain;
  animation: slidein .2s cubic-bezier(.22,.8,.3,1);
}
@keyframes slidein { from { transform: translateX(26px); opacity: .4 } to { transform: none; opacity: 1 } }

.drawer-inner { padding: 0 0 40px; }

.dw-head {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 16px 22px 14px;
}
.dw-head-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
}
.dw-eyebrow {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-4); font-weight: 650; margin-bottom: 4px;
}
.dw-title { font-size: 17px; letter-spacing: -0.018em; line-height: 1.3; }
.dw-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.dw-close {
  background: none; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  width: 28px; height: 28px; cursor: pointer; color: var(--ink-3);
  font-size: 16px; line-height: 1; flex: none;
}
.dw-close:hover { background: var(--surface-2); color: var(--ink); }

.dw-delta {
  display: flex; align-items: baseline; gap: 12px; margin-top: 12px;
  flex-wrap: wrap;
}
.dw-delta-big {
  font-size: 30px; font-weight: 680; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.dw-delta-meta { font-size: 12px; color: var(--ink-3); }
.dw-delta-meta b { color: var(--ink); font-variant-numeric: tabular-nums; }

.dw-section { padding: 18px 22px 4px; }
.dw-section h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: .095em;
  color: var(--ink-4); font-weight: 680; margin-bottom: 10px;
}
.dw-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 15px 17px; box-shadow: var(--shadow-1);
}
.dw-card + .dw-card { margin-top: 10px; }

/* narrative */
.narrative p { margin: 0 0 10px; font-size: 13px; line-height: 1.62; color: var(--ink-2); }
.narrative p:last-child { margin-bottom: 0; }
.narrative p.n-head { font-size: 14px; color: var(--ink); font-weight: 570; }
.narrative p.n-recon {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  background: var(--surface-2); padding: 9px 11px; border-radius: var(--r-sm);
  border-left: 2.5px solid var(--accent); line-height: 1.6;
}
.narr-actions { display: flex; gap: 8px; margin-top: 12px; }

/* waterfall + series charts */
.chart-wrap { width: 100%; overflow: visible; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-note {
  font-size: 11px; color: var(--ink-3); margin-top: 8px; line-height: 1.5;
}
.chart-legend {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px;
  font-size: 11px; color: var(--ink-3);
}
.cl-item { display: inline-flex; align-items: center; gap: 6px; }
.cl-key { width: 16px; height: 2.5px; border-radius: 2px; }
.cl-key.dash {
  background: none !important;
  border-top: 2px dashed var(--ink-4); height: 0;
}

/* stage list */
.stage {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
}
.stage + .stage { margin-top: 8px; }
.stage-head {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; cursor: pointer; background: none; border: 0;
  width: 100%; text-align: left; font-family: inherit; color: inherit;
}
.stage-head:hover { background: var(--surface-2); }
.stage-rule { width: 3px; align-self: stretch; border-radius: 2px; flex: none; }
.stage-title { flex: 1; min-width: 0; }
.stage-name { font-size: 13px; font-weight: 600; }
.stage-layer {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-4); font-weight: 650;
}
.stage-delta {
  font-size: 14px; font-weight: 660; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stage-caret { color: var(--ink-4); font-size: 11px; transition: transform .16s; }
.stage.is-open .stage-caret { transform: rotate(90deg); }
.stage-body {
  padding: 0 14px 14px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.6;
}
.stage-body > p:first-child { margin-top: 12px; }
.stage-desc { color: var(--ink-3); font-size: 11.5px; font-style: italic; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 10px 0 0; }
.kv dt {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-4); font-weight: 650; padding-top: 2px; white-space: nowrap;
}
.kv dd { margin: 0; font-size: 12.5px; }

.minitable { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; }
.minitable th {
  text-align: left; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-4); font-weight: 680;
  padding: 5px 8px; border-bottom: 1px solid var(--line);
}
.minitable td {
  padding: 6px 8px; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.minitable tr:last-child td { border-bottom: 0; }
.minitable .c-num { text-align: right; }

.paramgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 8px; margin-top: 8px;
}
.param {
  background: var(--surface-2); border-radius: var(--r-sm); padding: 7px 9px;
}
.param-k {
  font-family: var(--mono); font-size: 10px; color: var(--ink-4);
}
.param-v {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.param-v .was { color: var(--ink-4); font-weight: 400; }

.callout {
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
  border-radius: var(--r-md); padding: 10px 13px; font-size: 12px;
  color: var(--ink-2); line-height: 1.55; margin-top: 10px;
}
.callout-bad {
  background: var(--down-soft);
  border-color: color-mix(in srgb, var(--down) 26%, transparent);
}
.callout strong { color: var(--ink); }

.factbar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.fact { background: var(--surface); padding: 10px 12px; }
.fact-k {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-4); font-weight: 650;
}
.fact-v {
  font-size: 13px; font-weight: 600; margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.fact-v small { font-weight: 400; color: var(--ink-3); font-size: 11px; }

.model-swap {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.model-box {
  flex: 1; min-width: 180px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px;
}
.model-box.is-new { border-color: var(--accent); background: var(--accent-soft); }
.model-k {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-4); font-weight: 650;
}
.model-n { font-size: 13px; font-weight: 600; margin-top: 2px; }
.model-s { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.model-note { font-size: 11px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }
.swap-arrow { color: var(--ink-4); font-size: 17px; flex: none; }

/* ══════════════════════════ TRAY & TOAST ══════════════════════════ */

.tray {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 55; display: flex; align-items: center; gap: 20px;
  background: var(--ink); color: var(--paper);
  border-radius: 99px; padding: 9px 12px 9px 20px;
  box-shadow: var(--shadow-3);
  animation: trayup .2s cubic-bezier(.22,.8,.3,1);
}
@keyframes trayup { from { transform: translate(-50%, 14px); opacity: 0 } to { transform: translateX(-50%); opacity: 1 } }
.tray-left { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.tray-count {
  background: var(--accent); color: #fff; border-radius: 99px;
  min-width: 22px; height: 22px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 11.5px; font-weight: 700; padding: 0 7px;
}
.tray-right { display: flex; gap: 6px; }
.tray .btn-ghost { color: var(--ink-4); }
.tray .btn-ghost:hover { background: rgba(255,255,255,.1); color: var(--paper); }

.toast {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%);
  z-index: 90; background: var(--ink); color: var(--paper);
  padding: 9px 16px; border-radius: 99px; font-size: 12.5px;
  box-shadow: var(--shadow-2); animation: trayup .16s ease;
}

/* ══════════════════════════ SKELETON ══════════════════════════ */

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite linear;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }
.skel-row { height: 38px; margin: 1px 0; }

/* ══════════════════════════ RESPONSIVE ══════════════════════════ */

@media (max-width: 1500px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .c-attr { width: 230px; }
}
@media (max-width: 1180px) {
  .rail { position: fixed; transform: translateX(-100%); }
  .main { padding-left: 18px; padding-right: 18px; }
  .filter-row, .filter-row-2 { grid-template-columns: repeat(2, 1fr); }
  .rollup-grid { grid-template-columns: 1fr; }
  .runstrip { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .filter-row, .filter-row-2 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .factbar { grid-template-columns: repeat(2, 1fr); }
  .c-market, .c-period, .c-attr { display: none; }
  .drawer { width: 100vw; }
}

/* ══════════════════════════ ASK (grounded Q&A) ══════════════════════════ */

.ask-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden;
}
.ask-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.ask-spark { width: 15px; height: 15px; color: var(--accent); flex: none; }
.ask-head-t { flex: 1; min-width: 0; }
.ask-head-t strong { font-size: 12.5px; font-weight: 640; display: block; }
.ask-head-t span { font-size: 10.5px; color: var(--ink-3); }

.ask-thread { padding: 4px 15px 0; max-height: 460px; overflow-y: auto; }
.ask-turn { padding: 11px 0; border-bottom: 1px solid var(--line); }
.ask-turn:last-child { border-bottom: 0; }
.ask-q {
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  display: flex; gap: 8px; margin-bottom: 8px;
}
.ask-q::before {
  content: "?"; flex: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 11px;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  margin-top: 1px;
}
.ask-a { font-size: 12.5px; line-height: 1.62; color: var(--ink-2); }
.ask-a p { margin: 0 0 9px; }
.ask-a p:last-child { margin-bottom: 0; }
.ask-a ul { margin: 0 0 9px; padding-left: 17px; }
.ask-a li { margin-bottom: 4px; }
.ask-a strong { color: var(--ink); font-weight: 640; }
.ask-a em { font-style: italic; }
.ask-cursor {
  display: inline-block; width: 7px; height: 13px; background: var(--accent);
  vertical-align: -2px; animation: blink .9s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.ask-foot { padding: 11px 15px 13px; border-top: 1px solid var(--line); }
.ask-row { display: flex; gap: 7px; }
.ask-input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 12.5px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 8px 11px; resize: none; line-height: 1.45; max-height: 90px;
}
.ask-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.ask-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.ask-chip {
  font-family: inherit; font-size: 11px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 99px; padding: 4px 11px; cursor: pointer; text-align: left;
}
.ask-chip:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); }
.ask-note { font-size: 10.5px; color: var(--ink-4); margin-top: 9px; line-height: 1.5; }
.ask-off {
  padding: 15px; font-size: 12px; color: var(--ink-3); line-height: 1.55;
}
.ask-off strong { color: var(--ink); }

/* ══════════════════════ FEATURE 2 — HISTORY CLINIC ══════════════════════ */

.feature { display: none; }
.feature.is-active { display: block; }

.scanstrip {
  display: flex; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  margin-bottom: 14px; overflow: hidden;
}
.scanstrip .runcard + .runcard { border-left: 1px solid var(--line); }

/* ── finding cards ── */
.classcards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.classcard {
  text-align: left; font-family: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--cc);
  border-radius: var(--r-lg); padding: 13px 15px;
  box-shadow: var(--shadow-1); color: inherit;
  transition: background .13s, border-color .13s;
}
.classcard:hover { background: var(--surface-2); }
.classcard.is-on { background: var(--accent-soft); border-color: var(--accent-line); border-left-color: var(--cc); }
.cc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex: none; }
.cc-name { font-size: 13px; font-weight: 640; flex: 1; }
.cc-n { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cc-desc { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; min-height: 34px; }
.cc-foot {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 9px;
  padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-4);
}
.cc-imp { font-variant-numeric: tabular-nums; font-weight: 600; }

.tab-count {
  font-size: 10.5px; color: var(--ink-4); font-variant-numeric: tabular-nums;
  background: var(--surface-3); padding: 1px 6px; border-radius: 99px;
  margin-left: 3px;
}
.tab.is-active .tab-count { background: var(--accent-soft); color: var(--accent); }

.c-cust { max-width: 190px; }
.cust {
  font-size: 11.5px; color: var(--ink-2); display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.status-pill {
  display: inline-block; font-size: 10.5px; font-weight: 650;
  padding: 2px 9px; border-radius: 99px; white-space: nowrap;
}
.st-open { background: var(--accent-soft); color: var(--accent); }
.st-accepted { background: var(--up-soft); color: var(--up); }
.st-edited { background: var(--warn-soft); color: var(--warn); }
.st-rejected { background: var(--surface-3); color: var(--ink-3); }

.btn-reject {
  color: var(--down); border-color: color-mix(in srgb, var(--down) 38%, transparent);
}
.btn-reject:hover { background: var(--down-soft); border-color: var(--down); }

.tray-clinic .tray-count { background: var(--accent); }

/* ── proposal detail ── */
.chip-lg { font-size: 11.5px; padding: 3px 11px; }

.find-note { margin: 0 0 13px; font-size: 13px; line-height: 1.62; color: var(--ink-2); }

.beforeafter {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--surface-2); border-radius: var(--r-md); padding: 11px 13px;
}
.ba { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ba-k {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-4); font-weight: 650;
}
.ba-v {
  font-size: 17px; font-weight: 660; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.ba-v.is-muted { color: var(--ink-3); }
.ba.is-prop .ba-v { color: var(--accent); }
.ba-arrow { display: flex; align-items: center; color: var(--ink-4); font-size: 15px; }

.minitable tr.is-driver td { background: var(--accent-soft); }
.tag-driver {
  font-size: 9px; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-line); padding: 1px 5px; border-radius: 99px;
  margin-left: 5px;
}

.decide .dec-label {
  display: block; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-4); font-weight: 650; margin-bottom: 5px;
}
.dec-edit {
  margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line);
}
.dec-edit-row { display: flex; align-items: center; gap: 8px; }
.dec-qty {
  font-family: var(--mono); font-size: 13px; width: 130px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 9px;
}
.dec-qty:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.dec-unit { font-size: 11.5px; color: var(--ink-3); }
.dec-actions {
  display: flex; gap: 8px; margin-top: 15px; padding-top: 13px;
  border-top: 1px solid var(--line);
}
.dec-actions .btn { flex: 1; justify-content: center; }

.decided-box { }
.decided-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.decided-who { font-size: 11.5px; color: var(--ink-3); }
.decided-note {
  margin: 11px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-2);
  border-left: 2.5px solid var(--accent); padding-left: 11px;
}
.decided-note.is-muted { color: var(--ink-4); border-left-color: var(--line-2); font-style: italic; }
.decided-box .btn { margin-top: 13px; }

@media (max-width: 1180px) {
  .classcards { grid-template-columns: 1fr; }
  .c-cust { display: none; }
}

/* ══════════════════════ FEATURE EXPLAINER ══════════════════════ */

.explainer { margin-bottom: 14px; }
.explainer:empty { display: none; }

.xp {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden;
}
.xp-head {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 12px 16px; background: none; border: 0; cursor: pointer;
  font-family: inherit; color: inherit; text-align: left;
}
.xp-head:hover { background: var(--surface-2); }
.xp-num {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--brand); flex: none;
}
.xp-title { flex: 1; display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.xp-title strong { font-size: 13.5px; font-weight: 650; }
.xp-title em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.xp-badge {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 650; color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-line); padding: 2px 8px; border-radius: 99px;
  white-space: nowrap; flex: none;
}
.xp-caret {
  color: var(--ink-4); font-size: 12px; flex: none; transition: transform .16s;
}
.xp.is-collapsed .xp-caret { transform: rotate(-90deg); }
.xp.is-collapsed .xp-body { display: none; }

.xp-body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.xp-lead {
  margin: 13px 0 15px; font-size: 13.5px; line-height: 1.6; color: var(--ink);
  max-width: 96ch;
}
.xp-grid { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 20px; }
.xp-col h4 {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-4); font-weight: 680; margin: 0 0 8px;
}
.xp-col ol { margin: 0; padding-left: 17px; }
.xp-col li {
  font-size: 12px; line-height: 1.55; color: var(--ink-2); margin-bottom: 6px;
}
.xp-col li::marker { color: var(--ink-4); font-variant-numeric: tabular-nums; }
.xp-try li b { color: var(--ink); font-weight: 640; }
.xp-problem blockquote {
  margin: 0; padding: 10px 13px; background: var(--surface-2);
  border-left: 2.5px solid var(--down); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 12px; line-height: 1.6; color: var(--ink-2); font-style: italic;
}
.xp-solves {
  margin: 16px 0 0; padding-top: 13px; border-top: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.6; color: var(--ink-2); max-width: 110ch;
}
.xp-solves strong { color: var(--ink); }
.xp-hint {
  margin: 9px 0 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.55;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r-sm); padding: 8px 11px; max-width: 110ch;
}

/* ══════════════════════ FEATURE 3 — ONE NUMBER ══════════════════════ */

.signoff-banner { margin-bottom: 14px; }
.sb {
  display: flex; gap: 11px; align-items: flex-start;
  border-radius: var(--r-lg); padding: 12px 15px;
  font-size: 12.5px; line-height: 1.6; color: var(--ink-2);
}
.sb strong { color: var(--ink); }
.sb-icon {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.sb-locked {
  background: var(--up-soft);
  border: 1px solid color-mix(in srgb, var(--up) 28%, transparent);
}
.sb-locked .sb-icon { background: var(--up); color: var(--paper); }
.sb-open {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.sb-open .sb-icon { background: var(--warn); color: var(--paper); }

.figures {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.fig {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; min-width: 0;
}
.fig-sys { border-top: 3px solid var(--fc); }
.fig-k {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-4); font-weight: 650;
}
.fig-v {
  font-size: 30px; font-weight: 670; letter-spacing: -0.03em; line-height: 1.05;
  margin-top: 7px; font-variant-numeric: tabular-nums;
}
.fig-v small { font-size: 14px; font-weight: 550; color: var(--ink-3); }
.fig-s { font-size: 10.5px; color: var(--ink-3); margin-top: 7px; line-height: 1.45; }
.fig-o { font-size: 10.5px; color: var(--ink-4); margin-top: 5px; }
.fig-gap { background: var(--surface-2); }
.fig-gap .fig-v { color: var(--down); }
.fig-agreed { border-color: var(--accent-line); background: var(--accent-soft); }
.fig-agreed .fig-v { color: var(--accent); }
.fig-agreed.is-locked {
  border-color: color-mix(in srgb, var(--up) 40%, transparent);
}
.fig-pub { color: var(--accent); }

.bridge-wrap { padding: 4px 18px 0; }
.recon-ok { color: var(--up); font-weight: 600; }
.recon-bad { color: var(--down); font-weight: 600; }

.bridge-rows {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 9px; padding: 14px 18px 18px;
}
.brow {
  display: flex; gap: 10px;
  background: var(--surface-2); border-radius: var(--r-md); padding: 11px 13px;
}
.brow-rule { width: 3px; border-radius: 2px; background: var(--bc); flex: none; }
.brow-main { min-width: 0; flex: 1; }
.brow-top {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
}
.brow-name { font-size: 12.5px; font-weight: 640; }
.brow-delta { font-size: 13px; font-weight: 660; font-variant-numeric: tabular-nums; }
.brow-move {
  display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;
  margin-top: 4px; font-size: 11px;
}
.brow-from { color: var(--ink-4); text-decoration: line-through; }
.brow-arrow { color: var(--ink-4); }
.brow-to { color: var(--ink); font-weight: 570; }
.brow-why { font-size: 11px; color: var(--ink-3); line-height: 1.5; margin-top: 6px; }

.defgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(276px, 1fr));
  gap: 11px; padding: 4px 18px 16px;
}
.defcell {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 13px;
}
.defcell.is-disputed { border-color: var(--accent-line); }
.def-k {
  font-size: 12.5px; font-weight: 640; display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.def-flag {
  font-size: 9px; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--down); background: var(--down-soft);
  border: 1px solid color-mix(in srgb, var(--down) 26%, transparent);
  padding: 1px 6px; border-radius: 99px;
}
.def-q { font-size: 11px; color: var(--ink-3); margin: 3px 0 9px; }
.def-opts { display: flex; flex-direction: column; gap: 3px; }
.def-opt {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 11.5px; background: var(--surface); border: 1px solid transparent;
}
.def-opt:hover { border-color: var(--line-2); }
.def-opt.is-on { background: var(--accent-soft); border-color: var(--accent-line); }
.def-opt.is-locked { cursor: not-allowed; opacity: .72; }
.def-opt input {
  accent-color: var(--accent); width: 13px; height: 13px; margin: 0; flex: none;
}
.def-opt-l { flex: 1; min-width: 0; }
.def-tag {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; padding: 1px 5px; border-radius: 99px; white-space: nowrap;
}
.t-bi { background: color-mix(in srgb, #0E7490 18%, transparent); color: #0E7490; }
.t-pl { background: color-mix(in srgb, #7C3AED 18%, transparent); color: #7C3AED; }
:root[data-theme="dark"] .t-bi { color: #67C7DC; }
:root[data-theme="dark"] .t-pl { color: #B794F6; }
.def-why { font-size: 10.5px; color: var(--ink-4); line-height: 1.5; margin-top: 9px; }

.signoff-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px; padding: 0 18px 18px;
}
.sgn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 11px 14px;
}
.sgn.is-signed {
  background: var(--up-soft);
  border-color: color-mix(in srgb, var(--up) 26%, transparent);
}
.sgn-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sgn-who strong { font-size: 12.5px; font-weight: 620; }
.sgn-who span { font-size: 10.5px; color: var(--ink-3); }
.sgn-state {
  display: flex; align-items: center; gap: 8px; font-size: 11px;
  color: var(--up); font-weight: 600; white-space: nowrap;
}

.c-gapbar { width: 130px; }
.gapbar {
  display: block; height: 6px; border-radius: 3px;
  background: var(--surface-3); overflow: hidden;
}
.gapbar span {
  display: block; height: 100%; background: var(--down); border-radius: 3px;
}

.h3-sub {
  font-weight: 400; color: var(--ink-4); text-transform: none;
  letter-spacing: 0; font-size: 10.5px; margin-left: 6px;
}
.tag-flag {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; padding: 1px 5px; border-radius: 99px; margin-left: 5px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line); white-space: nowrap;
}
.t-disc { background: var(--surface-3); color: var(--ink-3); border-color: var(--line-2); }
.t-zero {
  background: var(--down-soft); color: var(--down);
  border-color: color-mix(in srgb, var(--down) 25%, transparent);
}

@media (max-width: 1400px) {
  .figures { grid-template-columns: repeat(2, 1fr); }
  .xp-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1000px) {
  .figures { grid-template-columns: 1fr; }
  .xp-grid { grid-template-columns: 1fr; }
  .c-gapbar { display: none; }
}

/* ══════════════════════════ COPILOT ══════════════════════════ */

.cp-launch {
  position: fixed; right: 22px; bottom: 22px; z-index: 70;
  display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 99px; padding: 11px 18px 11px 15px;
  font-family: inherit; font-size: 13px; font-weight: 640;
  cursor: pointer; box-shadow: var(--shadow-3);
  transition: transform .12s, filter .12s;
}
.cp-launch:hover { filter: brightness(1.08); transform: translateY(-1px); }
.cp-launch svg { width: 18px; height: 18px; }
.cp-launch.is-open { opacity: 0; pointer-events: none; }

.cp-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 72;
  width: min(440px, calc(100vw - 40px));
  height: min(660px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: cpin .18s cubic-bezier(.22,.8,.3,1);
}
@keyframes cpin {
  from { transform: translateY(14px) scale(.98); opacity: 0 }
  to { transform: none; opacity: 1 }
}

.cp-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.cp-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cp-head-t strong { font-size: 13.5px; font-weight: 650; }
.cp-head-t span { font-size: 10.5px; color: var(--ink-3); }

.cp-thread {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 14px;
}

.cp-empty { margin: auto 0; }
.cp-empty-t { font-size: 14px; font-weight: 620; margin-bottom: 6px; }
.cp-empty-s {
  font-size: 12px; color: var(--ink-3); line-height: 1.6; margin-bottom: 14px;
}
.cp-starters { display: flex; flex-direction: column; gap: 6px; }
.cp-starter {
  font-family: inherit; font-size: 12px; text-align: left;
  color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px 11px; cursor: pointer; line-height: 1.45;
}
.cp-starter:hover {
  background: var(--accent-soft); border-color: var(--accent-line);
  color: var(--ink);
}

.cp-turn { display: flex; flex-direction: column; }
.cp-user { align-items: flex-end; }
.cp-bubble {
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-lg) var(--r-lg) 3px var(--r-lg);
  padding: 8px 13px; font-size: 12.5px; line-height: 1.55;
  max-width: 88%; white-space: pre-wrap; word-break: break-word;
}

.cp-steps { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.cp-steps:empty { display: none; }
.cp-step {
  font-size: 10.5px; color: var(--ink-3);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 9px 2px 8px;
  display: inline-flex; align-items: center; gap: 5px;
}
.cp-step::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--up); flex: none;
}
.cp-step.is-running::before { background: var(--accent); animation: cppulse 1s infinite; }
.cp-step.is-bad::before { background: var(--down); }
@keyframes cppulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.cp-msg { font-size: 12.5px; line-height: 1.62; color: var(--ink-2); }
.cp-msg p { margin: 0 0 9px; }
.cp-msg p:last-child { margin-bottom: 0; }
.cp-msg ul { margin: 0 0 9px; padding-left: 17px; }
.cp-msg li { margin-bottom: 4px; }
.cp-msg strong { color: var(--ink); font-weight: 640; }
.cp-msg code {
  font-family: var(--mono); font-size: 11px;
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
}
.cp-cursor {
  display: inline-block; width: 6px; height: 12px; background: var(--accent);
  vertical-align: -2px; animation: cpblink .9s steps(2, start) infinite;
}
@keyframes cpblink { to { visibility: hidden } }

.cp-foot { padding: 11px 14px 13px; border-top: 1px solid var(--line); }
.cp-row { display: flex; gap: 7px; align-items: flex-end; }
.cp-input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 12.5px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 11px; resize: none; line-height: 1.45; max-height: 120px;
}
.cp-input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface);
}
.cp-note {
  font-size: 10px; color: var(--ink-4); line-height: 1.5; margin-top: 8px;
}
.cp-panel.is-busy .cp-input { opacity: .72; }

@media (max-width: 620px) {
  .cp-panel {
    right: 0; bottom: 0; width: 100vw; height: 86vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .cp-launch { right: 14px; bottom: 14px; }
}
