:root {
  /* Paleta acorde al logo NSS: azul oscuro profundo + azul eléctrico + plateado */
  --bg: #060e22;
  --card-header-1: #123a8c;
  --card-header-2: #2f6fed;
  --card-bg: #101f3d;
  --text: #eef3fb;
  --muted: #93a5c9;
  --online: #22c55e;
  --reconnecting: #f5a623;
  --offline: #ef4444;
  --starting: #64748b;
  --glow: #38bdf8;
  --silver-1: #e4e9f3;
  --silver-2: #a9b6cf;
}

* { box-sizing: border-box; }

/* Clase genérica de ocultar — antes solo existía ".modal.hidden", por lo que
   la pantalla de login y el dashboard (que no son ".modal") no se ocultaban
   nunca y quedaban los dos visibles al mismo tiempo. */
.hidden { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(ellipse at top, #0e1e42 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-logo {
  width: 480px;
  max-width: 85vw;
  height: auto;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 24px rgba(56,189,248,0.45));
}

.topbar {
  position: relative;
}

.topbar-logo {
  position: absolute;
  top: 12px;
  left: 24px;
  width: 130px;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(56,189,248,0.4));
}

@media (max-width: 900px) {
  .topbar-logo {
    position: static;
    display: block;
    margin: 0 auto 10px;
  }
}

.login-box {
  background: var(--card-bg);
  border: 1px solid rgba(56,189,248,0.2);
  border-radius: 12px;
  padding: 32px 28px;
  width: min(360px, 100%);
  text-align: center;
  box-shadow: 0 0 40px rgba(56,189,248,0.12), 0 8px 30px rgba(0,0,0,0.45);
}

.login-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.login-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.login-box label {
  display: block;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.login-box input {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid #3a4a75;
  background: #16223f;
  color: var(--text);
  font-size: 14px;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
}

.login-error {
  background: rgba(229,72,77,0.15);
  color: #ff9a9d;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 12px;
  text-align: left;
}

.whoami {
  color: var(--muted);
  font-size: 13px;
  align-self: center;
  padding: 0 4px;
}

.user-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.user-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 14px;
}

.user-list button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
}

.user-action {
  color: var(--glow);
  margin-right: 10px;
}

.user-action-danger {
  color: var(--offline);
}

.new-user-form {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  margin-top: 4px;
}

.topbar {
  text-align: center;
  padding: 20px 16px 10px;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.status-line {
  color: var(--muted);
  font-size: 13px;
  background: rgba(255,255,255,0.06);
  display: inline-block;
  padding: 4px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
}

.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, var(--card-header-1), var(--card-header-2));
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--silver-1), var(--silver-2));
  color: #0b1730;
}

.grid {
  padding: 8px 24px 40px;
}

.group-section {
  margin-bottom: 30px;
}

.group-section:last-child {
  margin-bottom: 0;
}

.group-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(56,189,248,0.25);
}

.group-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--silver-1);
}

.group-count {
  color: var(--muted);
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.card:hover { transform: translateY(-2px); }

.card-header {
  background: linear-gradient(135deg, var(--card-header-1), var(--card-header-2));
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--starting);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.dot.online { background: var(--online); }
.dot.reconnecting { background: var(--reconnecting); }
.dot.offline, .dot.error { background: var(--offline); }
.dot.paused { background: var(--starting); }

.card-paused {
  opacity: 0.55;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.15);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 5px;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.12);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0d1730;
  display: block;
}

.card-body {
  padding: 8px 10px 10px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-body .row {
  display: flex;
  justify-content: space-between;
}

.card-body .row span:last-child {
  color: var(--text);
  font-weight: 500;
}

.card-error {
  color: var(--offline);
  font-size: 11px;
  padding: 0 10px 8px;
}

/* ---------- Modales ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px 24px;
  width: min(420px, 92vw);
}

.modal-box label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.modal-box input, .modal-box select {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #3a4a75;
  background: #16223f;
  color: var(--text);
}

.field-hint {
  margin: -6px 0 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.field-hint code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--silver-1);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.modal-live { width: min(820px, 94vw); }

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

#liveVideo {
  width: 100%;
  border-radius: 8px;
  background: #000;
}

.live-message {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
}

.live-message.error {
  background: rgba(229,72,77,0.15);
  color: #ff9a9d;
}

.live-stats {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
