:root {
  --bg: #f5f6f4; --panel: #ffffff; --ink: #1d2320; --muted: #66706a; --line: #dfe3df;
  --brand: #028b2f; --brand-ink: #ffffff; --brand-soft: #e3f3e8;
  --ok: #1f8a3a; --warn: #b7791f; --fail: #c53030; --info: #2b6cb0;
  --hot: #e4572e; --cold: #2b7bb9; --accent: #ff8a3d;
  --shadow: 0 1px 3px rgba(0,0,0,.08); --changed: #fff7e0;
  color-scheme: light;
}
/* dark: follows the system unless the user picked a theme (data-theme on <html>, see theme.js) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131715; --panel: #1b201d; --ink: #e5ebe7; --muted: #9aa69f; --line: #2c3430;
    --brand: #22b04f; --brand-ink: #0c140f; --brand-soft: #173523;
    --ok: #48c26a; --warn: #e0a440; --fail: #f06a6a; --info: #6aa8ea;
    --shadow: none; --changed: #3a3216; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131715; --panel: #1b201d; --ink: #e5ebe7; --muted: #9aa69f; --line: #2c3430;
  --brand: #22b04f; --brand-ink: #0c140f; --brand-soft: #173523;
  --ok: #48c26a; --warn: #e0a440; --fail: #f06a6a; --info: #6aa8ea;
  --shadow: none; --changed: #3a3216; color-scheme: dark;
}
.theme-btn { min-width: 34px; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 16px; }

header#top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand small { font-weight: 400; color: var(--muted); }
.logo { width: 18px; height: 18px; border-radius: 4px; background: linear-gradient(var(--hot) 0 33%, #ffc46b 33% 66%, var(--cold) 66%); }
nav#nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav#nav a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
nav#nav a.active { background: var(--brand); color: var(--brand-ink); }
nav#nav a:hover:not(.active) { background: var(--brand-soft); }
nav#nav .cnt { font-size: 11px; opacity: .7; margin-left: 3px; }
#who { display: flex; gap: 8px; align-items: center; font-size: 13px; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
h3 { font-size: 14px; margin: 12px 0 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi .v { font-size: 22px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .s { font-size: 12px; color: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 5px 11px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.danger { color: var(--fail); }
.btn:disabled { opacity: .5; cursor: default; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search] { min-width: 220px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label.f { display: block; margin-bottom: 8px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
label.f input:not([type=checkbox]), label.f select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
table.list tr.click:hover td { background: var(--brand-soft); cursor: pointer; }
table.list td.uid { white-space: nowrap; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
table.list td.num { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; border: 1px solid var(--line); white-space: nowrap; }
.st-Entwurf, .st-Schätzung, .st-Idee, .st-Geplant { background: var(--bg); }
.st-Offen, .st-Vorschlag, .st-In-Bewertung, .st-In-Bearbeitung, .st-Läuft { background: #fff3d6; color: #7a5200; border-color: #f1d79a; }
.st-Abgestimmt, .st-Beantwortet, .st-Beherrscht, .st-Favorit { background: #dff3e5; color: #11602a; border-color: #a9dcb8; }
.st-Fixiert, .st-Erledigt, .st-Geschlossen { background: var(--brand); color: #fff; border-color: var(--brand); }
.st-Verworfen { text-decoration: line-through; opacity: .6; }
.pr-Muss { color: var(--fail); font-weight: 600; } .pr-Soll { color: var(--warn); } .pr-Kann { color: var(--muted); }
.larry { color: #7b3fe4; font-weight: 600; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 1px 6px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; margin: 2px; }
.chip a { text-decoration: none; }

.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: 4px 0 4px 22px; position: relative; border-bottom: 1px dashed var(--line); }
.checks li::before { position: absolute; left: 0; font-weight: 700; }
.checks li.ok::before { content: "✓"; color: var(--ok); }
.checks li.warn::before { content: "!"; color: var(--warn); }
.checks li.fail::before { content: "✗"; color: var(--fail); }

/* parameter view */
.pgroup { margin-bottom: 14px; }
.ptable td.val { white-space: nowrap; }
.ptable td.val input { width: 100px; text-align: right; }
.ptable td.sym { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }
.ptable tr.changed td { background: var(--changed); }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
.sticky { position: sticky; top: 64px; }
dl.res { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0; }
dl.res dt { color: var(--muted); }
dl.res dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* risk matrix */
.matrix { display: grid; grid-template-columns: 28px repeat(5, 1fr); gap: 3px; max-width: 520px; }
.matrix div { min-height: 44px; border-radius: 4px; padding: 3px; font-size: 11px; display: flex; flex-wrap: wrap; gap: 2px; align-content: flex-start; }
.matrix .ax { background: none; align-items: center; justify-content: center; color: var(--muted); min-height: 0; }
.matrix a { background: rgba(0,0,0,.25); color: #fff; border-radius: 3px; padding: 0 3px; text-decoration: none; }

/* simulation */
.chart { width: 100%; height: auto; background: var(--panel); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .ax { stroke: var(--line); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 3px; margin-right: 4px; vertical-align: middle; background: var(--c); }
.ovr { display: grid; grid-template-columns: 1fr 90px; gap: 4px 8px; align-items: center; }
.ovr input { width: 90px; text-align: right; }
.ovr .diff { color: #b26b00; font-weight: 600; }

/* drawer */
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -4px 0 20px rgba(0,0,0,.15); z-index: 20; overflow-y: auto; padding: 16px; }
#drawer .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.hist { font-size: 12px; border-left: 2px solid var(--line); padding-left: 8px; margin: 6px 0; }
.comment { background: var(--bg); border-radius: 8px; padding: 6px 9px; margin: 6px 0; white-space: pre-wrap; }
.comment .meta, .hist .meta { color: var(--muted); font-size: 11px; }
.feed .new { border-left-color: #7b3fe4; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 30; }
.login { max-width: 360px; margin: 10vh auto; }
.pre { white-space: pre-wrap; }
.note { background: var(--brand-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

@media (max-width: 900px) {
  .split, .g2 { grid-template-columns: 1fr; }
  .sticky, header#top { position: static; }
  main { padding: 10px 16px; }
  table.list th { position: static; }
  .row3 { grid-template-columns: 1fr; }
}
