/* stream.dnode.ca admin styles.
 *
 * Visual language ported from crew.dnode.ca (the canonical dnode admin design):
 *   slate-950 background, slate-200 text, cyan accent, color-mix()-based
 *   muted/line/surface scale, 8px/6px radii, 0.95rem on buttons, Inter 14px.
 * Tenant brand colors live only on per-tenant chips — the admin chrome stays
 * consistent across all dnode tools.
 */

:root {
  --app-bg: #020617;
  --app-sidebar: rgba(2, 6, 23, 0.96);
  --app-surface: rgba(15, 23, 42, 0.78);
  --app-panel: rgba(15, 23, 42, 0.72);
  --app-text: #e2e8f0;
  --app-muted: rgba(148, 163, 184, 0.78);
  --app-border: rgba(148, 163, 184, 0.18);
  --app-border-strong: rgba(148, 163, 184, 0.32);
  --app-accent: #dc2626;
  --app-accent-dark: #991b1b;
  --app-accent-soft: rgba(220, 38, 38, 0.18);
  --app-danger: #f87171;
  --app-success: #34d399;
  --app-warning: #fbbf24;
}

/* Redesign 2026 primitives — neutrals derive from --app-text so any tenant
 * theme override flows through the whole UI automatically. */
:root {
  --muted: color-mix(in srgb, var(--app-text) 62%, transparent);
  --muted-2: color-mix(in srgb, var(--app-text) 42%, transparent);
  --muted-3: color-mix(in srgb, var(--app-text) 28%, transparent);

  --line: color-mix(in srgb, var(--app-text) 8%, transparent);
  --line-2: color-mix(in srgb, var(--app-text) 14%, transparent);
  --line-3: color-mix(in srgb, var(--app-text) 22%, transparent);

  --surface: color-mix(in srgb, var(--app-text) 2.5%, transparent);
  --surface-2: color-mix(in srgb, var(--app-text) 4%, transparent);
  --surface-3: color-mix(in srgb, var(--app-text) 6%, transparent);

  --accent-soft: color-mix(in srgb, var(--app-accent) 12%, transparent);
  --accent-soft-2: color-mix(in srgb, var(--app-accent) 22%, transparent);

  /* Status hues — low chroma, one family. */
  --ok: oklch(0.75 0.12 165);
  --warn: oklch(0.78 0.13 75);
  --bad: oklch(0.68 0.18 25);

  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;

  --radius: 8px;
  --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { min-height: 100%; background: var(--app-bg); }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--app-text);
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--app-accent); }

/* =================================================================
 *  app shell — left sidebar + content column
 * ================================================================= */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  flex: 0 0 248px;
  width: 248px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app-sidebar);
  border-right: 1px solid var(--app-border);
  z-index: 60;
}
.content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* collapse handle — floats on the sidebar's right edge, toggles the icon rail */
.sidebar-collapse {
  position: absolute; top: 18px; right: -11px; z-index: 65;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  padding: 0; line-height: 0;          /* zero the UA button padding that was offsetting the glyph */
  appearance: none; -webkit-appearance: none;
  background: var(--app-surface); border: 1px solid var(--app-border-strong);
  border-radius: 50%; color: var(--muted); cursor: pointer;
  transition: color .14s ease, background .14s ease;
}
.sidebar-collapse:hover { color: var(--app-text); background: var(--surface-3); }
.sidebar-collapse svg { display: block; transition: transform .2s ease; }
.sidebar--collapsed .sidebar-collapse svg { transform: rotate(180deg); }

