/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: oklch(97.6% 0.003 95);
  --panel: oklch(99.7% 0.0015 95);
  --sunken: oklch(96.6% 0.004 95);
  --hover: oklch(98.2% 0.004 95);
  --ink: oklch(21% 0.012 265);
  --ink-2: oklch(42% 0.012 265);
  --ink-3: oklch(51% 0.01 265);
  --line: oklch(91.5% 0.005 265);
  --line-2: oklch(84% 0.007 265);
  --track: oklch(92.5% 0.006 265);

  --accent: oklch(50% 0.2 264);
  --accent-soft: oklch(95% 0.028 264);
  --fill-ok: oklch(55% 0.19 264);
  --warn: oklch(76% 0.155 70);
  --warn-ink: oklch(48% 0.12 60);
  --warn-soft: oklch(96.3% 0.045 85);
  --crit: oklch(60% 0.21 27);
  --crit-ink: oklch(49% 0.19 27);
  --crit-soft: oklch(95.8% 0.028 25);
  --stale: oklch(62% 0.035 265);
  --stale-ink: oklch(44% 0.03 265);
  --stale-soft: oklch(94.5% 0.01 265);
  --focus: oklch(56% 0.2 264);

  --mark-arc: oklch(80% 0.11 262);
  --shadow: 0 1px 0 oklch(20% 0.02 265 / 0.03), 0 1px 3px oklch(20% 0.02 265 / 0.05);
  --radius: 14px;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(16.5% 0.006 265);
    --panel: oklch(19.5% 0.007 265);
    --sunken: oklch(17.6% 0.006 265);
    --hover: oklch(21.5% 0.008 265);
    --ink: oklch(95% 0.004 265);
    --ink-2: oklch(77% 0.008 265);
    --ink-3: oklch(66% 0.01 265);
    --line: oklch(27% 0.008 265);
    --line-2: oklch(35% 0.01 265);
    --track: oklch(28.5% 0.01 265);

    --accent: oklch(74% 0.13 262);
    --accent-soft: oklch(28% 0.05 264);
    --fill-ok: oklch(68% 0.15 262);
    --warn: oklch(79% 0.15 72);
    --warn-ink: oklch(83% 0.12 78);
    --warn-soft: oklch(28% 0.045 70);
    --crit: oklch(66% 0.19 27);
    --crit-ink: oklch(78% 0.13 25);
    --crit-soft: oklch(28% 0.055 25);
    --stale: oklch(60% 0.03 265);
    --stale-ink: oklch(79% 0.02 265);
    --stale-soft: oklch(26% 0.012 265);
    --focus: oklch(74% 0.14 262);

    --mark-arc: oklch(52% 0.2 264);
    --shadow: 0 0 0 1px oklch(100% 0 0 / 0.015);
  }
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
time { font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed; z-index: 20; top: 12px; left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink); color: var(--bg);
  font-weight: 600; text-decoration: none;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

.wrap { width: min(100% - 2 * var(--gutter), 1240px); margin-inline: auto; }

/* ── Mark ───────────────────────────────────────────────────────────────── */

.mark { width: 26px; height: 26px; flex: none; }
.mark-lg { width: 40px; height: 40px; }
.mark-bg { fill: var(--ink); }
.mark-track, .mark-arc { fill: none; stroke-width: 3.2; stroke-linecap: round; }
.mark-track { stroke: var(--bg); stroke-opacity: 0.24; }
.mark-arc { stroke: var(--mark-arc); }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 10px;
  font-size: 14px; font-weight: 550; line-height: 1; white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn[aria-disabled="true"] { cursor: progress; }
.btn-secondary { background: var(--panel); border-color: var(--line-2); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--hover); border-color: color-mix(in oklch, var(--line-2) 60%, var(--ink-3)); }
.btn-secondary[aria-disabled="true"] { color: var(--ink-2); background: var(--panel); border-color: var(--line-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: color-mix(in oklch, var(--ink) 6%, transparent); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: color-mix(in oklch, var(--ink) 86%, var(--bg)); }
.btn-primary[aria-disabled="true"] { background: color-mix(in oklch, var(--ink) 75%, var(--bg)); }
.btn-block { width: 100%; height: 44px; }

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn[aria-disabled="true"] .icon-refresh { animation: spin 0.9s linear infinite; }

@media (pointer: coarse) {
  .btn { height: 44px; }
}

/* ── Loading ───────────────────────────────────────────────────────── */

.boot { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--ink-2); font-size: 14px; text-align: center; }

