/* StepDraw web. Tokens: tokens.css. Rules: docs/DESIGN.md (violet = selected/passed, red = needs attention only). */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: var(--fs-md)/var(--lh) var(--font); color: var(--ink); background: var(--violet-wash); font-feature-settings: "tnum" 1; min-height: 100vh; }
a { color: var(--violet-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
h1 { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.01em; margin: 0 0 var(--s4); }
h2 { font-size: var(--fs-lg); font-weight: 600; margin: var(--s5) 0 var(--s3); }
h3 { font-size: var(--fs-md); font-weight: 600; margin: 0 0 var(--s2); }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-xs); }
.strong { font-weight: 500; }
.hint { color: var(--ink-2); font-size: var(--fs-sm); margin: 0; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------- top bar */
.bar { display: flex; align-items: center; gap: var(--s4); height: 56px; padding: 0 var(--s5); background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.mark { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--fs-lg); letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.mark svg { display: block; }
.mark-bg { fill: var(--violet); }
.mark-fg { stroke: #fff; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.mark-arrow { stroke: var(--brand-arrow); stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mark.big { font-size: var(--fs-xl); justify-content: center; }
.asm { display: flex; flex-direction: column; line-height: 1.2; padding-left: var(--s4); border-left: 1px solid var(--line); min-width: 0; }
.asm b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.asm span { color: var(--ink-2); font-size: var(--fs-sm); }
.grow { flex: 1; }
.topnav { display: flex; gap: var(--s1); }
.topnav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: var(--r-md); }
.topnav a:hover { background: var(--violet-wash); color: var(--ink); }
.topnav a[aria-current] { color: var(--violet-strong); background: var(--violet-tint); font-weight: 500; }
.langs { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; margin: 0; }
.langs button { border: 0; background: none; padding: 5px 10px; color: var(--ink-2); cursor: pointer; font-size: var(--fs-sm); }
.langs button[aria-pressed="true"] { background: var(--violet-tint); color: var(--violet-strong); font-weight: 600; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.user { width: 32px; height: 32px; border-radius: 50%; background: var(--violet-tint); color: var(--violet-strong); display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm); }
.menu { position: absolute; right: 0; top: 40px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sheet); min-width: 200px; padding: var(--s2); display: flex; flex-direction: column; }
.menu-head { display: flex; flex-direction: column; padding: var(--s2); border-bottom: 1px solid var(--line); margin-bottom: var(--s1); }
.menu-head span { color: var(--ink-2); font-size: var(--fs-sm); }
.menu a, .menu button { text-align: left; padding: 7px var(--s2); border-radius: var(--r-sm); text-decoration: none; color: var(--ink); background: none; border: 0; cursor: pointer; width: 100%; }
.menu a:hover, .menu button:hover { background: var(--violet-wash); }
.menu form { margin: 0; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); border-radius: var(--r-md); padding: 7px 14px; cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.3; }
.btn:hover { border-color: var(--violet); }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--violet-strong); }
.btn.danger { color: var(--red-strong); border-color: var(--red-tint); }
.btn.danger:hover { border-color: var(--red); }
.btn.small { padding: 4px 10px; font-size: var(--fs-sm); }
.btn.wide { width: 100%; justify-content: center; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
input:not([type=checkbox]):not([type=file]), select, textarea { border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 7px 10px; background: var(--paper); min-width: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--violet); }
textarea { resize: vertical; width: 100%; }
.mono { font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.inline { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5); }
.card h2 { margin-top: 0; }
.alert { background: var(--red-tint); color: var(--red-strong); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin: 0 0 var(--s4); }
.notice { background: var(--violet-tint); color: var(--violet-strong); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin: 0 0 var(--s4); }
.chip { display: inline-block; font-size: var(--fs-xs); padding: 2px 8px; border-radius: 10px; background: var(--violet-wash); color: var(--ink-2); border: 1px solid var(--line); }
.chip.ok { color: var(--violet-strong); background: var(--violet-tint); border-color: transparent; }
.chip.fail { color: #fff; background: var(--red); border-color: transparent; }
.chip.busy { color: var(--violet-strong); border-color: var(--line-strong); }
.progress { height: 6px; background: var(--violet-tint); border-radius: 3px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 0; background: var(--violet); transition: width .2s; }
.empty-state { color: var(--ink-2); padding: var(--s6) 0; text-align: center; }

/* ---------------------------------------------------------------- pages */
.page { padding: var(--s6) var(--s5); max-width: 1200px; margin: 0 auto; }
.narrow { max-width: 520px; margin: 0 auto; }
.list { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.list th, .list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list th { font-weight: 500; color: var(--ink-2); font-size: var(--fs-sm); }
.list td.num, .list th.num { text-align: right; }
.list a { text-decoration: none; color: var(--ink); }
.list a:hover { color: var(--violet-strong); text-decoration: underline; }
.list tr.fail td:first-child { box-shadow: inset 3px 0 var(--red); }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { display: flex; flex-direction: column; align-items: center; gap: var(--s4); padding: var(--s5); width: 100%; }
.login-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sheet); padding: var(--s6); width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--s4); }
.login-card .lead { color: var(--ink-2); text-align: center; margin: 0; }
.login-langs { display: flex; justify-content: center; gap: var(--s3); font-size: var(--fs-sm); }
.login-langs a { color: var(--ink-2); text-decoration: none; }
.login-langs a[aria-current] { color: var(--violet-strong); font-weight: 600; }
.login-foot { color: var(--ink-3); font-size: var(--fs-xs); margin: 0; }

