/* ============================================================================
   OME Panel — "Control Room / Signal" identity.
   Broadcast console: console-black surfaces, tally-amber action, signal-green
   live, on-air red. Tokens drive every shared component; retint here to reskin.

   Token scope (U1): color, type scale, radius, elevation shadow, and the
   padding/margin/gap spacing rhythm are fully tokenized below — no raw hex or
   ad-hoc size remains in a page rule for these five categories. A few classes
   of literal px are intentionally left as-is because they aren't "drift" in
   the sense above:
     - @media breakpoints: CSS custom properties cannot appear in a media
       feature without a build step (this project has none by design), and
       the breakpoint set itself is U3's job.
     - border-width: 1px (a universal CSS idiom, not a rhythm value).
     - one-off decorative details: glow blur-radii, vertical-align nudges,
       icon/thumbnail/logo pixel dimensions, transform/opacity/duration/
       z-index/letter-spacing values.
   ============================================================================ */
:root {
  /* ---- Color: 3 bg elevations, borders, 3 text strengths, accent, semantic ---- */
  --bg: #0a0b0d; --panel: #121417; --panel2: #0e0f12; --panel3: #0a0d12;
  --border: #23272e;
  --text: #e8ebee; --muted: #7d8590;
  --ok: #35e07f; --bad: #ff4d4d; --accent: #ffb020; --accent-2: #ff7a00; --warn: #e0a52e;
  --on-accent: #0a0b0d;
  /* U8: same hue as --accent but dedicated — light theme's --accent (#cc7a00)
     fails 4.5:1 against its own panel backgrounds (~3:1), so plain-text links
     need their own token rather than reusing --accent directly. */
  --link: var(--accent);
  --input-bg: #0e0f12;
  /* tally glow tints (translucent, theme-aware chip/badge backgrounds) */
  --glow-live: rgba(53,224,127,.16); --glow-air: rgba(255,77,77,.16);
  --glow-accent: rgba(255,176,32,.14); --glow-warn: rgba(224,165,46,.16);
  --warn-bg: rgba(210,153,34,.08);
  /* derived tints — automatically re-tone with the theme via color-mix, so
     they can never drift out of sync with --muted/--bad the way hand-picked
     rgba() literals used to. */
  --hairline: color-mix(in srgb, var(--muted) 8%, transparent);
  --danger-hover-bg: color-mix(in srgb, var(--bad) 10%, transparent);
  --err-bg: color-mix(in srgb, var(--bad) 7%, transparent);
  /* fixed-dark surfaces: video letterboxing, tooltips, and the Operator
     Studio overlay chrome are deliberately theme-invariant (they float over
     video or need max contrast regardless of the panel's light/dark mode). */
  --video-bg: #000;
  --tooltip-bg: #000; --tooltip-fg: #fff;
  --scrim: rgba(0,0,0,.7); --scrim-soft: rgba(0,0,0,.5);
  --studio-overlay-bg: rgba(20,20,20,.7); --studio-overlay-border: rgba(255,255,255,.2); --studio-scrim-top: rgba(0,0,0,.6);
  --studio-fg: #fff; --studio-muted: #cfd3d8;

  /* ---- Space: every padding/margin/gap value in the file resolves to one
     of these (4px-ish rhythm; a few odd steps are kept because the shell's
     tight controls — pills, nav rows — were hand-tuned to them). ---- */
  --space-2: 2px; --space-3: 3px; --space-4: 4px; --space-5: 5px; --space-6: 6px;
  --space-7: 7px; --space-8: 8px; --space-9: 9px; --space-10: 10px; --space-11: 11px;
  --space-12: 12px; --space-13: 13px; --space-14: 14px; --space-16: 16px;
  --space-18: 18px; --space-20: 20px; --space-22: 22px; --space-24: 24px;
  --space-26: 26px; --space-28: 28px; --space-30: 30px; --space-32: 32px; --space-36: 36px;

  /* ---- Type scale: micro labels through hero stat numbers. Consolidates
     18 drifting sizes (9/10/10.5/11/11.5/12/12.5/13/13.5/14/15/17/18/20/22/
     24/26/28px) down to 9 disciplined steps — every page now shares one
     scale instead of hand-picking a size per view. ---- */
  --fs-10: 10px; --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --fs-16: 16px; --fs-20: 20px; --fs-24: 24px; --fs-28: 28px;

  /* ---- Radius ---- */
  --radius-xs: 4px; --radius-sm: 6px; --radius: 8px; --radius-lg: 12px;
  --radius-pill: 999px;

  /* ---- Shadow (elevation only — per-component glow effects stay literal
     blur-radii next to their token color, same as the tallyPulse/dot glows
     already in this file). ---- */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 6px 20px rgba(0,0,0,.4);
  --shadow: 0 8px 30px rgba(0,0,0,.55);
  --shadow-toast: 0 4px 20px rgba(0,0,0,.45);

  --ctl-h: 32px;

  /* ---- Layout constants: reused structural dimensions (retune the whole
     shell from one place) — distinct from one-off component sizing. ---- */
  --sidebar-w: 220px; --sidebar-w-collapsed: 56px; --content-max-w: 1100px;
  --drawer-w: 480px; --bell-panel-w: 340px; --toast-max-w: 320px;
  --modal-w-sm: 440px; --modal-w-md: 520px; --modal-w-lg: 880px; --cp-w: 620px;
  --icon-sm: 17px;

  --display: "Space Grotesk", system-ui, -apple-system, Segoe UI, sans-serif;
  --body: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
/* Light theme (T1/T8): "daylight console" — redefine tokens, keep tally accents.
   Space/type/radius/shadow-shape/layout tokens above are theme-invariant by
   design; only surface color and elevation-shadow tint need overriding here. */
:root[data-theme="light"] {
  --bg: #f4f5f3; --panel: #ffffff; --panel2: #eceee9; --panel3: #e9ebe6;
  --border: #d6d9d2;
  --text: #1a1c1e; --muted: #5f6670;
  --ok: #1a9e57; --bad: #d63a3a; --accent: #cc7a00; --accent-2: #d66a00; --warn: #b07400;
  --on-accent: #ffffff;
  --link: #8a5000; /* darker than --accent — passes 4.5:1 against white/panel2, --accent doesn't */
  --input-bg: #ffffff;
  --glow-live: rgba(26,158,87,.14); --glow-air: rgba(214,58,58,.12);
  --glow-accent: rgba(204,122,0,.12); --glow-warn: rgba(176,116,0,.16);
  --warn-bg: rgba(176,116,0,.08);
  --shadow-sm: 0 1px 3px rgba(90,96,104,.14);
  --shadow-md: 0 6px 20px rgba(90,96,104,.16);
  --shadow: 0 8px 30px rgba(90,96,104,.18);
  --shadow-toast: 0 4px 20px rgba(90,96,104,.22);
}
* { box-sizing: border-box; }
/* Thin, theme-matched scrollbars everywhere (page, sidebar nav, log stream,
   tables, dropdowns) instead of the browser's default chrome. */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: var(--space-8); height: var(--space-8); }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-pill); }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }
