/* Tech Base Player — Portal · terminal theme (all black, default) */

:root,
body[data-theme="terminal"] {
  --bg-0: #000000;
  --bg-1: #050605;
  --bg-2: #0a0c0a;
  --bg-3: #0f120f;
  --line: #1c241c;
  --line-2: #2a352a;
  --text: #cfdccf;             /* phosphor off-white */
  --text-dim: #7f927f;
  --text-muted: #566356;
  --accent: #2ee06a;           /* terminal green */
  --accent-rgb: 46, 224, 106;
  --accent-2: #ffb000;          /* amber */
  --accent-3: #19a35a;          /* dim green */
  --ok: #2ee06a;
  --warn: #ffb000;
  --err: #ff5f56;
  --shadow-glow: 0 0 16px rgba(var(--accent-rgb), 0.16);
  --bg-gradient: radial-gradient(1100px 700px at 50% -20%, #03130a 0%, transparent 60%);
}
/* Terminal skin reads as a console: monospace everywhere. */
body[data-theme="terminal"] {
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

body[data-theme="ocean"] {
  --bg-0: #050b12;
  --bg-1: #08121c;
  --bg-2: #0c1a26;
  --bg-3: #112536;
  --line: #1f3a52;
  --line-2: #2f5274;
  --text: #e2eff8;
  --text-dim: #9ab8d0;
  --text-muted: #5d7892;
  --accent: #4ad6ff;            /* lagoon */
  --accent-rgb: 74, 214, 255;
  --accent-2: #4afca0;           /* mint */
  --accent-3: #7bc1ff;           /* sky */
  --ok: #4afca0;
  --warn: #ffcf3a;
  --err: #ff5a8a;
  --shadow-glow: 0 0 24px rgba(var(--accent-rgb), 0.22);
  --bg-gradient: radial-gradient(1200px 800px at 20% -10%, #0a223a 0%, transparent 50%),
                 radial-gradient(900px 700px at 100% 100%, #07344a 0%, transparent 50%);
}

body[data-theme="daylight"] {
  --bg-0: #eef1f7;
  --bg-1: #ffffff;
  --bg-2: #f6f8fc;
  --bg-3: #eef1f7;
  --line: #d6dce8;
  --line-2: #c0c8da;
  --text: #1a2133;
  --text-dim: #4d566e;
  --text-muted: #8089a0;
  --accent: #0a6cff;            /* clean blue */
  --accent-rgb: 10, 108, 255;
  --accent-2: #e0245e;           /* rose */
  --accent-3: #6a4cff;           /* indigo */
  --ok: #15a05a;
  --warn: #b8860b;
  --err: #d92d4e;
  --shadow-glow: 0 1px 3px rgba(20, 30, 60, 0.12);
  --bg-gradient: radial-gradient(1200px 800px at 20% -10%, #e3ecff 0%, transparent 55%),
                 radial-gradient(900px 700px at 100% 100%, #e7f6ff 0%, transparent 55%);
}

/* Pitch 25 — sports bar + indoor soccer pitch (EaDo, Houston). Brand verified
   from pitch25.com: warm off-white base, charcoal ink, PITCH ORANGE #f45800 as
   the primary accent. Monochrome orange + charcoal — no green. */
body[data-theme="pitch25"] {
  --bg-0: #f9f8f6;             /* warm off-white (brand base) */
  --bg-1: #ffffff;             /* surfaces */
  --bg-2: #f4f2ee;
  --bg-3: #efece7;
  --line: #e6e2dd;             /* brand contrast token */
  --line-2: #d8d2c9;
  --text: #1f1f1f;             /* charcoal ink */
  --text-dim: #4a4a4a;
  --text-muted: #8a857d;
  --accent: #f45800;           /* Pitch orange — reserved for primary actions */
  --accent-rgb: 244, 88, 0;
  --accent-2: #303030;          /* charcoal — secondary (was orange; dials it back) */
  --accent-3: #c9410a;          /* deep orange */
  --ok: #c0560e;               /* online/success — calmer burnt orange, less neon */
  --warn: #c9410a;
  --err: #d92d2d;
  --shadow-glow: 0 1px 3px rgba(31, 31, 31, 0.10);
  --bg-gradient: radial-gradient(900px 600px at 16% -12%, #fdeee4 0%, transparent 48%);
}

/* USC — Uptown Sporting Club. Brand = gold script + platinum-gray wordmark.
   Premium lounge feel: warm near-black base, antique-gold accent, platinum
   secondary. Gold sampled from the logo (~#b8902f) and lifted for UI pop. */
body[data-theme="usc"] {
  --bg-0: #0a0906;             /* warm near-black */
  --bg-1: #0f0d09;
  --bg-2: #14110b;             /* charcoal surface */
  --bg-3: #1b1710;
  --line: #2a2417;             /* bronze-dark hairline */
  --line-2: #3b3322;
  --text: #f1e9d6;            /* warm cream */
  --text-dim: #b9ac8f;
  --text-muted: #7c7360;
  --accent: #d0a94e;          /* antique gold — primary */
  --accent-rgb: 208, 169, 78;
  --accent-2: #cdbfa0;         /* platinum (the wordmark gray, lifted) */
  --accent-3: #b8902f;         /* deep logo gold */
  --ok: #6faa76;              /* legible online-green against the gold */
  --warn: #d9a441;
  --err: #d9524e;
  --shadow-glow: 0 0 18px rgba(var(--accent-rgb), 0.18);
  --bg-gradient: radial-gradient(1100px 700px at 50% -20%, #1c1408 0%, transparent 60%);
}

/* Houston Rockets — black + red + silver. Official colors: red #CE1141,
   black #000000, silver #C4CED4 (teamcolorcodes.com). Pure-black base, Rockets
   red as the detail accent, silver as the cool secondary. */
body[data-theme="rockets"] {
  --bg-0: #000000;             /* pure black */
  --bg-1: #070708;
  --bg-2: #0d0d0f;             /* near-black surface (cool) */
  --bg-3: #131316;
  --line: #241a1d;             /* faint red-black hairline */
  --line-2: #3a2429;
  --text: #eef1f4;            /* silver-white */
  --text-dim: #aeb6bd;         /* silver */
  --text-muted: #6b7178;
  --accent: #ce1141;          /* Rockets red — the detail */
  --accent-rgb: 206, 17, 65;
  --accent-2: #c4ced4;         /* silver — secondary */
  --accent-3: #e23a5e;         /* lifted red (gradients/hover) */
  --ok: #3fbf6a;              /* legible online-green against red */
  --warn: #e0a020;
  --err: #ff5252;
  --shadow-glow: 0 0 18px rgba(var(--accent-rgb), 0.25);
  --bg-gradient: radial-gradient(1100px 700px at 50% -20%, #2a0510 0%, transparent 60%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg-gradient), var(--bg-0);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .3s;
  -webkit-text-size-adjust: 100%;   /* no iOS text inflation on rotate */
  overflow-x: hidden;               /* guard against horizontal scroll (sticky topbar, safe to clip) */
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ===================== layout ===================== */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
.topbar {
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-row { display: flex; align-items: center; gap: 20px; padding: 0 28px; }
.topbar-context { min-height: 78px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.topbar-nav { height: 48px; gap: 10px; }
/* Flat home: fleet summary chip replaces the old module tabs. */
.fleet-summary {
  display: inline-flex; align-items: center; gap: 8px;
  flex-shrink: 0; white-space: nowrap;
  font-family: inherit; font-size: 13px; letter-spacing: .04em;
  color: var(--text-dim); background: none;
  border: 1px solid transparent; border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}
.fleet-summary:hover { color: var(--text); border-color: var(--line-2); }
.fleet-summary.active { color: var(--text); }
.fleet-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.fleet-dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.context-group { display: flex; align-items: center; gap: 12px; margin-left: 8px; padding-left: 20px; border-left: 1px solid var(--line); }
.ctx-picker { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ctx-sep { color: var(--text-muted); font-size: 16px; opacity: .6; }
.user { gap: 14px; }
.topbar-row .grow { flex: 1; }   /* push user (context row) + Settings (nav row) to the right edge */
/* Brand logo (real artwork) on a black chip so the white logo reads on any theme. */
.brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  background: #000;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 8px 16px;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.10);
}
.brand-logo { height: 46px; width: auto; display: block; }
.login-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.login-logo-img {
  box-sizing: content-box;
  height: 46px; width: auto; display: block;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 24px;
  box-shadow: 0 0 24px rgba(var(--accent-rgb), .12);
}
.tabs { display: flex; gap: 8px; margin-left: 24px; flex: 1; flex-wrap: wrap; }
.tab {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--text-dim);
  font-family: 'Orbitron', sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s, transform .1s;
}
.tab:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb),.18);
}
.tab:active { transform: translateY(1px); }
.tab.active {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),.22), rgba(var(--accent-rgb),.08));
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(var(--accent-rgb),.35), inset 0 0 12px rgba(var(--accent-rgb),.12);
  text-shadow: 0 0 10px rgba(var(--accent-rgb),.5);
}
.tenant-picker {
  display: flex; align-items: center; gap: 8px;
  margin-left: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.picker-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.tenant-select {
  background: var(--bg-3);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  min-height: 36px;
  max-width: 240px;
  padding: 6px 30px 6px 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.01em;
  appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
                    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 8px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  box-shadow: 0 0 12px rgba(var(--accent-rgb),.15);
}
.tenant-static {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--accent);
}
.user {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
  font-size: 12px;
}
.user .who { color: var(--text); }
.user-email { color: var(--text); }
.user-role {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  color: var(--text-muted);
  text-transform: uppercase;
}
.user-role.super {
  border-color: var(--accent-2);
  color: var(--accent-2);
  text-shadow: 0 0 10px rgba(255,43,214,.4);
}

/* ===== theme swatches (Settings view) ===== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.theme-swatch {
  text-align: left;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.theme-swatch:hover { border-color: var(--accent); }
.theme-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(var(--accent-rgb),.3);
}
.theme-swatch-strip {
  height: 36px;
  background-size: cover;
}
.theme-swatch[data-theme-preview="terminal"] .theme-swatch-strip {
  background: linear-gradient(90deg, #000000 0%, #0a3a1e 55%, #2ee06a 100%);
}
.theme-swatch[data-theme-preview="ocean"] .theme-swatch-strip {
  background: linear-gradient(90deg, #4ad6ff 0%, #7bc1ff 50%, #4afca0 100%);
}
.theme-swatch[data-theme-preview="daylight"] .theme-swatch-strip {
  background: linear-gradient(90deg, #ffffff 0%, #cfe0ff 50%, #0a6cff 100%);
}
.theme-swatch[data-theme-preview="pitch25"] .theme-swatch-strip {
  background: linear-gradient(135deg, #f45800 0%, #f9f8f6 50%, #303030 100%);
}
.theme-swatch[data-theme-preview="usc"] .theme-swatch-strip {
  background: linear-gradient(90deg, #0a0906 0%, #6b531e 55%, #d0a94e 100%);
}
.theme-swatch[data-theme-preview="rockets"] .theme-swatch-strip {
  background: linear-gradient(90deg, #000000 0%, #ce1141 60%, #c4ced4 100%);
}
.theme-swatch-name {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.theme-swatch.active .theme-swatch-name { color: var(--accent); }
.btn-logout {
  min-height: 34px;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.btn-logout:hover { color: var(--err); border-color: var(--err); }

.main { padding: 24px; max-width: 1400px; min-width: 0; width: 100%; margin: 0 auto; }

/* ===================== typography / pills / chips ===================== */
.eyebrow {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin: 0 0 10px;
}
h1, h2, h3 { font-family: 'Orbitron', sans-serif; letter-spacing: 0.06em; margin: 0 0 12px; }
h1 { font-size: 22px; font-weight: 800; text-transform: uppercase; }
h2 { font-size: 16px; font-weight: 700; text-transform: uppercase; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--text-dim); }

.badge {
  display: inline-block;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--text-dim);
}
.upd-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--warn) 22%, transparent);
  vertical-align: middle;
  line-height: 1;
}
.upd-tag::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
  animation: upd-pulse 1.6s ease-in-out infinite;
}
@keyframes upd-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
.pair-list { display: flex; flex-direction: column; gap: 10px; }
.pair-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.pair-code {
  font-size: 26px; font-weight: 700; letter-spacing: 0.16em;
  color: var(--accent); min-width: 128px; text-align: center;
  text-shadow: 0 0 14px rgba(var(--accent-rgb), 0.4);
}
.pair-fields { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.pair-fields .small { font-size: 11px; }
.pl-editor-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.status-pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 8px currentColor;
}
.status-success { color: var(--ok); }
.status-warning { color: var(--warn); }
.status-error   { color: var(--err); }
.status-neutral { color: var(--text-muted); }

