:root {
  --bg: #111217;
  --panel: #181b1f;
  --panel-2: #1f2328;
  --line: #2a2e35;
  --text: #ccccdc;
  --muted: #8e8e9e;
  --strong: #ffffff;
  --green: #73bf69;
  --yellow: #f2cc0c;
  --orange: #ff9830;
  --red: #f2495c;
  --blue: #5794f2;
  --purple: #b877d9;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }

/* ── Sign in ─────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 28px; display: grid; gap: 10px; }
.login-card p { margin: 0 0 8px; color: var(--muted); }
.login-card label { font-size: 12px; color: var(--muted); }
.login-card input { background: var(--bg); border: 1px solid var(--line); color: var(--strong); border-radius: 4px; padding: 10px 12px; font-size: 16px; }
.login-card input:focus { outline: none; border-color: var(--blue); }
.login-card button { background: var(--blue); color: #fff; border: 0; border-radius: 4px; padding: 10px; font-weight: 600; cursor: pointer; margin-top: 6px; }
.login-error { background: var(--red); color: #fff; padding: 8px 10px; border-radius: 4px; font-size: 13px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--strong); font-size: 16px; white-space: nowrap; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px rgba(255, 152, 48, .2); }

/* ── Top bar ─────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); min-width: 0; }
.crumbs span { color: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ranges { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.ranges button { background: var(--panel-2); color: var(--text); border: 0; border-right: 1px solid var(--line); padding: 5px 12px; cursor: pointer; }
.ranges button:last-child { border-right: 0; }
.ranges button.on { background: var(--blue); color: #fff; }
.fresh { color: var(--muted); font-size: 12px; }
.signout { color: var(--muted); font-size: 12px; }
.stale { background: var(--orange); color: #111; padding: 8px 16px; font-weight: 600; }

/* ── Panels ──────────────────────────────────────────────── */
.app { padding: 12px 16px 40px; display: grid; gap: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px 6px; min-width: 0; }
.panel h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--strong); display: flex; justify-content: space-between; gap: 8px; }
.panel h3 small { color: var(--muted); font-weight: 400; }
.panel .hint { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.chart { min-height: 240px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; min-width: 0; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 30px; font-weight: 600; line-height: 1.2; color: var(--strong); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.good .value { color: var(--green); }
.stat.warn .value { color: var(--yellow); }
.stat.bad { background: var(--red); border-color: var(--red); }
.stat.bad .value, .stat.bad .label, .stat.bad .sub { color: #fff; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: var(--panel-2); }
tr.link { cursor: pointer; }
td.wrap { white-space: normal; word-break: break-all; }
.bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--blue); vertical-align: middle; margin-left: 6px; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11px; font-weight: 600; color: #111; }
.pill.person { background: var(--green); }
.pill.bot { background: var(--muted); }
.pill.server { background: var(--blue); color: #fff; }
.pill.db_down, .pill.db_lost { background: var(--red); color: #fff; }
.pill.db_limit { background: var(--orange); }
.pill.db_other, .pill.app { background: var(--yellow); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
svg.spark { vertical-align: middle; }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.err-msg { white-space: normal; color: var(--text); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

@media (max-width: 1200px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .row { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px)  {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 24px; }
  .top-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .app { padding: 10px; }
}
.sub-time { color: var(--muted); font-size: 11px; }