/* U10: the generic drawer/modals sit at right:0 with a closed-state
   translateX(100%) — despite being position:fixed and visually off-screen,
   that still extended the page's scrollable width by the drawer's full
   width (a real ~70px horizontal-scroll sliver, not just a screenshot
   artifact). <html> is the actual scrolling element here, so the fix has to
   go on it, not just <body>. Every internal scrollable region (.tbl-wrap,
   .urlbox, .code-block, etc.) already manages its own overflow-x:auto
   independently, so nothing scrollable is affected. */
html { overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, .brand h1 { font-family: var(--display); }
/* Inline SVG icon sprite (<use href="#i-...">): stroke-based outline icons,
   replacing the old inconsistent-weight HTML-entity glyphs. */
svg.ico { stroke: currentColor; fill: none; stroke-width: 2; flex: none; vertical-align: -3px; }

/* ---- App shell: sidebar + content ---- */
/* Hidden until body.ready (set by app.js after initAuth() resolves) so the
   static markup in index.html — the full sidebar/dashboard shell — never
   flashes on screen before the login overlay has a chance to cover it. */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; visibility: hidden; }
body.ready .app { visibility: visible; }

.sidebar { background: var(--panel2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: var(--space-18) var(--space-20); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-10); }
.sidebar .brand .logo { width: var(--space-26); height: var(--space-26); border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: inline-block; box-shadow: 0 0 12px var(--glow-accent); position: relative; }
.sidebar .brand .logo::after { content: ""; position: absolute; inset: var(--space-8); border-radius: 50%; background: var(--on-accent); opacity: .85; }
.sidebar .brand h1 { font-size: var(--fs-16); margin: 0; font-weight: 700; letter-spacing: .02em; }
/* nav is the scrollable middle section — brand header and foot stay pinned
   even when the link list is taller than the viewport (short screens, or
   more nav items added later). */