/* brand */
.brand { display: flex; align-items: center; gap: 9px; padding: 16px 16px 12px; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  object-fit: cover;            /* the logo <img> fills the square cleanly */
  background: linear-gradient(135deg, #ef4444, #991b1b);  /* fallback if img missing */
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 14px; }
.brand-dim { color: var(--muted-3); font-weight: 500; }

/* =================================================================
 *  organization switcher
 * ================================================================= */
.org-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dot, var(--app-accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--app-accent)) 16%, transparent);
  flex: 0 0 auto;
}
.org-dot--all {
  background: conic-gradient(from 210deg, #dc2626, #f59e0b, #10b981, #3b82f6, #dc2626);
  box-shadow: none;
}
.org-switcher { position: relative; margin: 0 12px 6px; }
.org-switcher__btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--app-text);
  font: inherit; cursor: pointer; text-align: left;
  transition: background .14s ease, border-color .14s ease;
}
.org-switcher__btn:hover { background: var(--surface-3); border-color: var(--line-3); }
.org-switcher.is-open .org-switcher__btn { border-color: color-mix(in srgb, var(--app-accent) 45%, transparent); background: var(--surface-3); }
.org-switcher__label { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.org-switcher__eyebrow {
  font-size: 9px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted-3);
}
.org-switcher__name {
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.org-switcher__chev { color: var(--muted-2); flex: 0 0 auto; transition: transform .16s ease; }
.org-switcher.is-open .org-switcher__chev { transform: rotate(180deg); }
.org-switcher__panel {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: color-mix(in srgb, var(--app-panel) 88%, #000);
  backdrop-filter: blur(12px);
  border: 1px solid var(--app-border-strong);
  border-radius: 11px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  padding: 6px; z-index: 70;
  max-height: 60vh; overflow-y: auto;
}
.org-switcher__panel[hidden] { display: none; }
.org-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: 8px;
  color: var(--app-text); font-size: 13px;
}
.org-opt:hover { background: var(--surface-2); color: var(--app-text); }
.org-opt.is-active { background: var(--accent-soft); }
.org-opt__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.org-opt__check { color: var(--app-accent); flex: 0 0 auto; opacity: 0; }
.org-opt.is-active .org-opt__check { opacity: 1; }

/* locked tenant-admin: a static chip, no switching */
.org-chip-static {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 6px; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
}
.org-chip-static__name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =================================================================
 *  sidebar nav — grouped + iconned
 * ================================================================= */
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 12px 12px; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-group__label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-3); padding: 0 10px; margin-bottom: 6px;
}
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  position: relative;
  transition: background .14s ease, color .14s ease;
}
.nav__item:hover { color: var(--app-text); background: var(--surface-2); }
.nav__icon { flex: 0 0 auto; opacity: 0.82; }
.nav__item.is-active { color: var(--app-text); background: var(--accent-soft); }
.nav__item.is-active .nav__icon { color: var(--app-accent); opacity: 1; }
.nav__item.is-active::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--app-accent);
}

/* =================================================================
 *  sidebar foot — role + email + sign out
 * ================================================================= */
.side-foot {
  display: flex; align-items: center; gap: 8px;
  /* Fixed height (matched to .footer) so the top border lines up with the
     content footer's border in BOTH the expanded and collapsed (icon-only,
     shorter content) states — otherwise the divider steps at the sidebar edge. */
  padding: 0 12px; min-height: 46px;
  border-top: 1px solid var(--app-border);
}
.who-role {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); background: var(--surface);
  flex: 0 0 auto;
}
.who-role.role-super {
  color: var(--app-accent);
  border-color: color-mix(in srgb, var(--app-accent) 40%, transparent);
  background: var(--accent-soft);
}
.who-email { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { color: var(--muted-2); display: inline-flex; flex: 0 0 auto; }
.logout:hover { color: var(--app-danger); }

/* =================================================================
 *  mobile chrome — hamburger + scrim (hidden on desktop)
 * ================================================================= */
.nav-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 90;
  width: 38px; height: 38px; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--app-sidebar) 90%, #000);
  border: 1px solid var(--app-border); border-radius: 9px;
  color: var(--app-text); cursor: pointer;
}
.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.6); z-index: 75; }
.scrim[hidden] { display: none; }

/* =================================================================
 *  org prompt — focused page on "All organizations" scope
 * ================================================================= */
.org-prompt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 56px 24px; min-height: 320px;
}
.org-prompt__icon {
  display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: 16px; color: var(--app-accent);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--app-accent) 24%, transparent);
  margin-bottom: 4px;
}
.org-prompt__title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.org-prompt__msg { color: var(--muted); font-size: 13px; margin: 0; max-width: 340px; line-height: 1.5; }

/* =================================================================
 *  collapsed sidebar — icon-only rail (desktop only; mobile uses the drawer)
 * ================================================================= */
