:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f252d;
  --border: #2a313b;
  --text: #e6e9ee;
  --muted: #8a94a3;
  --accent: #4caf50;
  --accent-2: #3d8f41;
  --danger: #e5534b;
  --warn: #d4a72c;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
a { color: #6cb6ff; }
code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
h3 { margin: 0 0 12px; font-size: 15px; }

.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo { color: var(--accent); font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.warn { border-color: var(--warn); margin-bottom: 16px; }
.card.warn p { margin: 6px 0 10px; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }

.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

input, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; margin-bottom: 12px; color: var(--muted); }
label input { margin-top: 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login-card .brand { margin-bottom: 8px; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--surface-2); }
.badge { background: var(--surface-2); border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.tab.active .badge { background: var(--border); }
.content { max-width: 1200px; margin: 0 auto; padding: 20px; }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }

/* Overview */
.server-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.state { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.dot.running { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.starting, .dot.stopping { background: var(--warn); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat .value { font-size: 24px; font-weight: 700; }
.stat .sub { color: var(--muted); font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.chart canvas { width: 100%; display: block; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* Console */
.console-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.console {
  margin: 0; height: calc(100vh - 230px); min-height: 300px; overflow: auto; background: #0a0c0f;
  border-radius: 8px; padding: 12px; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word;
}
.console .warn { color: var(--warn); }
.console .err { color: var(--danger); }
.console .panel { color: #6cb6ff; }
.console .cmd { color: var(--accent); }
.command { display: flex; align-items: center; gap: 8px; }
.command .prompt { font-family: var(--mono); color: var(--accent); }
.command input { font-family: var(--mono); }

/* Players */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.player-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.player-head img { width: 40px; height: 40px; border-radius: 6px; image-rendering: pixelated; background: var(--surface-2); }
.player-name { font-weight: 700; font-size: 16px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; background: var(--surface-2); border-radius: 4px; padding: 1px 6px; color: var(--muted); }
.tag.on { color: var(--accent); }
.player-info { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.player-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Files */
.files { display: grid; grid-template-columns: 260px 1fr; gap: 12px; }
.file-list { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.file-list button { text-align: left; background: none; border: 0; color: var(--text); font: inherit; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.file-list button:hover { background: var(--surface-2); }
.file-list button.active { background: var(--surface-2); color: var(--accent); }
.file-list button.missing { color: var(--muted); }
.editor { display: flex; flex-direction: column; gap: 10px; }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.editor textarea { min-height: 60vh; resize: vertical; font: 12.5px/1.5 var(--mono); tab-size: 2; }
.editor p { margin: 0; }

/* Backups */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table td { vertical-align: middle; }
.secret { font-size: 15px; letter-spacing: .08em; user-select: all; display: inline-block; padding: 6px 10px; }
#twofa-card p { margin: 0 0 10px; }

/* Settings */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--surface-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px;
  transition: .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { border-color: var(--danger); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .content { padding: 16px; }
  .files { grid-template-columns: 1fr; }
  .players { grid-template-columns: 1fr; }
}