.sidebar nav { padding: var(--space-10) var(--space-8); display: flex; flex-direction: column; gap: var(--space-2); flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* Channel strip: rows sit behind a thin tally rail; active item lights amber. */
.sidebar nav a { position: relative; display: flex; align-items: center; gap: var(--space-10); padding: var(--space-9) var(--space-12) var(--space-9) var(--space-14); border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: var(--fs-14); font-weight: 500; transition: color .15s, background .15s; }
.sidebar nav a::before { content: ""; position: absolute; left: var(--space-2); top: 50%; transform: translateY(-50%); width: var(--space-3); height: 0; border-radius: 2px; background: var(--accent); transition: height .18s ease; }
.sidebar nav a .ico { width: var(--icon-sm); height: var(--icon-sm); opacity: .75; }
.sidebar nav a:hover { background: var(--panel); color: var(--text); }
.sidebar nav a.active { background: var(--glow-accent); color: var(--accent); }
.sidebar nav a.active::before { height: 60%; box-shadow: 0 0 8px var(--accent); }
.sidebar nav a.active .ico { opacity: 1; }
.sidebar .foot { margin-top: auto; padding: var(--space-14) var(--space-20); border-top: 1px solid var(--border); font-size: var(--fs-11); color: var(--muted); font-family: var(--mono); display: flex; align-items: center; gap: var(--space-10); flex-wrap: wrap; }
#btn-sidebar-collapse { font-size: var(--fs-12); height: auto; padding: var(--space-3) var(--space-8); transition: transform .15s ease; }

/* ---- Sidebar collapse (icon-only rail) ---- */
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar-collapsed .sidebar .brand h1,
.sidebar-collapsed .sidebar .nav-group,
.sidebar-collapsed .sidebar nav a .lbl,
.sidebar-collapsed .sidebar .foot .lbl,
.sidebar-collapsed .sidebar .lang-pick { display: none; }
.sidebar-collapsed .sidebar nav a { justify-content: center; padding: var(--space-9) 0; }
.sidebar-collapsed #btn-sidebar-collapse { transform: rotate(180deg); }
.sidebar-collapsed .sidebar .foot { justify-content: center; padding: var(--space-14) var(--space-8); }
/* Hover tooltip for collapsed nav links — same data-tip/::after pattern as .tip. */
.sidebar-collapsed .sidebar nav a[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  margin-left: var(--space-10); background: var(--tooltip-bg); color: var(--tooltip-fg); padding: var(--space-6) var(--space-10); border-radius: var(--radius-sm);
  font-size: var(--fs-12); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 200;
}
.sidebar-collapsed .sidebar nav a[data-tip]:hover::after,
.sidebar-collapsed .sidebar nav a[data-tip]:focus-visible::after { opacity: .96; }

/* ---- Content column ---- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(8px); padding: var(--space-14) var(--space-28); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-12); }
.topbar h2 { font-size: var(--fs-16); margin: 0; font-weight: 600; }
#btn-menu-toggle { display: none; }

/* ---- ON-AIR tally strip (signature): topbar master-bus state + signal ---- */
.tally { display: inline-flex; align-items: center; gap: var(--space-9); padding: var(--space-5) var(--space-12) var(--space-5) var(--space-10); border: 1px solid var(--border); border-radius: var(--radius-pill); font-family: var(--mono); font-size: var(--fs-11); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); background: var(--panel2); white-space: nowrap; }
.tally .tdot { width: var(--space-9); height: var(--space-9); border-radius: 50%; background: var(--muted); }
.tally.on { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); background: var(--glow-air); }
.tally.on .tdot { background: var(--bad); box-shadow: 0 0 10px var(--bad); animation: tallyPulse 1.6s ease-in-out infinite; }
@keyframes tallyPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
/* VU / signal meter: N bars, height driven by --lvl (0..1) via inline style. */
.vu { display: inline-flex; align-items: flex-end; gap: var(--space-2); height: var(--space-16); }
.vu i { width: var(--space-3); height: calc(var(--space-3) + var(--space-13) * var(--lvl, 0)); background: var(--ok); border-radius: 1px; opacity: .85; transition: height .35s ease; }
.vu i:nth-child(odd) { background: var(--accent); }
.topbar .tally-wrap { display: inline-flex; align-items: center; gap: var(--space-10); margin-right: var(--space-4); }
.topbar .tag { font-size: var(--fs-12); color: var(--muted); border: 1px solid var(--border); padding: var(--space-2) var(--space-8); border-radius: var(--radius-pill); }
.topbar .live { display: flex; align-items: center; gap: var(--space-6); font-size: var(--fs-12); color: var(--muted); }
.user-info { font-size: var(--fs-12); color: var(--muted); padding: 0 var(--space-4); }
#user-name { color: var(--text); font-weight: 500; }
#btn-logout { font-size: var(--fs-11); height: auto; padding: var(--space-5) var(--space-10); }
.srv-pick { display: flex; align-items: center; gap: var(--space-8); margin-right: var(--space-14); }
.srv-pick .srv-lbl { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.srv-pick select { min-width: 150px; }
main#view { padding: var(--space-24) var(--space-28); max-width: var(--content-max-w); width: 100%; display: grid; gap: var(--space-20); align-content: start; }
/* Grid items default to min-width:auto, so a wide child (a table, a long
   nowrap URL box) blows out the whole page's scroll width instead of
   scrolling within its own overflow-x:auto wrapper. Reset it here so those
   internal scrollers actually contain their content on narrow viewports. */
main#view > * { min-width: 0; }

/* ---- Studio mode: Operator Studio (#/studio) runs full-bleed, no chrome ---- */
.app.studio-mode { grid-template-columns: 1fr; }
.app.studio-mode .sidebar, .app.studio-mode .topbar { display: none; }
.app.studio-mode main#view { padding: 0; max-width: none; height: 100vh; display: block; }

/* ---- Cards / tables / badges (reused as-is) ---- */
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-16); }
/* Rack module: raised panel, hairline seam, mono uppercase "label tab" heading. */
.card { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-16) var(--space-18); box-shadow: var(--shadow-sm); }
.card h2 { font-family: var(--mono); font-size: var(--fs-10); font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 0 0 var(--space-12); display: inline-flex; align-items: center; gap: var(--space-8); }
.card h2::before { content: ""; width: var(--space-5); height: var(--space-5); border-radius: 1px; background: var(--accent); opacity: .8; }
.status { display: flex; align-items: center; gap: var(--space-8); font-size: var(--fs-20); font-weight: 600; font-family: var(--display); }
.dot { width: var(--space-10); height: var(--space-10); border-radius: 50%; background: var(--muted); transition: background .3s; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.card.wide { grid-column: 1 / -1; }
/* System Load "small multiples": one sub-module per metric, same rack-module
   language as .card but nested a level deeper (panel2 on panel). */
.load-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-10); }
.load-card { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-10) var(--space-12); }
.lc-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-8); margin-bottom: var(--space-6); }
.lc-label { font-family: var(--mono); font-size: var(--fs-10); font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.lc-val { font-family: var(--display); font-weight: 600; font-size: var(--fs-16); font-variant-numeric: tabular-nums; }
.lc-spark { height: 44px; }
.toprow { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; row-gap: var(--space-8); margin-bottom: var(--space-12); gap: var(--space-12); }
.toprow h2 { margin: 0; }
.summary { display: flex; gap: var(--space-22); font-size: var(--fs-13); color: var(--muted); }
.summary b { color: var(--text); font-size: var(--fs-16); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
th { text-align: left; color: var(--muted); font-weight: 600; padding: var(--space-8) var(--space-10); border-bottom: 1px solid var(--border); font-size: var(--fs-10); text-transform: uppercase; letter-spacing: .1em; font-family: var(--mono); }
td { padding: var(--space-11) var(--space-10); border-bottom: 1px solid var(--border); vertical-align: middle; }
/* tally rows: hairline separators + subtle hover, like a patch-bay list */
tbody tr { transition: background .16s ease-out; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
tr:last-child td { border-bottom: 0; }
.stream-name { font-family: var(--mono); font-weight: 600; }
.stream-path { color: var(--muted); font-size: var(--fs-11); font-family: var(--mono); }
.badge { display: inline-flex; align-items: center; gap: var(--space-5); padding: var(--space-2) var(--space-9); border-radius: var(--radius-pill); font-size: var(--fs-10); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-family: var(--mono); }
.badge::before { content: ""; width: var(--space-6); height: var(--space-6); border-radius: 50%; background: currentColor; }
.badge.live { background: var(--glow-live); color: var(--ok); }
.badge.live::before { box-shadow: 0 0 7px currentColor; animation: tallyPulse 1.6s ease-in-out infinite; }
.badge.revoked { background: var(--glow-air); color: var(--bad); }
.badge.active { background: var(--glow-live); color: var(--ok); }
.pill { display: inline-block; background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-7); font-size: var(--fs-11); margin-right: var(--space-4); font-family: var(--mono); color: var(--muted); }
.num { font-variant-numeric: tabular-nums; font-family: var(--mono); text-align: right; }
.empty { text-align: center; color: var(--muted); padding: var(--space-28); }
/* U6: icon + primary action slots for the empty-state pattern */
.empty .empty-ico { width: 30px; height: 30px; margin: 0 auto var(--space-10); opacity: .45; display: block; }
.empty .empty-action { margin-top: var(--space-12); }
.flash { animation: flash .6s; }
@keyframes flash { from { background: var(--glow-accent); } to { background: transparent; } }
/* U7: brief "value changed" pulse for stat-card numbers (Dashboard hero +
   system-load tiles); re-triggered by removing/re-adding the class so rapid
   consecutive ticks each get their own pulse. */
.tick { animation: statTick .5s ease-out; }
@keyframes statTick { 0% { color: var(--accent); } 100% { color: inherit; } }
input, button, select { font: inherit; }
input[type=text], input[type=number], input[type=password], input:not([type]) { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); height: var(--ctl-h); padding: 0 var(--space-10); font-size: var(--fs-13); }
textarea { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: var(--space-7) var(--space-10); font-size: var(--fs-13); }
select { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); height: var(--ctl-h); padding: 0 var(--space-10); font-size: var(--fs-13); }
/* U2: canonical checkbox — was a bare unstyled native checkbox everywhere.
   accent-color re-themes the native control (check + focus ring included)
   without a markup change at any of its ~14 call sites. */
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
/* Labeled checkbox row, e.g. <label class="chk"><input type=checkbox> scope</label> */
label.chk { display: inline-flex; align-items: center; gap: var(--space-6); font-size: var(--fs-12); color: var(--muted); cursor: pointer; }
button { background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--radius); height: var(--ctl-h); padding: 0 var(--space-14); font-weight: 700; cursor: pointer; font-size: var(--fs-13); letter-spacing: .01em; transition: opacity .16s ease-out, box-shadow .16s ease-out; }
button:hover { opacity: .92; box-shadow: 0 0 0 1px var(--glow-accent), 0 0 14px var(--glow-accent); }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
button.ghost, a.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 500; box-shadow: none; text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-6); border-radius: var(--radius); height: var(--ctl-h); padding: 0 var(--space-14); font-size: var(--fs-13); }
button.ghost:hover, a.ghost:hover { color: var(--text); border-color: var(--muted); box-shadow: none; }
button.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); box-shadow: none; }
button.danger:hover { background: var(--glow-air); box-shadow: none; }
/* U8: plain in-prose links (e.g. "see Restream" inside a .note/.warn-box) had
   no color rule anywhere in this file, so they fell back to the browser's
   default blue (#0000ee) — unreadable on these dark panels (~2:1 contrast).
   Scoped to unclassed anchors only: every styled/button-like <a> already
   carries a class (.ghost, nav links via `.sidebar nav a`, etc.) with higher
   specificity, so this doesn't touch them. */
