:root {
  color-scheme: dark;
  --bg: #12160f;
  --panel: #1b2117;
  --panel-2: #232b1e;
  --line: #333d2b;
  --text: #edf1e6;
  --muted: #a1ab94;
  --accent: #a7cf6a;
  --accent-ink: #18200f;
  --danger: #e5695c;
  --warn: #e7b755;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1rem; }
.muted, .address { color: var(--muted); font-size: .85rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem .5rem; max-width: 1400px; margin: 0 auto; }
main { display: grid; gap: .75rem; padding: .5rem 1.25rem 1.25rem; max-width: 1400px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; min-height: 2rem; margin-bottom: .75rem; }

.btn { font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .85rem; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: #ffd3cd; border-color: #7b3a33; background: #3a1f1b; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn-small { padding: .2rem .5rem; font-size: .8rem; font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem 1.5rem; }
.state { display: flex; align-items: center; gap: .7rem; }
.state strong { display: block; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--accent); }
.dot.off { background: var(--danger); }
.dot.busy { background: var(--warn); }
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .85rem; min-width: 0; }
.stat span { display: block; color: var(--muted); font-size: .8rem; }
.stat strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.columns { display: grid; grid-template-columns: minmax(320px, 2fr) minmax(0, 3fr); gap: .75rem; }
.players, .console { display: flex; flex-direction: column; height: 620px; }
.switch { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.add-player { display: flex; gap: .5rem; margin-bottom: .75rem; }
input[type=text], input[type=password] { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .65rem; width: 100%; min-width: 0; }
.player-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.player { padding: .6rem .25rem; border-top: 1px solid var(--line); }
.player:first-child { border-top: 0; }
.player-main { display: flex; align-items: center; gap: .7rem; }
.player img { width: 36px; height: 36px; image-rendering: pixelated; border-radius: 3px; flex: none; }
.player.offline img { filter: grayscale(.8); opacity: .65; }
.player-info { min-width: 0; flex: 1; }
.player-name { font-weight: 600; overflow-wrap: anywhere; }
.player-meta { color: var(--muted); font-size: .8rem; }
.player-meta.is-online { color: var(--accent); }
.badge { display: inline-block; margin-left: .35rem; padding: 0 .35rem; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: .7rem; font-weight: 600; vertical-align: 1px; }
.badge.op { color: var(--warn); border-color: #6d5726; }
.badge.ban { color: var(--danger); border-color: #7b3a33; }
.player-actions { display: flex; flex-wrap: wrap; gap: .3rem; margin: .45rem 0 0 calc(36px + .7rem); }
.empty { color: var(--muted); padding: 1.5rem .25rem; text-align: center; }

.log { flex: 1; overflow-y: auto; background: #0c0f0a; border: 1px solid var(--line); border-radius: 6px; padding: .6rem .7rem; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; min-height: 0; }
.log .warn { color: var(--warn); }
.log .error { color: var(--danger); }
.log .chat { color: #cfe9a5; }
.log .join { color: var(--accent); }
.log .input { color: #fff; font-weight: 700; margin-top: .3rem; }
.log .output { color: #b9d7ea; }
.command-form { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; }
.command-form > span { color: var(--muted); font: 600 15px var(--mono); }
.command-form input { font-family: var(--mono); }

.backups .panel-head { margin-bottom: .5rem; }
.backup-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.backup { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .75rem; padding: .55rem .25rem; border-top: 1px solid var(--line); }
.backup-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.backup-meta { color: var(--muted); font-size: .8rem; }

.backup-result { font-size: .85rem; font-weight: 600; }
.backup-result.good, .log-entry .good { color: var(--accent); }
.backup-result.bad, .log-entry .bad { color: var(--danger); }
.backup-log { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.backup-log summary { cursor: pointer; font-weight: 600; }
.log-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 360px; overflow-y: auto; }
.log-entry { padding: .5rem .25rem; border-top: 1px solid var(--line); }
.log-entry:first-child { border-top: 0; }
.log-entry-head { display: flex; flex-wrap: wrap; gap: .1rem .6rem; font-size: .9rem; }
.log-entry-head strong { font-weight: 600; }
.log-entry-message { overflow-wrap: anywhere; font-size: .85rem; }
.log-steps { margin: .25rem 0 0; padding: 0; list-style: none; color: var(--muted); font: 12px/1.5 var(--mono); overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); max-width: calc(100% - 2rem); background: var(--panel-2); border: 1px solid var(--muted); border-radius: 6px; padding: .55rem .9rem; box-shadow: 0 6px 20px #0008; }
.toast.bad { border-color: var(--danger); }
dialog { color: var(--text); background: var(--panel); border: 1px solid var(--muted); border-radius: 8px; padding: 1.25rem; max-width: min(420px, calc(100% - 2rem)); }
dialog::backdrop { background: #000a; }
dialog .buttons { justify-content: flex-end; margin-top: 1rem; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(340px, 100%); display: grid; gap: .6rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1.5rem; }
.login-card h1 { margin-bottom: .5rem; }
.form-error { color: var(--danger); font-size: .9rem; }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .columns { grid-template-columns: minmax(0, 1fr); }
  .players { height: auto; max-height: 520px; }
  .console { height: 560px; }
}
@media (max-width: 520px) {
  .topbar, main { padding-left: 16px; padding-right: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .buttons .btn { flex: 1 1 40%; }
  .controls .buttons { width: 100%; }
}
