/* ---- tokens: paper, ink and hairlines (anatomy idiom), dataviz series colours ---- */
:root {
  color-scheme: light;
  --plane: #f2f2ef;            /* page */
  --surface: #fbfbfa;          /* card / chart surface */
  --face: #ffffff;             /* raised face */
  --ink: #18181a;              /* strong */
  --ink-2: #57575a;            /* text */
  --muted: #8c8c90;
  --hi: #26262a;               /* hairline tones */
  --mid: #8a8a8f;
  --lo: #b4b4b8;
  --faint: #d4d4d6;
  --grid: #e6e6e3;
  --axis: #c9c9c6;
  --lit: #000000;              /* the one accent */
  --border: rgba(24, 24, 26, 0.12);
  --s1: #2a78d6;               /* series 1 (identity) */
  --s2: #eb6834;               /* series 2 */
  --deemph: #c3c2b7;
  --div-pos: #2a78d6;
  --div-neg: #e34948;
  --div-mid: #eeeeeb;
  --good: #006300;
  --bad: #d03b3b;
  --meter-track: #e1e1de;
  --wash: rgba(24, 24, 26, 0.05);
  --lift: inset 0 1px 0 0 #ffffff, 0 0 0 1px rgba(0, 0, 0, .06), 0 1px 1px -.5px rgba(0, 0, 0, .04), 0 3px 3px -1.5px rgba(0, 0, 0, .04), 0 6px 6px -3px rgba(0, 0, 0, .04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0b0b0b; --surface: #131313; --face: #1b1b1b; --ink: #e6e6e6; --ink-2: #a3a3a3; --muted: #6e6e6e;
    --hi: #d4d4d4; --mid: #6a6a6a; --lo: #3e3e3e; --faint: #2a2a2a; --grid: #222222; --axis: #333333; --lit: #ffffff;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --deemph: #4a4a47; --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #1f1f1f;
    --good: #0ca30c; --bad: #e66767; --meter-track: #262626; --wash: rgba(255, 255, 255, 0.06);
    --lift: inset 0 1px 0 0 #ffffff0a, inset 0 0 0 1px #ffffff06, 0 0 0 1px #00000026, 0 1px 1px -.5px #00000014, 0 3px 3px -1.5px #00000014, 0 6px 6px -3px #00000014;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0b0b0b; --surface: #131313; --face: #1b1b1b; --ink: #e6e6e6; --ink-2: #a3a3a3; --muted: #6e6e6e;
  --hi: #d4d4d4; --mid: #6a6a6a; --lo: #3e3e3e; --faint: #2a2a2a; --grid: #222222; --axis: #333333; --lit: #ffffff;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --s2: #d95926; --deemph: #4a4a47; --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #1f1f1f;
  --good: #0ca30c; --bad: #e66767; --meter-track: #262626; --wash: rgba(255, 255, 255, 0.06);
  --lift: inset 0 1px 0 0 #ffffff0a, inset 0 0 0 1px #ffffff06, 0 0 0 1px #00000026, 0 1px 1px -.5px #00000014, 0 3px 3px -1.5px #00000014, 0 6px 6px -3px #00000014;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--plane); color: var(--ink-2); font-family: var(--font); font-size: 13.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--lo); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink-2); }
button, select, input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 11.5px; background: var(--div-mid); padding: 1px 5px; border-radius: 3px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---- header ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 16px 6px; max-width: 1440px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--hi); position: relative; flex: none; background: var(--surface); box-shadow: var(--lift); }
.mark::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 1px; background: var(--hi); transform: rotate(-35deg); }
.mark::before { content: ""; position: absolute; left: 50%; top: 6px; bottom: 6px; width: 1px; background: var(--lo); }
.brand h1 { font-size: 17px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; font-weight: 500; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 12.5px; }
.status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 3px; background: var(--surface); box-shadow: 0 0 0 1px var(--lo); font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; }
.chip strong { color: var(--ink); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lo); flex: none; }
.dot.fresh { background: var(--lit); box-shadow: 0 0 0 0 var(--wash); animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(128, 128, 128, .45); } 70% { box-shadow: 0 0 0 7px rgba(128, 128, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(128, 128, 128, 0); } }
@media (prefers-reduced-motion: reduce) { .dot.fresh { animation: none; } }
.ghost, .primary { border: 0; box-shadow: 0 0 0 1px var(--lo); background: var(--surface); border-radius: 3px; padding: 5px 10px; cursor: pointer; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.ghost:hover { box-shadow: 0 0 0 1px var(--mid); color: var(--ink); }
.ghost.icon { width: 30px; padding: 5px 0; text-align: center; font-size: 14px; line-height: 1; text-transform: none; }
.primary { background: var(--ink); color: var(--surface); box-shadow: none; font-weight: 600; }
.ghost.active { box-shadow: 0 0 0 1px var(--hi); color: var(--ink); }

/* ---- filters ---- */
.filters { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; padding: 10px 16px 4px; max-width: 1440px; margin: 0 auto; }
.field { display: flex; flex-direction: column; gap: 5px; font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.field.grow { flex: 1; }
.field.note { text-transform: none; letter-spacing: .02em; font-size: 10.5px; color: var(--muted); padding-bottom: 8px; }
.field select {
  min-width: 170px; height: 32px; border: 0; box-shadow: 0 0 0 1px var(--lo); background: var(--surface); border-radius: 3px; padding: 0 30px 0 10px;
  color: var(--ink); font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; text-transform: none; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--mid) 50%), linear-gradient(135deg, var(--mid) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.seg { display: inline-flex; box-shadow: 0 0 0 1px var(--lo); border-radius: 3px; background: var(--surface); height: 32px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 0 12px; cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--faint); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--surface); }