a:not([class]) { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:not([class]):hover { text-decoration-thickness: 2px; }
/* a11y: always-visible keyboard focus ring on interactive elements. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
code.key { font-family: var(--mono); background: var(--input-bg); border: 1px solid var(--border); padding: var(--space-2) var(--space-6); border-radius: var(--radius-xs); font-size: var(--fs-12); cursor: pointer; }
.muted { color: var(--muted); }
/* U8: visually-hidden but screen-reader-accessible text, e.g. for table
   header cells that are visually empty (icon/actions columns). */
.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; }

/* ---- Login overlay (self-rolled auth, replaces Keycloak's hosted redirect) ---- */
#login-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: min(340px, 90vw); padding: var(--space-24); }
.login-title { margin: 0 0 var(--space-18) 0; font-family: var(--mono); font-size: var(--fs-16); text-align: center; }
.login-box .field { margin-bottom: var(--space-14); }
.login-box #login-submit { width: 100%; margin-top: var(--space-6); }
.login-box .err-box { margin-bottom: var(--space-14); padding: var(--space-8) var(--space-10); font-size: var(--fs-12); }

/* ---- Player modal (shared in shell) ---- */
.modal { position: fixed; inset: 0; background: var(--scrim); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal.open { display: flex; animation: modalScrimIn .16s ease-out; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); width: min(var(--modal-w-lg), 94vw); overflow: hidden; box-shadow: var(--shadow); }
/* U7: modal/confirm-dialog entrance (both reuse .modal/.modal-box) — was an
   instant display:none/flex toggle with no easing. */
.modal.open .modal-box { animation: modalBoxIn .18s ease-out; }
@keyframes modalScrimIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalBoxIn { from { opacity: 0; transform: scale(.97) translateY(4px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-14) var(--space-18); border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: var(--fs-16); font-family: var(--mono); }
.modal-head .x { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: var(--radius); height: auto; padding: var(--space-4) var(--space-10); display: inline-flex; align-items: center; gap: var(--space-5); }
#player_wrap { aspect-ratio: 16/9; background: var(--video-bg); }
.modal-foot { padding: var(--space-10) var(--space-18); display: flex; gap: var(--space-10); align-items: center; flex-wrap: wrap; font-size: var(--fs-12); color: var(--muted); }
.seg { display: inline-flex; height: var(--ctl-h); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--border); border-radius: 0; height: 100%; display: inline-flex; align-items: center; padding: 0 var(--space-12); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.seg button:focus-visible { outline-offset: -2px; z-index: 1; }
.thumb { width: 80px; height: 45px; object-fit: cover; border-radius: var(--radius-xs); display: block; margin-bottom: var(--space-4); background: var(--panel2); border: 1px solid var(--border); }
.ingest-grid { display: grid; gap: var(--space-10); }
.ingest-row { display: grid; grid-template-columns: 70px 1fr; gap: var(--space-10); align-items: center; }
.ingest-row .lbl { color: var(--muted); font-size: var(--fs-12); }
.urlbox { font-family: var(--mono); font-size: var(--fs-12); background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-8) var(--space-10); overflow-x: auto; white-space: nowrap; cursor: pointer; }
.code-block { font-family: var(--mono); font-size: var(--fs-12); background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-10) var(--space-12); overflow-x: auto; white-space: pre; margin: 0 0 var(--space-16); }

@media (max-width: 760px) {
  .row { grid-template-columns: 1fr; }
}

/* ---- U3: sidebar becomes an overlay drawer below 900px (was a horizontal-
   wrapping in-flow strip at 760px — replaced, since a wrapping nav row and a
   real off-canvas drawer solve the same problem incompatibly). ---- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  #btn-menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    width: min(var(--sidebar-w), 82vw);
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  /* the desktop icon-rail density toggle doesn't apply in overlay mode */
  #btn-sidebar-collapse { display: none; }
}

/* ---- T9: toast notifications ---- */
#toast-root { position: fixed; bottom: var(--space-20); right: var(--space-20); z-index: 200; display: flex; flex-direction: column; gap: var(--space-8); pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-10) var(--space-16); font-size: var(--fs-13); max-width: var(--toast-max-w); pointer-events: auto; display: flex; align-items: center; gap: var(--space-10); box-shadow: var(--shadow-toast); transition: opacity .25s; animation: toastIn .2s ease; }
.toast.ok  { border-left: var(--space-3) solid var(--ok); }
.toast.err { border-left: var(--space-3) solid var(--bad); }
.toast.warn{ border-left: var(--space-3) solid var(--warn); }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- T9: skeleton loader ---- */
.skel { background: linear-gradient(90deg,var(--panel2) 25%,var(--border) 50%,var(--panel2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-xs); display: inline-block; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skel-row { height: var(--space-13); margin: var(--space-9) 0; }
.skel-row.w80 { width: 80%; }
.skel-row.w50 { width: 50%; }
.skel-row.w30 { width: 30%; }

/* ---- T9: table scroll wrapper ---- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* U4: opt-in modifier for tables that can genuinely grow tall (live channel
   lists, session logs) — short lookup tables stay exactly as before since
   max-height only clips content past the threshold. */
.tbl-wrap.tall { max-height: 480px; overflow-y: auto; }
.tbl-wrap.tall th { position: sticky; top: 0; background: var(--panel); z-index: 1; }

/* ---- T9: card fade-in ---- */
@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.card { animation: fadeUp .18s ease; }

/* ---- T9: keyboard shortcut modal ---- */
.scut td { padding: var(--space-7) var(--space-10); border-bottom: 1px solid var(--border); font-size: var(--fs-13); }
.scut tr:last-child td { border: 0; }
kbd { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: var(--space-2) var(--space-7); font-family: var(--mono); font-size: var(--fs-11); color: var(--text); }

/* ---- T9/U2: lang toggle — small variant of the canonical .seg control
   (was a hand-rolled near-duplicate of .seg/.seg button.on; folded in). ---- */
.seg.sm { height: auto; border-radius: var(--radius-xs); }
.seg.sm button { padding: var(--space-2) var(--space-8); font-size: var(--fs-11); line-height: 1.5; }

/* ===== T1: nav groups, breadcrumb, command palette, bell, errors ===== */
/* U8: was opacity:.7 on top of --muted, which dropped contrast to 3.11:1
   (fails WCAG AA 4.5:1 in both themes) — the uppercase/letter-spacing/size
   already carries the "section label" de-emphasis without further dimming. */
.nav-group { font-size: var(--fs-10); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: var(--space-12) var(--space-12) var(--space-4); }
.nav-group:first-child { padding-top: var(--space-4); }

.crumbs { display: flex; align-items: center; gap: var(--space-8); font-size: var(--fs-13); color: var(--muted); min-width: 52px; flex: 0 1 auto; overflow: hidden; }
.crumbs .crumb { white-space: nowrap; }
/* Current page title clips with an ellipsis so a long name never spills over
   the search button when the topbar is tight. */
.crumbs .crumb.cur { color: var(--text); font-weight: 600; font-size: var(--fs-16); overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { opacity: .5; flex: none; }

.cmdk { display: inline-flex; align-items: center; gap: var(--space-7); color: var(--muted); }
.cmdk kbd { font-size: var(--fs-10); }
.cmdk .ico { opacity: .8; }
.bell { position: relative; }
.bell .bell-count { position: absolute; top: -4px; right: -4px; background: var(--bad); color: var(--on-accent); border-radius: var(--radius-pill); font-size: var(--fs-10); min-width: 15px; height: 15px; line-height: 15px; text-align: center; padding: 0 var(--space-3); font-weight: 700; }

/* Command palette */
.modal.cp { align-items: flex-start; }
.cp-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); width: min(var(--cp-w), 94vw); margin-top: 12vh; overflow: hidden; box-shadow: var(--shadow); }
.cp-input-wrap { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-14) var(--space-16); border-bottom: 1px solid var(--border); }
.cp-search-ico { color: var(--muted); }
#cp-input { flex: 1; background: transparent; border: 0; color: var(--text); font-size: var(--fs-16); outline: none; padding: 0; }
.cp-list { max-height: 50vh; overflow-y: auto; padding: var(--space-6); }
.cp-item { display: flex; align-items: center; gap: var(--space-12); padding: var(--space-9) var(--space-12); border-radius: var(--radius); cursor: pointer; font-size: var(--fs-14); }
.cp-item.on { background: var(--glow-accent); }
.cp-item .cp-ico { width: 16px; text-align: center; color: var(--muted); }
.cp-item .cp-label { flex: 1; }
.cp-item .cp-hint { font-size: var(--fs-11); color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 1px var(--space-8); }
.cp-empty { padding: var(--space-24); text-align: center; color: var(--muted); font-size: var(--fs-13); }
.cp-foot { display: flex; align-items: center; gap: var(--space-14); padding: var(--space-8) var(--space-16); border-top: 1px solid var(--border); font-size: var(--fs-11); color: var(--muted); }
.cp-foot kbd { margin-right: var(--space-4); }