/* ===================== cards / grids ===================== */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.toolbar.compact { gap: 8px; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

.grid { display: grid; gap: 16px; }
.grid.two   { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.four  { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  position: relative;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--line-2); }
.card.clickable:hover {
  border-color: rgba(var(--accent-rgb),.4);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
  cursor: pointer;
}
.card.sub-card { background: var(--bg-3); border-color: var(--line); padding: 14px; border-radius: 8px; }

.card .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card .title { font-family: 'Orbitron', sans-serif; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; }
.card .meta { color: var(--text-dim); font-size: 13px; }

/* ===================== controles ===================== */
.btn {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow-glow); }
.btn.primary {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),.18), rgba(var(--accent-rgb),.06));
  border-color: var(--accent);
  color: var(--accent);
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(var(--accent-rgb),.3), rgba(var(--accent-rgb),.1));
  box-shadow: 0 0 18px rgba(var(--accent-rgb),.4);
}
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.danger:hover:not(:disabled) { background: rgba(255,77,109,.1); box-shadow: 0 0 18px rgba(255,77,109,.3); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.input, .select, .textarea {
  font-size: 14px;
  min-height: 38px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.12);
}
.textarea { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-size: 12px; min-height: 200px; }
label.field { display: block; margin-bottom: 14px; }
label.field .lbl {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* ===================== login ===================== */
.login-wrap {
  display: grid; place-items: center; min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(var(--accent-rgb),.08);
}
.login-card .brand-big {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  letter-spacing: 0.2em;
  font-size: 18px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 14px rgba(var(--accent-rgb),.45);
  text-align: center;
  margin-bottom: 6px;
}
.login-card .brand-big .accent { color: var(--accent-2); }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 12px; margin-bottom: 28px; }
.login-card .err {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px;
  background: rgba(255,77,109,.08); border: 1px solid rgba(255,77,109,.4);
  color: var(--err); font-size: 12.5px;
}
.login-box { width: min(420px, 100%); }
.login-box .login-card { width: 100%; }
/* Google sign-in — white per Google brand guidance, reads on every theme. */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; color: #1f1f1f;
  font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
