/* ═══════════════════════════════════════════════════════════════════
   Tally Portal — Premium Design System v4
   Deep space dark theme with luminous green accents
   Inspired by Linear, Vercel, Raycast
   ═══════════════════════════════════════════════════════════════════ */
:root {
  /* ── Core palette ── */
  --bg-base: #050a07;
  --bg-surface: rgba(255,255,255,0.035);
  --bg-surface-solid: #0c1610;
  --bg-elevated: rgba(255,255,255,0.06);
  --border: rgba(0,230,118,0.08);
  --border-solid: #122a1c;
  --border-hover: rgba(0,230,118,0.18);

  /* ── Primary accent ── */
  --primary: #00E676;
  --primary-dim: rgba(0,230,118,0.10);
  --primary-glow: rgba(0,230,118,0.20);
  --primary-bright: #66FFA0;

  /* ── Text ── */
  --text-primary: rgba(255,255,255,0.92);
  --text-secondary: rgba(255,255,255,0.55);
  --text-muted: rgba(255,255,255,0.32);

  /* ── Semantic ── */
  --warning: #FFB74D;
  --warning-dim: rgba(255,183,77,0.12);
  --danger: #FF5252;
  --danger-dim: rgba(255,82,82,0.12);
  --info: #64B5F6;

  /* ── Geometry ── */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  /* ── Glass ── */
  --glass-blur: blur(20px);
  --glass-blur-sm: blur(12px);

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 20px rgba(0,230,118,0.08);

  /* ── Motion ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 100% 80% at 15% 5%, rgba(0,230,118,0.06) 0%, transparent 50%),
    radial-gradient(ellipse 80% 60% at 90% 85%, rgba(0,230,118,0.04) 0%, transparent 45%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(0,230,118,0.015) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* Subtle noise texture overlay
   IMPORTANT: Sits *behind* content (z-index: -1) and does NOT use
   mix-blend-mode. A prior version had z-index:9998 + mix-blend-mode:overlay
   stacked above card backdrop-filter stacking contexts, which triggers a
   Chrome/Safari compositing bug that paints affected regions solid black
   (the overview cards below the equipment table turned into a black area). */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ─── SIDEBAR ──────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: rgba(5,10,7,0.80);
  backdrop-filter: var(--glass-blur) saturate(1.2);
  -webkit-backdrop-filter: var(--glass-blur) saturate(1.2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-brand {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}
.sidebar-church {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--duration-fast) ease;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  opacity: 0.7;
}
.nav-item.active .icon { opacity: 1; }
.nav-item:hover .icon { opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-settings-toggle { display: none; }
.sidebar-settings-panel { display: block; }
.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  padding: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.btn-logout:hover {
  border-color: rgba(255,82,82,0.4);
  color: var(--danger);
  background: var(--danger-dim);
}

/* ─── MAIN ─────────────────────────────────────────────────────── */
.main {
  margin-left: 220px;
  flex: 1;
  padding: 36px 48px;
  max-width: 1440px;
  width: 100%;
  min-height: 100vh;
}
.page { display: none; }
.page.active {
  display: block;
  animation: pageEnter 0.3s var(--ease-out);
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header-text { flex: 1; }
.page-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}
.page-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Help icon button */
.help-icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) ease;
}
.help-icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-dim);
  box-shadow: 0 0 12px rgba(0,230,118,0.15);
}
#page-overview .help-icon-btn { border-color: var(--border-solid); color: var(--primary-bright); }

/* Help modal */
#help-modal { background: rgba(0,0,0,0.7); }
#help-modal .modal {
  width: 540px;
  max-height: 80vh;
  overflow-y: auto;
}
#help-modal-body { font-size: 14px; color: var(--text-secondary); line-height: 1.75; }
#help-modal-body h3 { color: var(--text-primary); font-size: 15px; margin: 16px 0 6px; font-weight: 700; }
#help-modal-body ul { padding-left: 18px; margin: 8px 0; }
#help-modal-body li { margin-bottom: 6px; }
#help-modal-body strong { color: var(--text-primary); }
#help-modal-body .tip-box {
  background: var(--primary-dim);
  border: 1px solid rgba(0,230,118,0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 13px;
}

