/* ==========================================================================
   Stream Studio — Broadcast Control Center
   Design system. Dark-first, calm, high contrast. No gradients, no glass.
   ========================================================================== */

:root {
  /* surfaces */
  --bg:          #0b0b10;
  --surface:     #13131b;
  --surface-2:   #1a1a24;
  --surface-3:   #21212d;
  --border:      #252531;
  --border-soft: #1d1d27;

  /* text — neutrals carry a slight indigo bias so they read as chosen */
  --text:        #e8e8ef;
  --text-mid:    #b0b0c0;
  --text-dim:    #8a8a9c;
  --text-faint:  #5d5d70;

  /* accent */
  --accent:      #6366f1;
  --accent-hi:   #818cf8;
  --accent-wash: rgba(99, 102, 241, 0.12);
  --accent-line: rgba(99, 102, 241, 0.35);

  /* semantic — separate from the accent */
  --live:        #ef4444;
  --live-wash:   rgba(239, 68, 68, 0.12);
  --ok:          #22c55e;
  --ok-wash:     rgba(34, 197, 94, 0.12);
  --warn:        #f59e0b;
  --warn-wash:   rgba(245, 158, 11, 0.12);
  --info:        #38bdf8;
  --info-wash:   rgba(56, 189, 248, 0.12);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --sidebar-w: 232px;
  --topbar-h:  60px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; text-wrap: balance; }

button { font-family: inherit; }

a { color: var(--accent-hi); text-decoration: none; }

:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; border-radius: var(--r-sm); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tnum { font-variant-numeric: tabular-nums; }
.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;
}

svg.i { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 15px; height: 15px; }
svg.i-lg { width: 22px; height: 22px; }

/* ==========================================================================
   Shell
   ========================================================================== */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

/* Pin the two real cells explicitly. Any other direct child of .app (the
   mobile scrim, a future overlay) then cannot push .main out of column 2 -
   which is exactly what happened when the scrim was only taken out of flow
   inside the mobile media query. */
.sidebar { grid-column: 1; grid-row: 1; }
.main    { grid-column: 2; grid-row: 1; }

/* Always fixed and hidden; the mobile query only reveals it. */
.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(6, 6, 10, .6);
  z-index: 110;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; flex: 0 0 auto;
}
.brand-mark svg { width: 17px; height: 17px; stroke-width: 2; fill: none; stroke: currentColor; }
.brand-name { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; }

