:root {
  color-scheme: dark;
  --page: #0f0f0e;
  --card: #1a1a19;
  --raised: #232321;
  --line: rgba(255, 255, 255, 0.08);
  --grid: #2c2c2a;
  --axis: #383835;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --accent: #d95926;
  --s1: #3987e5;
  --s2: #d55181;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --c1: #3987e5;
  --c2: #199e70;
  --c3: #c98500;
  --c4: #d55181;
  --c5: #0ca30c;
  --c6: #9085e9;
  --c7: #e66767;
  --other: #4a4a46;
  --free: #262624;
  --sans: system-ui, -apple-system, "Segoe UI", Ubuntu, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace;
  --r-card: 14px;
  --r-small: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.id img { flex: none; }
.id h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.top-right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13.5px; }
.fresh.stale { color: var(--serious); }
.ghost-btn {
  white-space: nowrap;
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  color: var(--ink-2); cursor: pointer;
}
.ghost-btn:hover { background: var(--raised); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px 15px; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 600; margin-top: 2px; letter-spacing: -0.02em; white-space: nowrap; }
.tile-value small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 3px; letter-spacing: 0; }
.tile-sub { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 4px; border-radius: 4px; background: #24364d; margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--s1); transition: width .4s ease; }
.meter.hot { background: #4a2f24; }
.meter.hot > i { background: var(--serious); }
.flag { display: inline-flex; align-items: center; gap: 5px; color: var(--serious); font-size: 12.5px; }
.flag::before {
  content: "!"; display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%;
  background: var(--serious); color: #1a1a19; font-size: 10px; font-weight: 800;
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px 20px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 15.5px; }
.card-head p { margin: 0; color: var(--muted); font-size: 13px; }

.strip-card { margin-bottom: 26px; }
.strip { display: flex; gap: 2px; height: 28px; }
.strip > div {
  position: relative; border-radius: 4px; min-width: 2px; cursor: pointer;
  display: flex; align-items: center; padding-left: 8px; overflow: hidden;
  color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.strip > div.dark-label { color: #0b0b0b; }
.strip > div.free { background: var(--free); color: var(--muted); cursor: default; font-weight: 500; }
.strip > div:hover:not(.free), .strip > div.lit { filter: brightness(1.18); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { font-weight: 500; color: var(--ink); }

.filters { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.filters h2 { font-size: 17px; margin-right: auto; }
.chips { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.chips button {
  border: 0; background: none; padding: 4px 13px; border-radius: 999px; color: var(--ink-2); cursor: pointer;
  font-size: 13.5px;
}
.chips button:hover { color: var(--ink); }
.chips button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; transition: opacity .2s; }
.charts.loading, .sheet-charts.loading { opacity: .55; }
.chart-card { padding: 16px 18px 12px; min-width: 0; }
.chart-card .card-head { margin-bottom: 4px; }
.chart-now { color: var(--ink-2); font-size: 13px; }
.chart-now b { color: var(--ink); font-weight: 600; }
.chart { position: relative; height: 170px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gl { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.thin { stroke-width: 1.5; }
.chart .boot { stroke: var(--muted); stroke-width: 1; opacity: .7; }
.chart .boot-label { fill: var(--muted); font-size: 10.5px; }
.chart .xhair { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; min-height: 18px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 2px; border-radius: 2px; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; }
.link-btn { background: none; border: 0; padding: 2px 0; color: var(--muted); cursor: pointer; font-size: 12.5px; }
.link-btn:hover { color: var(--ink); text-decoration: underline; }
.chart-table { max-height: 220px; overflow: auto; margin-top: 8px; border-top: 1px solid var(--line); }

.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r-small); padding: 8px 10px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  min-width: 140px;
}
.tip-time { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tip-row i { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--ink-2); }

.run-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.run-tools input[type="search"] {
  background: var(--page); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; min-width: 200px;
  flex: 1 1 200px; max-width: 320px;
}
.run-tools select {
  background: var(--page); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.run-tools .count { margin-left: auto; color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
th.r, td.r { text-align: right; }
th button { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; }
th button[aria-sort] { color: var(--ink); }
th button[aria-sort="descending"]::after { content: " ↓"; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r { font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover, tbody tr.click:focus-visible { background: var(--raised); }
tbody tr:last-child td { border-bottom: 0; }
.nm { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nm-text { min-width: 0; }
.nm-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.kind {
  flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--raised); color: var(--ink-2); font-size: 11px; font-weight: 700;
}
.kind svg { width: 15px; height: 15px; }
.bar-cell { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.mini-bar { width: 56px; height: 4px; background: #24364d; border-radius: 4px; overflow: hidden; flex: none; }
.mini-bar i { display: block; height: 100%; background: var(--s1); border-radius: 4px; }
.spark { display: block; }
.spark path { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }
tr.unacc td { color: var(--muted); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 20; }
.sheet {
  position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--card);
  border-left: 1px solid var(--line); overflow-y: auto; padding: 22px 24px 48px;
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.sheet-head h2 { font-size: 19px; }
.sheet-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; word-break: break-word; }
.sheet-head .grow { flex: 1; min-width: 0; }
.icon-btn {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: none;
  color: var(--ink-2); cursor: pointer; font-size: 17px; line-height: 1;
}
.icon-btn:hover { background: var(--raised); color: var(--ink); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.fact { background: var(--page); border: 1px solid var(--line); border-radius: var(--r-small); padding: 10px 12px; }
.fact .tile-label { font-size: 12px; }
.fact .v { font-size: 18px; font-weight: 600; margin-top: 1px; white-space: nowrap; }
.sheet-section { margin-top: 22px; }
.sheet-section h3 { font-size: 14.5px; margin-bottom: 8px; }
.sheet-section .chips { margin-bottom: 10px; }
.sheet-charts { display: grid; gap: 14px; transition: opacity .2s; }
.sheet-charts .chart { height: 140px; }
.sheet table { font-size: 13px; }
.sheet td, .sheet th { padding: 7px 8px; }
.cmd {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2); word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cmd.open { -webkit-line-clamp: unset; display: block; }
.events { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--ink-2); }
.events li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 28px 26px 26px;
}
.gate-card h1 { font-size: 20px; margin-top: 16px; }
.gate-sub { color: var(--ink-2); margin: 6px 0 18px; font-size: 14px; }
.gate-error { color: var(--serious); margin: -6px 0 14px; font-size: 13.5px; }
.gate form { display: grid; gap: 14px; }
.gate label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.gate input[type="password"] {
  background: var(--page); border: 1px solid var(--line); border-radius: var(--r-small); padding: 10px 12px;
  font-size: 15px;
}
.gate input[type="password"]:focus { border-color: var(--accent); outline: none; }
.gate button {
  margin-top: 4px; background: var(--accent); border: 0; color: #fff; border-radius: var(--r-small);
  padding: 10px 14px; font-weight: 600; cursor: pointer;
}
.gate button:hover { filter: brightness(1.08); }

@media (max-width: 900px) {
  .charts { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 18px 14px 48px; }
  .top { align-items: flex-start; }
  .top-right .fresh { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tile { padding: 12px 13px; }
  .tile-value { font-size: 22px; }
  .tiles > .tile:last-child:nth-child(odd) { grid-column: span 2; }
  .card { padding: 14px 14px; }
  .filters { flex-wrap: wrap; }
  .hide-sm { display: none; }
  .nm-sub { max-width: 170px; }
  .run-tools .count { display: none; }
  .sheet { padding: 18px 16px 40px; border-left: 0; }
  .strip > div { font-size: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
.scroll-x { overflow-x: auto; }
