/* TV Dashboard — Responsive 16:9 */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: #1a1a26;
  --border: #252535;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  --accent-blue: #4d8ef7;
  --accent-cyan: #00d4ff;
  --accent-green: #2ecc71;
  --accent-yellow: #f1c40f;
  --accent-orange: #e67e22;
  --accent-red: #e74c3c;
  --accent-purple: #9b59b6;
  --group-alpha: #4d8ef7;
  --group-papa: #e74c3c;
  --group-other: #8888a0;
  --header-height: 5.5vw;
  --ticker-height: 2vw;
  --gap: 0.6vw;
  --radius: 0.4vw;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* HEADER */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1vw;
  z-index: 100; gap: 0.5vw;
}

.header-kpis {
  display: flex; flex: 1; gap: 0.4vw; justify-content: center;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3vw 0.8vw;
  min-width: 5.5vw; text-align: center;
  position: relative;
  transition: all 0.3s ease;
}

.kpi-card.pulsed {
  animation: kpiPulse 1.5s ease-in-out;
}

@keyframes kpiPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4); }
  50% { box-shadow: 0 0 1vw 0.3vw rgba(0, 212, 255, 0.2); border-color: var(--accent-cyan); }
  100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
}

.kpi-label { font-size: 0.55vw; color: var(--text-secondary); margin-bottom: 0.1vw; font-weight: 500; }
.kpi-value { font-size: 1.2vw; font-weight: 700; line-height: 1.1; }
.kpi-plan { font-size: 0.5vw; color: var(--text-muted); margin-top: 0.05vw; }

.kpi-progress {
  width: 100%; height: 0.15vw;
  background: rgba(255,255,255,0.06);
  border-radius: 0.1vw; margin-top: 0.2vw; overflow: hidden;
}

.kpi-progress-bar { height: 100%; border-radius: 0.1vw; transition: width 1s ease-out; }

.kpi-delta {
  position: absolute; top: 0.2vw; right: 0.3vw;
  font-size: 0.45vw; font-weight: 600;
}
.kpi-delta.up { color: var(--accent-green); }
.kpi-delta.down { color: var(--accent-red); }
.kpi-delta.same { color: var(--text-muted); }

.header-meta {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 0.15vw; min-width: 8vw;
}

.header-period { font-size: 0.65vw; font-weight: 600; }
.header-countdown { font-size: 0.55vw; color: var(--accent-cyan); font-weight: 500; }
.header-time { font-size: 0.5vw; color: var(--text-muted); }

/* MAIN */
.main {
  position: absolute;
  top: var(--header-height); left: 0; right: 0;
  bottom: var(--ticker-height);
  overflow: hidden;
}

.screen-container { width: 100%; height: 100%; position: relative; }

.screen {
  position: absolute; inset: 0;
  padding: 0.8vw 1vw;
  opacity: 0; transform: translateX(2vw);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
  display: flex; flex-direction: column; gap: 0.6vw;
}

.screen.active { opacity: 1; transform: translateX(0); pointer-events: auto; }
.screen.leaving { opacity: 0; transform: translateX(-2vw); }

.screen-title {
  font-size: 1.1vw; font-weight: 700; letter-spacing: -0.02vw;
  display: flex; align-items: center; gap: 0.4vw;
  flex-shrink: 0;
}

.screen-title svg { width: 1.1vw; height: 1.1vw; fill: var(--accent-cyan); }

/* CHARTS */
.chart-row { display: flex; gap: var(--gap); flex: 1; min-height: 0; }

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6vw 0.8vw;
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

.chart-card-title {
  font-size: 0.7vw; font-weight: 600;
  margin-bottom: 0.4vw; color: var(--text-secondary);
  flex-shrink: 0;
}

/* BAR CHART */
.bar-chart { display: flex; flex-direction: column; gap: 0.2vw; flex: 1; overflow: hidden; }

.bar-row {
  display: flex; align-items: center; gap: 0.3vw;
  height: 1.15vw; min-height: 1.15vw;
}

.bar-rank {
  font-size: 0.6vw; font-weight: 600; width: 1.2vw;
  text-align: center; flex-shrink: 0;
  color: var(--text-muted);
}

.bar-name {
  font-size: 0.6vw; width: 8.5vw; flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}