/* ─── GLASS CARDS ──────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.025);
  backdrop-filter: var(--glass-blur-sm) saturate(1.1);
  -webkit-backdrop-filter: var(--glass-blur-sm) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease, transform var(--duration-normal) var(--ease-out);
}
.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow), inset 0 1px 0 rgba(255,255,255,0.05);
  transform: translateY(-1px);
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ─── FORMS ────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, background var(--duration-fast) ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,230,118,0.08), 0 0 16px rgba(0,230,118,0.06);
  background: rgba(0,0,0,0.4);
}
.field input::placeholder, .field textarea::placeholder {
  color: var(--text-muted);
}
.field textarea {
  resize: vertical;
  min-height: 100px;
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'Courier New', monospace;
  font-size: 12px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ─── TAB BAR ──────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab-bar button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: color var(--duration-fast) ease, border-color var(--duration-fast) ease;
  white-space: nowrap;
  position: relative;
}
.tab-bar button:hover { color: var(--text-secondary); }
.tab-bar button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active {
  display: block;
  animation: tabFadeIn 0.2s var(--ease-out);
}
@keyframes tabFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── SCHEDULE ─────────────────────────────────────────────────── */
.schedule-empty {
  border: 1px dashed rgba(255,183,77,0.35);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 12px;
  text-align: center;
}
.schedule-quiet-banner {
  background: rgba(255, 183, 77, 0.08);
  border: 1px solid rgba(255, 183, 77, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: #FFB74D;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.45;
}
body:not(.booth-connected) .nav-item[data-booth-required] {
  display: none !important;
}
.booth-required-empty {
  display: none;
  background: rgba(255, 183, 77, 0.08);
  border: 1px solid rgba(255, 183, 77, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: #FFB74D;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.45;
}
body:not(.booth-connected) .booth-required-empty { display: block; }
.td-readonly-banner {
  display: none;
  background: rgba(100, 181, 246, 0.08);
  border: 1px solid rgba(100, 181, 246, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #64B5F6;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.45;
}
body.td-session .td-readonly-banner { display: block; }
body.td-session .church-admin-write { display: none !important; }
.schedule-rows { display: flex; flex-direction: column; gap: 10px; }
.schedule-row {
  display: grid;
  grid-template-columns: 150px auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--duration-fast) ease;
}
.schedule-row:hover { border-color: var(--border-hover); }
.schedule-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.schedule-note { color: var(--text-muted); font-size: 12px; }

/* Schedule Overview (read-only) */
.schedule-overview-day { margin-bottom: 10px; }
.schedule-overview-day:last-child { margin-bottom: 0; }
.schedule-day-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.schedule-window {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-dim);
  border: 1px solid rgba(0,230,118,0.12);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 6px;
  margin-bottom: 4px;
}
.schedule-window .sw-time { color: var(--primary); font-weight: 600; }
.schedule-window .sw-label { color: var(--text-secondary); font-style: italic; }
.time-select { display: inline-flex; align-items: center; gap: 2px; }
.time-select select {
  background: rgba(0,0,0,0.3);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 4px;
  font-size: 13px;
  cursor: pointer;
}
.time-select select:focus { border-color: var(--primary); outline: none; }
.time-select span { color: var(--text-muted); font-size: 14px; padding: 0 1px; }

/* ─── BUTTONS ──────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, #00E676 0%, #00C853 100%);
  color: #050a07;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  box-shadow: 0 0 16px rgba(0,230,118,0.20), 0 2px 4px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}
.btn-primary:hover {
  box-shadow: 0 0 28px rgba(0,230,118,0.35), 0 4px 8px rgba(0,0,0,0.3);
  transform: translateY(-1px);
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-secondary {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--primary);
  background: var(--primary-dim);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255,82,82,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.btn-danger:hover {
  background: var(--danger-dim);
  border-color: rgba(255,82,82,0.4);
}

.btn-sm {
  background: transparent;
  color: var(--primary);
  border: 1px solid rgba(0,230,118,0.2);
  border-radius: var(--radius-xs);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.btn-sm:hover {
  background: var(--primary-dim);
  border-color: rgba(0,230,118,0.35);
}

/* ─── TABLES ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr { transition: background var(--duration-fast) ease; }
tr:hover { background: rgba(255,255,255,0.015); }

/* ─── BADGES ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
  letter-spacing: 0.02em;
}
.badge-green {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid rgba(0,230,118,0.15);
}
.badge-yellow {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(255,183,77,0.15);
}
.badge-red {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255,82,82,0.15);
}
.badge-gray {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ─── STATUS ───────────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-dot.online {
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary), 0 0 16px rgba(0,230,118,0.3);
}
.status-dot.offline { background: var(--text-secondary); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes thinkBounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes onboardPulse { 0%, 100% { border-color: var(--border-solid); box-shadow: 0 0 0 rgba(0,230,118,0); } 50% { border-color: var(--primary); box-shadow: 0 0 12px rgba(0,230,118,0.15); } }
@keyframes onboardSlideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes onboardCheckPop { 0% { transform: scale(0.5); opacity: 0; } 50% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }
.onboard-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-dim);
  border: 1px solid rgba(0,230,118,0.15);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  cursor: pointer;
  text-decoration: none;
  margin-top: 4px;
  transition: all var(--duration-fast) ease;
}
.onboard-action-btn:hover { background: rgba(0,230,118,0.18); border-color: rgba(0,230,118,0.3); }

/* ─── STATS ROW ────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: rgba(255,255,255,0.025);
  backdrop-filter: var(--glass-blur-sm) saturate(1.1);
  -webkit-backdrop-filter: var(--glass-blur-sm) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.03);
  transition: all var(--duration-normal) ease;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(0,230,118,0.2) 50%, transparent 100%);
  opacity: 0;
  transition: opacity var(--duration-normal) ease;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(-2px);
}
.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── TOGGLE ───────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 22px;
  transition: all var(--duration-fast) ease;
}
.slider:before {
  position: absolute; content: "";
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--duration-fast) var(--ease-spring);
}
input:checked + .slider { background: rgba(0,230,118,0.2); }
input:checked + .slider:before {
  background: var(--primary);
  transform: translateX(18px);
  box-shadow: 0 0 8px rgba(0,230,118,0.4);
}

/* ─── TOAST ────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: rgba(12,22,16,0.95);
  backdrop-filter: var(--glass-blur) saturate(1.3);
  -webkit-backdrop-filter: var(--glass-blur) saturate(1.3);
  border: 1px solid rgba(0,230,118,0.2);
  color: var(--primary);
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  opacity: 0; transform: translateY(16px) scale(0.95);
  transition: all var(--duration-normal) var(--ease-out);
  pointer-events: none; z-index: 999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 16px rgba(0,230,118,0.1);
}
#toast.show { opacity: 1; transform: translateY(0) scale(1); }
#toast.error { border-color: rgba(255,82,82,0.3); color: var(--danger); }

/* ─── CODE BLOCK ───────────────────────────────────────────────── */
.code-block {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 16px;
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'Courier New', monospace;
  font-size: 12px;
  color: var(--primary);
  word-break: break-all;
}

/* ─── GRID UTILITIES ───────────────────────────────────────────── */
.grid-4col { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.grid-3col { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── MODAL ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px) saturate(0.8);
  -webkit-backdrop-filter: blur(8px) saturate(0.8);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-backdrop.open {
  display: flex;
  animation: backdropIn 0.2s var(--ease-out);
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: rgba(12,22,16,0.97);
  backdrop-filter: var(--glass-blur) saturate(1.3);
  -webkit-backdrop-filter: var(--glass-blur) saturate(1.3);
  border: 1px solid rgba(0,230,118,0.1);
  border-radius: 18px;
  padding: 32px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 40px rgba(0,230,118,0.05);
  animation: modalSlideIn 0.3s var(--ease-out);
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-close {
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) ease;
}
.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.1);
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.help-box {
  background: var(--primary-dim);
  border: 1px solid rgba(0,230,118,0.12);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
}
.help-box strong { color: var(--text-primary); }

/* ─── TOOLTIPS ─────────────────────────────────────────────────── */
.tip { position: relative; cursor: help; border-bottom: 1px dotted rgba(255,255,255,0.2); }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(12,22,16,0.95);
  backdrop-filter: var(--glass-blur-sm);
  -webkit-backdrop-filter: var(--glass-blur-sm);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: normal;
  width: max-content;
  max-width: 260px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.tip:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── MOBILE ───────────────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 1001;
  background: rgba(5,10,7,0.9);
  backdrop-filter: var(--glass-blur-sm);
  -webkit-backdrop-filter: var(--glass-blur-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 42px; height: 42px;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  align-items: center; justify-content: center;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
}
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar {
    display: none;
    position: fixed; z-index: 1000;
    top: 0; left: 0; bottom: 0;
    width: 220px;
    overflow-y: scroll; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar.open { display: flex; flex-direction: column; }
  .sidebar-overlay.open { display: block; }
  .sidebar .sidebar-footer { margin-top: 16px; }
  .sidebar-settings-toggle {
    display: flex; align-items: center; gap: 6px;
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-xs); color: var(--text-secondary);
    font-size: 12px; padding: 7px 10px; width: 100%; cursor: pointer;
    margin-bottom: 6px; transition: all var(--duration-fast) ease;
  }
  .sidebar-settings-toggle:hover { color: var(--text-primary); border-color: var(--primary); }
  .sidebar-settings-toggle svg { flex-shrink: 0; }
  .sidebar-settings-toggle .settings-chevron { margin-left: auto; transition: transform 0.2s; }
  .sidebar-settings-toggle.open .settings-chevron { transform: rotate(180deg); }
  .sidebar-settings-panel { display: none; margin-bottom: 6px; }
  .sidebar-settings-panel.open { display: block; }
  .nav-more-items { max-height: none; overflow: visible; transition: none; display: none; }
  .nav-more-items.open { display: block; }
  .main { margin-left: 0; padding: 16px; padding-top: 56px; }
  .page-title { font-size: 20px; }
  .card { padding: 18px; }
  .card-title { font-size: 12px; }
  .stats-row { grid-template-columns: repeat(3,1fr) !important; gap: 8px; }
  .stat-value { font-size: 22px; }
  .stat-card { padding: 14px 8px; }
  .grid-4col { grid-template-columns: repeat(2,1fr) !important; }
  .grid-3col { grid-template-columns: 1fr !important; }
  .grid-2col { grid-template-columns: 1fr !important; }
  .field-row { grid-template-columns: 1fr !important; }
  .schedule-row { grid-template-columns: 1fr !important; gap: 6px; }
  table { font-size: 12px; }
  th, td { padding: 8px 6px 8px 0; }
  #toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 24px 18px;
  }
  .modal-footer { flex-wrap: wrap; }
  .help-box { font-size: 12px; padding: 10px 12px; }
  #activity-feed-body { max-height: 200px; }
  .grid-4col > div { padding: 10px 6px !important; }
  .nav-item.active::before { display: none; }
}

/* ─── Desktop wide ────────────────────────────────────────────── */
@media (min-width: 1200px) {
  .main { padding: 36px 56px; }
  .grid-4col { grid-template-columns: repeat(4,1fr); gap: 18px; }
  .stats-row { gap: 20px; }
}
@media (min-width: 1600px) {
  .main { padding: 40px 72px; }
}

