/* softglass.css - конструктор мягких окон (светлая тема; тёмная пока не поддерживается) */
.sg-root {
    --sg-bg: #f2f5fa; --sg-card: #ffffff; --sg-line: #e2e8f1; --sg-line-2: #cfd8e6;
    --sg-text: #0f1b2d; --sg-muted: #6a7a91; --sg-accent: #0b57d0; --sg-accent-soft: #e8f0fe;
    --sg-warn: #b45309; --sg-warn-bg: #fff7e6; --sg-danger: #c62828; --sg-ok: #1b7f4b;
    --sg-radius: 14px;
    flex: 1; min-height: 0; min-width: 0; width: 100%; overflow: hidden; height: calc(100vh - 56px); display: flex;
    font-family: 'Inter', system-ui, sans-serif; color: var(--sg-text);
}
.sg-root *, .sg-root *::before, .sg-root *::after { box-sizing: border-box; }
/* Платформенная светлая тема принудительно красит border-color и b/input - возвращаем контроль */
.sg-root * { --bc: var(--sg-line); border-color: var(--bc) !important; }
.sg-root b, .sg-root strong { color: inherit !important; }
.sg-root input[type="text"], .sg-root select { background: #fff !important; color: var(--sg-text) !important; font-weight: 500 !important; border-width: 1px !important; border-style: solid !important; }
.sg-root input[type="checkbox"] { border: 0 !important; }
.sg-root .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.sg-root button { font-family: inherit; cursor: pointer; }
.sg-root button:disabled { opacity: .4; cursor: not-allowed; }

.sg-app { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--sg-bg); }

