:root {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --line: #e6e8f0;
  --text: #141824;
  --muted: #6b7286;
  --accent: #5b5bf6;
  --accent-soft: #ecebff;
  --ok: #12a37a;
  --ok-soft: #e3f7f0;
  --warn: #d98a00;
  --warn-soft: #fff4dc;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(20, 24, 36, .04), 0 8px 24px rgba(20, 24, 36, .06);
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e14;
    --panel: #151821;
    --panel-2: #1b1f2a;
    --line: #262b38;
    --text: #e9ecf3;
    --muted: #8d94a8;
    --accent: #8b8bff;
    --accent-soft: #23234a;
    --ok: #34d39e;
    --ok-soft: #10342a;
    --warn: #f5b13d;
    --warn-soft: #3a2c10;
    --bad: #ff6b6f;
    --bad-soft: #3d1a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 620; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px;
  border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 680; letter-spacing: -.02em; font-size: 16px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #7c5cff, #14b8a6);
}
.side .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.aktiv { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }

.haus { display: flex; flex-direction: column; gap: 4px; padding: 0 2px; }
.haus a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); font-weight: 550;
}
.haus a .etg { font-size: 11px; color: var(--muted); font-weight: 500; }
.haus a .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.haus a.aktiv { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.side .fuss { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px; }

.main { padding: 28px 34px 60px; min-width: 0; }
.kopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.kopf .sub { color: var(--muted); margin-top: 4px; }

.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g21, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .main { padding: 20px 16px; }
  .g4, .g2 { grid-template-columns: 1fr; }
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.kpi .wert { font-size: 26px; font-weight: 660; letter-spacing: -.02em; margin-top: 6px; }
.kpi .titel { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .hinweis { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.bad .wert { color: var(--bad); }
.kpi.warn .wert { color: var(--warn); }
.kpi.ok .wert { color: var(--ok); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 550; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
label.haken { display: flex; align-items: center; justify-content: center; margin: -10px; padding: 10px; cursor: pointer; }
label.haken input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
tbody tr.link:hover td { background: var(--panel-2); }
.tabelle { overflow-x: auto; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 650; display: inline-grid; place-items: center; }
.firma-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }

/* Formulare */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 11px; width: 100%; outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 38px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.felder { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.felder .voll { grid-column: 1 / -1; }
.feld.fehlt input, .feld.fehlt select { border-color: var(--warn); }
.filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter input[type=search] { flex: 1 1 260px; }
.filter select { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 580;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer; white-space: nowrap; transition: transform .06s, background .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.klein { padding: 4px 10px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
.knoepfe { display: flex; gap: 8px; flex-wrap: wrap; }
form.inline { display: inline; }

/* Upload */
.drop {
  border: 1.5px dashed var(--line); border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted);
  background: var(--panel); transition: border .15s, background .15s; cursor: pointer;
}
.drop.ueber { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { color: var(--text); }

/* Meldungen */
.meldungen { display: grid; gap: 8px; margin-bottom: 18px; }
.meldung { padding: 11px 14px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 520; }
.meldung.error { background: var(--bad-soft); color: var(--bad); }

/* Ampel */
.ampel { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ampel:last-child { border-bottom: 0; }
.ampel .licht { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px var(--panel-2); }
.licht.gruen { background: var(--ok); } .licht.gelb { background: var(--warn); } .licht.rot { background: var(--bad); }
.ampel .was { flex: 1; min-width: 0; }

/* Diagramme */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .linie { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .flaeche { fill: url(#verlauf); }
.chart .null { stroke: var(--bad); stroke-dasharray: 4 4; stroke-width: 1; opacity: .7; }
.chart .pkt { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.balken { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; align-items: end; height: 200px; padding-top: 10px; }
.balken .m { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.balken .paar { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.balken .b { width: 40%; max-width: 18px; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.b.ein { background: var(--ok); } .b.aus { background: var(--accent); opacity: .85; }
.legende { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.vorschau { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); }
.textvorschau { white-space: pre-wrap; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 78vh; overflow: auto; }
.leer { text-align: center; color: var(--muted); padding: 28px 10px; }
.trenner { height: 1px; background: var(--line); margin: 16px 0; }
details summary { cursor: pointer; color: var(--muted); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 30px; }

@media print {
  .side, .kopf .knoepfe, .no-print { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; border: 0; }
}