.btn-google:hover { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.btn-google:active { transform: translateY(1px); }
.btn-google .g-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-muted); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.2em;
}
.login-divider::before, .login-divider::after {
  content: ''; height: 1px; background: var(--line); flex: 1;
}
.login-foot {
  text-align: center; margin-top: 16px;
  color: var(--text-muted); font-size: 11px; letter-spacing: 0.06em;
}

/* ===================== device card ===================== */
.dev-name { font-size: 15px; }
.dev-meta { color: var(--text-dim); font-size: 13px; margin-top: 8px; line-height: 1.7; }
.dev-meta .k { color: var(--text-muted); }

/* ===================== media library ===================== */
.media-card {
  position: relative;
  overflow: hidden;
  /* Dark tile in every theme — thumbnails (and the name/badge overlays, which are
     built for dark) need contrast; on light skins (Pitch/Daylight) a white card
     washed the media out. */
  background: #191a1d;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
}
.media-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.4), var(--shadow-glow);
}
.media-card img, .media-card video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-card .pill {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,.7); color: var(--text);
  padding: 2px 8px; border-radius: 4px;
  font-family: 'Orbitron', sans-serif; font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
}
.media-card .pill.video { color: var(--accent-2); }
.media-card .tile-tags {
  position: absolute; top: 6px; left: 6px;
  display: flex; flex-wrap: wrap; gap: 4px; z-index: 1;
  max-width: calc(100% - 40px);   /* clear the top-right delete/order badge */
}
.media-card .tile-tags .pill { position: static; }
.media-card .pill.dim { color: var(--text-dim); background: rgba(0,0,0,.78); }
.media-card .name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px 10px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.85));
  font-size: 11px; color: var(--text); line-height: 1.3;
  word-break: break-all;
}
.media-card .order-badge {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #000;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 12px;
  box-shadow: 0 0 12px rgba(var(--accent-rgb),.6);
}
.media-card .del-btn {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.85); border: 1px solid var(--err); color: var(--err);
  padding: 0; font-size: 13px; line-height: 24px;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
  transition: background .12s, transform .12s, box-shadow .12s;
}
.media-card .del-btn:hover {
  background: var(--err); color: #fff;
  box-shadow: 0 0 14px rgba(255,77,109,.6);
  transform: scale(1.1);
}