.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--ink-2);
  animation: spin 0.8s linear infinite;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in oklch, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 10px; min-height: 60px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  margin-inline-end: auto;
  color: var(--ink); text-decoration: none;
  font-weight: 650; letter-spacing: -0.012em;
  border-radius: 8px;
}
.brand-sub { color: var(--ink-3); font-weight: 500; }
.brand-sub::before { content: "/"; margin-inline: 2px 8px; color: var(--line-2); font-weight: 400; }

.sync {
  display: flex; align-items: center; gap: 6px;
  margin-inline-end: 6px;
  font-size: 13px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sync-next { color: var(--ink-3); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fill-ok); flex: none; margin-inline-end: 2px; }
.sync[data-state="issue"] .sync-dot { background: var(--stale); }
.sync[data-state="offline"] .sync-dot { background: var(--warn); }
.sync[data-state="busy"] .sync-dot { background: var(--fill-ok); animation: pulse 1.1s ease-in-out infinite; }

/* ── Main ───────────────────────────────────────────────────────────────── */

main { padding-block: clamp(28px, 4.5vw, 52px) 24px; }
main:focus { outline: none; }

.notice {
  margin-bottom: 28px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--warn-soft); color: var(--warn-ink);
  border: 1px solid color-mix(in oklch, var(--warn) 30%, transparent);
}
/* Transient confirmations float as a toast so the page doesn't shift. */
.notice[data-tone="info"] {
  position: fixed; z-index: 30; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  width: max-content; max-width: calc(100% - 2 * var(--gutter));
  margin: 0; padding: 10px 16px;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-color: transparent;
  box-shadow: 0 8px 24px oklch(15% 0.02 265 / 0.22);
  animation: toast-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Overview ───────────────────────────────────────────────────────────── */

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.95fr) minmax(0, 1.2fr);
  margin-bottom: clamp(32px, 4.5vw, 56px);
}
.kpi { min-width: 0; padding: 2px clamp(20px, 3vw, 40px) 4px; border-inline-start: 1px solid var(--line); }
.kpi-primary { padding-inline-start: 0; border-inline-start: 0; }
.kpi-label { margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kpi-value {
  font-family: var(--display);
  font-size: clamp(52px, 6.6vw, 84px);
  font-weight: 650;
  line-height: 0.92;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}
.kpi-value-md { font-size: clamp(36px, 3.6vw, 48px); letter-spacing: -0.04em; line-height: 1; }
.kpi-unit { margin-inline-start: 8px; font-family: var(--sans); font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--ink-2); }
.kpi-clear { color: var(--ink-2); }
.kpi-value.is-empty { padding-block: 0.18em 0.1em; font-size: clamp(30px, 3.2vw, 40px); font-weight: 600; letter-spacing: -0.03em; color: var(--ink-3); }
.kpi-sub { margin-top: 12px; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; text-wrap: pretty; }
.kpi-foot { margin-top: 12px; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }

.stack { display: flex; gap: 3px; height: 10px; margin-top: 22px; max-width: 560px; }
.seg {
  position: relative; overflow: hidden;
  flex: var(--grow, 1) 1 0; min-width: 6px;
  border-radius: 3px;
  background: var(--track);
}

.alist { display: grid; gap: 1px; margin: 14px -10px 0; }
.alink {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px;
  border: 0; border-radius: 8px;
  background: none; text-align: start;
  font-size: 14px; cursor: pointer;
  transition: background-color 0.12s ease;
}
.alink:hover { background: color-mix(in oklch, var(--ink) 5%, transparent); }
.alink-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.alink-why { margin-inline-start: auto; padding-inline-start: 8px; color: var(--ink-3); font-size: 13px; white-space: nowrap; }

/* ── Tones (dots, pills, meters, rails) ─────────────────────────────────── */

[data-tone="ok"] { --tone: var(--fill-ok); }
[data-tone="warn"] { --tone: var(--warn); }
[data-tone="crit"] { --tone: var(--crit); }
[data-tone="error"] { --tone: var(--warn); }
[data-tone="stale"] { --tone: var(--stale); }
[data-tone="pending"], [data-tone="muted"] { --tone: var(--ink-3); }

