/* Admin page (admin.html). Builds on app.css's color tokens, panels and buttons. */

/* The chart's one series color, checked against the panel in each theme (>= 3:1). */
:root { --chart: #2459cc; }
:root[data-theme="dark"] { --chart: #5b8ef5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart: #5b8ef5; } }

a.brand { color: inherit; text-decoration: none; }
.admin-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.admin-sub { margin: 0; color: var(--soft); font-size: 14px; }
main.admin { display: flex; flex-direction: column; gap: 16px; }
main.admin .page-head { margin-bottom: 2px; }
main.admin h2 { margin: 0; }
.foot a { color: var(--soft); }

/* Loading / signed-out / not-allowed / not-set-up / error */
.admin-state { max-width: 640px; }
.state-title { margin: 0; font-size: 16px; font-weight: 700; }
.state-body { margin: 6px 0 0; color: var(--soft); font-size: 14px; line-height: 1.5; }
.state-body:empty { display: none; }
.state-body code { font-family: "JetBrains Mono", monospace; font-size: 12.5px; background: var(--tint-2); padding: 1px 5px; border-radius: 5px; color: var(--ink); }
.state-body ol { margin: 8px 0 0; padding-left: 20px; }
.state-body li { margin: 4px 0; }
.state-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.state-actions:empty { display: none; }
.state-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }

#stats { display: flex; flex-direction: column; gap: 16px; }
#stats[hidden] { display: none; }
#stats.refetching { opacity: 0.55; transition: opacity 0.15s; } /* keep the old numbers on screen while refreshing */

/* Hero number + stat tiles */
.admin-hero { display: flex; gap: 24px 40px; align-items: flex-end; flex-wrap: wrap; }
.tile-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--soft); }
.hero-value { margin: 2px 0 0; font-size: 56px; font-weight: 700; letter-spacing: -1.5px; line-height: 1.05; }
.tile-note { margin: 4px 0 0; font-size: 13px; color: var(--soft); }
.kpis { display: flex; flex-wrap: wrap; gap: 12px; flex: 1; justify-content: flex-end; }
.kpi { min-width: 150px; padding: 12px 16px; border-radius: 14px; background: var(--tint-1); box-shadow: 0 0 0 1px var(--panel-ring); }
.kpi .kpi-value { margin: 2px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }

/* Column chart */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.chart .grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--check-border); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--soft); font: 500 11px "Inter", sans-serif; font-variant-numeric: tabular-nums; }
.chart .peak { fill: var(--ink); font: 600 12px "Inter", sans-serif; }
.chart .bar { fill: var(--chart); transition: opacity 0.12s; }
.chart.hovering .bar { opacity: 0.45; }
.chart.hovering .bar.on { opacity: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart-empty { margin: 4px 0 0; font-size: 13px; color: var(--soft); }

.chart-tip {
  position: fixed; z-index: 40; pointer-events: none; padding: 7px 10px; border-radius: 10px;
  background: var(--panel-solid); box-shadow: var(--shadow), 0 0 0 1px var(--panel-ring);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.chart-tip .key { width: 12px; height: 2px; border-radius: 1px; background: var(--chart); }
.chart-tip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip span { font-size: 12px; color: var(--soft); }

.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; font-size: 13px; color: var(--soft); width: fit-content; }
.table-view .admin-table { margin-top: 8px; max-width: 360px; }

/* Tables and count lists */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--soft); padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; padding-left: 12px; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.counts { margin: 0; }
.counts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.counts div:last-child { border-bottom: none; }
.counts dt { color: var(--ink); }
.counts dt small { display: block; color: var(--soft); font-size: 12px; margin-top: 1px; }
.counts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Share of accounts with a school connected: fill and track from the same blue. */
.meter-block { margin-bottom: 10px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; color: var(--soft); }
.meter-top strong { font-size: 20px; color: var(--ink); }
.meter { height: 8px; border-radius: 4px; background: var(--brand-tint); margin-top: 8px; overflow: hidden; }
.meter > div { height: 100%; border-radius: 4px; background: var(--chart); }

.admin-links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 24px; }
.admin-links li { padding: 6px 0; }
.admin-links a { font-weight: 600; font-size: 14px; }
.admin-links span { display: block; font-size: 12.5px; color: var(--soft); margin-top: 2px; }

@media (max-width: 720px) {
  .admin-hero { flex-direction: column; align-items: stretch; gap: 16px; }
  .kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpi { min-width: 0; padding: 10px 12px; }
  .kpi .tile-label { font-size: 12px; }
  .kpi .kpi-value { font-size: 22px; }
  .hero-value { font-size: 48px; }
  .admin-actions .mono { display: none; }
}