/* upload card / drop zone */
.upload-card {
  aspect-ratio: 16 / 9;
  border: 2px dashed var(--line-2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
  color: var(--text-dim);
  background: rgba(255,255,255,.02);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.upload-card:hover, .upload-card.drag {
  border-color: var(--accent); color: var(--accent);
  background: rgba(var(--accent-rgb),.05);
}
.upload-card .big {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px; line-height: 1;
}
.upload-card .lbl2 { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }

/* ===================== modal ===================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5,5,12,.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: min(900px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: 0 30px 100px rgba(0,0,0,.7);
}
.modal header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal header .ttl { font-family: 'Orbitron', sans-serif; text-transform: uppercase; letter-spacing: 0.08em; font-size: 14px; color: var(--text); }
.modal header .sub { color: var(--text-dim); font-size: 12px; }
.modal main { padding: 20px 22px; }
.modal footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}
.modal .close {
  background: transparent; border: 0; color: var(--text-muted); font-size: 20px; line-height: 1; padding: 4px 8px;
}
.modal .close:hover { color: var(--err); }

/* ===================== confirm modal ===================== */
.modal.confirm-modal { max-width: 480px; }
.modal.confirm-modal header { border-bottom: 0; padding-bottom: 0; }
.modal.confirm-modal header .ttl { font-size: 15px; }
.modal.confirm-modal header .sub { font-size: 13px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; max-width: 420px; }
.modal.confirm-modal footer { border-top: 0; padding-top: 16px; padding-bottom: 22px; }

/* ===================== upload progress modal ===================== */
.upload-modal { max-width: 620px; width: 100%; }
.upload-overall {
  height: 8px; background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 4px; overflow: hidden;
  margin-bottom: 18px;
}
.upload-overall-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease-out;
  box-shadow: 0 0 14px rgba(var(--accent-rgb),.5);
}
.upload-list { display: flex; flex-direction: column; gap: 14px; }
.upload-row {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.upload-row-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 12px;
  gap: 10px;
}
.upload-row .upload-name { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .upload-pct {
  color: var(--text); flex-shrink: 0;
  font-family: 'Orbitron', sans-serif; letter-spacing: 0.08em; font-size: 11px;
}
.upload-row .upload-bar {
  height: 6px; background: var(--bg-1); border-radius: 3px; overflow: hidden;
  border: 1px solid var(--line);
}
.upload-row .upload-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transition: width .2s ease-out;
}
.upload-row.done .upload-bar-inner { background: var(--ok); box-shadow: 0 0 10px rgba(43,255,154,.4); }
.upload-row.done .upload-pct       { color: var(--ok); }
.upload-row.err  .upload-bar-inner { background: var(--err); }
.upload-row.err  .upload-pct       { color: var(--err); }
.upload-row .upload-err {
  margin-top: 6px; color: var(--err); font-size: 11.5px;
}

/* ===================== utilidades ===================== */
.loading { padding: 80px 24px; text-align: center; color: var(--text-muted); font-family: 'Orbitron', sans-serif; letter-spacing: 0.2em; }
.empty {
  padding: 60px 24px; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--line-2); border-radius: 10px;
}
.empty .big { font-family: 'Orbitron', sans-serif; font-size: 16px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
}
.toast .t {
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 14px; border-radius: 6px; font-size: 12.5px;
  box-shadow: 0 6px 28px rgba(0,0,0,.6);
  animation: slideIn .15s ease-out;
}
.toast .t.ok  { border-color: var(--ok);   color: var(--ok); }
.toast .t.err { border-color: var(--err);  color: var(--err); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--bg-3); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px;
  font-size: 11px;
}
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* lighting */
.light-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.light-swatch {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2);
  cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  transition: transform .1s ease;
}
.light-swatch:hover { transform: scale(1.1); border-color: var(--text); }
.sched-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  margin-top: 8px; background: var(--bg-3);
}
.sched-row.active { border-color: var(--ok); }

