:root {
  --primary: #1C1C3D;
  --primary-dark: #33335E;
  --primary-tint: #E9E9F2;
  --bg: #f2f3f6;
  --card: #ffffff;
  --border: #dfe3ea;
  --border-strong: #cdd3dd;
  --text: #1f2229;
  --muted: #6d7081;
  --accent: #1C1C3D;
  --green: #0f9d76;
  --green-tint: #e6f6f1;
  --red: #d63031;
  --red-tint: #fdecec;
  --amber: #b98900;
  --amber-tint: #fdf5e0;
  --amber-border: #ecd9a0;
  --red-border: #f3bcbc;
  --tint-border: #c9c9dc;
  --row-bg: #f8f8fb;
  --overlay-card: rgba(255, 255, 255, 0.94);
  --modal-overlay: rgba(31, 34, 41, 0.45);
  --radius: 12px;
  --shadow: 0 1px 3px rgba(29, 30, 32, 0.06);
}

/* ---------------- dark mode ----------------
   The Live Control studio is dark by design and keeps its own palette;
   these variables re-skin everything else. Toggled by the moon button in
   the topbar, persisted in localStorage, follows the OS on first visit. */
[data-theme="dark"] {
  --primary: #8a8ade;
  --primary-dark: #a5a5ec;
  --primary-tint: #23233f;
  --bg: #0f1015;
  --card: #181a22;
  --border: #262a35;
  --border-strong: #333845;
  --text: #e6e8ef;
  --muted: #8d92a3;
  --accent: #8a8ade;
  --green: #26bd91;
  --green-tint: #10281f;
  --red: #ef5b5b;
  --red-tint: #2c1214;
  --amber: #d9a520;
  --amber-tint: #2a2210;
  --amber-border: #4d3f14;
  --red-border: #58201f;
  --tint-border: #34345c;
  --row-bg: #1d202a;
  --overlay-card: rgba(24, 26, 34, 0.94);
  --modal-overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] body { color-scheme: dark; }