@media (min-width: 861px) {
  .sidebar--collapsed { flex-basis: 66px; width: 66px; }
  .sidebar--collapsed .brand { justify-content: center; padding: 16px 0 12px; gap: 0; }
  .sidebar--collapsed .brand-name { display: none; }

  .sidebar--collapsed .org-switcher,
  .sidebar--collapsed .org-chip-static { margin-left: 8px; margin-right: 8px; }
  .sidebar--collapsed .org-switcher__btn,
  .sidebar--collapsed .org-chip-static { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
  .sidebar--collapsed .org-switcher__label,
  .sidebar--collapsed .org-switcher__chev,
  .sidebar--collapsed .org-chip-static__name { display: none; }
  /* the dropdown flies out to the right of the rail instead of filling it */
  .sidebar--collapsed .org-switcher__panel { left: calc(100% + 8px); right: auto; width: 240px; top: 0; }

  .sidebar--collapsed .nav { padding-left: 8px; padding-right: 8px; }
  .sidebar--collapsed .nav-group__label { display: none; }
  .sidebar--collapsed .nav-group + .nav-group { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
  .sidebar--collapsed .nav__item { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
  .sidebar--collapsed .nav__label { display: none; }

  .sidebar--collapsed .side-foot { justify-content: center; }
  .sidebar--collapsed .who-role,
  .sidebar--collapsed .who-email { display: none; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  /* collapse-to-rail is a desktop affordance; mobile always uses the full drawer */
  .sidebar-collapse { display: none; }
  .sidebar--collapsed { width: 248px; flex-basis: 248px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5); z-index: 80;
  }
  .sidebar.is-open { transform: none; }
  .content { min-height: 100vh; }
  /* Clear the fixed hamburger. More specific than the base `.container` rule so
     the shorthand `padding` defined later in the file can't reset padding-top. */
  .content .container { padding-top: 64px; }
}

/* =================================================================
 *  page chrome
 * ================================================================= */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  width: 100%;
  flex: 1;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head__meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--app-accent);
  box-shadow: 0 0 6px var(--app-accent);
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.022em;
  margin: 0;
  text-wrap: balance;
}
.page-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 24px;
}

/* =================================================================
 *  cards
 * ================================================================= */
.card {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: var(--radius);
  padding: 18px;
  /* flex column so sibling cards in a grid row balance — any element with
     `.card-actions` (or a manual `margin-top: auto`) sticks to the bottom
     regardless of how much content sits above. */
  display: flex;
  flex-direction: column;
}
.card + .card { margin-top: 12px; }
/* Cards laid out in a grid use `gap`, not sibling margins. Without this
   override the `.card + .card` rule above adds a 12px top margin to every card
   after the first IN A GRID ROW, which knocks it out of the equal-height
   stretch — so the first card renders taller than the rest. Grids (.card-grid
   on the dashboard, .comp-grid on competitions) must cancel it. */
.card-grid .card + .card,
.comp-grid .card + .card { margin-top: 0; }
.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}
.card-actions { margin-top: auto; padding-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-sub { color: var(--muted); font-size: 12px; }

/* tenant chip — only place where tenant brand color leaks into the chrome */
.tenant-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.tenant-chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--app-accent);
}

/* stat strip */
.stat-row { display: flex; gap: 20px; margin-top: 4px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 64px; }
.stat-num { font-size: 22px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.stat-label {
  color: var(--muted-2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-top: 4px;
}

/* =================================================================
 *  tables
 * ================================================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.table th {
  color: var(--muted-2);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface); }
.table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted-strong, var(--app-text));
}

/* =================================================================
 *  pills (status)
 * ================================================================= */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pill-scheduled { background: var(--surface); color: var(--muted); border: 1px solid var(--line-2); }
.pill-live      {
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
}
.pill-finished  {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent);
}
.pill-cancelled {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}

/* =================================================================
 *  buttons — copied directly from crew's btn primitives
 * ================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 0.95rem;
  border: 1px solid transparent;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  color: var(--app-text);
  background: var(--surface-2);
  border-color: var(--line-2);
}
/* Buttons rendered as <a> would otherwise inherit the global `a:hover { color:
   var(--app-accent) }` (specificity 0,1,1), which beats a plain `.btn-primary`
   color (0,1,0) — that's the red-text-on-red-bg hover bug. Every :hover here
   sets an explicit color so the class rule (0,2,0) wins and buttons keep their
   intended text color on hover. */
.btn:hover { background: var(--surface-3); border-color: var(--line-3); color: var(--app-text); }
.btn-primary {
  background: var(--app-accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: color-mix(in oklab, var(--app-accent) 90%, white);
  border-color: transparent;
  color: #fff;
}
.btn-outline {
  background: transparent;
  border-color: var(--line-2);
  color: var(--app-text);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--line-3); color: var(--app-text); }
.btn-ghost {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--app-accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--app-accent) 24%, transparent);
}
.btn-ghost:hover { background: var(--accent-soft-2); color: var(--app-accent); }
.btn-danger {
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  color: var(--bad);
}
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 26%, transparent); border-color: var(--bad); color: var(--bad); }
.btn-text { background: transparent; border-color: transparent; color: var(--muted); }
.btn-text:hover { color: var(--app-text); background: transparent; }
.btn-sm, .btn-small {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 0.7rem;
}