/* projects */
.drop { position: relative; background: var(--paper); border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); padding: var(--s5); margin-bottom: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.drop.over { border-color: var(--violet); background: var(--violet-wash); }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-label { flex-direction: row; align-items: center; gap: var(--s4); color: var(--ink); cursor: pointer; font-size: var(--fs-md); }
.drop-label span { color: var(--ink-2); font-size: var(--fs-sm); }
.drop-label b { font-weight: 500; }
.drop-ic { stroke: var(--violet); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.drop-row { display: flex; gap: var(--s2); }
.drop-row input { flex: 1; }
.drop .progress-text { font-size: var(--fs-sm); color: var(--ink-2); margin: 0; min-height: 1.4em; }
.drop .progress-text.fail { color: var(--red-strong); }

/* admin */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); margin: 0 0 var(--s3); }
.stats div { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); }
.stats dt { color: var(--ink-2); font-size: var(--fs-sm); }
.stats dd { margin: 0; font-size: var(--fs-xl); font-weight: 600; }
.stats div.warn dd { color: var(--red); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); margin-top: var(--s5); }
.reset summary { list-style: none; }
.reset summary::-webkit-details-marker { display: none; }
.reset[open] form { margin-top: var(--s2); }
.audit td { font-size: var(--fs-sm); }
.filter { margin-bottom: var(--s3); }
.pager { display: flex; gap: var(--s2); margin-top: var(--s3); }