/* on-primary text: primary is light lavender in dark mode, so ink flips dark */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .nav-badge,
[data-theme="dark"] .day-picker label:has(input:checked) { color: #14151c; }

/* dark mode swaps in the white logo artwork (see applyThemeAssets in app.js) */

/* theme toggle in the topbar */
.theme-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover { color: var(--text); border-color: var(--border-strong); }

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

/* the hidden attribute must always win, even over display:flex rules */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.logo { font-size: 20px; font-weight: 800; letter-spacing: 0.2px; color: var(--text); }
.logo span { color: var(--primary); }
.logo-img { height: 34px; display: block; }
.login-card .logo-img { height: auto; width: 78%; margin: 0 auto; }

/* ---------------- login ---------------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px;
  padding: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-sub { color: var(--muted); margin: 8px 0 24px; }
.login-card input { width: 100%; margin-bottom: 14px; }
.login-hint { margin-top: 16px; color: var(--muted); font-size: 12px; }
.login-hint code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.form-error { color: var(--red); margin-top: 10px; min-height: 18px; font-size: 13px; }

/* ---------------- shell ---------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-badge { display: flex; flex-direction: column; align-items: flex-end; gap: 0; line-height: 1.3; }
.user-badge strong { font-size: 13.5px; }
.user-badge .small { font-size: 12px; }

.body { display: flex; flex: 1; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13.8px;
}
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }
.sidebar nav a.live-link.active { background: var(--red-tint); color: var(--red); }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
}

.main { flex: 1; padding: 28px 32px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; font-weight: 700; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }

/* ---------------- components ---------------- */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.8px;
  font-weight: 600;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-tint); border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--primary); border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-live { background: var(--red); border-color: var(--red); color: #fff; font-size: 15px; padding: 13px 26px; }
.btn-live:hover { background: #b82525; border-color: #b82525; color: #fff; }

input, select, textarea {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28, 28, 61, 0.15); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  overflow-x: auto; /* wide tables scroll inside the card instead of bleeding out */
  min-width: 0;
}

.grid { display: grid; gap: 16px; }
.grid > .card { min-width: 0; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; }
.stat .value.green { color: var(--green); }
.stat .value.accent { color: var(--primary); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; white-space: nowrap; }
td { white-space: nowrap; }
tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.online { background: var(--green-tint); color: var(--green); }
.pill.offline { background: #eef0f3; color: var(--muted); }
.pill.takeover { background: var(--red-tint); color: var(--red); }
.pill.code { background: var(--primary-tint); color: var(--primary); font-family: "SF Mono", Menlo, monospace; letter-spacing: 2px; }
.pill.pending { background: var(--amber-tint); color: var(--amber); }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

.section-title { font-size: 13px; margin: 22px 0 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.mt-s { margin-top: 6px; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12.5px; }

/* ---------------- ad cards ---------------- */
.ad-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; position: relative; }
/* ---------------- game days calendar ---------------- */
.cal-card { padding: 18px; margin-bottom: 20px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head strong { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dows { margin-bottom: 6px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.cal-cell {
  min-height: 86px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--row-bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell.empty { border: none; background: transparent; }
.cal-cell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-daynum { font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-cell.today .cal-daynum { color: var(--primary); }
.cal-game {
  font-size: 11.5px;
  font-weight: 600;
  background: var(--primary-tint);
  color: var(--primary);
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-game.past { opacity: 0.5; }
.game-card { margin-bottom: 14px; }
.game-card.flash { box-shadow: 0 0 0 3px var(--primary-tint), 0 0 14px rgba(28, 28, 61, 0.25); }
.game-msg { margin-top: 8px; font-style: italic; }
.inv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.inv-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--row-bg);
}
.inv-chip.accepted { background: var(--green-tint); color: var(--green); border-color: var(--green); }
.inv-chip.declined { background: var(--red-tint); color: var(--red); border-color: var(--red); }
.check-item { display: flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; padding: 3px 0; }

.logic-col { display: flex; flex-direction: column; gap: 10px; line-height: 1.55; }
.logic-col b { color: var(--text); }

/* idle settings organization */
.idle-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.idle-section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.idle-section-title { font-size: 12px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--primary); margin-bottom: 12px; }
.idle-save { margin-top: 18px; text-align: right; }

/* idle layout visual editor */
.idle-editor-label { display: block; margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.idle-editor { margin-top: 4px; }
.idle-preview {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  background: radial-gradient(600px 400px at 50% 40%, #131a28, #05070c);
  border-radius: 10px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.idle-preview .ip-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.idle-preview .ip-shade { position: absolute; inset: 0; background: rgba(4, 6, 12, 0.35); }
/* safe area guide: 5% inset, matches the player's overscan-safe clamp */
.ip-safe { position: absolute; inset: 5%; border: 1px dashed rgba(255, 255, 255, 0.3); border-radius: 6px; pointer-events: none; }
.ip-el {
  position: absolute;
  transform: translate(-50%, -50%);
  color: #fff;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
  cursor: grab;
  white-space: nowrap;
  padding: 2px 6px;
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  border-radius: 6px;
}
.ip-el:active { cursor: grabbing; border-color: #f59e0b; }
.ip-logo {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  object-fit: contain;
}
.idle-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.ie-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--row-bg); }
.ie-card .ie-content { width: 100%; margin: 8px 0; }
.ie-hint { font-size: 11.5px; color: var(--muted); margin: 6px 0; }
.ie-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.ie-line span { width: 58px; flex-shrink: 0; }
.ie-line input[type="range"], .ie-line select, .ie-line input[type="file"] { flex: 1; min-width: 0; }

/* idle slideshow manager (Settings) */
.idle-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.idle-item { display: flex; align-items: center; gap: 10px; }
.idle-item img { width: 92px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.idle-item .id-credit { flex: 1; }
.idle-item .id-dur { width: 76px; }

/* invoice line editor */
.ie-table { width: 100%; border-collapse: collapse; }
.ie-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); padding: 4px 6px; }
.ie-table td { padding: 3px 4px; }
.ie-table input { width: 100%; padding: 8px 10px; }

/* screen-down warning banner */
.offline-bar {
  background: var(--red);
  color: #fff;
  padding: 9px 24px;
  font-size: 13.5px;
  text-align: center;
}

/* category filter chips on Venues & Screens */
.cat-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.cat-chip:hover { border-color: var(--primary); color: var(--text); }
.cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .cat-chip.active { color: #14151c; }
.cat-chip .cat-count {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11.5px;
}
.cat-chip.active .cat-count { background: rgba(255, 255, 255, 0.25); }
[data-theme="dark"] .cat-chip .cat-count { background: rgba(255, 255, 255, 0.08); }
[data-theme="dark"] .cat-chip.active .cat-count { background: rgba(0, 0, 0, 0.18); }

/* venue category tier badges (A premium … D basic) */
.cat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 800;
  vertical-align: middle;
}
.cat-badge.cat-A { background: #f3e8ff; color: #7c3aed; border: 1px solid #d8b4fe; }
.cat-badge.cat-B { background: var(--green-tint); color: var(--green); border: 1px solid var(--green); }
.cat-badge.cat-C { background: var(--primary-tint); color: var(--primary); border: 1px solid var(--tint-border); }
.cat-badge.cat-D { background: var(--row-bg); color: var(--muted); border: 1px solid var(--border-strong); }
[data-theme="dark"] .cat-badge.cat-A { background: #2b2140; color: #c4b5fd; border-color: #6d28d9; }

/* QR placement controls in the ad modal */
.qr-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--row-bg); }
.qr-preview {
  position: relative;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #2a2f3a, #12151c);
  border-radius: 8px;
  margin-top: 10px;
  overflow: hidden;
}
.qr-dot {
  position: absolute;
  aspect-ratio: 1;
  background: repeating-conic-gradient(#fff 0 25%, #d8dbe6 0 50%);
  border: 3px solid #fff;
  border-radius: 6px;
}

/* duration chip over the thumbnail, YouTube style */
.ad-dur {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.3px;
  pointer-events: none;
}
.ad-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #14161a;
  display: block;
  border-bottom: 1px solid var(--border);
}
.ad-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 500px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(29, 30, 32, 0.18);
}
.modal h2 { margin-bottom: 18px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.check-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  background: var(--card);
}
.check-list label { display: flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.check-inline { display: flex; gap: 7px; align-items: center; font-size: 13.5px; cursor: pointer; }

.day-picker { display: flex; gap: 6px; }
.day-picker label {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  user-select: none;
}
.day-picker input { display: none; }
.day-picker label:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }

/* ---------------- live studio ---------------- */
.studio { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.studio.has-editor { grid-template-columns: 340px 1fr; }
@media (max-width: 1100px) { .studio.has-editor { grid-template-columns: 1fr; } }

/* editor rail (left of the live preview) */
.editor-rail { padding: 0; overflow: hidden; }
.ed-head-main { padding: 14px 16px 2px; font-weight: 700; font-size: 15px; }
.ed-sub { padding: 0 16px 10px; }
.ed-section-label {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); font-weight: 700;
}
.ed-section-label .search-input { min-width: 0; flex: 1; padding: 5px 9px; font-size: 12px; text-transform: none; letter-spacing: normal; font-weight: 400; }
.editor-rail .ed-list { max-height: 300px; }
.editor-rail .ed-row.playing { background: var(--green-tint); }

/* campaign/playlist timeline under the preview */
.timeline-card { padding: 0; overflow: hidden; margin-top: 12px; }
.timeline-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.timeline-head select { max-width: 260px; }
.timeline {
  display: flex;
  gap: 10px;
  padding: 14px;
  overflow-x: auto;
}
.tl-item {
  flex: 0 0 auto;
  width: 130px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.tl-item:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 40px; right: -10px;
  width: 10px; height: 2px;
  background: var(--border-strong);
}
.tl-num {
  position: absolute; top: 5px; left: 5px; z-index: 2;
  width: 19px; height: 19px; border-radius: 50%;
  background: rgba(6,6,18,0.72); color: #fff;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.tl-thumb {
  width: 100%; aspect-ratio: 16/9;
  border-radius: 7px; overflow: hidden;
  background: #0b0b16; position: relative;
  border: 2px solid transparent;
}
.tl-item.playing .tl-thumb { border-color: var(--green); }
.tl-thumb img, .tl-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-live-dot {
  position: absolute; top: 6px; right: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); border: 2px solid #fff;
}
.tl-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-meta { font-size: 11px; }

.pl-panel { padding: 0; overflow: hidden; }
.pl-title {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.pl-ads { max-height: 520px; overflow-y: auto; }
.pl-ad {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.pl-ad:last-child { border-bottom: none; }
.pl-ad.playing { background: var(--green-tint); }
.pl-thumb {
  width: 86px;
  aspect-ratio: 16/9;
  border-radius: 6px;
  overflow: hidden;
  background: #0b0b16;
  flex-shrink: 0;
}
.pl-thumb img, .pl-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pl-info strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-playing-tag { color: var(--green); font-weight: 700; }

.studio-top { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.venue-bar {
  flex: 1;
  min-width: 220px;
  background: var(--amber-tint);
  border: 1px solid var(--amber-border);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  border-radius: 10px;
  padding: 11px 16px;
}
.status-bar {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  border-radius: 10px;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-bar.live { background: var(--red); border-color: var(--red); color: #fff; }
.status-bar .tv-live-dot { background: #fff; }
.lc-timer { font-family: "SF Mono", Menlo, monospace; font-weight: 800; letter-spacing: 1px; }

.clock-bar {
  background: #16162b;
  color: #e8e9f2;
  border-radius: 10px;
  padding: 11px 16px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  min-width: 118px;
  text-align: center;
}

.main-screen {
  position: relative;
  aspect-ratio: 16/9;
  background: #0b0b16;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid transparent;
}
.main-screen.is-live { border-color: var(--red); animation: liveGlow 1.6s ease-in-out infinite; }
@keyframes liveGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(214, 48, 49, 0.45), 0 0 3px rgba(214, 48, 49, 0.7); }
  50% { box-shadow: 0 0 28px rgba(214, 48, 49, 0.85), 0 0 8px rgba(214, 48, 49, 1); }
}
.main-screen img, .main-screen video { width: 100%; height: 100%; object-fit: contain; display: block; }
.main-screen .tv-off { font-size: 18px; letter-spacing: 6px; }
.main-screen .tv-idle { font-size: 15px; }
.ms-countdown {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(214, 48, 49, 0.95);
  color: #fff;
  border-radius: 12px;
  padding: 8px 18px 10px;
  text-align: center;
  box-shadow: 0 4px 18px rgba(214, 48, 49, 0.45);
}
.ms-count-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  opacity: 0.85;
}
.ms-count-digits {
  display: block;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 3px;
  line-height: 1.1;
}

.ms-label {
  position: absolute;
  bottom: 10px;
  left: 12px;
  background: rgba(6, 6, 18, 0.72);
  color: #e8e9f2;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 7px;
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-bar {
  background: #16162b;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.cbtn {
  background: #262649;
  color: #e8e9f2;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cbtn svg { width: 18px; height: 18px; }
.cbtn:hover { background: #33335e; }
.cb-spacer { flex: 1; }
.cb-select, .cb-min {
  background: #262649;
  color: #e8e9f2;
  border: 1px solid #33335e;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
}
.cb-min { width: 84px; }
.cb-unit { color: #8b90a5; font-size: 12.5px; font-weight: 600; margin-left: -3px; }
.cb-kill {
  background: #3d0f12;
  color: #ff8080;
  border: 1px solid #7f1d1d;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.cb-kill:hover { background: #58151a; color: #ffb3b3; }
.cb-sched {
  background: #23233f;
  color: #cfd2ea;
  border: 1px solid #3a3a63;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.cb-sched:hover { background: #33335e; color: #fff; }
.cb-auto {
  background: #262649;
  color: #cfd2ea;
  border: 1px solid #3a3a63;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
  font-size: 12.5px;
}
.cb-auto:hover:not(:disabled) { background: #33335e; color: #fff; }
.cb-auto:disabled { opacity: 0.4; cursor: default; }

/* upcoming campaigns queue */
.queue-card { padding: 0; overflow: hidden; margin-top: 12px; }
.queue-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.queue-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.queue-row:last-child { border-bottom: none; }
.queue-when { display: flex; flex-direction: column; min-width: 96px; }
.queue-when strong { font-family: "SF Mono", Menlo, monospace; font-size: 13.5px; }
.queue-info { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.queue-info strong { font-size: 13.5px; }
.cb-clear {
  background: #262649;
  color: #b9bdd6;
  border: 1px solid #33335e;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}
.cb-clear:hover { background: #33335e; color: #fff; }

.sibling-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.sibling-strip .tv-meta { padding: 7px 10px; }
.sibling-strip .tv-meta .muted { display: none; }

/* inline playlist editor under the live preview */
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); }
.ed-col { min-width: 0; }
.ed-col + .ed-col { border-left: 1px solid var(--border); }
.ed-head {
  padding: 9px 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ed-head .search-input { min-width: 0; width: 170px; padding: 5px 9px; font-size: 12.5px; text-transform: none; letter-spacing: normal; font-weight: 400; }
.ed-list { max-height: 320px; overflow-y: auto; }
.ed-row { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ed-row:last-child { border-bottom: none; }
.ed-num { color: var(--muted); font-size: 12px; font-weight: 700; width: 16px; text-align: right; flex-shrink: 0; }
.ed-thumb { width: 62px; aspect-ratio: 16/9; border-radius: 5px; overflow: hidden; background: #0b0b16; flex-shrink: 0; }
.ed-thumb img, .ed-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.ed-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.ed-btn svg { width: 14px; height: 14px; }
.ed-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.ed-btn:disabled { opacity: 0.3; cursor: default; }
.ed-btn.danger { color: var(--red); border-color: #f0c4c4; }
.ed-btn.danger:hover { background: var(--red-tint); border-color: var(--red); color: var(--red); }
.ed-btn.add { color: var(--green); border-color: #bfe3d7; }
.ed-btn.add:hover { background: var(--green-tint); border-color: var(--green); color: var(--green); }
@media (max-width: 1100px) { .ed-grid { grid-template-columns: 1fr; } .ed-col + .ed-col { border-left: none; border-top: 1px solid var(--border); } }

/* collapsible business list in Live Control */
.biz-row { border-bottom: 1px solid var(--border); }
.biz-row:last-child { border-bottom: none; }
.biz-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
}
.biz-head:hover { background: var(--bg); }
.biz-head strong { font-size: 14.5px; }
.biz-caret { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; transition: transform 0.15s ease; }
.biz-head.open .biz-caret { transform: rotate(90deg); }
.biz-head.open { background: var(--bg); }
.biz-badges { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.biz-screens { padding: 4px 16px 16px; background: var(--bg); }

.venue-sec { margin-bottom: 20px; }
.venue-sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px; }
.tv-grid.mini { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---------------- live TV control center ---------------- */
.tv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tv-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, border-color 0.08s ease;
}
.tv-tile:hover { border-color: var(--primary); }
.tv-tile.selected { outline: 2px solid var(--primary); outline-offset: -1px; }
.tv-tile.is-live { border-color: var(--red); animation: liveGlow 1.6s ease-in-out infinite; }
.tv-screen {
  position: relative;
  aspect-ratio: 16/9;
  background: #0b0b16;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tv-screen img, .tv-screen video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tv-tile.is-offline .tv-screen { background: #111118; }
.tv-off { color: #4c4f63; font-weight: 800; letter-spacing: 3px; font-size: 12px; }
.tv-idle { color: #8b90a5; font-size: 12.5px; padding: 0 14px; text-align: center; }
.tv-live {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  padding: 3px 9px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tv-live-dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
.tv-status-dot { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 50%; }
.tv-status-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.tv-status-dot.off { background: #4c4f63; }
.tv-meta { padding: 10px 13px; display: flex; flex-direction: column; gap: 1px; }
.tv-meta strong { font-size: 13.5px; }
.tv-now { color: var(--muted); }
.tv-now.live { color: var(--red); font-weight: 700; }
.command-bar .field label { margin-bottom: 4px; }

/* ---------------- live control header + online strip ---------------- */
.live-stats { display: flex; gap: 10px; }
.lstat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 18px;
  text-align: center;
  min-width: 92px;
}
.lstat-num { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.lstat-num.green { color: var(--green); }
.lstat-num.red { color: var(--red); }
.lstat-den { font-size: 15px; color: var(--muted); font-weight: 600; }
.lstat-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }

.online-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.online-strip-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 700; margin-right: 4px; }
.online-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.online-chip:hover { border-color: var(--primary); }
.online-chip.active { border-color: var(--primary); background: var(--primary-tint); }
.online-chip.live { border-color: var(--red); }
.online-chip.live .dot { background: var(--red); }

/* ---------------- watermark settings preview ---------------- */
.wm-preview {
  position: relative;
  aspect-ratio: 16/9;
  margin-top: 14px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2f3a, #12151c);
  border: 1px solid var(--border);
}
.wm-preview-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #4b5262;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.wm-preview img { position: absolute; height: auto; }
.wm-preview .wm-pos-top-left { top: 5%; left: 4%; }
.wm-preview .wm-pos-top-right { top: 5%; right: 4%; }
.wm-preview .wm-pos-bottom-left { bottom: 5%; left: 4%; }
.wm-preview .wm-pos-bottom-right { bottom: 5%; right: 4%; }
.wm-preview .wm-pos-center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ---------------- venue list ---------------- */
.venue-list th, .venue-list td { padding: 11px 16px; }
.venue-list thead th { background: var(--bg); border-bottom: 1px solid var(--border); }
.venue-list .venue-row td {
  background: var(--row-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: normal;
}
.venue-list tbody:first-of-type .venue-row td { border-top: none; }
.venue-list .venue-row strong { font-size: 14.5px; }
.venue-list .venue-row .btn { margin-left: 4px; }
.venue-list .screen-cell { padding-left: 34px; }
.venue-list tr:last-child td { border-bottom: 1px solid var(--border); }
.venue-list tbody:last-of-type tr:last-child td { border-bottom: none; }

/* ---------------- payouts ---------------- */
.rate-input { width: 120px; padding: 6px 9px; }
.sim-field { width: 150px; margin-bottom: 0; }
#simResults .card { border: 1px solid var(--border); background: var(--bg); }
.totals-row td { background: var(--bg); border-top: 2px solid var(--border-strong); }

/* ---------------- search ---------------- */
.search-input {
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 12px;
}

/* ---------------- campaign map ---------------- */
.map-layout { display: grid; grid-template-columns: 1fr 350px; gap: 16px; align-items: start; }
.map-wrap { padding: 12px; position: relative; overflow: visible; }
.map-canvas {
  height: clamp(440px, calc(100vh - 290px), 700px);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  z-index: 0;
  border: 1px solid var(--border);
}
.map-legend {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 600;
  background: var(--overlay-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.map-legend .dot { width: 10px; height: 10px; border: 1.5px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.map-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.map-side .card { padding: 18px; }
.sel-summary {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--primary-tint);
  border: 1px solid var(--tint-border);
  border-radius: 8px;
  font-size: 13.5px;
}
.mini-map { height: 220px; border-radius: 8px; background: var(--bg); z-index: 0; border: 1px solid var(--border); }
.leaflet-container { font-family: inherit; }
@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-canvas { height: 400px; }
}

/* ---------------- chart ---------------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 40px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; opacity: 0.85; }
.chart .bar:hover { opacity: 1; }
.chart .bar-label { font-size: 10px; color: var(--muted); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  padding: 13px 18px;
  border-radius: 10px;
  z-index: 200;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(29, 30, 32, 0.12);
}
.toast.error { border-left-color: var(--red); }

/* ---------------- banners ---------------- */
.takeover-banner {
  background: var(--red-tint);
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.takeover-banner .title { font-weight: 800; color: var(--red); }

.pending-strip {
  display: block;
  background: var(--amber-tint);
  border: 1px solid var(--amber-border);
  color: var(--amber);
  border-radius: var(--radius);
  padding: 13px 18px;
  font-weight: 600;
  text-decoration: none;
}
.pending-strip:hover { filter: brightness(0.98); }

.join-link {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--primary);
}
.code-list {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
}

@media (max-width: 860px) {
  .body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a span { white-space: nowrap; }
  .main { padding: 20px; }
}