.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--tone); }
/* Ring = data problem (no reading or old reading); solid = allowance level. */
.dot[data-tone="error"], .dot[data-tone="stale"], .dot[data-tone="pending"], .dot[data-tone="muted"] { background: none; box-shadow: inset 0 0 0 1.75px var(--tone); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 100%;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 18px;
  white-space: nowrap;
}
.pill-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--tone); }
.pill[data-tone="ok"] { padding-inline-start: 0; color: var(--ink-2); font-weight: 500; }
.pill[data-tone="warn"] { background: var(--warn-soft); color: var(--warn-ink); }
.pill[data-tone="crit"] { background: var(--crit-soft); color: var(--crit-ink); }
.pill[data-tone="error"] { background: var(--warn-soft); color: var(--warn-ink); }
.pill[data-tone="stale"] { background: var(--stale-soft); color: var(--stale-ink); }
.pill[data-tone="pending"] { box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); font-weight: 500; }
.pill[data-tone="muted"] { padding-inline-start: 0; color: var(--ink-3); font-weight: 500; }
.pill[data-tone="error"] .pill-dot, .pill[data-tone="stale"] .pill-dot,
.pill[data-tone="pending"] .pill-dot, .pill[data-tone="muted"] .pill-dot { background: none; box-shadow: inset 0 0 0 1.5px var(--tone); }

.flag {
  display: inline-flex; align-items: center; gap: 5px;
  margin-inline-start: 8px;
  font-size: 12px; font-weight: 500; color: var(--stale-ink);
}
.flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--stale); }

.meter { position: relative; height: 6px; overflow: hidden; border-radius: 3px; background: var(--track); }
.meter-fill, .seg-fill {
  position: absolute; inset: 0 auto 0 0;
  width: calc(var(--fill, 0) * 100%);
  border-radius: inherit;
  background-color: var(--tone);
  transform-origin: left center;
}
.meter[data-tone="crit"], .seg[data-tone="crit"] { background: color-mix(in oklch, var(--crit) 22%, var(--panel)); }
/* Stripes mark a value that is real but no longer current. */
.meter[data-stale] .meter-fill, .seg[data-stale] .seg-fill {
  background-image: repeating-linear-gradient(-45deg, transparent 0 3px, color-mix(in oklch, var(--panel) 52%, transparent) 3px 6px);
}
/* No reading at all: a dotted baseline instead of an empty (zero-looking) bar. */
.meter[data-state="unknown"] {
  background: repeating-linear-gradient(90deg, var(--line-2) 0 3px, transparent 3px 7px) 0 50% / 100% 2px no-repeat;
}

/* ── Ledger ─────────────────────────────────────────────────────────────── */

