/* ArmaZon-Farben: AZ-Blau #1E78E6, AZ-Rot #E0243A, Cyan #3FB8F5, Navy #0F2235, Silber #D9DEE5 */
:root {
  color-scheme: dark;
  --bg: #0a1018;
  --bg-2: #0d1520;
  --panel: #111b27;
  --panel-2: #172331;
  --border: #223143;
  --border-strong: #2e4157;
  --text: #dce2e9;
  --muted: #8595a8;
  --accent: #1e78e6;
  --accent-hover: #3b8cf0;
  --accent-ink: #ffffff;
  --danger: #e0243a;
  --danger-text: #ff5a6a;
  --danger-bg: rgba(224, 36, 58, 0.14);
  --danger-border: rgba(224, 36, 58, 0.45);
  --ok: #46b358;
  --ok-bg: rgba(70, 179, 88, 0.12);
  --warn: #d29922;
  --warn-bg: rgba(210, 153, 34, 0.14);
  --info: #3fb8f5;
  --terminal: #070c12;
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; letter-spacing: 0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
h3 { font-size: 13px; margin: 18px 0 8px; color: var(--muted); }
p { margin: 0; }
pre { margin: 0; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.text-danger { color: var(--danger-text); }
.spacer { flex: 1; }
.boot { padding: 40px; color: var(--muted); text-align: center; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Grundgerüst ---------- */

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand strong { display: block; font-size: 15px; letter-spacing: 0.18em; }
.brand small { display: block; font-size: 10.5px; letter-spacing: 0.24em; color: var(--accent); }
.env-badge {
  margin-left: auto; padding: 1px 8px; border-radius: 4px;
  background: var(--warn-bg); border: 1px solid rgba(210, 153, 34, 0.45); color: var(--warn);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; white-space: nowrap;
}

/* Logo: Ausschnitte aus public/logo.webp (1672x941, schwarzer Hintergrund).
   "screen" lässt das Schwarz verschwinden, das Logo liegt dann direkt auf dem Hintergrund. */
.logo-crop { position: relative; overflow: hidden; flex: none; display: block; }
.logo-crop img {
  position: absolute; max-width: none; height: auto;
  mix-blend-mode: screen; pointer-events: none; user-select: none;
}
/* ganzes Logo (Dreieck + ARMAZON + Linie): x 403-1264, y 151-778 */
.logo-full { width: 100%; aspect-ratio: 861 / 627; }
.logo-full img { width: 194.19%; left: -46.81%; top: -24.08%; }
/* nur das Dreieck: x 611-1059, y 165-549 */
.logo-mark { width: 36px; aspect-ratio: 448 / 384; }
.logo-mark img { width: 373.21%; left: -136.38%; top: -42.97%; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
}
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-link.active .icon { color: var(--accent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; text-decoration: none; }
.me:hover { background: var(--panel); }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
}
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 16px; max-width: 1280px; width: 100%; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel);
  font-size: 13px; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
[data-state="connected"] .dot, .state-connected .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
[data-state="connecting"] .dot, .state-connecting .dot { background: var(--warn); }
[data-state="disconnected"] .dot, [data-state="auth_failed"] .dot,
.state-disconnected .dot, .state-auth_failed .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.state { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Bausteine ---------- */

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.grid.three { grid-template-columns: 2fr 1fr auto; align-items: end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar.card { flex-direction: row; padding: 12px 16px; }
.toolbar input[type="search"], .toolbar input:not([type]) { width: 240px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger-text); border-color: var(--danger-border); }
.btn.danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:hover:not(:disabled) { background: #ea3d51; border-color: #ea3d51; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); justify-content: flex-start; }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: var(--panel); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; padding: 10px; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 10px; min-width: 0;
}
textarea { resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[readonly] { color: var(--muted); }
input[type="color"] { padding: 2px; width: 52px; height: 36px; }
input.narrow { width: 80px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); }
label.inline { flex-direction: row; align-items: center; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--muted); }
.form-error { color: var(--danger-text); font-size: 13px; min-height: 1em; }
.form-error:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.chip:hover:not(:disabled):not(.static) { border-color: var(--muted); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip:disabled { opacity: 0.35; cursor: not-allowed; }
.chip.static { cursor: default; color: var(--muted); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; white-space: nowrap;
}
.badge + .badge { margin-left: 4px; }
.badge-danger { color: var(--danger-text); background: var(--danger-bg); border-color: var(--danger-border); }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: rgba(70, 179, 88, 0.35); }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(210, 153, 34, 0.35); }

.role-badge {
  --role-color: var(--muted);
  display: inline-flex; align-items: center;
  padding: 1px 10px; border-radius: 999px;
  color: var(--role-color);
  background: color-mix(in srgb, var(--role-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--role-color) 45%, transparent);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

.notice { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.notice-error { color: var(--danger-text); background: var(--danger-bg); border-color: var(--danger-border); }
.notice-warn { background: var(--warn-bg); border-color: rgba(210, 153, 34, 0.45); }
.notice-warn strong { color: var(--warn); }

.empty { padding: 36px 16px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.empty p { max-width: 520px; }

.copyable {
  background: none; border: 0; padding: 0; color: var(--text); cursor: copy; text-align: left;
  font-family: var(--mono); font-size: 12px; word-break: break-all;
}
.copyable:hover { color: var(--accent); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-size: 15px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.action-row:first-child { border-top: 0; padding-top: 0; }
.action-row p { margin-top: 2px; }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.card .table-wrap { border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
td.details { min-width: 260px; max-width: 480px; overflow-wrap: anywhere; }
tr.row-failed td { background: rgba(224, 36, 58, 0.06); }
tr.row-disabled td { opacity: 0.55; }

/* ---------- Rohausgaben & Konsole ---------- */

.raw {
  background: var(--terminal); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; font-family: var(--mono); font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto;
}
.raw.raw-error { color: var(--danger-text); }
.raw-details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }

.console { display: flex; flex-direction: column; gap: 12px; }
.console-log {
  height: calc(100vh - 290px); min-height: 320px; overflow-y: auto;
  background: var(--terminal); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}
.c-line { display: flex; gap: 10px; align-items: baseline; }
.c-line pre { font: inherit; white-space: pre-wrap; word-break: break-word; color: #b4c0cc; }
.c-time { color: #5a6b7e; flex: none; }
.c-user { color: var(--accent); flex: none; }
.c-user::after { content: ":"; }
.c-command span:last-child { color: var(--text); font-weight: 600; }
.c-system { color: var(--info); }
.c-action { color: var(--ok); }
.c-error { color: var(--danger-text); }
.c-alert { color: var(--danger-text); font-weight: 700; }
.c-server, .c-server pre { color: #cfd8e2; }

.console-input { display: flex; align-items: center; gap: 8px; background: var(--terminal); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 6px 6px 14px; }
.console-input:focus-within { border-color: var(--accent); }
.console-input .prompt { color: var(--accent); font-family: var(--mono); font-weight: 700; }
.console-input input { flex: 1; background: transparent; border: 0; padding: 6px 0; }
.console-input input:focus { outline: none; }
.console > div > .chips { margin-top: 8px; }

/* ---------- Spieler-Archiv ---------- */

.link-btn {
  background: none; border: 0; padding: 0; font: inherit; font-weight: 600;
  color: var(--text); cursor: pointer; text-align: left;
}
.link-btn:hover { color: var(--accent); text-decoration: underline; }
.name-badge { margin-left: 8px; vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(30, 120, 230, 0.07); }

.player-detail .detail-name { font-size: 18px; font-weight: 700; }
.player-detail h3 { margin: 6px 0 0; }
.player-detail .card-head .badge + .btn { margin-left: 4px; }

.note { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; background: var(--bg-2); }
.note-head { display: flex; align-items: center; gap: 8px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.icon-btn.small { font-size: 12px; padding: 2px 6px; }

.timeline { display: flex; flex-direction: column; gap: 10px; border-left: 2px solid var(--border); padding-left: 14px; margin-left: 6px; }
.tl-item { display: flex; gap: 10px; align-items: flex-start; }
.tl-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none; box-sizing: content-box;
  margin: 4px 0 0 -22px; border: 2px solid var(--panel); background: var(--muted);
}
.tl-session { background: var(--ok); }
.tl-kick { background: var(--warn); }
.tl-ban { background: var(--danger); }
.tl-unban { background: var(--info); }
.tl-teamkill { background: var(--danger); }
.tl-admin_action, .tl-admin_target { background: var(--accent); }
.tl-watchlist_add { background: var(--warn); }
.tl-watchlist_remove { background: var(--info); }

/* ---------- Spieler-Verlauf (Grafik) & Stoßzeiten ---------- */

.chart-wrap { position: relative; min-width: 0; }
.chart { display: block; overflow: visible; }
.chart:focus { outline: none; }
.chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--accent-hover); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--accent-hover); fill-opacity: 0.1; stroke: none; }
.chart-point { fill: var(--accent-hover); stroke: var(--panel); stroke-width: 2; }
.chart-cross { stroke: var(--muted); stroke-width: 1; }
.chart-dot { fill: var(--accent-hover); stroke: var(--panel); stroke-width: 2; pointer-events: none; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  background: var(--panel-2); border: 1px solid var(--border-strong); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  font-size: 12px; color: var(--muted);
  transform: translate(-50%, calc(-100% - 6px));
}
.chart-tip strong { color: var(--text); font-size: 13px; }
.chart-tip-top { top: 4px; transform: translateX(-50%); }

/* Raster: Wochentag × Stunde. Stufen einer Farbe (AZ-Blau), hell = viel los */
.heatmap { display: grid; grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 2px; }
.hm-hour { font-size: 10.5px; color: var(--muted); text-align: left; font-variant-numeric: tabular-nums; }
.hm-day { font-size: 11.5px; color: var(--muted); align-self: center; }
.hm-cell { height: 20px; border-radius: 3px; }
.hm-cell.hover { outline: 2px solid var(--text); outline-offset: -1px; }
.hm-empty { background: var(--panel-2); }
.hm-s0 { background: #235a98; }
.hm-s1 { background: #2a72c8; }
.hm-s2 { background: #4a92ef; }
.hm-s3 { background: #80b5f3; }
.hm-s4 { background: #bcd8f8; }
.hm-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.hm-swatch { width: 18px; height: 12px; border-radius: 3px; }

/* ---------- Einstellungen ---------- */

.inline.wrap { flex-wrap: wrap; }
.template-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; gap: 8px; align-items: center; }

/* ---------- Ränge ---------- */

.role-card { gap: 12px; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.perm-group legend { padding: 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.perm-group label.check:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }

/* ---------- Anmeldung ---------- */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: min(380px, 100%); gap: 16px; padding: 28px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: -6px 0 8px; }
.login-logo .logo-full { width: 82%; }
.login-sub { font-size: 11px; font-weight: 600; letter-spacing: 0.32em; color: var(--accent); padding-left: 0.32em; }
.auth-card h2 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }

/* ---------- Dialog & Toasts ---------- */

dialog {
  width: min(500px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  padding: 0; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); }
.dialog-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

#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 {
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--panel-2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border-left: 3px solid var(--ok); transition: opacity 0.3s, transform 0.3s;
  overflow-wrap: anywhere;
}
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .nav { order: 3; width: 100%; flex-direction: row; overflow-x: auto; }
  .nav-link { flex: none; padding: 6px 10px; }
  .nav-link.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .topbar { padding: 14px 16px; }
  .content { padding: 16px 16px 40px; }
  .toolbar input[type="search"], .toolbar input:not([type]) { width: 100%; }
  .grid.three { grid-template-columns: 1fr; }
  .console-log { height: 55vh; }
  .template-row { grid-template-columns: minmax(0, 1fr) 118px auto; }
  .hm-cell { height: 14px; }
}
