:root {
  --talgo-red: #d71920;
  --talgo-red-dark: #9f1117;
  --dark: #171717;
  --soft: #f5f5f5;
  --line: #e5e5e5;
  --white: #fff;
  --muted: #666;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--soft);
  color: var(--dark);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.25), transparent 30%),
    linear-gradient(135deg, var(--talgo-red), #4d0508);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--white);
  padding: 36px;
  border-radius: 22px;
  box-shadow: 0 25px 70px rgba(0,0,0,.28);
  border-top: 8px solid var(--talgo-red);
}

.logo-container {
  text-align: center;
  margin-bottom: 24px;
  padding: 20px;
}
.logo {
  height: 60px;
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(215,25,32,.15));
}
.topbar-logo {
  height: 48px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(215,25,32,.1));
}

h1 { margin: 8px 0 8px; font-size: 32px; }
h2 { margin-top: 0; }
p { color: var(--muted); }

input {
  width: 100%;
  padding: 14px 15px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  outline-color: var(--talgo-red);
}

select, textarea {
  width: 100%;
  padding: 14px 15px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline-color: var(--talgo-red);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

label { display:block; font-weight: 700; margin-top: 12px; }

button, .btn {
  display: inline-block;
  border: 0;
  background: var(--talgo-red);
  color: white;
  padding: 13px 18px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  margin-top: 10px;
}
button:hover, .btn:hover { background: var(--talgo-red-dark); }
.btn-small {
  display: inline-block;
  border: 0;
  background: var(--talgo-red);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  margin: 0;
  font-size: 14px;
  line-height: 1.1;
}
.btn-small:hover { background: var(--talgo-red-dark); }

.btn-small.btn-secondary {
  background: #6366f1;
}
.btn-small.btn-secondary:hover {
  background: #4f46e5;
}

.btn-small.btn-danger {
  background: #ef4444;
}
.btn-small.btn-danger:hover {
  background: #dc2626;
}

.btn-guest {
  background: #0f766e;
}
.btn-guest:hover {
  background: #115e59;
}

.btn-live {
  background: #dc2626;
  color: #fff;
}
.btn-live:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: #6366f1;
}
.btn-secondary:hover {
  background: #4f46e5;
}

.btn-danger {
  background: #ef4444;
}
.btn-danger:hover {
  background: #dc2626;
}

.error-box {
  margin-top: 16px;
  color: var(--talgo-red);
  font-weight: 700;
}

.topbar {
  height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 5px solid var(--talgo-red);
  box-shadow: 0 8px 30px rgba(0,0,0,.05);
}
.brand { display:flex; gap:12px; align-items:center; font-weight:700; }
.brand-main { font-size: 28px; }
nav { display:flex; gap:16px; }
nav a { color: var(--dark); text-decoration:none; font-weight:700; }
nav a:hover { color: var(--talgo-red); }
nav a.active { color: var(--talgo-red); }

.admin-nav { flex-wrap: wrap; justify-content: flex-end; }

.hero-actions { display:flex; gap:12px; flex-wrap:wrap; }

.stats-grid {
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  margin-bottom: 18px;
}

.flash.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.container {
  max-width: 1180px;
  margin: 32px auto;
  padding: 0 20px;
}

.hero-admin, .live-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  margin-bottom:24px;
}

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

.audit-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.audit-grid > .card {
  min-width: 0;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  max-width: 1200px;
  margin: 0 auto 22px;
}

.dash-tile {
  aspect-ratio: 1.55 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(145deg, #ef4444, #b91c1c);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 18px 44px rgba(185, 28, 28, .28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 54px rgba(185, 28, 28, .34);
}

.dash-tile-icon {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  color: rgba(255,255,255,.95);
}

.dash-tile-icon svg {
  width: 60px;
  height: 60px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dash-tile-body {
  display: grid;
  gap: 6px;
}

.dash-tile-body h2 {
  margin: 0;
  font-size: clamp(17px, 1.8vw, 22px);
  color: #fff;
}

.dash-tile-body p {
  margin: 0;
  color: rgba(255,255,255,.88);
  font-weight: 700;
}

.section-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.section-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 55px rgba(0,0,0,.10);
  border-color: #d0d0d0;
}

.card, .player-card {
  background: var(--white);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 16px 45px rgba(0,0,0,.08);
  border-top: 5px solid var(--talgo-red);
}
.form-card,
.guest-card {
  width: 100%;
  max-width: none;
}
.wide { margin-top:22px; }

.action-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 48px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
}

.chip button {
  margin-top: 0;
  padding: 4px 8px;
  border-radius: 999px;
}

