:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --card: #ffffff; --line: #e2e4ea; --text: #1d2026; --muted: #6a7080;
  --accent: #2f6f4f; --accent-soft: #e3f1ea; --bad: #b3342f; --bad-soft: #fbe9e8; --warn: #9a6a00;
  --bar: #2f6f4f; --bar2: #9ccbb2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --card: #1c1f25; --line: #2b2f38; --text: #e8eaee; --muted: #9096a4;
    --accent: #5cb98a; --accent-soft: #1e3329; --bad: #ef7b75; --bad-soft: #3a2121; --warn: #e0b04a;
    --bar: #5cb98a; --bar2: #2f5a45;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top { background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
header.top h1 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
header.top h1 .logo { width: 26px; height: 26px; }
header.top h1 .sub { font-weight: 400; color: var(--muted); }
nav { display: flex; gap: 4px; }
nav a { padding: 5px 12px; border-radius: 6px; color: var(--muted); }
nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav a:hover { text-decoration: none; color: var(--text); }
.spacer { flex: 1; }
.live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,111,79,.5); } 100% { box-shadow: 0 0 0 8px rgba(47,111,79,0); } }

main { padding: 20px 24px 48px; max-width: 1240px; margin: 0 auto; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
section { margin-bottom: 26px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }

input, select, button { font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: inherit; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--bad); }
button.small { font-size: 12px; padding: 3px 9px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.tabs button { border: 0; border-radius: 0; padding: 5px 14px; background: transparent; }
.tabs button.on { background: var(--accent); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0 20px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 650; line-height: 1.2; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.kpi .sub b { color: var(--accent); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
tr.req { cursor: pointer; }
tr.req:hover td { background: var(--bg); }
tr.new td { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
tr.detail td { background: var(--bg); font-size: 12px; color: var(--muted); }
tr.detail b { color: var(--text); font-weight: 600; }
.detail .grid { display: flex; gap: 22px; flex-wrap: wrap; }

.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.pill.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pill.bad { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.pill.cache { border-color: var(--accent); color: var(--accent); }
.muted { color: var(--muted); }
.err { color: var(--bad); }
.ok { color: var(--accent); }
code { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--bar); }

.token { margin-top: 10px; padding: 12px; border: 1px solid var(--accent); border-radius: 6px; word-break: break-all; display: none; }
details > summary { cursor: pointer; font-weight: 600; }
.empty { padding: 18px; text-align: center; color: var(--muted); }

#chart { width: 100%; height: 190px; display: block; }
#chart text { fill: var(--muted); font-size: 11px; }
#chart .grid { stroke: var(--line); }
#chart .b1 { fill: var(--bar); }
#chart .b1:hover { opacity: .8; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; display: none; z-index: 9; }

#logs td { padding: 4px 8px; }
