:root {
  --bg: #0b0e14;
  --surface: #131823;
  --surface-2: #1a2130;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #e11d48;
  --red: #dc2626;
  --blue: #2563eb;
  --gold: #f59e0b;
  --green: #10b981;
  --radius: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(11, 14, 20, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 24px;
}

.brand-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
}

.brand-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.conn-badge.online .conn-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.conn-badge.offline .conn-dot {
  background: var(--red);
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: var(--surface-2);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tab-pill {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

/* LAYOUT */
.main-wrap {
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 20px 36px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-title {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
}

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

.hidden {
  display: none !important;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
}
.btn-primary:hover {
  background: #be123c;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: #252f44;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: #cbd5e1;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-danger {
  background: #991b1b;
  border-color: #ef4444;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-amber {
  background: #92400e;
  border-color: #f59e0b;
}
.btn-amber:hover {
  background: #b45309;
}

.btn-gold {
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff;
}
.btn-gold:hover {
  filter: brightness(1.1);
}

.btn-green {
  background: #059669;
}

.btn-lg {
  padding: 12px 18px;
  font-size: 15px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.flex-1 { flex: 1; }
.full-w { width: 100%; }

/* INPUTS */
.lbl {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 5px;
}

.input, .input-select {
  width: 100%;
  background: #0d1119;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #fff;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}

.input:focus, .input-select:focus {
  outline: none;
  border-color: var(--primary);
}

.input-xs {
  background: #0d1119;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
}

.input-color {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0d1119;
  cursor: pointer;
  padding: 2px;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
}

/* =====================================================
   TAB 1: LIVE GRID
   ===================================================== */
.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.live-left, .live-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* LIVE PREVIEW MONITOR */
.preview-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.scorebug-quick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
}

.sqb-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 2px;
}

.preview-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 50% 40%, #1c2436 0%, #090c12 100%);
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.03) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#overlay-preview {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}

/* ACTIVE FIGHT BAR */
.fight-nav-btns {
  display: flex;
  gap: 6px;
}

.fight-summary-strip {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: #cbd5e1;
}

/* SCENE SWITCHBOARD */
.switchboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.scene-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 14px 14px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.scene-btn:hover {
  background: #222b3e;
  border-color: rgba(255, 255, 255, 0.24);
}

.scene-btn.active {
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.28), rgba(225, 29, 72, 0.12));
  border-color: #ef4444;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.25);
}

.scene-btn.red-accent.active {
  border-color: var(--red);
}

.scene-btn.blue-accent.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.3), rgba(37, 99, 235, 0.12));
  border-color: #3b82f6;
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.25);
}

.scene-btn.gold-accent.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(245, 158, 11, 0.12));
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.25);
}

.scene-key {
  position: absolute;
  top: 8px;
  right: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 5px;
  border-radius: 4px;
}

.scene-icon {
  font-size: 20px;
}

.scene-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.scene-sub {
  font-size: 11px;
  color: var(--muted);
}

.on-air-pill {
  display: none;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  border-radius: 3px;
  background: #ef4444;
  color: #fff;
}

.scene-btn.active .on-air-pill {
  display: inline-block;
}

.fc-page-controls {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* TIMER CARD */
.phase-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 3px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.phase-badge.rest {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

.timer-display-box {
  background: #090c12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}

.timer-display-box.running {
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: inset 0 0 24px rgba(16, 185, 129, 0.12);
}

.timer-display-box.warning {
  border-color: #ef4444;
  box-shadow: inset 0 0 30px rgba(239, 68, 68, 0.28);
}

.ctrl-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 54px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ctrl-timer-state {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-top: 6px;
}

.timer-primary-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.timer-secondary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.timer-adjust-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.corner-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.corner-stat-box {
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--red);
}

.corner-stat-box.blue {
  border-left-color: var(--blue);
}

.cs-name {
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* RESULT FORM */
.result-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 76px 1fr 1fr;
  gap: 8px;
}

.align-end {
  display: flex;
  align-items: flex-end;
}

/* LIVE ADS GRID */
.carousel-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-ads-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.live-ad-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #0d1119;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: #fff;
}

.live-ad-tile.active {
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.35);
}

