/* TresCAD — анализ чертежей: рабочее пространство по этапам (оболочка плагина).
   Расширяет styles.css; токены — terminal.css. Цвета не задаются руками: только токены. */

/* ── режимы страницы: подготовка (файл, листы) и работа (этапы) ── */
.dw { grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: 44px 40px auto minmax(0, 1fr) 196px;
  grid-template-areas: "title title" "stages stages" "tools tools" "canvas right" "bottom bottom"; }
body[data-mode="intake"] .dw { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr); grid-template-areas: "title" "intake"; }
body[data-mode="intake"] .dw-ws { display: none !important; }
body[data-mode="work"] .dw-intake { display: none !important; }
.stagebar { grid-area: stages; } .intake { grid-area: intake; } .snapbar { grid-area: auto; }
.dw [hidden] { display: none !important; }
.dw .titlebar .grow { flex: 1; }
.dw .titlebar .btn-secondary { height: 28px; font-size: 12px; padding: 0 10px; }

/* ── подготовка ── */
.dw-intake { display: flex; flex-direction: column; min-height: 0; }
.intake-steps { display: flex; gap: 0; padding: 0 12px; border-bottom: 1px solid var(--border-soft); }
.istep { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 11px; color: var(--text-muted); text-align: left; transition: color 120ms ease, box-shadow 160ms var(--ease-out); }
.istep .num { color: var(--text-disabled); font-size: 12px; }
.istep b { font-weight: 500; } .istep small { color: var(--text-dim); font-size: 11px; }
.istep.is-active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); } .istep.is-active .num { color: var(--accent); }
.intake-stage { flex: 1; min-height: 0; position: relative; background: var(--bg); }