.keybar { max-width: 1408px; margin: 8px auto 0; padding: 12px 14px; box-shadow: 0 0 0 1px var(--lo); border-radius: 3px; background: var(--surface); display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.keybar[hidden] { display: none; }
.keybar form { display: flex; gap: 8px; flex-wrap: wrap; }
.keybar input { height: 30px; border: 0; box-shadow: 0 0 0 1px var(--lo); border-radius: 3px; background: var(--plane); padding: 0 10px; min-width: 260px; font-family: var(--mono); font-size: 12px; }
@media (max-width: 768px) { .keybar { margin: 8px 16px 0; } .chip { white-space: normal; } .status { max-width: 100%; } }

.pair { display: inline-flex; align-items: center; gap: 6px; height: 32px; }
.pair input { width: 78px; height: 32px; border: 0; box-shadow: 0 0 0 1px var(--lo); background: var(--surface); border-radius: 3px; padding: 0 8px; color: var(--ink); font-family: var(--mono); font-size: 12.5px; text-transform: none; letter-spacing: 0; -moz-appearance: textfield; }
.pair input#target-days { width: 56px; }
.pair input::-webkit-outer-spin-button, .pair input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pair input:focus { outline: none; box-shadow: 0 0 0 1px var(--hi); }
.pair .in { text-transform: none; letter-spacing: .02em; color: var(--muted); }
.target-note { max-width: 1440px; margin: 0 auto; padding: 6px 16px 0; font-family: var(--mono); font-size: 11.5px; color: var(--ink); letter-spacing: .01em; line-height: 1.5; }
.target-note[hidden] { display: none; }
.target-note .label { margin-right: 8px; }
.target-note b { font-weight: 600; }
.target-note .cat { color: var(--muted); }

/* ---- layout ---- */
main { max-width: 1440px; margin: 0 auto; padding: 8px 16px 24px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 14px; }
.tile { background: var(--surface); border-radius: 3px; box-shadow: var(--lift); padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tile .value { font-family: var(--mono); font-size: 24px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); }
.tile.hero .value { font-size: 48px; }
.tile.hero { grid-column: span 2; }
.tile .delta { font-size: 11.5px; color: var(--ink-2); font-family: var(--mono); letter-spacing: 0; }
.tile .delta.up { color: var(--good); }
.tile .delta.down { color: var(--bad); }
.tile .meter { height: 4px; border-radius: 2px; background: var(--meter-track); margin-top: 7px; overflow: hidden; position: relative; }
.tile .meter > span { display: block; height: 100%; background: var(--ink); border-radius: 2px; }
.tile .spark { margin-top: 4px; width: 100%; height: 28px; display: block; }
@media (max-width: 520px) { .tile.hero { grid-column: span 2; } .tile.hero .value { font-size: 40px; } }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--surface); border-radius: 3px; box-shadow: var(--lift); padding: 0; min-width: 0; display: flex; flex-direction: column; position: relative; }
.card.span2 { grid-column: span 2; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .card.span2 { grid-column: span 1; } }
.card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px 0; }
.card > header > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card h2 { font-size: 10.5px; font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; font-weight: 500; color: var(--ink-2); display: flex; gap: 14px; align-items: baseline; }
.card h2::before { content: attr(data-fig); color: var(--ink); font-weight: 500; }
.desc { margin: 4px 0 0; color: var(--ink-2); font-size: 12.5px; max-width: 70ch; }
.card-tools { display: flex; gap: 0; flex: none; box-shadow: 0 0 0 1px var(--faint); border-radius: 3px; overflow: hidden; }
.card-tools button { border: 0; background: transparent; padding: 3px 9px; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.card-tools button + button { border-left: 1px solid var(--faint); }
.card-tools button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.plot { position: relative; min-height: 120px; transition: opacity .2s; padding: 10px 18px 6px; }
.plot.stale { opacity: .45; pointer-events: none; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot .empty { color: var(--muted); font-size: 12.5px; padding: 36px 8px; text-align: center; box-shadow: inset 0 0 0 1px var(--faint); border-radius: 3px; font-family: var(--mono); }
.plot .empty strong { color: var(--ink-2); }
.card-foot { display: flex; justify-content: space-between; gap: 12px; padding: 6px 18px 12px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card-foot .readout { color: var(--ink-2); text-transform: none; letter-spacing: .02em; font-variant-numeric: tabular-nums; text-align: right; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; color: var(--ink-2); margin: 2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.legend i.rect { width: 12px; height: 10px; border-radius: 1px; }
.legend i.dot { width: 8px; height: 8px; border-radius: 50%; }

/* svg text and hairlines */
svg text { font-family: var(--mono); fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
svg .ink { fill: var(--ink); } svg .ink2 { fill: var(--ink-2); }
svg .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg .axis line, svg .axis path { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
svg .hit { fill: transparent; }
svg .hit:hover, svg .hit:focus { outline: none; }
svg .cell:hover, svg .cell:focus { stroke: var(--lit); stroke-width: 1.2; outline: none; }
svg .bar:hover, svg .bar:focus { filter: brightness(1.12); outline: none; }

/* table views */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--mono); }
.tbl th, .tbl td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; position: sticky; top: 0; background: var(--surface); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tbody tr:hover { background: var(--wash); }
.tbl-wrap { overflow: auto; max-height: 420px; box-shadow: inset 0 0 0 1px var(--faint); border-radius: 3px; }
.tbl-wrap.tall { max-height: none; }
.tbl .sortable { cursor: pointer; user-select: none; }
.tbl tr.sel td { background: var(--wash); box-shadow: inset 2px 0 0 var(--lit); }
.tbl tr.sel td + td { box-shadow: none; }
.tbl tr.row-click { cursor: pointer; }
.tbl td.l, .tbl th.l { text-align: left; }
.tbl .tick { font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.tbl .cat { color: var(--muted); font-size: 10.5px; }
.tbl .pos { color: var(--good); } .tbl .neg { color: var(--bad); }
.cellbar { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.cellbar .track { width: 64px; height: 4px; border-radius: 2px; background: var(--meter-track); overflow: hidden; display: inline-block; }
.cellbar .track > span { display: block; height: 100%; background: var(--ink); }
.divbar { position: relative; width: 84px; height: 6px; display: inline-block; vertical-align: middle; background: var(--div-mid); border-radius: 1px; margin-right: 6px; }
.divbar::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.divbar > span { position: absolute; top: 0; height: 100%; border-radius: 1px; }
.divbar > span.p { left: 50%; background: var(--div-pos); border-radius: 0 1px 1px 0; }
.divbar > span.n { right: 50%; background: var(--div-neg); border-radius: 1px 0 0 1px; }
.spark-cell svg { display: block; }
.badge { display: inline-block; font-size: 9.5px; padding: 1px 6px; border-radius: 2px; box-shadow: 0 0 0 1px var(--lo); color: var(--ink-2); margin-left: 6px; vertical-align: middle; letter-spacing: .06em; text-transform: uppercase; }

.foot { max-width: 1440px; margin: 0 auto; padding: 8px 16px 40px; color: var(--muted); font-size: 12px; }
.foot p { margin: 4px 0; }

/* tooltip */
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--mid), var(--lift); border-radius: 3px; padding: 8px 10px; font-size: 11.5px; min-width: 120px; max-width: 280px; font-family: var(--mono); }
.tip .t { color: var(--muted); margin-bottom: 4px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.tip .r b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tip .r span { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.tip .r i { display: inline-block; width: 10px; height: 2px; border-radius: 1px; }

/* ---- rent gauge ---- */
.rent { background: var(--surface); border-radius: 3px; box-shadow: var(--lift); padding: 12px 16px 10px; margin: 0 0 12px; }
.rent:empty { display: none; }
.rent-lead { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.45; max-width: 110ch; }
.rent-lead .label { display: block; margin-bottom: 4px; }

/* ---- shop table ---- */
.shop-tbl td, .shop-tbl th { padding: 5px 7px; }
.shop-tbl .dl { color: var(--ink); font-weight: 600; }
.shop-tbl td.lead { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--lit); }
.shop-tbl td.tgt, .thesis-tbl tr.target td { background: var(--wash); }
.shop-tbl tr.bestrr td { border-top: 1px solid var(--lit); border-bottom: 1px solid var(--lit); color: var(--ink); }
.shop-tbl .rr { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 2px; background: var(--ink); color: var(--surface); margin-left: 6px; vertical-align: middle; letter-spacing: .08em; text-transform: uppercase; }
.thesis-tbl tr.target td.l .tick { box-shadow: inset 0 -2px 0 var(--lit); }
.shop-tbl td.neg { color: var(--bad); }
.shop-tbl .flag { display: inline-block; font-size: 9px; padding: 0 5px; border-radius: 2px; box-shadow: 0 0 0 1px var(--bad); color: var(--bad); margin-left: 6px; letter-spacing: .08em; text-transform: uppercase; vertical-align: middle; }

/* ---- thesis grid ---- */
.thesis-tbl th.grp { text-align: center !important; color: var(--ink-2); letter-spacing: .08em; border-left: 1px solid var(--axis); }
.thesis-tbl td { border-left: 1px solid transparent; }
.thesis-tbl td.best { color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--lit); }
.thesis-tbl td.neg { color: var(--bad); }
.thesis-tbl td.expd { color: var(--muted); font-style: italic; }
.thesis-tbl tr.headline td { background: var(--wash); }
.thesis-tbl td { text-align: center; }
.thesis-tbl th { text-align: center; }

svg text.muted { fill: var(--muted); }
