:root {
  --bg: #10120f;
  --bg-raised: #171a15;
  --bg-sunken: #0b0c0a;
  --line: #2a2f26;
  --line-soft: #21261e;
  --fg: #e6e8e1;
  --fg-muted: #8e968a;
  --accent: #8fae4f;
  --accent-dim: #5c7332;
  --danger: #c4593f;
  --ok: #6fae4f;
  --warn: #d0a53c;
  --radius: 6px;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

/* The UA stylesheet's [hidden] { display: none } loses against any author
   display rule — .gate below sets display: grid, which kept the login card
   on screen after a successful login and pushed the panel below the fold.
   Author-level + !important so toggling .hidden in JS always wins. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); margin: 0 0 0.9rem; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-sunken); padding: 0.1em 0.35em; border-radius: 3px; }
.muted { color: var(--fg-muted); }
.error { color: var(--danger); }
.hint { color: var(--fg-muted); font-size: 0.82rem; margin: 0.7rem 0 0; }

/* ---------- login gate ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.gate-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 24rem;
  text-align: center;
}
.gate-card h1 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.gate-card .btn { margin-top: 1.6rem; width: 100%; justify-content: center; }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand strong { display: block; font-size: 0.95rem; }
.brand .muted { font-size: 0.8rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fg-muted); flex: none; }
.dot.is-up { background: var(--ok); box-shadow: 0 0 0 3px rgb(111 174 79 / 0.18); }
.dot.is-down { background: var(--danger); box-shadow: 0 0 0 3px rgb(196 89 63 / 0.18); }
.dot.is-warn { background: var(--warn); box-shadow: 0 0 0 3px rgb(208 165 60 / 0.18); }
.who { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.who img { border-radius: 50%; }

.tabs { display: flex; gap: 0.15rem; padding: 0 1.25rem; border-bottom: 1px solid var(--line); background: var(--bg-raised); overflow-x: auto; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--fg-muted); padding: 0.7rem 0.9rem; font: inherit; font-size: 0.88rem;
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--fg); border-bottom-color: var(--accent); }

.panel { display: none; padding: 1.25rem; }
.panel.is-active { display: block; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1rem; align-items: start; }
.card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.card-wide { grid-column: 1 / -1; }

.kv { display: grid; grid-template-columns: minmax(6rem, auto) 1fr; gap: 0.4rem 1rem; margin: 0; font-size: 0.88rem; }
.kv dt { color: var(--fg-muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 0.85rem; word-break: break-word; }

.badge { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 99px; padding: 0.05em 0.55em; font-size: 0.75rem; color: var(--fg); }

/* ---------- controls ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--bg-sunken); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.45rem 0.85rem; font: inherit; font-size: 0.85rem;
  cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent-dim); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #f2f5ec; }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #14170f; }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: none; }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn-discord:hover { background: #4752c4; border-color: #4752c4; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.field { display: block; margin-bottom: 0.8rem; }
.field span { display: block; font-size: 0.78rem; color: var(--fg-muted); margin-bottom: 0.25rem; }
input[type="text"], input[type="number"], input[type="search"], textarea {
  width: 100%; background: var(--bg-sunken); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.45rem 0.6rem; font: inherit; font-size: 0.87rem;
}
textarea { font-family: var(--mono); font-size: 0.8rem; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
.check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--fg-muted); }
.check input { accent-color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; margin-bottom: 0.75rem; }
.toolbar input[type="search"] { flex: 1 1 12rem; max-width: 22rem; }

/* ---------- log ---------- */
.log {
  background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius);
  margin: 0; padding: 0.8rem 0.9rem;
  font-family: var(--mono); font-size: 0.78rem; line-height: 1.5;
  height: calc(100dvh - 15rem); min-height: 16rem;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.log-short { height: 18rem; }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th { text-align: left; font-weight: 500; color: var(--fg-muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); }
.table td { padding: 0.45rem 0.5rem 0.45rem 0; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); font-size: 0.82rem; }
.table tr:last-child td { border-bottom: 0; }

.rcon-form { display: flex; gap: 0.5rem; margin: 0.7rem 0; }
.rcon-form input { flex: 1; font-family: var(--mono); }
.cmd-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.78rem; }
td .btn-sm + .btn-sm { margin-left: 0.35rem; }
h2 .btn-sm { float: right; margin-top: -0.25rem; text-transform: none; letter-spacing: 0; }

.player-name { font-family: system-ui, sans-serif; font-size: 0.9rem; color: var(--fg); }
.uid { color: var(--fg-muted); font-size: 0.75rem; }
.current-scenario { margin: 0 0 1rem; }
.current-scenario code { font-size: 0.8rem; word-break: break-all; }

select {
  width: 100%; background: var(--bg-sunken); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.45rem 0.6rem; font: inherit; font-size: 0.87rem;
}
select:focus { outline: none; border-color: var(--accent-dim); }

dialog {
  background: var(--bg-raised); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; max-width: 26rem; width: 90vw;
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.dialog-body { padding: 1.3rem 1.4rem; }
.dialog-body h2 { margin-bottom: 0.3rem; }
.dialog-body .muted { font-family: var(--mono); font-size: 0.78rem; word-break: break-all; margin: 0 0 1rem; }
.confirm-detail { font-size: 0.88rem; margin: 0 0 0.6rem; }

/* Armed state of the two-step confirm button. */
.btn.is-armed {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: arm-pulse 1.1s ease-in-out infinite;
}
@keyframes arm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(196 89 63 / 0.5); }
  50%      { box-shadow: 0 0 0 5px rgb(196 89 63 / 0); }
}
@media (prefers-reduced-motion: reduce) {
  .btn.is-armed { animation: none; }
}

/* ---------- flash ---------- */
.flash {
  position: fixed; inset-inline: 0; top: 0; z-index: 20;
  padding: 0.65rem 1.25rem; font-size: 0.86rem;
  background: var(--accent-dim); color: #f4f7ec;
}
.flash.is-error { background: var(--danger); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .panel { padding: 0.9rem; }
}
