/* Layout: sidebar + work area on desktop, top bar with menu on phones. Tokens follow the approved draft. */
:root {
  --bg: #f3f5f3; --surface: #ffffff; --sunk: #eaeeeb; --ink: #18221f; --muted: #5a6762; --line: #dce2de;
  --accent: #1d5d58; --accent-soft: #dcebe8; --on-accent: #ffffff;
  --red: #b3332b; --red-soft: #f8e3e1; --amber: #9a6200; --amber-soft: #f8ecd3; --green: #27744a; --green-soft: #dff0e5;
  --grey-soft: #e9ecea;
  --f-body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614; --surface: #18201d; --sunk: #141b18; --ink: #e4eae7; --muted: #97a49e; --line: #2a3430;
    --accent: #62b5ab; --accent-soft: #1d3532; --on-accent: #0d1513;
    --red: #f07b70; --red-soft: #3a1f1c; --amber: #e2a845; --amber-soft: #382a12; --green: #6cc690; --green-soft: #17301f;
    --grey-soft: #232c29; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.12rem; } h3 { font-size: .98rem; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--f-mono); font-size: .88em; }
.muted { color: var(--muted); }
.klein { font-size: .8rem; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.laden { padding: 40px; color: var(--muted); text-align: center; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--sunk); border-right: 1px solid var(--line); padding: 18px 10px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 8px; display: flex; flex-direction: column; }
.brand b { font-family: var(--f-display); font-size: 1.05rem; }
.brand span { font-size: .75rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; justify-content: space-between; padding: 7px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .9rem; }
.nav a:hover { background: var(--grey-soft); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a small { color: var(--muted); font-variant-numeric: tabular-nums; }
.nav .grp { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 8px 4px; font-weight: 600; }
.side .wer { margin-top: auto; padding: 0 8px; font-size: .8rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.topbar { display: none; }
main.main { padding: 22px max(24px, env(safe-area-inset-right, 0px)) 48px 24px; display: flex; flex-direction: column; gap: 18px; min-width: 0; max-width: 1240px; }
.kopf { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; }

/* Building blocks */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.kpi .v { font-family: var(--f-display); font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: .78rem; color: var(--muted); }
.kpi.warn { border-color: var(--red); background: var(--red-soft); }
.kpi.warn .v { color: var(--red); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; }
.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.karte { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ph { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.bar-row small { display: block; color: var(--muted); font-size: .74rem; }
.track { height: 12px; background: var(--grey-soft); border-radius: 3px; overflow: hidden; display: flex; }
.fill { height: 100%; background: var(--accent); }
.fill.plan { opacity: .45; }
.bar-row .a { text-align: right; font-weight: 600; }
.legende { display: flex; gap: 14px; font-size: .76rem; color: var(--muted); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--accent); }
.legende i.plan { opacity: .45; }

.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; text-align: left; padding: 8px 10px; background: var(--sunk); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.klick { cursor: pointer; }
tr.klick:hover td { background: var(--sunk); }
tfoot td { font-weight: 700; background: var(--sunk); }
.leer { padding: 22px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.p-red { background: var(--red-soft); color: var(--red); }
.p-amber { background: var(--amber-soft); color: var(--amber); }
.p-green { background: var(--green-soft); color: var(--green); }
.p-grey { background: var(--grey-soft); color: var(--muted); }
.p-acc { background: var(--accent-soft); color: var(--accent); }
.stripe { border-left: 3px solid var(--line); padding-left: 8px; }
.s-red { border-left-color: var(--red); } .s-amber { border-left-color: var(--amber); } .s-green { border-left-color: var(--green); }

.due { display: flex; flex-direction: column; }
.due a { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0 9px 8px; border-bottom: 1px solid var(--line); align-items: center; color: inherit; text-decoration: none; }
.due a:last-child { border-bottom: 0; }
.due a:hover { background: var(--sunk); }
.due .d { font-weight: 600; font-variant-numeric: tabular-nums; font-size: .85rem; }
.due small { display: block; color: var(--muted); font-size: .76rem; }

.btn { font: inherit; font-size: .86rem; font-weight: 600; border-radius: 6px; padding: 7px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.gefahr { color: var(--red); }
.btn.sm { padding: 3px 9px; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: default; }
.aktionen { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .82rem; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

form.formular { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
form.formular .breit { grid-column: 1 / -1; }
.feld { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.feld input, .feld select, .feld textarea, input.suche {
  font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
.feld textarea { min-height: 70px; resize: vertical; }
.feld input:focus, .feld select:focus, .feld textarea:focus { border-color: var(--accent); outline: none; }
.check { display: flex; gap: 8px; align-items: center; font-size: .88rem; }
.meldung { padding: 9px 12px; border-radius: 6px; font-size: .88rem; }
.meldung.fehler { background: var(--red-soft); color: var(--red); }
.meldung.ok { background: var(--green-soft); color: var(--green); }
.hinweis { font-size: .82rem; color: var(--muted); background: var(--sunk); border-radius: 6px; padding: 9px 11px; }
dl.dl { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: .9rem; }
dl.dl dt { color: var(--muted); }
dl.dl dd { margin: 0; }
.progress { height: 8px; background: var(--grey-soft); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); }
.kopieren { display: flex; gap: 6px; }
.kopieren input { flex: 1; font-family: var(--f-mono); font-size: .8rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.login .karte { width: 100%; max-width: 400px; padding: 26px; gap: 16px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.qr { align-self: center; background: #fff; padding: 8px; border-radius: 8px; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: fixed; inset: 0; z-index: 20; height: auto; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .shell.menu-offen .side { display: flex; }
  .topbar { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
  .topbar b { font-family: var(--f-display); }
  main.main { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  form.formular { grid-template-columns: minmax(0, 1fr); }
  .bar-row { grid-template-columns: 110px minmax(0, 1fr); }
  .bar-row .a { grid-column: 2; text-align: left; }
  dl.dl { grid-template-columns: 120px minmax(0, 1fr); }
  .kpi .v { font-size: 1.12rem; }
  .nur-breit { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
