:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7873;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #b42e2e;
  --discord: #5865f2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #96948d;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --series-1: #3987e5;
    --good-text: #2fbf2f;
    --critical-text: #ef7474;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--critical-text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; height: 44px; width: 100%; font-size: 15px; }
.btn-discord:hover:not(:disabled) { background: #4752c4; }

/* ---------------- Login ---------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 36px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; margin-top: 12px; }
.login-card p { margin: 4px 0 24px; }
.login-logo { display: block; margin: 0 auto; }
.notice {
  text-align: left; padding: 10px 12px; margin-bottom: 16px; border-radius: 8px;
  background: var(--surface-2); border-left: 3px solid var(--warning); font-size: 13px;
}
.notice.error { border-left-color: var(--critical); }

/* ---------------- Layout ---------------- */
#app { max-width: 1240px; margin: 0 auto; padding: 0 20px 80px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 0 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--muted); }
.user { display: flex; align-items: center; gap: 8px; }
.user img { border-radius: 50%; background: var(--surface-2); }
#user-name { font-weight: 500; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 10px 14px; color: var(--text-2); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.count:not(:empty) { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--surface-2); font-size: 12px; text-align: center; }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-main { grid-template-columns: 1.4fr 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.grid > .card { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------------- Status-Pill ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px;
  border-radius: 13px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill.good .pill-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.pill.warn .pill-dot { background: var(--warning); animation: pulse 1.4s ease-in-out infinite; }
.pill.bad .pill-dot { background: var(--critical); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------------- Key/Value ---------------- */
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.kv div { min-width: 0; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 2px 0 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.secret-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.secret-row:last-of-type { border-bottom: 0; }
.secret-label { width: 74px; color: var(--muted); font-size: 12.5px; flex: none; }
.secret-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; padding: 0; font-size: 13.5px; }

/* ---------------- Tiles ---------------- */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 24px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: 12px; color: var(--text-2); min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Charts ---------------- */
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.chart { margin: 0; min-width: 0; }
.chart figcaption { font-size: 12.5px; color: var(--text-2); font-weight: 500; margin-bottom: 6px; }
.chart-box { position: relative; height: 150px; }
.chart-box svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-box .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart-box .base-line { stroke: var(--axis); stroke-width: 1; }
.chart-box .tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-box .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-box .area { fill: var(--series-1); opacity: .10; }
.chart-box .bar { fill: var(--series-1); }
.chart-box .cross { stroke: var(--axis); stroke-width: 1; }
.chart-box .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-box .empty { fill: var(--muted); font-size: 12px; }
.chart-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -110%);
  background: var(--text); color: var(--surface); padding: 4px 8px; border-radius: 6px;
  font-size: 12px; white-space: nowrap; z-index: 2;
}

/* ---------------- Forms ---------------- */
input[type=text], input[type=search], input[type=number], input[type=time], input[type=password], select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; min-width: 0;
}
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.form fieldset { border: 0; border-top: 1px solid var(--border); margin: 0; padding: 14px 0; }
.form legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; max-width: 420px; }
.field span { font-size: 12.5px; color: var(--text-2); }

/* ---------------- Tabellen ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table th.right, .table td.right { text-align: right; }
.table td.right { white-space: nowrap; }
.table .empty-row td { color: var(--muted); text-align: center; padding: 24px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

/* ---------------- Banner ---------------- */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warning); box-shadow: var(--shadow);
}
.banner.info { border-left-color: var(--accent); }
.banner.error { border-left-color: var(--critical); }
.banner-text { flex: 1; min-width: 200px; }
.banner-text b { display: block; }
.banner-text span { color: var(--text-2); font-size: 13px; }
.countdown { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- Einstellungen ---------------- */
.settings-toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; z-index: 3; }
.settings-toolbar input[type=search] { flex: 1; min-width: 200px; }
details.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
details.group > summary { padding: 14px 20px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "▾"; color: var(--muted); }
details.group:not([open]) > summary::after { content: "▸"; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) 260px 32px; gap: 16px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); }
.set-row.changed { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.set-label { font-weight: 500; }
.set-key { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.set-help { font-size: 13px; color: var(--text-2); margin-top: 3px; max-width: 70ch; line-height: 1.45; }
.set-default { font-size: 12px; color: var(--muted); margin-top: 3px; }
.set-pending { font-size: 12px; color: var(--accent); }
.set-input input:not([type=checkbox]), .set-input select { width: 100%; }
.set-input .toggle { display: flex; align-items: center; gap: 8px; }
.savebar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18);
  max-width: calc(100% - 32px);
}

/* ---------------- Logs ---------------- */
.subtabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.subtabs button { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: inherit; cursor: pointer; }
.subtabs button.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 150px 170px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; }
.activity .who { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity .what b { font-weight: 600; }
.activity .what span { color: var(--text-2); word-break: break-word; }
.activity li.warn .what b::before { content: "⚠ "; color: var(--serious); }
.activity li.error .what b::before { content: "✖ "; color: var(--critical); }
.console {
  margin: 0; max-height: 65vh; overflow: auto; padding: 12px; border-radius: 8px;
  background: var(--surface-2); font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all;
}

.mt-16 { margin-top: 16px; }
.danger-zone { border-color: color-mix(in srgb, var(--critical) 40%, var(--border)); }
.wipe-list { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
.wipe-list li { margin: 4px 0; }
.btn-danger-solid { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: color-mix(in srgb, var(--critical) 85%, #000); }
.dlg-input { width: 100%; margin-top: 10px; }

/* ---------------- Spieler-Statistik ---------------- */
.table-click tbody tr { cursor: pointer; }
.table-click td { white-space: nowrap; }
.table-click tbody tr:hover td { background: var(--surface-2); }
.table-click tbody tr.selected td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th.sorted { color: var(--text); }
.table th.sorted::after { content: " ▾"; }
.table th.sorted.asc::after { content: " ▴"; }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: middle; }
.st-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 4px 0 18px; }
.st-tiles .tile { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.st-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
.st-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.activity li.st-event { grid-template-columns: 150px 1fr; }
@media (max-width: 860px) { .st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .st-charts { grid-template-columns: 1fr; } }

/* ---------------- Mods ---------------- */
.mod-title { font-weight: 500; }
.mod-sub { font-size: 12px; color: var(--muted); }
.mod-sub a { color: var(--muted); }
.badge.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge.warn { border-color: color-mix(in srgb, var(--warning) 55%, transparent); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.badge.bad { border-color: color-mix(in srgb, var(--critical) 45%, transparent); background: color-mix(in srgb, var(--critical) 10%, transparent); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.notice.ok { border-left-color: var(--good); }

/* ---------------- Dialog & Toasts ---------------- */
dialog {
  border: 1px solid var(--border-strong); border-radius: 14px; padding: 0; width: min(460px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body h3 { font-size: 17px; }
#dlg-text { color: var(--text-2); }
#dlg-text ul { margin: 6px 0; padding-left: 18px; max-height: 200px; overflow: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100% - 32px); }
.toast {
  padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--surface);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13.5px; max-width: 380px; animation: slidein .18s ease-out;
}
.toast.error { background: var(--critical); color: #fff; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .set-row { grid-template-columns: 1fr 32px; }
  .set-row .set-input { grid-column: 1; grid-row: 2; }
  .activity li { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 560px) {
  #app { padding: 0 16px 90px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user #user-name { display: none; }
  .card { padding: 16px; }
  .secret-row { flex-wrap: wrap; }
  .secret-row code { flex-basis: calc(100% - 82px); }
}