/* =================================================================
 *  forms
 * ================================================================= */
form.stack { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 500;
}
.field input, .field select, .field textarea {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--app-text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--app-accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-accent) 18%, transparent);
}
.field-hint { color: var(--muted-2); font-size: 12px; }
.field-row { display: flex; gap: 12px; align-items: center; }

/* =================================================================
 *  alerts
 * ================================================================= */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid;
  margin-bottom: 14px;
}
.alert-error, .alert-danger {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
}
.alert-ok, .alert-success {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}
.alert-warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

/* =================================================================
 *  shared page components — hoisted out of per-page <style> blocks so
 *  every list/form across the admin uses the same primitives. Page-
 *  specific classes still live inline in their page.
 * ================================================================= */

/* Filter bar — matches/list, sponsors/assets */
.filter-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter-label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted-2); font-weight: 500;
}
.filter-label select {
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--app-text); font-size: 13px; font-family: inherit; min-width: 170px;
}

/* Inline form — sits next to other controls (e.g. a delete button in a table row) */
.inline-form { margin: 0; display: inline; }

/* Button/action row under a form */
.form-actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Copy-to-clipboard row — OBS ingest fields, webhook secret */
.copy-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 8px; margin-top: 8px; }
.copy-row label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); font-weight: 500; }
.copy-row input { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--app-text); font-size: 12px; font-family: ui-monospace, monospace; }
.copy-actions { display: flex; gap: 6px; }

/* Monospace size chip — sponsor zone size hints (slots + assets) */
.zone-size { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--app-text); font-family: ui-monospace, monospace; font-weight: 500; }

/* =================================================================
 *  REDESIGN v2 — shared component language (the interior design system)
 *  Built on the existing tokens. Reused across every page in the rollout.
 * ================================================================= */

/* page-head right-aligned actions slot (header.php renders $page_actions here) */
.page-head__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- tabs (shared by sponsors + viewers; hoisted from the inline _tabs.php) --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--app-border); margin: 0 0 20px; }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .14s ease, border-color .14s ease;
}
.tab:hover { color: var(--app-text); }
.tab.is-active { color: var(--app-text); border-bottom-color: var(--app-accent); }

