:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-elev2: #18212d;
  --line: #223041;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #35d07f;      /* live / ok */
  --accent-dim: #1c6b45;
  --warn: #f0b429;
  --bad: #f0506e;
  --brand: #5aa9ff;
  --tg: #2aabee;          /* azul Telegram */
  --tg2: #2196d6;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #16324a33, transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0e141ccc, #0b0f14cc);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand .dot { color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .85rem; font-family: var(--mono); }

/* ---------- Live badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--mono); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; padding: .3rem .6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.live { color: var(--accent); border-color: var(--accent-dim); }
.badge.live .pip { background: var(--accent); box-shadow: 0 0 0 0 #35d07f88; animation: pulse 1.8s infinite; }
.badge.down { color: var(--bad); border-color: #6b1c2c; }
.badge.down .pip { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #35d07f66; } 70% { box-shadow: 0 0 0 7px #35d07f00; } 100% { box-shadow: 0 0 0 0 #35d07f00; } }

/* ---------- Buttons / inputs ---------- */
button, .btn {
  font: inherit; cursor: pointer; color: var(--text);
  background: var(--bg-elev2); border: 1px solid var(--line);
  padding: .6rem .95rem; border-radius: 10px; transition: border-color .15s, transform .05s;
}
button:hover { border-color: var(--brand); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent-dim); border-color: var(--accent); color: #eafff3; font-weight: 600; }
input {
  font: inherit; color: var(--text); background: #0c1219;
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; width: 100%;
}
input:focus { outline: none; border-color: var(--brand); }
label { display: block; font-size: .78rem; color: var(--muted); margin: 0 0 .35rem; }

/* ---------- Login card ---------- */
.center { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 1.5rem; }
.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.6rem; width: 100%; max-width: 360px;
  box-shadow: 0 24px 60px -30px #000;
}
.card h1 { margin: 0 0 .25rem; font-size: 1.3rem; letter-spacing: -0.02em; }
.card .sub { color: var(--muted); font-size: .85rem; margin: 0 0 1.2rem; }
.field { margin-bottom: .9rem; }
.err { color: var(--bad); font-size: .82rem; min-height: 1.1em; margin-top: .2rem; }
.hint { color: var(--muted); font-size: .75rem; margin-top: 1rem; font-family: var(--mono); line-height: 1.5; }

/* ---------- Home pública (entrar por código + promo) ---------- */
.home { max-width: 680px; margin: 0 auto; padding: 2.4rem 1.25rem 2rem; }
.home-card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.6rem 1.5rem; box-shadow: 0 24px 60px -30px #000;
}
.home-card h1 { margin: 0 0 .3rem; font-size: 1.4rem; letter-spacing: -0.02em; }
.home-card .sub { color: var(--muted); font-size: .9rem; margin: 0 0 1.1rem; line-height: 1.45; }
.code-form { display: flex; gap: .5rem; }
.code-input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 1.1rem; letter-spacing: .14em; text-transform: uppercase; text-align: center; }
.code-form .btn { flex: none; white-space: nowrap; font-weight: 650; }
.home-card .err { margin-top: .5rem; }
.home-card .hint { margin-top: .9rem; }