/* ── этапы и панель инструментов ── */
.stagebar { display: flex; align-items: stretch; padding: 0 8px; border-bottom: 1px solid var(--border-soft); background: var(--bg); }
.stage-tab { display: flex; align-items: baseline; gap: 10px; padding: 0 18px; color: var(--text-muted); transition: color 120ms ease, box-shadow 160ms var(--ease-out); }
.stage-tab .num { color: var(--text-disabled); font-size: 12px; }
.stage-tab b { font-weight: 500; font-size: 13px; }
.stage-tab.is-active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.stage-tab.is-active .num { color: var(--accent); }
.stage-utils { display: flex; align-items: center; gap: 2px; }
.util { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted); }
.util svg { width: 14px; height: 14px; }
.util:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.util:disabled { color: var(--text-disabled); cursor: default; }
.dw .toolbar { padding: 4px 12px; gap: 0; }
.dw .toolbar .tools { align-items: center; }
/* stage 01 has many tools: on a narrow window they wrap to a second row instead of hiding behind a scroll */
.dw .toolbar .tools[data-for="zones"] { flex-wrap: wrap; overflow: visible; row-gap: 2px; }
.dw .toolbar .tools[data-for="zones"] .tool { padding-left: 4px; padding-right: 4px; min-width: 52px; }
.dw .toolbar .tools[data-for="zones"] .sep { margin: 6px 3px; align-self: stretch; min-height: 28px; }
.dw .tools[hidden] { display: none; }
.tool-danger:not(:disabled) svg { color: var(--danger); }
.tool:disabled { cursor: default; }
.seg-group { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; margin-right: 8px; }
.seg-label { padding: 0 10px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.seg { height: 28px; padding: 0 12px; font-size: 12px; color: var(--text-muted); border-left: 1px solid var(--border-soft); transition: background-color 120ms ease, color 120ms ease; }
.seg:hover { background: var(--hover); color: var(--text); }
.seg.is-active { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.seg-inline { margin: 0; width: max-content; }
.seg-inline .seg:first-child { border-left: 0; }

/* ── холст ── */
.dw .canvas { padding: 10px 16px 12px; position: relative; }
.dw .canvas-head { margin-bottom: 8px; gap: 8px; }
.facade-tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.ftab { display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 12px; color: var(--text-muted); border-radius: var(--radius-sm); white-space: nowrap; max-width: 220px; transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease; }
.ftab .num { color: var(--text-disabled); }
.ftab span:last-child { overflow: hidden; text-overflow: ellipsis; }
.ftab:hover { background: var(--hover); color: var(--text); }
.ftab.is-active { color: var(--text); background: var(--hover); box-shadow: inset 0 -2px 0 var(--accent); }
.ftab.is-active .num { color: var(--accent); }
.ftab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-disabled); flex: none; }
.ftab .dot.is-on { background: var(--ok); }
.dw-view { position: absolute; inset: 0; }
#draw { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; cursor: default; }
#draw.t-draw { cursor: crosshair; }
#draw.is-pan { cursor: grabbing; }
#draw .sheet { fill: #fff; }
#draw .z { stroke: var(--guide); stroke-width: 1.2; vector-effect: non-scaling-stroke; fill-rule: evenodd; cursor: pointer; }
#draw .z.k-roof { stroke: #6aa5e8; }
#draw .z.k-fence, #draw .z.k-ignored { stroke: #8a8a88; stroke-dasharray: 2 3; }
#draw .z.is-off.k-wall { stroke: #8a8a88; stroke-dasharray: 2 3; }
#draw .z.is-warn { stroke-dasharray: 6 3; }
#draw .z.is-ai { stroke: #b48cf2; stroke-width: 1.8; stroke-dasharray: 5 3; }
#draw .z.is-sel { stroke: var(--accent); stroke-width: 2.2; stroke-dasharray: none; }
#draw .o { fill: #e5484d2e; stroke: var(--danger); stroke-width: 1.3; vector-effect: non-scaling-stroke; stroke-dasharray: 6 3; cursor: pointer; }
#draw .o.o-door { fill: #ff7a1a2e; stroke: var(--accent); }
#draw .o.is-ai { stroke: #b48cf2; fill: #b48cf22e; }
#draw .o.is-sel { stroke-width: 2.4; stroke-dasharray: none; }
#draw .ln { stroke: var(--guide); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linecap: round; cursor: pointer; }
#draw .ln.c-inside { stroke-dasharray: 7 4; }
#draw .ln.k-plinth_line, #draw .ln.k-cornice, #draw .ln.k-trim_line { stroke-width: 2.2; }
#draw .ln.is-prop { opacity: .7; stroke-width: 2.4; }
#draw .ln.is-sel { stroke: var(--accent); stroke-dasharray: none; stroke-width: 3.6; }
#draw .ln-hit { stroke: transparent; stroke-width: 12; vector-effect: non-scaling-stroke; cursor: pointer; }
#draw .trim { fill: none; stroke: var(--guide); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 1 3; pointer-events: none; opacity: .9; }
#draw .sill { fill: none; stroke: var(--guide); stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; opacity: .85; }
#draw .sc-ex { stroke: var(--guide); stroke-width: 1.4; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .sc-ex-t { font: 500 10px var(--font); fill: #0a5; paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
#draw .h { fill: #fff; stroke: var(--accent); vector-effect: non-scaling-stroke; stroke-width: 1.5; cursor: move; }
#draw .h:hover { fill: var(--accent); }
#draw .h.is-sel { fill: var(--accent); }
#draw .eb { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; fill: none; opacity: .55; cursor: move; vector-effect: non-scaling-stroke; }
#draw .eb:hover { opacity: 1; }
#draw .lbl { font: 500 10px var(--font); fill: #111; paint-order: stroke; stroke: #fff; stroke-linejoin: round; pointer-events: none; text-anchor: middle; dominant-baseline: central; }
#draw .lead { stroke: #111; opacity: .5; pointer-events: none; }
#draw .draft { fill: #ff7a1a22; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; pointer-events: none; }
#draw .poly-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .poly-fill { fill: #ff7a1a14; stroke: none; pointer-events: none; }
#draw .poly-band { stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; pointer-events: none; }
#draw .poly-band.is-bad { stroke: var(--danger); }
#draw .poly-close { stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 1 4; opacity: .7; pointer-events: none; }
#draw .poly-pt { fill: #fff; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .poly-pt.is-first { fill: var(--accent); }
#draw .poly-pt.is-first.is-hot { stroke: #fff; stroke-width: 2; }
#draw .ruler { stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .marq { fill: #96969614; stroke: var(--text-secondary); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 3; pointer-events: none; }
#draw .sn { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .sn-acq { stroke: var(--guide); }
#draw .sn-guide { stroke: var(--guide); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 2 4; pointer-events: none; }
#draw .sn-t { font: 500 10px var(--font); fill: var(--text); paint-order: stroke; stroke: var(--bg-canvas); stroke-width: 3px; pointer-events: none; }
#draw .dm { stroke: var(--guide); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .dm-t { font: 500 10px var(--font); fill: var(--text); paint-order: stroke; stroke: var(--bg-canvas); stroke-width: 3px; pointer-events: none; text-anchor: middle; }