/* --- panel: a contained surface that wraps a list/table with an optional head --- */
.panel { background: var(--app-panel); border: 1px solid var(--app-border); border-radius: var(--radius); overflow: hidden; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.panel__title { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.panel__sub { font-size: 12px; color: var(--muted); }

/* --- list rows (modern row-list; reusable for sponsors, viewers, matches…) --- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  transition: background .12s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface); }
.list-row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.list-row__title { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; display: flex; align-items: center; gap: 8px; min-width: 0; }
.list-row__title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.list-row__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
/* a compact "value + label" stat used inside a row's meta cluster */
.meta-stat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.meta-stat b { color: var(--app-text); font-weight: 600; }
.meta-stat.is-ok b { color: var(--ok); }
.meta-stat.is-warn b { color: var(--warn); }
/* per-group label row (e.g. per-tenant section header in a grouped list) */
.list-group__label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  font-size: 11px; color: var(--muted);
}

/* --- thumb: small framed image preview (zone thumbnails, logos…) --- */
.thumb {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  overflow: hidden; flex: 0 0 auto;
}
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb--zone { width: 56px; height: 34px; }
.thumb--empty { background: var(--surface-2); color: var(--muted-3); font-size: 12px; }
.thumb--text { background: var(--surface-2); color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: 0.1em; }

/* --- status dot (semantic) --- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--muted-3); }
.dot--ok { background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 55%, transparent); }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); opacity: 0.75; }
.dot--muted { background: var(--muted-3); }

/* --- badge: small semantic label (feature/mode/gender/size chips) --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  border: 1px solid var(--line-2); color: var(--muted); background: var(--surface);
}
.badge--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge--bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 38%, transparent); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge--accent { color: var(--app-accent); border-color: color-mix(in srgb, var(--app-accent) 38%, transparent); background: var(--accent-soft); }
.badge--mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: none; letter-spacing: 0; color: var(--app-text); background: var(--surface-2); }

/* --- quiet button: a disclosure/toggle control that reads as a real control --- */
.btn-quiet {
  background: var(--surface-3); border: none; box-shadow: inset 0 0 0 1px var(--line-2);
  border-radius: var(--radius-sm); padding: 5px 12px;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--app-text);
  cursor: pointer; transition: background .15s ease, box-shadow .15s ease;
}
.btn-quiet:hover { background: color-mix(in srgb, var(--app-text) 8%, transparent); box-shadow: inset 0 0 0 1px var(--line-3); }
.btn-quiet[aria-expanded="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--app-accent) 30%, transparent); }

/* --- square icon button (row actions: delete, etc.) --- */
.btn-icon {
  width: 32px; height: 32px; padding: 0; min-height: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  transition: color .14s ease, background .14s ease, border-color .14s ease;
}
.btn-icon:hover { color: var(--app-text); background: var(--surface-3); border-color: var(--line-3); }
.btn-icon.btn-icon--danger:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.btn-icon svg { display: block; }

/* --- empty state (no-data + feature-locked variants) --- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 44px 24px; }
.empty__icon {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 14px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line-2); margin-bottom: 4px;
}
.empty__title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.empty__msg { font-size: 13px; color: var(--muted); max-width: 360px; line-height: 1.5; margin: 0; }
.empty--locked .empty__icon {
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
}

/* --- asset card (sponsor creatives; reused by ads + asset editor) --- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.asset-card { background: var(--app-panel); border: 1px solid var(--app-border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.asset-thumb { aspect-ratio: 16/9; background: #fff; border-radius: var(--radius-sm); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-thumb__placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.asset-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.asset-meta { font-size: 11px; color: var(--muted); }
.asset-actions { display: flex; gap: 6px; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }

/* --- expandable detail panel (under a list row) --- */
.detail-panel { background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-panel__inner { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.detail-add { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-fields { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-fields input { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 12px; color: var(--app-text); font-size: 13px; font-family: inherit; }
.inline-fields input[type="text"] { min-width: 240px; flex: 1; }

/* --- zone settings bar (cards shown + rotation) at the top of a zone's panel --- */
.zone-settings { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius); }
.zone-settings__field { display: flex; flex-direction: column; gap: 5px; }
.zone-settings__field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); font-weight: 500; }
.zone-settings__field input { width: 130px; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 10px; color: var(--app-text); font-size: 13px; font-family: inherit; }
.zone-settings__field input:focus { outline: none; border-color: color-mix(in srgb, var(--app-accent) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-accent) 18%, transparent); }
.zone-settings__hint { font-size: 11px; color: var(--muted-2); line-height: 1.5; flex: 1 1 100%; margin-top: 2px; }

@media (max-width: 640px) {
  .list-row { flex-wrap: wrap; }
  .list-row__actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .list-row__meta { gap: 12px; }
}

/* --- toolbar: filter/search bar above a list (matches, teams, viewers) --- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 8px 12px; color: var(--app-text); font-size: 13px; font-family: inherit;
}
.toolbar input[type="search"], .toolbar input[type="text"] { flex: 0 1 240px; min-width: 160px; }
.toolbar select:focus, .toolbar input:focus { outline: none; border-color: color-mix(in srgb, var(--app-accent) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-accent) 18%, transparent); }
.toolbar__count { font-size: 12px; color: var(--muted); margin-left: auto; }

/* --- form section: a paneled group of fields with a title (editors, configs) --- */
.form-section { background: var(--app-panel); border: 1px solid var(--app-border); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; }
.form-section__title { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; margin: 0 0 14px; }
.form-section__sub { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* --- bento: pack stacked section-cards into balanced columns (up to 2) with NO
   gaps — masonry, so uneven-height cards don't leave empty rows or stretch to
   match a taller neighbour. Full width (fills the canvas, matching the header
   panel). Responsive: 1 column on narrow, 2 columns >=820px. Keep a form's
   submit row OUTSIDE .bento so it spans full width below the columns. */
.bento { column-gap: 16px; }
.bento > * { break-inside: avoid; -webkit-column-break-inside: avoid; margin: 0 0 16px; }
@media (min-width: 820px) { .bento { column-count: 2; } }

/* --- small form helpers (shared by the asset editor, match editor, etc.) --- */
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check-row input { accent-color: var(--app-accent); }
.preview-box { aspect-ratio: 16/9; background: #fff; border-radius: var(--radius); border: 1px solid var(--line-2); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.preview-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* --- card refinements --- */
.card--interactive { transition: border-color .14s ease, transform .14s ease, background .14s ease; cursor: pointer; }
.card--interactive:hover { border-color: var(--line-3); transform: translateY(-1px); }

/* --- stat number semantic colors (dashboard / health strips) --- */
.stat-num.is-ok { color: var(--ok); }
.stat-num.is-warn { color: var(--warn); }
.stat-num.is-bad { color: var(--bad); }

/* --- a labelled key/value description grid (settings summaries, OBS ingest) --- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--app-text); }

/* =================================================================
 *  login page
 * ================================================================= */
body.login {
  display: flex; align-items: center; justify-content: center;
  background: var(--app-bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: var(--radius);
  padding: 28px;
}
.login-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-brand .mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ef4444, #991b1b);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
.login-brand .name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.login-tag { color: var(--muted); margin: 4px 0 20px; font-size: 13px; line-height: 1.5; }
.login-card form { width: 100%; }
.login-card .submit {
  width: 100%; padding: 10px;
  margin-top: 4px;
  background: var(--app-accent);
  color: #fff; font-weight: 600;
  border: none; border-radius: 0.95rem;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease;
}
.login-card .submit:hover { background: color-mix(in oklab, var(--app-accent) 90%, white); }
.login-card .remember {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  cursor: pointer;
}
.login-card .remember input { accent-color: var(--app-accent); }
.login-card .notice {
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 14px;
  text-align: center;
}
.login-card .notice a { color: var(--app-accent); }

/* =================================================================
 *  toggle switch — used for sponsor-zone visibility (slots.php +
 *  assets.php). Pill background with a sliding thumb. The element is
 *  a <button data-visible="0|1"> so the JS in footer.php can swap the
 *  attribute optimistically without re-rendering anything else.
 *  Accessible: real <button>, focus ring, aria-pressed.
 * ================================================================= */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  width: 48px;
  height: 26px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
}
.toggle-switch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-accent) 28%, transparent);
}
.toggle-switch .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 1px 2px rgba(0,0,0,0.45);
  transition: left .18s ease, background .18s ease, transform .18s ease;
}
.toggle-switch[data-visible="1"] {
  background: color-mix(in srgb, var(--ok) 28%, transparent);
  border-color: color-mix(in srgb, var(--ok) 60%, transparent);
}
.toggle-switch[data-visible="1"] .toggle-thumb {
  left: 24px;
  background: var(--ok);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--ok) 50%, transparent);
}
.toggle-switch[data-busy="1"] { opacity: 0.6; pointer-events: none; }
.toggle-switch[data-busy="1"] .toggle-thumb { transform: scale(0.9); }
/* Optional inline label sitting next to the switch when the layout has
   room for it (assets.php zone-actions row). slots.php uses the switch
   in a narrow table cell without a label. */
