:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #9aa8bc;
  --accent: #5b9cff;
  --ok: #3dd68c;
  --bad: #ff6b6b;
  --warn: #ffc857;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.page { padding: 1.25rem 1rem 2rem; }

.container { max-width: 1200px; margin: 0 auto; }

.page__header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page__title { margin: 0 0 0.25rem; font-size: 1.75rem; }

.page__lead { margin: 0; color: var(--muted); }

.admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

button, .btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font: inherit;
}

button:hover, .btn:hover { border-color: var(--accent); }

.btn-primary { background: #1f4b99; border-color: #2f66c4; }

.btn-danger { background: #5a1f1f; border-color: #8a3030; }

.btn-sm { font-size: 0.875rem; padding: 0.35rem 0.65rem; }

.admin-status { color: var(--muted); margin: 0 0 1rem; }

.wallet-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.wallet-card.error {
  border-color: var(--bad);
  color: #ffd0d0;
}

.stats-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.wallet-panel--redis {
  grid-column: 1 / -1;
}

@media (min-width: 900px) {
  .wallet-panel--redis {
    grid-column: span 2;
  }
}

.wallet-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.wallet-panel h2, .wallet-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.stats-accordion {
  padding: 0;
  overflow: hidden;
}

.container > .stats-accordion {
  margin-bottom: 1rem;
}

.stats-accordion > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.9rem 1rem;
  cursor: pointer;
  user-select: none;
  font-size: 1.05rem;
  font-weight: 600;
}

.stats-accordion > summary::-webkit-details-marker {
  display: none;
}

.stats-accordion > summary::after {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.stats-accordion[open] > summary {
  border-bottom: 1px solid var(--border);
}

.stats-accordion[open] > summary::after {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}

.stats-accordion__body {
  padding: 1rem;
}

.stats-accordion__body > :first-child {
  margin-top: 0;
}

.stats-subtitle {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.wallet-panel .stats-data-heading {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  color: var(--text);
  font-weight: 600;
}

.wallet-panel--redis .stats-data-heading:not(:first-child) {
  margin-top: 1.25rem;
}

.stats-data-actions {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.stats-item { margin: 0; }

.stats-item dt {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-item dd {
  margin: 0.1rem 0 0;
  font-variant-numeric: tabular-nums;
}

.stats-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

.stats-badge--ok { color: var(--ok); border-color: #2a7a55; }

.stats-badge--bad { color: var(--bad); border-color: #8a3030; }

.stats-note {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stats-note code {
  background: #0b1018;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.stats-table-wrap { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.stats-table th, .stats-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  text-align: left;
}

.stats-table th { color: var(--muted); font-weight: 600; }

.admin-form label {
  display: block;
  margin: 0.5rem 0 0.2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-form input {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1018;
  color: var(--text);
  font: inherit;
}

.stats-form-submit { margin-top: 0.75rem; width: 100%; }

.maintenance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.shutdown-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.shutdown-row input {
  flex: 1 1 10rem;
  min-width: 8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
}

.shutdown-row .btn-danger {
  flex: 0 0 auto;
}

#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

#login-overlay[hidden] { display: none; }

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.login-card h2 { margin: 0 0 0.5rem; }

.login-card p { margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; }

.stats-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
}

.stats-checkbox input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.maintenance-layout {
  margin-top: 1rem;
}

.maint-desc {
  margin: 0.5rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 2.5rem;
}

.maint-fields {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.maint-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.maint-field input,
.maint-field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
}

.maint-tier-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.maint-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.maint-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.maint-result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}

.maint-result--ok {
  border-color: rgba(61, 214, 140, 0.35);
}

.maint-result--error {
  border-color: rgba(255, 107, 107, 0.45);
  color: var(--bad);
}

.maint-custom-tier {
  margin-top: 0.35rem;
}

.maint-info {
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.25);
  font-size: 0.9rem;
  color: var(--text);
}

.vh-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0.75rem 0;
}

.vh-remove-toggle {
  margin: 0;
}

.vh-table-wrap {
  max-height: 360px;
  overflow: auto;
}

#voxel-history-panel input[type="datetime-local"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  padding: 1rem;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.15rem 1.25rem 1.35rem;
}

.modal-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-card__header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.player-edit-privileges {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.player-edit-privileges .stats-checkbox {
  margin: 0.35rem 0;
}

.stats-table .btn-sm {
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
}
