:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1b1d22;
  --muted: #6b6f78;
  --line: #e2dfd8;
  --accent: #1b1d22;
  --accent-text: #ffffff;
  --gold: #f2b33d;
  --good: #1f8a5b;
  --bad: #c2412d;
  --warn: #b7791f;
  --plan-bg: #faf9f6;
  --c-light: #f2b33d;
  --c-speaker: #3b7dd8;
  --c-adjustable: #e0762f;
  --c-sub: #7a4fc9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131417; --surface: #1c1e22; --surface-2: #25282d; --text: #eceae5; --muted: #9a9ea6;
    --line: #2f3238; --accent: #f2b33d; --accent-text: #1b1d22; --plan-bg: #22252a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131417; --surface: #1c1e22; --surface-2: #25282d; --text: #eceae5; --muted: #9a9ea6;
  --line: #2f3238; --accent: #f2b33d; --accent-text: #1b1d22; --plan-bg: #22252a; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 6px 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0 4px; color: var(--muted); text-decoration: underline; font-size: 12px; }
input[type=text], input[type=number], select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { accent-color: var(--gold); }
table { border-collapse: collapse; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.good-text { color: var(--good); }
.bad-text { color: var(--bad); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-mark { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle, var(--text) 32%, var(--gold) 34%); }
.brand-sub { font-weight: 400; color: var(--muted); }
.steps, .support-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.step { border: 0; background: transparent; padding: 6px 10px; border-radius: 999px; color: var(--muted); }
.step.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.step-n { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px; border-radius: 50%; border: 1px solid currentColor; font-size: 11px; }
.step.on .step-n { background: var(--gold); border-color: var(--gold); color: #1b1d22; }
.mode { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.support-nav { padding-right: 12px; border-right: 1px solid var(--line); }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }

main { padding: 20px; max-width: 1480px; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card.empty { text-align: center; padding: 48px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; }
.field-help { font-size: 12px; color: var(--muted); }
.banner { border-radius: 8px; padding: 10px 12px; margin: 10px 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line)); }
.badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: color-mix(in srgb, var(--gold) 25%, var(--surface)); color: var(--text); font-weight: 500; }
.badge.good { background: color-mix(in srgb, var(--good) 18%, var(--surface)); }