/* Notifications panel */
.bell-panel { position: fixed; top: 60px; right: var(--space-18); width: var(--bell-panel-w); max-height: 70vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); z-index: 120; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-12) var(--space-16); border-bottom: 1px solid var(--border); }
.bell-head h3 { margin: 0; font-size: var(--fs-14); }
.bell-list { padding: var(--space-6); }
.bell-item { padding: var(--space-9) var(--space-12); border-radius: var(--radius); border-left: var(--space-3) solid var(--border); margin: var(--space-3) 0; background: var(--panel2); }
.bell-item.sev-error, .bell-item.sev-critical { border-left-color: var(--bad); }
.bell-item.sev-warn, .bell-item.sev-warning { border-left-color: var(--warn); }
.bell-item.sev-ok { border-left-color: var(--ok); }
.bell-msg { font-size: var(--fs-13); }
.bell-meta { font-size: var(--fs-11); color: var(--muted); margin-top: var(--space-3); }

/* Inline structured-error box (T2) */
.err-box { border: 1px solid var(--bad); background: var(--err-bg); border-radius: var(--radius); padding: var(--space-14) var(--space-16); }
.err-box.err-config_only { border-color: var(--warn); background: var(--warn-bg); }
.err-head { display: flex; align-items: center; gap: var(--space-8); font-size: var(--fs-14); }
.err-head .err-ico { color: var(--warn); }
.err-detail { font-family: var(--mono); font-size: var(--fs-11); color: var(--muted); background: var(--panel2); border-radius: var(--radius-sm); padding: var(--space-8) var(--space-10); margin: var(--space-8) 0 0; overflow-x: auto; white-space: pre-wrap; }
.err-actions { display: flex; gap: var(--space-8); margin-top: var(--space-10); flex-wrap: wrap; }

/* Drawer (slide-in panel) */
.drawer-scrim { position: fixed; inset: 0; background: var(--scrim-soft); z-index: 60; display: none; }
.drawer-scrim.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(var(--drawer-w), 96vw); background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 61; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-16) var(--space-20); border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: var(--fs-16); }
.drawer-body { padding: var(--space-18) var(--space-20); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--space-14); }

/* Tooltip helper: <span class="tip" data-tip="...">?</span> */
.tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); font-size: var(--fs-10); cursor: help; margin-left: var(--space-5); }
.tip::after { content: attr(data-tip); position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); background: var(--tooltip-bg); color: var(--tooltip-fg); padding: var(--space-6) var(--space-9); border-radius: var(--radius-sm); font-size: var(--fs-11); white-space: normal; width: max-content; max-width: 240px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 200; line-height: 1.4; }
.tip:hover::after { opacity: .96; }

/* ---- Saved output-stream-name suggestions (Pull/Forward) ---- */
.name-suggest-wrap { position: relative; }
.name-suggest { position: absolute; top: 100%; left: 0; right: 0; margin-top: var(--space-4); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; max-height: 220px; overflow-y: auto; }
.name-suggest-item { display: flex; align-items: center; gap: var(--space-8); padding: var(--space-7) var(--space-10); font-size: var(--fs-13); cursor: pointer; }
.name-suggest-item:hover { background: var(--panel2); }
.name-suggest-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-suggest-item button { flex: none; background: none; border: none; color: var(--muted); cursor: pointer; font-size: var(--fs-12); padding: var(--space-2) var(--space-6); border-radius: var(--radius-xs); }
.name-suggest-item button:hover { color: var(--bad); background: var(--danger-hover-bg); }

/* Live/Config control tags (T5) */
.ctl-tag { font-size: var(--fs-10); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: var(--space-2) var(--space-7); border-radius: var(--radius-pill); }
.ctl-tag.live { background: var(--glow-live); color: var(--ok); }
.ctl-tag.config { background: var(--glow-warn); color: var(--warn); }

/* ---- T3: analytics charts ---- */
.chart-box { width: 100%; min-height: 180px; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 180px; color: var(--muted); font-size: var(--fs-12); }

/* ---- T4: log viewer ---- */
.log-stream { height: 60vh; overflow-y: auto; background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--mono); font-size: var(--fs-12); padding: var(--space-6) var(--space-4); }
.log-row { display: grid; grid-template-columns: 150px 64px 52px 1fr; gap: var(--space-8); padding: var(--space-3) var(--space-8); border-bottom: 1px solid var(--hairline); white-space: pre-wrap; word-break: break-word; }
.log-row:hover { background: var(--hairline); }
.log-time { color: var(--muted); }
.log-src { color: var(--accent); text-transform: uppercase; font-size: var(--fs-10); align-self: center; }
.log-lvl { font-size: var(--fs-10); align-self: center; }
.log-row.lvl-error .log-lvl, .log-row.lvl-error .log-text { color: var(--bad); }
.log-row.lvl-warn .log-lvl { color: var(--warn); }
.log-row.lvl-debug { opacity: .7; }
.log-text b { color: var(--text); }