.live-ad-tile img {
  width: 100%;
  height: 76px;
  object-fit: cover;
  display: block;
}

.live-ad-meta {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
}

.empty-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 4px;
}

/* =====================================================
   TAB 2: FIGHTS MANAGER
   ===================================================== */
.fights-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}

.fights-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 4px;
}

.fight-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}

.fight-list-item.selected {
  border-color: var(--primary);
  background: rgba(225, 29, 72, 0.14);
}

.fight-list-item.is-live {
  border-left: 4px solid var(--gold);
}

.fli-info {
  min-width: 0;
  flex: 1;
}

.fli-top {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.fli-names {
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.fli-actions {
  display: flex;
  gap: 4px;
}

.fights-footer-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.editor-header-actions {
  display: flex;
  gap: 8px;
}

.form-section {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.section-label {
  font-size: 12px;
  font-weight: 800;
  color: #cbd5e1;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.span-2 {
  grid-column: span 2;
}

.checkbox-wrap {
  display: flex;
  align-items: flex-end;
  padding-bottom: 6px;
}

.fighters-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.fighter-editor-box {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
}

.red-box { border-top: 3px solid var(--red); }
.blue-box { border-top: 3px solid var(--blue); }

.fe-header {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.photo-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.photo-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: #0d1119;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.photo-upload-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =====================================================
   TAB 3: ADS & SETTINGS
   ===================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.span-2-desktop {
  grid-column: span 2;
}

.ads-manager-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ad-manager-row {
  display: grid;
  grid-template-columns: 110px 1fr 170px auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.ad-manager-row img {
  width: 110px;
  height: 62px;
  object-fit: cover;
  border-radius: 5px;
  background: #090c12;
}

.toggles-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.obs-guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.obs-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.obs-box-title {
  font-weight: 800;
  margin-bottom: 10px;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.obs-steps {
  margin-top: 12px;
  padding-left: 18px;
  color: #cbd5e1;
  line-height: 1.7;
  font-size: 13px;
}

.lan-urls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* RESPONSIVE */
@media (max-width: 1120px) {
  .live-grid,
  .fights-layout,
  .settings-grid,
  .fighters-editor-grid,
  .obs-guide-grid {
    grid-template-columns: 1fr;
  }
  .span-2-desktop {
    grid-column: span 1;
  }
}


/* =====================================================
   CUSTOM VERSUS POSTER & 8-PAD SAMPLES (V3)
   ===================================================== */
.custom-vs-upload-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.poster-thumb {
  width: 142px;
  height: 80px;
  border-radius: 6px;
}

.custom-vs-meta {
  flex: 1;
  min-width: 0;
}

/* 8-pad live sampler grid */
.samples-pad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sample-pad {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: #fff;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: all 0.14s ease;
}

.sample-pad:hover {
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.sample-pad.is-empty {
  opacity: 0.6;
  border-style: dashed;
}

.sample-pad.active {
  border-color: #ef4444;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.4);
}

.sample-pad-thumb {
  position: relative;
  width: 100%;
  height: 62px;
  background: #090c12;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
}

.sample-pad-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sample-pad-num {
  position: absolute;
  top: 5px;
  left: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.72);
  color: #cbd5e1;
}

.sample-pad-live {
  display: none;
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 2px 5px;
  border-radius: 3px;
  background: #ef4444;
  color: #fff;
}

.sample-pad.active .sample-pad-live {
  display: inline-block;
}

.sample-pad-footer {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.sample-pad-name {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sample-pad-mode {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

/* 8-pad settings manager grid */
.samples-manager-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.sample-cfg-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sample-cfg-thumb {
  width: 100%;
  height: 86px;
  border-radius: 6px;
  background: #090c12;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 11px;
  color: var(--muted);
}

.sample-cfg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sample-cfg-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 1120px) {
  .samples-pad-grid,
  .samples-manager-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
