:root {
  --bg: #0a0a0a;
  --panel: #121212;
  --accent: #cfff04;
  --accent-dim: #8fb300;
  --text: #f2f2f2;
  --text-dim: #9a9a9a;
  --danger: #ff4d4d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  height: 100%;
}
button { font-family: inherit; }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel); padding: 32px 28px; border-radius: 16px;
  width: 100%; max-width: 360px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.tagline { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input {
  background: #1a1a1a; border: 1px solid #262626; color: var(--text);
  padding: 12px 14px; border-radius: var(--radius); font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--accent-dim); }
.setup-note { margin-top: 14px; font-size: 12px; color: var(--accent); }

.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin: 0 0 4px; }
.brand span { color: var(--accent); }

.btn-accent {
  background: var(--accent); color: #0a0a0a; border: none; font-weight: 700;
  padding: 12px; border-radius: var(--radius); cursor: pointer; font-size: 15px;
  transition: transform .1s;
}
.btn-accent:active { transform: scale(0.97); }
.form-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid #1d1d1d;
}
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.chip-btn {
  background: #1d1d1d; border: none; color: var(--text); width: 30px; height: 30px;
  border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 15px;
}
.chip-btn svg { display: block; }

/* ---------- player ---------- */
#player-wrap {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #000;
  max-height: 60vh;
}
#video { width: 100%; height: 100%; display: block; background: #000; }
#player-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: var(--text-dim); font-size: 14px; text-align: center; padding: 0 20px;
}
#controls {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(10,10,10,.55); backdrop-filter: blur(10px);
  transition: opacity .2s;
}
.ctrl-btn {
  background: transparent; border: none; color: var(--text); cursor: pointer;
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.ctrl-btn svg { display: block; }
.ctrl-btn:active { background: rgba(255,255,255,.1); }
#vol { width: 80px; accent-color: var(--accent); }
.now-playing { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.spacer { flex: 1; }
.live-badge {
  color: var(--accent); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px;
}
.live-dot-badge {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.6s infinite; flex-shrink: 0;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ---------- grid ---------- */
#channels-wrap { padding: 14px 16px 40px; }
.grid, .shimmer-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
}
@media (max-width: 640px) {
  .grid, .shimmer-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 7px; }
  .card { padding: 6px 4px; gap: 4px; }
  .card-thumb { width: 38px; height: 38px; }
  .card-name { font-size: 10px; }
  .shimmer-card { height: 58px; }
  #vol { display: none; } /* iOS Safari no permite controlar volumen por JS */
}
.card {
  background: var(--panel); border: 1px solid #1d1d1d; border-radius: var(--radius);
  padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; color: var(--text); text-align: center;
}
.card.active { border-color: var(--accent); background: #171b02; }
.card-thumb { position: relative; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; }
.card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-logo-fallback {
  width: 100%; height: 100%; border-radius: 8px; background: #1d1d1d;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--text-dim);
}
.live-dot {
  position: absolute; bottom: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}
.card-name { font-size: 12px; line-height: 1.2; }

.shimmer-card {
  background: linear-gradient(90deg, #121212 25%, #1a1a1a 37%, #121212 63%);
  background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); height: 86px;
}
@keyframes shimmer { 0%{background-position:100% 50%} 100%{background-position:0 50%} }

.empty { text-align: center; color: var(--text-dim); margin-top: 40px; font-size: 14px; }

/* ---------- admin ---------- */
#admin-app { max-width: 800px; margin: 0 auto; padding: 16px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #1d1d1d; }
.admin-table th { color: var(--text-dim); font-weight: 600; }
.status-badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.status-activa { background: #17330f; color: #9bff6a; }
.status-vencida { background: #331111; color: #ff8a8a; }
.status-deshabilitada { background: #2a2a2a; color: var(--text-dim); }
.admin-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; background: var(--panel); padding: 14px; border-radius: var(--radius); }
.admin-form input, .admin-form select { background: #1a1a1a; border: 1px solid #262626; color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn { background: #1d1d1d; border: none; color: var(--text); padding: 4px 8px; border-radius: 6px; font-size: 11px; cursor: pointer; }
.mini-btn.danger { color: var(--danger); }
.mini-btn.accent { color: var(--accent); }

[hidden] { display: none !important; }
