:root {
  --bg: #0a0a0b; --panel: #121214; --panel2: #19191c; --line: #26262b; --text: #ececee; --muted: #8a8a93;
  --accent: #f2c230; --accent-ink: #111; --ok: #3ecf8e; --warn: #f5a524; --crit: #ff7a45; --err: #ff5d5d; --info: #5aa9ff;
  --l1: #a0703c; --l2: #6b6b74; --l3: #b8b8c0;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
:root.light {
  --bg: #f4f4f5; --panel: #ffffff; --panel2: #f1f1f3; --line: #e0e0e4; --text: #18181b; --muted: #6b6b74;
  --accent: #d9a400; --accent-ink: #111; --l3: #55555c; color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger, .danger { color: var(--err); }
button.ghost { background: none; border-color: transparent; padding: 2px 6px; }
button.ghost:hover { border-color: var(--line); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
textarea { width: 100%; font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.qty { width: 64px; }
input.n { width: 70px; }
input.n2 { width: 110px; }
label { color: var(--muted); font-size: 12px; display: grid; gap: 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
code, pre { font-family: var(--mono); font-size: 12px; background: var(--panel2); border-radius: 4px; padding: 1px 4px; }
pre { padding: 10px; overflow: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--err); }
.ok { color: var(--ok); }

.top { display: flex; align-items: center; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.bolt { color: var(--accent); text-shadow: 0 0 10px var(--accent); }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
nav a.active, nav a:hover { color: var(--text); background: var(--panel2); }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
main.wide { max-width: none; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 8px; color: var(--muted); font-weight: 600; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; align-items: flex-end; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.empty { padding: 40px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.search { width: 100%; max-width: 360px; margin-bottom: 12px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel2); }
table.list td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--panel2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); margin-right: 4px; color: var(--muted); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.error { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.notice.error { background: color-mix(in srgb, var(--err) 12%, transparent); border: 1px solid color-mix(in srgb, var(--err) 40%, transparent); }

/* Planung */
.evhead { margin-bottom: 12px; }
.evhead .title { font-size: 20px; font-weight: 700; background: none; border-color: transparent; padding: 4px 6px; width: 100%; max-width: 640px; }
.evhead .title:hover { border-color: var(--line); }
.cols { display: grid; grid-template-columns: 320px minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.col-left, .col-right { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
@media (max-width: 1200px) { .cols { grid-template-columns: 280px minmax(0, 1fr); } .col-right { grid-column: 1 / -1; position: static; max-height: none; } }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } .col-left { position: static; max-height: none; } }

.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px 2px 8px; margin: 2px 4px 2px 0; cursor: grab; user-select: none; font-size: 13px; }
.chip .muted { margin-left: 4px; }
.chip.locked { border-color: var(--info); }
.chip.sel { outline: 2px solid var(--accent); }
.chip.dragging { opacity: .4; }
.chip-act { display: inline-flex; margin-left: 4px; }
.chip-act button { font-size: 11px; padding: 0 4px; }
.unassigned { min-height: 60px; border: 1px dashed var(--line); border-radius: 8px; padding: 6px; }
.dragover { outline: 2px dashed var(--accent) !important; background: color-mix(in srgb, var(--accent) 8%, transparent); }

.feed { margin-bottom: 18px; }
.feed-head { padding: 6px 2px; }
.feed.loose .feed-head { color: var(--warn); }
.feed-edit { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.branch { border-left: 2px solid var(--line); padding-left: 10px; margin-top: 10px; }
.distro { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.distro.amp-over, .distro.conflict { border-color: var(--err); }
.distro.amp-crit { border-color: var(--crit); }
.distro.flash { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .2s; }
.distro-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 6px; }
.live { color: var(--muted); }
.live.on { color: var(--ok); }
.cable { margin: 8px 0; flex-wrap: wrap; }
.cable input, .cable select { padding: 3px 6px; font-size: 12px; }
.outputs { border-top: 1px solid var(--line); margin-top: 6px; }
.ogroup { border-left: 3px solid var(--panel2); margin: 6px 0; padding-left: 6px; }
.ogroup-h { padding: 4px 0 0; }
.out { display: grid; grid-template-columns: 200px minmax(0, 1fr) 190px; gap: 10px; align-items: center; padding: 5px 4px; border-bottom: 1px solid var(--line); border-radius: 4px; }
.out:last-child { border-bottom: 0; }
.out.target { cursor: copy; }
.out.target:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.out-l { display: flex; align-items: center; gap: 6px; }
.out-r { display: flex; align-items: center; gap: 6px; }
.drop-hint { font-style: italic; }
@media (max-width: 1000px) { .out { grid-template-columns: 1fr; } }

.phbadge { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); min-width: 26px; text-align: center; }
.phbadge.L1, .phl.L1 { color: var(--l1); border-color: var(--l1); }
.phbadge.L2, .phl.L2 { color: var(--muted); }
.phbadge.L3, .phl.L3 { color: var(--l3); }
.phbadge.L3P { color: var(--accent); border-color: var(--accent); }
.inrush { font-size: 11px; white-space: nowrap; }
.inrush.amp-warn { color: var(--warn); } .inrush.amp-over { color: var(--err); } .inrush.amp-ok { color: var(--muted); }

.phases { display: grid; gap: 3px; }
.ph { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 6px; align-items: center; font-size: 12px; }
.phl { font-family: var(--mono); font-weight: 700; }
.meas { font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.amp-ok.meas, td.amp-ok { color: var(--ok); } .amp-warn.meas, td.amp-warn { color: var(--warn); } .amp-crit.meas, .amp-over.meas, td.amp-crit, td.amp-over { color: var(--err); }
.bar { position: relative; height: 16px; background: var(--panel2); border-radius: 4px; overflow: hidden; flex: 1; min-width: 80px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--ok); opacity: .75; }
.bar.amp-warn i { background: var(--warn); }
.bar.amp-crit i { background: var(--crit); }
.bar.amp-over i { background: var(--err); opacity: 1; }
.bar span { position: relative; color: var(--text); text-shadow: 0 0 3px var(--bg); font-size: 11px; padding: 0 6px; line-height: 16px; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.kpis div { background: var(--panel2); border-radius: 8px; padding: 8px; }
.kpis small { display: block; color: var(--muted); font-size: 11px; }
.kpis b { font-size: 16px; }
.mini { margin-top: 8px; }
ul.warnings { list-style: none; margin: 0; padding: 0; }
ul.warnings li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; font-size: 13px; cursor: pointer; background: var(--panel2); }
ul.warnings li.error { border-left: 3px solid var(--err); }
ul.warnings li.warn { border-left: 3px solid var(--warn); }
ul.warnings li.info { border-left: 3px solid var(--info); color: var(--muted); }
.add-distro { border-style: dashed; }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(640px, 100%); max-height: 90vh; overflow: auto; }
#toast { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 30; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--err); }
