:root {
  --bg: #0e1011;
  --surface: #151819;
  --line: #262b2d;
  --text: #e8ecec;
  --muted: #8d9698;
  --accent: #ff7a1a;
  --accent-soft: rgb(255 122 26 / .14);
  --bad: #ff5d5d;
  --ok: #4cc38a;
  --radius: 14px;
  --radius-sm: 8px;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f3;
    --surface: #ffffff;
    --line: #dcdfde;
    --text: #141718;
    --muted: #596265;
    --accent: #d95a00;
    --accent-soft: rgb(217 90 0 / .12);
    --bad: #c62828;
    --ok: #1c8a5a;
  }
}

:root[data-theme="light"] {
  --bg: #f3f4f3;
  --surface: #ffffff;
  --line: #dcdfde;
  --text: #141718;
  --muted: #596265;
  --accent: #d95a00;
  --accent-soft: rgb(217 90 0 / .12);
  --bad: #c62828;
  --ok: #1c8a5a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; color: var(--muted); font-weight: 500; }

.bar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.bar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 16px;
}
.brand { font-weight: 600; letter-spacing: -.01em; margin-right: auto; white-space: nowrap; }

.status {
  font: 500 13px/1 var(--mono); color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0;
}
.status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
}
.status[data-state="live"] { color: var(--text); }
.status[data-state="live"]::before { background: var(--ok); }
.status[data-state="stale"] { color: var(--bad); }
.status[data-state="stale"]::before { background: var(--bad); }

button { font: inherit; color: inherit; cursor: pointer; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.ghost { text-decoration: none; }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.primary {
  background: var(--accent); color: #140a02; border: 0; border-radius: var(--radius-sm);
  padding: 11px 18px; font-weight: 600;
  transition: transform .12s, filter .15s;
}
:root[data-theme="light"] .primary { color: #fff; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .primary { color: #fff; } }
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px) scale(.99); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }

/* login */
.login { min-height: 60dvh; display: grid; place-items: center; }
.login form {
  width: min(100%, 380px); display: grid; gap: 10px;
}
.login h1 { font-size: 22px; margin-bottom: 8px; }
.login label { font-size: 13px; color: var(--muted); }
.login input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: 500 15px var(--mono);
}
.login input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { margin: 0 0 6px; font-size: 13px; color: var(--muted); min-height: 20px; }
.hint[data-error="1"] { color: var(--bad); }

/* layout */
.dash { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 920px) {
  .dash { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
}

.gauge-card, .quota-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 20px 22px;
}

/* gauge */
.gauge { display: block; width: 100%; max-width: 560px; margin: 8px auto 0; height: auto; overflow: visible; }
.g-track, .g-fill { fill: none; stroke-linecap: round; stroke-width: 14; }
.g-track { stroke: var(--line); }
.g-fill { stroke: var(--accent); transition: stroke-dasharray .9s cubic-bezier(.2, .9, .2, 1); }
.tick { stroke: var(--muted); stroke-width: 1.5; opacity: .6; }
.tick.minor { opacity: .3; stroke-width: 1; }
.tick-label { fill: var(--muted); font: 500 11px var(--mono); text-anchor: middle; dominant-baseline: middle; }
.needle {
  transform-box: view-box; transform-origin: 200px 200px;
  transition: transform .9s cubic-bezier(.2, .9, .2, 1);
}
.needle line { stroke: var(--text); stroke-width: 3.5; stroke-linecap: round; }
.hub { fill: var(--surface); stroke: var(--text); stroke-width: 3; }
.g-value { fill: var(--text); font: 600 46px var(--mono); font-variant-numeric: tabular-nums; }
.g-unit { fill: var(--muted); font: 500 13px var(--sans); }
.gauge-card[data-stale="1"] .g-fill, .gauge-card[data-stale="1"] .needle { opacity: .35; }

.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px;
  margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
}
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 4px 0 0; font: 600 18px var(--mono); font-variant-numeric: tabular-nums; }
.note { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); max-width: 62ch; }
.stats dd.small { font-size: 14px; font-weight: 500; color: var(--muted); }

.spark-wrap { margin-top: 18px; }
.spark { display: block; width: 100%; height: 64px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.8; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-area { fill: var(--accent-soft); stroke: none; }
.spark-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* quotas */
.sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); min-height: 20px; }
.quotas { display: grid; gap: 22px; margin-top: 18px; }
.fam-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fam-name { font-weight: 600; }
.fam-pct { font: 600 22px var(--mono); font-variant-numeric: tabular-nums; }
.fam-pct[data-low="1"] { color: var(--bad); }
.fam-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.acc { margin-top: 12px; }
.acc-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; gap: 8px; }
.acc-row span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.acc-tier { margin-left: 6px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.meter { position: relative; height: 8px; border-radius: 4px; }
.meter::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.meter-fill {
  position: relative; height: 100%; border-radius: 4px; background: var(--accent);
  transition: width .8s cubic-bezier(.2, .9, .2, 1);
}
.meter-fill[data-low="1"] { background: var(--bad); }
.acc[data-off="1"] { opacity: .5; }
.acc[data-off="1"] .meter-fill { background: var(--muted); }

.empty { color: var(--muted); font-size: 14px; }
.foot { margin: 20px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* loading skeleton */
.dash[data-loading="1"] .g-value, .dash[data-loading="1"] .stats dd { color: transparent; border-radius: 6px; background: var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .dash[data-loading="1"] .stats dd { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .45; } }
}

@media (max-width: 520px) {
  .bar-inner { gap: 10px; }
  .status { font-size: 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .gauge-card, .quota-card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .needle, .g-fill, .meter-fill { transition: none; }
}