/* project / plan import */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; display: grid; gap: 6px; }
.dropzone:hover { border-color: var(--gold); }
.dropzone-title { font-weight: 600; font-size: 16px; }
.importer { margin-top: 12px; display: grid; gap: 8px; }
.importer-status { color: var(--muted); }
.importer-stage { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.importer-holder { position: relative; width: 100%; }
.importer-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.importer-svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.importer-svg .calib { stroke: #e0472f; }
.importer-svg .calib-pt { fill: #e0472f; }
.importer-svg .plan-draft { fill: rgba(242, 179, 61, .18); stroke: var(--gold); }
.plan-room rect { fill: rgba(59, 125, 216, .12); stroke: #3b7dd8; cursor: pointer; }
.plan-room text { fill: #1d3f73; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px; background: var(--surface-2); border-radius: 8px; }
.inline-form input, .inline-form select { width: auto; min-width: 120px; }
.zoom { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg { border: 0; border-radius: 0; border-right: 1px solid var(--line); padding: 6px 11px; background: var(--surface); }
.seg:last-child { border-right: 0; }
.seg.on { background: var(--accent); color: var(--accent-text); }

/* rooms */
.split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.room-list { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 72px; }
.room-card { text-align: left; white-space: normal; padding: 10px 12px; border-radius: 10px; }
.room-card.on { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.room-card-name { font-weight: 600; }
.add-room { border-style: dashed; }
.questions h3 { border-top: 1px solid var(--line); padding-top: 16px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { border-radius: 999px; padding: 6px 12px; }
.choice.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* design */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border-radius: 999px; }
.tab.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tab .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-left: 6px; vertical-align: middle; }
.design-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel h3 { margin-top: 0; }
.selected-panel { border-color: var(--gold); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; border-left: 4px solid var(--line); }
.metric.good { border-left-color: var(--good); }
.metric.bad { border-left-color: var(--bad); }
.metric-label { font-size: 12px; color: var(--muted); }
.metric-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-sub { font-size: 11px; color: var(--muted); }
.counts { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.count { padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border-left: 4px solid var(--c-light); }
.count.role-speakerlight { border-left-color: var(--c-speaker); }
.count.role-adjustable { border-left-color: var(--c-adjustable); }
.count.role-sublight { border-left-color: var(--c-sub); }
.checks, .why { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.checks li.warn { color: var(--warn); }
.checks li.error { color: var(--bad); }
.checks li[class] { cursor: default; }
.why li { color: var(--text); }

.plan-host { overflow-x: auto; min-height: 200px; }
.planview { position: relative; margin: 0 auto; }
.planview canvas, .planview svg { position: absolute; left: 0; top: 0; }
.planview-svg { touch-action: none; user-select: none; }
.planview-svg.tool-select .fixture { cursor: grab; }
.planview-svg[class*="tool-add"], .planview-svg.tool-keepout, .planview-svg.tool-task { cursor: crosshair; }
.room-outline { fill: none; stroke: var(--text); stroke-width: 2; }
.wall-label { font-size: 12px; fill: var(--muted); font-weight: 600; }
.fixture .fx-halo { fill: transparent; }
.fixture.selected .fx-halo { fill: rgba(255, 255, 255, .35); stroke: #fff; stroke-width: 2; stroke-dasharray: 3 2; }
.fixture.problem .fx-halo { stroke: #ff5a3c; stroke-width: 2; fill: rgba(255, 90, 60, .15); }
.fx-light { fill: var(--c-light); stroke: #1b1d22; stroke-width: 1.5; }
.fx-core { fill: #1b1d22; }
.fx-speaker { fill: var(--c-speaker); stroke: #0f2340; stroke-width: 1.5; }
.fx-speaker-ring { fill: var(--c-light); stroke: #0f2340; stroke-width: 1; }
.fx-adjustable { fill: var(--c-adjustable); stroke: #1b1d22; stroke-width: 1.5; }
.fixture .aim { stroke: var(--c-adjustable); stroke-width: 3; stroke-linecap: round; }
.fx-sub { fill: var(--c-sub); stroke: #231345; stroke-width: 1.5; }
.fx-sub-text { fill: #fff; font-size: 8px; font-weight: 800; pointer-events: none; }
.coverage circle { fill: rgba(59, 125, 216, .06); stroke: rgba(160, 200, 255, .9); stroke-width: 1.2; stroke-dasharray: 5 4; pointer-events: none; }
.zone rect { stroke-width: 1.5; }
.zone text { font-size: 11px; font-weight: 600; fill: #fff; paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 3px; pointer-events: none; }
.zone.keepout rect { fill: url(#hatch); stroke: #ff6b57; cursor: pointer; }
.hatch-bg { fill: rgba(255, 107, 87, .12); }
.hatch-line { stroke: rgba(255, 107, 87, .7); stroke-width: 2; }
.zone.task rect { fill: rgba(255, 255, 255, .08); stroke: #fff; stroke-dasharray: 6 4; cursor: pointer; }
.zone.selected rect { stroke-width: 3; }
.zone.seat rect { fill: none; stroke: #9fe6c3; stroke-dasharray: 3 3; pointer-events: none; }
.zone.seat circle { fill: #9fe6c3; }
.draft { fill: rgba(255, 255, 255, .15); stroke: #fff; stroke-dasharray: 4 3; }
.readout { font-size: 12px; color: var(--muted); padding: 6px 34px; font-variant-numeric: tabular-nums; min-height: 26px; }
.scale { margin: 4px 0 0; }
.scale-bar { height: 10px; border-radius: 3px; }
.scale-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 2px; }
.elevations .row { align-items: flex-start; gap: 16px; }
.elevation { margin: 0; }
.elevation canvas { display: block; border-radius: 4px; }
.elevation figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* proposal */
.proposal-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 12px; }
.plan-host.small { min-height: 160px; }
.table-wrap { overflow-x: auto; }
.bom, .bench { width: 100%; font-variant-numeric: tabular-nums; }
.bom th, .bom td, .bench th, .bench td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.bom th, .bench th { font-size: 12px; color: var(--muted); font-weight: 600; }
.num { text-align: right !important; }
.strong { font-weight: 700; }
.bom tfoot td { font-weight: 600; border-bottom: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--c-light); vertical-align: middle; }
.swatch.role-speakerlight { background: var(--c-speaker); }
.swatch.role-adjustable { background: var(--c-adjustable); }
.swatch.role-sublight { background: var(--c-sub); border-radius: 3px; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 12px 3px 0; }
.kv td { padding: 3px 0; }
.disclaimer { max-width: 860px; }

/* rules */
.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; align-content: start; }
.rule.wide { grid-column: 1 / -1; }
.rule.changed { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 7%, var(--surface)); }
.rule-name { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.rule-help { font-size: 12px; color: var(--muted); }
.mini td, .mini th { padding: 4px 6px; text-align: left; font-size: 13px; }
.mini th { color: var(--muted); font-weight: 600; }
.mini input, .mini select { min-width: 70px; }
.mini.wide { width: 100%; }
.bench-score { font-weight: 700; font-size: 15px; color: var(--warn); }
.bench-score.good { color: var(--good); }
.bench tr.fail td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.bench tr.pass td:first-child { box-shadow: inset 3px 0 0 var(--good); }
.bench .count { margin-right: 4px; }
.bench .issues { font-size: 12px; color: var(--warn); max-width: 420px; }
.bench .up { color: var(--bad); }
.bench .down { color: var(--good); }

/* products */
.product.inactive { opacity: .6; }
.product-grid { display: grid; gap: 14px; margin-top: 10px; }
.checks-col { display: grid; gap: 6px; align-content: center; }
.photometry, .audio-spec { border-top: 1px solid var(--line); padding-top: 12px; }
.polar { width: 200px; height: 115px; }
.polar-grid { fill: none; stroke: var(--line); }
.polar-c0 { fill: color-mix(in srgb, var(--gold) 25%, transparent); stroke: var(--gold); stroke-width: 1.5; }
.polar-c90 { fill: none; stroke: var(--c-speaker); stroke-width: 1; stroke-dasharray: 3 2; }

#toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: var(--shadow); }
.toast.warn { background: var(--warn); color: #fff; }
.toast.error { background: var(--bad); color: #fff; }
.busy { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .3); color: #fff; font-size: 16px; z-index: 200; }

@media (max-width: 1100px) {
  .design-grid { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .proposal-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  main { padding: 12px 16px; }
  .split { grid-template-columns: 1fr; }
  .room-list { position: static; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .mode { margin-left: 0; }
}
@media print {
  .no-print, .topbar, .toolbar { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
.bom tr.bom-group td { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding-top: 14px; }
.beam-group h3 { margin-top: 16px; }
.bulb { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.bulb.inactive { opacity: .55; }
.bulb-empty { height: 115px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 12px; }
.bulb-body { display: grid; gap: 6px; min-width: 0; }
.section-title { margin: 8px 4px 0; }
@media (max-width: 760px) { .bulb { grid-template-columns: 1fr; } }
.zone.art .art-line { stroke: #2fd3c0; stroke-width: 6; stroke-linecap: round; pointer-events: none; }
.zone.art .art-hit { stroke: transparent; stroke-width: 22; cursor: pointer; }
.zone.art.selected .art-line { stroke: #fff; }
.zone.art text { font-size: 11px; }
.art-list { display: grid; gap: 8px; }
.art-row { display: grid; grid-template-columns: 1.4fr 1.3fr repeat(4, minmax(70px, 1fr)) auto; gap: 8px; align-items: end; padding: 8px; background: var(--surface-2); border-radius: 8px; }
.art-field { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.art-list > button { justify-self: start; }
@media (max-width: 900px) { .art-row { grid-template-columns: 1fr 1fr; } }
.gll { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; align-items: start; padding: 10px; background: var(--surface-2); border-radius: 8px; margin-top: 8px; }
.imp-plot { width: 260px; height: 110px; }
.imp-plot text { font-size: 9px; fill: var(--muted); }
.imp-line { fill: none; stroke: var(--c-speaker); stroke-width: 1.8; }
@media (max-width: 760px) { .gll { grid-template-columns: 1fr; } }
.clf-plot { width: 300px; height: 130px; }
.clf-plot text { font-size: 9px; fill: var(--muted); }
.clf-range { fill: color-mix(in srgb, var(--gold) 18%, transparent); }
.clf-sens { fill: none; stroke: var(--c-speaker); stroke-width: 1.8; }
.clf-angle { fill: none; stroke: var(--c-adjustable); stroke-width: 1.8; }
.key-sens { color: var(--c-speaker); }
.key-angle { color: var(--c-adjustable); }
.gll { grid-template-columns: minmax(0, 1fr) auto; }
.gll .row select, label.row select { width: auto; }
