:root {
  --bg: #0b1020;
  --panel: #121a2e;
  --panel-2: #18223a;
  --line: #24304d;
  --text: #e6ebf5;
  --muted: #8b97b3;
  --accent: #3b82f6;
  --accent-2: #1d4ed8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 10px;
  --mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--accent); }
code, pre { font-family: var(--mono); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: #fecaca; background: #7f1d1d55; border: 1px solid #b91c1c; padding: 8px 12px; border-radius: 8px; margin: 12px 0 0; }

/* ---------- Formularelemente ---------- */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
label input { color: var(--text); font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 550; cursor: pointer;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; white-space: nowrap;
}
.btn:hover { border-color: #3a4a70; background: #1e2a46; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: #fecaca; border-color: #7f1d1d; }
.btn.danger:hover { background: #7f1d1d; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-card .brand { margin-bottom: 22px; }
.qr { width: 220px; height: 220px; align-self: center; background: #fff; border-radius: 8px; padding: 6px; }
.secret { display: block; margin-top: 6px; word-break: break-all; padding: 8px; background: var(--bg); border-radius: 6px; user-select: all; }
.code-input { font-family: var(--mono); font-size: 22px !important; letter-spacing: 6px; text-align: center; }
details summary { cursor: pointer; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800;
}

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav button {
  text-align: left; font: inherit; color: var(--muted); background: none; border: 0;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
#nav button:hover { color: var(--text); background: var(--panel-2); }
#nav button.active { color: #fff; background: var(--accent-2); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.whoami { font-size: 13px; }
.whoami small { display: block; color: var(--muted); }

.content { padding: 24px 28px; min-width: 0; }
.view-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* ---------- Karten ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.narrow { max-width: 520px; margin-bottom: 16px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.meter { height: 6px; border-radius: 3px; background: var(--line); margin-top: 10px; overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.meter.warn > div { background: var(--warn); }
.meter.bad > div { background: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--ok); }
.pill.bad::before { background: var(--bad); }
.pill.warn::before { background: var(--warn); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 550; font-size: 12.5px; background: var(--panel-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #ffffff06; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .right { text-align: right; }
.table td.right .actions { justify-content: flex-end; flex-wrap: nowrap; }
.table .empty { color: var(--muted); text-align: center; padding: 24px; }
.table code { font-size: 12.5px; }
.details-cell { color: var(--muted); font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ---------- Dateien ---------- */
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.tabs button { font: inherit; color: var(--muted); background: none; border: 0; padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.tabs button.active { color: #fff; background: var(--accent-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1; min-width: 200px; font-family: var(--mono); font-size: 13px; }
.crumbs button { font: inherit; color: var(--accent); background: none; border: 0; padding: 2px 4px; cursor: pointer; border-radius: 4px; }
.crumbs button:hover { background: var(--panel-2); }
.crumbs span { color: var(--muted); }
.files td:first-child { width: 100%; }
.file-link { font: inherit; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; display: inline-flex; gap: 8px; align-items: center; }
.file-link:hover { color: var(--accent); }
.file-icon { width: 18px; text-align: center; flex: none; }
.dropzone { position: relative; border-radius: var(--radius); }
.dropzone.dragging { outline: 2px dashed var(--accent); outline-offset: 4px; }
.drop-hint { color: var(--muted); font-size: 12.5px; text-align: center; margin: 10px 0 0; }
.progress { position: relative; height: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-2); transition: width .2s; }
.progress span { position: relative; display: block; text-align: center; line-height: 24px; font-size: 12.5px; }

/* ---------- Log ---------- */
.log {
  background: #05080f; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0; height: calc(100vh - 140px); overflow: auto;
  font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Benutzer ---------- */
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.inline-form input { flex: 1 1 180px; }

/* ---------- Editor ---------- */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; }
.editor-box { width: min(1400px, 100%); height: min(900px, 100%); overflow: hidden; }
.editor-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.editor-head strong { font-family: var(--mono); font-size: 13px; word-break: break-all; }
.editor-head .actions { margin-left: auto; }
.editor-host { flex: 1; min-height: 0; }
.editor-host .CodeMirror { height: 100%; font-family: var(--mono); font-size: 13.5px; }

/* ---------- Meldungen ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; box-shadow: 0 8px 24px #0008; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }

/* ---------- Control Center ---------- */
.view-head p { margin: 2px 0 0; }
.alert { background: #7f1d1d40; border: 1px solid #b91c1c; color: #fecaca; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-bottom: 16px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 10px; }
.chart-svg .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart-svg .line.players { stroke: var(--accent); }
.chart-svg .line.cpu, .lg.cpu { stroke: #f59e0b; color: #f59e0b; }
.chart-svg .line.mem, .lg.mem { stroke: #a855f7; color: #a855f7; }
.lg { font-weight: 600; }
.kv-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-row .btn { margin-left: auto; }

.toolbar .grow, .inline-form .grow { flex: 1 1 220px; }
.toolbar.levels { gap: 14px; margin-top: -4px; }
.lvl { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.lvl.info { color: var(--muted); }
.lvl.warning { color: var(--warn); }
.lvl.error { color: #f87171; }
.lvl.critical { color: #fff; background: #b91c1c; padding: 1px 8px; border-radius: 6px; }
input.invalid { outline: 2px solid var(--bad); }
.mono { font-family: var(--mono); }

.log .ll { white-space: pre-wrap; word-break: break-word; padding: 1px 4px; border-radius: 3px; }
.log .ll:hover { background: #ffffff08; }
.log .lt { color: #5b6785; margin-right: 8px; user-select: none; }
.log .lv { display: inline-block; width: 46px; font-weight: 700; margin-right: 6px; user-select: none; font-size: 11px; }
.log .ll.info .lv { color: #5b6785; }
.log .ll.warning { color: #fde68a; }
.log .ll.warning .lv { color: var(--warn); }
.log .ll.error { color: #fca5a5; background: #7f1d1d26; }
.log .ll.error .lv { color: var(--bad); }
.log .ll.critical { color: #fff; background: #b91c1c66; }
.log .ll.critical .lv { color: #fff; }
.log .ll.cmd { color: var(--accent); font-weight: 600; margin-top: 8px; }
.log.short { height: auto; max-height: 420px; }
#view-logs .log { height: calc(100vh - 250px); min-height: 300px; }
.console-block { border-left: 2px solid var(--line); margin: 2px 0 6px 6px; padding-left: 6px; }
.small-gap { gap: 6px; margin: 10px 0; }

.table tr.group-row td { background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 6px 12px; }
.table tr.dim td { opacity: .6; }
.linkish { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; color: var(--muted); }
.linkish.bad { color: #f87171; }
.linkish.warn { color: var(--warn); }
.mono-list { font-family: var(--mono); font-size: 12px; color: #fca5a5; padding-left: 18px; margin: 4px 0 10px; }
.mono-list li { margin-bottom: 4px; word-break: break-word; }
#crash-detail h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
#crash-detail { margin-bottom: 16px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
.stack.tight { gap: 6px; }

/* ---------- Stufe 2 ---------- */
.schedule-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; margin-bottom: 14px; }
.warn-text { color: var(--warn); }
.view-head.sub { margin: 26px 0 10px; }
details.small summary, td details summary { color: var(--accent); }
.kv.ids { margin-top: 6px; font-size: 12px; }
.kv.ids code { word-break: break-all; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 10px 14px; }
.check-item.ok { border-left-color: var(--ok); }
.check-item.info { border-left-color: var(--accent); }
.check-item.warn { border-left-color: var(--warn); }
.check-item.bad { border-left-color: var(--bad); background: #7f1d1d22; }
.check-icon { font-size: 16px; line-height: 1.4; }
.check-detail { margin: 4px 0 0; white-space: pre-wrap; font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; }
  #nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .content { padding: 16px; }
  .table { display: block; overflow-x: auto; }
  .log { height: 60vh; }
  .files th:nth-child(3), .files td:nth-child(3) { display: none; }
}