.dw-busy { position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 10px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); font-size: 12px; color: var(--text-muted); }
/* ── status strip above the canvas: tool, hint, typed sizes, messages, progress (D-045: nothing transient over the editing area) ── */
.dw-status { display: flex; align-items: center; gap: 10px; height: 30px; flex: none; margin-bottom: 6px; padding: 0 4px 0 0; font-size: 11px; color: var(--text-dim); min-width: 0; }
.dw-status .grow { flex: 0 0 0; }
.dw-status .st-tool { flex: none; height: 22px; padding: 0 8px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.dw-status .st-tool.is-tool { color: var(--accent); border-color: var(--border); }
@media (hover: hover) { .dw-status .st-tool:hover { background: var(--hover); color: var(--text); } }
.dw-status .st-hint, .dw-status .st-msg { margin: 0; min-width: 0; line-height: 14px; max-height: 28px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  pointer-events: none; opacity: 0; transition: opacity 800ms ease; }
.dw-status .st-hint { flex: 1 1 0; color: var(--text-muted); }
.dw-status .st-msg { flex: 0 0 auto; max-width: 46%; padding-left: 8px; border-left: 2px solid var(--accent); color: var(--text); }
.dw-status .is-on { opacity: 1; transition-duration: 120ms; }
.dw-status .is-gone { visibility: hidden; }
.dw-status .st-msg.is-gone { display: none; }
.dw-status .st-help { flex: none; width: 24px; height: 24px; }
.dw-status .st-help svg { width: 14px; height: 14px; }
.dw-status .dw-busy { position: static; flex: none; padding: 0; border: 0; background: none; font-size: 11px; gap: 8px; }
.dw-status .dw-dim { position: static; flex: none; flex-direction: row; gap: 10px; padding: 0; border: 0; background: none; pointer-events: auto; z-index: auto; }
.dw-status .dw-dim[hidden], .dw-status .dw-busy[hidden] { display: none; }
.dw-status .dw-dim input { width: 64px; height: 20px; }
@media (prefers-reduced-motion: reduce) { .dw-status .st-hint, .dw-status .st-msg { transition-duration: 1ms; } }
body[data-stage="spec"] .dw-status .st-hint { display: none; }
/* the loupe is docked over the right column while points are picked: it never covers the sheet */
.dw-loupe { position: fixed; width: 168px; height: 168px; border: 1px solid var(--accent); border-radius: var(--radius); overflow: hidden; pointer-events: none; background: #fff no-repeat; box-shadow: 0 6px 24px #0008; z-index: 8; }
.dw-loupe[hidden] { display: none; }
.dw-keys { max-width: 860px; }
.dw-keys .keys-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; margin: 10px 0 14px; }
.dw-keys dl.kv { grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 12px; align-content: start; }
.dw-keys dt { color: var(--accent); white-space: nowrap; }
@media (max-width: 760px) { .dw-keys .keys-cols { grid-template-columns: minmax(0, 1fr); } }
/* work mode: messages go to the strip; the floating toast is only for the intake steps */
body[data-mode="work"] #toast { display: none; }
.dw-loupe i { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 1px solid var(--accent); border-radius: 50%; }
.dw-loupe i::before, .dw-loupe i::after { content: ""; position: absolute; background: var(--accent); }
.dw-loupe i::before { left: 50%; top: -6px; bottom: -6px; width: 1px; }
.dw-loupe i::after { top: 50%; left: -6px; right: -6px; height: 1px; }
.dw-dim { pointer-events: none; position: absolute; display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 11px; color: var(--text-dim); z-index: 4; }
.dw-dim label { display: flex; align-items: center; gap: 6px; }
.dw-dim input { width: 78px; height: 22px; background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); color: var(--text); font: inherit; padding: 0 6px; text-align: right; }
.dw-dim input:focus-visible { outline: 0; border-color: var(--accent); }
.dw-dim input.is-fixed { border-color: var(--accent); }
.dw-dim u { text-decoration: none; }

