@font-face {
  font-family: "Geist";
  src: url("/Geist.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f6f5fb;
  --surface: #fcfcfb;
  --tonal: #eeedf6;
  --border: rgba(11, 11, 11, .10);
  --text: #1d1d27;
  --text-2: #52514e;
  --muted: #646576;
  --axis: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --accent: #735cdd;
  --accent-hover: #6650d3;
  --accent-tint: #ebe7fd;
  --error: #c02f2f;
  --good: #006300;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --shadow: 0 1px 2px rgba(22, 18, 48, .05), 0 2px 8px -2px rgba(22, 18, 48, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0c10;
    --surface: #1a1a19;
    --tonal: #24242a;
    --border: rgba(255, 255, 255, .10);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #a3a3ad;
    --axis: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --accent: #8d7bf0;
    --accent-hover: #9c8cf3;
    --accent-tint: #2a2550;
    --error: #ff8a8a;
    --good: #0ca30c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0c10;
  --surface: #1a1a19;
  --tonal: #24242a;
  --border: rgba(255, 255, 255, .10);
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #a3a3ad;
  --axis: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --accent: #8d7bf0;
  --accent-hover: #9c8cf3;
  --accent-tint: #2a2550;
  --error: #ff8a8a;
  --good: #0ca30c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ---- sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.login-card img { border-radius: 12px; margin-bottom: 8px; }
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 14px; }
.login-card label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.login-card input {
  height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--page); padding: 0 12px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.error { color: var(--error); font-size: 13px; margin: 4px 0 0 !important; }
button { cursor: pointer; border: 0; background: none; }
.primary {
  margin-top: 12px; height: 42px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600;
  transition: background .15s;
}
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .6; cursor: default; }

/* ---- top bar */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: inherit; text-decoration: none; }
.brand img { border-radius: 7px; }
.controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.segments { display: inline-flex; background: var(--tonal); border-radius: 10px; padding: 3px; }
.segments button { padding: 5px 11px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--muted); white-space: nowrap; }
.segments button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.quiet { padding: 7px 11px; border-radius: 9px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.quiet:hover { background: var(--tonal); }
.icon-button { display: inline-grid; place-items: center; padding: 7px; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- sections */
.status { min-height: 22px; margin: 14px 0 0; font-size: 13px; }
section { margin: 18px 0 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.section-head p { margin: 0; font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .label { font-size: 13px; color: var(--text-2); font-weight: 550; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 6px; }
.tile .note { font-size: 12px; color: var(--muted); margin-top: 4px; }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; box-shadow: var(--shadow); min-width: 0; }
.card.wide { grid-column: span 2; }
@media (max-width: 760px) {
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .card.wide { grid-column: auto; }
  .tile .value { font-size: 26px; }
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-head .toggle { font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 7px; white-space: nowrap; }
.card-head .toggle:hover { background: var(--tonal); color: var(--text); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); margin: 0 0 8px; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .line-key { height: 3px; border-radius: 2px; width: 14px; }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
svg.chart text { fill: var(--axis); font-size: 11px; font-family: inherit; }
svg.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .baseline { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .cross { stroke: var(--baseline); stroke-width: 1; }
svg.chart .end-label { fill: var(--text-2); font-weight: 600; }

.empty { color: var(--muted); font-size: 13px; padding: 26px 0; text-align: center; }

/* bar lists: name, bar, value */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bars li { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bars .track { height: 12px; position: relative; }
.bars .fill { position: absolute; inset: 0 auto 0 0; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.bars .num { color: var(--text-2); text-align: right; min-width: 54px; }
.bars .num small { color: var(--muted); margin-left: 4px; }

/* tables */
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; color: var(--text-2); font-size: 12.5px; background: color-mix(in srgb, var(--tonal) 50%, transparent); }
td.n, th.n { text-align: right; }
tr:last-child td { border-bottom: 0; }
.data-table { margin-top: 8px; max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--tonal); color: var(--text-2); }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .25); min-width: 130px; max-width: 260px;
}
.tooltip .when { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 7px; }
.tooltip .row i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.tooltip .row strong { font-weight: 650; margin-left: auto; padding-left: 12px; }
