/* Redio portals — shared design system.
 *
 * Station Manager and Office are one family: the app's housing blacks, brass
 * accent and orange signal, Plus Jakarta Sans. Every screen moves the same
 * way (150–350 ms, ease-out, small distances) and stands still under
 * prefers-reduced-motion.
 */

:root {
  color-scheme: dark;
  --void: #0e1012;
  --housing: #16181c;
  --surface: #1c2024;
  --surface-high: #24282e;
  --recess: #121418;
  --hairline: #32373e;
  --hairline-soft: #262a30;
  --ink: #f2f4f7;
  --ink-muted: #9ba2ac;
  --ink-faint: #7d848e;
  --brass: #e9b778;
  --brass-deep: #c7924f;
  --signal: #ff7a1a;
  --signal-deep: #d95926;
  --good: #3fb68b;
  --bad: #e0644b;
  --warn: #e3a33a;

  /* Chart slots — validated (dataviz) against --surface, dark mode. */
  --series-1: #d95926;
  --series-2: #3987e5;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 160ms;
  --t-med: 240ms;
  --t-slow: 340ms;

  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-md: 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  --max: 1200px;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Type ─────────────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brass);
}
.h-display {
  font-size: clamp(40px, 6.4vw, 84px); line-height: 1.02; letter-spacing: -0.035em;
  font-weight: 800; margin: 0;
}
.h1 { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.1; letter-spacing: -0.025em; font-weight: 800; margin: 0; }
.h2 { font-size: 22px; line-height: 1.2; letter-spacing: -0.015em; font-weight: 700; margin: 0; }
.h3 { font-size: 16px; font-weight: 700; margin: 0; }
.lede { font-size: clamp(16px, 1.5vw, 19px); color: var(--ink-muted); max-width: 60ch; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  --bg: var(--surface-high); --fg: var(--ink); --bd: var(--hairline);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-sm);
  background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
  font-weight: 650; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
  text-decoration: none !important;
}
.btn:hover { --bd: #454b54; }
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn.is-busy { opacity: 0.55; cursor: default; pointer-events: none; }
.btn-primary { --bg: var(--brass); --fg: #16120b; --bd: transparent; }
.btn-primary:hover { --bg: #f1c58c; }
.btn-signal { --bg: var(--signal); --fg: #fff; --bd: transparent; }
.btn-signal:hover { --bg: #ff8c38; }
.btn-ghost { --bg: transparent; --bd: transparent; color: var(--ink-muted); }
.btn-ghost:hover { --bg: var(--surface); color: var(--ink); }
.btn-danger { --bg: transparent; --fg: var(--bad); --bd: #5a2c25; }
.btn-lg { height: 54px; padding: 0 26px; font-size: 16px; border-radius: var(--r-md); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-xs); }
.btn-icon { width: 38px; padding: 0; }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > span:first-child { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--r-sm);
  background: var(--recess); border: 1px solid var(--hairline); color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.input:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(233, 183, 120, 0.16); }
.input::placeholder { color: #5f666f; }
.hint { font-size: 12.5px; color: var(--ink-faint); }
.form-error { color: var(--bad); font-size: 13.5px; min-height: 1em; }
.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--recess); border: 1px solid var(--hairline); border-radius: var(--r-sm); }
.segmented button {
  height: 36px; padding: 0 16px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-muted);
  font-weight: 650; cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.segmented button[aria-pressed="true"] { background: var(--surface-high); color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset; }

.switch { position: relative; display: inline-block; vertical-align: middle; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--hairline); transition: background var(--t-fast); pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--t-med) var(--ease-out); }
.switch input:checked + i { background: var(--brass); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--brass); outline-offset: 2px; }

.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink-muted); cursor: pointer; font-weight: 600; font-size: 13.5px; transition: all var(--t-fast); }
.chip[aria-pressed="true"] { background: rgba(233,183,120,0.14); border-color: var(--brass); color: var(--ink); }

