/* Dark, dense, and legible at a glance — this page is read, not browsed.
   Deliberately no web fonts: an admin page should not wait on a font CDN. */

:root {
  --bg: #0d0f13;
  --bg-2: #14171d;
  --surface: #171b22;
  --border: #252b35;
  --text: #e8eaed;
  --muted: #98a1ae;
  --muted-2: #6b7484;
  --accent: #ff6a1a;
  --accent-2: #6ea8fe;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px clamp(16px, 4vw, 40px) 60px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Hidden until auth resolves, so the shell never flashes before a redirect to sign-in. */
  visibility: hidden;
}
body.authed { visibility: visible; }

h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { margin: 36px 0 6px; font-size: 1.05rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }
h3 { margin: 0; font-size: 1rem; }
p { margin: 0; }

.muted { color: var(--muted); }
.note { margin-bottom: 14px; font-size: 0.87rem; max-width: 70ch; }
.num { font-family: var(--mono); text-align: right; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.controls { display: flex; gap: 8px; }

select, button {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font: inherit; font-size: 0.9rem; cursor: pointer;
}
select:hover, button:hover { border-color: var(--muted-2); }

/* One hero tile carrying the headline number and the all-properties chart, with the
   supporting figures stacked beside it. */
.hero {
  display: grid; gap: 12px; margin: 20px 0 8px;
  grid-template-columns: minmax(0, 2.2fr) minmax(210px, 1fr);
}
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }

.hero-main {
  background: linear-gradient(180deg, var(--bg-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px 14px;
  min-width: 0;
}
.hero-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.hero-v { font-family: var(--mono); font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1.05; letter-spacing: -0.03em; }
.hero-l { margin-top: 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted-2); }
.hero-range { font-family: var(--mono); font-size: 0.78rem; }
.hero-chart { margin-top: 10px; }
.hero-chart .chart-block:first-child { margin-top: 8px; }

.hero-side { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.total { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.total-v { font-family: var(--mono); font-size: 1.5rem; letter-spacing: -0.02em; }
.total-l { margin-top: 2px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  min-width: 0; /* grid items default to min-content; without this a wide chart cannot shrink */
}

/* Expanded: the card takes the whole row. Bar width decides whether a value label fits, so the
   full width is the feature, not decoration. */
.card--expanded {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.card--expanded .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 720px; }
@media (max-width: 640px) {
  .card--expanded .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { margin: 0; font-size: 1rem; font-weight: 600; color: var(--text); text-decoration: none; }
a.card-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.admin-link {
  display: inline-block; margin: -6px 0 12px;
  font-size: 0.8rem; color: var(--accent-2); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.admin-link:hover { border-bottom-color: var(--accent-2); }
.pill {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; }
.stat-v { font-family: var(--mono); font-size: 1.12rem; }
.stat-l { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); }
.stat-s { font-size: 0.72rem; color: var(--muted-2); font-style: italic; }

/* Bar charts. Laid out in real pixels by ops.js — no CSS sizing here, or the labels would
   shear. The slot exists only to give the script a width to measure. */
.chart-slot { display: block; width: 100%; min-width: 0; }
.chart { display: block; overflow: visible; }
.chart-base { stroke: var(--border); stroke-width: 1; }
.chart-bar { fill: var(--accent); }
.chart-bar:hover { fill: #ff8a4a; }
.chart-label { font-family: var(--mono); pointer-events: none; }
/* Inside a bar: dark text on the bar's own colour. Above one: muted, so it never competes
   with the bar it belongs to. */
.chart-label.in { fill: #1a0f07; opacity: 0.85; }
.chart-label.out { fill: var(--muted-2); }

.chart.users .chart-bar { fill: var(--accent-2); }
.chart.users .chart-bar:hover { fill: #96c0ff; }
.chart.users .chart-label.in { fill: #06101f; }
.chart.cost .chart-bar { fill: var(--accent-2); }
.chart.cost .chart-bar:hover { fill: #96c0ff; }
.chart.cost .chart-label.in { fill: #06101f; }

.chart-block { margin-top: 14px; }
.chart-cap {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px;
}
.chart-cap-l { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted-2); }
.chart-cap-v { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }

/* Collapsed by default: four numbers at a glance, charts on request. */
.expand {
  margin-top: 14px; width: 100%; padding: 6px 10px;
  background: transparent; border: 1px dashed var(--border); border-radius: 8px;
  color: var(--muted); font-size: 0.8rem;
}
.expand:hover { border-color: var(--muted-2); color: var(--text); border-style: solid; }
.detail { display: none; }
.detail.open { display: block; }

.pages { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); }
.pages li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 0.88rem; color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl td:first-child { white-space: nowrap; }
.bar-cell { width: 100%; }
.bar { height: 7px; border-radius: 999px; background: var(--accent-2); min-width: 2px; }

footer { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.85rem; }

@media (prefers-reduced-motion: no-preference) {
  .card, .total { transition: border-color 0.2s; }
}