.dw-range { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.dw-range input { width: 84px; accent-color: var(--accent); }

/* ── полоса «Привязки и режимы» ── */
.snapbar { position: relative; margin-top: 8px; padding-top: 8px; gap: 6px 8px; align-items: center; }
.snapbar .modes-title { margin-right: 4px; }
.snapbar .mode-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.snapbar .snap-btn { width: auto; padding: 0 10px; }
.snapbar .snap-arrow { width: 22px; padding: 0; }
.snapbar .snap-btn:disabled { opacity: .5; cursor: default; }
.snap-btn span { font-size: 12px; }
.snap-main { display: inline-flex; }
.snap-main .snap-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.snap-arrow { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; padding: 0 4px; }
.snap-menu { position: absolute; left: 90px; bottom: 100%; margin-bottom: 4px; z-index: 6; min-width: 300px; padding: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 28px #000a; }
.snap-menu label { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 5px 8px; font-size: 12px; border-radius: var(--radius-sm); cursor: pointer; }
.snap-menu label:hover { background: var(--hover); }
.snap-menu small { color: var(--text-dim); }
.snap-menu svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 1.6; }
.dw-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); margin-left: 4px; flex-wrap: wrap; }
.dw-legend .lg { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--guide); margin-left: 10px; }
.dw-legend .lg-roof { border-top-color: #6aa5e8; }
.dw-legend .lg-win { border-top: 2px dashed var(--danger); }
.dw-legend .lg-door { border-top: 2px dashed var(--accent); }
.dw-legend .lg-corner { border-top: 3px solid var(--guide); }
.dw-legend .lg-ai { border-top: 2px dashed #b48cf2; }
/* an element marked data-stage-only="a b" exists only on stages a and b */
body[data-stage="zones"] [data-stage-only]:not([data-stage-only~="zones"]),
body[data-stage="layout"] [data-stage-only]:not([data-stage-only~="layout"]),
body[data-stage="spec"] [data-stage-only]:not([data-stage-only~="spec"]) { display: none !important; }
/* ── stage «Раскладка»: panels from the plugin core over the sheet ── */
#draw .lay-p { fill-opacity: .30; stroke: #0d0d0dcc; stroke-width: 1; vector-effect: non-scaling-stroke; }
#draw .lay-p.is-cut { fill-opacity: .16; stroke-dasharray: 3 2; }
#draw .lay-j { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
#draw .lay.is-stale { opacity: .35; }
body[data-stage="layout"] #draw .z { fill-opacity: .06 !important; pointer-events: none; }
body[data-stage="layout"] #draw .o, body[data-stage="layout"] #draw .ln-hit { pointer-events: none; }
body[data-stage="layout"] #draw { cursor: grab; }
.dw-lay .lay-mat { padding: 8px 0 10px; border-bottom: 1px solid var(--border-soft); }
.dw-lay .lay-mat:last-child { border-bottom: 0; }
.dw-lay .lay-mat-h { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 8px; }
.dw-lay .lay-mat-h b { font-weight: 400; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-lay .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.dw-lay .lay-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.dw-lay .lay-f { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-dim); }
.dw-lay .lay-f input { width: 74px; height: 24px; background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: 12px; padding: 0 6px; text-align: right; }
.dw-lay .lay-f input:focus-visible { outline: 0; border-color: var(--accent); }
.dw-lay .lay-opts { display: flex; gap: 14px; margin-top: 8px; font-size: 11px; color: var(--text-muted); }
.dw-lay .lay-opts label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.dw-lay .lay-table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.dw-lay .lay-table th { font-weight: 400; color: var(--text-dim); text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--border-soft); }
.dw-lay .lay-table td { text-align: right; padding: 3px 4px; color: var(--text-muted); }
.dw-lay .lay-table th:first-child, .dw-lay .lay-table td:first-child { text-align: left; }
.dw-lay .lay-table tr.sum td { color: var(--text); border-top: 1px solid var(--border-soft); }
.dw-lay .lay-table.is-stale { opacity: .45; }
.dw-lay .lay-kv { margin-top: 10px; font-size: 11px; grid-template-columns: max-content 1fr; }
.dw-lay .lay-banner { margin-bottom: 8px; padding: 6px 10px; font-size: 11px; border-left: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent); }
.dw-lay .lay-banner.is-err { border-color: var(--danger); color: var(--text); background: #e5484d1f; }

/* ── правая колонка ── */
.dw-empty { color: var(--text-dim); font-size: 12px; padding: 4px 10px; }
.dw .zones { min-height: 120px; }
.dw .zones .panel-head { margin-bottom: 8px; }
.dw-mini { appearance: none; background: transparent; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); color: var(--text-muted); font: inherit; font-size: 11px; height: 22px; padding: 0 6px; cursor: pointer; }
.dw-mini option { background: var(--panel); }
.dw .zone .z-body span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw .zone.is-off { opacity: .55; }
.dw .zone .z-sw { width: 10px; height: 10px; margin-top: 4px; border-radius: 2px; border: 1px solid #0007; flex: none; }
.dw .zone .z-sw.o-window { background: var(--danger); }
.dw .zone .z-sw.o-door { background: var(--accent); }
.dw .zone .z-sw.l-line { background: var(--guide); height: 3px; margin-top: 6px; }
.dw .zone .z-flag { display: block; margin-left: auto; color: var(--accent); font-size: 11px; }
.dw .zone .z-flag.is-mid { color: var(--text-dim); }
.dw-row-sm { margin-top: 8px; }
.dw-row-sm .btn-secondary { height: 26px; font-size: 11px; padding: 0 8px; }
.dw .btn-secondary:disabled, .dw .btn-primary:disabled { opacity: .45; cursor: default; }
.dw-inc { margin-top: 10px; padding: 0; }
.dw-why { margin: 10px 0 0; font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.dw-why:empty { display: none; }
.dw-warns { margin: 10px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-muted); }
.dw-warns li { padding-left: 2ch; text-indent: -2ch; }
.dw-warns li::before { content: "! "; color: var(--accent); }
.dw .field input#p-name { color: var(--text); }
.dw .field[hidden], .dw .check[hidden] { display: none; }
.color-row { display: flex; align-items: center; gap: 8px; height: 28px; }
.color-row input[type=color] { width: 36px; height: 22px; padding: 0; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--bg-surface); cursor: pointer; }
.color-row code { color: var(--text-muted); font-size: 12px; }
.vcount { display: flex; align-items: center; gap: 8px; padding-left: 8px; font-size: 12px; color: var(--text-muted); }
.vcount.is-over { color: var(--accent); }
.vcount.is-over::before { content: "!"; font-weight: 600; }