.toggle-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.toggle-label[data-visible="1"] { color: var(--ok); }

/* =================================================================
 *  footer
 * ================================================================= */
.footer {
  border-top: 1px solid var(--app-border);
  /* Height matched to .side-foot so the two top borders form one continuous
     divider regardless of the sidebar's collapsed/expanded state. */
  padding: 0 20px; min-height: 46px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted-3);
  font-size: 11px;
}

/* =================================================================
 *  Custom confirm modal — replaces native browser confirm() dialogs.
 *  Add `data-confirm="message"` (optional `data-confirm-danger`,
 *  `data-confirm-ok`, `data-confirm-title`) to any <form> and the
 *  handler in footer.php intercepts submit + shows this modal.
 * ================================================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: modal-fade .14s ease-out;
}
.modal-overlay[hidden] { display: none; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  /* SOLID (not the translucent --app-panel) so the page behind never bleeds
     through and the form stays readable. */
  background: #0f172a;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius);
  padding: 18px 22px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: modal-pop .16s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modal-pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 14px; font-weight: 600; margin: 0 0 8px; color: var(--app-text); }
.modal-msg { font-size: 13px; color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Larger modal variant for an inline FORM (e.g. editing a sponsor creative). */
.modal-card--form { max-width: 560px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head .modal-title { margin: 0; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--app-text); }
/* the asset edit form drops .stack's max-width inside a modal (the modal caps it) */
.modal-card--form .asset-edit-form { max-width: none; }
