:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c2430;
  --muted: #5f6b7a;
  --accent: #c97a06;
  --accent-text: #ffffff;
  --ok: #1a8f4e;
  --bad: #c0352b;
  --warn-bg: #fff4e0;
  --warn-text: #7a4b00;
  --term-bg: #10151c;
  --term-text: #d6dde6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 21, 28, .06), 0 2px 8px rgba(16, 21, 28, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1318;
    --surface: #171c23;
    --surface-2: #1f262f;
    --border: #2b3440;
    --text: #e3e8ee;
    --muted: #93a0b0;
    --accent: #f0a12b;
    --accent-text: #1a1206;
    --ok: #3cc479;
    --bad: #ef6a5f;
    --warn-bg: #3a2a0f;
    --warn-text: #f6d08f;
    --term-bg: #0a0d11;
    --term-text: #d6dde6;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1318; --surface: #171c23; --surface-2: #1f262f; --border: #2b3440;
  --text: #e3e8ee; --muted: #93a0b0; --accent: #f0a12b; --accent-text: #1a1206;
  --ok: #3cc479; --bad: #ef6a5f; --warn-bg: #3a2a0f; --warn-text: #f6d08f;
  --term-bg: #0a0d11; --term-text: #d6dde6; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.5em; margin: 0; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }

/* Eingaben & Buttons */
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn {
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.btn:hover:not(:disabled) { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger.ghost { color: var(--bad); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.inline { display: inline-flex; gap: 8px; align-items: center; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-card label { font-size: 13px; color: var(--muted); }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.server-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tabs button {
  font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { display: block; font-size: 20px; font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td.actions .btn, td.actions select { margin-left: 6px; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.empty { margin: 12px 0 0; }

/* Terminal */
.term {
  background: var(--term-bg); color: var(--term-text); border-radius: 8px;
  padding: 12px 14px; margin: 0 0 12px; height: 420px; overflow: auto;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.term.tall { height: calc(100vh - 220px); min-height: 320px; }
.term .cmd { color: #f0a12b; }
.term .err { color: #ef6a5f; }

/* Maps */
#maps-filter { width: 100%; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 360px; overflow: auto; }
.chip {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.chip:hover { border-color: var(--accent); }
.chip.current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Uploads */
.upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.upload input[type=file] { flex: 1; min-width: 220px; }
.upload progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* Sound-Tags */
.tag-rows { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.tag-rows:empty { display: none; }
.tag-row { display: flex; gap: 10px; align-items: center; }
.tag-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-row input { width: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge.warn-badge { background: var(--warn-bg); color: var(--warn-text); margin-left: 0; }
.warn code { background: transparent; }

/* Configs */
.config-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.filelist { list-style: none; margin: 0 0 12px; padding: 0; max-height: 50vh; overflow: auto; }
.filelist button {
  width: 100%; text-align: left; font: 14px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: none; border: 0; color: var(--text); padding: 7px 10px; border-radius: 6px; cursor: pointer;
}
.filelist button:hover { background: var(--surface-2); }
.filelist button.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.editor-card textarea {
  width: 100%; height: calc(100vh - 290px); min-height: 320px; resize: vertical; margin-bottom: 12px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 4;
}

/* Hinweis-Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(460px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: var(--radius); background: var(--text); color: var(--bg);
  box-shadow: 0 6px 24px rgba(0,0,0,.25); font-weight: 600;
}
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  main { padding: 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2, .config-layout { grid-template-columns: 1fr; }
  .term { height: 320px; }
}