.dw-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dw-table td, .dw-table th { padding: 5px 0; border-bottom: 1px solid var(--border-soft); vertical-align: top; text-align: left; }
.dw-table th { font-weight: 400; color: var(--text-dim); font-size: 11px; }
.dw-table tr:last-child td { border-bottom: 0; }
.dw-table td.num, .dw-table th.num { text-align: right; white-space: nowrap; padding-left: 12px; }
.dw-table td.num { color: var(--text); }
.dw-table .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid #0007; margin-right: 8px; vertical-align: -1px; }
.dw-table .unk { color: var(--text-dim); }
.dw-table tr.sum td { color: var(--text); font-weight: 500; border-top: 1px solid var(--border); }

.dw-ai-note { margin: 0 0 8px; font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.dw-ai-note.is-err { color: var(--text-muted); }
.dw-ai textarea { width: 100%; resize: vertical; min-height: 44px; margin-bottom: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 6px 8px; font: inherit; font-size: 12px; }
.dw-ai textarea:focus-visible { outline: 0; border-color: var(--accent); }
.dw-ai-kv { margin-top: 10px; } .dw-ai-kv dd { color: var(--text-muted); }
.dw-ai-log { margin-top: 10px; max-height: 150px; overflow-y: auto; gap: 5px; } .dw-ai-log:empty { display: none; }
.dw-check-log { max-height: 170px; overflow-y: auto; gap: 5px; margin-bottom: 10px; }
.dw-check-log .cmd { cursor: pointer; }
.dw-check-log .cmd.is-ok .line { color: var(--ok, var(--accent)); }
.dw .log li.is-fail .line, .dw .log li.is-warn .line { color: var(--text); }
.dw .log li.is-fail .line::before { color: var(--danger); opacity: 1; }
.dw .log li.is-undone { opacity: .45; text-decoration: line-through; }
.dw .log .who-ai { color: #b48cf2; font-weight: 500; }
.dw .logp { min-height: 150px; }

/* ── подготовка: загрузка и листы ── */
.dw-drop { position: absolute; inset: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-muted); text-align: center; cursor: pointer; padding: 24px; transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out); }
.dw-drop svg { width: 28px; height: 28px; color: var(--text-dim); }
.dw-drop b { font-weight: 500; color: var(--text); font-size: 14px; }
.dw-drop span { font-size: 12px; max-width: 56ch; }
.dw-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dw-drop:focus-within { border-color: var(--accent); }
.dw-sheets-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 12px; color: var(--text-muted); background: var(--bg); }
.dw-sheets { position: absolute; inset: 57px 0 0 0; overflow-y: auto; padding: 16px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; list-style: none; }
.dw-sheet { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; font-size: 11px; color: var(--text-dim); }
.dw-sheet .th { position: relative; aspect-ratio: 1.414; background: #fff; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; }
.dw-sheet.is-port .th { aspect-ratio: .707; }
.dw-sheet img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dw-sheet .cap { display: flex; gap: 8px; align-items: baseline; }
.dw-sheet .cap b { font-weight: 500; color: var(--text-muted); }
.dw-sheet .cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-sheet .tick { position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border: 1px solid #0008; border-radius: var(--radius-sm); background: #fffd; }
.dw-sheet .badge { position: absolute; right: 6px; top: 6px; padding: 1px 6px; border-radius: var(--radius-sm); background: #121212d9; color: var(--text-muted); font-size: 10px; }
.dw-sheet .badge.is-scan { color: var(--danger); }
.dw-sheet.is-on .th { outline: 2px solid var(--accent); outline-offset: 1px; }
.dw-sheet.is-on .tick { background: var(--accent); border-color: var(--accent); }
.dw-sheet.is-on .cap b { color: var(--accent); }

/* ── нижняя полоса ── */
.dw .bottom > .panel { padding: 12px 16px; overflow-y: auto; }
.dw .bottom .kv { gap: 3px 16px; }
.dw .bottom { grid-template-columns: 1.3fr .9fr 1.1fr 1.6fr; }
.dw .assistant .bubble { overflow-y: auto; max-height: 100px; }
.stale-line { margin-bottom: 8px; font-size: 11px; color: var(--text-dim); line-height: 1.4; min-height: 15px; }
.stale-line.is-stale { color: var(--accent); }
.stale-line.is-stale::before { content: "! "; }
.stale-line.is-ok { color: var(--ok); }
.export-row { flex-wrap: wrap; }
.export-row .btn-secondary { padding: 0 8px; }
.export-row .btn-secondary span { font-size: 11px; }

/* ── этап 02: спецификация ── */
.dw-spec { position: absolute; inset: 0; overflow: auto; background: var(--bg); }
.spec-banner { position: sticky; top: 0; z-index: 2; padding: 8px 20px; font-size: 12px; background: var(--accent-soft); border-bottom: 1px solid var(--accent); color: var(--accent); }
.spec-banner::before { content: "РАСЧЁТ УСТАРЕЛ · "; font-weight: 600; }
.spec-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; color: var(--text-muted); padding: 32px; }
.spec-empty b { color: var(--text); font-weight: 500; font-size: 14px; }
.spec-empty span { font-size: 12px; max-width: 56ch; }
.spec-body { padding: 18px 24px 40px; }
.spec-body.is-stale { opacity: .5; }
.spec-log { margin: 0 0 22px; max-width: 120ch; gap: 6px; }
.spec-log li { display: block; }
.spec-log li.is-warn { color: var(--text-muted); padding-left: 2ch; text-indent: -2ch; }
.spec-log li.is-warn::before { content: "! "; color: var(--accent); }
.spec-section { margin: 0 0 26px; }
.spec-section h3 { font-size: 11px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); margin: 0 0 8px; }
.spec-table { width: 100%; max-width: 1100px; border-collapse: collapse; font-size: 12px; }
.spec-table th { font-weight: 400; color: var(--text-dim); font-size: 11px; text-align: right; padding: 6px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.spec-table th:first-child, .spec-table td:first-child { text-align: left; padding-left: 0; }
.spec-table td { padding: 7px 12px; border-bottom: 1px solid var(--border-soft); text-align: right; font-variant-numeric: tabular-nums; }
.spec-table td:first-child { white-space: normal; }
.spec-table tr.sum td { font-weight: 500; color: var(--text); border-top: 1px solid var(--border); }
.spec-table .sub td { color: var(--text-dim); padding-top: 2px; padding-bottom: 2px; font-size: 11px; }
.spec-table .mat { display: inline-flex; align-items: center; gap: 8px; }
.spec-table .mat .sw { width: 12px; height: 12px; border-radius: 2px; border: 1px solid #0007; flex: none; }
.spec-table .mat .unk { color: var(--text-dim); }
.spec-table td.cell { cursor: default; position: relative; }
.spec-table td.cell:hover { background: var(--hover); }
.spec-table td.cell .fl { margin-left: 6px; font-size: 10px; color: var(--text-dim); }
.spec-table td.cell .fl.is-manual { color: var(--accent); }
.spec-table td.cell.is-ov { color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent-border, var(--accent)); }
.spec-table td.cell input { width: 88px; height: 24px; background: var(--bg-surface); border: 1px solid var(--accent); border-radius: var(--radius-sm); color: var(--text); font: inherit; text-align: right; padding: 0 6px; }
.spec-note { margin-top: 18px; font-size: 11px; color: var(--text-dim); max-width: 100ch; line-height: 1.6; }
.perim-body p { margin: 0 0 10px; }
.perim-body b { color: var(--text); }

/* ── диалоги ── */
.dw-dlg { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; width: min(420px, 92vw); font: 400 13px/1.5 var(--font); }
.dw-dlg::backdrop { background: #000a; }
.dw-dlg form { display: flex; flex-direction: column; gap: 12px; }
.dw-dlg p { margin: 0; font-size: 12px; }
.dw-dlg b { color: var(--text); font-weight: 500; }
.dw-dlg .btn-primary { flex: 1; }
.dw-dlg .check { padding: 0; }
.dw .st.is-err::before { background: var(--danger); }
.dw .bubble.is-err::before { color: var(--danger); }

@media (max-width: 1400px) { .dw-range span { display: none; } .dw .bottom { grid-template-columns: 1.2fr .9fr 1fr 1.5fr; } }
@media (max-width: 1100px) {
  .dw { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "title" "stages" "tools" "canvas" "right" "bottom"; height: auto; }
  .dw .canvas-stage { min-height: 60vh; } .dw .bottom { grid-template-columns: minmax(0, 1fr); }
}

/* правая колонка прокручивается целиком, панели не сжимаются */
.dw .right > .panel { flex: none; }
.dw .zone-list { max-height: 240px; overflow-y: auto; }
.dw .logp .log { max-height: 220px; overflow-y: auto; }
