:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e6;
  --text: #1c2026;
  --text-2: #4b5360;
  --muted: #7a8390;
  --accent: #2f6fdf;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --good: #1f8a3b;
  --warn: #a86b00;
  --bad: #c9302c;
  --good-soft: #e3f4e8;
  --warn-soft: #fbf0d9;
  --bad-soft: #fbe5e4;
  --neutral-soft: #eceef1;
  --track: #e4e7eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #181b20;
    --surface-2: #1f2329;
    --border: #2b3038;
    --text: #e7e9ec;
    --text-2: #b4bac3;
    --muted: #858d99;
    --accent: #6d9cf2;
    --accent-ink: #0d1117;
    --accent-soft: #1d2a42;
    --good: #4cc26a;
    --warn: #e0a83a;
    --bad: #f0645e;
    --good-soft: #16301f;
    --warn-soft: #33280f;
    --bad-soft: #3a1a19;
    --neutral-soft: #262a31;
    --track: #2a2f37;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #181b20;
  --surface-2: #1f2329;
  --border: #2b3038;
  --text: #e7e9ec;
  --text-2: #b4bac3;
  --muted: #858d99;
  --accent: #6d9cf2;
  --accent-ink: #0d1117;
  --accent-soft: #1d2a42;
  --good: #4cc26a;
  --warn: #e0a83a;
  --bad: #f0645e;
  --good-soft: #16301f;
  --warn-soft: #33280f;
  --bad-soft: #3a1a19;
  --neutral-soft: #262a31;
  --track: #2a2f37;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
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;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ Layout */
.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 13px; }
.user-chip:hover { text-decoration: none; background: var(--neutral-soft); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.btn.menu-btn { display: none; }

.sidebar { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 8px; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--text-2);
  font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .count { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.nav svg { width: 17px; height: 17px; flex: none; }
.tree { margin-top: 2px; }
.tree a { padding: 4px 10px 4px 14px; font-size: 13px; font-weight: 450; }
.tree .tree-node { font-weight: 600; }
.tree .tree-guest { padding-left: 30px; }

.main { overflow-y: auto; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ Karten & Raster */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-body { padding: 16px 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card-head h2 { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .foot { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ Meter */
.meter { margin-top: 12px; }
.meter:first-child { margin-top: 0; }
.meter-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; gap: 8px; }
.meter-top .label { color: var(--text-2); font-weight: 500; }
.meter-top .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s ease; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }

/* ------------------------------------------------------------ Sparkline */
.spark-wrap { position: relative; }
.spark { display: block; width: 100%; height: 64px; overflow: visible; }
.spark .grid-line { stroke: var(--border); stroke-width: 1; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--accent); opacity: .12; }
.spark .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.spark .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.spark-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--text); color: var(--surface);
  padding: 3px 8px; border-radius: 6px; font-size: 12px; pointer-events: none; white-space: nowrap; }

/* ------------------------------------------------------------ Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.empty { padding: 32px 18px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--neutral-soft); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.dot-status { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot-status.good { background: var(--good); }
.dot-status.bad { background: var(--bad); }
.dot-status.warn { background: var(--warn); }
.type-tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--surface-2);
  color: var(--text-2); border: 1px solid var(--border); letter-spacing: .03em; }

/* ------------------------------------------------------------ Formulare & Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn svg { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; }
textarea { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; margin-bottom: 12px; }
.check input { margin-top: 3px; }
.input-group { display: flex; }
.input-group input { border-radius: 8px 0 0 8px; }
.input-group .btn { border-radius: 0 8px 8px 0; margin-left: -1px; height: 36px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ------------------------------------------------------------ Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 6px 14px; border-radius: 7px;
  font: inherit; font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ------------------------------------------------------------ Erstellen-Assistent */
.create-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.summary { position: sticky; top: 0; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; }
.os-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.os-card { border: 1.5px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--surface);
  display: flex; gap: 10px; align-items: center; text-align: left; font: inherit; color: var(--text); }
.os-card:hover { border-color: var(--muted); }
.os-card.active { border-color: var(--accent); background: var(--accent-soft); }
.os-icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  flex: none; color: #fff; }
.os-icon.debian { background: #c70036; }
.os-icon.ubuntu { background: #e95420; }
.os-icon.windows { background: #0078d4; }
.os-icon.linux { background: #4b5360; }
.os-card .t { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.os-card .s { font-size: 12px; color: var(--muted); }
.slider-row { display: grid; grid-template-columns: 110px 1fr 110px; gap: 14px; align-items: center; margin-bottom: 14px; }
.slider-row .lbl { font-weight: 600; color: var(--text-2); font-size: 13px; }
.slider-row .out { display: flex; align-items: center; gap: 6px; }
.slider-row .out input { height: 32px; text-align: right; }
.presets { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.sum-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border);
  font-size: 13.5px; }
.sum-line:last-of-type { border-bottom: 0; }
.sum-line .k { color: var(--muted); }
.sum-line .v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ Modal, Toast, Log */
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 16, .55); display: grid; place-items: center; z-index: 50;
  padding: 16px; animation: fade .12s ease; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: 100%; max-width: 560px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.wide { max-width: 820px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow);
  max-width: 380px; font-size: 13.5px; animation: fade .15s ease; }
.toast.bad { background: var(--bad); color: #fff; }
.log { background: #0d1014; color: #cfd6df; font-family: var(--mono); font-size: 12px; line-height: 1.55; padding: 12px 14px;
  border-radius: 8px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 8px 8px 12px; font-family: var(--mono); font-size: 14px; }
.secret span { flex: 1; overflow-wrap: anywhere; }
.alert { padding: 11px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--text); font-size: 13.5px; }
.alert.warn { background: var(--warn-soft); }
.alert.bad { background: var(--bad-soft); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; font-size: 20px; margin-bottom: 24px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ------------------------------------------------------------ Mobil */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .create-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 260px; z-index: 40; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 16px 16px 40px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .slider-row { grid-template-columns: 1fr 100px; }
  .slider-row .lbl { grid-column: 1 / -1; }
  .row { flex-direction: column; gap: 0; }
  .user-chip .uname { display: none; }
}

/* Formularelemente in Tabellen (Firewall-Regeln) */
td select { width: auto; min-width: 118px; }
td input[type=text] { height: 32px; }
