/* =====================================================================
   Design layer (js/design*.js): top-level Design mode, map symbols, schematic,
   duct cross-section, catalogue editor. Tokens from app.css; adds only
   the bundle tones below. See docs/UI_DESIGN.md §11.
   ===================================================================== */
:root {
  /* duct bundle identity (band beside the route, schematic band): neutral tones, never an effect / option / depth colour */
  --bundle-1: #37413E;  /* charcoal: the default bundle */
  --bundle-2: #B06B7D;  /* rose */
  --bundle-3: #6E6A2F;  /* dark olive */
  --bundle-4: #4F5D75;  /* slate */
  --bundle-5: #8A9490;  /* mid grey */
}

/* ---------- sidebar ---------- */
.dz-mode-context { position: sticky; top: 0; z-index: 5; padding: 10px 16px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dz-mode-context .pl-title { margin: 5px 0 0; }
.dz-option-choice { display: grid; gap: 4px; margin-top: 12px; color: var(--text-3); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.dz-option-choice select { width: 100%; font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.dz-mode-empty { padding: 24px 16px; }
.dz-mode-empty h2 { margin: 0 0 6px; font-size: 16px; }
.dz-mode-empty p { margin: 0 0 14px; font-size: 13px; color: var(--text-2); }
.dz-mode-tabs { display: flex; gap: 2px; margin: 12px -2px -12px; }
.dz-mode-tabs button { flex: 1 0 auto; padding: 8px 3px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.dz-mode-tabs button:hover { color: var(--text); }
.dz-mode-tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.dz-boq-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.dz-boq-head h3 { margin: 0 0 3px; font-size: 15px; }
.dz-boq-side-total { margin: 0 0 8px; font-size: 14px; }
.dz-boq-scroll-hint { display: none; color: var(--text-3); font-size: 11px; }
.dz-boq-group { margin-bottom: 16px; }
.dz-boq-group h4 { margin: 0 0 5px; padding-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.dz-boq-t th { color: var(--text-3); font-weight: 600; text-align: left; font-size: 11px; }
.dz-boq-t th.num, .dz-boq-t td.num { text-align: right; }
.dz-boq-t td:first-child { width: 60%; overflow-wrap: anywhere; }
.dz-boq-t td .small { line-height: 15px; }
.dz-boq-workspace, .dz-catalogue-workspace { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--surface); }
.dz-workspace-return { display: flex; align-items: center; gap: 12px; flex: none; padding: 7px 18px; border-bottom: 1px solid var(--line); color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
#dz-boq { flex: 1; min-height: 0; overflow: auto; padding: 18px 22px 36px; }
#dz-boq .dz-boq-head { max-width: 1100px; }
#dz-boq .dz-boq-group { max-width: 1100px; }
#dz-boq .dz-boq-t td:first-child { width: 48%; }
#dz-boq .dz-boq-t th:not(:first-child) { text-align: right; }
#dz-boq .dz-boq-t td:nth-child(3) { text-align: right; white-space: nowrap; }
#dz-catalogue { flex: 1; min-height: 0; overflow: hidden; }
body.design-workspace #inspector { display: none; }
body.design-workspace .pl-map-actions { display: none; }
.dz-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 10px; }
.dz-f { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); }
.dz-f select { max-width: 150px; }
.dz-f-wide { display: flex; margin-top: 10px; }
.dz-f-wide select { max-width: none; flex: 1; }
.dz-schem { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); margin-left: auto; }
.dz-schem input { margin: 0; accent-color: var(--accent); }
.dz-empty p { margin: 0 0 6px; }
.dz-sum { margin: 0 0 6px; font-size: 13px; line-height: 18px; }
.dz-chips { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.dz-chip { display: inline-flex; align-items: center; gap: 4px; }
.dz-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 1.5px solid #fff; box-shadow: 0 0 0 1px var(--accent); display: inline-block; }
.dz-ducts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin-bottom: 8px; }
.dz-ducts i { display: inline-block; width: 16px; height: 5px; border-radius: 2px; margin-right: 5px; vertical-align: 2px; }
.dz-checks { border: 1px solid var(--line); border-radius: var(--r); padding: 0 10px; margin: 6px 0 4px; }
.dz-checks > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.dz-sev { font-size: 11px; font-weight: 650; border-radius: 4px; padding: 0 5px; line-height: 16px; }
.dz-error { background: color-mix(in srgb, var(--danger) 12%, white); color: var(--danger); }
.dz-warn { background: color-mix(in srgb, var(--warn) 16%, white); color: #7A5B00; }
.dz-ok { color: var(--ok); margin: 6px 0; }
.dz-vlist { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 3px; font-size: 12px; line-height: 16px; }
.dz-vlist button { background: none; border: 0; padding: 2px 0; text-align: left; color: var(--text-2); }
.dz-vlist button:hover { color: var(--text); text-decoration: underline; }
.dz-v-error b { color: var(--danger); } .dz-v-warn b { color: #7A5B00; } .dz-v-info b { color: var(--text-3); }
.dz-structs { display: grid; gap: 6px; }
.dz-grp-h { margin: 4px 0 2px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.dz-grp ul { list-style: none; margin: 0; padding: 0; }
.dz-grp li button { display: grid; grid-template-columns: 16px 64px 1fr auto; align-items: center; gap: 6px; width: 100%; background: none; border: 0;
  padding: 3px 4px; border-radius: 5px; text-align: left; font-size: 12px; }
.dz-grp li button:hover { background: var(--bg); }
.dz-grp li.sel button { background: var(--accent-soft); }
.dz-sn { font-weight: 600; font-family: var(--mono); font-size: 11.5px; }
.dz-sr { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-sc { color: var(--text-3); font-variant-numeric: tabular-nums; }
.dz-boq { margin-top: 12px; }
.dz-boq-g { margin: 8px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; }
.dz-boq-t { width: 100%; border-collapse: collapse; font-size: 12px; }
.dz-boq-t td { padding: 3px 4px 3px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.dz-boq-t .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dz-from { color: var(--accent); }

/* ---------- right panel ---------- */
.dz-detail .pl-kicker svg { vertical-align: -2px; }
.dz-why { background: var(--surface-2); border-radius: var(--r); padding: 8px 10px; margin: 10px 0; }
.dz-why p { margin: 2px 0 0; }
.dz-edit { margin-top: 10px; }
.dz-del:hover:not(:disabled) { color: var(--danger) !important; border-color: var(--danger) !important; }
.dz-xs { margin: 10px 0 4px; }

/* symbols (sidebar, schematic): white fill, dark outline; closure = accent dot */
.ds-sym { fill: #fff; stroke: #16201D; stroke-width: 1.8; }
.ds-sym-in { fill: none; stroke: #16201D; stroke-width: 1.2; }
.ds-closure { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }

/* ---------- map: drag handle for the selected structure ---------- */
.dz-handle { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--accent); background: rgba(255,255,255,.25); cursor: grab; position: relative; }
.dz-handle.pulse { animation: dzpulse .6s ease-in-out 2; }
@keyframes dzpulse { 50% { transform: scale(1.35); } }
.dz-handle-tip { position: absolute; left: 30px; top: 2px; white-space: nowrap; background: var(--text); color: #fff; font: 11px/16px var(--mono); border-radius: 4px; padding: 0 5px; }
.dz-handle-tip:empty { display: none; }

/* ---------- schematic panel (bottom of the map) ---------- */
#map-wrap.with-schematic #map { bottom: 204px; }
#map-wrap.with-schematic .map-legend, #map-wrap.with-schematic .coords { transform: translateY(-204px); }
.dz-schem-panel { position: absolute; left: 0; right: 0; bottom: 0; height: 204px; z-index: 4; background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(22,32,29,.08); display: flex; flex-direction: column; }
.dz-schem-head { display: flex; align-items: center; gap: 10px; padding: 5px 10px 0 14px; }
.dz-schem-head .icon-btn { margin-left: auto; }
.dz-schem-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; padding: 0 10px; }
.ds-svg { display: block; font-family: var(--sans); }
.ds-hit { fill: transparent; cursor: pointer; }
.ds-line { stroke: #16201D; stroke-width: 2; }
.ds-len { font-size: 11px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.ds-km { font-size: 10px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.ds-name { font-size: 11px; font-weight: 600; fill: var(--text); font-family: var(--mono); }
.ds-band { stroke: #fff; stroke-width: 1; }
.ds-blab { font-size: 10.5px; fill: var(--text-2); }
.ds-cable { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.ds-rowlab { font-size: 10.5px; fill: var(--text-3); }
.ds-slack { fill: none; stroke: #16201D; stroke-width: 1.4; }
.ds-slack-arrow { fill: none; stroke: #16201D; stroke-width: 1.4; }
.ds-sl { font-size: 10px; fill: var(--text-2); }
.ds-warn { font-size: 13px; font-weight: 800; fill: #B7860B; }
.ds-st.hover .ds-sym, .ds-st.sel .ds-sym { stroke-width: 3; }
.ds-st.sel .ds-name { fill: var(--accent); }
.ds-st.sel .ds-sym { stroke: var(--accent); }
.ds-st.manual .ds-name { text-decoration: underline dotted; }
.ds-st.locked .ds-sym { stroke-dasharray: 3 1.5; }
.ds-span.hover .ds-line, .ds-span.sel .ds-line { stroke-width: 4; }
.ds-span.sel .ds-line { stroke: var(--accent); }
.ds-span.hover .ds-band, .ds-span.sel .ds-band { stroke: #16201D; stroke-width: 1.5; }

/* ---------- duct cross-section ---------- */
.dx-svg { display: block; max-width: 380px; }
.dx-outer { fill: var(--surface-2); stroke: #16201D; stroke-width: 1.5; }
.dx-outer.dx-reserve { stroke-dasharray: 4 3; }
.dx-tube circle:first-child { stroke: #16201D; stroke-width: 1.3; }
.dx-occ circle:first-child { fill: color-mix(in srgb, var(--accent) 18%, white); stroke: var(--accent); stroke-width: 2; }
.dx-spare circle:first-child { fill: #fff; stroke-dasharray: 3 2; }
.dx-res circle:first-child { fill: #D5DBD8; }
.dx-cable { fill: var(--accent); }
.dx-lab { font: 600 12px var(--sans); fill: var(--text); }
.dx-sub { font: 11px var(--sans); fill: var(--text-3); }
.dx-key { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; color: var(--text-2); margin: 2px 0 0; }
.dx-k { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1.3px solid #16201D; margin-left: 6px; }
.dx-k.dx-occ { background: color-mix(in srgb, var(--accent) 18%, white); border: 2px solid var(--accent); }
.dx-k.dx-spare { background: #fff; border-style: dashed; }
.dx-k.dx-res { background: #D5DBD8; }

/* ---------- catalogue editor (dialog) ---------- */
.dc-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(22,32,29,.28); display: flex; align-items: center; justify-content: center; }
.dc-dialog { width: min(1180px, 96vw); height: min(760px, 92vh); background: var(--surface); border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.2);
  display: flex; flex-direction: column; overflow: hidden; }
.dc-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 18px 6px; }
.dc-head h2 { margin: 0; font-size: 18px; }
.dc-head p { margin: 0; }
.dc-head-r { display: flex; align-items: center; gap: 8px; }
.dc-tabs { padding: 0 18px; }
.dc-body { flex: 1; overflow: auto; padding: 10px 18px; }
.dc-scroll { overflow-x: auto; }
.dc-scroll-hint { display: none; margin: 0 0 6px; color: var(--text-3); font-size: 11px; }
.dc-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.dc-table th { text-align: left; color: var(--text-3); font-weight: 550; border-bottom: 1px solid var(--line); padding: 4px 6px 4px 0; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.dc-table td { border-bottom: 1px solid var(--line-soft); padding: 5px 6px 5px 0; vertical-align: top; }
.dc-table .num { text-align: right; }
.dc-table tr.dirty td { background: color-mix(in srgb, var(--accent) 6%, white); }
.dc-code { min-width: 150px; }
.dc-code code { display: block; margin-bottom: 2px; }
.dc-name { width: 100%; min-width: 220px; }
.dc-num { width: 74px; text-align: right; }
.dc-conf { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--text-2); }
.dc-conf input { accent-color: var(--accent); }
.dc-ok { font-size: 11px; color: var(--ok); font-weight: 600; }
.dc-add { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.dc-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 18px 10px; border-top: 1px solid var(--line); background: var(--bg); }
.dc-dirty { font-size: 12px; font-weight: 600; color: var(--accent); }
.dc-inline, .dc-inline .dc-dialog { width: 100%; height: 100%; }
.dc-inline .dc-dialog { border-radius: 0; box-shadow: none; }
.dc-inline .dc-tabs { overflow-x: auto; scrollbar-width: thin; flex: none; }
.dc-inline .dc-tabs button { flex: none; white-space: nowrap; }
.dc-inline .dc-head { gap: 12px; }
.dc-inline .dc-head-r { min-width: 0; }
.dc-inline .dc-head-r select { max-width: 100%; min-width: 0; }
.dc-inline .dc-body { min-height: 0; }
@media (max-width: 900px) {
  .dz-boq-workspace, .dz-catalogue-workspace { position: fixed; top: 58px; left: 0; right: 0; bottom: 0; z-index: 19; }
  #dz-boq { padding: 12px 14px 30px; }
  #dz-boq .dz-boq-t { min-width: 650px; }
  #dz-boq .dz-boq-scroll-hint { display: block; }
  .dc-inline .dc-head { flex-wrap: wrap; padding: 10px 12px 6px; }
  .dc-inline .dc-head-r { width: 100%; }
  .dc-inline .dc-head-r select { width: 100%; }
  .dc-inline .dc-tabs { padding: 0 12px; }
  .dc-inline .dc-body { padding: 8px 12px; }
  .dc-inline .dc-scroll-hint { display: block; }
}
