:root {
  --bg: #0f1419;
  --panel: #171e27;
  --fg: #e7ecf1;
  --muted: #8b9aab;
  --accent: #c4a35a;
  --up: #3d9a6a;
  --down: #b54a4a;
  --border: #2a3441;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #121820;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 650; letter-spacing: 0.04em; color: var(--fg); text-decoration: none; white-space: nowrap; }
.top nav {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.nav-email {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.muted { color: var(--muted); }
main { padding: 1.25rem; max-width: 960px; margin: 0 auto; width: 100%; }
.hero { padding: 3rem 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.75rem; color: var(--accent); }
.lede { color: var(--muted); max-width: 36rem; }
.panel h1 { margin-top: 0; margin-bottom: 0.35rem; font-size: clamp(1.35rem, 4vw, 1.75rem); }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sv-hostname {
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0.35rem 0 0.15rem;
  line-height: 1.35;
}
.sv-hostname .qc { font-weight: 650; }
.live-hint { margin: 0; font-size: 0.85rem; }
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card.is-polling { opacity: 0.92; }
.card-top { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.card-foot { margin-top: 0.65rem; font-size: 0.8rem; }
.badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.badge.up { background: color-mix(in srgb, var(--up) 25%, transparent); color: #8fdfb4; }
.badge.down { background: color-mix(in srgb, var(--down) 25%, transparent); color: #f0a0a0; }

/* Quake / CoD ^N color codes */
.qc { font-weight: 600; }
.qc0 { color: #000000; text-shadow: 0 0 1px #666; }
.qc1 { color: #ff2a2a; }
.qc2 { color: #33ff33; }
.qc3 { color: #ffff33; }
.qc4 { color: #3388ff; }
.qc5 { color: #33ffff; }
.qc6 { color: #ff33ff; }
.qc7 { color: #ffffff; }
.qc8 { color: #ff7f00; }
.qc9 { color: #999999; }

.status-box, .box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}
.actions-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}
.quick-actions {
  grid-column: 1 / -1;
}
.quick-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.quick-action-row form.inline { display: inline-block; }
.quick-action-row button { margin-top: 0; }
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.75rem 0 1.5rem;
}
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td { text-align: left; padding: 0.45rem 0.35rem; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.row-actions { white-space: nowrap; }
form.inline { display: inline; }
label { display: block; margin: 0.4rem 0; }
input, select, button {
  font: inherit;
  margin-top: 0.25rem;
}
input, select {
  width: 100%;
  max-width: 28rem;
  background: #10161d;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
}
button, .btn {
  display: inline-block;
  margin-top: 0.65rem;
  background: #243041;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button:disabled, button.is-busy {
  opacity: 0.65;
  cursor: wait;
}
button.danger { border-color: #6e3030; }
.btn-small {
  margin-top: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  text-decoration: none;
}
.btn-ghost {
  background: transparent;
  margin-left: 0.5rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.85rem 0;
}
.check input { width: auto; margin: 0; }
.rcon-hint { font-size: 0.9rem; }
.rcon-field .rcon-hint { margin-top: 0.35rem; }
code.rcon-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg);
}
.servers-table { min-width: 560px; }

.messages { list-style: none; padding: 0.75rem 1.25rem; margin: 0; }
.messages li { padding: 0.5rem 0.75rem; border-radius: 6px; margin-bottom: 0.35rem; background: #1c2733; }
.messages .error { background: #3a1f1f; }
.messages .success { background: #1c3228; }

.toast-host {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  background: #1c2733;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 0.92rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: #2f6b4c; background: #1c3228; }
.toast-error { border-color: #6e3030; background: #3a1f1f; }
.toast-info { border-color: #3a4654; }

@media (max-width: 640px) {
  .top { padding: 0.7rem 0.9rem; }
  main { padding: 0.9rem; }
  .hero { padding: 1.75rem 0; }
  .row-actions { white-space: normal; }
  .row-actions form.inline { display: inline-block; margin: 0.15rem 0.15rem 0.15rem 0; }
  .toast-host {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}
