:root {
  --bg: #090d14; --surface: #0f1521; --surface2: #151d2d; --border: #1f2a40; --text: #e6edf7; --muted: #8493ae;
  --accent: #22d3ee; --accent2: #38bdf8; --ok: #22c55e; --warn: #f59e0b; --err: #ef4444;
  --radius: 12px; --shadow: 0 10px 40px rgba(0,0,0,.45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
aside { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; letter-spacing: .06em; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 500; letter-spacing: 0; color: var(--muted); font-size: 11px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 550; }
nav a:hover { background: var(--surface2); color: var(--text); }
nav a.on { background: linear-gradient(90deg, rgba(34,211,238,.16), rgba(34,211,238,.04)); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
nav svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.spacer { flex: 1; }
.foot { padding: 10px; color: var(--muted); font-size: 12px; display: grid; gap: 8px; }
main { padding: 26px 30px 60px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { margin: 2px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Karten und Kacheln */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: 2fr 1fr; align-items: start; }
.tile { background: linear-gradient(180deg, var(--surface2), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tile .num { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.tile .sub { color: var(--muted); font-size: 12.5px; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); margin-bottom: 10px; align-items: flex-start; }
.notice.warn { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.08); }
.notice.err { border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.08); }
.notice.ok { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.07); }

/* Buttons und Formulare */
button, .btn { font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); padding: 7px 14px; font-weight: 600; transition: border-color .15s, background .15s, transform .05s; }
button:hover { border-color: #33466b; background: #1a2438; }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: linear-gradient(135deg, #0891b2, #22d3ee); border: 0; color: #031318; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: #fca5a5; border-color: rgba(239,68,68,.45); }
button.danger:hover { background: rgba(239,68,68,.12); }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 12px; }
button.icon { padding: 5px 8px; line-height: 1; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.f { display: grid; gap: 5px; font-weight: 600; font-size: 12.5px; color: var(--muted); }
label.f > span small { font-weight: 400; }
.form { display: grid; gap: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.check input { width: auto; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input { flex: 1; }

/* Tabellen */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.name b { display: block; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* Chips, Balken */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 650; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.chip.ok { color: #86efac; border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.08); }
.chip.warn { color: #fcd34d; border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.08); }
.chip.err { color: #fca5a5; border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.08); }
.chip.info { color: #7dd3fc; border-color: rgba(56,189,248,.4); background: rgba(56,189,248,.08); }
.bar { height: 6px; background: var(--border); border-radius: 9px; overflow: hidden; min-width: 90px; margin-top: 5px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #0891b2, #22d3ee); border-radius: 9px; }
.bar.low > i { background: linear-gradient(90deg, #d97706, #f59e0b); }

/* Diagramm */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column-reverse; align-items: stretch; height: 100%; justify-content: flex-start; gap: 1px; min-width: 0; cursor: default; }
.chart .col i { display: block; border-radius: 3px; min-height: 0; }
.chart .c1 { background: #22d3ee; } .chart .c2 { background: #3b82f6; } .chart .c3 { background: #ef4444; } .chart .c4 { background: #f59e0b; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* Listen */
.rows { display: grid; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 200px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
pre { margin: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 12px; overflow-x: auto; font-size: 12px; }
.copybox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.copybox code { flex: 1; word-break: break-all; }

/* Modal und Toasts */
.overlay { position: fixed; inset: 0; background: rgba(3,6,12,.72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 92vh; overflow: auto; animation: pop .18s cubic-bezier(.2,.9,.3,1); }
.modal.wide { width: min(760px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal .body { padding: 20px; display: grid; gap: 14px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; }
.toast { background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; animation: pop .18s; }
.toast.err { border-left-color: var(--err); } .toast.ok { border-left-color: var(--ok); }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* Anmeldung */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 50% -10%, rgba(34,211,238,.12), transparent 70%); }
.auth .card { width: min(430px, 100%); padding: 28px; box-shadow: var(--shadow); }
.auth .logo { display: grid; place-items: center; gap: 8px; margin-bottom: 18px; text-align: center; }
.auth .logo img { width: 54px; height: 54px; }
.auth .qr { background: #fff; border-radius: 10px; padding: 10px; width: max-content; margin: 0 auto; }
.auth .qr svg { display: block; width: 180px; height: 180px; }
.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.steps i { width: 26px; height: 4px; border-radius: 4px; background: var(--border); } .steps i.on { background: var(--accent); }
.err-text { color: #fca5a5; min-height: 1.2em; font-size: 13px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 4px 8px; } nav { display: flex; flex-wrap: wrap; } .foot, .spacer { display: none; }
  main { padding: 18px 14px 50px; } .two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