/* ---- T5: settings dashboard ---- */
.set-live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-16); }
.set-live-item { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-14); }
.set-live-item b { display: block; margin-bottom: var(--space-4); }
.set-live-item p { font-size: var(--fs-12); margin: 0 0 var(--space-10); }
.set-sections select { min-width: 260px; }
/* U10: .set-field (a one-off sentence-case label variant used only by
   perf.js/server_settings.js) removed — both now use the standard .field
   kit component like every other form in the app. #set-current kept. */
#set-current { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: var(--space-7) var(--space-10); font-size: var(--fs-13); width: 100%; }
#set-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4) var(--space-16); }
.xmlblock { font-family: var(--mono); font-size: var(--fs-12); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-12); overflow-x: auto; white-space: pre; }
.snip-head { display: flex; align-items: center; gap: var(--space-10); margin-bottom: var(--space-6); }
.apply-steps { border: 1px dashed var(--border); border-radius: var(--radius); padding: var(--space-10) var(--space-14); margin: var(--space-10) 0; font-size: var(--fs-13); }
.apply-steps ol { margin: var(--space-6) 0; padding-left: var(--space-20); }
.apply-steps li { margin: var(--space-3) 0; }
.diff { font-family: var(--mono); font-size: var(--fs-12); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-10); overflow-x: auto; }
.diff .dadd { color: var(--ok); display: block; }
.diff .ddel { color: var(--bad); display: block; }
.diff .deq { color: var(--muted); display: block; }

/* ---- T6: performance helper ---- */
.perf-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4) var(--space-16); }
.perf-protos { display: flex; gap: var(--space-14); flex-wrap: wrap; font-size: var(--fs-13); color: var(--text); }
.perf-knobs { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-12); }
.knob { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-14); text-align: center; box-shadow: var(--shadow-sm); }
.knob-v { font-size: var(--fs-24); font-weight: 700; color: var(--accent); }
.knob-k { font-size: var(--fs-11); color: var(--muted); margin-top: var(--space-4); font-family: var(--mono); }
.perf-list { font-size: var(--fs-13); margin: var(--space-4) 0; padding-left: var(--space-20); }
.perf-list li { margin: var(--space-4) 0; }
.perf-list.warn li { color: var(--warn); }
@media (max-width: 700px) {
  .set-live-grid, #set-form, .perf-form { grid-template-columns: 1fr; }
  .perf-knobs { grid-template-columns: repeat(2, 1fr); }
}

/* ---- T7: health center ---- */
.hc-list { display: flex; flex-direction: column; gap: var(--space-10); }
.hc-item { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-12) var(--space-14); }
.hc-top { display: flex; align-items: center; gap: var(--space-10); }
.hc-drift { margin-top: var(--space-8); font-size: var(--fs-13); display: flex; align-items: center; gap: var(--space-8); flex-wrap: wrap; }

/* ---- T8: onboarding checklist ---- */
.onboard .ob-list { list-style: none; margin: 0; padding: 0; }
.ob-list li { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-9) var(--space-4); border-bottom: 1px solid var(--border); font-size: var(--fs-14); }
.ob-list li:last-child { border-bottom: 0; }
.ob-list li.done .ob-label { color: var(--muted); text-decoration: line-through; }
.ob-check { color: var(--muted); width: 18px; text-align: center; }
.ob-list li.done .ob-check { color: var(--ok); }
.ob-go { color: var(--accent); text-decoration: none; font-size: var(--fs-13); }

/* Topbar fits progressively: shed the search label, then the VU meter, before
   the breadcrumb is forced to ellipsize. Keeps the page title readable. */
@media (max-width: 1180px) {
  .cmdk .cmdk-lbl, .cmdk kbd { display: none; }
}
@media (max-width: 1000px) {
  .topbar .tally-wrap .vu { display: none; }
  .srv-pick select { min-width: 120px; }
  .srv-pick .srv-lbl { display: none; }
  .topbar .bell, .topbar .user-info { display: none; }
}
@media (max-width: 820px) {
  #onair-label, .live #ws-state { display: none; }
  .topbar { padding-left: var(--space-16); padding-right: var(--space-16); }
}

/* ---- T9: mobile topbar polish ---- */
@media (max-width: 600px) {
  /* Narrow phones (~360-430px) can't fit every control on one row even after
     the shedding above — wrap instead of forcing horizontal scroll. */
  .topbar { padding: var(--space-10) var(--space-14); gap: var(--space-8); row-gap: var(--space-8); flex-wrap: wrap; }
  .topbar h2 { font-size: var(--fs-14); }
  .srv-pick .srv-lbl { display: none; }
  .srv-pick select { min-width: 100px; }
  .user-info { display: none; }
  #btn-logout { font-size: var(--fs-10); padding: var(--space-4) var(--space-8); }
  main#view { padding: var(--space-14) var(--space-12); }
  .topbar .live { gap: var(--space-4); font-size: var(--fs-11); }
  .topbar .grow { flex: 1 1 100%; order: 1; min-height: 0; }
}

/* ============================================================================
   Dashboard MASTER hero — the signature block. On-air state + VU meters +
   aggregate signal timeline, styled like a broadcast master-bus module.
   ============================================================================ */
