/* Gemeinsames Design von Admin- und Staatspanel: flaches, sauberes macOS (keine Rahmen, kein Glas, ein Grau, ein Blau). Keine Inline-Styles (CSP: style-src 'self'). */
:root {
  --bg:#ffffff; --surface:#ffffff; --surface-2:#f2f2f5; --text:#1d1d1f; --muted:#6e6e73; --line:rgba(0,0,0,.1); --line-strong:rgba(0,0,0,.18);
  --accent:#0071e3; --accent-hover:#0077ed; --accent-soft:rgba(0,113,227,.1); --on-accent:#fff;
  --danger:#d70015; --danger-hover:#b80012; --danger-soft:rgba(215,0,21,.08);
  --ok:#1d7a36; --ok-soft:rgba(29,122,54,.1); --warn:#a64b00; --warn-soft:rgba(255,149,0,.14);
  --shadow:none;
  --shadow-lg:0 10px 32px rgba(0,0,0,.2), 0 1px 3px rgba(0,0,0,.1);
  --radius:14px; --radius-sm:10px; --side-w:236px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#1e1e20; --surface:#2a2a2d; --surface-2:#333337; --text:#f5f5f7; --muted:#a1a1a6; --line:rgba(255,255,255,.1); --line-strong:rgba(255,255,255,.2);
    --accent:#2997ff; --accent-hover:#52adff; --accent-soft:rgba(41,151,255,.16); --on-accent:#fff;
    --danger:#ff6961; --danger-hover:#ff8a84; --danger-soft:rgba(255,69,58,.16);
    --ok:#4cd964; --ok-soft:rgba(76,217,100,.16); --warn:#ffb340; --warn-soft:rgba(255,179,64,.16);
    --shadow:none; --shadow-lg:0 10px 32px rgba(0,0,0,.6), 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; background:var(--bg); color:var(--text); font:14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif; letter-spacing:-.008em; -webkit-font-smoothing:antialiased; }
h1 { font-size:28px; line-height:1.15; font-weight:600; margin:0; letter-spacing:-.02em; }
h2 { font-size:15px; font-weight:600; margin:0 0 12px; letter-spacing:-.01em; }
h3 { font-size:14px; margin:16px 0 6px; }
p { margin:0 0 8px; }
a { color:var(--accent); }
:focus-visible { outline:3px solid var(--accent-soft); outline-offset:2px; border-radius:8px; }
svg.ic { width:18px; height:18px; flex:none; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }

/* ---- Layout ---- */
.shell { display:flex; min-height:100vh; }
.side { width:var(--side-w); flex:none; background:var(--surface-2); display:flex; flex-direction:column; position:sticky; top:0; height:100vh; padding:22px 12px 16px; z-index:30; }
.brand { display:flex; align-items:center; gap:10px; padding:4px 8px 16px; }
.logo { width:30px; height:30px; border-radius:8px; background:var(--accent); color:#fff; display:grid; place-items:center; flex:none; }
.logo svg.ic { width:17px; height:17px; }
.brand b { display:block; font-size:15px; line-height:1.2; }
.brand small { color:var(--muted); font-size:12px; }
nav#nav { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:2px; margin:0; }
.nav-group { font-size:11px; font-weight:600; letter-spacing:0; text-transform:none; color:var(--muted); padding:14px 10px 4px; }
.nav-group:first-child { padding-top:4px; }
nav#nav button { display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:transparent; color:var(--text); border:0; border-radius:var(--radius-sm); padding:7px 10px; cursor:pointer; font:inherit; font-weight:400; }
nav#nav button svg.ic { color:var(--muted); }
nav#nav button:hover { background:rgba(120,120,128,.12); }
nav#nav button.aktiv { background:var(--accent-soft); color:var(--accent); font-weight:500; }
nav#nav button.aktiv svg.ic { color:var(--accent); }
nav#nav button.gefahr svg.ic, nav#nav button.gefahr { color:var(--danger); }
nav#nav button.gefahr.aktiv { background:var(--danger-soft); }
.side-foot { padding-top:12px; margin-top:8px; }
.side-foot button { width:100%; }
.main-col { flex:1; min-width:0; display:flex; flex-direction:column; }
.top { display:none; align-items:center; gap:10px; padding:10px 16px; background:var(--surface-2); position:sticky; top:0; z-index:20; }
.top .t { font-weight:600; }
main { width:100%; max-width:960px; margin:0; padding:30px 32px 80px; }
.page-head { margin-bottom:22px; }
.page-head p { display:none; }
.scrim { display:none; }

/* ---- Karten und Raster ---- */
.card { margin-bottom:32px; padding:0; }
.card > p.muted:first-of-type, .card h2 + p.muted { display:none; }
.card.gefahr { background:var(--danger-soft); border-radius:var(--radius); padding:20px; }
.row { display:grid; grid-template-columns:repeat(auto-fit, minmax(210px, 1fr)); gap:14px 16px; align-items:start; }
.stats { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:14px; margin-bottom:28px; }
.stat { background:var(--surface-2); border-radius:var(--radius); padding:16px 18px; }
.stat { text-align:center; display:flex; flex-direction:column; justify-content:center; }
.stat .l { color:var(--text); font-size:14px; display:flex; align-items:center; justify-content:center; gap:6px; letter-spacing:-.01em; }
.stat .l svg.ic { display:none; }
.stat .v { font-size:24px; font-weight:700; letter-spacing:-.02em; margin-top:4px; font-variant-numeric:tabular-nums; }
.stat .s { color:var(--muted); font-size:12px; margin-top:2px; }
.stat.hero { grid-column:1 / -1; background:var(--accent-soft); padding:26px 28px; text-align:left;  justify-content:flex-start;}
.stat.hero .l { font-size:20px; justify-content:flex-start; }
.stat.hero .v { font-size:48px; line-height:1.1; letter-spacing:-.03em; margin-top:8px; }
.cols2 { display:grid; grid-template-columns:repeat(auto-fit, minmax(300px, 1fr)); gap:32px; }
.cols2 > .card { margin-bottom:0; }
.gross { font-size:26px; font-weight:600; }
.tot { font-size:28px; line-height:1.15; font-weight:600; letter-spacing:-.02em; font-variant-numeric:tabular-nums; }
.part { margin-top:18px; }
.part .prow { display:flex; justify-content:space-between; align-items:baseline; gap:12px; }
.part .prow b { font-variant-numeric:tabular-nums; }
.part .meter { display:flex; align-items:center; gap:10px; margin-top:7px; }
.part .pct { flex:none; width:46px; font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.part .bar { flex:1; margin-top:0; }

/* ---- Formulare ---- */
label { display:block; font-size:13px; font-weight:500; color:var(--text); margin:0 0 5px; }
input, select, textarea { width:100%; padding:7px 12px; border:0; border-radius:var(--radius-sm); background:var(--surface-2); color:var(--text); font:inherit; min-height:36px; }
input:hover, select:hover, textarea:hover { filter:brightness(.98); }
input:focus, select:focus, textarea:focus { outline:3px solid var(--accent-soft); background:var(--surface); box-shadow:0 0 0 1.5px var(--accent); }
input::placeholder, textarea::placeholder { color:var(--muted); opacity:.8; }
select { -webkit-appearance:none; appearance:none; padding-right:34px; cursor:default;
  background-image:linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size:5px 5px, 5px 5px; background-repeat:no-repeat; }
input[type=file] { padding:7px; }
textarea { resize:vertical; font-family:ui-monospace, "SF Mono", Menlo, monospace; font-size:13px; }
.hint, span.muted { display:block; margin-top:4px; }
.muted { color:var(--muted); font-size:13px; }
.field { min-width:0; }
.field .hint { font-size:12px; color:var(--muted); }
.unit { position:relative; }
.unit input { padding-right:44px; }
.unit .u { position:absolute; right:12px; top:0; bottom:0; display:flex; align-items:center; color:var(--muted); font-size:13px; pointer-events:none; }
.actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-top:18px; }
.savebar { display:flex; justify-content:flex-end; position:sticky; bottom:0; padding:24px 0 12px; margin-top:4px; pointer-events:none; }
.savebar button { pointer-events:auto; box-shadow:var(--shadow-lg); }

/* Schalter (Checkbox als Toggle) */
.switch { display:flex; align-items:flex-start; gap:14px; padding:12px 0; border-bottom:1px solid var(--line); cursor:default; margin:0; color:var(--text); font-size:14px; font-weight:400; }
.switch:last-of-type { border-bottom:0; }
.switch .txt { flex:1; min-width:0; }
.switch .txt b { display:block; font-weight:600; }
.switch .txt span { color:var(--muted); font-size:13px; }
.switch input { appearance:none; -webkit-appearance:none; width:46px; min-height:0; height:26px; flex:none; border-radius:999px; background:rgba(120,120,128,.32); border:0; padding:0; position:relative; cursor:pointer; transition:background .2s; box-shadow:none; }
.switch input::after { content:""; position:absolute; top:2px; left:2px; width:22px; height:22px; border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.3); transition:transform .25s cubic-bezier(.32,.72,0,1); }
.switch input:checked { background:#34c759; }
.switch input:checked::after { transform:translateX(20px); }
.switch.warnsw input:checked { background:#ff3b30; }
.switch input:focus { outline:0; box-shadow:none; }
.switch input:focus-visible { outline:3px solid var(--accent-soft); outline-offset:2px; }
.check { display:flex; gap:10px; align-items:flex-start; color:var(--text); font-size:14px; font-weight:400; margin:0; cursor:pointer; }
.check input { width:18px; height:18px; min-height:0; margin-top:2px; accent-color:var(--accent); flex:none; }

/* ---- Suche (erster Eintrag der Seitenleiste) und Sprungliste ---- */
nav#nav button.suche { background:rgba(120,120,128,.14); color:var(--muted); margin-bottom:8px; }
nav#nav button.suche:hover { background:rgba(120,120,128,.2); }
nav#nav button.suche span { flex:1; }
kbd { font:11px ui-monospace, "SF Mono", Menlo, monospace; color:var(--muted); background:var(--surface); padding:1px 6px; border-radius:5px; }
dialog.pal { margin:12vh auto 0; width:min(540px, calc(100vw - 32px)); overflow:hidden; }
.pal-in { display:flex; align-items:center; gap:10px; padding:14px 18px; color:var(--muted); }
.pal-in input { border:0; background:transparent; box-shadow:none; font-size:17px; min-height:0; padding:0; color:var(--text); }
.pal-in input:focus { outline:0; box-shadow:none; background:transparent; }
.pal-list { max-height:50vh; overflow-y:auto; padding:0 6px 6px; }
.pal-list button { display:flex; align-items:center; gap:10px; width:100%; min-height:38px; padding:0 12px; border:0; border-radius:8px; background:transparent; text-align:left; color:var(--text); cursor:default; font:inherit; font-size:14px; }
.pal-list button svg.ic { color:var(--muted); }
.pal-list button.aktiv, .pal-list button:hover { background:var(--accent); color:#fff; }
.pal-list button.aktiv svg.ic, .pal-list button:hover svg.ic { color:#fff; }
.pal-list small { margin-left:auto; opacity:.7; }

/* ---- Buttons ---- */
button { font:inherit; }
button.p, button.d, button.k, summary.k { display:inline-flex; align-items:center; justify-content:center; gap:6px; border-radius:999px; padding:0 16px; min-height:34px; cursor:default; font-weight:400; font-size:13px; letter-spacing:-.005em; border:0; user-select:none; transition:transform .2s cubic-bezier(.32,.72,0,1), background-color .15s, color .15s, filter .15s, box-shadow .2s; }
button.p svg.ic, button.d svg.ic, button.k svg.ic, summary.k svg.ic { width:14px; height:14px; stroke-width:2; }
button.p:active:not(:disabled), button.d:active:not(:disabled), button.k:active:not(:disabled) { filter:brightness(.88); }
button.p { background:var(--accent); color:var(--on-accent); }
button.p:hover:not(:disabled) { filter:brightness(.94); }
button.d { background:var(--danger); color:#fff; }
button.d:hover:not(:disabled) { filter:brightness(.94); }
button.k, summary.k { background:var(--surface-2); color:var(--text); min-height:30px; padding:0 14px; }
button.k:hover:not(:disabled), summary.k:hover { filter:brightness(.96); }
button.k.gefahr { color:var(--danger); }
button.k.icon, summary.k.icon { padding:0 9px; }
button:disabled { opacity:.35; cursor:default; }
/* ---- Hover-Animationen: jeder Knopf reagiert weich beim Darüberfahren und Drücken ---- */
button, summary.k, .tile, .switch input { transition:transform .2s cubic-bezier(.32,.72,0,1), background-color .15s, color .15s, filter .15s, box-shadow .2s; }
button.p:hover:not(:disabled), button.d:hover:not(:disabled), button.k:hover:not(:disabled), summary.k:hover { transform:translateY(-1px) scale(1.03); box-shadow:0 6px 16px rgba(0,0,0,.16); }
button.p:active:not(:disabled), button.d:active:not(:disabled), button.k:active:not(:disabled), summary.k:active { transform:scale(.96); box-shadow:none; }
nav#nav button:hover { transform:translateX(3px); }
nav#nav button:active { transform:translateX(1px) scale(.98); }
.tile:hover { transform:translateY(-2px); box-shadow:0 8px 20px rgba(0,0,0,.12); }
.tile:active { transform:scale(.99); }
.menu-list button:hover, .pal-list button:hover { transform:translateX(2px); }
.switch input:hover { filter:brightness(1.06); }
.switch input:active::after { width:26px; }
.switch input:checked:active::after { transform:translateX(16px); }


/* ---- Tabellen ---- */
.table-wrap { overflow-x:auto; margin:0; padding:0 0 4px; }
table { width:100%; border-collapse:collapse; font-size:14px; }
th { text-align:left; padding:8px 12px; font-size:12px; font-weight:500; color:var(--muted); white-space:nowrap; }
td { text-align:left; padding:10px 12px; vertical-align:middle; }
tbody tr + tr td { border-top:1px solid var(--line); }
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; }
td input { min-height:30px; padding:4px 10px; min-width:90px; }
.empty { text-align:center; color:var(--muted); padding:28px 12px; }
.empty b { display:block; color:var(--text); margin-bottom:2px; }
.bar { display:block; height:6px; border-radius:99px; background:var(--surface-2); margin-top:5px; overflow:hidden; min-width:80px; }
.bar i { display:block; height:100%; border-radius:99px; background:var(--accent); width:0; }
.bar.out i { background:var(--danger); }
.bar.in i { background:var(--accent); }

/* ---- Badges, Hinweise ---- */
.badge { display:inline-flex; align-items:center; gap:6px; padding:0; font-size:12px; font-weight:500; background:transparent; color:var(--muted); white-space:nowrap; }
.badge.ok { color:var(--ok); }
.badge.warn { color:var(--warn); }
.badge.bad { color:var(--danger); }
.badge.info { color:var(--accent); }
.badge::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }
.badge.plain::before { display:none; }
.warn:not(.badge) { background:var(--warn-soft); border-radius:12px; padding:12px 14px; margin:16px 0 0; font-size:13px; }
.statusbar { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.statusbar .badge { font-size:13px; }
.copy { cursor:pointer; }
code { font-family:ui-monospace, "SF Mono", Menlo, monospace; background:var(--surface-2); padding:2px 6px; border-radius:5px; font-size:.92em; }
.toolbar { display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; margin-bottom:14px; }
.toolbar .field { flex:1; min-width:200px; }
.search { position:relative; }
.toolbar { align-items:flex-end; }
.search svg.ic { position:absolute; left:11px; top:10px; pointer-events:none; color:var(--muted); }
.search input { padding-left:36px; }

/* Aktionsmenü */
details.menu { position:relative; display:inline-block; }
details.menu > summary { list-style:none; cursor:pointer; }
details.menu > summary::-webkit-details-marker { display:none; }
details.menu[open] > summary { filter:brightness(.94); }
.menu-list { position:absolute; right:0; top:calc(100% + 4px); min-width:190px; background:var(--surface); border-radius:12px; box-shadow:var(--shadow-lg); padding:5px; z-index:15; }
.menu-list button { display:flex; align-items:center; gap:8px; width:100%; background:transparent; border:0; text-align:left; padding:6px 10px; border-radius:7px; color:var(--text); cursor:default; font-size:13px; }
.menu-list button:hover { background:var(--accent); color:#fff; }
.menu-list button.gefahr { color:var(--danger); }
.menu-list button.gefahr:hover { background:var(--danger); color:#fff; }
td.act { text-align:right; }
.btns { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }

/* ---- Meldung (Toast) ---- */
#meldung { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); padding:10px 20px; border-radius:999px; color:#fff; display:none; max-width:90vw; z-index:100; box-shadow:var(--shadow-lg); font-weight:500; }
#meldung.ok { background:#1d1d1f; } #meldung.fehler { background:#b3001b; }

/* ---- Dialog ---- */
dialog.dlg { border:0; border-radius:18px; padding:0; width:min(440px, calc(100vw - 32px)); background:var(--surface); color:var(--text); box-shadow:var(--shadow-lg); }
dialog.dlg::backdrop { background:rgba(0,0,0,.35); }
.dlg form { padding:22px; }
.dlg h2 { font-size:18px; margin-bottom:6px; }
.dlg .body { color:var(--muted); margin-bottom:14px; }
.dlg .field { margin-bottom:12px; }
.dlg .actions { justify-content:flex-end; margin-top:20px; }

/* ---- Laden / Fehler ---- */
.loading { display:flex; align-items:center; gap:12px; color:var(--muted); padding:40px 8px; justify-content:center; }
.spinner { width:20px; height:20px; border:3px solid var(--line-strong); border-top-color:var(--accent); border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.loaderr { text-align:center; padding:40px 12px; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration:2s; } * { transition:none !important; } }

/* ---- Anmeldung ---- */
.login-wrap { min-height:100vh; display:grid; place-items:center; padding:20px; background:var(--bg); }
.login { width:100%; max-width:380px; padding:30px; margin:0; background:var(--surface-2); border-radius:20px; }
.login .logo { width:52px; height:52px; margin:0 auto 14px; border-radius:14px; }
.login .logo svg.ic { width:26px; height:26px; }
.login h2 { text-align:center; font-size:20px; }
.login .sub { text-align:center; color:var(--muted); margin-bottom:22px; }
.login button.p { width:100%; margin-top:18px; }
.login .pwrap { position:relative; }

/* ---- Startseite ---- */
.home { max-width:560px; margin:0 auto; padding:10vh 20px; }
.home .brand { padding-bottom:22px; }
.tile { display:flex; gap:14px; align-items:center; padding:18px; margin-bottom:12px; background:var(--surface-2); border-radius:var(--radius); color:var(--text); text-decoration:none; }
.tile:hover { background:var(--accent-soft); }
.tile b { display:block; } .tile span { color:var(--muted); font-size:13.5px; }

/* ---- Mobil ---- */
@media (max-width: 860px) {
  .side { position:fixed; left:0; top:0; bottom:0; transform:translateX(-100%); transition:transform .2s; box-shadow:var(--shadow-lg); }
  .shell.offen .side { transform:none; }
  .shell.offen .scrim { display:block; position:fixed; inset:0; background:rgba(10,13,22,.5); z-index:25; }
  .top { display:flex; }
  main { padding:18px 16px 80px; }
  .stat.hero .v { font-size:36px; }
  .stats { grid-template-columns:1fr; }
  h1 { font-size:21px; }
  .page-head .pt { display:none; }
  .card.gefahr { padding:16px; }
  .menu-list { right:auto; left:0; }
}