.bar-track {
  flex: 1; height: 0.9vw;
  background: rgba(255,255,255,0.04);
  border-radius: 0.2vw; overflow: hidden;
}

.bar-fill {
  height: 100%; border-radius: 0.2vw;
  transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0.1vw;
}

.bar-fill.gradient-blue { background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan)); }
.bar-fill.gradient-red { background: linear-gradient(90deg, #c0392b, var(--accent-red)); }
.bar-fill.gradient-green { background: linear-gradient(90deg, #27ae60, var(--accent-green)); }
.bar-fill.gradient-yellow { background: linear-gradient(90deg, var(--accent-orange), var(--accent-yellow)); }
.bar-fill.gradient-purple { background: linear-gradient(90deg, #8e44ad, var(--accent-purple)); }

.bar-value { font-size: 0.6vw; font-weight: 700; width: 3vw; text-align: right; flex-shrink: 0; }

/* GROUPS */
.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8vw; flex: 1;
  display: flex; flex-direction: column; gap: 0.5vw;
}

.group-name { font-size: 0.9vw; font-weight: 700; }
.group-name.alpha { color: var(--group-alpha); }
.group-name.papa { color: var(--group-papa); }
.group-name.other { color: var(--group-other); }

.group-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3vw; }

.group-metric {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius); padding: 0.4vw; text-align: center;
}

.group-metric-label { font-size: 0.5vw; color: var(--text-secondary); margin-bottom: 0.15vw; }
.group-metric-value { font-size: 1vw; font-weight: 700; }

/* BIG STATS */
.stat-big { text-align: center; padding: 0.4vw; }
.stat-big-value {
  font-size: 2.5vw; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-big-label { font-size: 0.7vw; color: var(--text-secondary); margin-top: 0.2vw; }

/* NAVIGATION CONTROLS */
.nav-controls {
  position: fixed;
  bottom: calc(var(--ticker-height) + 0.8vw);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.4vw;
  z-index: 100;
  background: rgba(0,0,0,0.6);
  padding: 0.2vw 0.5vw;
  border-radius: 1vw;
  backdrop-filter: blur(10px);
}

.nav-btn {
  width: 1.2vw; height: 1.2vw;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.2s;
  font-size: 0.5vw;
}

.nav-btn:hover { background: rgba(255,255,255,0.2); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-cyan); color: var(--bg-primary); }

.nav-btn svg { width: 0.6vw; height: 0.6vw; fill: currentColor; }

.screen-dot {
  width: 0.3vw; height: 0.3vw; border-radius: 50%;
  background: var(--text-muted); opacity: 0.3;
  transition: all 0.3s; cursor: pointer;
}

.screen-dot.active { background: var(--accent-cyan); opacity: 1; transform: scale(1.3); }

/* TICKER */
.ticker {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--ticker-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; overflow: hidden;
  z-index: 100;
}

.ticker-label {
  padding: 0 0.6vw; font-size: 0.6vw; font-weight: 700;
  color: var(--accent-cyan); white-space: nowrap;
  border-right: 1px solid var(--border);
  height: 100%; display: flex; align-items: center;
}

.ticker-track { flex: 1; overflow: hidden; white-space: nowrap; }

.ticker-content {
  display: inline-flex; gap: 1.5vw;
  animation: tickerScroll 45s linear infinite;
  padding-left: 100%;
}

@keyframes tickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex; align-items: center; gap: 0.3vw;
  font-size: 0.6vw; white-space: nowrap;
}

.ticker-dot { width: 0.25vw; height: 0.25vw; border-radius: 50%; flex-shrink: 0; }
.ticker-dot.exclusive { background: var(--accent-green); }
.ticker-dot.meeting { background: var(--accent-blue); }
.ticker-dot.call { background: var(--accent-yellow); }

.ticker-time { color: var(--text-muted); font-size: 0.5vw; }

/* LOADING */
.loading-overlay {
  position: fixed; inset: 0; background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; transition: opacity 0.5s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 2vw; height: 2vw;
  border: 0.1vw solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-badge {
  position: fixed; top: var(--header-height); right: 1vw;
  background: var(--accent-red); color: white;
  padding: 0.3vw 0.6vw; border-radius: var(--radius);
  font-size: 0.5vw; z-index: 200;
  opacity: 0; transition: opacity 0.3s;
}
.error-badge.visible { opacity: 1; }

::-webkit-scrollbar { display: none; }