.master { background: linear-gradient(180deg, var(--panel) 0%, var(--panel2) 100%); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-20) var(--space-22); display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: var(--space-22); align-items: center; overflow: hidden; }
.master-state { display: flex; flex-direction: column; gap: var(--space-10); }
.master-air { display: inline-flex; align-items: center; gap: var(--space-11); font-family: var(--mono); font-size: var(--fs-24); font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.master-air .tdot { width: var(--space-14); height: var(--space-14); border-radius: 50%; background: currentColor; }
.master.on .master-air { color: var(--bad); }
.master.on .master-air .tdot { box-shadow: 0 0 14px var(--bad); animation: tallyPulse 1.6s ease-in-out infinite; }
.master-sub { font-family: var(--mono); font-size: var(--fs-12); color: var(--muted); letter-spacing: .04em; }
.master-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-14); }
.metric { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-12) var(--space-14); display: flex; flex-direction: column; gap: var(--space-6); box-shadow: var(--shadow-sm); }
.metric .m-k { font-family: var(--mono); font-size: var(--fs-10); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.metric .m-v { font-family: var(--display); font-size: var(--fs-24); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.metric .vu { height: var(--space-14); }
/* aggregate signal timeline: a strip of bars fed a rolling history */
.signal-strip { grid-column: 1 / -1; display: flex; align-items: flex-end; gap: var(--space-3); height: 46px; padding-top: var(--space-4); border-top: 1px solid var(--border); }
.signal-strip i { flex: 1; min-width: 2px; height: calc(3px + 42px * var(--lvl, 0)); background: linear-gradient(180deg, var(--ok), color-mix(in srgb, var(--accent) 60%, var(--ok))); border-radius: 1px 1px 0 0; opacity: .9; transition: height .4s ease; }
/* services as tally chips row */
.svc-row { display: flex; gap: var(--space-10); flex-wrap: wrap; }
.svc-chip { flex: 1; min-width: 150px; display: flex; align-items: center; gap: var(--space-10); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-12) var(--space-14); box-shadow: var(--shadow-sm); }
.svc-chip .svc-k { font-family: var(--mono); font-size: var(--fs-11); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.svc-chip .svc-v { margin-left: auto; font-family: var(--display); font-weight: 600; font-size: var(--fs-14); }
@media (max-width: 760px) {
  .master { grid-template-columns: 1fr; }
  .master-metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) { .master-metrics { grid-template-columns: 1fr; } }

/* ============================================================================
   Professional form system — labeled fields, custom select chrome, confirm modal.
   Used across every view's create/edit menus.
   ============================================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-12) var(--space-14); align-items: end; }
.field { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.field > label, .field .field-lbl { font-family: var(--mono); font-size: var(--fs-10); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.field input, .field select { width: 100%; }
.field-hint { font-size: var(--fs-11); color: var(--muted); }
.field-hint b { color: var(--accent); font-weight: 600; }
/* U2: error state — pair .field.invalid with a .field-hint.error message */
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.field-hint.error { color: var(--bad); }
/* U5: unit suffix inside the input (Mbps/px/fps) instead of only in the label */
.field-unit { position: relative; }
.field-unit input { padding-right: 38px; }
.field-unit .unit { position: absolute; right: var(--space-10); top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--fs-11); font-family: var(--mono); pointer-events: none; }
.field-row { display: flex; gap: var(--space-10); flex-wrap: wrap; align-items: end; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-10); align-items: center; margin-top: var(--space-14); padding-top: var(--space-14); border-top: 1px solid var(--border); }
.form-actions .spacer { flex: 1; }
/* Rack-styled form container reused by builder menus. */
.form-card { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-16); margin-top: var(--space-12); }

/* Custom select chrome: strip OS look, draw a caret. Applies to all selects. */
select { -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'><path d='M1 1l4 4 4-4' fill='none' stroke='%237d8590' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right var(--space-10) center; padding-right: var(--space-28); cursor: pointer; }
select:hover { border-color: var(--muted); }

/* Ingest section headings (Pull page): rack-divider between transport flows. */
.ingest-h { font-family: var(--display); font-size: var(--fs-14); font-weight: 600; margin: var(--space-22) 0 var(--space-8); padding-top: var(--space-16); border-top: 1px solid var(--border); }
.ingest-h .muted { font-weight: 400; font-size: var(--fs-12); }
/* .grp-h: top-level group heading (e.g. "Bring a source IN" vs "Push in from a
   publisher") — smaller/uppercase so it reads as a category label above the
   normal-weight subsection headings, with a heavier divider between groups. */
.ingest-h.grp-h { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; border-top-width: 2px; margin-top: var(--space-30); padding-top: var(--space-20); }
.ingest-h:first-of-type { border-top: 0; padding-top: 0; margin-top: var(--space-2); }

/* Confirm dialog body/footer (modal shell reused from .modal/.modal-box). */
.cf-body { padding: var(--space-18) var(--space-20); font-size: var(--fs-14); color: var(--text); line-height: 1.5; white-space: pre-wrap; }
.cf-foot { display: flex; justify-content: flex-end; gap: var(--space-10); padding: var(--space-12) var(--space-20) var(--space-16); border-top: 1px solid var(--border); }

/* ============================================================================
   Consistency utilities — the shared vocabulary that replaces per-view inline
   styles. Layout first, then components. Keep this the ONLY place ad-hoc
   spacing/sub-panel/chip looks are defined.
   ============================================================================ */
/* Layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-16); }
.grid-main-side { display: grid; grid-template-columns: 1fr 280px; gap: var(--space-20); align-items: start; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-16); }
.stack { display: flex; flex-direction: column; gap: var(--space-12); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); }
.grow { flex: 1; }
.w-full { width: 100%; }
.btn-row { display: flex; gap: var(--space-8); flex-wrap: wrap; align-items: center; }
/* Header-row control cluster: scope-select + segmented-range-picker + action
   button. Distinct from .btn-row (lone action buttons) and .summary (spaced
   stat readouts) — controls here now share --ctl-h so they line up exactly. */
.toolbar { display: flex; align-items: center; gap: var(--space-10); flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 auto; }
.toolbar select { min-width: 150px; }
.nowrap { white-space: nowrap; }
.cell-wrap { max-width: 320px; word-break: break-word; }
/* U2: border-color modifier, replacing repeated inline style="border-color:var(--warn)" */
.b-warn { border-color: var(--warn); }
/* U2: center content over a relatively-positioned parent (player loading states) */
.overlay-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
@media (max-width: 1000px) { .grid-main-side { grid-template-columns: 1fr; } }
@media (max-width: 820px)  { .grid-2 { grid-template-columns: 1fr; } }

/* Components */
.tile { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-12); box-shadow: var(--shadow-sm); }
.tile-h { font-size: var(--fs-13); font-weight: 600; margin-bottom: var(--space-8); }
.sub-panel { background: var(--panel3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-10) var(--space-14); font-size: var(--fs-12); }
.warn-box { background: var(--warn-bg); border: 1px solid var(--warn); border-radius: var(--radius-sm); padding: var(--space-8) var(--space-12); font-size: var(--fs-12); color: var(--warn); }
.chip { display: inline-block; padding: 1px var(--space-8); border-radius: var(--radius-pill); font-size: var(--fs-11); border: 1px solid currentColor; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); } .chip.muted { color: var(--muted); }
.msg-ok { background: var(--glow-live); color: var(--ok); }
.msg-bad { background: var(--glow-air); color: var(--bad); }
button.sm, a.ghost.sm { font-size: var(--fs-12); height: auto; padding: var(--space-5) var(--space-10); }
button.xs, a.ghost.xs { font-size: var(--fs-11); height: auto; padding: var(--space-3) var(--space-8); }
.mono { font-family: var(--mono); }
.bar { padding: var(--space-10) var(--space-14); display: flex; align-items: center; gap: var(--space-12); flex-wrap: wrap; border-top: 1px solid var(--border); font-size: var(--fs-12); color: var(--muted); }
.card.flush { padding: 0; overflow: hidden; }
.card.sunken { background: var(--panel3); }
.card.inset { background: var(--panel2); }
.urlbox.pre { white-space: pre; padding: var(--space-10) var(--space-12); font-size: var(--fs-11); line-height: 1.5; }
.urlbox.wrap { white-space: normal; word-break: break-all; }
.modal-body { padding: var(--space-18) var(--space-20); display: flex; flex-direction: column; gap: var(--space-14); }
.modal-box.sm { max-width: var(--modal-w-sm); }
.modal-box.md { max-width: var(--modal-w-md); }
.inline-field { display: flex; align-items: center; gap: var(--space-12); font-size: var(--fs-13); }
.inline-field > label, .inline-field > .lbl { color: var(--muted); min-width: 110px; }
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-12); font-size: var(--fs-13); }
.kv-row .k { color: var(--muted); }
.kv-row .v { text-align: right; word-break: break-word; }
#sd-player-wrap { aspect-ratio: 16/9; background: var(--video-bg); position: relative; }
.thumb-lg { width: 100%; border-radius: var(--radius-sm); background: var(--panel3); display: block; }

