/* Dense, dark, terminal-ish. Optimised for reading numbers fast, and for
   cheap repaints: no shadows or blurs on anything that updates. */
:root {
  --bg: #0a0e14;
  --bg2: #10151d;
  --bg3: #161d27;
  --line: #212a36;
  --fg: #d6dee9;
  --dim: #7d8b9e;
  --dimmer: #55637a;
  --up: #21d07a;
  --dn: #ff5c5c;
  --acc: #4aa3ff;
  --warn: #ffb648;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.35 var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- top bar */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand strong { font-size: 14px; letter-spacing: .2px; white-space: nowrap; }
.brand .sub { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dimmer); flex: 0 0 auto;
}
.dot.live { background: var(--up); }
.dot.stale { background: var(--warn); }
.dot.dead { background: var(--dn); }

.chip {
  font-size: 11px; color: var(--dim);
  background: var(--bg3); border: 1px solid var(--line);
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
}
.chip.warn { color: var(--warn); border-color: #4a3a1c; }
.chip.bad { color: var(--dn); border-color: #4a2020; }

.tgl {
  font: inherit; font-size: 11px;
  color: var(--dim); background: var(--bg3);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 3px 8px; cursor: pointer; text-decoration: none;
}
.tgl:hover { color: var(--fg); border-color: #33404f; }
.tgl.on { color: #06202a; background: var(--acc); border-color: var(--acc); font-weight: 700; }

/* ------------------------------------------------------------------- kpis */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.kpi { background: var(--bg2); padding: 8px 10px 9px; min-width: 0; }
.kpi.wide { grid-column: span 2; }
.kpi label {
  display: block; font-size: 10px; letter-spacing: .6px;
  text-transform: uppercase; color: var(--dimmer); margin-bottom: 3px;
}
.kpi label em { font-style: normal; color: var(--dimmer); text-transform: none; letter-spacing: 0; }
.kpi-main {
  font-size: 21px; font-weight: 700; line-height: 1.15;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.kpi-main.small { font-size: 15px; }
.kpi-main .unit { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: 2px; }
.kpi-main .vs { color: var(--dimmer); font-weight: 400; }
.kpi-foot {
  font-size: 10.5px; color: var(--dim); margin-top: 2px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.meter {
  position: relative; height: 5px; margin: 5px 0 3px;
  background: var(--bg3); border-radius: 3px; overflow: hidden;
}
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--acc); border-radius: 3px; }
.meter i.full { background: var(--up); }
.meter u {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--warn); left: 0; text-decoration: none;
}

/* ------------------------------------------------------------------ panes */
.panes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border-bottom: 1px solid var(--line);
}
.pane { background: var(--bg2); padding: 8px 10px 4px; min-width: 0; }
.pane h2, .thead h2 {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--dim); font-weight: 600;
}
.pane h2 small, .thead h2 small {
  text-transform: none; letter-spacing: 0; color: var(--dimmer);
  font-weight: 400; margin-left: 6px;
}
canvas { display: block; width: 100%; }

/* ------------------------------------------------------------------ table */
.tablewrap { padding: 0; }
.thead {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 6px; flex-wrap: wrap;
}
.thead h2 { margin: 0; }
.tools { margin-left: auto; display: flex; gap: 12px; }
.ck { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.ck input { accent-color: var(--acc); margin: 0; }

.scroll { max-height: 60vh; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg3); color: var(--dim);
  font-size: 10px; letter-spacing: .5px; text-transform: uppercase;
  font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 3px 10px; border-bottom: 1px solid #151b24;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.r { text-align: right; }
tbody tr:hover td { background: #131a24; }
tbody tr.floor td { background: #17212e; }
tbody tr.floor td:first-child::after {
  content: " CUT-OFF"; font-size: 9px; color: var(--warn); letter-spacing: .5px;
}
tbody tr.clear td { box-shadow: inset 0 -1px 0 var(--up); }
tbody tr.empty td { color: var(--dimmer); }
td.px { color: var(--fg); font-weight: 600; }
td.zero { color: #3d4757; }
td.cum { color: var(--acc); }
td.open { color: var(--dim); }
.unc { color: var(--dim); }
th.unc, td.unc { display: none; }
body.show-unc th.unc, body.show-unc td.unc { display: table-cell; }

/* Flashes are short and use background only — no layout or paint of text. */
@keyframes fu { from { background: rgba(33,208,122,.30); } to { background: transparent; } }
@keyframes fd { from { background: rgba(255,92,92,.28); } to { background: transparent; } }
td.up { animation: fu .85s ease-out; }
td.dn { animation: fd .85s ease-out; }

/* ----------------------------------------------------------------- footer */
.foot {
  display: flex; gap: 14px; align-items: center;
  padding: 6px 12px; font-size: 10.5px; color: var(--dimmer);
  background: var(--bg2); border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.foot .spacer { margin-left: auto; }
#foot-drift.bad { color: var(--warn); }

.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 14px; font-size: 12px; color: var(--fg);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .panes { grid-template-columns: 1fr; }
  .kpi.wide { grid-column: span 2; }
}

/* ------------------------------------------------------------- spot strip */
.spot {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(4, minmax(130px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.spot-box { background: #0d141d; padding: 8px 12px 9px; min-width: 0; }
.spot-box.main { background: #101a26; }
.spot-box label {
  display: block; font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--dimmer); margin-bottom: 2px;
}
.spot-box label em { font-style: normal; color: var(--acc); }
.spot-px { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
#s-ltp { font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.spot-chg { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.spot-chg.up { color: var(--up); }
.spot-chg.dn { color: var(--dn); }
.spot-sub {
  font-size: 10.5px; color: var(--dim); margin-top: 3px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.spot-sub b { color: var(--fg); font-weight: 600; }
.spot-sub .muted { color: var(--dimmer); margin-left: 6px; }
.cmp {
  font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums;
  line-height: 1.2; white-space: nowrap;
}
.cmp.good { color: var(--up); }
.cmp.bad { color: var(--dn); }
.cmp.flat { color: var(--dim); }
#s-ltp.tick-up { animation: fu .7s ease-out; }
#s-ltp.tick-dn { animation: fd .7s ease-out; }

/* ------------------------------------------------------- three-pane region */
.panes3 {
  display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 1px;
  background: var(--line); border-bottom: 1px solid var(--line);
}
.panes3 .pane { padding: 8px 10px 10px; }
.pane-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; flex-wrap: wrap; }
.hint { font-size: 10.5px; color: var(--dimmer); line-height: 1.4; }
p.hint { margin: 0 0 7px; }
h2.mt { margin-top: 12px; }
.scroll.sm { max-height: 262px; }
table.tight tbody td { padding: 2px 8px; font-size: 12px; }
table.tight thead th { padding: 5px 8px; }

/* coverage bar inside the discovery table */
.cov { position: relative; height: 8px; min-width: 60px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.cov i { position: absolute; inset: 0 auto 0 0; background: var(--acc); }
.cov i.full { background: var(--up); }
.cov i.mid { background: var(--warn); }
tr.xbase td { background: #1b2417; }
tr.xtotal td { background: #16241c; }
td.badge-c { color: var(--up); font-weight: 700; }

/* ------------------------------------------------------------------ inputs */
.field { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.field label { font-size: 10.5px; color: var(--dim); width: 84px; flex: 0 0 auto; }
.field input, .field select {
  font: inherit; font-size: 12px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 7px; min-width: 0; flex: 1 1 auto;
  font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--acc); }
.field select { flex: 0 0 auto; cursor: pointer; }
.unitlbl { font-size: 10px; color: var(--dimmer); flex: 0 0 auto; }
.row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.btn {
  font: inherit; font-size: 11px; font-weight: 600;
  color: #06202a; background: var(--acc); border: 1px solid var(--acc);
  border-radius: 4px; padding: 5px 12px; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { color: var(--dim); background: var(--bg3); border-color: var(--line); font-weight: 400; }
.btn.ghost:hover { color: var(--fg); }
.ovr-flag {
  font-size: 10px; color: var(--warn); border: 1px solid #4a3a1c;
  background: #221a0d; padding: 2px 6px; border-radius: 3px;
}
.hide { display: none !important; }

.tabs { display: flex; gap: 1px; margin-bottom: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.tab {
  font: inherit; font-size: 10.5px; flex: 1 1 0;
  color: var(--dim); background: var(--bg3); border: 0;
  padding: 5px 4px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--fg); }
.tab.on { color: #06202a; background: var(--acc); font-weight: 700; }

.result { margin-top: 9px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 12px; }
.result .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.result .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--dimmer); }
.result table { width: 100%; margin-top: 6px; }
.result td { padding: 2px 0; font-variant-numeric: tabular-nums; }
.result td:first-child { color: var(--dim); font-size: 11px; }
.result td:last-child { text-align: right; font-weight: 600; }
.verdict { padding: 6px 9px; border-radius: 4px; margin-top: 7px; font-weight: 600; font-size: 12px; }
.verdict.fill { background: #10291c; color: var(--up); border: 1px solid #1d4630; }
.verdict.part { background: #2a2210; color: var(--warn); border: 1px solid #4a3a1c; }
.verdict.none { background: #2a1414; color: var(--dn); border: 1px solid #4a2020; }

@media (max-width: 1180px) {
  .panes3 { grid-template-columns: 1fr 1fr; }
  .spot { grid-template-columns: minmax(200px, 1.4fr) repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .panes3 { grid-template-columns: 1fr; }
  .spot { grid-template-columns: 1fr 1fr; }
}

td.dimc { color: var(--dimmer); font-size: 11px; }
