/* ==========================================================================
   Pink Waves Signalplaner
   ========================================================================== */
:root {
  --bg: #0e0b11; --panel: #16121a; --panel2: #1e1824; --hover: rgba(255,255,255,.05);
  --line: #2a2330; --line-strong: #3e3446; --text: #efe8f2; --muted: #9b90a5;
  --accent: #ff66c4; --accent-strong: #ff3fb0; --accent-soft: rgba(255,102,196,.16); --on-accent: #1a0f17;
  --danger: #ff5a6e; --ok: #5ee6a8; --warn: #ffb347;
  --canvas: #0b090d; --venue: #131017; --grid1: rgba(255,255,255,.045); --grid5: rgba(255,255,255,.11);
  --dev-body: #221b29; --label-bg: #18131c;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 10px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f2f6; --panel: #ffffff; --panel2: #f4eff6; --hover: rgba(0,0,0,.04);
  --line: #e4dbe8; --line-strong: #cfc3d5; --text: #1c1420; --muted: #6e6475;
  --accent: #e0359f; --accent-strong: #c81f88; --accent-soft: rgba(224,53,159,.12); --on-accent: #fff;
  --danger: #d6334a; --ok: #12996a; --warn: #c27400;
  --canvas: #ebe6ee; --venue: #ffffff; --grid1: rgba(0,0,0,.06); --grid5: rgba(0,0,0,.16);
  --dev-body: #ffffff; --label-bg: #ffffff;
  --shadow: 0 10px 30px rgba(40,10,40,.15);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.pad { padding: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.warn-txt { color: var(--warn); font-weight: 700; font-style: normal; }
.ok-txt { color: var(--ok); margin: 10px 0 0; font-size: 13px; }

/* ---------- Kopfzeile ---------- */
.topbar { flex-shrink: 0; height: 58px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo { height: 38px; width: auto; display: block; margin: -4px -6px; }
.app-name { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line); padding-left: 10px; font-weight: 700; }
.project-btn { display: flex; align-items: baseline; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; max-width: 280px; min-width: 0; flex-shrink: 1; }
.project-btn:hover { border-color: var(--accent); }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmeta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 11px; }
.tabs { display: flex; gap: 2px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 18px 10px 16px; font-size: 13.5px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.save-state { font-size: 11px; color: var(--muted); margin-right: 4px; }
.save-state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }
.save-state.dirty::before { background: var(--warn); }

/* ---------- Buttons & Felder ---------- */
.btn { background: var(--panel2); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { border-color: var(--danger); }
.btn.left { margin-right: auto; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; color: var(--muted); font-size: 16px; display: inline-grid; place-items: center; padding: 0; }
.icon-btn:hover { color: var(--text); background: var(--hover); border-color: var(--line); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.link:hover { text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.page-head .btn-row { margin-top: 0; }
.btn-row.spread { justify-content: space-between; margin: 0 0 14px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
input:not([type="checkbox"]):not([type="range"]):not([type="color"]), select, textarea {
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 9px; width: 100%; min-width: 0; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type="color"] { width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); padding: 2px; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.mini-num { width: 78px !important; padding: 4px 6px !important; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.span2 { grid-column: span 2; }
.grow { flex: 1; }
.w-sm { width: 120px; }
.tgl { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }

/* ---------- Ansichten ---------- */
#view { flex: 1; min-height: 0; overflow: hidden; }
.plan-layout { display: grid; grid-template-columns: 264px 1fr 340px; height: 100%; }
.flow-layout { display: grid; grid-template-columns: 1fr 340px; height: 100%; }
.side { background: var(--panel); overflow-y: auto; min-height: 0; }
.side.left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side.right { border-left: 1px solid var(--line); padding: 14px 16px 30px; }
.side-head { padding: 14px 12px 10px; border-bottom: 1px solid var(--line); }
.side-head h3 { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.side-foot { padding: 10px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.lib-list { flex: 1; overflow-y: auto; padding: 6px 6px 20px; }
.lib-cat-h { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 8px 8px; cursor: pointer; font-weight: 700; font-size: 12.5px; text-align: left; border-radius: 6px; }
.lib-cat-h:hover { background: var(--hover); }
.lib-cat-h i { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.lib-cat-h span { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 11px; }
.lib-cat-h::after { content: "▸"; color: var(--muted); font-size: 10px; margin-left: 4px; transition: transform .15s; }
.lib-cat.open .lib-cat-h::after { transform: rotate(90deg); }
.lib-items { padding: 0 0 6px 14px; }
.lib-item { padding: 6px 9px; border-radius: 7px; cursor: grab; border: 1px solid transparent; display: flex; flex-direction: column; user-select: none; }
.lib-item:hover { background: var(--panel2); border-color: var(--line); }
.lib-item:active { cursor: grabbing; }
.lib-item b { font-weight: 600; font-size: 13px; }
.lib-item small { color: var(--muted); font-size: 11.5px; }

.canvas-wrap { position: relative; overflow: hidden; background: var(--canvas); min-width: 0; }
.toolbar { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none; }
.toolbar > * { pointer-events: auto; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px; box-shadow: var(--shadow); }
.seg button, .tb { background: none; border: 0; padding: 6px 11px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap; }
.tb { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); }
.seg button:hover, .tb:hover { color: var(--text); background: var(--hover); }
.seg button.active { background: var(--accent); color: var(--on-accent); }
.seg .ico { display: inline-block; width: 14px; text-align: center; }
.toolbar .tgl { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; box-shadow: var(--shadow); }
.mobile-only { display: none; }
.drawer-close { display: none; position: absolute; top: 10px; z-index: 11; width: 38px; height: 38px; place-items: center; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font-size: 15px; cursor: pointer; margin: 0 8px; box-shadow: var(--shadow); }
.scalebar { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 3px; font: 600 11px var(--mono); color: var(--muted); pointer-events: none; }
.scalebar i { display: block; height: 6px; border: 2px solid var(--muted); border-top: 0; }
.coords { position: absolute; right: 14px; bottom: 14px; font: 11px var(--mono); color: var(--muted); pointer-events: none; }
.mode-hint { position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 10px); background: var(--panel); border: 1px solid var(--accent); color: var(--text); padding: 7px 14px; border-radius: 999px; font-size: 12.5px; opacity: 0; transition: .2s; pointer-events: none; box-shadow: var(--shadow); max-width: calc(100% - 200px); text-align: center; }
.mode-hint.show { opacity: 1; transform: translate(-50%, 0); }
#flowHint { border-color: var(--line); color: var(--muted); }

/* ---------- Lageplan-SVG ---------- */
svg.plan-svg, svg.flow-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
svg.plan-svg { cursor: grab; }
svg.plan-svg[data-mode="area"], svg.plan-svg[data-mode="calib"] { cursor: crosshair; }
svg.plan-svg[data-mode="cable"] .dev { cursor: crosshair; }
svg text { pointer-events: none; }
.venue { fill: var(--venue); stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.grid1, .grid5 { fill: none; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.grid1 { stroke: var(--grid1); } .grid5 { stroke: var(--grid5); }
.gridlbl text { fill: var(--muted); font-family: var(--mono); }
.bgimg { pointer-events: none; }
.area > rect:first-child { fill-opacity: .1; stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; cursor: move; }
.area.sel > rect:first-child { fill-opacity: .2; stroke-dasharray: none; stroke-width: 2; }
.alabel { font-weight: 800; letter-spacing: .1em; font-family: var(--font); }
.ahandle { fill: var(--accent); cursor: nwse-resize; }
.cable { cursor: pointer; }
.cable path { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.cable .hit { stroke: transparent; stroke-width: 14; pointer-events: stroke; }
.cable .halo { stroke: transparent; stroke-width: 8; pointer-events: none; }
.cable .line { stroke-width: 2.4; pointer-events: none; }
.cable:hover .halo { stroke: var(--hover); }
.cable.sel .halo { stroke: var(--accent); opacity: .35; }
.cable.sel .line { stroke-width: 3.2; }
.cable.wl .line { stroke-dasharray: 2 6; }
.cable.bad .halo { stroke: var(--warn); opacity: .25; }
.clabel { cursor: pointer; }
.clabel rect { fill: var(--label-bg); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.clabel.sel rect { stroke-width: 2.4; }
.clabel text { fill: var(--text); font-family: var(--mono); font-weight: 700; }
.wp { fill: var(--accent); stroke: var(--venue); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: move; }
.mid { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: copy; opacity: .9; }
.dev { cursor: move; }
.dev .body { fill: var(--dev-body); stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.dev:hover .body { stroke: var(--c, var(--accent)); }
.dev.sel .body { stroke: var(--accent); stroke-width: 2.5; }
.dev.target .body { stroke: var(--ok); stroke-width: 3; }
.dev .t1 { fill: var(--text); font-weight: 700; }
.dev .t2 { fill: var(--muted); }
.dev .hgt { fill: var(--accent); font-weight: 800; font-family: var(--mono); }
.dev .cnt { fill: var(--muted); font-family: var(--mono); }
.temp-wire { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; fill: none; }
.temp-area { fill: rgba(122,215,255,.12); stroke: #7ad7ff; stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.temp-txt { fill: var(--accent); font-family: var(--mono); font-weight: 700; }
.calib-pt { fill: var(--accent); }

/* ---------- Signalfluss-SVG ---------- */
.fbox { fill: var(--panel); stroke: var(--line-strong); stroke-width: 1; }
.fdev.unc .fbox { stroke-dasharray: 4 3; }
.fdev.hl .fbox { stroke: var(--accent); stroke-width: 2; }
.fhead { cursor: move; }
.fhead .ht { fill: #170f15; font-weight: 800; font-size: 13px; }
.fhead .hs { fill: rgba(23,15,21,.72); font-size: 10.5px; font-weight: 600; }
.frow { cursor: pointer; }
.frow rect { fill: transparent; }
.frow:hover rect { fill: var(--hover); }
.frow.hl rect { fill: var(--accent-soft); }
.frow .pn { fill: var(--text); font-size: 12px; }
.frow .pn .al { fill: var(--accent); font-weight: 700; }
.frow .pc { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.frow .pdot { fill: var(--line-strong); }
.frow.hl .pdot { fill: var(--accent); }
.frow.bundle .pn { font-weight: 700; }
.pn.muted { fill: var(--muted); font-size: 12px; font-style: italic; }
.fedge { cursor: pointer; }
.fedge path { fill: none; }
.fedge .hit { stroke: transparent; stroke-width: 12; }
.fedge .line { stroke-width: 2.2; }
.fedge:hover .line, .fedge.hl .line { stroke-width: 3.6; }
.fedge.wl .line { stroke-dasharray: 3 6; }
.fedge.dim, .flabel.dim, .fdev.dim { opacity: .16; }
.flabel { cursor: pointer; }
.flabel rect { fill: var(--label-bg); stroke-width: 1; }
.flabel text { fill: var(--text); font: 700 10.5px var(--mono); }

/* ---------- Inspektor ---------- */
.insp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.insp-head h3 { font-size: 16px; }
.insp-head .muted { font-size: 12px; }
.dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.side section { border-top: 1px solid var(--line); padding: 12px 0; }
.side section:first-of-type { border-top: 0; padding-top: 0; }
.side h4 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; }
.tips ul { padding-left: 16px; margin: 0; color: var(--muted); font-size: 12.5px; }
.tips li { margin-bottom: 6px; }
.tips b { color: var(--text); font-weight: 600; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.legend i { width: 18px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.legend span { flex: 1; }
.legend small { color: var(--muted); font-family: var(--mono); min-width: 48px; text-align: right; }
.alert { display: block; width: 100%; text-align: left; background: rgba(255,179,71,.12); border: 1px solid var(--warn); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-weight: 600; cursor: pointer; margin-bottom: 12px; font-size: 12.5px; }
table.ports { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.ports td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.ports td small { display: block; color: var(--muted); font-size: 10.5px; }
table.ports .pdir { width: 16px; color: var(--muted); text-align: center; }
table.ports .pdir.in { color: #7ad7ff; } table.ports .pdir.out { color: var(--accent); }
table.ports tr.used b { color: var(--text); }
table.ports tr:not(.used) b { font-weight: 500; color: var(--muted); }
table.ports .alias { padding: 3px 6px !important; font-size: 12px; width: 92px !important; }
table.ports .pconn { font-size: 11.5px; }
table.ports .pconn .link { display: flex; align-items: center; gap: 5px; line-height: 1.3; color: var(--text); }
table.ports .pconn .link i { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
table.ports .pconn .link.add { color: var(--muted); }
table.ports .pconn .link.add:hover { color: var(--accent); }
.cable-sum { display: grid; gap: 4px; }
.end-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.end-box small { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; }
.end-box span { color: var(--muted); font-size: 12.5px; }
.cable-sum .arrow { text-align: center; color: var(--accent); }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.tag { font-size: 10px; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; font-weight: 700; vertical-align: 1px; }
.issues { list-style: none; margin: 10px 0 0; padding: 8px 10px; background: rgba(255,179,71,.1); border: 1px solid rgba(255,179,71,.4); border-radius: 8px; color: var(--warn); font-size: 12.5px; }
.issues li + li { margin-top: 3px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 26px; height: 26px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.sw.on { border-color: var(--text); }
.sw-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }

/* Signalweg-Liste */
.hops { list-style: none; padding: 0; margin: 0; counter-reset: hop; }
.hop { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; cursor: pointer; font-size: 12.5px; background: var(--panel2); }
.hop:hover { border-color: var(--accent); }
.hop small { color: var(--muted); }
.hop-c { display: flex; align-items: center; gap: 6px; color: var(--muted); font-family: var(--mono); font-size: 11.5px; padding: 3px 0 3px 10px; border-left: 2px solid var(--line-strong); margin: 3px 0 3px 3px; }
.hop-c i { width: 10px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.hop-a, .hop-b { font-weight: 600; }

/* ---------- Seiten (Listen, Bibliothek, Projekt) ---------- */
.page { height: 100%; overflow-y: auto; padding: 24px 28px 60px; }
.page.narrow { max-width: 900px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.page-head h1::before { content: ""; display: inline-block; width: 6px; height: 22px; background: var(--accent); border-radius: 2px; margin-right: 10px; vertical-align: -3px; box-shadow: 0 0 14px var(--accent); }
.page-head p { margin: 4px 0 0; }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type="search"] { max-width: 360px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--panel2); white-space: nowrap; position: sticky; top: 0; }
table.data th[data-s] { cursor: pointer; }
table.data th[data-s]:hover { color: var(--text); }
table.data th.asc::after { content: " ▲"; color: var(--accent); }
table.data th.desc::after { content: " ▼"; color: var(--accent); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data.patch tbody tr { cursor: pointer; }
table.data.patch tbody tr:hover td { background: var(--hover); }
table.data tr.grp td { background: var(--panel2); font-weight: 700; font-size: 12.5px; }
table.data tr.has-issue td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.data tfoot td { font-weight: 700; background: var(--panel2); border-top: 1px solid var(--line); }
table.data.compact td, table.data.compact th { padding: 6px 10px; }
table.data .c { text-align: center; }
table.data .nowrap { white-space: nowrap; }
table.data.groups input, table.data.groups select { padding: 5px 7px; }
.warn { color: var(--warn); cursor: help; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; min-width: 140px; display: flex; flex-direction: column; margin: 0; }
.stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.stat b { font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.stat.bad b { color: var(--warn); }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.pack-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.pack-card h3 { font-size: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.pack-card h3 i { width: 14px; height: 5px; border-radius: 2px; }
.pack-card h3 .muted { margin-left: auto; font-weight: 500; font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.card > .muted { margin: -4px 0 12px; font-size: 13px; }

.subtabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.subtabs button { background: none; border: 0; padding: 10px 14px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.subtabs span { font-weight: 500; font-size: 12px; color: var(--muted); }
.lib-split { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.lib-col { position: sticky; top: 0; }
.lib-col .filters { margin-bottom: 8px; flex-wrap: nowrap; }
.lib-col .filters input { flex: 1; max-width: none !important; }
.lib-index { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px; max-height: calc(100vh - 290px); overflow-y: auto; }
.lib-index h5 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 10px 8px 4px; display: flex; align-items: center; gap: 7px; }
.lib-index h5 i { width: 8px; height: 8px; border-radius: 2px; }
.lib-index .li { display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 7px; padding: 6px 9px; cursor: pointer; }
.lib-index .li:hover { background: var(--hover); }
.lib-index .li.on { border-color: var(--accent); background: var(--accent-soft); }
.lib-index .li b { font-weight: 600; }
.lib-index .li small { display: block; color: var(--muted); font-size: 11.5px; }
.lib-editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.lib-editor h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.editor-head h2 { font-size: 19px; }
.editor-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.editor-foot .btn-row { margin: 0; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,3,7,.6); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body p { margin-top: 0; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal footer:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* Kabel-Dialog */
.cd-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-bottom: 6px; }
.cd-grid fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 2px; margin: 0; min-width: 0; }
.cd-grid legend { font-weight: 700; padding: 0 6px; font-size: 13px; }
.cd-grid legend small { color: var(--muted); font-weight: 500; }
.swap { font-size: 18px; color: var(--accent); }
.len-box { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.len-calc { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel2); border-bottom: 1px solid var(--line); }
.len-calc > div { padding: 8px 12px; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.len-calc > div:last-child { border-right: 0; }
.len-calc span { font-size: 11px; color: var(--muted); }
.len-calc b { font-family: var(--mono); font-size: 14px; display: flex; align-items: center; gap: 4px; }
.len-calc .sum b { color: var(--accent); }
.len-calc .mini-num { width: 62px !important; }
.pieces { padding: 10px 12px; }
.pieces .lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--c, var(--line-strong)); border-radius: 999px; padding: 4px 6px 4px 12px; font: 700 13px var(--mono); }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 11px; }
.chip button:hover { color: var(--danger); }
.plus { color: var(--muted); }
.add-piece { width: auto !important; padding: 4px 8px !important; font-size: 12.5px; }
.len-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; }
.len-foot .btn { margin-left: auto; }

/* Projekte */
.proj-list { list-style: none; margin: 0; padding: 0; }
.proj-list li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 4px 8px 4px 4px; }
.proj-list li.cur { border-color: var(--accent); }
.proj-open { flex: 1; background: none; border: 0; text-align: left; padding: 8px 10px; cursor: pointer; border-radius: 7px; display: flex; flex-direction: column; min-width: 0; }
.proj-open:hover { background: var(--hover); }
.proj-open small { font-size: 12px; }
.proj-actions { display: flex; gap: 6px; align-items: center; }

/* Toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--panel); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; max-width: 380px; transition: .4s; }
.toast.err { border-left-color: var(--danger); }
.toast.out { opacity: 0; transform: translateX(20px); }

#printArea { display: none; }

/* ---------- Responsiv ---------- */
@media (max-width: 1500px) { .app-name, .pmeta { display: none; } }
@media (max-width: 1180px) {
  .plan-layout { grid-template-columns: 230px 1fr 300px; }
  .save-state { display: none; }
}
@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px 0; gap: 8px; }
  .logo { height: 30px; }
  .project-btn { order: 2; flex: 1 1 100%; max-width: none; }
  .top-actions { order: 1; margin-left: auto; }
  .tabs { order: 3; flex-basis: 100%; margin: 0; }
  .tabs button { padding: 10px 10px 12px; }
  .toolbar .tgl, .seg .lbl { display: none; }
  .seg button, .tb { padding: 6px 9px; }
  .plan-layout, .flow-layout { grid-template-columns: 1fr; position: relative; }
  .plan-layout .side { position: absolute; top: 0; bottom: 0; z-index: 10; width: min(340px, 88vw); transition: transform .2s; box-shadow: var(--shadow); }
  .plan-layout .side.left { left: 0; transform: translateX(-105%); }
  .plan-layout .side.right { right: 0; transform: translateX(105%); }
  .plan-layout.show-left .side.left, .plan-layout.show-right .side.right { transform: none; }
  .mobile-only { display: inline-block; }
  .plan-layout.show-left .drawer-close, .plan-layout.show-right .drawer-close { display: grid; }
  .plan-layout.show-left .drawer-close { left: min(340px, 88vw); }
  .plan-layout.show-right .drawer-close { right: min(340px, 88vw); }
  .flow-layout { grid-template-rows: 1fr auto; }
  .flow-layout .side.right { border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .lib-split { grid-template-columns: 1fr; }
  .lib-col { position: static; }
  .lib-index { max-height: 260px; }
  .page { padding: 16px 14px 60px; }
  .cd-grid { grid-template-columns: 1fr; }
  .swap { justify-self: center; transform: rotate(90deg); }
  .len-calc { grid-template-columns: 1fr 1fr; }
  .mode-hint { max-width: calc(100% - 24px); bottom: 44px; }
  .pack-grid { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr 1fr; }
}

/* ---------- Druck ---------- */
@media print {
  :root, :root[data-theme] {
    --bg: #fff; --panel: #fff; --panel2: #f4f1f5; --hover: transparent; --line: #d8d0dc; --line-strong: #a99fae;
    --text: #111; --muted: #555; --accent: #d6248f; --accent-soft: rgba(214,36,143,.12); --canvas: #fff; --venue: #fff;
    --grid1: rgba(0,0,0,.07); --grid5: rgba(0,0,0,.2); --dev-body: #fff; --label-bg: #fff; --warn: #b36b00;
  }
  @page { size: A4 landscape; margin: 10mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; color: #111; font-size: 10.5pt; }
  .pp { page-break-after: always; break-after: page; }
  .pp:last-child { page-break-after: auto; }
  .pp h2 { font-size: 15pt; margin: 0 0 8px; border-bottom: 2px solid #d6248f; padding-bottom: 4px; }
  .pp svg { width: 100%; height: auto; max-height: 172mm; display: block; }
  .pp-head { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; background: #0e0b11; padding: 14px 18px; border-radius: 8px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pp-head img { height: 60px; }
  .pp-head h1 { color: #fff; font-size: 22pt; }
  .pp-head p { color: #ff66c4; margin: 4px 0 0; letter-spacing: .12em; text-transform: uppercase; font-size: 9pt; font-weight: 700; }
  table.meta { border-collapse: collapse; font-size: 11pt; }
  table.meta th { text-align: left; padding: 4px 18px 4px 0; color: #555; font-weight: 600; }
  .notes { margin-top: 18px; }
  .small { font-size: 8.5pt; color: #555; }
  table.data { font-size: 8.5pt; }
  table.data th { position: static; background: #f4f1f5; }
  table.data td, table.data th { padding: 3px 6px; }
  table.data tr { break-inside: avoid; }
  table.data tr.first td { border-top: 1.5px solid #888; }
  td.box { font-size: 12pt; text-align: center; }
  .sw-dot, .clabel rect, .fhead path, .area rect, .dev .stripe { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
