:root {
    --panel: #ffffff;
    --bg: #e9edf2;
    --ink: #1d2430;
    --accent: #1769aa;
    --danger: #b42318;
    --success: #137333;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    height: 100vh;
    display: flex;
    overflow: hidden;
  }
  #sidebar {
    width: 330px;
    min-width: 330px;
    background: var(--panel);
    border-right: 1px solid #cbd3dc;
    padding: 16px;
    overflow-y: auto;
  }
  h1 { font-size: 20px; margin: 0 0 8px; }
  h2 { font-size: 15px; margin: 18px 0 8px; }
  p, label { font-size: 13px; line-height: 1.45; }
  .note {
    padding: 10px;
    border-left: 4px solid var(--accent);
    background: #f5f9fd;
    border-radius: 4px;
  }
  .toolbar, .row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }
  button, select, textarea, input[type="number"], input[type="text"] {
    font: inherit;
  }
  button {
    border: 0;
    border-radius: 5px;
    padding: 9px 10px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
  }
  button.secondary { background: #5f6b78; }
  button.success { background: var(--success); }
  button.danger { background: var(--danger); }
  button.light { background: #eef2f6; color: #24303c; border: 1px solid #c7d0da; }
  button.active { outline: 3px solid rgba(23,105,170,.25); }
  button:disabled { opacity: .45; cursor: not-allowed; }
  input[type="range"] { width: 100%; }
  input[type="number"], input[type="text"], textarea, select {
    width: 100%;
    padding: 8px;
    border: 1px solid #c7d0da;
    border-radius: 5px;
  }
  textarea { min-height: 82px; resize: vertical; }
  .label-box { fill: rgba(23,105,170,.05); stroke: #1769aa; stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }
  .label-resize-handle { fill: #fff; stroke: #1769aa; stroke-width: 2; cursor: ew-resize; vector-effect: non-scaling-stroke; }
  #main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  #topbar {
    background: #f8fafc;
    border-bottom: 1px solid #cbd3dc;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
  }
  #canvasWrap {
    flex: 1;
    overflow: auto;
    padding: 18px;
  }
  #stage {
    width: 2100px;
    height: 1400px;
    position: relative;
    background: white;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
    transform-origin: top left;
  }
  svg { width: 2100px; height: 1400px; display: block; }
  .wall {
    stroke: #111;
    stroke-width: 5;
    stroke-linecap: square;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
  }
  .wall.selected { stroke: #1769aa; }
  .door {
    stroke: #d97706;
    stroke-width: 3;
    fill: none;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
  }
  .door.selected { stroke: #1769aa; }
  .opening-cut { stroke: #fff; stroke-width: 10; vector-effect: non-scaling-stroke; pointer-events: none; }
  .opening-guide { stroke: #7c3aed; stroke-width: 3; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; cursor: pointer; }
  .opening.selected .opening-guide { stroke: #1769aa; stroke-width: 4; }
  .label {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: middle;
    fill: #111;
    cursor: move;
    user-select: none;
  }
  .label.selected { fill: #1769aa; font-weight: 700; }
  .handle {
    fill: #fff;
    stroke: #1769aa;
    stroke-width: 2;
    cursor: grab;
    vector-effect: non-scaling-stroke;
  }
  .grid-line { stroke: #eef1f4; stroke-width: 1; }
  .reference { pointer-events: none; }
  .status-pill {
    padding: 4px 8px;
    border-radius: 999px;
    background: #e9f2fb;
    color: #164f7c;
    font-weight: 600;
  }
  .small { font-size: 12px; color: #5e6873; }
  .field { margin-bottom: 10px; }
  .field label { display: block; margin-bottom: 4px; font-weight: 600; }

  .layer-grid { display:grid; gap:6px; margin-bottom:10px; }
  .layer-grid>div { display:grid; grid-template-columns:1fr auto; gap:6px; align-items:center; }
  .layer-grid label { display:flex; gap:4px; align-items:center; }
  .inventory { display:grid; gap:5px; }
  .inventory button { text-align:left; font-size:11px; padding:6px 8px; }
  .fixture-body { stroke:#243447; stroke-width:1.5; vector-effect:non-scaling-stroke; cursor:move; }
  .fixture-clearance { fill:rgba(220,38,38,.20); stroke:rgba(185,28,28,.65); stroke-width:1; stroke-dasharray:4 3; vector-effect:non-scaling-stroke; pointer-events:none; }
  .fixture-label { font-family:"Segoe UI",Arial,sans-serif; font-weight:700; fill:#111; text-anchor:middle; dominant-baseline:middle; pointer-events:none; }
  .fixture-selected .fixture-body { stroke:#1769aa; stroke-width:3; }
  .fixture-multi-selected .fixture-body { stroke:#7c3aed; stroke-width:3; }
  .fixture-individually-locked .fixture-body { stroke:#475569; stroke-width:2.5; stroke-dasharray:4 2; cursor:not-allowed; }
  .fixture-individually-locked .fixture-label { fill:#334155; font-weight:700; }
  .staging-zone { fill:#f8fafc; stroke:#94a3b8; stroke-width:2; stroke-dasharray:8 6; }
  .staging-label { font-size:16px; font-weight:700; fill:#475569; }
  .flow-line { fill:none; stroke-linecap:round; cursor:move; }
  .flow-hit { fill:none; stroke:transparent; stroke-width:16; cursor:move; }
  .flow-arrowhead { cursor:move; }
  .flow-object.selected .flow-line { filter: drop-shadow(0 0 2px #1769aa); }
  .flow-object.selected .flow-hit { stroke:rgba(23,105,170,.18); }
  .flow-label { font-family:"Segoe UI",Arial,sans-serif; font-weight:700; text-anchor:middle; dominant-baseline:auto; pointer-events:none; paint-order:stroke; stroke:#fff; stroke-width:3px; stroke-linejoin:round; }
  .section-help { background:#fff8e1; border-left:4px solid #d97706; padding:8px; border-radius:4px; font-size:12px; margin-bottom:8px; }


  .layer-panel { margin-top:12px; }
  .inventory-scroll { max-height:280px; overflow-y:auto; padding-right:3px; }
  .equipment-body { stroke:#1e3a5f; stroke-width:1.6; vector-effect:non-scaling-stroke; cursor:move; }
  .equipment-placeholder { stroke-dasharray:6 4; fill:#e2e8f0; }
  .equipment-label { font-family:"Segoe UI",Arial,sans-serif; font-weight:800; fill:#111827; text-anchor:middle; dominant-baseline:middle; pointer-events:none; paint-order:stroke; stroke:white; stroke-width:2.5px; }
  .equipment-selected .equipment-body { stroke:#7c3aed; stroke-width:3.5; }
  .equipment-locked .equipment-body { stroke:#475569; stroke-dasharray:4 2; cursor:not-allowed; }
  .equipment-staging-zone { fill:#f8fafc; stroke:#64748b; stroke-width:2; stroke-dasharray:9 6; }
  .equipment-staging-label { font-size:16px; font-weight:800; fill:#334155; }
  .bottleneck-zone { stroke-width:2; stroke-dasharray:7 5; cursor:move; }
  .bottleneck-label { font-family:"Segoe UI",Arial,sans-serif; font-weight:800; text-anchor:middle; dominant-baseline:middle; pointer-events:none; paint-order:stroke; stroke:white; stroke-width:3px; }
  .bottleneck-selected .bottleneck-zone { stroke:#7c3aed !important; stroke-width:4; }
  .heat-legend { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; margin-bottom:10px; }
  .legend-item { display:flex; align-items:center; gap:6px; font-size:11px; }
  .legend-swatch { width:16px; height:16px; border-radius:3px; border:1px solid rgba(0,0,0,.25); flex:0 0 auto; }


  .layer-panel { margin-top:12px; }
  .inventory-scroll { max-height:280px; overflow-y:auto; padding-right:3px; }
  .equipment-mount-wall .equipment-body { stroke-dasharray:2 2; }
  .equipment-mount-ceiling .equipment-body { stroke-dasharray:6 3; }
  .equipment-inactive .equipment-body { fill:#cbd5e1 !important; stroke:#64748b !important; fill-opacity:.48 !important; }

  @media print {
    body { display: block; background: white; overflow: visible; }
    #sidebar, #topbar { display: none !important; }
    #main, #canvasWrap { display: block; padding: 0; overflow: visible; }
    #stage { box-shadow: none; transform: none !important; }
    .reference { display: none !important; }
    .handle { display: none !important; }
    @page { size: landscape; margin: 0.25in; }
  }