/* ---------- Верхняя панель ---------- */
.sg-top { height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 18px; padding: 0 18px; background: var(--sg-card); border-bottom: 1px solid; --bc: var(--sg-line); }
.sg-brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.sg-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--sg-accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.sg-brand b { display: block; font-size: 13px; letter-spacing: -.01em; }
.sg-brand span { font-size: 11px; color: var(--sg-muted); }
.sg-sum { margin-left: auto; display: flex; gap: 26px; }
.sg-sum div { display: flex; flex-direction: column; gap: 1px; }
.sg-sum span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--sg-muted); }
.sg-sum b { font-size: 14px; }
.sg-sum b.accent { color: var(--sg-accent); font-size: 16px; }
.sg-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Кнопки и контролы ---------- */
.sg-seg { display: inline-flex; gap: 2px; padding: 3px; background: #eef2f8; border-radius: 10px; }
.sg-seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--sg-muted); transition: all .15s; }
.sg-seg button.on { background: #fff; color: var(--sg-accent); box-shadow: 0 1px 3px rgba(15, 27, 45, .12); }
.sg-seg button:hover:not(.on):not(:disabled) { color: var(--sg-text); }
.sg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid; --bc: var(--sg-line-2); background: #fff; color: var(--sg-text); font-size: 12px; font-weight: 600; transition: all .15s; }
.sg-btn:hover:not(:disabled) { --bc: var(--sg-accent); color: var(--sg-accent); }
.sg-btn svg, .sg-ibtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sg-btn.primary { background: var(--sg-accent); --bc: var(--sg-accent); color: #fff; }
.sg-btn.primary:hover:not(:disabled) { background: #0a4cb8; color: #fff; }
.sg-btn.danger { color: var(--sg-danger); }
.sg-btn.danger:hover:not(:disabled) { --bc: var(--sg-danger); color: var(--sg-danger); background: #fdecec; }
.sg-btn.sm { height: 28px; padding: 0 10px; font-size: 11px; }
.sg-btn.on { background: var(--sg-accent); --bc: var(--sg-accent); color: #fff; }
.sg-btn.on:hover:not(:disabled) { background: #0a4cb8; color: #fff; }
.sg-ibtn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid; --bc: var(--sg-line-2); background: #fff; color: var(--sg-muted); }
.sg-ibtn:hover:not(:disabled) { color: var(--sg-accent); --bc: var(--sg-accent); }
.sg-orient { display: flex; align-items: center; gap: 6px; }
.sg-reset { width: 30px; height: 30px; border: 0; border-radius: 8px; background: #eef2f8; color: var(--sg-accent); font-size: 16px; line-height: 1; cursor: pointer; transition: all .15s; }
.sg-reset:hover:not(:disabled) { background: #fff; box-shadow: 0 1px 3px rgba(15, 27, 45, .12); }
.sg-reset:disabled { opacity: .35; cursor: default; }
.sg-link { background: none; border: 0; padding: 4px 0; color: var(--sg-accent); font-size: 12px; font-weight: 600; text-align: left; }
.sg-link:hover { text-decoration: underline; }
.sg-x { width: 24px; height: 24px; flex-shrink: 0; display: inline-grid; place-items: center; padding: 0; border-radius: 7px; border: 0; background: transparent; color: var(--sg-muted); line-height: 1; }
.sg-x svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sg-x:hover { background: #fdecec; color: var(--sg-danger); }
.sg-reel-card .sg-x { font-size: 16px; }

.sg-input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid; --bc: var(--sg-line-2); border-radius: 9px; background: #fff; color: var(--sg-text); font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.sg-input:focus { --bc: var(--sg-accent); box-shadow: 0 0 0 3px rgba(11, 87, 208, .14); }
.sg-inwrap { position: relative; display: block; }
.sg-inwrap i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11px; color: var(--sg-muted); pointer-events: none; }
.sg-inwrap .sg-input { padding-right: 34px; }
select.sg-input { padding-right: 8px; }

.sg-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.sg-switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.sg-switch span { position: absolute; inset: 0; border-radius: 20px; background: #cbd5e3; transition: background .15s; }
.sg-switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.sg-switch input:checked + span { background: var(--sg-accent); }
.sg-switch input:checked + span::after { transform: translateX(16px); }

.sg-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--sg-muted); cursor: pointer; }
.sg-check input { accent-color: var(--sg-accent); width: 14px; height: 14px; }

/* ---------- Рабочая область ---------- */
.sg-work { flex: 1; min-height: 0; display: flex; }
.sg-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sg-toolbar { height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; }
.sg-title { display: flex; align-items: baseline; gap: 12px; }
.sg-title b { font-size: 14px; }
.sg-title span { font-size: 12px; color: var(--sg-muted); }
.sg-title em { font-style: normal; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--sg-accent-soft); color: var(--sg-accent); }
.sg-toolbar-r { display: flex; align-items: center; gap: 14px; }
.sg-pill { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; font-family: 'JetBrains Mono', monospace; }
.sg-pill.warn { background: var(--sg-warn-bg); color: var(--sg-warn); }

.sg-canvas { position: relative; flex: 1; min-height: 0; margin: 0 18px; border-radius: var(--sg-radius); background-color: #fbfcfe; background-image: radial-gradient(circle, #d4dcea 1.1px, transparent 1.1px); background-size: 22px 22px; box-shadow: inset 0 0 0 1px var(--sg-line); overflow: hidden; }
.sg-canvas svg { width: 100%; height: 100%; display: block; user-select: none; }
.sg-stagefoot { height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; font-size: 11px; color: var(--sg-muted); }
.sg-stagefoot span:first-child { display: flex; align-items: center; gap: 8px; }
.sg-stagefoot i { width: 7px; height: 7px; border-radius: 50%; background: var(--sg-accent); }
.sg-dimedit { position: absolute; width: 80px; height: 30px; padding: 0 8px; text-align: center; font-size: 13px; font-weight: 700; border: 2px solid; --bc: var(--sg-accent); border-radius: 8px; outline: none; background: #fff; box-shadow: 0 6px 20px rgba(11, 87, 208, .25); z-index: 5; }

/* ---------- SVG-чертёж ---------- */
.sg-canvas .sg-floor { stroke: #9fb0c8; stroke-width: 1; stroke-dasharray: 2 4; }
.sg-canvas .sg-border { stroke: none; }
.sg-canvas .sg-outline { fill: none; stroke: rgba(15, 27, 45, .55); stroke-width: 1.2; stroke-linejoin: round; }
.sg-canvas .sg-film { stroke: rgba(255, 255, 255, .5); stroke-width: 1; }
.sg-canvas .sg-streak { fill: #fff; opacity: .22; }
.sg-canvas .sg-skirt { opacity: .88; stroke: rgba(15, 27, 45, .5); stroke-width: 1; }
.sg-canvas .sg-pocket { stroke: rgba(15, 27, 45, .55); stroke-width: 1; }
.sg-canvas .sg-seam { stroke: #0b57d0; stroke-width: 2; stroke-dasharray: 14 4 3 4; }
.sg-canvas .sg-seam-label { fill: #0b57d0; font: 700 10px 'JetBrains Mono', monospace; }
.sg-canvas .sg-door { fill: transparent; stroke: none; }
.sg-canvas .sg-zip { stroke-width: 1.5; stroke-dasharray: 3 2.5; pointer-events: none; }
.sg-canvas .sg-cutout { fill: #eef2f8; stroke: #0f1b2d; stroke-width: 1.5; stroke-dasharray: 5 3; }
.sg-canvas .sg-patch { opacity: .85; stroke: #0f1b2d; stroke-width: 1; }
.sg-canvas .sg-note { fill: #0b3d91; font: 700 10px 'JetBrains Mono', monospace; letter-spacing: .04em; }
.sg-canvas .sg-note.on-fabric { fill: #fff; }
.sg-canvas .sg-note.muted { fill: var(--sg-muted); font-weight: 500; }
.sg-canvas .sg-side-hit { stroke: transparent; stroke-width: 16; cursor: pointer; pointer-events: stroke; }
.sg-canvas .sg-side-hit:hover { stroke: rgba(11, 87, 208, .14); }
.sg-canvas.is-picking .sg-side-hit { stroke: rgba(11, 87, 208, .28); stroke-width: 22; cursor: crosshair; }
.sg-canvas.is-picking .sg-side-hit:hover { stroke: rgba(11, 87, 208, .45); }
.sg-canvas .sg-side-active { stroke: var(--sg-accent); stroke-width: 6; opacity: .22; stroke-linecap: round; pointer-events: none; }
.sg-canvas .sg-chain line { stroke: #8da0bb; stroke-width: 1; }
.sg-canvas .sg-chain text { fill: #5b6b82; font: 500 9.5px 'JetBrains Mono', monospace; }
.sg-canvas .sg-chain .is-sel { stroke: var(--sg-accent); fill: var(--sg-accent); font-weight: 700; }
.sg-canvas .sg-dim line { stroke: #8da0bb; stroke-width: 1.2; }
.sg-canvas .sg-guide { stroke: var(--sg-accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; pointer-events: none; }
.sg-canvas .sg-chip rect { fill: #14213a; }
.sg-canvas .sg-chip text { fill: #fff; font: 700 12px 'JetBrains Mono', monospace; }
.sg-canvas .sg-chip.is-edit { cursor: text; }
.sg-canvas .sg-chip.is-edit:hover rect { fill: var(--sg-accent); }
.sg-canvas .sg-hw { cursor: grab; }
.sg-canvas .sg-hw:active { cursor: grabbing; }
.sg-canvas .sg-hit { fill: transparent; }
.sg-canvas .sg-hw-body { fill: #cfd5df; stroke: #101826; stroke-width: 1; }
.sg-canvas .sg-hw-dot { fill: #101826; }
.sg-canvas .sg-hw-bar { stroke: #101826; stroke-width: 1.6; stroke-linecap: round; fill: none; }
.sg-canvas .sg-hw:hover .sg-hw-body { stroke: var(--sg-accent) !important; }
.sg-canvas .sg-hw.is-selected .sg-hw-body { stroke: var(--sg-accent) !important; }
.sg-canvas .sg-hw-ring { fill: rgba(11, 87, 208, .1); stroke: var(--sg-accent); stroke-width: 1.4; stroke-dasharray: 3 2; }
.sg-canvas .sg-hw-bad { fill: rgba(180, 83, 9, .14); stroke: var(--sg-warn); stroke-width: 1.6; stroke-dasharray: 3 2; pointer-events: none; }

/* ---------- Инспектор ---------- */
.sg-inspector { width: 430px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--sg-card); border-left: 1px solid; --bc: var(--sg-line); box-shadow: -8px 0 28px rgba(15, 27, 45, .05); }
.sg-tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin: 12px 14px 4px; padding: 3px; background: #eef2f8; border-radius: 11px; }
.sg-tabs button { position: relative; height: 32px; border: 0; background: transparent; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--sg-muted); }
.sg-tabs button.on { background: #fff; color: var(--sg-accent); box-shadow: 0 1px 3px rgba(15, 27, 45, .12); }
.sg-tabs button i { position: absolute; top: 6px; right: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--sg-accent); }
.sg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.sg-body::-webkit-scrollbar { width: 6px; }
.sg-body::-webkit-scrollbar-thumb { background: #cfd8e6; border-radius: 6px; }

.sg-card { background: var(--sg-card); border: 1px solid; --bc: var(--sg-line); border-radius: var(--sg-radius); padding: 14px; display: flex; flex-direction: column; gap: 11px; }
.sg-card.is-off { padding-bottom: 12px; background: #fafbfd; }
.sg-card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sg-card h4 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .02em; display: flex; flex-direction: column; gap: 2px; }
.sg-card h4 small { font-size: 11px; font-weight: 500; color: var(--sg-muted); letter-spacing: 0; }
.sg-badge { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--sg-accent-soft); color: var(--sg-accent); }
.sg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sg-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sg-lbl { font-size: 11px; font-weight: 600; color: var(--sg-muted); }
.sg-hint { font-size: 10.5px; color: var(--sg-muted); }
.sg-kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--sg-muted); }
.sg-kv b { color: var(--sg-text); font-size: 12px; text-align: right; }
.sg-note-line { font-size: 12px; color: var(--sg-muted); }
.sg-empty { font-size: 12px; color: var(--sg-muted); padding: 6px 0; line-height: 1.5; }

.sg-alert { font-size: 12px; line-height: 1.45; padding: 9px 11px; border-radius: 10px; }
.sg-alert.info { background: var(--sg-accent-soft); color: #0a3d91; }
.sg-alert.warn { background: var(--sg-warn-bg); color: var(--sg-warn); }
.sg-alert.ok { background: #e8f6ee; color: var(--sg-ok); }

.sg-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; background: #f4f7fc; font-size: 12px; }
.sg-banner > div { display: flex; flex-direction: column; gap: 2px; }
.sg-banner span { color: var(--sg-muted); font-size: 11px; }
.sg-banner.is-indiv { background: var(--sg-accent-soft); }

.sg-shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sg-shape { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px 7px; border: 1px solid; --bc: var(--sg-line); border-radius: 11px; background: #fff; color: var(--sg-muted); transition: all .15s; }
.sg-shape svg { width: 26px; height: 26px; fill: rgba(11, 87, 208, .07); stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.sg-shape span { font-size: 9.5px; line-height: 1.15; text-align: center; font-weight: 500; min-height: 22px; }
.sg-shape:hover { --bc: var(--sg-accent); color: var(--sg-accent); }
.sg-shape.on { --bc: var(--sg-accent); background: var(--sg-accent-soft); color: var(--sg-accent); }
.sg-shape.on span { font-weight: 700; }

.sg-opts { display: flex; flex-direction: column; gap: 6px; }
.sg-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid; --bc: var(--sg-line); border-radius: 11px; background: #fff; color: var(--sg-text); font-size: 12px; transition: all .15s; }
.sg-opt div { display: flex; flex-direction: column; gap: 2px; }
.sg-opt small { color: var(--sg-muted); font-size: 11px; }
.sg-opt > span { font-size: 12px; font-weight: 700; white-space: nowrap; }
.sg-opt:hover { --bc: var(--sg-accent); }
.sg-opt.on { --bc: var(--sg-accent); background: var(--sg-accent-soft); }

/* Стильный выпадающий список */
.sg-dd { position: relative; min-width: 0; }
.sg-dd-btn { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 12px; border: 1px solid; --bc: var(--sg-line-2); border-radius: 11px; background: #fff; color: var(--sg-text); text-align: left; transition: border-color .15s, box-shadow .15s; cursor: pointer; }
.sg-dd-btn:hover { --bc: var(--sg-accent); }
.sg-dd.open .sg-dd-btn { --bc: var(--sg-accent); box-shadow: 0 0 0 3px rgba(11, 87, 208, .14); }
.sg-dd-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sg-dd-main b { font-size: 12.5px; font-weight: 600; line-height: 1.25; white-space: normal; }
.sg-dd-main small { font-size: 10.5px; color: var(--sg-muted); line-height: 1.2; }
.sg-dd em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--sg-accent); white-space: nowrap; }
.sg-dd-dot { width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%; border: 1px solid; --bc: rgba(15, 27, 45, .2); }
.sg-dd-chev { width: 18px; height: 18px; flex-shrink: 0; display: grid; place-items: center; color: var(--sg-muted); transition: transform .15s; }
.sg-dd-chev svg, .sg-dd-ok svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sg-dd.open .sg-dd-chev { transform: rotate(180deg); color: var(--sg-accent); }
.sg-dd-menu { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0; max-height: 320px; overflow-y: auto; padding: 5px; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid; --bc: var(--sg-line); border-radius: 13px; box-shadow: 0 14px 36px rgba(15, 27, 45, .18); animation: sg-dd-in .12s ease-out; }
@keyframes sg-dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sg-dd-grp { padding: 8px 9px 3px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sg-muted); }
.sg-dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 9px; border: 0; border-radius: 9px; background: transparent; color: var(--sg-text); text-align: left; cursor: pointer; }
.sg-dd-item:hover { background: #f1f5fb; }
.sg-dd-item.on { background: var(--sg-accent-soft); }
.sg-dd-ok { width: 16px; flex-shrink: 0; color: var(--sg-accent); }
.sg-dd.sm .sg-dd-btn { min-height: 32px; padding: 3px 8px; }
.sg-dd.sm .sg-dd-main b { font-size: 11.5px; }
.sg-dd.sm .sg-dd-menu { left: auto; min-width: 200px; }
.sg-swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.sg-swatch { aspect-ratio: 1; border-radius: 9px; border: 1px solid; --bc: rgba(15, 27, 45, .18); transition: transform .12s; }
.sg-swatch:hover { transform: scale(1.1); }
.sg-swatch.on { outline: 2px solid var(--sg-accent); outline-offset: 2px; }

.sg-sides { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sg-sides button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; border: 1px solid; --bc: var(--sg-line); border-radius: 10px; background: #fff; font-size: 11px; font-weight: 700; color: var(--sg-muted); }
.sg-sides button small { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px; background: #eef2f8; }
.sg-sides button.on { --bc: var(--sg-accent); background: var(--sg-accent-soft); color: var(--sg-accent); }
.sg-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.sg-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid; --bc: transparent; border-radius: 9px; background: #f6f8fc; font-size: 12px; color: var(--sg-text); text-align: left; }
.sg-row i { width: 20px; height: 20px; border-radius: 50%; background: #e1e8f3; font-style: normal; font-size: 10px; font-weight: 700; display: grid; place-items: center; color: var(--sg-muted); }
.sg-row span { flex: 1; }
.sg-row em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--sg-muted); }
.sg-row u { text-decoration: none; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--sg-warn-bg); color: var(--sg-warn); }
.sg-row:hover { --bc: var(--sg-accent); }
.sg-row.on { background: var(--sg-accent-soft); --bc: var(--sg-accent); }
.sg-row.on i { background: var(--sg-accent); color: #fff; }
.sg-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sg-add-pick { grid-column: 1 / -1; }
.sg-row.is-bad:not(.on) { background: var(--sg-warn-bg); }
.sg-btnrow { display: flex; gap: 8px; }
.sg-btnrow .sg-btn { flex: 1; }
.sg-listrow { display: flex; align-items: flex-end; gap: 6px; }
.sg-listrow label { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sg-listrow label span { font-size: 10px; color: var(--sg-muted); font-weight: 600; }
.sg-listrow .sg-input { padding: 0 6px; height: 32px; }

/* ---------- Липкий терминал аудита ---------- */
.sg-auditwrap { flex-shrink: 0; padding: 0 14px 14px; }
.sg-audit { background: #0f1b2d; color: #fff; border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 28px rgba(15, 27, 45, .28); }
.sg-audit-warn { font-size: 11px; line-height: 1.4; padding: 7px 10px; border-radius: 9px; background: rgba(251, 191, 36, .16); color: #fcd34d; }
.sg-audit-grid { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 10px; }
.sg-audit-grid div, .sg-audit-total div { display: flex; flex-direction: column; gap: 3px; }
.sg-audit span { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: #8fa1bd; }
.sg-audit-grid b { font-size: 13px; }
.sg-audit-grid b.low { color: #fca5a5; }
.sg-audit-total { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 10px; border-top: 1px solid; --bc: rgba(255, 255, 255, .1); }
.sg-audit-total b { font-size: 24px; letter-spacing: -.02em; }
.sg-audit .sg-btn { background: rgba(255, 255, 255, .1); --bc: transparent; color: #fff; }
.sg-audit .sg-btn:hover { background: rgba(255, 255, 255, .2); color: #fff; --bc: transparent; }
.sg-audit details summary { cursor: pointer; font-size: 11px; color: #8fa1bd; list-style: none; }
.sg-audit details summary::-webkit-details-marker { display: none; }
.sg-audit details summary::before { content: '▸ '; }
.sg-audit details[open] summary::before { content: '▾ '; }
.sg-spec { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 11px; }
.sg-spec td { padding: 4px 0; color: #d3dcec; border-top: 1px solid; --bc: rgba(255, 255, 255, .06); }
.sg-spec td:not(:first-child) { text-align: right; white-space: nowrap; padding-left: 10px; }

/* ---------- Полка окон ---------- */
.sg-reel { height: 92px; flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 0 18px; background: var(--sg-card); border-top: 1px solid; --bc: var(--sg-line); }
.sg-reel-track { flex: 1; min-width: 0; display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px; }
.sg-reel-card { position: relative; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border: 1px solid; --bc: var(--sg-line); border-radius: 13px; background: #fff; cursor: pointer; transition: all .15s; }
.sg-reel-card:hover { --bc: var(--sg-accent); }
.sg-reel-card.on { --bc: var(--sg-accent); background: var(--sg-accent-soft); box-shadow: 0 0 0 2px rgba(11, 87, 208, .12); }
.sg-reel-prev { width: 56px; height: 56px; border-radius: 9px; background: #f3f6fb; }
.sg-reel-info { display: flex; flex-direction: column; gap: 2px; min-width: 96px; }
.sg-reel-info b { font-size: 12px; display: flex; align-items: center; gap: 5px; }
.sg-reel-info b i { color: var(--sg-accent); font-style: normal; font-size: 8px; }
.sg-reel-info span { font-size: 11px; color: var(--sg-muted); }
.sg-reel-info em { font-style: normal; font-size: 12px; font-weight: 700; }
.sg-reel-card .sg-x { position: absolute; top: 4px; right: 4px; opacity: 0; }
.sg-reel-card:hover .sg-x { opacity: 1; }
.sg-reel-add { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100px; border: 1.5px dashed; --bc: var(--sg-line-2); border-radius: 13px; background: transparent; font-size: 11px; font-weight: 600; color: var(--sg-muted); }
.sg-reel-add span { font-size: 20px; line-height: 1; }
.sg-reel-add:hover { --bc: var(--sg-accent); color: var(--sg-accent); }
.sg-reel-status { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--sg-muted); white-space: nowrap; }
.sg-reel-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.sg-reel-status .dot.ok { background: var(--sg-ok); }

@media (max-width: 1180px) {
    .sg-inspector { width: 360px; }
    .sg-sum { gap: 14px; }
    .sg-brand { min-width: 0; }
}

/* ---------- Производственное ТЗ (предпросмотр / печать / PDF) ---------- */
.sg-pdf-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; background: #dfe5ee; height: 100vh !important; }
.sg-pdf-bar { flex-shrink: 0; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: #fff; border-bottom: 1px solid; --bc: var(--sg-line); }
.sg-pdf-bar span { color: var(--sg-muted); font-size: 12px; }
.sg-pdf-bar div { margin-left: auto; display: flex; gap: 8px; }
.sg-pdf-scroll { flex: 1; overflow: auto; padding: 20px; }
.sg-pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.sg-page { width: 1123px; height: 794px; flex-shrink: 0; position: relative; display: flex; flex-direction: column; padding: 30px 34px 22px; background: #fff; color: #0f1b2d; box-shadow: 0 6px 24px rgba(15, 27, 45, .18); page-break-after: always; overflow: hidden; font-family: 'Inter', sans-serif; }
.sg-pg-head { display: flex; align-items: center; gap: 24px; padding-bottom: 12px; border-bottom: 2px solid; --bc: #0f1b2d; }
.sg-pg-head .brand { display: flex; flex-direction: column; min-width: 200px; }
.sg-pg-head .brand b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.sg-pg-head .brand b span { color: #0b57d0; }
.sg-pg-head .brand small { font-size: 10px; color: #6a7a91; }
.sg-pg-head .ttl { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sg-pg-head .ttl b { font-size: 18px; }
.sg-pg-head .ttl span { font-size: 12px; color: #4a5a72; }
.sg-pg-head .qr svg { width: 72px; height: 72px; display: block; }
.sg-pg-body { flex: 1; min-height: 0; display: flex; gap: 20px; padding-top: 12px; }
.sg-pg-left { flex: 6; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sg-pg-right { flex: 4; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sg-page h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #0b57d0; }
.sg-page h4 { margin: 6px 0 0; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #4a5a72; }
.sg-print .sg-canvas, .sg-print-draw.sg-canvas { margin: 0; background: #fff; box-shadow: inset 0 0 0 1px #d7dfeb; border-radius: 8px; flex: 1; min-height: 0; }
.sg-print .sg-side-hit { display: none; }
.sg-pg-coords { font-size: 10px; line-height: 1.5; display: flex; flex-direction: column; gap: 1px; }
.sg-pg-coords b { margin-right: 4px; }
.sg-pg-coords i { font-style: normal; color: #6a7a91; margin-right: 8px; }
.sg-cutsvg { width: 100%; height: auto; }
.sg-cutsvg .t-lbl { font: 700 9.5px 'Inter', sans-serif; fill: #4a5a72; letter-spacing: .04em; }
.sg-cutsvg .t-dim { font: 700 10.5px 'JetBrains Mono', monospace; fill: #0f1b2d; }
.sg-cutsvg .t-dim.s { font-size: 9.5px; font-weight: 500; }
.sg-cutsvg .piece { fill: rgba(186, 215, 245, .35); stroke: #0f1b2d; stroke-width: 1.2; }
.sg-cutsvg .strip { stroke: rgba(0, 0, 0, .5); stroke-width: .8; }
.sg-pg-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.sg-pg-table td { padding: 5px 4px; border-bottom: 1px solid; --bc: #e2e8f1; vertical-align: middle; }
.sg-pg-table td:first-child { width: 22px; }
.sg-pg-table td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.sg-pg-notes { margin: 4px 0 0; padding-left: 16px; font-size: 10.5px; line-height: 1.5; color: #374762; }
.sg-pg-foot { display: flex; justify-content: space-between; padding-top: 8px; border-top: 1px solid; --bc: #d7dfeb; font-size: 10px; color: #6a7a91; }

@media print {
    @page { size: A4 landscape; margin: 0; }
    body.sg-printing > *:not(.sg-pdf-overlay) { display: none !important; }
    body.sg-printing .sg-pdf-overlay { position: static; background: #fff; display: block; height: auto !important; }
    body.sg-printing .sg-pdf-bar { display: none; }
    body.sg-printing .sg-pdf-scroll { padding: 0; overflow: visible; }
    body.sg-printing .sg-pdf-pages { display: block; zoom: 1 !important; }
    body.sg-printing .sg-page { box-shadow: none; width: 297mm; height: 210mm; }
}

.sg-root .sg-sum b.accent { color: var(--sg-accent) !important; }
.sg-root .sg-audit-grid b.low { color: #fca5a5 !important; }
.sg-root .sg-kv b { color: var(--sg-text) !important; }
.sg-top { overflow-x: auto; scrollbar-width: none; }
.sg-top > * { flex-shrink: 0; }
@media (max-width: 1360px) {
    .sg-brand span { display: none; }
    .sg-top { gap: 10px; padding: 0 12px; }
    .sg-brand { min-width: 0; }
    .sg-btn.ghost { padding: 0 10px; }
}


/* ---- v0.2: слои, масштаб, допы, новая отрисовка ---- */
.sg-canvas .sg-filmbase { fill: #eef3f9; }
.sg-canvas .sg-film { stroke: rgba(255, 255, 255, .5); stroke-width: 1; cursor: pointer; }
.sg-canvas .sg-border { stroke: none; cursor: pointer; }
.sg-canvas [data-layer] { cursor: pointer; }
.sg-canvas .sg-stitch { stroke: rgba(255, 255, 255, .55); stroke-width: 1; stroke-dasharray: 3 2; pointer-events: none; }
.sg-canvas .sg-stitch-box { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 1; stroke-dasharray: 3 2; pointer-events: none; }
.sg-canvas .sg-pipe-ghost { fill: rgba(255, 255, 255, .22); stroke: rgba(255, 255, 255, .45); stroke-width: 1; pointer-events: none; }
.sg-canvas .sg-pipe { stroke: #5d6877; stroke-width: 1; }
.sg-canvas .sg-pipe-cap { fill: #dfe4ec; stroke: #5d6877; stroke-width: 1; }
.sg-canvas .sg-pipe-hole { fill: #6b7686; }
.sg-canvas .sg-zipkant { stroke: rgba(15, 27, 45, .35); stroke-width: .6; }
.sg-canvas .sg-zip { stroke-width: 1.5; stroke-dasharray: 3 2.5; pointer-events: none; }
.sg-canvas .sg-door { fill: transparent; stroke: none; }
.sg-canvas .sg-notch { fill: #fbfcfe; stroke: rgba(15, 27, 45, .5); stroke-width: 1; stroke-dasharray: 4 3; }
.sg-canvas .sg-belt { cursor: grab; }
.sg-canvas .sg-belt:active { cursor: grabbing; }
.sg-canvas .sg-belt-strap { stroke: rgba(15, 27, 45, .5); stroke-width: .8; }
.sg-canvas .sg-belt-sheen { fill: rgba(255, 255, 255, .28); pointer-events: none; }
.sg-canvas .sg-fastex { fill: #2a2f3a; stroke: #12151c; stroke-width: .8; stroke-linejoin: round; }
.sg-canvas .sg-fastex-hl { stroke: rgba(255, 255, 255, .35); stroke-width: 1; stroke-linecap: round; pointer-events: none; }
.sg-print .sg-notch { fill: #fff; }
.sg-print .sg-canvas .sg-filmbase, .sg-print.sg-canvas .sg-filmbase { fill: #f1f5fa; }

/* Левая панель слоёв */
.sg-layers { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 4; display: flex; flex-direction: column; gap: 2px; padding: 5px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border: 1px solid; --bc: var(--sg-line); border-radius: 13px; box-shadow: 0 6px 22px rgba(15, 27, 45, .08); max-height: calc(100% - 20px); overflow-y: auto; }
.sg-layers button { display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px 0 8px; border: 0; border-radius: 8px; background: transparent; font-size: 11.5px; font-weight: 600; color: var(--sg-muted); text-align: left; white-space: nowrap; transition: all .12s; }
.sg-layers button:hover { background: #f1f5fb; color: var(--sg-text); }
.sg-layers button.on { background: var(--sg-accent-soft); color: var(--sg-accent); }
.sg-layers hr { border: 0; height: 1px; margin: 3px 6px; background: var(--sg-line); }

/* Масштаб */
.sg-zoom { display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: #eef2f8; border-radius: 10px; }
.sg-zoom button { width: 28px; height: 26px; border: 0; border-radius: 8px; background: transparent; font-size: 15px; font-weight: 600; color: var(--sg-muted); }
.sg-zoom button:hover { background: #fff; color: var(--sg-accent); }
.sg-zoom span { min-width: 42px; text-align: center; font-size: 11px; color: var(--sg-muted); }

/* Допы: выбор + кнопка сброса */
.sg-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.sg-chips button { position: relative; height: 30px; padding: 0 12px; border: 1px solid; --bc: var(--sg-line); border-radius: 20px; background: #fff; font-size: 12px; font-weight: 600; color: var(--sg-muted); transition: all .12s; }
.sg-chips button.has::after { content: ''; position: absolute; top: 5px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--sg-accent); }
.sg-chips button:hover { --bc: var(--sg-accent); color: var(--sg-accent); }
.sg-chips button.on { background: var(--sg-accent-soft); --bc: var(--sg-accent); color: var(--sg-accent); }
.sg-hdr-r { display: inline-flex; align-items: center; gap: 8px; }
.sg-iconbtn { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--sg-muted); transition: all .12s; }
.sg-iconbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sg-iconbtn:hover { background: #eef2f8; color: var(--sg-accent); }
.sg-field.is-bad .sg-input { --bc: var(--sg-danger); background: #fff6f6; }
.sg-err { font-size: 10.5px; font-weight: 600; color: var(--sg-danger); }
.sg-listcard { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: #f6f8fc; border-radius: 11px; }
.sg-listrow.cols3 label { flex: 1; }
.sg-snap { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 10.5px; color: var(--sg-muted); font-weight: 600; }
.sg-snap span { margin-right: 4px; }
.sg-snap button { height: 24px; padding: 0 9px; border: 1px solid; --bc: var(--sg-line-2); border-radius: 7px; background: #fff; font-size: 11px; font-weight: 600; color: var(--sg-text); }
.sg-snap button:hover, .sg-snap button.on { --bc: var(--sg-accent); color: var(--sg-accent); background: var(--sg-accent-soft); }
.sg-snap .sg-x { margin-left: auto; }
@media (max-width: 1200px) { .sg-layers { left: 6px; } .sg-layers button { padding: 0 6px; font-size: 10.5px; } }

.sg-layers button { gap: 8px; height: 32px; padding: 0 12px 0 6px; }
.sg-thumb { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: #eef2f8; color: var(--sg-accent); flex-shrink: 0; transition: all .12s; }
.sg-thumb svg { width: 16px; height: 16px; }
.sg-layers button.on .sg-thumb { background: #fff; }
.sg-layers button.is-off { color: #a2aec1; }
.sg-layers button.is-off .sg-thumb { background: #f3f5f8; color: #b7c1d0; filter: grayscale(1); opacity: .7; }
.sg-layers button.is-off:hover .sg-thumb { color: var(--sg-accent); filter: none; opacity: 1; }

/* Ручки на чертеже (только у выбранного слоя) */
.sg-canvas .sg-hbody { fill: rgba(11, 87, 208, .05); stroke: none; cursor: move; }
.sg-canvas .sg-handle { fill: #fff; stroke: var(--sg-accent); stroke-width: 2; cursor: grab; transition: r .1s; filter: drop-shadow(0 1px 2px rgba(15, 27, 45, .35)); }
.sg-canvas .sg-handle:hover { r: 8; fill: var(--sg-accent-soft); }

/* ---- v0.4: линейки, привязка, подсказка, копирование ---- */
.sg-canvas .sg-chip.sub rect { fill: #fff; stroke: #9fb0c8; stroke-width: 1; }
.sg-canvas .sg-chip.sub text { fill: #14213a; font: 600 10.5px 'JetBrains Mono', monospace; }
.sg-canvas .sg-chip.sub.is-edit:hover rect { fill: var(--sg-accent-soft); stroke: var(--sg-accent); }
.sg-canvas .sg-chip.sub.is-edit:hover text { fill: var(--sg-accent); }
.sg-canvas .sg-dim.sub line { stroke: #a9b7cc; stroke-width: 1; }
.sg-canvas .sg-arc { fill: none; stroke: #8da0bb; stroke-width: 1.2; pointer-events: none; }
.sg-canvas .sg-diag { stroke: #6e83a3; stroke-width: 1.2; stroke-dasharray: 6 4; pointer-events: none; }
.sg-canvas .sg-snapline { stroke: #e0457b; stroke-width: 1; stroke-dasharray: 4 3; pointer-events: none; }
.sg-hud { position: absolute; z-index: 6; padding: 4px 9px; border-radius: 8px; background: #14213a; color: #fff; font-size: 12px; font-weight: 700; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 14px rgba(15, 27, 45, .3); }
.sg-mgroup { margin-top: 4px; }
.sg-mrow { display: grid; grid-template-columns: 1fr 96px 120px; gap: 8px; align-items: center; font-size: 12px; color: var(--sg-text); }
.sg-mrow > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-input.sm { height: 32px; font-size: 11px; padding: 0 6px; }
.sg-mrow .sg-input { height: 32px; }
.sg-mfix { font-size: 10.5px; color: var(--sg-muted); }
.sg-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 8px 10px; background: var(--sg-accent-soft); border-radius: 11px; font-size: 11px; font-weight: 600; color: var(--sg-accent); }
.sg-copy button { height: 26px; padding: 0 10px; border: 1px solid; --bc: var(--sg-accent); border-radius: 8px; background: #fff; color: var(--sg-accent); font-size: 11px; font-weight: 600; }
.sg-copy button:hover { background: var(--sg-accent); color: #fff; }
.sg-warn-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: #e8890c; box-shadow: 0 0 0 3px rgba(232, 137, 12, .18); }
.sg-iconbtn:disabled { opacity: .35; cursor: default; }

.sg-cfg { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 12px; background: #f4f7fc; cursor: pointer; font-size: 12px; }
.sg-cfg > span:first-child { display: flex; flex-direction: column; line-height: 1.2; }
.sg-cfg small { color: var(--sg-muted); font-size: 10.5px; }
.sg-cfg.is-indiv { background: var(--sg-accent-soft); }
