/* Busbar Route Configurator — app shell in the style of current professional tools:
   neutral surfaces, one blue accent for selection and focus, hairline borders, sentence case, light and dark themes. */
:root {
  --bg: #f7f7f8; --sidebar: #fafafa; --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #ececef;
  --border: #e6e6e9; --border-strong: #d4d4d8;
  --fg: #18181b; --fg-2: #3f3f46; --muted: #71717a; --faint: #a1a1aa;
  --accent: #2563eb; --accent-fg: #ffffff; --accent-subtle: #eef3fe; --accent-ring: rgba(37, 99, 235, .28);
  --primary: #18181b; --primary-fg: #ffffff; --primary-hover: #27272a;
  --ok: #15803d; --ok-subtle: #ecfdf3; --warn: #b45309; --warn-subtle: #fffbeb; --bad: #dc2626; --bad-subtle: #fef2f2;
  --copper: #b4632a;
  --plan-bg: #ffffff; --plan-grid: #f1f1f3; --plan-grid-2: #e3e3e7; --plan-ul: #b5b9c1; --plan-wall: #6b7280; --plan-text: #8a909a; --plan-label: #1e3a5f; --plan-halo: #ffffff;
  --viewer-bg: #f2f3f5; --viewer-grid: #d3d8de; --viewer-grid-2: #e3e6ea;
  --shadow-float: 0 1px 2px rgba(16, 18, 24, .06), 0 4px 16px rgba(16, 18, 24, .08);
  --shadow-pop: 0 8px 30px rgba(16, 18, 24, .16);
  --r: 6px; --r-lg: 10px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --f-head: var(--font); --f-body: var(--font); --f-mono: var(--mono);
  --sb-w: 232px; --top-h: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0c0c0e; --sidebar: #111113; --surface: #161618; --surface-2: #1c1c1f; --surface-3: #26262a;
  --border: #27272a; --border-strong: #3a3a40;
  --fg: #f4f4f5; --fg-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
  --accent: #5b8ff9; --accent-fg: #ffffff; --accent-subtle: rgba(91, 143, 249, .14); --accent-ring: rgba(91, 143, 249, .35);
  --primary: #f4f4f5; --primary-fg: #18181b; --primary-hover: #e4e4e7;
  --ok: #4ade80; --ok-subtle: rgba(74, 222, 128, .1); --warn: #fbbf24; --warn-subtle: rgba(251, 191, 36, .1); --bad: #f87171; --bad-subtle: rgba(248, 113, 113, .1);
  --copper: #e09a62;
  --plan-bg: #121214; --plan-grid: #1b1b1e; --plan-grid-2: #26262b; --plan-ul: #4a4f58; --plan-wall: #8b909a; --plan-text: #7c838f; --plan-label: #a9c6ff; --plan-halo: #121214;
  --viewer-bg: #141417; --viewer-grid: #30343b; --viewer-grid-2: #22252a;
  --shadow-float: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0c0c0e; --sidebar: #111113; --surface: #161618; --surface-2: #1c1c1f; --surface-3: #26262a;
  --border: #27272a; --border-strong: #3a3a40;
  --fg: #f4f4f5; --fg-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
  --accent: #5b8ff9; --accent-fg: #ffffff; --accent-subtle: rgba(91, 143, 249, .14); --accent-ring: rgba(91, 143, 249, .35);
  --primary: #f4f4f5; --primary-fg: #18181b; --primary-hover: #e4e4e7;
  --ok: #4ade80; --ok-subtle: rgba(74, 222, 128, .1); --warn: #fbbf24; --warn-subtle: rgba(251, 191, 36, .1); --bad: #f87171; --bad-subtle: rgba(248, 113, 113, .1);
  --copper: #e09a62;
  --plan-bg: #121214; --plan-grid: #1b1b1e; --plan-grid-2: #26262b; --plan-ul: #4a4f58; --plan-wall: #8b909a; --plan-text: #7c838f; --plan-label: #a9c6ff; --plan-halo: #121214;
  --viewer-bg: #141417; --viewer-grid: #30343b; --viewer-grid-2: #22252a;
  --shadow-float: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .92em; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.eyebrow { font-size: 12.5px; font-weight: 500; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 16px; height: 16px; flex: none; display: block; }
i[data-icon] { display: contents; }
kbd { font: 500 11px var(--mono); color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.logo { color: var(--fg); flex: none; }
.sb-title { min-width: 0; display: flex; flex-direction: column; }
.sb-title b { font-weight: 600; font-size: 14px; }
.sb-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-search { margin: 4px 10px 8px; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.sb-search span { flex: 1; }
.sb-search:hover { border-color: var(--border-strong); color: var(--fg-2); }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: 12px; font-weight: 500; color: var(--faint); padding: 14px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r); background: none; color: var(--fg-2); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.nav-item .ic { color: var(--muted); }
.nav-item:hover { background: var(--surface-3); color: var(--fg); }
.nav-item.on { background: var(--surface-3); color: var(--fg); font-weight: 500; }
.nav-item.on .ic { color: var(--fg); }
.nav-item span:first-of-type { flex: 1; }
.nav-badge { font-size: 11.5px; font-weight: 600; color: var(--bad); font-variant-numeric: tabular-nums; }
.sb-foot { border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.credit { font-size: 12px; color: var(--muted); padding: 2px 8px 4px; }
.credit a { color: var(--fg-2); font-weight: 600; text-decoration: none; white-space: nowrap; }
.credit a:hover { color: var(--accent); text-decoration: underline; }
.scrim { display: none; }

.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar { height: var(--top-h); display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; }
.crumbs .crumb-proj { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.crumbs .crumb-sep { color: var(--faint); }
.crumbs .crumb-cur { font-weight: 600; white-space: nowrap; }
.crumbs .crumb-sys { font: 12px var(--mono); color: var(--muted); padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--border); white-space: nowrap; }
.tb-spacer { flex: 1; }
.tb-group { display: flex; }
.status { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; font: inherit; font-size: 13px; color: var(--fg-2); padding: 6px 8px; border-radius: var(--r); cursor: pointer; white-space: nowrap; }
.status:hover { background: var(--surface-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.icon-btn.menu-btn { display: none; }

main { flex: 1; min-height: 0; }
.pane { display: none; height: 100%; overflow: auto; padding: 24px 28px 56px; }
.pane.on { display: block; }
.pane.fixed { padding: 0; overflow: hidden; }
.pane > .stack { display: flex; flex-direction: column; gap: 20px; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: space-between; align-items: flex-end; }
.page-head > div:first-child { min-width: 0; max-width: 760px; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; }
.card > h2, .card-h { padding: 14px 16px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h2 { padding: 0; }
.card-h > .small { color: var(--muted); }
.card-b { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-b.flush { padding: 8px 0 0; }
.card-b.flush > .tbl { border-top: 1px solid var(--border); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

/* ---------- controls ---------- */
.btn { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; font: 500 13px var(--font); color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.pri:hover { background: var(--primary-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-subtle); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn .ic { width: 15px; height: 15px; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r); background: none; color: var(--fg-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn.toggle { color: var(--faint); }
.icon-btn.toggle.on { color: var(--fg); background: var(--surface-3); }
.btn.toggle.on { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border-radius: 8px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; font: 500 12.5px var(--font); color: var(--muted); background: none; border: 0; border-radius: 6px; cursor: pointer; }
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--border); }
.seg button[disabled] { opacity: .4; cursor: not-allowed; }
input, select, textarea { font: inherit; font-size: 13.5px; color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); padding: 0 10px; height: 32px; width: 100%; min-width: 0; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input.num, input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input[type=file] { display: none; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--fg-2); font-weight: 500; }
label.f small { font-weight: 400; font-size: 12px; color: var(--muted); }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--fg-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- status text ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.acc { color: var(--accent); } .pill.cu { color: var(--copper); }
.note { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--fg-2); }
.note::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 1px; background: var(--muted); -webkit-mask: var(--i-info) center / contain no-repeat; mask: var(--i-info) center / contain no-repeat; }
.note.warn { background: var(--warn-subtle); } .note.warn::before { background: var(--warn); -webkit-mask-image: var(--i-alert); mask-image: var(--i-alert); }
.note.bad { background: var(--bad-subtle); } .note.bad::before { background: var(--bad); -webkit-mask-image: var(--i-alert); mask-image: var(--i-alert); }
.note.ok { background: var(--ok-subtle); } .note.ok::before { background: var(--ok); -webkit-mask-image: var(--i-check); mask-image: var(--i-check); }
.note > * { min-width: 0; }
:root {
  --i-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E");
  --i-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20z'/%3E%3Cpath d='M12 10v4M12 17h.01'/%3E%3C/svg%3E");
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E");
}
.tag { font: 12px var(--mono); color: var(--fg-2); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }

/* ---------- summary strip (replaces stat tiles) ---------- */
.kpis { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 0; }
.kpi { flex: 1 1 150px; display: flex; flex-direction: column; gap: 2px; padding: 2px 20px; border-left: 1px solid var(--border); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi .eyebrow { font-size: 12.5px; }
.kpi .v { font-size: 19px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .d { font-size: 12px; color: var(--muted); }
.kpi.bad .v { color: var(--bad); }

/* ---------- tables ---------- */
.tbl { overflow-x: auto; min-width: 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { font-weight: 500; font-size: 12.5px; color: var(--muted); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
th.num { text-align: right; }
td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td, tbody tr:hover td { background: var(--surface-2); }
tr.sel td { background: var(--accent-subtle); }
tr.sum td { font-weight: 600; background: var(--surface-2); }
tr.grand td { font-weight: 600; border-top: 1px solid var(--border-strong); }
td input, td select { height: 28px; font-size: 12.5px; padding: 0 8px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------- canvases with floating tools ---------- */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100%; }
.canvas-wrap { position: relative; min-width: 0; min-height: 0; background: var(--plan-bg); }
.plan { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; user-select: none; }
.viewer { position: absolute; inset: 0; background: var(--viewer-bg); }
.viewer canvas { display: block; }
.float-bar { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-float); max-width: calc(100% - 24px); flex-wrap: wrap; }
.float-bar .seg { background: none; padding: 0; }
.float-bar .seg button.on { background: var(--accent-subtle); color: var(--accent); box-shadow: none; }
.float-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.float-chip { position: absolute; display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; pointer-events: none; max-width: calc(100% - 24px); }
.float-chip.right { top: 12px; right: 12px; font-family: var(--mono); }
.float-chip.bottom { left: 12px; bottom: 12px; }
.float-chip #plan-xy:empty { display: none; }
.float-chip.bottom:not(:has(span:not(:empty))) { display: none; }
.inspector { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.inspector .sec { padding: 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.inspector .sec:last-child { border-bottom: 0; }
.inspector .sec h3 { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 13.5px; }
.inspector .form-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.inspector table { font-size: 12.5px; }
.inspector td, .inspector th { padding: 6px 8px; }
.inspector ol { color: var(--fg-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---------- plan svg ---------- */
.pl-bg { fill: var(--plan-bg); }
.pl-grid { stroke: var(--plan-grid); stroke-width: 1; fill: none; }
.pl-grid2 { stroke: var(--plan-grid-2); stroke-width: 1; fill: none; }
.pl-origin { stroke: var(--plan-ul); stroke-width: 1; }
.pl-ul { stroke: var(--plan-ul); stroke-width: 1; fill: none; }
.pl-wall { stroke: var(--plan-wall); stroke-width: 2; fill: none; }
.pl-ult { fill: var(--plan-text); font-family: var(--font); }
.pl-run-bg { stroke: var(--accent-subtle); stroke-linecap: butt; }
.pl-run { stroke-width: 4; stroke-linecap: round; cursor: pointer; }
.pl-run.sel { stroke: #f59e0b !important; stroke-width: 5; }
.pl-run.err { stroke-dasharray: 8 4; }
.pl-riser { fill: var(--plan-bg); stroke: var(--accent); stroke-width: 2.5; }
.pl-riser.sel { stroke: #f59e0b; }
.pl-riser-ar { fill: var(--accent); pointer-events: none; }
.pl-len { font: 500 11px var(--mono); fill: var(--plan-label); paint-order: stroke; stroke: var(--plan-halo); stroke-width: 3px; pointer-events: none; }
.pl-joint { stroke: var(--fg-2); stroke-width: 1.6; pointer-events: none; }
.pl-ctag { font: 600 10px var(--mono); fill: var(--plan-label); paint-order: stroke; stroke: var(--plan-halo); stroke-width: 3px; pointer-events: none; }
.pl-node { fill: var(--plan-bg); stroke: var(--accent); stroke-width: 2; cursor: pointer; }
.pl-node.feed { fill: var(--copper); stroke: var(--copper); }
.pl-node.end { fill: var(--surface-3); stroke: var(--fg-2); }
.pl-node.sel { stroke: #f59e0b; stroke-width: 3; }
.pl-node.from { stroke: var(--ok); stroke-width: 3; }
.pl-node.err { stroke: var(--bad); }
.pl-feedt { font: 700 10px var(--mono); fill: #fff; pointer-events: none; }
.pl-nlbl { font: 500 11px var(--font); fill: var(--copper); paint-order: stroke; stroke: var(--plan-halo); stroke-width: 3px; pointer-events: none; }
.pl-tap { fill: #16a34a; stroke: #14532d; stroke-width: 1; cursor: grab; }
.pl-tap.sel { fill: #f59e0b; stroke: #92400e; }
.pl-tap.err { fill: var(--bad); }
.pl-tapl { stroke: #16a34a; stroke-width: 1; pointer-events: none; }
.pl-taplbl { font: 500 10px var(--font); fill: var(--ok); paint-order: stroke; stroke: var(--plan-halo); stroke-width: 3px; pointer-events: none; }
.pl-preview { stroke: var(--ok); stroke-width: 3; stroke-dasharray: 6 4; pointer-events: none; }
.pl-preview-pt { fill: var(--ok); pointer-events: none; }
.pl-plen { font: 600 12px var(--mono); fill: var(--ok); paint-order: stroke; stroke: var(--plan-halo); stroke-width: 3px; pointer-events: none; }
.pl-scale { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.pl-scalet { font: 11px var(--mono); fill: var(--muted); }

/* ---------- product family choice ---------- */
.fam-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fam { position: relative; border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: 14px; cursor: pointer; background: var(--surface); text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; transition: border-color .12s, box-shadow .12s; }
.fam:hover { border-color: var(--faint); }
.fam.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fam.on::after { content: ""; position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; background: var(--accent); -webkit-mask: var(--i-check) center / contain no-repeat; mask: var(--i-check) center / contain no-repeat; }
.fam b { font-weight: 600; font-size: 14px; padding-right: 22px; }
.fam .sw { height: 6px; width: 40px; border-radius: 3px; }
.fam p { font-size: 12.5px; color: var(--muted); }
.fam .small.mono { color: var(--muted); }

/* ---------- drawings ---------- */
.dwg-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.dwg-list { max-height: calc(100vh - 190px); overflow-y: auto; padding: 4px; }
.dwg-list button { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; border: 0; border-radius: var(--r); background: none; padding: 8px 10px; cursor: pointer; font: inherit; font-size: 13px; color: var(--fg-2); }
.dwg-list button:hover { background: var(--surface-2); }
.dwg-list button.on { background: var(--accent-subtle); color: var(--fg); }
.dwg-list .no { font: 12px var(--mono); color: var(--muted); }
.dwg-list button.on .no { color: var(--accent); }
.dwg-view { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; box-shadow: var(--shadow-float); }
.dwg-view svg { width: 100%; height: auto; display: block; }

/* ---------- quotation document (always paper white) ---------- */
.paper { background: #fff; color: #1b1b1b; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 32px 34px; font-size: 13px; box-shadow: var(--shadow-float); display: flex; flex-direction: column; gap: 16px; color-scheme: light; }
.paper table th { background: #f4f4f5; color: #52525b; position: static; }
.paper td, .paper th { border-color: #e4e4e7; }
.paper tbody tr:hover td { background: transparent; }
.paper .q-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; border-bottom: 2px solid #1b1b1b; padding-bottom: 14px; }
.paper .lbl { font-size: 11.5px; font-weight: 600; color: #71717a; margin-bottom: 4px; }
.paper .grid-2 { gap: 12px; }
.paper .tot { margin-left: auto; width: min(360px, 100%); }
.paper .tot td { border: 0; padding: 3px 8px; }
.paper .tot tr.grand td { border-top: 2px solid #1b1b1b; }
.paper .sign { display: flex; justify-content: flex-end; }
.paper .sign div { border-top: 1px solid #1b1b1b; padding-top: 6px; width: 220px; text-align: center; font-size: 12.5px; margin-top: 30px; }

/* ---------- chart ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--mono); fill: var(--muted); }

/* ---------- dialogs, palette, toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9, 9, 11, .45); z-index: 50; display: grid; place-items: start center; padding: 12vh 16px 16px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: min(560px, 100%); max-height: 76vh; overflow: auto; display: flex; flex-direction: column; box-shadow: var(--shadow-pop); }
.modal .mh { padding: 16px 18px 4px; display: flex; justify-content: space-between; align-items: center; }
.modal .mh h2 { font-size: 16px; }
.modal .mb { padding: 12px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal .mf { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; }
.issue { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.issue:last-child { border-bottom: 0; }
.issue span.t { flex: 1; }
.palette { width: min(600px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); overflow: hidden; display: flex; flex-direction: column; max-height: 66vh; }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-in input { border: 0; box-shadow: none; height: 48px; padding: 0; font-size: 15px; background: none; }
.palette-in input:focus { box-shadow: none; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-group { font-size: 12px; color: var(--faint); padding: 8px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--fg-2); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.palette-item .ic { color: var(--muted); }
.palette-item span { flex: 1; }
.palette-item.on { background: var(--surface-3); color: var(--fg); }
.palette-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13.5px; }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--primary); color: var(--primary-fg); padding: 9px 14px; border-radius: 8px; font-size: 13px; max-width: 440px; box-shadow: var(--shadow-pop); animation: rise .16s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- import / export ---------- */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.exp-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.exp-card .fmt { font: 500 12px var(--mono); color: var(--muted); }
.exp-card h3 { font-size: 14px; }
.exp-card p { font-size: 13px; color: var(--muted); flex: 1; }
.roadmap { background: var(--surface-2); border-style: dashed; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(380px, 1fr) auto; }
  .inspector { border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
  .pane.fixed { overflow: auto; }
  .dwg-grid { grid-template-columns: minmax(0, 1fr); }
  .fam-cards { grid-template-columns: minmax(0, 1fr); }
  .crumbs .crumb-sys { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-pop); }
  .sidebar.open + .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(9, 9, 11, .4); }
  .icon-btn.menu-btn { display: inline-grid; }
  .pane { padding: 16px 16px 48px; }
  .topbar { padding: 0 8px; }
  .topbar .btn:not(.pri) { display: none; }
  .crumbs .crumb-proj, .crumbs .crumb-sep { display: none; }
  .float-bar .seg button span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .toasts { display: none !important; }
}