/* ---------------------------------------------------------------- workspace */
.ws-body { height: 100vh; overflow: hidden; }
.ws { display: grid; grid-template-columns: 200px minmax(480px, 1fr) minmax(460px, 34vw); grid-template-rows: minmax(0, 1fr); grid-template-areas: "rail table detail"; height: calc(100vh - 56px); min-width: 0; }
.ws [hidden] { display: none !important; }
.ws.layout-both.rail-collapsed { grid-template-columns: 36px minmax(480px, 1fr) minmax(460px, 34vw); grid-template-areas: "rail-stub table detail"; }
.ws.layout-table { grid-template-columns: 200px minmax(0, 1fr) 36px; grid-template-areas: "rail table detail-stub"; }
.ws.layout-table.rail-collapsed { grid-template-columns: 36px minmax(0, 1fr) 36px; grid-template-areas: "rail-stub table detail-stub"; }
.ws.layout-view { grid-template-columns: 200px 36px minmax(0, 1fr); grid-template-areas: "rail table-stub detail"; }
.ws.layout-view.rail-collapsed { grid-template-columns: 36px 36px minmax(0, 1fr); grid-template-areas: "rail-stub table-stub detail"; }
.rail { grid-area: rail; }
.rail-stub { grid-area: rail-stub; }
.list-pane { grid-area: table; }
.table-stub { grid-area: table-stub; }
.detail { grid-area: detail; border-left: 1px solid var(--line); background: var(--paper); overflow: auto; min-height: 0; }
.detail-stub { grid-area: detail-stub; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 40px; padding: var(--s1) var(--s2); border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; padding: 0; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { border-color: var(--line); background: var(--violet-wash); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pane-stub { min-width: 36px; display: flex; justify-content: flex-start; align-items: flex-start; padding: 4px 2px; border-right: 1px solid var(--line); background: var(--paper); }
.table-stub, .detail-stub { border-right: 0; border-left: 1px solid var(--line); }
.rail > .pane-head .icon-btn { width: 32px; flex: 0 0 32px; padding: 0; justify-content: center; }
.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 var(--s5); }
.list-pane > .pane-head { margin: 0 calc(-1 * var(--s5)) var(--s3); padding-inline: var(--s5); }
.detail > .pane-head { position: sticky; top: 0; z-index: 2; background: var(--paper); padding-inline: var(--s4); }
.ws.layout-view .detail { border-left: 0; }
.ws.layout-view .stage:not(.max) { height: clamp(300px, calc(100dvh - 340px), 720px); min-height: 300px; display: flex; flex-direction: column; }
.ws.layout-view .sheet, .ws.layout-view .viewer { flex: 1; width: 100%; height: auto; min-height: 0; aspect-ratio: auto; }
.ws.layout-view .stage-empty { flex: 1; display: grid; place-items: center; }
.rail { padding: 0 var(--s3) var(--s5); border-right: 1px solid var(--line); overflow: auto; min-width: 0; }
.rail > .pane-head { position: sticky; top: 0; z-index: 2; margin: 0 calc(-1 * var(--s3)) var(--s3); padding-inline: var(--s3); background: var(--paper); }
.rail button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: var(--s2); padding: 7px var(--s2); border: 0; background: none; border-radius: var(--r-sm); text-align: left; cursor: pointer; color: var(--ink); }
.rail button:hover { background: var(--violet-tint); }
.rail button[aria-pressed="true"] { background: var(--violet); color: #fff; }
.rail button[aria-pressed="true"] .n { color: #fff; }
.rail .n { color: var(--ink-2); flex: none; }
.rail hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) var(--s2); }
.rail button.review { color: var(--red-strong); }
.rail button.review .n { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: var(--fs-xs); line-height: 20px; }
.rail button.review[aria-pressed="true"] { background: var(--red); color: #fff; }

.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 var(--s5); }
.tools { display: flex; gap: var(--s2); align-items: center; margin-bottom: var(--s3); flex-wrap: wrap; }
.search { flex: 1; min-width: 180px; }
.job { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin-bottom: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.job-head { display: flex; align-items: center; gap: var(--s2); }
.job-pct { font-weight: 600; color: var(--violet-strong); font-feature-settings: "tnum" 1; }
.job-time { color: var(--ink-2); font-size: var(--fs-sm); font-feature-settings: "tnum" 1; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--violet-tint); border-top-color: var(--violet); animation: sd-spin .8s linear infinite; flex: none; }
@keyframes sd-spin { to { transform: rotate(360deg); } }
.progress.indeterminate .progress-bar { width: 30% !important; animation: sd-slide 1.4s ease-in-out infinite; }
@keyframes sd-slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.job-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--fs-sm); }
.job-steps li { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.job-steps li .ic { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; border: 1.5px solid var(--line-strong); flex: none; }
.job-steps li.done { color: var(--ink-2); }
.job-steps li.done .ic { background: var(--violet); border-color: var(--violet); color: #fff; }
.job-steps li.now { color: var(--ink); font-weight: 500; }
.job-steps li.now .ic { border-color: var(--violet); border-top-color: transparent; animation: sd-spin .8s linear infinite; }
.job-steps li .x { color: var(--ink-3); font-weight: 400; font-feature-settings: "tnum" 1; }
.job-now { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner { border-radius: var(--r-md); padding: var(--s3) var(--s4); margin-bottom: var(--s3); background: var(--violet-tint); color: var(--violet-strong); }
.banner.fail { background: var(--red-tint); color: var(--red-strong); }
.approval { border: 1px solid var(--line); border-left: 4px solid var(--violet); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin-bottom: var(--s3); background: var(--paper); }
.approval.review, .approval.stale, .approval.busy { border-left-color: #a87f00; }
.approval.failed { border-left-color: var(--red); background: var(--red-tint); }
.approval.approved { border-left-color: var(--violet); background: var(--violet-wash); }
.approval-head, .approval-actions { display: flex; align-items: center; gap: var(--s2); }
.approval-head { color: var(--ink); }
.approval-time { color: var(--ink-2); font-size: var(--fs-sm); }
.approval p { margin: var(--s2) 0; color: var(--ink-2); }
.approval ul { max-height: 180px; overflow: auto; margin: var(--s2) 0; padding-left: 22px; color: var(--ink-2); font-size: var(--fs-sm); }
.approval-ack { display: flex; align-items: flex-start; gap: var(--s2); margin: var(--s2) 0; }
.approval-ack input { margin-top: 3px; }
.approval-actions { justify-content: space-between; flex-wrap: wrap; }
.source-info { flex: none; margin: 0 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); color: var(--ink-2); font-size: var(--fs-sm); }
.source-info summary { cursor: pointer; padding: 7px var(--s3); color: var(--ink-2); }
.source-info[open] summary { border-bottom: 1px solid var(--line); }
.source-info-body { padding: var(--s2) var(--s3); }
.source-info-body p { margin: var(--s2) 0 0; }
.source-facts, .source-audit { display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); gap: 3px var(--s3); margin: 0; }
.source-facts dt, .source-audit dt { color: var(--ink-2); }
.source-facts dd, .source-audit dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.source-audit { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
.source-note { color: var(--ink-3); font-size: var(--fs-xs); }
.table-wrap { overflow: auto; flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); margin-bottom: var(--s4); }
table.parts { width: 100%; border-collapse: collapse; }
.parts th, .parts td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.parts th { font-weight: 500; color: var(--ink-2); font-size: var(--fs-sm); background: var(--paper); position: sticky; top: 0; z-index: 1; cursor: default; }
.parts th[data-sort] { cursor: pointer; }
.parts th[aria-sort="ascending"]::after { content: " ↑"; }
.parts th[aria-sort="descending"]::after { content: " ↓"; }
.parts td.num, .parts th.num { text-align: right; }
.parts th.ck, .parts td.ck { width: 32px; padding-right: 0; }
.parts tbody tr { cursor: pointer; }
.parts tbody tr:hover { background: var(--violet-wash); }
.parts tbody tr[aria-selected="true"] { background: var(--violet-tint); box-shadow: inset 3px 0 var(--violet); }
.parts tbody tr.fail td.ck { box-shadow: inset 3px 0 var(--red); }
.parts .dwg { font-weight: 500; }
.parts .cat { color: var(--ink-2); font-size: var(--fs-sm); }
.parts .empty { color: var(--ink-3); }
.parts .edited { border-bottom: 1px dotted var(--violet); }
.st { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); }
.st.ok { color: var(--violet); }
.st.fail { color: var(--red); font-weight: 500; }
.st.none { color: var(--ink-3); }

.detail-empty { color: var(--ink-2); padding: var(--s6) var(--s5); }
.source-part { padding: var(--s3) var(--s5) 0; color: var(--ink-2); }
.source-part h3 { margin: 0 0 var(--s2); font-size: var(--fs-sm); font-weight: 500; color: var(--ink); }
.source-part h4 { margin: var(--s2) 0 0; font-size: var(--fs-xs); font-weight: 500; }
.source-list { margin: 2px 0 0; padding-left: 20px; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.source-part .source-note { margin: var(--s2) 0 0; }
.dh { padding: var(--s5) var(--s5) 0; }
.dh h1 { margin: 0; }
.dh p { margin: 2px 0 0; color: var(--ink-2); }
.tabs { display: flex; gap: var(--s5); padding: 0 var(--s5); margin-top: var(--s4); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 10px 0; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--violet); }
.tabs button:disabled { color: var(--ink-3); cursor: default; }
.stage { background: var(--violet-wash); padding: var(--s4); position: relative; }
.sheet { background: var(--paper); box-shadow: var(--shadow-sheet); border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 420 / 297; cursor: grab; position: relative; touch-action: none; }
.sheet.dragging { cursor: grabbing; }
.sheet img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.stage-empty { color: var(--ink-2); text-align: center; padding: var(--s6) var(--s4); margin: 0; }
.stage-tools { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s2); color: var(--ink-2); font-size: var(--fs-sm); flex-wrap: wrap; }
.stage-tools a { color: var(--violet-strong); }
.viewer { position: relative; height: 420px; border-radius: var(--r-sm); overflow: hidden; background: var(--violet-wash); }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer .labels { position: absolute; inset: 0; }
.viewer-bar { position: absolute; top: var(--s2); left: var(--s2); right: var(--s2); display: flex; gap: var(--s2); flex-wrap: wrap; z-index: 2; }
.viewer-group-label { align-self: center; font-size: var(--fs-xs); color: var(--ink-2); }
.viewer-group { max-width: min(320px, 55vw); min-width: 140px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--paper); color: var(--ink); font-size: var(--fs-sm); }
.viewer-annotation-note { position: absolute; left: var(--s2); top: 48px; z-index: 2; max-width: min(560px, calc(100% - 2 * var(--s2))); margin: 0; padding: 4px 8px; border-radius: var(--r-sm); background: rgba(255,255,255,.92); color: var(--ink-2); font-size: var(--fs-xs); }
.job-resources { margin: 4px 0 0; color: var(--ink-2); font-size: var(--fs-xs); }
.viewer-hint { position: absolute; left: var(--s2); bottom: var(--s2); margin: 0; color: var(--ink-3); font-size: var(--fs-xs); z-index: 2; }
.seg { display: flex; background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; }
.seg button { border: 0; background: none; padding: 5px 10px; color: var(--ink-2); cursor: pointer; font-size: var(--fs-sm); }
.seg button[aria-pressed="true"] { background: var(--violet-tint); color: var(--violet-strong); font-weight: 500; }
.dimtext { font-size: 12px; font-weight: 500; color: var(--ink); padding: 0 3px; border-radius: 3px; background: rgba(255,255,255,.85); pointer-events: none; white-space: nowrap; }
.dimtext.note { border: 1px solid currentColor; }   /* хүрээний өнгийг JS зургийн стандартаас (state.lsp) тавина */