/* ---- Audio zones (per-zone source / volume / mute) ---- */
.zones { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.zrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
        border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); }
.zname { width: 130px; flex: 0 0 auto; font-weight: 600;
         overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zrow select.zsrc { flex: 0 0 auto; max-width: 200px; min-height: 36px; font-size: 14px; padding: 6px 10px;
                    border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text); }
.zvol { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.zvol-top { display: flex; align-items: center; gap: 10px; }
.zvol-top input[type="range"] { flex: 1; accent-color: var(--accent); }
.znudge { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 8px; padding: 0;
          border: 1px solid var(--line-2, #2a3550); background: var(--panel-2, #131a2b);
          color: var(--text, #e8eefc); font-size: 20px; font-weight: 700; line-height: 1;
          cursor: pointer; }
.znudge:hover { border-color: var(--accent); }
.znudge:active { background: var(--accent); color: #04121f; }
.znudge[disabled] { opacity: .4; cursor: default; }
.vu { height: 5px; border-radius: 3px; background: rgba(127,127,160,.18); overflow: hidden; }
.vu-fill { height: 100%; width: 0%; background: var(--ok); border-radius: 3px; transition: width .3s linear; }
.vu-fill.hot { background: var(--danger, #ff4d6a); }
.zval { width: 46px; flex: 0 0 auto; text-align: right; font-size: 13px;
        font-variant-numeric: tabular-nums; color: var(--text-muted);
        font-family: 'JetBrains Mono', ui-monospace, monospace; }
@media (max-width: 900px) {
  .zrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; }
  .zname { width: auto; }
  .zrow select.zsrc { width: 100%; max-width: 100%; min-width: 0; }
  .zrow > .btn { grid-column: 3; grid-row: 1; }
  .zvol { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .zrow { grid-template-columns: minmax(0, 1fr) auto; }
  .zrow > .btn { grid-column: 2; }
  .zrow select.zsrc { grid-column: 1 / -1; grid-row: 2; }
  .zvol { grid-row: 3; }
}

/* ---- Video matrix: routing grid (outputs × inputs) ---- */
.route-wrap { overflow-x: auto; margin-top: 8px; }
.route-grid { border-collapse: separate; border-spacing: 4px; }
.route-grid th {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-align: center; padding: 2px 4px; white-space: nowrap;
}
.route-grid th.route-out { text-align: right; padding-right: 8px; }
.route-cell {
  width: 38px; height: 32px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px;
  transition: transform .08s ease, border-color .1s ease, background .1s ease;
}
.route-cell:hover { border-color: var(--text); color: var(--text); }
.route-cell.active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700;
}

/* ---- video matrix: floor-plan tap-to-route ---- */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg-btn {
  padding: 7px 16px; background: var(--bg-3); color: var(--text-dim); border: 0; cursor: pointer;
  font-family: 'Orbitron', sans-serif; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
}
.seg-btn.on { background: var(--accent); color: #fff; }
.floorwrap {
  position: relative; width: 100%; margin-top: 10px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-2);
}
/* The plan PNG is dark-line-on-white; invert it on dark themes, leave it as-is on light ones. */
.floorbg { display: block; width: 100%; height: auto; filter: invert(1) brightness(1.08); }
body[data-theme="daylight"] .floorbg,
body[data-theme="pitch25"] .floorbg { filter: none; }
/* Vector floor plan (inline SVG, fill=currentColor): themes natively — no filters. */
.floorbg-vec { color: var(--text-dim); }
.floorbg-vec svg { display: block; width: 100%; height: auto; }
/* Dashed arc linking screens that share one matrix output (drawn under the chips). */
.floorlinks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.floorlink { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 10 8; opacity: .5; }
.hotspots { position: absolute; inset: 0; }
.hotspot {
  position: absolute; transform: translate(-50%, -50%); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 56px; padding: 5px 9px; border-radius: 9px;
  border: 2px solid var(--line-2); background: var(--bg-2); color: var(--text-dim);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); transition: border-color .1s, box-shadow .1s;
}
.hotspot b { font-family: 'Orbitron', sans-serif; font-size: 12px; color: var(--text); font-weight: 700; line-height: 1.15; }
.hotspot span { font-size: 10px; color: var(--text-muted); white-space: nowrap; line-height: 1.2; }
.hotspot:hover { border-color: var(--text); }
.hotspot.live { border-color: var(--accent); }
.hotspot.live span { color: var(--accent); }
.hotspot.sel { border-color: var(--accent-2); box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.6); }
.pickpop {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7); min-width: 280px; max-width: 90%; text-align: center;
}
.pickpop-h {
  font-family: 'Orbitron', sans-serif; font-size: 11px; color: var(--text-dim);
  margin-bottom: 12px; letter-spacing: 0.1em; text-transform: uppercase;
}
.pickpop .btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px; }
.pickpop .btn.lg { flex: 1 1 40%; min-height: 48px; }

/* ===================== responsive ===================== */

/* ---- Tablet: tighten page padding + grid floors before columns cramp ---- */
/* Give context controls their own row before account controls get squeezed. */
@media (min-width: 641px) and (max-width: 1200px) {
  .topbar-context { gap: 12px 20px; }
  .context-group { order: 3; flex: 1 1 100%; margin-left: 0; padding-left: 0; border-left: 0; padding-bottom: 4px; }
  .ctx-picker { flex: 0 1 auto; }
  .tenant-select { min-width: 0; width: 190px; max-width: 240px; }
}
.tenant-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tenant-select option { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; background: var(--bg-2); color: var(--text); }

@media (max-width: 900px) {
  .main { padding: 18px; }
  /* keep 2-up readable instead of squeezing toward another column */
  .grid.two   { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .grid.three { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ============================================================
   PHONES (360–414px target) — replaces the old max-width:720px
   block (which targeted the dead .tabs/.topbar layout).
   ============================================================ */
@media (max-width: 640px) {

  /* ---- TOPBAR: rows drop fixed heights, notch-safe side padding ---- */
  .topbar { padding-top: env(safe-area-inset-top, 0px); }
  .topbar-row {
    gap: 10px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  /* collapse the .grow spacers so wrapping/scrolling places items, not the spacer */
  .topbar-row .grow { display: none; }

  /* context row wraps into stacked lines instead of running off-edge */
  .topbar-context {
    flex-wrap: wrap;
    height: auto;
    min-height: 58px;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px 12px;
  }

  /* Keep the brand prominent while controls stay compact. */
  .brand { padding: 8px 14px; border-radius: 8px; }
  .brand-logo { height: 38px; }

  /* context-group: own full-width line, no left divider/indent */
  .context-group {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 8px 10px;
  }
  .ctx-picker { flex: 1 1 auto; min-width: 0; gap: 6px; }
  .ctx-sep { display: none; } /* › separator reads as clutter once wrapped */

  /* user block: own full-width line, email truncates instead of pushing Sign out off-screen */
  .user { flex: 1 1 100%; gap: 8px; min-width: 0; }
  .user-email {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .user-role { flex: 0 0 auto; }
  .btn-logout {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
  }

  /* nav: horizontal scroll strip (full-bleed) instead of cut-off tabs */
  .topbar-nav {
    height: auto;
    min-height: 48px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -14px;
    padding: 6px 14px;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav .grow { display: none; } /* keep Settings scrolling inline, not pinned off-edge */

  /* ---- TABS / TAP TARGETS ---- */
  .tab {
    flex: 0 0 auto;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 9px 12px;
    font-size: 12px;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn.small { min-height: 40px; }
  .tenant-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 38px;
    padding: 6px 30px 6px 10px;
    text-overflow: ellipsis;
  }
  .tenant-static { min-height: 40px; display: inline-flex; align-items: center; }
  .media-card .del-btn { width: 38px; height: 38px; line-height: 36px; }
  .light-swatch { width: 44px; height: 44px; }

  /* ---- iOS zoom guard: 16px font on form fields (mono editor stays smaller) ---- */
  .input, .select, .textarea,
  input, select, textarea { font-size: 16px; }
  .textarea { font-size: 13px; }

  /* ---- PAGE SHELL: safe-area side insets (16px floor) ---- */
  .main {
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  /* ---- HEADINGS: scale down a touch, keep Orbitron presence ---- */
  h1 { font-size: 18px; letter-spacing: 0.05em; }
  h2 { font-size: 15px; }
  h3 { font-size: 12.5px; }
  .eyebrow { font-size: 10px; letter-spacing: 0.18em; }
  .badge { letter-spacing: 0.12em; }

  /* ---- GRIDS ---- */
  .grid { gap: 12px; }
  .grid.two,
  .grid.three { grid-template-columns: 1fr; }
  /* four = media thumbnails: hold 2 columns, never force a cramped 3rd */
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  /* ---- CARDS ---- */
  .card { padding: 14px; border-radius: 9px; }
  .card.sub-card { padding: 12px; }
  .card .row { flex-wrap: wrap; gap: 8px; }

  /* ---- TOOLBARS: wrap, never overflow (the .grow spacer is the culprit) ---- */
  .toolbar { gap: 10px; margin-bottom: 16px; }
  .toolbar.compact { gap: 8px; margin-bottom: 12px; }
  .toolbar .grow { flex: 0 0 100%; flex-basis: 100%; height: 0; } /* force a line break */
  .toolbar .btn {
    flex: 1 1 auto;
    min-width: 132px;
    text-align: center;
  }
  .toolbar.compact > div:first-child { flex: 1 1 100%; }

  /* ---- DEVICE META: wrap long IP / version / ssid values ---- */
  .dev-name { font-size: 14px; }
  .dev-meta { overflow-wrap: anywhere; word-break: break-word; }
  .dev-meta .mono { overflow-wrap: anywhere; word-break: break-all; }

  /* ---- EMPTY STATE / DIVIDERS ---- */
  .empty { padding: 44px 16px; }
  .empty .big { font-size: 14px; letter-spacing: 0.14em; }
  .hr { margin: 14px 0; }

  /* ---- MODAL: tight gutters, near-fullscreen ---- */
  .modal-overlay { padding: 9px; place-items: stretch; align-content: stretch; }
  .modal { width: 100%; max-height: calc(100vh - 18px); border-radius: 10px; }
  .modal.confirm-modal,
  .upload-modal { max-width: none; width: 100%; }
  .modal header { padding: 14px 16px; }
  .modal header .ttl { font-size: 13px; }
  .modal header .sub { font-size: 13px; }
  .modal main { padding: 16px; }
  .modal .close {
    min-width: 40px; min-height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px; font-size: 22px;
  }
  /* footer: full-width stacked, primary on top, clear the home-bar */
  .modal footer {
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal footer .btn { width: 100%; min-height: 44px; padding: 12px 16px; }
  .modal.confirm-modal footer { padding-top: 14px; padding-bottom: 18px; }
  /* embedded media picker grid already 2-up via .grid.four above */
  label.field { margin-bottom: 16px; }

  /* ---- PLAYLIST / SCHEDULE EDITOR HEADER ---- */
  .pl-editor-top { gap: 10px; margin-bottom: 14px; }
  .pl-editor-top .btn { min-height: 44px; }

  /* ---- PAIRING ROWS: stack, code on its own line ---- */
  .pair-row { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .pair-code { min-width: 0; width: 100%; font-size: 30px; letter-spacing: 0.18em; }
  .pair-fields { width: 100%; }
  .pair-row .btn { width: 100%; min-height: 44px; }

  /* ---- UPLOAD PROGRESS MODAL ---- */
  .upload-list { gap: 12px; }
  .upload-row-top { gap: 8px; }

  /* ---- LIGHTING: swatches ---- */
  .light-swatches { gap: 10px; }
  .light-swatch { border-radius: 10px; }
  .light-swatch:hover { transform: none; } /* no hover on touch */
  .light-swatch:active { transform: scale(1.08); }

  /* ---- LIGHTING: "Live control" macro row (color input + Full/Blackout/Stop fade) ---- */
  .light-swatches + .row { flex-wrap: wrap; align-items: flex-end; gap: 10px; }
  .light-swatches + .row .field { margin-bottom: 0; flex: 0 0 auto; }
  .light-swatches + .row input[type="color"] {
    width: 56px;
    height: 44px;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-2);
    cursor: pointer;
  }
  .light-swatches + .row .grow { flex: 0 0 100%; height: 0; }
  .light-swatches + .row .btn { flex: 1 1 auto; min-height: 44px; text-align: center; }

  /* ---- LIGHTING: scene / schedule rows ---- */
  .sched-row { flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; padding: 10px 12px; }
  .sched-row > div:first-child { flex: 1 1 100%; min-width: 0; line-height: 1.5; }
  .sched-row .row { flex: 1 1 100%; justify-content: flex-end; gap: 8px; }
  .sched-row .btn.small { min-height: 40px; padding: 6px 14px; }
  .sched-row > .btn.small.danger { margin-left: auto; }

  /* ---- LOGIN ---- */
  .login-wrap { padding: 20px; }
  .login-card { padding: 22px; border-radius: 12px; }
  .login-logo { margin-bottom: 16px; }
  .login-logo-img { height: 38px; padding: 12px 18px; border-radius: 10px; }
  .login-card .brand-big { font-size: 16px; letter-spacing: 0.16em; margin-bottom: 6px; }
  .login-card .sub { margin-bottom: 22px; }
  .login-card .err { font-size: 12px; }

  /* ---- HARDENING: kill horizontal overflow on real phones ---- */
  .topbar, .topbar-row, .topbar-context, .topbar-nav,
  .main, .card, .toolbar { max-width: 100%; min-width: 0; }
  /* pickers stack full-width so a native <select>'s intrinsic min-width can't push the page wide */
  .context-group { flex-direction: column; align-items: stretch; gap: 8px; width: 100%; }
  .ctx-picker { width: 100%; justify-content: space-between; gap: 10px; }
  .picker-label { flex: 0 0 64px; }
  .ctx-picker .tenant-select,
  .ctx-picker .tenant-static { flex: 1 1 auto; min-width: 0; max-width: 100%; }
  .tenant-select { width: 100%; max-width: 100%; }
  .user { width: 100%; }
  /* nav: drop the full-bleed negative margin (overflowed ~28px) — plain inset instead */
  .topbar-nav { margin: 0; padding: 6px 0; }
}

/* ============================================================
   Spotify module — now-playing card + transport
   ============================================================ */
.sp-now { display: flex; gap: 18px; align-items: flex-start; }
.sp-art { width: 132px; height: 132px; flex: 0 0 auto; border-radius: 10px;
  object-fit: cover; border: 1px solid var(--line); box-shadow: var(--shadow-glow); }
.sp-art-empty { display: flex; align-items: center; justify-content: center;
  font-size: 44px; color: var(--text-muted); background: rgba(var(--accent-rgb), .07); }
.sp-now-info { flex: 1 1 auto; min-width: 0; }
.sp-track { font-size: 20px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-artist { color: var(--text-dim); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-prog { margin: 14px 0 4px; }
.sp-prog-bar { height: 6px; border-radius: 3px; background: rgba(127,127,160,.18); overflow: hidden; }
.sp-prog-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 3px; transition: width .4s linear; }
.sp-prog-time { display: flex; justify-content: space-between; font-size: 12px;
  color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.sp-transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sp-transport .sp-play { min-width: 104px; }
.sp-vol { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.sp-vol input[type="range"] { flex: 1 1 auto; max-width: 320px; }
.chip-wrap { display: inline-flex; align-items: stretch; }
.chip-wrap .btn.small.danger { padding: 4px 8px; margin-left: 2px; }

/* Spotify Web API search/browse results */
.sp-res-h {
  font-family: 'Orbitron', sans-serif; font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-muted);
  margin: 14px 0 6px;
}
.sp-res-list { display: flex; flex-direction: column; gap: 4px; }
.sp-res {
  display: flex; align-items: center; gap: 12px;
  padding: 6px; border-radius: 8px;
  transition: background .12s;
}
.sp-res:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.sp-res-art { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 5px; object-fit: cover; background: #191a1d; }
.sp-res-art.sp-art-empty { display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-muted); }
.sp-res-info { flex: 1 1 auto; min-width: 0; }
.sp-res-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-res-sub { color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.sp-res-actions { flex: 0 0 auto; display: flex; gap: 6px; }

@media (max-width: 560px) {
  .sp-now { flex-direction: column; align-items: center; text-align: center; }
  .sp-art { width: 160px; height: 160px; }
  .sp-track, .sp-artist { white-space: normal; }
  .sp-vol input[type="range"] { max-width: none; }
  .sp-res-actions .btn { padding: 6px 8px; }
}

/* ---- boot splash: the logo always comes first, then the app fades in ---- */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-0, #050b12);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; transition: opacity .45s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-logo {
  width: min(320px, 62vw); height: auto;
  mix-blend-mode: screen;              /* melts the logo's black plate into the bg */
  opacity: 0; animation: splash-in .6s ease-out .05s forwards;
}
.splash-rail {
  height: 2px; width: min(230px, 48vw); border-radius: 2px;
  background: linear-gradient(90deg, #22d3ee, #38bdf8, #3b82f6);
  transform-origin: left center;
  animation: splash-rail .85s ease-out .3s both;
}
@keyframes splash-in   { from { opacity: 0; transform: translateY(10px) scale(.985); }
                         to   { opacity: 1; transform: none; } }
@keyframes splash-rail { from { transform: scaleX(0); opacity: .35; }
                         to   { transform: scaleX(1); opacity: 1; } }

/* ── Lighting · look library ────────────────────────────────────────────────
   Layout first: this is a wrapping button grid, NOT a toolbar. It must not
   inherit `.card .row { justify-content: space-between }` — with wrapped content
   that rule stretches every line to full width and leaves ragged holes between
   buttons. Left-aligned with an even gap instead. */
.look-grid { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
.look-cat { margin: 16px 0 7px; }
.look-cat:first-of-type { margin-top: 6px; }
.look-scroll { max-height: 52vh; overflow-y: auto; margin-top: 4px; padding-right: 4px; }

/* Master: the slider takes the room, the readout stays pinned beside it.
   min-width:0 lets the range actually shrink inside the flex line instead of
   forcing the value onto its own row. */
.light-master-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.light-master-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.light-master-row .lbl { flex: 0 0 auto; }
.light-master-row .val {
  flex: 0 0 auto; min-width: 3.5em; text-align: right;
  color: var(--accent); font-size: 15px; text-shadow: 0 0 12px rgba(var(--accent-rgb), .35);
}

/* ── Lighting · surface ─────────────────────────────────────────────────────
   No glass: flat panels, same as the rest of the console. What carries the
   accent is an edge-light hairline and the state of the chips — everything
   resolves through the theme tokens, so all six client skins hold. */
.light-card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-color: rgba(var(--accent-rgb), .16);
  overflow: hidden;
}
.light-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), .55), transparent);
  pointer-events: none;
}

/* Looks read as chips: quiet at rest, accent on approach, lit when live. */
.look-grid .btn {
  border-color: var(--line);
  background: var(--bg-3);
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s, transform .15s;
}
.look-grid .btn:hover {
  border-color: rgba(var(--accent-rgb), .45);
  color: var(--text);
  transform: translateY(-1px);
}
.look-grid .btn.primary {
  border-color: rgba(var(--accent-rgb), .7);
  box-shadow: var(--shadow-glow);
}
/* Category headers get a rule that fades out, so 18 banks stay scannable. */
.look-cat { display: flex; align-items: center; gap: 10px; color: var(--text-dim); }
.look-cat::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .18), transparent);
}

/* ── Device card header ─────────────────────────────────────────────────────
   The pills used to sit in a `.card .row`, whose space-between pushes wrapped
   chips into ragged rows and crushes the header. Own flex line instead: chips
   flow left with a real gap, the version is pinned right and never breaks
   mid-token (it read as "vceiling-\n1.0.0"). */
.dev-card-head {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; row-gap: 9px; margin-bottom: 14px;
}
.dev-card-head .grow { flex: 1 1 auto; }
.dev-card-head .badge, .dev-card-head .status-pill { margin-left: 0 !important; }
.dev-card-ver { white-space: nowrap; flex: 0 0 auto; font-size: 12px; }

/* Breathing room — TB Ops spacing, not a data table. */
.card .dev-name { margin: 2px 0 12px; }
.card .dev-meta > div { padding: 3px 0; }
