:root {
  --bg: #0f141c;
  --panel: #161d28;
  --panel-2: #1c2533;
  --line: #273246;
  --text: #e6ebf2;
  --muted: #8d9bb0;
  --red: #d7263d;
  --red-soft: rgba(215, 38, 61, .14);
  --good: #3fb67f;
  --good-soft: rgba(63, 182, 127, .14);
  --bad: #f0616f;
  --warn: #e5a83b;
  --warn-soft: rgba(229, 168, 59, .14);
  --link: #8fb8ff;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* top bar */
.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: #0b1017; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand .mark { width: 10px; height: 26px; background: var(--red); border-radius: 2px; }
.brand small { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.nav a:hover, .nav a.on { color: var(--text); background: var(--panel-2); text-decoration: none; }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px;
  font-weight: 700; text-align: center; background: var(--red); color: #fff; margin-left: 4px; }
.who { color: var(--muted); font-size: 12px; }
.who input { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 4px;
  padding: 3px 6px; width: 110px; font-size: 12px; }

main { padding: 20px 24px 90px; max-width: 1800px; margin: 0 auto; }
h1 { font-size: 22px; margin: 4px 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.banner { border: 1px solid var(--warn); background: var(--warn-soft); padding: 10px 14px; border-radius: 8px;
  margin-bottom: 16px; color: #f3d9a6; }
.banner b { color: #ffe3ad; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 11px; margin-top: 2px; }
.kpi.accent { border-top: 3px solid var(--red); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select { background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 7px 10px; }
.toolbar input[type=search] { width: 260px; }
.spacer { flex: 1; }
.btn { display: inline-block; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 7px 12px; cursor: pointer; font: inherit; }
.btn:hover { border-color: #3a4a66; text-decoration: none; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.small { padding: 3px 8px; font-size: 12px; }
details.cols { position: relative; }
details.cols summary { list-style: none; }
details.cols .menu { position: absolute; right: 0; top: 36px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; z-index: 30; columns: 2; width: 420px; }
details.cols label { display: block; padding: 2px 0; white-space: nowrap; }

/* tables */
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  max-height: calc(100vh - 180px); min-height: 420px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; text-align: left;
  position: sticky; top: 0; z-index: 2; cursor: pointer; user-select: none; white-space: nowrap; }
th.sorted-asc::after { content: " ▲"; font-size: 9px; }
th.sorted-desc::after { content: " ▼"; font-size: 9px; }
tbody tr:hover { background: #1a2230; }
td.name { min-width: 220px; }
td.name a { color: var(--text); font-weight: 550; }
td.name .gc { color: var(--muted); font-size: 12px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.muted { color: var(--muted); }
.why { color: var(--warn); font-size: 12px; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; }
.tag.high { border-color: var(--red); color: #ff8b98; background: var(--red-soft); }
.tag.medium { border-color: var(--warn); color: #f3c26b; background: var(--warn-soft); }
.tag.low { color: var(--muted); }
.tag.good { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.tag.unrev { border-color: var(--warn); color: #f3c26b; }
.bar { height: 6px; background: var(--line); border-radius: 3px; width: 70px; display: inline-block; vertical-align: middle; margin-right: 6px; }
.bar i { display: block; height: 100%; background: var(--link); border-radius: 3px; }
table.plain th { cursor: default; position: static; }
table.kv td:first-child { color: var(--muted); }
table.kv td { border-bottom: 1px dashed var(--line); }
tr.struck td { color: var(--muted); text-decoration: line-through; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

/* sticky summary */
.summary { position: fixed; left: 0; right: 0; bottom: 0; background: #0b1017; border-top: 2px solid var(--red);
  display: flex; gap: 36px; padding: 10px 24px; z-index: 25; flex-wrap: wrap; }
.summary div { font-size: 12px; color: var(--muted); }
.summary b { display: block; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 16px 0; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-bottom-color: var(--red); text-decoration: none; }

form.inline { display: inline; }
label.f { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
label.f input, label.f select, label.f textarea, input.f, select.f { display: block; width: 100%; margin-top: 4px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 7px 9px; font: inherit; }
select.f, input.f { display: inline-block; width: auto; }
.warnlist li { color: #f3c26b; }
.okbox { border: 1px solid var(--good); background: var(--good-soft); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.big { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.kpis.five { grid-template-columns: repeat(5, minmax(170px, 1fr)); }
.kpis.watch { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.kpi.small { padding: 10px 14px; background: var(--bg); }
.kpi.small .value { font-size: 18px; }
@media (max-width: 1100px) { .kpis.five, .kpis.watch { grid-template-columns: repeat(2, 1fr); } }
details.tie summary { cursor: pointer; list-style: none; }
details.tie summary::before { content: "▸ "; color: var(--muted); }
details.tie[open] summary::before { content: "▾ "; }
