:root {
  --bg: #070917;
  --bg-2: #0c0e24;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.10);
  --text: #e9ecff;
  --muted: rgba(233, 236, 255, 0.55);
  --accent: #7c5cff;
  --accent-2: #33d6a6;
  --danger: #ff5d6c;
  --warn: #ffb020;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar siempre: .app y .login-wrap definen display,
   y sin esto las dos vistas se apilaban en la misma pagina. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(900px 520px at 105% 5%, rgba(51, 214, 166, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 32px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.5px;
}

.login-card .muted { margin: 0 0 12px; }

label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 8px;
}

input, select, textarea {
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(124, 92, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

button.primary {
  margin-top: 16px;
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #5a3ce0);
  color: #fff;
  font-weight: 600;
  transition: transform 0.12s ease, filter 0.12s ease;
}

button.primary:hover { filter: brightness(1.1); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: 0.55; cursor: not-allowed; }

button.ghost {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

button.ghost:hover { background: var(--panel-strong); }
button.danger { color: var(--danger); border-color: rgba(255, 93, 108, 0.35); }
button.small { padding: 6px 10px; font-size: 12px; }

.error { color: var(--danger); min-height: 18px; margin: 6px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- app shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: rgba(7, 9, 23, 0.65);
  backdrop-filter: blur(14px);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: var(--panel); color: var(--text); }

.nav-item.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.30), rgba(124, 92, 255, 0.10));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.35);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content {
  padding: 28px 32px 60px;
  max-width: 1400px;
  width: 100%;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.view-head h2 { margin: 0; font-size: 22px; }
h3 { margin: 28px 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- tables ---------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--panel);
}

table { width: 100%; border-collapse: collapse; min-width: 640px; }

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge.ok { background: rgba(51, 214, 166, 0.16); color: var(--accent-2); }
.badge.off { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.badge.admin { background: rgba(124, 92, 255, 0.20); color: #c3b4ff; }
.badge.warn { background: rgba(255, 176, 32, 0.16); color: var(--warn); }
.badge.bad { background: rgba(255, 93, 108, 0.16); color: var(--danger); }

.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(51, 214, 166, 0.6);
}
.live-dot.on {
  background: var(--accent-2);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(51, 214, 166, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(51, 214, 166, 0); }
  100% { box-shadow: 0 0 0 0 rgba(51, 214, 166, 0); }
}

.bar {
  position: relative;
  height: 7px;
  min-width: 90px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}

.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ---------- games ---------- */
.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.game-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-cover {
  height: 150px;
  background: rgba(0, 0, 0, 0.35) center/cover no-repeat;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.game-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.game-body h4 { margin: 0; font-size: 16px; }
.game-body .slug { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.game-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.versions { margin: 6px 0 0; padding-left: 16px; color: var(--muted); font-size: 12px; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 12, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #14162e, #0b0d1e);
  box-shadow: var(--shadow);
  padding: 20px;
}

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

.modal-card h3 { margin: 0; font-size: 17px; color: var(--text); }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-top: 10px;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 80;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #161933;
  box-shadow: var(--shadow);
  max-width: 380px;
}

.toast.ok { border-color: rgba(51, 214, 166, 0.45); }
.toast.bad { border-color: rgba(255, 93, 108, 0.45); }

code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar-foot { margin: 0; }
  nav { flex-direction: row; }
  .content { padding: 20px 16px 60px; }
}