/* ─── Light Theme ──────────────────────────────────────────────── */
body.light-theme {
  --bg-base: #f8fafc;
  --bg-surface: rgba(255,255,255,0.8);
  --bg-surface-solid: #ffffff;
  --bg-elevated: rgba(255,255,255,0.9);
  --border: rgba(0,0,0,0.06);
  --border-solid: #e2e8f0;
  --border-hover: rgba(22,163,74,0.25);
  --primary: #16a34a;
  --primary-dim: rgba(22,163,74,0.06);
  --primary-glow: rgba(22,163,74,0.12);
  --primary-bright: #16a34a;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --warning: #d97706;
  --warning-dim: rgba(217,119,6,0.08);
  --danger: #dc2626;
  --danger-dim: rgba(220,38,38,0.08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-glow: none;
}
body.light-theme { background: var(--bg-base); background-image: none; color: var(--text-primary); }
body.light-theme::before { display: none; }
body.light-theme .sidebar {
  background: var(--bg-surface-solid);
  border-right-color: var(--border-solid);
  backdrop-filter: none;
  box-shadow: 1px 0 4px rgba(0,0,0,0.04);
}
body.light-theme .card {
  background: var(--bg-surface-solid);
  border-color: var(--border-solid);
  backdrop-filter: none;
}
body.light-theme .card:hover {
  border-color: rgba(22,163,74,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
body.light-theme .stat-card {
  background: var(--bg-surface-solid);
  border-color: var(--border-solid);
  backdrop-filter: none;
}
body.light-theme .stat-card::before {
  background: linear-gradient(90deg, transparent, rgba(22,163,74,0.15), transparent);
}
body.light-theme .stat-value { color: var(--text-primary); }
body.light-theme .nav-item { color: var(--text-secondary); }
body.light-theme .nav-item:hover { background: #f1f5f9; color: var(--text-primary); }
body.light-theme .nav-item.active { background: #dcfce7; color: #166534; }
body.light-theme .nav-item.active::before { background: #16a34a; }
body.light-theme input, body.light-theme textarea, body.light-theme select { background: #f8fafc; border-color: var(--border-solid); color: var(--text-primary); }
body.light-theme input:focus, body.light-theme textarea:focus, body.light-theme select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,0.08); }
body.light-theme .btn-primary { background: linear-gradient(135deg, #16a34a 0%, #15803d 100%); box-shadow: 0 1px 4px rgba(22,163,74,0.2); }
body.light-theme .btn-secondary { background: #f1f5f9; border-color: var(--border-solid); color: #334155; }
body.light-theme .btn-secondary:hover { background: #e2e8f0; border-color: rgba(22,163,74,0.2); }
body.light-theme .btn-logout { background: #f1f5f9; border-color: var(--border-solid); color: var(--text-secondary); }
body.light-theme .badge-gray { background: #f1f5f9; color: var(--text-secondary); }
body.light-theme .badge-green { background: #dcfce7; color: #166534; }
body.light-theme .badge-yellow { background: #fef9c3; color: #854d0e; }
body.light-theme .badge-red { background: #fee2e2; color: #991b1b; }
body.light-theme table th { color: var(--text-secondary); border-bottom-color: var(--border-solid); }
body.light-theme table td { border-bottom-color: #f1f5f9; color: #334155; }
body.light-theme .tip { color: var(--text-primary); }
body.light-theme .sidebar-footer { border-top-color: var(--border-solid); }
body.light-theme .modal {
  background: rgba(255,255,255,0.97);
  border-color: var(--border-solid);
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.15);
}
body.light-theme .modal-backdrop {
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
}
body.light-theme .modal-close { background: #f1f5f9; }
body.light-theme .modal-close:hover { background: #e2e8f0; }
body.light-theme .help-box { background: #f1f5f9; border-color: var(--border-solid); color: #334155; }
body.light-theme .sidebar-brand { color: var(--text-primary); }
body.light-theme #theme-toggle { border-color: var(--border-solid) !important; }
body.light-theme #theme-label { color: #334155 !important; }
/* Referral card */
body.light-theme #referral-card { background: #f0fdf4 !important; border-color: #bbf7d0 !important; }
body.light-theme #referral-card * { color: var(--text-primary) !important; }
body.light-theme #referral-card .btn-primary { color: #000 !important; }
body.light-theme #referral-card [style*="background:#060D08"], body.light-theme #referral-card [style*="background:#0a1610"] { background: #f8fafc !important; border-color: var(--border-solid) !important; color: var(--text-primary) !important; }
/* Pre-service check cards */
body.light-theme .psc-check-pass { background: #dcfce7 !important; border-color: #bbf7d0 !important; color: #166534 !important; }
body.light-theme .psc-check-fail { background: #fee2e2 !important; border-color: #fecaca !important; color: #991b1b !important; }
body.light-theme .psc-check-warn { background: #fef9c3 !important; border-color: #fde68a !important; color: #854d0e !important; }
body.light-theme [style*="background:#16532e"], body.light-theme [style*="background:#14532d"] { background: #dcfce7 !important; color: #166534 !important; }
body.light-theme [style*="background:#7f1d1d"], body.light-theme [style*="background:#991b1b"] { background: #fee2e2 !important; color: #991b1b !important; }
body.light-theme [style*="background:#713f12"] { background: #fef9c3 !important; color: #854d0e !important; }
/* Inline dark backgrounds -> white */
body.light-theme [style*="background:#0a1610"] { background: #ffffff !important; border-color: var(--border-solid) !important; }
body.light-theme [style*="background:#060D08"] { background: #f8fafc !important; border-color: var(--border-solid) !important; }
body.light-theme [style*="background:#0c1f17"] { background: #f0fdf4 !important; border-color: #bbf7d0 !important; }
/* Muted text overrides */
body.light-theme [style*="color:rgba(255,255,255,0.6)"] { color: var(--text-secondary) !important; }
body.light-theme [style*="color:rgba(255,255,255,0.95)"] { color: var(--text-primary) !important; }
body.light-theme [style*="color:rgba(255,255,255,0.4)"] { color: var(--text-muted) !important; }
body.light-theme [style*="color:rgba(255,255,255,0.35)"] { color: var(--text-muted) !important; }
body.light-theme [style*="color:#F0F2F4"] { color: var(--text-primary) !important; }
body.light-theme [style*="color:#8B9DAF"] { color: var(--text-secondary) !important; }
body.light-theme [style*="color:#6B7280"] { color: var(--text-muted) !important; }
/* Border overrides */
body.light-theme [style*="border-color:#0d3320"], body.light-theme [style*="border:1px solid #0d3320"] { border-color: var(--border-solid) !important; }
/* ATEM / stream cards */
body.light-theme .grid-4col > div { background: #f8fafc !important; border-color: var(--border-solid) !important; }
/* Broader inline style overrides */
body.light-theme [style*="color:#F0F2F4"], body.light-theme [style*="color: #F0F2F4"] { color: var(--text-primary) !important; }
body.light-theme [style*="color:#B0BEC5"], body.light-theme [style*="color:#b0bec5"] { color: #334155 !important; }
body.light-theme .card, body.light-theme [style*="background:#0a1610"], body.light-theme [style*="background: #0a1610"] { background: #ffffff !important; }
body.light-theme [style*="background:rgba(0,230,118"] { background: rgba(22,163,74,0.08) !important; }
body.light-theme [style*="background:rgba(255,82,82"] { background: #fee2e2 !important; }
body.light-theme [style*="background:rgba(255,183,77"] { background: #fef9c3 !important; }
body.light-theme .badge { font-weight: 700; }
body.light-theme .nav-item svg { opacity: 0.6; }
body.light-theme .nav-item.active svg { opacity: 1; }
body.light-theme table tbody tr:hover { background: #f1f5f9; }
body.light-theme .net-type-filter.active { background: #dcfce7; border-color: #16a34a; color: #166534; }
body.light-theme .net-proto-tag { background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.2); color: #166534; }
body.light-theme [style*="font-family:ui-monospace"] { background: #f1f5f9 !important; color: var(--text-primary) !important; border-color: var(--border-solid) !important; }
body.light-theme ::-webkit-scrollbar-track { background: #f1f5f9; }
body.light-theme ::-webkit-scrollbar-thumb { background: #cbd5e1; }
body.light-theme [style*="border-bottom:1px solid #0d3320"] { border-bottom-color: var(--border-solid) !important; }
body.light-theme #toast {
  background: rgba(255,255,255,0.95);
  border-color: rgba(22,163,74,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

/* ─── NETWORK TOPOLOGY PAGE ───────────────────────────────────── */
.net-type-filter.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}
.net-type-filter { border-radius: 100px; }

.net-empty-icon {
  display: block;
  margin: 0 auto 16px;
  color: var(--text-muted);
  opacity: 0.5;
}
.net-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.net-empty-desc {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

/* Protocol tags */
.net-proto-tag {
  display: inline-block;
  background: rgba(0,230,118,0.08);
  border: 1px solid rgba(0,230,118,0.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--primary);
  margin: 1px;
}

/* Device table */
.net-device-name { font-weight: 600; font-size: 13px; }
.net-device-ip   { font-size: 11px; color: var(--text-muted); }
.net-device-type { font-size: 12px; }
.net-device-model { font-size: 11px; color: var(--text-muted); }
.net-device-vendor { font-size: 12px; color: var(--text-secondary); }
.net-device-seen { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Responsive: hide low-priority columns on small screens */
@media (max-width: 768px) {
  .net-col-vendor,
  .net-col-protocols { display: none; }
}
@media (max-width: 480px) {
  .net-col-seen { display: none; }
}

/* ─── REPORTS PAGE ─────────────────────────────────────────────── */
.reports-range.active, .rpt-win-range.active, .rpt-health-range.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}
.rpt-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rpt-summary-item {
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  transition: border-color var(--duration-fast) ease;
}
.rpt-summary-item:hover { border-color: var(--border-hover); }
.rpt-summary-item .rpt-item-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.rpt-summary-item .rpt-item-value { font-size: 20px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; }
.rpt-context-bar {
  flex: 1;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.rpt-context-bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height 0.5s var(--ease-out);
  min-height: 4px;
}
.rpt-context-bar-fill.pre { background: linear-gradient(180deg, #f97316, #fb923c); }
.rpt-context-bar-fill.in { background: linear-gradient(180deg, var(--danger), #FF8A80); }
.rpt-context-bar-fill.off { background: rgba(255,255,255,0.15); }
.rpt-context-bar-label { font-size: 11px; color: var(--text-secondary); text-align: center; }
.rpt-context-bar-value { font-size: 18px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; }
.rpt-health-card {
  background: rgba(255,255,255,0.025);
  backdrop-filter: var(--glass-blur-sm);
  -webkit-backdrop-filter: var(--glass-blur-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--duration-normal) ease;
}
.rpt-health-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.rpt-health-card .rpt-h-uptime {
  font-size: 30px;
  font-weight: 800;
  min-width: 80px;
  text-align: center;
  letter-spacing: -0.03em;
}
.rpt-health-card .rpt-h-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.rpt-health-card .rpt-h-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.rpt-trend-arrow {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}
.rpt-trend-arrow.improving { color: var(--primary); background: var(--primary-dim); }
.rpt-trend-arrow.declining { color: var(--danger); background: var(--danger-dim); }
.rpt-trend-arrow.stable { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.rpt-device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background var(--duration-fast) ease;
}
.rpt-device-row:hover { background: rgba(255,255,255,0.015); }
.rpt-device-row:last-child { border-bottom: none; }
.rpt-device-row .rpt-d-label { flex: 1; font-size: 13px; font-weight: 600; text-transform: capitalize; }
.rpt-device-row .rpt-d-count { font-size: 13px; color: var(--text-primary); font-weight: 700; min-width: 40px; text-align: right; }
.rpt-device-row .rpt-d-bar { flex: 2; height: 8px; background: rgba(0,0,0,0.25); border-radius: 4px; overflow: hidden; }
.rpt-device-row .rpt-d-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s var(--ease-out); }
.rpt-ai-action-result {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
}
.rpt-ai-action-result.success { background: var(--primary-dim); color: var(--primary); }
.rpt-ai-action-result.failed { background: var(--danger-dim); color: var(--danger); }
@media (max-width: 768px) {
  .rpt-summary-grid { grid-template-columns: 1fr; }
  .rpt-health-card { flex-direction: column; text-align: center; }
  .rpt-device-row { flex-wrap: wrap; }
  .rpt-device-row .rpt-d-bar { flex-basis: 100%; }
}
body.light-theme .rpt-summary-item { background: #f8fafc; border-color: var(--border-solid); }
body.light-theme .rpt-health-card { background: #ffffff; border-color: var(--border-solid); backdrop-filter: none; }
body.light-theme .rpt-device-row .rpt-d-bar { background: #f1f5f9; }

/* ─── AI TRIAGE PAGE ─────────────────────────────────────────────── */
.ai-mode-btn {
  flex: 1;
  min-width: 140px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.15);
  cursor: pointer;
  text-align: left;
  transition: all var(--duration-normal) ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-mode-btn:hover {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.03);
  transform: translateY(-1px);
}
.ai-mode-btn.active {
  border-color: var(--primary);
  background: rgba(0,230,118,0.06);
  box-shadow: 0 0 24px rgba(0,230,118,0.1), inset 0 1px 0 rgba(0,230,118,0.1);
}
.ai-mode-icon { font-size: 22px; }
.ai-mode-label { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.ai-mode-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }
.ai-mode-btn.active .ai-mode-label { color: var(--primary); }

.severity-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.severity-badge.critical { background: rgba(255,82,82,0.12); color: var(--danger); }
.severity-badge.high { background: rgba(249,115,22,0.12); color: #f97316; }
.severity-badge.medium { background: var(--warning-dim); color: var(--warning); }
.severity-badge.low { background: rgba(100,181,246,0.12); color: var(--info); }
.severity-badge.info { background: rgba(255,255,255,0.04); color: var(--text-secondary); }

.context-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 700;
}
.context-badge.pre_service { background: rgba(249,115,22,0.12); color: #f97316; }
.context-badge.in_service { background: rgba(255,82,82,0.12); color: var(--danger); }
.context-badge.off_hours { background: rgba(255,255,255,0.04); color: var(--text-secondary); }

.window-bar {
  height: 36px;
  border-radius: var(--radius-sm);
  position: relative;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.window-segment {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: var(--radius-xs);
  transition: all 0.4s var(--ease-out);
}
.window-segment.pre { background: rgba(249,115,22,0.2); }
.window-segment.service { background: rgba(0,230,118,0.2); }
.window-segment.post { background: rgba(100,181,246,0.12); }
.window-now-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  z-index: 2;
  box-shadow: 0 0 6px rgba(255,255,255,0.3);
}

/* Triage chart bars */
.triage-bar {
  flex: 1;
  min-width: 12px;
  border-radius: 4px 4px 0 0;
  transition: height 0.5s var(--ease-out);
  cursor: default;
}
.triage-bar:hover { opacity: 0.85; }

@keyframes triagePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.triage-pulse { animation: triagePulse 2s ease-in-out infinite; }

body.light-theme .ai-mode-btn { background: #f8fafc; border-color: var(--border-solid); }
body.light-theme .ai-mode-btn:hover { border-color: rgba(22,163,74,0.4); background: #f1f5f9; }
body.light-theme .ai-mode-btn.active { background: #f0fdf4; border-color: var(--primary); }
body.light-theme .ai-mode-desc { color: var(--text-secondary); }
body.light-theme .window-bar { background: #f8fafc; border-color: var(--border-solid); }

/* ─── CONNECTION BADGES ──────────────────────────────────────────── */
.conn-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 4px 12px;
  border-radius: 9999px; white-space: nowrap;
}
.conn-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
}
.conn-badge-on {
  background: rgba(0,230,118,0.08);
  color: var(--primary);
  border: 1px solid rgba(0,230,118,0.2);
}
.conn-badge-on::before { background: var(--primary); box-shadow: 0 0 6px var(--primary); }
.conn-badge-off {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
}
.conn-badge-off::before { background: rgba(255,255,255,0.3); }
.conn-badge-warn {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(255,183,77,0.2);
}
.conn-badge-warn::before { background: var(--warning); }
body.light-theme .conn-badge-on { background: #f0fdf4; color: #16a34a; border-color: #86efac; }
body.light-theme .conn-badge-off { background: #f1f5f9; color: #94a3b8; border-color: var(--border-solid); }
body.light-theme .conn-badge-warn { background: #fffbeb; color: #d97706; border-color: #fde68a; }

/* ═══════════════════════════════════════════════════════════════════
   UX Overhaul — Simple/Advanced Mode, Readiness, Navigation
   ═══════════════════════════════════════════════════════════════════ */

/* ─── NAV: More toggle ────────────────────────────────────────── */
.nav-more-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  transition: all var(--duration-fast) ease;
  border-radius: var(--radius-xs);
}
.nav-more-toggle:hover { color: var(--text-secondary); background: rgba(255,255,255,0.03); }
.nav-more-chevron {
  margin-left: auto;
  transition: transform 0.25s var(--ease-out);
  flex-shrink: 0;
}
.nav-more-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-out);
}
.nav-more-items.open {
  max-height: 500px;
}
.nav-more-items .nav-item {
  padding-left: 28px;
  font-size: 12px;
}
.nav-more-toggle.open .nav-more-chevron {
  transform: rotate(180deg);
}
/* Auto-expand More when a child page is active */
.nav-more-items .nav-item.active { background: var(--primary-dim); color: var(--primary); }

/* ─── VIEW MODE TOGGLE ────────────────────────────────────────── */
.view-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px 4px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}
.view-mode-toggle:hover { border-color: var(--border-hover); color: var(--primary); }
.sidebar-view-mode-toggle {
  width: 100%;
  border-radius: var(--radius-xs);
  padding: 8px 14px;
  margin-bottom: 8px;
  justify-content: space-between;
}
.view-mode-switch {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: rgba(255,255,255,0.08);
  position: relative;
  transition: background 0.2s ease;
}
.view-mode-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.2s var(--ease-spring);
}
body.advanced-mode .view-mode-switch { background: rgba(0,230,118,0.2); }
body.advanced-mode .view-mode-knob { background: var(--primary); transform: translateX(14px); box-shadow: 0 0 6px rgba(0,230,118,0.4); }

/* ─── SIMPLE / ADVANCED VISIBILITY ────────────────────────────── */
.simple-only { display: block; }
.advanced-only { display: none; }
body.advanced-mode .simple-only { display: none; }
body.advanced-mode .advanced-only { display: block; }
/* Preserve display:none on cards that use it for conditional visibility */
body.advanced-mode .advanced-only[style*="display:none"] { display: none !important; }
/* Table-cell variants for thead/tbody columns */
th.advanced-only, td.advanced-only { display: none; }
body.advanced-mode th.advanced-only, body.advanced-mode td.advanced-only { display: table-cell; }
/* Flex variants */
.advanced-only-flex { display: none; }
body.advanced-mode .advanced-only-flex { display: flex; }

/* ─── EQUIPMENT SIMPLE SUMMARY (Rooms & Equipment tab) ───────── */
.eq-summary-list { display: flex; flex-direction: column; gap: 6px; }
.eq-summary-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) ease;
}
.eq-summary-row:hover {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}
.eq-summary-icon { flex: 0 0 28px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.eq-summary-icon svg { width: 18px; height: 18px; }
.eq-summary-info { flex: 1; min-width: 0; }
.eq-summary-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.eq-summary-detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.eq-summary-status { font-size: 12px; font-weight: 600; white-space: nowrap; }
.eq-summary-status.configured { color: var(--primary); }
.eq-summary-status.not-configured { color: var(--text-muted); }

/* ─── READINESS HERO ──────────────────────────────────────────── */
.readiness-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px 30px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  background: rgba(0,230,118,0.04);
  border: 1px solid rgba(0,230,118,0.12);
  transition: all var(--duration-slow) ease;
  position: relative;
  overflow: hidden;
}
.readiness-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,230,118,0.3), transparent);
}
.readiness-hero.ready {
  background: rgba(0,230,118,0.04);
  border-color: rgba(0,230,118,0.15);
}
.readiness-hero.warning {
  background: rgba(255,183,77,0.04);
  border-color: rgba(255,183,77,0.15);
}
.readiness-hero.warning::before {
  background: linear-gradient(90deg, transparent, rgba(255,183,77,0.3), transparent);
}
.readiness-hero.error {
  background: rgba(255,82,82,0.04);
  border-color: rgba(255,82,82,0.15);
}
.readiness-hero.error::before {
  background: linear-gradient(90deg, transparent, rgba(255,82,82,0.3), transparent);
}
.readiness-hero.offline {
  background: rgba(255,255,255,0.02);
  border-color: var(--border);
}
.readiness-hero.offline::before { opacity: 0; }
.readiness-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(0,230,118,0.1);
  color: var(--primary);
  box-shadow: 0 0 20px rgba(0,230,118,0.1);
}
.readiness-hero.warning .readiness-icon { background: rgba(255,183,77,0.12); color: var(--warning); box-shadow: 0 0 20px rgba(255,183,77,0.1); }
.readiness-hero.error .readiness-icon { background: rgba(255,82,82,0.12); color: var(--danger); box-shadow: 0 0 20px rgba(255,82,82,0.1); }
.readiness-hero.offline .readiness-icon { background: rgba(255,255,255,0.05); color: var(--text-muted); box-shadow: none; }
.readiness-text { flex: 1; }
.readiness-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.readiness-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.readiness-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ─── NEEDS ATTENTION ─────────────────────────────────────────── */
.needs-attention {
  background: rgba(255,183,77,0.04);
  border: 1px solid rgba(255,183,77,0.12);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
}
.needs-attention-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--warning);
  margin-bottom: 12px;
}
.needs-attention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,183,77,0.06);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--duration-fast) ease;
}
.needs-attention-item:last-child { border-bottom: none; }
.needs-attention-item .na-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.needs-attention-item .na-dot.warn { background: var(--warning); box-shadow: 0 0 4px rgba(255,183,77,0.4); }
.needs-attention-item .na-dot.error { background: var(--danger); box-shadow: 0 0 4px rgba(255,82,82,0.4); }

/* ─── SIMPLIFIED EQUIPMENT LIST ───────────────────────────────── */
.equip-simple-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.equip-simple-row:last-child { border-bottom: none; }
.equip-simple-row:hover {
  background: rgba(255,255,255,0.025);
  margin: 0 -14px;
  padding: 14px 14px;
  border-radius: var(--radius-sm);
}
.equip-simple-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.equip-simple-info {
  flex: 1;
  min-width: 0;
}
.equip-simple-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.equip-simple-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.equip-simple-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.equip-simple-status .es-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.equip-simple-status.ready .es-dot { background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.equip-simple-status.ready { color: var(--primary); }
.equip-simple-status.warning .es-dot { background: var(--warning); box-shadow: 0 0 6px rgba(255,183,77,0.5); }
.equip-simple-status.warning { color: var(--warning); }
.equip-simple-status.error .es-dot { background: var(--danger); box-shadow: 0 0 6px rgba(255,82,82,0.5); }
.equip-simple-status.error { color: var(--danger); }
.equip-simple-status.off .es-dot { background: var(--text-muted); }
.equip-simple-status.off { color: var(--text-muted); }
.equip-simple-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s var(--ease-out), padding 0.25s var(--ease-out);
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 0 0 54px;
}
.equip-simple-detail.open {
  max-height: 120px;
  padding: 8px 0 10px 54px;
}
.equip-simple-chevron {
  color: var(--text-muted);
  transition: transform 0.2s var(--ease-out);
  flex-shrink: 0;
}
.equip-simple-row.expanded .equip-simple-chevron {
  transform: rotate(90deg);
}

/* Empty state for equipment */
.equip-empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}
.equip-empty-state svg { color: var(--primary); margin-bottom: 10px; }

/* ─── LIGHT THEME OVERRIDES ───────────────────────────────────── */
body.light-theme .readiness-hero { background: #f0fdf4; border-color: #bbf7d0; }
body.light-theme .readiness-hero::before { background: linear-gradient(90deg, transparent, rgba(22,163,74,0.2), transparent); }
body.light-theme .readiness-hero.warning { background: #fffbeb; border-color: #fde68a; }
body.light-theme .readiness-hero.warning::before { background: linear-gradient(90deg, transparent, rgba(217,119,6,0.2), transparent); }
body.light-theme .readiness-hero.error { background: #fef2f2; border-color: #fecaca; }
body.light-theme .readiness-hero.error::before { background: linear-gradient(90deg, transparent, rgba(220,38,38,0.2), transparent); }
body.light-theme .readiness-hero.offline { background: #f8fafc; border-color: var(--border-solid); }
body.light-theme .readiness-icon { background: #dcfce7; box-shadow: none; }
body.light-theme .readiness-hero.warning .readiness-icon { background: #fef3c7; box-shadow: none; }
body.light-theme .readiness-hero.error .readiness-icon { background: #fee2e2; box-shadow: none; }
body.light-theme .needs-attention { background: #fffbeb; border-color: #fde68a; }
body.light-theme .equip-simple-icon { background: #f1f5f9; border-color: var(--border-solid); }
body.light-theme .equip-simple-row:hover { background: #f8fafc; }
body.light-theme .view-mode-toggle { background: #f1f5f9; border-color: var(--border-solid); }
body.light-theme .nav-more-toggle { color: var(--text-muted); }
body.light-theme .nav-more-items .nav-item { color: var(--text-secondary); }

@media (max-width: 768px) {
  .readiness-hero { padding: 18px 20px; gap: 14px; }
  .readiness-icon { width: 46px; height: 46px; }
  .readiness-icon svg { width: 24px; height: 24px; }
  .readiness-title { font-size: 18px; }
  .equip-simple-row { gap: 10px; }
  .view-mode-toggle { font-size: 11px; padding: 3px 10px 3px 12px; }
}

/* ─── OVERVIEW SECTIONS: Collapse + Drag-and-Drop ────────────────────────── */
.section-body {
  overflow: hidden;
  max-height: 3000px;
  transition: max-height 0.4s var(--ease-out), opacity 0.3s ease;
  opacity: 1;
}
.section-collapsed .section-body {
  max-height: 0 !important;
  opacity: 0;
}
.section-collapsed > :first-child {
  margin-bottom: 0 !important;
}

.section-drag-handle {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  opacity: 0.25;
  cursor: grab;
  padding: 2px 8px 2px 0;
  flex-shrink: 0;
  transition: opacity var(--duration-fast) ease;
  touch-action: none;
}
.section-drag-handle:hover { opacity: 0.6; }
.section-drag-handle:active { cursor: grabbing; opacity: 1; }

.section-chevron {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding-left: 10px;
  color: var(--text-secondary);
  opacity: 0.35;
  transition: transform 0.3s var(--ease-out), opacity var(--duration-fast) ease;
  flex-shrink: 0;
  pointer-events: none;
}
.section-collapsed .section-chevron {
  transform: rotate(-90deg);
  opacity: 0.6;
}

.section-header-row {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.section-header-row:hover .section-drag-handle { opacity: 0.5; }
.section-header-row:hover .section-chevron { opacity: 0.6; }

.section-dragging {
  opacity: 0.4;
  cursor: grabbing !important;
}
.section-drag-over {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(0,230,118,0.2), var(--shadow-lg) !important;
}
.section-drag-placeholder {
  border: 2px dashed rgba(0,230,118,0.3);
  border-radius: var(--radius);
  background: rgba(0,230,118,0.03);
  margin-bottom: 20px;
  pointer-events: none;
}

body.light-theme .section-drag-handle { color: var(--text-muted); }
body.light-theme .section-chevron { color: var(--text-muted); }
body.light-theme .section-drag-over { border-color: rgba(22,163,74,0.5) !important; box-shadow: 0 0 0 2px rgba(22,163,74,0.15) !important; }
body.light-theme .section-drag-placeholder { border-color: rgba(22,163,74,0.3); background: rgba(22,163,74,0.03); }

/* ── Live Show Mode ─────────────────────────────────────────────────────── */

.live-show-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  transition: all var(--duration-normal) ease;
}
.live-show-status,
.live-show-actions {
  display: flex;
  align-items: center;
}
.live-show-status { gap: 12px; }
.live-show-actions { gap: 8px; }
.live-show-elapsed {
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
  font-size: 14px;
  color: #F0F2F4;
  font-weight: 600;
}

.live-show-bar--active {
  background: rgba(0,230,118,0.03);
  border: 1px solid rgba(0,230,118,0.15);
  box-shadow: 0 0 24px rgba(0,230,118,0.05), inset 0 1px 0 rgba(0,230,118,0.08);
}

.live-badge-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #EF4444, #DC2626);
  animation: livePulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(239,68,68,0.3);
}

@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(239,68,68,0.3); }
  50% { opacity: 0.8; box-shadow: 0 0 20px rgba(239,68,68,0.6); }
}

/* ── GO BUTTON — The star of the show ── */
.btn-live-go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 36px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  color: #050a07;
  background: linear-gradient(135deg, #00E676 0%, #00C853 50%, #00E676 100%);
  background-size: 200% 200%;
  transition: all var(--duration-normal) ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  box-shadow:
    0 0 20px rgba(0,230,118,0.3),
    0 0 40px rgba(0,230,118,0.15),
    0 4px 12px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-live-go::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(255,255,255,0.3), transparent 30%);
  animation: goButtonSpin 3s linear infinite;
  opacity: 0;
  transition: opacity var(--duration-normal) ease;
}
.btn-live-go:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 0 30px rgba(0,230,118,0.4),
    0 0 60px rgba(0,230,118,0.2),
    0 8px 24px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.3);
  background-position: 100% 100%;
}
.btn-live-go:hover::before { opacity: 1; }
.btn-live-go:active {
  transform: translateY(0) scale(0.98);
  box-shadow:
    0 0 20px rgba(0,230,118,0.3),
    0 2px 8px rgba(0,0,0,0.3);
}
@keyframes goButtonSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-live-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  transition: all var(--duration-fast) ease;
}
.btn-live-back:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }

.btn-live-end {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid rgba(255,82,82,0.2);
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--danger);
  background: rgba(255,82,82,0.04);
  transition: all var(--duration-fast) ease;
}
.btn-live-end:hover { background: rgba(255,82,82,0.1); border-color: rgba(255,82,82,0.4); }

/* Pause button */
.btn-live-pause {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm, 10px);
  border: 1px solid rgba(255,183,77,0.25);
  background: rgba(255,183,77,0.06);
  color: #FFB74D;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.btn-live-pause:hover { background: rgba(255,183,77,0.12); border-color: rgba(255,183,77,0.4); }
.btn-live-pause.is-paused {
  background: linear-gradient(135deg, #FFB74D 0%, #FFA726 100%);
  color: #1a1a2e;
  border-color: #FFB74D;
  box-shadow: 0 0 16px rgba(255,183,77,0.3);
}
.btn-live-pause svg { width: 14px; height: 14px; }

/* Phone: the caller bar is a fixed thumb target, not a row buried in the list. */
@media (max-width: 768px) {
  #rundown-live-bar.is-live {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    margin: 0 !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(8, 14, 10, 0.96);
    border-top: 1px solid rgba(0, 230, 118, 0.28);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.45);
  }
  #rundown-live-bar.is-live .live-show-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  #rundown-live-bar.is-live .live-show-actions {
    flex-wrap: wrap;
  }
  #rundown-live-bar.is-live .btn-live-go {
    order: -1;
    flex: 1 1 100%;
    min-height: 56px;
    justify-content: center;
    font-size: 22px;
    padding: 14px 20px;
  }
  #rundown-live-bar.is-live .btn-live-back,
  #rundown-live-bar.is-live .btn-live-pause,
  #rundown-live-bar.is-live .btn-live-end {
    flex: 1 1 30%;
    min-height: 48px;
    justify-content: center;
    font-size: 15px;
  }
  .rundown-editor-main:has(#rundown-live-bar.is-live) {
    padding-bottom: 148px;
  }
}

/* Active cue row glow */
.live-cue-active {
  box-shadow: inset 0 0 30px rgba(0,230,118,0.05);
  position: relative;
}
.live-cue-active::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #00E676, #00C853);
  box-shadow: 0 0 12px rgba(0,230,118,0.5);
  border-radius: 0 2px 2px 0;
}

/* ─── RUNDOWN DASHBOARD ──────────────────────────────────────────────────────── */

/* Filter bar */
.rundown-filter-bar { position: relative; }
.rundown-search-wrap { position: relative; }
.rundown-search-wrap input:focus { border-color: rgba(0,230,118,0.4); }

/* Status group header */
.rundown-status-group-header {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0 4px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rundown-status-group-header .rundown-group-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Dashboard card grid */
.rundown-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

/* Individual rundown card */
.rundown-dash-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.rundown-dash-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  transition: background var(--duration-normal) ease;
}
.rundown-dash-card:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(-2px);
}
.rundown-dash-card:hover::before {
  background: linear-gradient(90deg, transparent, rgba(0,230,118,0.15), transparent);
}
.rundown-dash-card.is-live {
  border-color: rgba(239,68,68,0.3);
  box-shadow: 0 0 16px rgba(239,68,68,0.08);
}
.rundown-dash-card .card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.rundown-dash-card .card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rundown-dash-card .card-meta span {
  white-space: nowrap;
}
.rundown-dash-card .card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) ease;
}
.rundown-dash-card:hover .card-actions {
  opacity: 1;
  pointer-events: auto;
}
.rundown-dash-card .card-actions button {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.rundown-dash-card .card-actions button:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.15);
}
.rundown-dash-card .card-actions button.action-delete:hover {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(255,82,82,0.2);
}

/* Active editors badge on card */
.rundown-editors-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-dim);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

/* Status badges */
.rundown-status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  line-height: 1.4;
}
.rundown-status-badge.status-draft { background: rgba(85,98,112,0.15); color: var(--text-secondary); }
.rundown-status-badge.status-rehearsal { background: rgba(255,167,38,0.12); color: #FFA726; }
.rundown-status-badge.status-show_ready { background: rgba(0,230,118,0.1); color: var(--primary); }
.rundown-status-badge.status-live { background: rgba(239,68,68,0.12); color: #EF4444; animation: rundown-pulse 1.5s ease-in-out infinite; }
.rundown-status-badge.status-archived { background: rgba(85,98,112,0.08); color: var(--text-muted); }

/* 12.2: Save status indicator */
#rundown-save-status[data-state="saving"] { color: var(--text-secondary); }
#rundown-save-status[data-state="saved"] { color: var(--primary); }
#rundown-save-status[data-state="queued"] { color: var(--warning); }

@keyframes rundown-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ─── FULL-SCREEN EDITOR ─────────────────────────────────────────────────────── */

/* Dashboard / editor transition */
#rundown-manager {
  animation: rundownFadeIn 0.25s var(--ease-out);
}
.rundown-fullscreen-editor {
  animation: rundownFadeIn 0.25s var(--ease-out);
}
@keyframes rundownFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Editor top bar */
.rundown-editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.rundown-editor-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.rundown-editor-topbar-title {
  min-width: 0;
  flex: 1;
}
.rundown-editor-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.rundown-back-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rundown-back-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

/* Editor body: main + optional sidebar */
.rundown-editor-body {
  display: flex;
  gap: 0;
  min-height: 0;
}
.rundown-editor-main {
  flex: 1;
  min-width: 0;
}

/* Toolbar card in editor */
.rundown-editor-toolbar-card {
  position: relative;
  z-index: 1;
}

/* ─── Team sidebar ───────────────────────────────────────────────────────────── */
.rundown-team-sidebar {
  width: 280px;
  flex-shrink: 0;
  margin-left: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  align-self: flex-start;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  animation: teamSlideIn 0.2s var(--ease-out);
}
@keyframes teamSlideIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.rundown-team-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.rundown-team-sidebar-close {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: color var(--duration-fast) ease;
}
.rundown-team-sidebar-close:hover {
  color: var(--text-primary);
}
.rundown-team-share-block {
  margin-bottom: 16px;
}
.rundown-team-section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.rundown-team-members {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rundown-team-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  transition: background var(--duration-fast) ease;
}
.rundown-team-member:hover {
  background: rgba(255,255,255,0.04);
}
.rundown-team-member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.rundown-team-member-avatar .online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00E676;
  border: 2px solid var(--bg-base);
}
.rundown-team-member-avatar .offline-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--bg-base);
  opacity: 0.5;
}
.rundown-team-member-info {
  min-width: 0;
  flex: 1;
}
.rundown-team-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rundown-team-member-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 1px;
}
.rundown-team-device-info {
  padding: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
  .rundown-team-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid var(--border);
    z-index: 200;
    background: var(--bg-base);
  }
  .rundown-editor-topbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .rundown-editor-topbar-actions {
    flex-wrap: wrap;
  }
}

/* Presence bar in editor */
#rundown-presence-bar {
  display: none;
}
#rundown-presence-bar.has-editors {
  display: flex !important;
}
.presence-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  margin-right: -6px;
  border: 2px solid var(--bg-base);
  flex-shrink: 0;
}

/* Collaborative edit flash */
@keyframes rundown-cell-flash {
  0% { background: rgba(0,230,118,0.2); }
  100% { background: transparent; }
}
.rundown-cell-flash {
  animation: rundown-cell-flash 1s ease-out;
}

.rundown-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.rundown-editor-toolbar-card .rundown-toolbar {
  padding-top: 0;
  border-top: none;
}
.rundown-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* toolbar-primary-mobile is only visible on mobile when toolbar-secondary is hidden */
.rundown-toolbar-group.toolbar-primary-mobile {
  display: none;
}
.rundown-toolbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.06);
  margin: 0 4px;
  flex-shrink: 0;
}
/* ── 3.2 Overflow menu for toolbar on mobile ── */
.rundown-toolbar-overflow {
  position: relative;
  display: none;
}
.rundown-toolbar-overflow-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  letter-spacing: 1px;
  transition: all var(--duration-fast) ease;
}
.rundown-toolbar-overflow-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.rundown-toolbar-overflow-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 200px;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(12,22,16,0.97);
  backdrop-filter: var(--glass-blur) saturate(1.3);
  -webkit-backdrop-filter: var(--glass-blur) saturate(1.3);
  box-shadow: var(--shadow-lg);
}
.rundown-toolbar-overflow-menu.open { display: flex; }
.rundown-toolbar-overflow-menu button,
.rundown-toolbar-overflow-menu select {
  width: 100%;
  text-align: left;
}
.rundown-toolbar-overflow-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  display: none;
}
.rundown-toolbar-overflow-backdrop.open { display: block; }

@media (max-width: 768px) {
  .rundown-toolbar {
    gap: 8px;
  }
  .rundown-toolbar-group {
    flex-wrap: wrap;
    gap: 6px;
  }
  .rundown-toolbar-divider {
    display: none;
  }
  /* 3.2: Hide secondary toolbar groups, show primary-mobile + overflow */
  .rundown-toolbar-group.toolbar-primary-mobile { display: flex !important; }
  .rundown-toolbar-group.toolbar-secondary { display: none !important; }
  .rundown-toolbar-overflow { display: block; }

  /* ── Mobile stacking fix ──
     backdrop-filter on .card creates a new stacking context; later sibling
     cards paint over the toolbar card's absolutely-positioned overflow menu.
     Give the toolbar card explicit z-index so its overflow menu appears above
     the timing bar and items cards beneath it. */
  .card:has(.rundown-toolbar) {
    position: relative;
    z-index: 1;
  }

  /* Disable the hover-lift transform on mobile — iOS fires :hover on tap,
     causing transform: translateY(-1px) to create a stacking context that
     makes the toolbar card render behind subsequent sibling cards. */
  .card:hover {
    transform: none;
  }

  /* Timing bar: allow the Start Time / Target End row to wrap on narrow
     screens so it doesn't overflow and visually collide with items below. */
  #rundown-start-time,
  #rundown-end-time {
    flex-shrink: 1;
    min-width: 90px;
  }
  #rundown-over-under {
    min-width: auto;
  }
}

/* ── 3.1 Mobile card layout for rundown editor items ── */
.rundown-mobile-card {
  display: none;
}
@media (max-width: 768px) {
  .rundown-mobile-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  #rundown-editor-items table { display: none; }
  .rundown-mobile-card-item {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    border-left: 3px solid rgba(255,255,255,0.1);
  }
  .rundown-mobile-card-item.is-section {
    background: rgba(255,255,255,0.035);
    border-left-color: var(--text-secondary);
    padding: 10px 14px;
  }
  .rundown-mobile-card-item.is-section .mobile-card-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
  }
  .rundown-mobile-card-item.is-current {
    background: rgba(0,230,118,0.06);
    border-left-color: var(--primary);
    box-shadow: 0 0 16px rgba(0,230,118,0.05);
  }
  .rundown-mobile-card-item.is-past { opacity: 0.4; }
  .mobile-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .mobile-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    cursor: text;
  }
  .mobile-card-duration {
    font-family: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    cursor: text;
  }
  .mobile-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
  }
  .mobile-card-type-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255,255,255,0.05);
    display: inline-block;
  }
  .mobile-card-assignee {
    font-size: 12px;
    color: var(--text-secondary);
  }
  .mobile-card-expand {
    appearance: none;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 0;
    margin-left: auto;
  }
  .mobile-card-details {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
  }
  .mobile-card-details.expanded { display: block; }
  .mobile-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
  }
}

/* 4.5: Rundown Simple Mode — hide advanced features when not in advanced mode */
body:not(.advanced-mode) .rundown-adv { display: none !important; }

/* Light theme overrides */
body.light-theme .rundown-dash-card { background: rgba(0,0,0,0.015); border-color: var(--border-solid); }
body.light-theme .rundown-dash-card:hover { background: rgba(0,0,0,0.03); border-color: rgba(22,163,74,0.2); box-shadow: var(--shadow-md); }
body.light-theme .rundown-dash-card::before { background: linear-gradient(90deg, transparent, rgba(0,0,0,0.03), transparent); }
body.light-theme .rundown-dash-card:hover::before { background: linear-gradient(90deg, transparent, rgba(22,163,74,0.1), transparent); }
body.light-theme .rundown-dash-card .card-title { color: #1a1a2e; }
body.light-theme .rundown-dash-card .card-meta { color: #6b7280; }
body.light-theme .rundown-status-badge.status-draft { background: rgba(107,114,128,0.1); color: #6b7280; }
body.light-theme .rundown-status-badge.status-rehearsal { background: rgba(245,158,11,0.1); color: #d97706; }
body.light-theme .rundown-status-badge.status-show_ready { background: rgba(22,163,74,0.08); color: #16a34a; }
body.light-theme .rundown-status-badge.status-live { background: rgba(220,38,38,0.08); color: #dc2626; }
body.light-theme .rundown-status-badge.status-archived { background: rgba(107,114,128,0.06); color: #9ca3af; }
body.light-theme .presence-avatar { border-color: #fff; }
body.light-theme #rundown-presence-bar.has-editors { background: rgba(22,163,74,0.04); border-color: rgba(22,163,74,0.12); }

/* ── Phase 1 v3: Color coding, Section headers, Duration picker, Empty state, Templates, UI polish ── */

/* Color stripe on item rows */
.rundown-color-stripe {
  width: 4px;
  border-radius: 2px;
  min-height: 28px;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

/* Color picker popup */
.rundown-color-picker {
  position: absolute;
  z-index: 60;
  background: rgba(12,22,16,0.97);
  backdrop-filter: var(--glass-blur) saturate(1.3);
  -webkit-backdrop-filter: var(--glass-blur) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-lg);
  display: none;
  width: 220px;
}
.rundown-color-picker.open { display: block; animation: modalSlideIn 0.15s var(--ease-out); }
.rundown-color-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.rundown-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s var(--ease-spring), border-color 0.15s ease;
  position: relative;
}
.rundown-color-swatch:hover { transform: scale(1.15); }
.rundown-color-swatch.active { border-color: #fff; }
.rundown-color-swatch-label {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1px;
  line-height: 1.1;
}
.rundown-color-custom-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.rundown-color-custom-row input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  background: none;
}
.rundown-color-custom-row input[type="text"] {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
}
.rundown-color-clear {
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: none;
  border: none;
  transition: all var(--duration-fast) ease;
}
.rundown-color-clear:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

/* Section headers v3: collapsible, color band, item count */
.rundown-section-header {
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast) ease;
}
.rundown-section-header:hover { background: rgba(255,255,255,0.04); }
.rundown-section-chevron {
  display: inline-flex;
  transition: transform 0.25s var(--ease-out);
  color: var(--text-secondary);
}
.rundown-section-chevron.collapsed { transform: rotate(-90deg); }
.rundown-section-meta {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  margin-left: 8px;
}
.rundown-section-collapsed { display: none; }

/* Inline duration picker popup */
.rundown-duration-picker {
  position: absolute;
  z-index: 60;
  background: rgba(12,22,16,0.97);
  backdrop-filter: var(--glass-blur) saturate(1.3);
  -webkit-backdrop-filter: var(--glass-blur) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-lg);
  display: none;
  width: 240px;
}
.rundown-duration-picker.open { display: block; animation: modalSlideIn 0.15s var(--ease-out); }
.rundown-duration-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.rundown-duration-preset {
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xs);
  cursor: pointer;
  text-align: center;
  transition: all var(--duration-fast) ease;
  font-family: ui-monospace, monospace;
}
.rundown-duration-preset:hover { background: var(--primary-dim); border-color: rgba(0,230,118,0.2); }
.rundown-duration-preset.active { background: rgba(0,230,118,0.12); border-color: rgba(0,230,118,0.35); color: var(--primary); }
.rundown-duration-manual {
  display: flex;
  gap: 6px;
  align-items: center;
}
.rundown-duration-manual input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
  text-align: center;
}
.rundown-duration-manual input:focus { border-color: rgba(0,230,118,0.4); outline: none; }

/* Empty state onboarding card */
.rundown-empty-state {
  text-align: center;
  padding: 72px 24px;
  max-width: 560px;
  margin: 0 auto;
}
.rundown-empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: rgba(0,230,118,0.08);
  border: 1px solid rgba(0,230,118,0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.rundown-empty-icon svg { width: 36px; height: 36px; color: var(--primary); }
.rundown-empty-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}
.rundown-empty-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}
.rundown-empty-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: linear-gradient(135deg, #00E676 0%, #00C853 100%);
  color: #050a07;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  margin-bottom: 36px;
  box-shadow: 0 0 20px rgba(0,230,118,0.2), 0 4px 12px rgba(0,0,0,0.3);
}
.rundown-empty-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(0,230,118,0.3), 0 8px 24px rgba(0,0,0,0.4);
}
.rundown-empty-cta svg { width: 20px; height: 20px; }
.rundown-empty-cta.rundown-empty-cta-secondary {
  background: rgba(255,255,255,0.08);
  color: #F0F2F4;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), inset 0 0 0 1px rgba(255,255,255,0.1);
}
.rundown-empty-cta.rundown-empty-cta-secondary:hover {
  background: rgba(255,255,255,0.12);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.15);
}

/* Template cards */
.rundown-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  text-align: left;
  margin-top: 12px;
}
.rundown-template-card {
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--duration-normal) ease;
}
.rundown-template-card:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.rundown-template-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.rundown-template-card-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.rundown-template-card-items {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.rundown-template-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-weight: 700;
}
.rundown-template-section-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Service total duration in toolbar */
.rundown-total-duration {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  padding: 5px 12px;
  background: var(--primary-dim);
  border: 1px solid rgba(0,230,118,0.12);
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

/* UI polish: better row spacing and hover */
#rundown-editor-items table tbody tr {
  transition: background var(--duration-fast) ease, opacity var(--duration-fast) ease;
}
#rundown-editor-items table tbody tr[draggable="true"] {
  margin-bottom: 2px;
}