/* ---- Stream Keys: app-scope badge + expandable publish-URL panel ---- */
.key-toolbar { display: flex; align-items: center; gap: var(--space-8); flex-wrap: wrap; }
.badge.scope { background: var(--glow-accent); color: var(--accent); }
.key-urls { background: var(--panel3); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-10) var(--space-12); margin: var(--space-2) 0 var(--space-6); }
.key-url-line { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-3) 0; }
.key-url-lbl { color: var(--muted); font-size: var(--fs-11); min-width: 215px; flex: none; }
.key-url-val { font-family: var(--mono); font-size: var(--fs-11); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; color: var(--text); }
.key-url-val:hover { color: var(--accent); }
.key-urls-row > td { padding-top: 0; }

/* ============================================================================
   Utilities — the shared vocabulary that replaced per-view inline style="..."
   attributes. Views compose these instead of hand-rolling font sizes/margins,
   so spacing and type stay on one scale. Semantic classes first (notes/hints),
   then single-purpose overrides (declared LAST so `note fs-13` etc. resolve
   with the single-purpose class winning).
   ============================================================================ */
/* Section intro / helper paragraph under a heading. */
.note    { margin: 0 0 var(--space-14); font-size: var(--fs-12); }
.note-sm { margin: 0 0 var(--space-12); font-size: var(--fs-12); }
/* Helper line that FOLLOWS a control (result meta, validation hint). */
.note-after { margin: var(--space-8) 0 0; font-size: var(--fs-12); }
.meta-note  { font-size: var(--fs-11); margin: var(--space-6) 0 0; }
/* Small bold in-card section label. */
.subhead { font-size: var(--fs-12); font-weight: 600; margin-bottom: var(--space-8); }

/* Type scale + color */
.fs-10 { font-size: var(--fs-10); } .fs-11 { font-size: var(--fs-11); } .fs-12 { font-size: var(--fs-12); }
.fs-13 { font-size: var(--fs-13); } .fs-14 { font-size: var(--fs-14); } .fs-16 { font-size: var(--fs-16); }
.c-text { color: var(--text); } .c-warn { color: var(--warn); } .c-muted { color: var(--muted); }
.c-ok { color: var(--ok); } .c-bad { color: var(--bad); } .c-accent { color: var(--accent); }

/* Spacing (4px grid) */
.m-0 { margin: 0; }
.mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); } .mt-10 { margin-top: var(--space-10); }
.mt-12 { margin-top: var(--space-12); } .mt-14 { margin-top: var(--space-14); } .mt-16 { margin-top: var(--space-16); }
.mb-6 { margin-bottom: var(--space-6); } .mb-8 { margin-bottom: var(--space-8); } .mb-10 { margin-bottom: var(--space-10); }
.gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); } .gap-8 { gap: var(--space-8); } .gap-10 { gap: var(--space-10); }
.pt-12 { padding: var(--space-12) 0 0; } .py-12-4 { padding: var(--space-12) 0 var(--space-4); } .py-4-12 { padding: var(--space-4) 0 var(--space-12); }

/* Layout / misc */
.span-all { grid-column: 1 / -1; }
.nowrap { white-space: nowrap; }
.ta-right { text-align: right; }
.resize-v { resize: vertical; }
.pointer { cursor: pointer; }
.w-110 { width: 110px; } .w-150 { width: 150px; } .w-160 { width: 160px; }

/* Motion floor: honor reduced-motion — kill pulses/shimmer/transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---- Operator Studio (#/studio): PIN lock + full-bleed broadcast layout ---- */
.studio-lock { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 40; }
.studio-lock-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-32) var(--space-36); width: min(320px, 90vw); text-align: center; }
.studio-lock-icon { font-size: var(--fs-28); margin-bottom: var(--space-6); }
.studio-lock-card h2 { margin: 0 0 var(--space-4); font-family: var(--display); font-size: var(--fs-20); }
.studio-lock-card input[type=password] { width: 100%; text-align: center; letter-spacing: .3em; font-size: var(--fs-20); margin: var(--space-16) 0 var(--space-10); }
.studio-lock-card button { width: 100%; }

.studio-grid { height: 100vh; display: grid; grid-template-columns: 1fr 320px; background: var(--video-bg); }
.studio-preview { position: relative; display: flex; align-items: center; justify-content: center; background: var(--video-bg); overflow: hidden; }
.studio-preview video { width: 100%; height: 100%; object-fit: contain; background: var(--video-bg); }
.studio-topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: var(--space-10); padding: var(--space-14) var(--space-18); background: linear-gradient(180deg, var(--studio-scrim-top), transparent); }
.studio-onair { font-family: var(--mono); font-size: var(--fs-11); font-weight: 700; letter-spacing: .12em; padding: var(--space-5) var(--space-12); border-radius: var(--radius-pill); background: var(--studio-overlay-bg); color: var(--muted); border: 1px solid var(--border); }
.studio-onair.on { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); background: var(--glow-air); }
.studio-timer { font-family: var(--mono); font-size: var(--fs-12); color: var(--studio-fg); }
.studio-topbar #st-conn { color: var(--studio-muted); }
.studio-topbar #st-exit { background: var(--studio-overlay-bg); border-color: var(--studio-overlay-border); color: var(--studio-fg); }
.studio-controls { position: absolute; bottom: 18px; left: 18px; display: flex; gap: var(--space-8); }
.studio-controls button { background: var(--studio-overlay-bg); border: 1px solid var(--studio-overlay-border); color: var(--studio-fg); }
.studio-controls button.active { background: var(--glow-air); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); color: var(--bad); }
.studio-rail { background: var(--panel); border-left: 1px solid var(--border); padding: var(--space-18); display: flex; flex-direction: column; gap: var(--space-14); overflow-y: auto; }
.studio-rail select, .studio-rail input[type=text], .studio-rail input[type=number] { width: 100%; }
@media (max-width: 860px) {
  .studio-grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .studio-rail { border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
}