/* ---------- Player ---------- */
.stage { max-width: 1100px; margin: 1.25rem auto; padding: 0 1.25rem; }
.videowrap {
  position: relative; background: #000; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9;
}
video { width: 100%; height: 100%; display: block; background: #000; }
.playerbar { display: flex; align-items: center; gap: .75rem; margin-top: .9rem; color: var(--muted); font-size: .85rem; }
.playerbar .ch { font-family: var(--mono); color: var(--text); }

/* ---------- Admin ---------- */
.grid { max-width: 1100px; margin: 1.25rem auto; padding: 0 1.25rem; display: grid; gap: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.tile { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.tile .k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.tile .v { font-family: var(--mono); font-size: 1.9rem; font-weight: 600; margin-top: .35rem; letter-spacing: -0.02em; }
.tile .v small { font-size: .9rem; color: var(--muted); font-weight: 400; }

.panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.panel h2 { margin: 0 0 1rem; font-size: 1rem; letter-spacing: -0.01em; }
.switcher { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.switcher .field { flex: 1; min-width: 160px; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
td.num { font-family: var(--mono); text-align: right; }
.tag { font-family: var(--mono); font-size: .72rem; padding: .15rem .5rem; border-radius: 6px; border: 1px solid var(--line); }
.tag.on { color: var(--accent); border-color: var(--accent-dim); }
.tag.off { color: var(--muted); }
.empty { color: var(--muted); padding: 1rem .5rem; font-size: .88rem; }
.toast { color: var(--accent); font-size: .82rem; min-height: 1.1em; }

/* Copiar URL (player) */
.copyrow { display: flex; gap: .5rem; }
.copyrow input { flex: 1; font-family: var(--mono); font-size: .82rem; }

/* Barra fija bajo el player: enlace para VLC / apps de IPTV, siempre visible */
.vlc-help { text-align: center; margin: 1.1rem auto 0; max-width: 640px; }
.vlc-help-title { font-weight: 600; font-size: .95rem; margin: 0; }
.vlc-help-sub { color: var(--muted); font-size: .85rem; margin: .3rem 0 .7rem; }
.vlc-help-row { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.vlc-help-row .vlc-url { margin-top: 0; }

/* ---------- Promo: bot de compra + canal de Telegram ---------- */
.promo { max-width: 640px; margin: 1.7rem auto 2.6rem; text-align: center; }
.promo::before {
  content: ""; display: block; width: 46px; height: 2px; margin: 0 auto 1.2rem; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.promo-eyebrow {
  margin: 0 0 .3rem; font-family: var(--mono); font-size: .68rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .16em;
}
.promo-title { margin: 0 0 1.05rem; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.promo-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; text-align: left; }
@media (max-width: 560px) { .promo-cards { grid-template-columns: 1fr; } }

.promo-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: .85rem;
  padding: 1rem 1.05rem; border-radius: 14px; text-decoration: none; color: var(--text);
  background: linear-gradient(160deg, var(--bg-elev), #0f151d);
  border: 1px solid var(--line); position: relative; overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.promo-card:hover { transform: translateY(-2px); border-color: var(--tg); box-shadow: 0 18px 36px -22px #000, 0 0 0 1px #2aabee22; }
.promo-card:hover, .promo-card:focus-visible { text-decoration: none; }  /* anula el subrayado global de a:hover */
.promo-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.promo-card:active { transform: translateY(0); }

.promo-head { display: flex; align-items: center; gap: .7rem; }
.promo-ic { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.promo-ic svg { width: 23px; height: 23px; display: block; }
.promo-txt { min-width: 0; }
.promo-card-title { display: block; font-weight: 650; font-size: .96rem; letter-spacing: -0.01em; }
.promo-card-sub { display: block; margin-top: .18rem; color: var(--muted); font-size: .8rem; line-height: 1.35; }

.promo-foot { display: flex; align-items: center; justify-content: space-between; gap: .55rem; flex-wrap: wrap; }
.promo-handle { font-family: var(--mono); font-size: .82rem; color: var(--tg); letter-spacing: -0.01em; }
.promo-cta {
  display: inline-flex; align-items: center;
  font-size: .82rem; font-weight: 600; padding: .42rem .85rem; border-radius: 999px;
  transition: filter .15s ease, border-color .15s ease, color .15s ease;
}
.promo-card:hover .promo-cta { filter: brightness(1.07); }

/* Bot = acción principal (dinero): chip e icono en azul Telegram, CTA sólida. */
.promo-card--bot { border-color: #1e4a63; background: linear-gradient(160deg, #12283a, #0f1a25); }
.promo-card--bot .promo-ic { background: linear-gradient(160deg, var(--tg), var(--tg2)); box-shadow: 0 8px 20px -8px #2aabeeaa; }
.promo-card--bot .promo-ic svg { fill: #f7fcff; }
.promo-card--bot .promo-cta { background: linear-gradient(160deg, var(--tg), var(--tg2)); color: #f2fbff; }

/* Canal = secundaria: chip neutro con icono azul, CTA de contorno. */
.promo-card--ch .promo-ic { background: var(--bg-elev2); border: 1px solid var(--line); }
.promo-card--ch .promo-ic svg { fill: var(--tg); }
.promo-card--ch .promo-cta { background: transparent; border: 1px solid var(--line); color: var(--text); }
.promo-card--ch:hover .promo-cta { border-color: var(--tg); color: var(--tg); }

@media (prefers-reduced-motion: reduce) {
  .promo-card { transition: border-color .15s ease; }
  .promo-card:hover { transform: none; }
}

/* Capa de entrada sobre el video: solo aparece si el navegador bloquea el sonido.
   Un clic desbloquea el audio (gesto del usuario) y la capa desaparece. */
.gate {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center; padding: 1rem;
  width: 100%; height: 100%; margin: 0; border: 0;
  background: radial-gradient(120% 120% at 50% 42%, #00000066, #000000c2);
  -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
  color: var(--text); font: inherit; cursor: pointer;
  animation: gateIn .28s ease;
}
.gate.gone { display: none; }
.gate-inner { display: grid; justify-items: center; gap: .8rem; transform: translateY(-2%); pointer-events: none; }
.gate-icon {
  width: 82px; height: 82px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-dim); border: 2px solid var(--accent);
  box-shadow: 0 14px 34px -10px #000, 0 0 0 0 #35d07f55;
  transition: transform .15s ease, filter .15s ease;
  animation: gatePulse 2.6s ease-out infinite;
}
.gate-icon svg { width: 34px; height: 34px; fill: #eafff3; display: block; }
.gate:hover .gate-icon, .gate:focus-visible .gate-icon { transform: scale(1.06); filter: brightness(1.08); }
.gate:active .gate-icon { transform: scale(.97); }
.gate-label { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.gate-sub { color: var(--muted); font-size: .84rem; }
.gate:focus { outline: none; }
.gate:focus-visible { outline: 2px solid var(--brand); outline-offset: -5px; }
@keyframes gateIn { from { opacity: 0; } }
@keyframes gatePulse {
  0%   { box-shadow: 0 14px 34px -10px #000, 0 0 0 0 #35d07f55; }
  70%  { box-shadow: 0 14px 34px -10px #000, 0 0 0 16px #35d07f00; }
  100% { box-shadow: 0 14px 34px -10px #000, 0 0 0 0 #35d07f00; }
}
@media (prefers-reduced-motion: reduce) {
  .gate { animation: none; }
  .gate-icon { animation: none; }
}

/* Tabla de usuarios: controles compactos */
td button, .switcher select, select.mini {
  padding: .35rem .6rem; font-size: .8rem; border-radius: 8px;
}
select { font: inherit; color: var(--text); background: #0c1219; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; }
select.mini { padding: .35rem .5rem; }
td button { margin: .1rem .1rem; }
button.danger { border-color: #6b1c2c; color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.switcher .field select { width: 100%; }

/* Overlay de carga/reconexión sobre el video: transitorio (arranque, cambio de canal, red).
   A propósito discreto, sin mensajes de error: solo un spinner + texto neutro. */
.loading { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .8rem; background: #0009; backdrop-filter: blur(2px); }
.loading.gone { display: none; }
.loading .spinner { width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid #ffffff2e; border-top-color: var(--accent); animation: spin .9s linear infinite; }
.loading .loading-txt { color: var(--muted); font-size: .88rem; letter-spacing: .01em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading .spinner { animation-duration: 2.2s; } }

/* Overlay de aviso sobre el video (evento no empezado / finalizado / en uso) */
.notice { position: absolute; inset: 0; display: grid; place-items: center; background: #000a; backdrop-filter: blur(2px); z-index: 2; padding: 1rem; }
.notice.gone { display: none; }
.notice-box { text-align: center; max-width: 90%; }
.notice-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.notice-sub { color: var(--muted); font-size: .9rem; margin-top: .45rem; line-height: 1.5; }
/* Aviso "ver por VLC" (canal no reproducible por navegador) */
.vlc-url { font-family: var(--mono); font-size: .82rem; word-break: break-all; color: var(--text); background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 8px; padding: .2rem .45rem; display: inline-block; margin-top: .5rem; }
.vlc-copy { font-size: .82rem; padding: .3rem .7rem; margin-left: .4rem; }
