* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; letter-spacing: 0; line-height: 1.15; }
code, .mono { font-family: var(--mono); }
/* UI chrome is sans; prose stays serif */
.rail, .nav, .toolbar, table, .pill, .btn, select, input, .kpi, .legend,
.provenance, .ins-head, .field, .note, .count { font-family: var(--sans); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.rail {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 2px 8px 16px; }
.brand .title { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand .sub { color: var(--ink-faint); font-size: 11px; margin-top: 2px; font-family: var(--mono); }
.brand .dot { color: var(--hot); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav button {
  all: unset; cursor: pointer; padding: 8px 11px; border-radius: var(--r-sm);
  color: var(--ink-dim); font-size: 14px; display: flex; align-items: center; gap: 9px;
}
.nav button .num { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); width: 14px; }
.nav button:hover { background: var(--panel-2); color: var(--ink); }
.nav button.active { background: var(--hot-soft); color: var(--ink); box-shadow: inset 2px 0 0 var(--hot); }
.nav button.active .num { color: var(--hot); }

.rail .spacer { flex: 1; }
.provenance { font-size: 11px; color: var(--ink-faint); line-height: 1.6; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.provenance b { color: var(--ink-dim); font-weight: 700; }

/* ---------- main ---------- */
.main { min-width: 0; }
.view { padding: 30px 36px 64px; max-width: 1180px; }
.view h2 { margin: 0 0 4px; font-size: 28px; }
.view .lede { color: var(--ink-dim); margin: 0 0 24px; max-width: 66ch; font-size: 17px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 18px; }
select, input[type="search"], input[type="text"] {
  background-color: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 10px; font-family: var(--sans); font-size: 13px;
  transition: border-color .15s, background-color .15s;
}
/* flatten the OS select into a quiet inline field with a hairline caret */
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a938a' stroke-width='1.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select optgroup { font-style: normal; font-weight: 700; color: var(--ink-faint); }
select:hover, input:hover { border-color: var(--ink-faint); }
input[type="search"] { min-width: 240px; }
select:focus, input:focus { outline: none; border-color: var(--hot); box-shadow: 0 0 0 3px var(--hot-soft); background-color: var(--panel); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }

.btn { all: unset; cursor: pointer; background: var(--panel-2); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: var(--r-sm); font-size: 13px; color: var(--ink); font-family: var(--sans); }
.btn:hover { border-color: var(--brown); }
.btn.hot { background: var(--hot); border-color: var(--hot); color: #fff; }
.btn.hot:hover { background: #a23a1d; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.tablecard { overflow-x: auto; }
.chart { width: 100%; height: 560px; }
.chart.tall { height: 620px; }
/* bar charts that scroll natively (real scrollbar + mouse wheel) */
.chart-scroll { overflow-y: auto; overflow-x: hidden; }
.chart-inner { width: 100%; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tablecard table { min-width: 560px; }
thead th { text-align: left; color: var(--ink-faint); font-weight: 700; font-size: 10px;
  text-transform: uppercase; letter-spacing: .06em; padding: 9px 11px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
tbody td { padding: 9px 11px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-2); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 10.5px; font-family: var(--mono); border: 1px solid var(--line); color: var(--ink-dim); white-space: nowrap; }
.pill.bare { color: var(--c-bare); border-color: var(--c-bare); }
.pill.minimal { color: var(--c-minimal); border-color: var(--c-minimal); }
.pill.production { color: var(--c-production); border-color: var(--c-production); }
mark { background: var(--hot-soft); color: var(--hot); border-radius: 3px; padding: 0 2px; }

/* ---------- inspector (right slide-in) ---------- */
.inspector { position: fixed; top: 0; right: 0; height: 100vh; width: min(540px, 46vw);
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .22s ease; overflow: auto; z-index: 40; }
.inspector.open { transform: translateX(0); }
.inspector .ins-head { display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); }
.inspector #ins-title { font-family: var(--serif); }
.inspector .ins-body { padding: 18px 20px; }
.inspector h4 { margin: 18px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); font-family: var(--sans); }
.inspector pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 10px; margin: 0; color: var(--ink-dim); max-height: 320px; overflow: auto; }
.close-x { all: unset; cursor: pointer; color: var(--ink-faint); font-size: 18px; padding: 4px 10px; border-radius: var(--r-sm); }
.close-x:hover { color: var(--ink); background: var(--panel-2); }

.pick-row { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.pick-row .rk { font-family: var(--mono); color: var(--hot); }
.pick-row .nm { font-weight: 700; }
.pick-row .ex { color: var(--ink-dim); font-size: 13px; }

/* ---------- loading ---------- */
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; }
.loader .box { text-align: center; width: 320px; max-width: 80vw; }
.loader .bar { height: 4px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 14px; border: 1px solid var(--line); }
.loader .bar > i { display: block; height: 100%; width: 0; background: var(--hot); transition: width .15s; }
.loader .lbl { color: var(--ink-faint); font-family: var(--mono); font-size: 11px; margin-top: 8px; }

.muted { color: var(--ink-faint); }
.kpis { display: flex; gap: 28px; flex-wrap: wrap; margin: 4px 0 24px; }
.kpi .v { font-family: var(--sans); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .v .unit { font-size: 14px; color: var(--hot); font-weight: 700; }
.kpi .k { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.note { font-size: 12px; color: var(--ink-faint); margin-top: 10px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-dim); margin: 10px 0 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 1fr; }
  .rail {
    flex-direction: row; align-items: center; gap: 6px; height: auto;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 8px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .brand { padding: 0 6px 0 2px; flex: 0 0 auto; }
  .brand .title { font-size: 16px; }
  .brand .sub { display: none; }
  .nav { flex-direction: row; margin-top: 0; gap: 3px; }
  .nav button { white-space: nowrap; padding: 7px 10px; font-size: 13px; }
  .nav button .num { display: none; }
  .nav button.active { box-shadow: inset 0 -2px 0 var(--hot); }
  .rail .spacer, .provenance { display: none; }
  .view { padding: 18px 15px 56px; }
  .view h2 { font-size: 23px; }
  .view .lede { font-size: 16px; }
  .chart, .chart.tall { height: 66vh; min-height: 340px; }
  .toolbar { gap: 10px; }
  .toolbar .field, .toolbar select, .toolbar input[type="search"] { width: 100%; }
  input[type="search"] { min-width: 0; }
  .inspector { width: 100vw; }
  .kpis { gap: 18px; }
  .kpi .v { font-size: 22px; }
}