.ledger-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 36px; margin-bottom: 12px; }
.ledger-title { display: flex; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.count { color: var(--ink-3); font-size: 13px; font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }

.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.select { position: relative; display: inline-flex; }
.select::after {
  content: ""; position: absolute; top: 50%; right: 10px;
  width: 10px; height: 10px; margin-top: -5px;
  background: var(--ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5 5 6.5 8 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5 5 6.5 8 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
.select select {
  appearance: none; -webkit-appearance: none;
  height: 32px; padding: 0 30px 0 11px;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--panel);
  color: var(--ink); font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.select select:hover { border-color: color-mix(in oklch, var(--line-2) 55%, var(--ink-3)); }
@media (pointer: coarse) { .select select { height: 40px; } }

.panel {
  overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.table thead th {
  padding: 11px 16px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px; font-weight: 600; text-align: start; vertical-align: bottom;
  white-space: normal;
}
.h-note { display: block; font-weight: 450; color: color-mix(in oklch, var(--ink-3) 80%, var(--panel)); }
.h-account { width: 22%; padding-inline-start: 20px !important; }
.h-status { width: 14%; }
.h-remaining { width: 21%; }
.h-used { width: 8%; text-align: end !important; }
.h-organic { width: 8%; text-align: end !important; }
.h-forecast { width: 16%; padding-inline-start: 16px !important; }
.h-data { width: 11%; }

.row { cursor: pointer; transition: background-color 0.12s ease; }
.row > th, .row > td {
  padding: 15px 16px;
  border-top: 1px solid var(--line);
  text-align: start; font-weight: inherit;
  vertical-align: middle;
}
.table tbody .row:first-child > * { border-top: 0; }
.row:hover { background: var(--hover); }
.row[data-open] { background: var(--sunken); }
.row > :first-child { padding-inline-start: 20px; box-shadow: inset 3px 0 0 var(--rail, transparent); }
.row[data-tone="crit"] { --rail: var(--crit); }
.row[data-tone="warn"], .row[data-tone="error"] { --rail: var(--warn); }
.row[data-tone="stale"] { --rail: var(--stale); }
.row.is-flash { animation: flash 1.6s ease-out; }

.toggle {
  display: flex; align-items: flex-start; gap: 8px;
  width: 100%; padding: 0;
  border: 0; border-radius: 6px;
  background: none; text-align: start;
  cursor: pointer;
}
.toggle:focus-visible { outline-offset: 5px; }
.chev {
  width: 14px; height: 14px; flex: none; margin: 3px 0 0 -4px;
  fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.row:hover .chev { stroke: var(--ink-2); }
.acct { display: grid; min-width: 0; }
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; letter-spacing: -0.006em; }
.acct-note { display: block; margin-top: 3px; font-size: 12px; line-height: 1.4; color: var(--ink-3); overflow-wrap: anywhere; }

.rem { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rem-value { font-family: var(--display); font-size: 20px; font-weight: 650; letter-spacing: -0.025em; line-height: 1; }
.rem-of { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink-3); font-size: 13px; }
.rem-pct { margin-inline-start: auto; padding-inline-start: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.rem-unknown { font-size: 15px; font-weight: 600; color: var(--ink-3); line-height: 20px; }

.cell-num { text-align: end !important; font-variant-numeric: tabular-nums; }
.n { font-weight: 550; }
.n-quiet { font-weight: 450; color: var(--ink-2); }
.cell-forecast { padding-inline-start: 16px !important; }
.cell-main { display: block; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-sub { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font-size: 12.5px; }
.cell-sub.is-warn { color: var(--warn-ink); }
.cell-sub.is-crit { color: var(--crit-ink); }
.cell-sub.is-stale { color: var(--stale-ink); }
.unknown { color: var(--ink-3); }

.empty-row td { padding: 40px 20px; text-align: center; color: var(--ink-3); }

/* Detail drawer */
.detail > td { padding: 2px 20px 24px 42px; background: var(--sunken); }
.detail[data-tone="crit"] > td { box-shadow: inset 3px 0 0 var(--crit); }
.detail[data-tone="warn"] > td, .detail[data-tone="error"] > td { box-shadow: inset 3px 0 0 var(--warn); }
.detail[data-tone="stale"] > td { box-shadow: inset 3px 0 0 var(--stale); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.05fr) minmax(0, 1.25fr); gap: 20px 36px; animation: rise 0.22s ease-out; }
.detail-grid[data-blocks="2"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); max-width: 980px; }
.d-block { min-width: 0; }
.d-title { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; color: var(--ink-3); font-size: 12px; font-weight: 600; }
.d-lead { font-weight: 600; }
.d-text { margin-top: 4px; max-width: 52ch; color: var(--ink-2); font-size: 13.5px; text-wrap: pretty; }

.calc { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.calc div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.calc dt { color: var(--ink-2); }
.calc .calc-total { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line-2); font-weight: 650; }
.calc .calc-total dt { color: var(--ink); }

.apps { max-height: 216px; overflow: auto; font-size: 13.5px; }
.apps li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; padding: 6px 0; border-top: 1px solid var(--line); }
.apps li:first-child { border-top: 0; padding-top: 3px; }
.app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.app-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.app-n { text-align: end; font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.app-n small { font-size: 12px; font-weight: 450; color: var(--ink-3); }
.app-n-quiet { font-weight: 450; color: var(--ink-2); font-size: 12.5px; }

.facts { display: grid; gap: 5px; font-size: 13.5px; }
.facts div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; }
.facts dt { color: var(--ink-3); }
.facts dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.d-note {
  margin-top: 12px; padding: 8px 11px;
  border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px; line-height: 1.45; text-wrap: pretty;
}
.d-note[data-tone="warn"] { background: var(--warn-soft); border-color: transparent; color: var(--warn-ink); }
.d-note[data-tone="crit"] { background: var(--crit-soft); border-color: transparent; color: var(--crit-ink); }
.d-note[data-tone="stale"] { background: var(--stale-soft); border-color: transparent; color: var(--stale-ink); }

.method { max-width: 92ch; margin-top: 16px; color: var(--ink-3); font-size: 13px; line-height: 1.6; text-wrap: pretty; }
.method strong { color: var(--ink-2); font-weight: 600; }

.footer { padding-block: 22px 36px; border-top: 1px solid var(--line); margin-top: 28px; color: var(--ink-3); font-size: 12.5px; }

/* ── Motion ─────────────────────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.25; } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(-3px); } }
@keyframes flash { from { background-color: var(--accent-soft); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (prefers-reduced-motion: no-preference) {
  [data-intro] .meter-fill, [data-intro] .seg-fill {
    animation: grow 0.9s cubic-bezier(0.22, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms + 60ms);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .h-organic, .cell-organic { display: none; }
  .h-account { width: 23%; }
  .h-status { width: 16%; }
  .h-remaining { width: 24%; }
  .h-used { width: 9%; }
  .h-forecast { width: 17%; }
  .h-data { width: 11%; }
  .table thead th, .row > th, .row > td { padding-inline: 12px; }
  .h-forecast, .cell-forecast { padding-inline-start: 16px !important; }
  .detail-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .detail-grid > :last-child:nth-child(3) { grid-column: 1 / -1; }
}

@media (max-width: 920px) {
  .overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 28px; }
  .kpi-primary { grid-column: 1 / -1; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
  .kpi-primary + .kpi { padding-inline-start: 0; border-inline-start: 0; }
  .stack { max-width: none; }
}

@media (max-width: 960px) {
  .table, .table tbody { display: block; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "acct acct acct status"
      "rem rem rem rem"
      "used org plan data";
    gap: 14px 12px;
    padding: 16px 16px 16px 18px;
    border-top: 1px solid var(--line);
    box-shadow: inset 3px 0 0 var(--rail, transparent);
  }
  .table tbody .row:first-child { border-top: 0; }
  .row > th, .row > td { display: block; padding: 0 !important; border: 0; box-shadow: none !important; min-width: 0; }
  .cell-account { grid-area: acct; }
  .cell-status { grid-area: status; justify-self: end; align-self: start; }
  .cell-remaining { grid-area: rem; }
  .cell-used { grid-area: used; }
  .cell-organic { grid-area: org; display: block !important; }
  .cell-forecast { grid-area: plan; }
  .cell-data { grid-area: data; }
  .cell-num { text-align: start !important; }
  .cell-used, .cell-organic, .cell-forecast, .cell-data { font-size: 13.5px; }
  .row [data-label]::before {
    content: attr(data-label);
    content: attr(data-label) / "";
    display: block; margin-bottom: 1px;
    color: var(--ink-3); font-size: 11.5px; font-weight: 500;
  }
  .rem-value { font-size: 24px; }
  .row-nodata { grid-template-areas: "acct acct acct status" "rem rem rem rem" "plan plan data data"; }
  .row-nodata .cell-used, .row-nodata .cell-organic, .row-nodata .meter { display: none !important; }
  .row-nodata .rem { margin-bottom: 0; }
  .pill { white-space: normal; }
  .flag { display: flex; justify-content: flex-end; margin: 4px 0 0; }

  .detail { display: block; }
  .detail > td { display: block; padding: 4px 16px 20px 18px; }
  .detail-grid, .detail-grid[data-blocks="2"] { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .detail-grid > :last-child:nth-child(3) { grid-column: auto; }
  .empty-row, .empty-row td { display: block; }
}

@media (max-width: 760px) {
  .topbar { position: static; }
  .topbar-inner { flex-wrap: wrap; row-gap: 0; padding-block: 10px; }
  .sync { order: 5; flex-basis: 100%; margin: 2px 0 0; padding-inline-start: 0; }
}

@media (max-width: 560px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
  .kpi { grid-column: auto; padding: 0 0 24px; border-inline-start: 0; border-bottom: 1px solid var(--line); }
  .kpi:last-child { padding-bottom: 0; border-bottom: 0; }
  .overview { row-gap: 24px; }
  .kpi-primary { padding-bottom: 24px; }
  .ledger-bar { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .brand-sub { display: none; }
  .row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "acct status"
      "rem rem"
      "used org"
      "plan data";
  }
  .row-nodata { grid-template-areas: "acct status" "rem rem" "plan data"; }
  .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #refresh { width: 44px; padding: 0; }
  .facts div { grid-template-columns: 96px minmax(0, 1fr); }
}


.language { flex: none; }
.language select { min-width: 64px; }

.cell-status .pill { max-width: 100%; white-space: normal; line-height: 1.35; text-wrap: balance; }
.cell-status .pill-dot { flex: none; }
.cell-forecast .cell-main, .cell-forecast .cell-sub { white-space: normal; }
.cell-forecast .cell-main { font-size: 13px; }
.cell-main.is-warn { color: var(--warn-ink); }
.cell-main.is-crit { color: var(--crit-ink); }
@media (max-width: 960px) {
  .cell-forecast .cell-main { font-size: 13.5px; }
  .cell-status { min-width: 0; max-width: 100%; }
}