.search-info,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.search-results {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.search-result {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.search-result strong {
  display: block;
  margin-bottom: 3px;
}

.search-result small {
  color: var(--muted);
}

.search-result button {
  margin-top: 0;
  white-space: nowrap;
}

.guest-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.guest-summary h2 {
  margin-bottom: 6px;
}

.guest-summary p {
  margin: 0;
}

.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse: collapse; min-width: 0; }
th { text-align:left; background: var(--dark); color:white; padding:13px; }
td { border-bottom:1px solid var(--line); padding:13px; }

.pill {
  background:#eee;
  padding:5px 9px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
}
.live-pill {
  background: #dc2626 !important;
  color: #fff !important;
  animation: livePulse 1s steps(2, end) infinite;
}
@keyframes livePulse {
  0%, 49% {
    opacity: 1;
    box-shadow: 0 0 0 rgba(220, 38, 38, 0);
  }
  50%, 100% {
    opacity: 0.45;
    box-shadow: 0 0 18px rgba(220, 38, 38, 0.55);
  }
}
.ok { color:#16803a; font-weight:800; }
.bad { color:var(--talgo-red); font-weight:800; }

.stat-box {
  background: #fafafa;
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin:18px 0;
}
.stat-box strong { font-size:34px; color:var(--talgo-red); }
.stat-link {
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.stat-link:hover {
  transform: translateY(-2px);
  border-color: #c9c9c9;
  box-shadow: 0 14px 30px rgba(0,0,0,.08);
}
.prebox {
  max-height:220px;
  overflow:auto;
  background:#111;
  color:#eee;
  padding:14px;
  border-radius:12px;
  font-size:12px;
}
code { word-break: break-all; }

.player-container { max-width: 1050px; }
.player-shell { display: grid; gap: 18px; }
.player-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
.player-hero h1 {
  margin-bottom: 4px;
}
.player-hero p {
  margin: 0;
}
.player-frame {
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.player-frame iframe,
.player-frame video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.player-status {
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}
.notfound-page {
  min-height: 70vh;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 18px 0;
}
.notfound-wrap {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
  align-items: center;
}
.notfound-copy {
  padding-right: 12px;
}
.notfound-copy h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5vw, 56px);
}
.notfound-copy p {
  max-width: 520px;
  margin-bottom: 18px;
}
.notfound-art svg {
  width: 100%;
  height: auto;
  display: block;
}
.notfound-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: none;
}
.forbidden-page {
  min-height: 70vh;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 18px 0;
}
.forbidden-wrap {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
  align-items: center;
}
.forbidden-copy {
  width: 100%;
  text-align: left;
  display: grid;
  justify-items: start;
  gap: 12px;
}
.red-pill {
  background: #fee2e2;
  color: #b91c1c;
}
.forbidden-copy h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
}
.forbidden-copy p {
  margin: 0;
  max-width: 640px;
}
.forbidden-note {
  color: #7f1d1d;
  font-weight: 700;
}
.forbidden-signal {
  margin-top: 16px;
  display: grid;
  justify-items: center;
  gap: 0;
}
.forbidden-art {
  width: 100%;
}
.forbidden-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: none;
}
.signal-post {
  width: 18px;
  height: 160px;
  background: linear-gradient(180deg, #4b5563, #1f2937);
  border-radius: 999px;
}
.signal-head {
  margin-top: -6px;
  padding: 16px 18px;
  border-radius: 24px;
  background: #111827;
  display: flex;
  gap: 12px;
  border: 3px solid #374151;
}
.signal-light {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3f3f46;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
}
.signal-light.active {
  background: #ef4444;
  box-shadow: 0 0 16px rgba(239,68,68,.85), inset 0 0 0 2px rgba(255,255,255,.25);
}
.live-dot { color: var(--talgo-red); font-weight:900; }
video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  display:block;
}
.player-status {
  margin-top:14px;
  color: var(--muted);
  font-weight:700;
}

#passwordMessage {
  padding:12px 14px;
  border-radius:8px;
  background:#f0fdf4;
  border-left:4px solid #22c55e;
  font-weight:600;
  font-size:14px;
}

@media (max-width: 800px) {
  .grid-2, .hero-admin, .live-head, .stats-grid, .guest-summary { grid-template-columns:1fr; display:block; }
  .dash-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  nav { gap: 10px; }
  .search-result { flex-direction: column; align-items: flex-start; }
  .player-hero { display:block; }
  .notfound-wrap {
    display: flex;
    flex-direction: column;
  }
  .notfound-art {
    order: -1;
  }
  .notfound-copy {
    order: 1;
  }
  .notfound-page { min-height: auto; }
  .forbidden-wrap {
    display: flex;
    flex-direction: column;
  }
  .forbidden-art {
    order: -1;
  }
  .forbidden-copy {
    order: 1;
  }
  .forbidden-page { min-height: auto; }
}
