.viz-root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface-1: #ffffff;
  --text-primary: #191919;
  --text-secondary: #666666;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #257de0;   /* download */
  --series-2: #f47230;   /* upload */
  --good: #0aac23;
  --warning: #fbb315;
  --critical: #dc3c3d;
  --wash: rgba(11, 11, 11, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface-1: #191919;
    --text-primary: #efefef;
    --text-secondary: #9c9c9c;
    --grid: #303030;
    --axis: #474747;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #338ced;
    --series-2: #e76624;
    --wash: rgba(255, 255, 255, 0.06);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "PingFang SC", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}
.viz-root { min-height: 100vh; background: var(--page); color: var(--text-primary); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }

header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
header h1 { font-size: 20px; font-weight: 600; margin: 0; }
.spacer { flex: 1; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-1); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); }
.status.ok .dot { background: var(--good); }
.status.warn .dot { background: var(--warning); }
.status.bad .dot { background: var(--critical); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--surface-1); }
.seg button { border: 0; background: none; color: var(--text-secondary); padding: 5px 11px;
  font: inherit; font-size: 13px; cursor: pointer; }
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { color: var(--text-primary); font-weight: 600; background: var(--wash); }
a.link { color: var(--text-secondary); font-size: 13px; text-decoration: none; }
a.link:hover { text-decoration: underline; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .label { color: var(--text-secondary); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.tile .value small { font-size: 13px; font-weight: 400; color: var(--text-secondary); margin-left: 3px; }
.tile .sub { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
.key.s1 { background: var(--series-1); }
.key.s2 { background: var(--series-2); }
.key.box { height: 10px; width: 10px; border-radius: 2px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 12px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.card-head .note { color: var(--text-secondary); font-size: 12px; }
.legend { display: flex; gap: 14px; color: var(--text-secondary); font-size: 12px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.section-filters { display: flex; gap: 12px; align-items: center; margin: 24px 0 10px; flex-wrap: wrap; }
.section-filters h2 { font-size: 16px; margin: 0; }

.chart { position: relative; height: 240px; }
.chart.short { height: 160px; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart.loading canvas { opacity: 0.45; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 13px; pointer-events: none; }

.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); min-width: 120px; }
.tip .t { color: var(--text-secondary); margin-bottom: 3px; }
.tip .row { display: flex; align-items: center; gap: 7px; }
.tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .row span:last-child { color: var(--text-secondary); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--text-secondary); font-weight: 500; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.table-scroll { overflow-x: auto; max-height: 340px; overflow-y: auto; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.bad::before { background: var(--critical); }
.badge.warn::before { background: var(--warning); }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 12px; margin-top: 6px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; width: 100%; max-width: 340px; }
.login h1 { font-size: 18px; margin: 0 0 16px; }
.login input { width: 100%; font: inherit; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--axis); background: var(--page); color: var(--text-primary); }
.login button { margin-top: 12px; width: 100%; font: inherit; font-weight: 600; padding: 9px;
  border-radius: 8px; border: 0; background: var(--series-1); color: #fff; cursor: pointer; }
.login .err { color: var(--critical); font-size: 13px; min-height: 20px; margin-top: 8px; }
.login .login-lang { margin-top: 14px; }