/* ── Surfaces ─────────────────────────────────────────────────────────── */
.card { background: var(--housing); border: 1px solid var(--hairline-soft); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-md); }
.card-flat { background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: var(--r-md); padding: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 11.5px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; background: var(--surface-high); color: var(--ink-muted); border: 1px solid var(--hairline); }
.pill-brass { background: rgba(233,183,120,0.13); color: var(--brass); border-color: rgba(233,183,120,0.35); }
.pill-good { background: rgba(63,182,139,0.12); color: #6fd3ad; border-color: rgba(63,182,139,0.35); }
.pill-bad { background: rgba(224,100,75,0.12); color: #f08a74; border-color: rgba(224,100,75,0.35); }
.pill-warn { background: rgba(227,163,58,0.12); color: #f0bd67; border-color: rgba(227,163,58,0.35); }
/* LIVE: the word and the colour say it — no dot. */
.live-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px; background: var(--signal); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }

.divider { height: 1px; background: var(--hairline-soft); margin: 18px 0; border: 0; }

/* ── Motion helpers ───────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out); transition-delay: calc(var(--i, 0) * 45ms); }
.reveal.is-in { opacity: 1; transform: none; }
.view-enter { animation: viewIn var(--t-med) var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.press { transition: transform var(--t-fast) var(--ease-out); }
.press:active { transform: scale(0.985); }
.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-med) var(--ease-out), opacity var(--t-med); opacity: 0; }
.collapse > * { overflow: hidden; }
.collapse.is-open { grid-template-rows: 1fr; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ── Toast ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--surface-high); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 12px 16px; box-shadow: var(--shadow-lg); font-size: 14px; animation: toastIn var(--t-med) var(--ease-out) both; }
.toast.is-bad { border-color: #5a2c25; }
.toast.is-out { animation: toastOut var(--t-fast) ease-in both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ── Sheet (tour, What's New, dialogs) ────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(5, 6, 8, 0.66); backdrop-filter: blur(6px); display: grid; place-items: end center; animation: fadeIn var(--t-med) ease-out both; }
@media (min-width: 720px) { .scrim { place-items: center; } }
.scrim.is-out { animation: fadeOut var(--t-fast) ease-in both; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.sheet { width: min(560px, 100vw); max-height: min(86vh, 760px); overflow: auto; background: var(--housing); border: 1px solid var(--hairline); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 26px; box-shadow: var(--shadow-lg); animation: sheetUp var(--t-slow) var(--ease-out) both; }
@media (min-width: 720px) { .sheet { border-radius: var(--r-xl); } }
.scrim.is-out .sheet { animation: sheetDown var(--t-fast) ease-in both; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes sheetDown { to { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.sheet-head img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.sheet-rows { display: grid; gap: 10px; }
.sheet-row { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--hairline-soft); }
.sheet-row .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(233,183,120,0.12); color: var(--brass); }
.sheet-row .ico svg { width: 20px; height: 20px; }
.sheet-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.dot-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); display: inline-block; }

/* ── App shell (signed in) ────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--hairline-soft); background: var(--housing); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--ink) !important; text-decoration: none !important; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { font-size: 15px; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--r-sm); color: var(--ink-muted); font-weight: 600; font-size: 14.5px; text-decoration: none !important; transition: background var(--t-fast), color var(--t-fast); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-high); color: var(--ink); box-shadow: inset 2px 0 0 var(--brass); }
.nav .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--signal); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.side-foot { margin-top: auto; display: grid; gap: 6px; }
.side-foot .faint { overflow-wrap: anywhere; }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar { display: none; }
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 70; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform var(--t-med) var(--ease-out); box-shadow: var(--shadow-lg); }
  .shell.nav-open .side { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 60; padding: 10px 14px; background: rgba(14,16,18,0.86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--hairline-soft); }
  .topbar .brand { padding: 0; }
  .main { padding-top: 18px; }
}

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--housing); border: 1px solid var(--hairline-soft); border-radius: var(--r-md); padding: 16px; }
.kpi .label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--ink-faint); }

.table-wrap { overflow-x: auto; border: 1px solid var(--hairline-soft); border-radius: var(--r-md); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; padding: 12px 14px; background: var(--housing); border-bottom: 1px solid var(--hairline-soft); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-muted); }
.empty .h3 { color: var(--ink); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-high) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart-card { background: var(--housing); border: 1px solid var(--hairline-soft); border-radius: var(--r-lg); padding: 18px 18px 14px; }
.chart-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head .h3 { font-size: 15px; }
.chart-tools { display: flex; gap: 6px; align-items: center; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-muted); margin: 2px 0 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-plot { position: relative; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-plot svg:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; border-radius: 6px; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface-high); border: 1px solid var(--hairline); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow-md); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity var(--t-fast); }
.chart-tip.is-on { opacity: 1; }
.chart-tip b { display: block; font-size: 12px; color: var(--ink-faint); font-weight: 650; margin-bottom: 2px; }
.chart-tip .tip-row { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.chart-tip .tip-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-caption { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }
.sample-badge { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 5px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; background: repeating-linear-gradient(135deg, rgba(227,163,58,0.18) 0 6px, rgba(227,163,58,0.08) 6px 12px); color: #f0bd67; border: 1px solid rgba(227,163,58,0.4); }
.chart-empty { display: grid; place-items: center; gap: 10px; padding: 40px 12px; text-align: center; color: var(--ink-muted); }
.chart-table { margin-top: 8px; max-height: 280px; overflow: auto; }

/* While an app link (#/…) boots, show a loader instead of the landing. */
.booting #landing { display: none; }
.booting body::after { content: ""; position: fixed; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; border: 2.5px solid var(--hairline); border-top-color: var(--brass); animation: spin 0.8s linear infinite; }