/* Drag-and-drop smooth transitions */
#rundown-editor-items table tbody tr.dragging {
  opacity: 0.4;
  transform: scale(0.98);
}
#rundown-editor-items table tbody tr.drag-over {
  border-top: 2px solid var(--primary);
}

/* Light theme overrides for new v3 elements */
body.light-theme .rundown-color-picker { background: rgba(255,255,255,0.97); border-color: var(--border-solid); backdrop-filter: blur(20px); }
body.light-theme .rundown-color-custom-row input[type="text"] { background: #f5f5f5; border-color: rgba(0,0,0,0.1); color: #1a1a2e; }
body.light-theme .rundown-duration-picker { background: rgba(255,255,255,0.97); border-color: var(--border-solid); backdrop-filter: blur(20px); }
body.light-theme .rundown-duration-preset { background: #f5f5f5; border-color: rgba(0,0,0,0.06); color: #1a1a2e; }
body.light-theme .rundown-duration-preset:hover { background: rgba(22,163,74,0.06); border-color: rgba(22,163,74,0.15); }
body.light-theme .rundown-duration-manual input { background: #f5f5f5; border-color: rgba(0,0,0,0.08); color: #1a1a2e; }
body.light-theme .rundown-empty-title { color: #1a1a2e; }
body.light-theme .rundown-empty-subtitle { color: #6b7280; }
body.light-theme .rundown-empty-cta { background: linear-gradient(135deg, #16a34a, #15803d); box-shadow: 0 2px 8px rgba(22,163,74,0.2); }
body.light-theme .rundown-empty-cta.rundown-empty-cta-secondary { background: rgba(0,0,0,0.04); color: #1a1a2e; box-shadow: 0 1px 4px rgba(0,0,0,0.08), inset 0 0 0 1px rgba(0,0,0,0.1); }
body.light-theme .rundown-empty-cta.rundown-empty-cta-secondary:hover { background: rgba(0,0,0,0.07); box-shadow: 0 2px 8px rgba(0,0,0,0.12), inset 0 0 0 1px rgba(0,0,0,0.15); }
body.light-theme .rundown-template-card { background: rgba(0,0,0,0.015); border-color: var(--border-solid); }
body.light-theme .rundown-template-card:hover { background: rgba(0,0,0,0.03); border-color: rgba(22,163,74,0.2); }
body.light-theme .rundown-template-card-title { color: #1a1a2e; }
body.light-theme .rundown-total-duration { background: rgba(22,163,74,0.05); color: #16a34a; border-color: rgba(22,163,74,0.12); }

/* ═══════════════════════════════════════════════════════════════════════════
   Phase 11 (v3): Workflow Power Features
   ═══════════════════════════════════════════════════════════════════════════ */

/* Selected row highlight */
.rundown-selected-row { outline: 1px solid rgba(66,165,245,0.3); outline-offset: -1px; background: rgba(66,165,245,0.03) !important; }

/* Context menu */
#rundown-ctx-menu div:hover { background: rgba(255,255,255,0.05); }

/* Checklist panel */
.checklist-panel { animation: fadeSlideIn 0.15s var(--ease-out); }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.checklist-item:hover .checklist-delete { opacity: 1; }
.checklist-delete { opacity: 0; transition: opacity var(--duration-fast) ease; }

/* Undo/Redo disabled state */
#btn-rundown-undo:disabled, #btn-rundown-redo:disabled { opacity: 0.3; cursor: default; pointer-events: none; }

/* Export menu hover */
.rundown-export-menu > div:hover { background: rgba(255,255,255,0.05) !important; }

/* Light theme overrides */
body.light-theme .rundown-selected-row { outline-color: rgba(66,165,245,0.35); background: rgba(66,165,245,0.05) !important; }
body.light-theme #rundown-ctx-menu { background: rgba(255,255,255,0.97); border-color: var(--border-solid); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
body.light-theme #rundown-ctx-menu div { color: #1a1a1a; }
body.light-theme #rundown-ctx-menu div:hover { background: rgba(0,0,0,0.04); }
body.light-theme .rundown-export-menu { background: rgba(255,255,255,0.97) !important; border-color: var(--border-solid) !important; box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important; }
body.light-theme .rundown-export-menu > div { color: #1a1a1a !important; }
body.light-theme .rundown-export-menu > div:hover { background: rgba(0,0,0,0.04) !important; }
body.light-theme .checklist-panel input[type="text"] { background: rgba(0,0,0,0.03); color: #1a1a1a; border-color: rgba(0,0,0,0.1); }

/* ─── Phase 5: Calendar View ───────────────────────────────────────────── */
.rundown-calendar { margin-top: 16px; }
.rundown-calendar-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.rundown-calendar-nav button { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); color: var(--text-primary); border-radius: var(--radius-xs); padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all var(--duration-fast) ease; }
.rundown-calendar-nav button:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }
.rundown-calendar-nav .cal-title { font-size: 16px; font-weight: 800; color: var(--text-primary); min-width: 180px; text-align: center; letter-spacing: -0.02em; }
.rundown-calendar-mode { display: flex; gap: 4px; margin-left: auto; }
.rundown-calendar-mode button { padding: 4px 10px; font-size: 11px; }
.rundown-calendar-mode button.active { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }
.rundown-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: rgba(255,255,255,0.03); border-radius: var(--radius-sm); overflow: hidden; }
.rundown-cal-header { padding: 10px 4px; text-align: center; font-size: 11px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; background: var(--bg-surface-solid); letter-spacing: 0.5px; }
.rundown-cal-cell { min-height: 90px; padding: 8px; background: var(--bg-base); border: 1px solid rgba(255,255,255,0.03); position: relative; cursor: pointer; transition: all var(--duration-fast) ease; }
.rundown-cal-cell:hover { background: rgba(255,255,255,0.025); }
.rundown-cal-cell.today { background: rgba(0,230,118,0.03); border-color: rgba(0,230,118,0.12); }
.rundown-cal-cell.other-month { opacity: 0.3; }
.rundown-cal-date { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 700; }
.rundown-cal-cell.today .rundown-cal-date { color: var(--primary); }
.rundown-cal-plan { font-size: 10px; padding: 3px 6px; border-radius: var(--radius-xs); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-weight: 600; transition: filter var(--duration-fast) ease; }
.rundown-cal-plan:hover { filter: brightness(1.2); }
.rundown-cal-plan.status-draft { background: rgba(85,98,112,0.15); color: var(--text-secondary); }
.rundown-cal-plan.status-rehearsal { background: rgba(255,167,38,0.12); color: #FFA726; }
.rundown-cal-plan.status-show_ready { background: rgba(0,230,118,0.1); color: var(--primary); }
.rundown-cal-plan.status-live { background: rgba(239,68,68,0.12); color: #EF4444; }
.rundown-cal-plan.status-archived { background: rgba(85,98,112,0.08); color: var(--text-muted); }
.rundown-cal-add { position: absolute; bottom: 4px; right: 4px; font-size: 14px; color: var(--text-muted); cursor: pointer; opacity: 0; transition: opacity var(--duration-fast) ease; line-height: 1; }
.rundown-cal-cell:hover .rundown-cal-add { opacity: 1; }
.rundown-cal-month .rundown-cal-cell { min-height: 60px; }
.rundown-cal-month .rundown-cal-plan { font-size: 0; width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin: 1px; padding: 0; }

/* ─── Phase 5: Accessibility ───────────────────────────────────────────── */
.skip-link { position: absolute; top: -40px; left: 0; background: var(--primary); color: #050a07; padding: 8px 16px; z-index: 9999; font-weight: 700; text-decoration: none; border-radius: 0 0 var(--radius-sm) 0; }
.skip-link:focus { top: 0; }
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[role="timer"] { font-variant-numeric: tabular-nums; }

/* Light theme overrides for Phase 5 */
body.light-theme .rundown-cal-cell { background: #fff; border-color: rgba(0,0,0,0.04); }
body.light-theme .rundown-cal-cell:hover { background: rgba(0,0,0,0.015); }
body.light-theme .rundown-cal-cell.today { background: rgba(22,163,74,0.03); }
body.light-theme .rundown-cal-header { background: #f8f9fa; color: #6b7280; }
body.light-theme .analytics-card { background: rgba(0,0,0,0.015); border-color: var(--border-solid); }
body.light-theme .analytics-card:hover { border-color: rgba(22,163,74,0.2); }
/* Focus-visible accessibility indicators */
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* AI import spinner */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ─── Skeleton loaders (overview tables/cards on first load) ──── */
.skeleton-bar {
  display: inline-block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row td { padding: 14px 12px !important; vertical-align: middle; }
.staleness-syncing { color: var(--primary) !important; opacity: 0.7; }

/* ─── Custom Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ─── Selection Color ──────────────────────────────────────────── */
::selection {
  background: rgba(0,230,118,0.2);
  color: var(--text-primary);
}