.proof { padding: var(--s5) var(--s5) 0; }
.proof h3 { display: flex; align-items: center; gap: 8px; }
.proof h3 .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; background: var(--violet); flex: none; }
.proof.fail h3 .ic { background: var(--red); }
.proof.fail h3 { color: var(--red-strong); }
.proof .lead { margin: 0 0 var(--s3); color: var(--ink-2); font-size: var(--fs-sm); }
.proof dl { display: grid; grid-template-columns: 22px 1fr; margin: 0; }
.proof dt, .proof dd { margin: 0; padding: 7px 0; border-top: 1px solid var(--line); }
.proof dt { color: var(--violet); }
.proof dt.fail { color: var(--red); font-weight: 600; }
.proof dt.warn { color: var(--ink-2); }
.proof dd b { font-weight: 500; display: block; }
.proof dd span { color: var(--ink-2); font-size: var(--fs-sm); word-break: break-word; }
.proof dd.fail b { color: var(--red-strong); }
.notes { padding: var(--s3) var(--s5) 0; }
.notes p { margin: 0 0 var(--s2); color: var(--ink-2); font-size: var(--fs-sm); padding-left: var(--s3); border-left: 2px solid var(--line-strong); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); padding: var(--s5); }
.fields > * { min-width: 0; }
.fields label > input, .fields label > select { width: 100%; min-width: 0; }
.fields h3 { grid-column: span 2; margin: 0; }
.fields .wide { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--s3); }
.form-msg { color: var(--ink-2); font-size: var(--fs-sm); }
.form-msg.fail { color: var(--red); }