.nav { padding: 14px 10px; overflow-y: auto; flex: 1 1 auto; }
.nav-label {
  font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint); padding: 0 8px; margin: 16px 0 6px; font-weight: 600;
}
.nav-label:first-child { margin-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; margin-bottom: 2px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text-dim); font-size: 13.5px; text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-wash); color: var(--accent-hi); font-weight: 500; }
.nav-item .count {
  margin-left: auto; font-size: 11px; color: var(--text-faint);
  background: var(--surface-3); padding: 1px 7px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

.side-foot { border-top: 1px solid var(--border); padding: 12px; flex: 0 0 auto; }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-mid);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  flex: 0 0 auto; text-transform: uppercase;
}
.who-text { min-width: 0; }
.who-name {
  font-size: 13px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.who-role { font-size: 11px; color: var(--text-faint); }
.side-actions { display: flex; gap: 6px; }

/* ---------- topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tenant { font-weight: 600; font-size: 14px; white-space: nowrap; }
.topbar-meta { display: flex; align-items: center; gap: 14px; min-width: 0; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.meta-item strong { color: var(--text); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.divider-v { width: 1px; height: 22px; background: var(--border); flex: 0 0 auto; }

.burger { display: none; }

.page-wrap { padding: 22px; flex: 1 1 auto; }
@media (max-width: 640px) { .page-wrap { padding: 14px; } }

.page { display: none; }
.page.is-active { display: block; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; letter-spacing: -0.015em; }
.page-head p { margin: 3px 0 0; color: var(--text-dim); font-size: 13px; max-width: 68ch; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   Status system — icon + label + treatment. Never colour alone.
   ========================================================================== */

.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.status svg { width: 12px; height: 12px; stroke-width: 2.2; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.status-live      { background: var(--live-wash);   color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.status-live .dot { animation: pulse 1.6s ease-in-out infinite; }
.status-online    { background: var(--ok-wash);     color: #86efac; border-color: rgba(34,197,94,0.35); }
.status-connecting{ background: var(--warn-wash);   color: #fcd34d; border-color: rgba(245,158,11,0.35); }
.status-processing{ background: var(--accent-wash); color: var(--accent-hi); border-color: var(--accent-line); }
.status-warning   { background: var(--warn-wash);   color: #fcd34d; border-color: rgba(245,158,11,0.35); }
.status-error     { background: var(--live-wash);   color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.status-offline   { background: var(--surface-3);   color: var(--text-dim); border-color: var(--border); }
.status-disabled  { background: var(--surface-2);   color: var(--text-faint); border-color: var(--border-soft); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .status-live .dot { animation: none; }
  * { transition: none !important; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .14s, border-color .14s, opacity .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5457e5; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-live { background: var(--live); border-color: var(--live); color: #fff; }
.btn-live:hover { background: #dc2626; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #052e14; }
.btn-ok:hover { background: #16a34a; }

/* A high-impact action must not look like a normal button. */
.btn-danger-zone {
  background: transparent; color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.45);
}
.btn-danger-zone:hover { background: var(--live-wash); border-color: var(--live); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }
.btn-block { width: 100%; }
.btn-lg { padding: 11px 18px; font-size: 14px; }

/* ==========================================================================
   Cards & panels
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-soft);
}
.card-head h2 { font-size: 13.5px; font-weight: 600; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }

.hint { color: var(--text-faint); font-size: 12px; }

/* ==========================================================================
   Studio layout
   ========================================================================== */

.studio { display: grid; grid-template-columns: minmax(0, 65fr) minmax(320px, 35fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .studio { grid-template-columns: minmax(0, 1fr); } }

/* ---------- broadcast monitor ---------- */
.monitor { background: #000; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.monitor-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.monitor-frame:fullscreen { aspect-ratio: auto; }
.monitor-frame video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }

.monitor-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: #0a0a0f; color: var(--text-faint); text-align: center; padding: 20px;
}
.monitor-overlay.is-hidden { display: none; }
.monitor-overlay svg { width: 42px; height: 42px; stroke-width: 1.2; color: #3a3a48; }
.monitor-overlay p { margin: 0; font-size: 13.5px; color: var(--text-dim); }
.monitor-overlay .sub { font-size: 12px; color: var(--text-faint); }

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid var(--surface-3); border-top-color: var(--accent-hi);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.monitor-badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 2; }
.monitor-clock {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: rgba(0,0,0,.62); border: 1px solid rgba(255,255,255,.09);
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; color: #e5e5ee; font-variant-numeric: tabular-nums;
}

.monitor-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface);
  flex-wrap: wrap;
}
.monitor-bar .spacer { margin-left: auto; }

/* ---------- health strip ---------- */
.health-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 1px; background: var(--border-soft);
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; margin-top: 14px;
}
.hs {
  background: var(--surface); padding: 9px 12px;
  display: flex; flex-direction: column; gap: 1px;
}
.hs-label { font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.hs-value { font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 5px; }
.hs-value .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.hs.is-good .hs-value .dot { background: var(--ok); }
.hs.is-warn .hs-value .dot { background: var(--warn); }
.hs.is-bad  .hs-value .dot { background: var(--live); }
.hs.is-good .hs-value { color: #86efac; }
.hs.is-warn .hs-value { color: #fcd34d; }
.hs.is-bad  .hs-value { color: #fca5a5; }

/* ==========================================================================
   Source selector
   ========================================================================== */

.source-list { display: flex; flex-direction: column; gap: 8px; }

.source-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); cursor: pointer;
  transition: border-color .14s, background .14s;
}
.source-card:hover { border-color: var(--accent-line); background: var(--surface-3); }
.source-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.source-ico {
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
  background: var(--surface-3); color: var(--text-mid);
  display: grid; place-items: center;
}
.source-card[aria-pressed="true"] .source-ico { background: var(--accent); color: #fff; }
.source-text { min-width: 0; flex: 1 1 auto; }
.source-title { font-size: 13.5px; font-weight: 600; }
.source-sub { font-size: 11.5px; color: var(--text-dim); }
.source-card .status { margin-left: auto; }

.mode-panel { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }

/* ---------- copy field ---------- */
.copy-field { margin-bottom: 9px; }
.copy-field label {
  display: block; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; margin-bottom: 4px;
}
.copy-row { display: flex; gap: 6px; }
.copy-row input {
  flex: 1 1 auto; min-width: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); padding: 7px 10px; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-mid); margin-bottom: 5px; }
.field .req { color: #fca5a5; }
.input, .field input[type="text"], .field input[type="password"], .field select, .field textarea {
  width: 100%; padding: 9px 11px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: 13.5px; font-family: inherit;
}
.input:focus, .field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.input.is-invalid, .field input.is-invalid { border-color: var(--live); }
.field-help { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.field-error { font-size: 11.5px; color: #fca5a5; margin-top: 5px; display: none; }
.field-error.is-shown { display: block; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; margin-bottom: 0; }

.masked { letter-spacing: .12em; color: var(--text-dim); }

/* ==========================================================================
   Destination cards
   ========================================================================== */

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

.dest-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.dest-card.is-off { opacity: .62; }
.dest-top { display: flex; align-items: flex-start; gap: 11px; padding: 14px; }
.plat {
  width: 36px; height: 36px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-mid);
}
.plat.is-yt { background: rgba(239,68,68,.14); color: #fca5a5; }
.plat.is-fb { background: rgba(59,130,246,.14); color: #93c5fd; }
.dest-id { min-width: 0; flex: 1 1 auto; }
.dest-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dest-host {
  font-size: 11.5px; color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dest-meta { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 7px; }
.dest-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.dest-line .k { color: var(--text-faint); min-width: 74px; }
.dest-err {
  font-size: 11.5px; color: #fca5a5; background: var(--live-wash);
  border: 1px solid rgba(239,68,68,.28); border-radius: var(--r-sm); padding: 6px 9px;
}
.dest-foot { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }
.dest-foot .spacer { margin-left: auto; }

/* ==========================================================================
   Media library
   ========================================================================== */

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border: 0; border-radius: 4px;
  background: none; color: var(--text-dim); font-size: 12.5px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 13px; }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.media-card.is-playing { border-color: var(--accent); }
.thumb {
  aspect-ratio: 16/9; background: var(--surface-2);
  display: grid; place-items: center; position: relative; border-bottom: 1px solid var(--border-soft);
}
.thumb svg { width: 30px; height: 30px; color: #40404f; stroke-width: 1.3; }
.thumb .badge-src {
  position: absolute; bottom: 7px; left: 7px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
  background: rgba(0,0,0,.66); color: #d4d4e0; padding: 2px 6px; border-radius: 4px;
}
.media-info { padding: 11px 12px; }
.media-name { font-size: 13px; font-weight: 500; word-break: break-word; }
.media-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.media-acts { display: flex; gap: 6px; padding: 0 12px 12px; }
.media-acts .spacer { margin-left: auto; }

/* list view */
.media-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.media-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.media-row:last-child { border-bottom: 0; }
.media-row.is-playing { background: var(--accent-wash); }
.media-row .m-ico { width: 30px; height: 30px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; flex: 0 0 auto; color: #4a4a5a; }
.media-row .m-name { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-row .m-meta { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.media-row .m-acts { display: flex; gap: 6px; flex: 0 0 auto; }

/* dropzone */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--r);
  padding: 26px 18px; text-align: center; background: var(--surface-2);
  transition: border-color .14s, background .14s; cursor: pointer;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone svg { width: 28px; height: 28px; color: var(--text-faint); margin-bottom: 8px; }
.dropzone p { margin: 0; font-size: 13px; }
.dropzone .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

.progress { height: 6px; border-radius: 20px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 20px; transition: width .2s; }

.file-chip {
  display: flex; align-items: center; gap: 9px; margin-top: 12px;
  padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 12.5px;
}
.file-chip .spacer { margin-left: auto; }

/* ==========================================================================
   Playlist
   ========================================================================== */

.pl-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.pl-item:last-child { border-bottom: 0; }
.pl-item.is-current { background: var(--accent-wash); }
.pl-ord {
  width: 24px; height: 24px; border-radius: 6px; flex: 0 0 auto;
  background: var(--surface-2); color: var(--text-dim);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pl-item.is-current .pl-ord { background: var(--accent); color: #fff; }
.pl-grip { color: var(--text-faint); cursor: grab; display: grid; place-items: center; }
.pl-name { flex: 1 1 auto; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-meta { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }

/* ==========================================================================
   Activity timeline
   ========================================================================== */

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 11px; border-radius: 20px; font-size: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent-hi); }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }

.tl-item { position: relative; padding: 9px 0; }
.tl-dot {
  position: absolute; left: -26px; top: 11px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-dim);
}
.tl-dot svg { width: 11px; height: 11px; stroke-width: 2.1; }
.tl-item.cat-streaming   .tl-dot { color: var(--accent-hi); border-color: var(--accent-line); }
.tl-item.cat-destination .tl-dot { color: #93c5fd; border-color: rgba(59,130,246,.35); }
.tl-item.cat-media       .tl-dot { color: #86efac; border-color: rgba(34,197,94,.3); }
.tl-item.cat-account     .tl-dot { color: #fcd34d; border-color: rgba(245,158,11,.3); }
.tl-item.cat-admin       .tl-dot { color: #fca5a5; border-color: rgba(239,68,68,.3); }
.tl-item.is-alert .tl-dot { background: var(--live-wash); color: #fca5a5; border-color: rgba(239,68,68,.45); }

.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-actor { font-size: 13px; font-weight: 600; }
.tl-time { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tl-detail { font-size: 13px; color: var(--text-mid); margin-top: 1px; }
.tl-item.is-alert .tl-detail { color: #fca5a5; }

.tag {
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase; font-weight: 600;
  padding: 1.5px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-dim);
}
.tag-admin  { background: var(--live-wash); color: #fca5a5; }
.tag-worker { background: var(--surface-3); color: var(--text-dim); }
.tag-tenant { background: var(--info-wash); color: #7dd3fc; }

/* ==========================================================================
   Admin
   ========================================================================== */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; }
.stat-top { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.stat-top .k { font-size: 11.5px; color: var(--text-dim); font-weight: 500; }
.stat-top svg { width: 15px; height: 15px; color: var(--text-faint); }
.stat-val { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.danger-zone { border: 1px solid rgba(239,68,68,.3); border-radius: var(--r-lg); overflow: hidden; }
.danger-zone .card-head { background: var(--live-wash); border-bottom-color: rgba(239,68,68,.25); }
.danger-zone .card-head h2 { color: #fca5a5; }
.danger-row { display: flex; align-items: flex-start; gap: 16px; padding: 15px 16px; flex-wrap: wrap; }
.danger-row .txt { flex: 1 1 260px; }
.danger-row .txt h3 { font-size: 13.5px; margin-bottom: 3px; }
.danger-row .txt p { margin: 0; font-size: 12.5px; color: var(--text-dim); }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; padding: 9px 14px; font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint); font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-mid); }
table.grid tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }

pre.log {
  margin: 0; padding: 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 12px; line-height: 1.6; color: var(--text-dim);
  max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ==========================================================================
   Empty / loading states
   ========================================================================== */

.empty { text-align: center; padding: 40px 20px; }
.empty svg { width: 34px; height: 34px; color: #383846; stroke-width: 1.3; margin-bottom: 10px; }
.empty h3 { font-size: 14px; margin-bottom: 4px; }
.empty p { margin: 0 auto 14px; font-size: 12.5px; color: var(--text-faint); max-width: 44ch; }

.skeleton { background: var(--surface-2); border-radius: var(--r-sm); animation: sk 1.4s ease-in-out infinite; }
@keyframes sk { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ==========================================================================
   Modal / drawer
   ========================================================================== */

.scrim {
  position: fixed; inset: 0; background: rgba(6,6,10,.72);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.scrim.is-open { display: flex; }

.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  width: 100%; max-width: 520px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { font-size: 15px; }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }
.modal-foot .spacer { margin-left: auto; }

.modal.is-confirm { max-width: 440px; }
.confirm-body { display: flex; gap: 14px; padding: 18px; }
.confirm-ico {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--warn-wash); color: #fcd34d;
}
.confirm-ico.is-danger { background: var(--live-wash); color: #fca5a5; }
.confirm-body h3 { font-size: 14.5px; margin-bottom: 5px; }
.confirm-body p { margin: 0; font-size: 13px; color: var(--text-dim); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin: -18px -18px 16px; padding: 0 18px; }
.tabs button {
  padding: 11px 3px; margin-right: 16px; border: 0; background: none;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ==========================================================================
   Applying-configuration overlay — non-dismissible by design
   ========================================================================== */

.applying {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8,8,13,.9);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px; text-align: center;
}
.applying.is-open { display: flex; }
.applying h3 { font-size: 16px; }
.applying p { margin: 0; font-size: 13px; color: var(--text-dim); max-width: 46ch; }
.applying .step { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-mid); }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 9px; max-width: min(370px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--r); padding: 11px 13px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.toast .t-body { flex: 1 1 auto; min-width: 0; }
.toast .t-title { font-size: 13px; font-weight: 600; }
.toast .t-msg { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; word-break: break-word; }
.toast .t-close { background: none; border: 0; color: var(--text-faint); cursor: pointer; padding: 0 2px; }
.toast.is-ok    { border-left-color: var(--ok); }
.toast.is-ok    svg { color: var(--ok); }
.toast.is-err   { border-left-color: var(--live); }
.toast.is-err   svg { color: #fca5a5; }
.toast.is-warn  { border-left-color: var(--warn); }
.toast.is-warn  svg { color: #fcd34d; }
.toast.is-info  { border-left-color: var(--accent); }
.toast.is-info  svg { color: var(--accent-hi); }

/* inline alert */
.alert { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--r); font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.alert.is-ok  { background: var(--ok-wash);   border-color: rgba(34,197,94,.3); color: #86efac; }
.alert.is-err { background: var(--live-wash); border-color: rgba(239,68,68,.35); color: #fca5a5; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 268px; z-index: 120;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.is-open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .burger { display: inline-flex; }
  .sidebar-scrim.is-open { display: block; }
}

@media (max-width: 700px) {
  .topbar { gap: 10px; padding: 0 13px; }
  .tenant { font-size: 13px; }
  /* Status must never be hidden on small screens. */
  .topbar-meta .meta-item.is-optional { display: none; }
  .page-head h1 { font-size: 18px; }
  .dest-grid, .media-grid { grid-template-columns: minmax(0, 1fr); }
  .btn { padding: 9px 14px; }   /* keep touch targets comfortable */
  .btn-sm { padding: 7px 11px; font-size: 12px; }
  .toasts { left: 13px; right: 13px; bottom: 13px; max-width: none; }
  .monitor-bar { gap: 6px; }
}
