*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute must win over every display rule below.
   Browsers implement it as `[hidden] { display: none }` in the user-agent
   stylesheet, which any author `display:` rule overrides. Without this,
   the login view (`.login { display: flex }`) stays on screen after a
   successful sign-in, stacked above the dashboard. */
[hidden] { display: none !important; }

:root {
  --bg: #0e0e18;
  --bg-card: #16162a;
  --bg-sunken: #101020;
  --bg-surface: #1e1e35;
  --accent: #5eead4;
  --accent-dim: #2dd4bf;
  --accent-glow: rgba(94, 234, 212, .14);
  --text: #e6ecf5;
  --text-dim: #98a6bf;
  --muted: #64718c;
  --border: #272742;
  --border-soft: #1f1f36;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .9375rem; font-weight: 600;
  border: 2px solid transparent; cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, opacity .16s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #0b0b14; border-color: var(--accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-dim); }
.btn--danger { background: transparent; color: var(--red); border-color: rgba(248,113,113,.4); }
.btn--danger:hover:not(:disabled) { background: rgba(248,113,113,.12); border-color: var(--red); }
.btn--ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.btn--small { padding: 6px 12px; font-size: .8125rem; }
.btn--full { width: 100%; margin-top: 6px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login__card {
  width: 100%; max-width: 360px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login__mark { font-size: 2rem; text-align: center; }
.login__title { font-size: 1.25rem; font-weight: 800; text-align: center; letter-spacing: -.01em; }
.login__sub { text-align: center; color: var(--muted); font-size: .8125rem; margin-top: -10px; }
.login__error { color: var(--red); font-size: .8125rem; min-height: 1.2em; text-align: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.field input {
  padding: 10px 12px; font-family: var(--font); font-size: .9375rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border-soft);
  background: rgba(14,14,24,.9); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__mark { font-size: 1.5rem; }
.topbar__brand strong { display: block; font-size: 1rem; }
.topbar__sub { font-size: .75rem; color: var(--muted); }
.topbar__right { display: flex; align-items: center; gap: 8px; }

.pill {
  font-size: .75rem; font-weight: 700; letter-spacing: .04em;
  padding: 4px 12px; border-radius: 999px; text-transform: uppercase;
  border: 1px solid var(--border); color: var(--muted); background: var(--bg-sunken);
}
.pill--running { color: var(--green); border-color: rgba(74,222,128,.35); background: rgba(74,222,128,.1); }
.pill--stopped { color: var(--text-dim); }
.pill--busy { color: var(--amber); border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.1); }
.pill--error { color: var(--red); border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.1); }

/* ---------- layout ---------- */
.banner {
  margin: 16px 24px 0; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; border: 1px solid;
}
.banner--warn { color: var(--amber); border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.08); }
.banner--error { color: var(--red); border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.08); }

.grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px; padding: 24px; align-items: start;
}
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__title { font-size: .9375rem; font-weight: 700; margin-bottom: 16px; }
.card__head .card__title { margin-bottom: 0; }

/* ---------- power ---------- */
.power { display: flex; flex-direction: column; gap: 4px; }
.power__state { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 700; }
.power__msg { font-size: .8125rem; color: var(--amber); min-height: 1.2em; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot--running { background: var(--green); box-shadow: 0 0 10px rgba(74,222,128,.65); }
.dot--stopped { background: #4a5568; }
.dot--busy { background: var(--amber); animation: pulse 1s ease-in-out infinite; }
.dot--error { background: var(--red); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.power__actions { display: flex; gap: 10px; margin: 18px 0; }
.power__actions .btn { flex: 1; }

.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.meta dt { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.meta dd { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.players { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.players__label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.players__list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.players__list span { font-size: .8125rem; padding: 3px 10px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border); }

/* ---------- switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: var(--bg-sunken); border: 1px solid var(--border); position: relative; transition: background .18s, border-color .18s; }
.switch__thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .18s, background .18s; }
.switch input:checked + .switch__track { background: var(--accent-glow); border-color: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch__label { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; min-width: 26px; }

/* ---------- whitelist ---------- */
.add { display: flex; gap: 8px; }
.add input {
  flex: 1; min-width: 0; padding: 8px 12px;
  font-family: var(--font); font-size: .9375rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
}
.add input:focus { outline: none; border-color: var(--accent); }
.add__status { font-size: .8125rem; color: var(--text-dim); margin-top: 8px; min-height: 1.2em; }
.add__status--error { color: var(--red); }

.wlist { list-style: none; margin-top: 14px; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.wlist li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--border);
}
.wlist__name { font-weight: 600; font-size: .9375rem; }
.wlist__uuid { font-family: var(--mono); font-size: .6875rem; color: var(--muted); }
.wlist__remove {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 4px 6px; border-radius: 6px;
  transition: color .16s, background .16s;
}
.wlist__remove:hover { color: var(--red); background: rgba(248,113,113,.12); }
.wlist__empty { margin-top: 14px; font-size: .875rem; color: var(--muted); text-align: center; }

.foot { padding: 0 24px 32px; font-size: .8125rem; color: var(--muted); text-align: center; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--bg-card); border: 1px solid var(--accent); color: var(--accent);
  padding: 11px 22px; border-radius: var(--radius-sm); font-weight: 600; font-size: .875rem;
  opacity: 0; transition: all .26s ease; z-index: 200; pointer-events: none;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { border-color: var(--red); color: var(--red); }