@media (max-width: 1365px) {
  .ws-body { overflow: auto; height: auto; }
  .ws { height: auto; grid-template-rows: auto auto; }
  .ws.layout-both { grid-template-columns: 180px minmax(0, 1fr); grid-template-areas: "rail table" "detail detail"; }
  .ws.layout-both.rail-collapsed { grid-template-columns: 36px minmax(0, 1fr); grid-template-areas: "rail-stub table" "detail detail"; }
  .ws.layout-table { grid-template-columns: 180px minmax(0, 1fr) 36px; grid-template-areas: "rail table detail-stub"; }
  .ws.layout-table.rail-collapsed { grid-template-columns: 36px minmax(0, 1fr) 36px; grid-template-areas: "rail-stub table detail-stub"; }
  .ws.layout-table, .ws.layout-view { grid-template-rows: auto; }
  .ws.layout-view { grid-template-columns: 180px 36px minmax(0, 1fr); grid-template-areas: "rail table-stub detail"; }
  .ws.layout-view.rail-collapsed { grid-template-columns: 36px 36px minmax(0, 1fr); grid-template-areas: "rail-stub table-stub detail"; }
  .ws.layout-both .detail, .ws.layout-view .detail { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .ws.layout-view .detail > .pane-head, .ws.layout-both .detail > .pane-head, .ws.layout-table .list-pane > .pane-head { position: sticky; top: 56px; z-index: 5; background: var(--paper); }
  .ws.layout-view .stage:not(.max) { height: clamp(300px, calc(100dvh - 340px), 720px); }
  .table-wrap { max-height: 60vh; }
}
@media (max-width: 760px) {
  .ws.layout-view, .ws.layout-view.rail-collapsed { grid-template-rows: auto auto auto; }
  .ws.layout-both { grid-template-columns: minmax(0, 1fr); grid-template-areas: "rail" "table" "detail"; }
  .ws.layout-both.rail-collapsed { grid-template-columns: 36px minmax(0, 1fr); grid-template-areas: "rail-stub ." "table table" "detail detail"; }
  .ws.layout-table { grid-template-columns: minmax(0, 1fr) 36px; grid-template-areas: "rail rail" "table detail-stub"; }
  .ws.layout-table.rail-collapsed { grid-template-columns: 36px minmax(0, 1fr) 36px; grid-template-areas: "rail-stub . ." "table table detail-stub"; }
  .ws.layout-view { grid-template-columns: minmax(0, 1fr); grid-template-areas: "rail" "table-stub" "detail"; }
  .ws.layout-view.rail-collapsed { grid-template-columns: 36px 36px minmax(0, 1fr); grid-template-areas: "rail-stub table-stub ." "detail detail detail"; }
  .pane-stub { min-height: 36px; border-right: 0; border-bottom: 1px solid var(--line); }
  .table-stub, .detail-stub { border-left: 0; }
  .rail-stub, .table-stub, .detail-stub { width: 36px; padding: 2px; }
  .ws.layout-view .table-stub { width: 36px; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-grid, .stats { grid-template-columns: 1fr; }
  .bar { padding: 0 var(--s4); gap: var(--s2); }
  .topnav, .asm span { display: none; }
}
.proof .lead.stale { color: var(--red-strong); }
.card.stack > .btn { align-self: flex-start; }
table.parts.stale .st.ok { opacity: .45; }   /* багц хуучирсан: өмнөх ✓ баталгаагүй */
label.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
/* бүтэн дэлгэцээр харах (Esc -> буцах) */
.stage-max { position: absolute; top: calc(var(--s4) + 6px); right: calc(var(--s4) + 6px); z-index: 5; background: var(--paper); }
.stage.max { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; padding: var(--s5); }
.stage.max .sheet { flex: 1; aspect-ratio: auto; min-height: 0; }
.stage.max .viewer { flex: 1; height: auto; min-height: 0; }
.stage.max .stage-max { top: calc(var(--s5) + 6px); right: calc(var(--s5) + 6px); }
body.stage-maxed { overflow: hidden; }
/* Инженерийн утгуудыг энгийн талбараар, тухайн эд ангийн хүрээнд оруулна. */
.engineering-panel { margin: var(--s4); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); }
.engineering-panel summary { cursor: pointer; font-weight: 600; }
.engineering-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s2); margin: var(--s3) 0; }
.engineering-form label { display: flex; flex-direction: column; gap: var(--s1); font-size: var(--fs-sm); min-width: 0; }
.engineering-form input,.engineering-form select { min-width: 0; width: 100%; }
.engineering-form input[type=checkbox] { width: auto; align-self: flex-start; }
.engineering-form [hidden] { display: none; }
.engineering-list { padding-left: var(--s4); font-size: var(--fs-sm); }
.engineering-list li { margin-bottom: var(--s2); }
.engineering-list button { margin-left: var(--s2); }
.build-summary { display: flex; flex-wrap: wrap; gap: var(--s3); padding: var(--s2) var(--s4); color: var(--ink-2); font-size: var(--fs-sm); }
.build-summary[hidden] { display: none; }
.rebuild-option { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-sm); }
.tools .rebuild-option { display: inline-flex; flex-direction: row; align-items: center; white-space: nowrap; }
.tools .rebuild-option input { width: auto; margin: 0; flex: 0 0 auto; }
