/* PMP Production — Base, Shell, Components
   Depends on tokens.css. No per-screen overrides; everything composes from tokens. */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text-accent); text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.boot { display: grid; place-items: center; height: 100vh; color: var(--text-3); font-size: var(--fs-lg); }

/* Default icon size — every icon() renders at 16px unless a context overrides it. */
svg.ic { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -2px; }
.stat .label svg.ic { width: 15px; height: 15px; color: var(--text-3); }
.stat[data-quick] .label svg.ic { color: var(--accent); }
.empty svg.ic { width: 30px; height: 30px; }
.viewer .placeholder svg.ic { width: 34px; height: 34px; }

/* ============ App shell ============ */
.app-shell { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100vh; overflow: hidden; }
.app-shell.rail-collapsed { grid-template-columns: var(--rail-w-compact) 1fr; }

/* Rail (uses --rail-* tokens so Slate Pro gets a navy rail over light content) */
.rail { background: var(--rail-bg); border-right: 1px solid var(--rail-border); display: flex; flex-direction: column; min-width: 0; }
.rail-brand { display: flex; align-items: center; gap: var(--sp-2); height: var(--topbar-h); padding: 0 var(--sp-3); border-bottom: 1px solid var(--rail-border); cursor: pointer; }
.rail-brand .logo { width: 30px; height: 30px; background: transparent; color: var(--brand-valve, var(--rail-accent)); display: grid; place-items: center; flex-shrink: 0; }
.rail-brand .logo svg { width: 30px; height: 30px; }
.rail-brand .name { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--rail-text-strong); white-space: nowrap; overflow: hidden; }
.rail-brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; overflow: hidden; }
.rail-brand .brand-pmp { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: .5px; color: var(--rail-text-strong); }
.rail-brand .brand-sub { font-size: 8px; font-weight: var(--fw-medium); letter-spacing: .3px; text-transform: uppercase; color: var(--rail-muted); white-space: nowrap; }
.rail-brand .brand-ver { font-size: 9px; font-weight: var(--fw-medium); letter-spacing: .3px; color: var(--rail-accent); vertical-align: 2px; }
.rail-brand { gap: var(--sp-2); }
.rail-brand .logo { flex-shrink: 0; }
.rail-collapsed .rail-brand .name, .rail-collapsed .rail-brand .brand-text, .rail-collapsed .rail-group-label, .rail-collapsed .nav-item .label { display: none; }
.rail-collapsed .rail-brand { justify-content: center; padding: 0; }
.rail-collapsed .nav-item { justify-content: center; }
/* Collapsed footer: stack the action buttons vertically, centered (no overflow) */
.rail-collapsed .rail-foot { flex-direction: column; gap: 4px; align-items: center; }
.rail-collapsed .rail-foot .grow { display: none; }

.rail-nav { flex: 1; overflow-y: auto; padding: var(--sp-2) var(--sp-1); }
.rail-group-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--rail-group); padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.nav-item { display: flex; align-items: center; gap: var(--sp-2); height: 34px; padding: 0 var(--sp-3); margin: 1px var(--sp-1); border-radius: var(--r-md); color: var(--rail-text); cursor: pointer; user-select: none; white-space: nowrap; transition: background var(--t-fast); }
.nav-item:hover { background: var(--rail-active-bg); color: var(--rail-text-strong); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--rail-text-strong); font-weight: var(--fw-bold); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .label { flex: 1; }
[hidden] { display: none !important; }   /* ensure hidden cards/sections never render (e.g. import map card) */
/* Branded, clearly-visible checkboxes/radios (data-entry selection) */
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; vertical-align: middle; flex-shrink: 0; }
/* Unread-email-style attention badge on rail items + tabs */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 10px; font-weight: var(--fw-bold); line-height: 1; vertical-align: middle; }
.nav-item.active .nav-badge, .tab .nav-badge { box-shadow: 0 0 0 1.5px var(--bg-surface); }
/* Collapsed rail: badge becomes a small notification dot on the icon corner (count stays in the
   tooltip) — a "99+" pill can't fit the narrow rail without overlapping the glyph. */
.rail-collapsed .nav-item { position: relative; }
/* Scope to RAIL nav items only — must not leak onto tabbar badges (.tab .nav-badge), which would
   turn the tab count into a floating absolute dot. */
.rail-collapsed .nav-item .nav-badge { position: absolute; top: 5px; right: 50%; transform: translateX(13px); margin: 0; min-width: 0; width: 9px; height: 9px; padding: 0; font-size: 0; line-height: 0; border-radius: 50%; box-shadow: 0 0 0 2px var(--rail-bg); }
.rail-foot { padding: var(--sp-2); border-top: 1px solid var(--rail-border); }
.rail .icon-btn { color: var(--rail-text); }
.rail .icon-btn:hover { background: var(--rail-active-bg); color: var(--rail-text-strong); }

/* Main column */
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
/* On-demand insights surface (drawer / top bar) */
.insights-backdrop { position: absolute; inset: 0; top: var(--topbar-h); background: rgba(15, 23, 42, 0.28); z-index: 60; }
.insights-panel { position: absolute; top: var(--topbar-h); right: 0; bottom: 0; width: 440px; max-width: 92%; background: var(--bg-surface); border-left: 1px solid var(--border-1); box-shadow: var(--shadow-pop); z-index: 61; display: flex; flex-direction: column; }
.insights-panel.as-bar { left: 0; right: 0; bottom: auto; width: auto; max-width: none; max-height: 280px; border-left: none; border-bottom: 1px solid var(--border-1); box-shadow: var(--shadow-card); }
.insights-panel-head { display: flex; align-items: center; gap: 8px; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-1); font-weight: var(--fw-medium); flex-shrink: 0; }
.insights-panel-head svg { width: 16px; height: 16px; color: var(--accent); }
.insights-panel-body { flex: 1; min-height: 0; overflow: auto; background: var(--bg-app); }
.insights-panel-body .page-head { padding: var(--sp-4) var(--sp-4) var(--sp-1); }
/* tame the embedded module insights header inside the narrow drawer */
.insights-panel-body .page-head h1 { font-size: var(--fs-lg); }
.insights-panel-body .page-head .sub { font-size: var(--fs-xs); }
.insights-panel-body .widget-grid { padding: 0 var(--sp-4) var(--sp-4); gap: 12px; }
/* Dashboard / Insights layout-options dropdown (top-right of the board header) */
.board-menu { position: relative; display: inline-flex; }
.board-menu-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 168px; background: var(--bg-surface); border: 1px solid var(--border-2); border-radius: var(--r-md); box-shadow: var(--shadow-2, 0 8px 24px rgba(0,0,0,.18)); padding: 5px; display: flex; flex-direction: column; gap: 2px; }
.board-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 10px; border: none; background: transparent; color: var(--text-1); font-size: var(--fs-sm); border-radius: var(--r-sm); cursor: pointer; }
.board-menu-item:hover { background: var(--bg-hover); }
.board-menu-item .ic { width: 16px; height: 16px; color: var(--text-2); }
/* Per-card hide/show control shown while a dashboard is in Edit-layout mode */
.dash-edit-x { position: absolute; top: 6px; right: 6px; z-index: 5; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--border-2); background: var(--bg-surface); color: var(--text-1); font-size: 15px; line-height: 1; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.dash-edit-x:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* mobile-app feel: soft rounded tiles with elevation for the embedded module widgets too */
.insights-panel-body .widget { border-radius: 20px; box-shadow: 0 4px 16px rgba(15, 23, 42, 0.07); border: none; }

/* per-tab configured metric cards (built in shell.js renderInsightMetrics) — mobile dashboard tiles */
.tab-metrics { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-3); }
.tab-metrics-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: var(--fw-bold); }
.tab-metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tab-metric {
  position: relative; overflow: hidden;
  background: var(--bg-surface);
  border: none; border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tab-metric::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--accent); opacity: .9; }
.tab-metric:active { transform: scale(.97); }
.tab-metric-val { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--text-1); line-height: 1.05; letter-spacing: -.02em; }
.tab-metric-lab { font-size: var(--fs-sm); color: var(--text-2); margin-top: 6px; font-weight: var(--fw-medium); }
/* explicit display rules above out-rank [hidden]'s UA display:none — restore it */
.insights-panel[hidden], .insights-backdrop[hidden] { display: none; }
.cursor-note { position: fixed; z-index: 1300; max-width: 300px; background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); color: var(--text-1); }
.cursor-note .cn-cwa { display: inline-block; background: var(--accent-soft); color: var(--text-accent); border-radius: var(--r-pill); padding: 1px 8px; margin: 3px 3px 0 0; font-family: var(--pmp-font-mono, monospace); }
.pdb-total { display: flex; align-items: center; gap: 6px; }
.pdb-total svg.ic { width: 15px; height: 15px; color: var(--accent); }
.pdb-total b { color: var(--text-1); }
/* Continuity review — side-by-side ISO drawings */
.cr-review-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; flex: 0 0 auto; }
.cr-review-cols { display: flex; flex: 1 1 auto; min-height: 0; align-items: stretch; }
.cr-review-col { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.cr-review-col.cr-col-cur { flex: 0 0 50%; }        /* JS splitter adjusts this basis */
.cr-review-col.cr-col-cand { flex: 1 1 auto; }
.cr-review-split { flex: 0 0 10px; align-self: stretch; cursor: col-resize; position: relative; }
.cr-review-split::before { content: ''; position: absolute; inset: 0 4px; border-radius: 2px; background: var(--border-1); transition: background .15s; }
.cr-review-split:hover::before { background: var(--accent); }
.cr-rv-cap { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-2); flex: 0 0 auto; }
.cr-rv-cap svg { width: 14px; height: 14px; color: var(--accent); }
.cr-rv-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--border-1); border-radius: var(--r-md); overflow: hidden; background: var(--bg-surface-2); }
.cr-rv-view .viewer-toolbar { flex: 0 0 auto; }
.cr-rv-view .viewer { flex: 1 1 auto; min-height: 0; }
/* Continuity review modal: large by default and user-resizable for ISO drawing review. */
.modal.cr-modal { width: min(1600px, 96vw); height: 92vh; max-height: 92vh; min-width: 640px; min-height: 440px; resize: both; }
.modal.cr-modal .modal-body { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
@media (max-width: 720px) { .cr-review-cols { flex-direction: column; } .cr-review-col.cr-col-cur { flex: 1 1 auto; } .cr-review-split { display: none; } }

/* Topbar */
.topbar { display: flex; align-items: center; gap: var(--sp-3); height: var(--topbar-h); padding: 0 var(--sp-4); background: var(--bg-surface); border-bottom: var(--topbar-border, 1px solid var(--border-1)); }
.topbar .icon-btn { color: var(--text-2); }
.crumbs { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.crumbs .ctx-pill { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--border-1); border-radius: var(--r-md); cursor: pointer; }
.crumbs .ctx-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.crumbs .ctx-cap { font-size: 8.5px; font-weight: var(--fw-medium); letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }
.crumbs .ctx-meta [data-ctx-text] { font-size: var(--fs-sm); color: var(--text-1); font-weight: var(--fw-medium); white-space: nowrap; }
.crumbs .ctx-pill:hover { background: var(--bg-hover); }
.crumbs .sep { color: var(--text-3); }
.topbar .spacer { flex: 1; }
.cmd-trigger { display: flex; align-items: center; gap: var(--sp-2); width: 320px; max-width: 38vw; height: 32px; padding: 0 var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-md); color: var(--text-3); font-size: var(--fs-sm); cursor: text; background: var(--bg-app); }
.cmd-trigger:hover { border-color: var(--border-2); }
.cmd-trigger .kbd { margin-left: auto; font-size: var(--fs-xs); border: 1px solid var(--border-1); border-radius: 4px; padding: 1px 6px; color: var(--text-3); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-weak); color: var(--accent); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: var(--fw-medium); border: none; cursor: pointer; }
.user-menu { position: relative; }
.user-pop { position: absolute; right: 0; top: 36px; width: 220px; background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px; z-index: 1300; }
.user-pop-head { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border-1); margin-bottom: 4px; }
.user-pop-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border: none; background: transparent; color: var(--text-1); border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-sm); text-align: left; }
.user-pop-item:hover { background: var(--bg-hover); }
.user-pop-item svg { width: 16px; height: 16px; color: var(--text-2); }
.user-pop-foot { margin: 6px 2px 2px; padding-top: 8px; border-top: 1px solid var(--border-1); font-size: var(--fs-xs); color: var(--text-3); text-align: center; }
.ver-badge { flex: none; display: inline-flex; align-items: center; padding: 8px 14px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text-accent); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
/* DCC upload wizard stepper */
.wstep { display: flex; flex-direction: column; gap: 8px; transition: opacity var(--t-fast), box-shadow var(--t-fast); }
.wstep .wstep-head { display: flex; align-items: center; gap: 8px; }
.wstep .wstep-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); background: var(--bg-surface-2); color: var(--text-2); border: 1px solid var(--border-1); flex: none; }
.wstep .wstep-num svg { width: 14px; height: 14px; }
.wstep .wstep-title { font-weight: var(--fw-bold); }
.wstep .wstep-pill { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: var(--fw-medium); padding: 3px 9px; border-radius: 999px; background: var(--bg-surface-2); color: var(--text-3); }
.wstep .wstep-pill svg { width: 12px; height: 12px; }
.wstep-actions { margin-top: auto; display: flex; gap: 6px; }
.wstep-actions .btn { flex: 1; justify-content: center; height: 32px; }
.wstep.active { box-shadow: 0 0 0 1px var(--accent), var(--shadow-card); }
.wstep.active .wstep-num { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.wstep.active .wstep-pill { background: var(--accent-soft); color: var(--text-accent); }
.wstep.done .wstep-num { background: var(--ok-text); color: var(--bg-surface); border-color: var(--ok-text); }
.wstep.done .wstep-pill { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); }
.wstep.locked { opacity: .5; }
.wstep.locked .btn { pointer-events: none; }
.wstep-bar { display: flex; flex-direction: column; gap: 4px; }
.progress.indet { overflow: hidden; }
.progress.indet > i { width: 35% !important; border-radius: 999px; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* Login screen */
.login-scrim { position: fixed; inset: 0; background: var(--bg-app); display: grid; place-items: center; z-index: 2000; padding: var(--sp-4); }
.login-card { width: 360px; max-width: 96vw; background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .brand-pmp { font-weight: var(--fw-bold); letter-spacing: .5px; line-height: 1.1; }
.login-brand .brand-sub { font-size: 9px; font-weight: var(--fw-medium); letter-spacing: 1.4px; text-transform: uppercase; }

/* Tabbar */
.tabbar { display: flex; align-items: center; gap: 2px; height: var(--tabbar-h); padding: 0 var(--sp-4); background: var(--bg-surface); border-bottom: 1px solid var(--border-1); overflow: hidden; }
.tabbar-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; min-width: 0; }
.tabbar-kpi { display: flex; align-items: center; gap: 14px; flex-shrink: 0; padding-left: var(--sp-3); }
.tabbar-kpi .tabkpi { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.tabbar-kpi .tabkpi b { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-1); }
.tabbar-kpi .tabkpi span { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.tab { display: flex; align-items: center; gap: 6px; height: 100%; padding: 0 var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--selected-fg); font-weight: var(--fw-bold); border-bottom-color: var(--accent); }

/* Content area */
.content { flex: 1; min-height: 0; overflow: auto; padding: var(--sp-4); display: flex; flex-direction: column; }
/* fill-table screens own their internal scroll so the sticky header stays put */
.content > .tp-table-fill, .content > .dt-fill { flex: 1; min-height: 0; }
.content.flush { padding: 0; }
.page-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.page-head h1 { font-size: var(--fs-xl); font-weight: var(--fw-bold); margin: 0; letter-spacing: -0.02em; }
.page-head .sub { font-size: var(--fs-sm); color: var(--text-2); }

/* ============ Components ============ */

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--sp-3); border: 1px solid var(--border-2); background: var(--bg-surface); color: var(--text-1); border-radius: var(--r-md); font-size: var(--fs-sm); cursor: pointer; transition: background var(--t-fast), transform var(--t-fast); white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(.98); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.danger { color: var(--err-text); border-color: var(--err-border); }
.btn.sm { height: 28px; font-size: var(--fs-xs); padding: 0 var(--sp-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: none; background: transparent; color: var(--text-2); border-radius: var(--r-md); cursor: pointer; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.icon-btn svg { width: 17px; height: 17px; }

/* Inputs */
.input, .select, textarea.input { height: 32px; width: 100%; padding: 0 var(--sp-3); border: 1px solid var(--border-2); background: var(--bg-surface); color: var(--text-1); border-radius: var(--r-md); font-size: var(--fs-sm); outline: none; }
textarea.input { height: auto; padding: var(--sp-2) var(--sp-3); resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: var(--shadow-ring); }
.input::placeholder { color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: var(--fs-xs); color: var(--text-2); }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 30px; }

/* Badges / pills */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: var(--fw-medium); border: 1px solid transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.badge.err { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); }
.badge.info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }
.badge.muted { background: var(--bg-surface-2); color: var(--text-2); border-color: var(--border-1); }

/* Cards & stats */
.card { background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-card); }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--text-1); }
/* sidebar icon editor rows */
.nav-icon-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border-1); }
.nav-icon-row:last-child { border-bottom: none; }
.nav-icon-glyph { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text-accent); }
.nav-icon-glyph svg { width: 18px; height: 18px; }
.nav-icon-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sec-title svg { width: 18px; height: 18px; color: var(--text-2); }
.empty.sm { padding: var(--sp-5) var(--sp-3); min-height: 0; }
.empty.sm svg { width: 28px; height: 28px; }
/* DCC icon registry gallery */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.icon-chip { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-1); border-radius: var(--r-md); background: var(--bg-surface-2); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.icon-chip:hover { border-color: var(--accent); box-shadow: var(--shadow-card); }
.icon-chip-glyph { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text-accent); }
.icon-chip-glyph svg { width: 20px; height: 20px; }
.icon-chip-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.icon-chip-label { font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-chip-sub { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-chip-badge { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-left: auto; box-shadow: 0 0 0 2px var(--bg-surface-2); }
.icon-chip-actions { display: none; gap: 4px; margin-left: auto; }
.icon-chip:hover .icon-chip-actions { display: flex; }
.icon-chip:hover .icon-chip-badge { display: none; }
/* icon picker (modal) */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; max-height: 220px; overflow: auto; padding: 4px; border: 1px solid var(--border-1); border-radius: var(--r-md); background: var(--bg-surface-2); }
.picker-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid transparent; border-radius: var(--r-md); background: transparent; cursor: pointer; color: var(--text-2); }
.picker-cell svg { width: 20px; height: 20px; }
.picker-cell span { font-size: 9px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.picker-cell:hover { background: var(--bg-hover); color: var(--text-1); }
.picker-cell.active { border-color: var(--accent); background: var(--accent-soft); color: var(--selected-fg); }
.picker-cell.active span { color: var(--selected-fg); font-weight: var(--fw-bold); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
.rec-metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat { background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-card); transition: box-shadow var(--t-fast), transform var(--t-fast); }
.stat[data-quick] { cursor: pointer; }
.stat[data-quick]:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
.stat .label { font-size: var(--fs-sm); color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); margin-top: 6px; letter-spacing: -0.02em; }
.stat .value.ok { color: var(--ok-text); }
.stat .value.warn { color: var(--warn-text); }
.stat .value.err { color: var(--err-text); }

/* Toolbar row */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--bg-surface-2); border-radius: var(--r-md); padding: 2px; }
.seg button { height: 26px; padding: 0 10px; border: none; background: transparent; color: var(--text-2); font-size: var(--fs-sm); border-radius: var(--r-sm); cursor: pointer; }
.seg button.active { background: var(--accent-weak); color: var(--text-accent); font-weight: var(--fw-bold); box-shadow: inset 0 0 0 1px var(--accent-soft); }

/* Data table */
.table-wrap { border: 1px solid var(--border-1); border-radius: var(--r-lg); overflow: auto; background: var(--bg-surface); box-shadow: var(--shadow-card); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
table.data thead th { position: sticky; top: 0; z-index: 2; background: var(--th-bg); color: var(--th-fg); font-weight: var(--fw-medium); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: var(--cell-pad-y) var(--cell-pad-x); border-bottom: 1px solid var(--th-bg); white-space: nowrap; cursor: default; }
table.data thead th.sortable:hover { background: color-mix(in srgb, var(--th-bg) 88%, #fff); }
table.data thead th .sort-ind { color: var(--th-fg); margin-left: 4px; }
/* Excel-style per-column filter: funnel button in the header + a dropdown menu */
/* keep position:sticky from the base rule (sticky already anchors the absolute funnel button) */
table.data thead th.has-filter { padding-right: 22px; }
.th-filter { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; padding: 0; border: none; background: transparent; color: var(--th-fg); opacity: .4; cursor: pointer; border-radius: 3px; }
table.data thead th.has-filter:hover .th-filter { opacity: .85; }
.th-filter:hover { background: rgba(125, 125, 125, .25); opacity: 1; }
.th-filter.active { opacity: 1; color: #fff; background: var(--accent); }
.dt-filter-menu { position: fixed; z-index: 100000; width: 250px; max-height: 70vh; display: flex; flex-direction: column; background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-md); box-shadow: var(--shadow-pop); font-size: var(--fs-sm); overflow: hidden; }
.dt-fm-sort { display: flex; flex-direction: column; border-bottom: 1px solid var(--border-1); }
.dt-fm-sortbtn { text-align: left; padding: 7px 12px; background: none; border: none; cursor: pointer; color: var(--text-1); font-size: var(--fs-sm); }
.dt-fm-sortbtn:hover { background: var(--bg-hover); }
.dt-fm-search { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border-1); }
.dt-fm-search svg { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.dt-fm-search .input { height: 28px; }
.dt-fm-allrow { border-bottom: 1px solid var(--border-1); }
.dt-fm-list { overflow: auto; flex: 1 1 auto; padding: 4px 0; min-height: 60px; }
.dt-fm-row { padding: 3px 12px; display: flex; align-items: center; gap: 4px; }
.dt-fm-row label { display: flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.dt-fm-row:hover { background: var(--bg-hover); }
.dt-fm-y label, .dt-fm-m label { font-weight: var(--fw-medium); }
.dt-fm-m { padding-left: 24px; }
.dt-fm-d { padding-left: 46px; }
.dt-fm-exp { width: 16px; border: none; background: none; cursor: pointer; color: var(--text-2); font-size: 11px; padding: 0; flex: none; }
.dt-fm-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--border-1); }
/* password field with show/hide eye toggle */
.pw-field { position: relative; display: block; }
.pw-field .input { width: 100%; padding-right: 42px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: none; background: transparent; color: var(--text-3); cursor: pointer; border-radius: var(--r-sm); }
.pw-toggle:hover { color: var(--text-1); background: var(--bg-hover); }
.pw-toggle svg { width: 18px; height: 18px; }
/* frozen left column (e.g. the row-actions column) — stays visible during horizontal scroll */
.dt-sticky-left { position: sticky; left: 0; z-index: 1; }
table.data thead th.dt-sticky-left { left: 0; z-index: 3; }   /* top-left corner sits above other headers */
table.data tbody td.dt-sticky-left { background: var(--bg-surface); }
table.data tbody tr:hover td.dt-sticky-left { background: var(--bg-hover); }
table.data tbody tr.selected td.dt-sticky-left { background: var(--bg-selected); }
/* per-row edit/delete action buttons in the pinned left rail — shown only on the highlighted row */
.dt-rowact { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s ease; }
table.data tbody tr:hover .dt-rowact, table.data tbody tr.selected .dt-rowact { opacity: 1; }
.dt-rowact .icon-btn { width: 26px; height: 26px; color: var(--text-2); }
.dt-rowact .icon-btn:hover { color: var(--accent); background: var(--bg-hover); }
table.data tbody td { padding: var(--cell-pad-y) var(--cell-pad-x); border-bottom: 1px solid var(--border-1); height: var(--row-h); color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
table.data tbody tr { cursor: default; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr.selected { background: var(--bg-selected); color: var(--selected-fg); font-weight: var(--fw-bold); }
table.data tbody tr.row-click { cursor: pointer; }
.table-empty { padding: var(--sp-8); text-align: center; color: var(--text-3); }
/* DataTable built-in toolbar */
.dt-toolbar { display: flex; align-items: center; gap: 6px; padding: var(--sp-2) 0; flex-shrink: 0; flex-wrap: wrap; }
.dt-toolbar .dt-pager-inline { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: none; margin-left: 4px; }
.dt-toolbar .dt-pager-inline .select { height: 28px; }
.dt-toolbar .dt-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--text-1); letter-spacing: -0.02em; }
.dt-toolbar .dt-title + .dt-count { padding-left: 8px; margin-left: 8px; border-left: 1px solid var(--border-1); }
.dt-toolbar .dt-count { font-size: var(--fs-sm); color: var(--text-2); font-weight: var(--fw-medium); }
.dt-toolbar .dt-search { width: 220px; max-width: 32vw; margin-left: 8px; }
.dt-toolbar .dt-search .input { height: 28px; }
/* batch selector group */
.batch-bar { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--border-1); border-radius: var(--r-md); background: var(--bg-surface); }
.batch-bar .batch-label { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); white-space: nowrap; }
.batch-bar .batch-label svg { width: 14px; height: 14px; color: var(--accent); }
.batch-bar .select { width: auto; border: none; background: transparent; height: 28px; font-weight: var(--fw-medium); }
.batch-bar .icon-btn { width: 28px; height: 28px; }
.dt-fill .dt-toolbar { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-1); }
/* Batch Report issue filter chips */
.match-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.mf-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border-1); border-radius: 999px; background: var(--bg-surface); color: var(--text-2); cursor: pointer; font-size: var(--fs-sm); }
.mf-chip b { font-weight: var(--fw-bold); color: var(--text-1); }
.mf-chip:hover { background: var(--bg-hover); }
.mf-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text-accent); }
.mf-chip.active b { color: inherit; }
.mf-chip.ok.active { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-text); }
.mf-chip.warn.active { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-text); }
.mf-chip.err.active { border-color: var(--err-border); background: var(--err-bg); color: var(--err-text); }
/* tablePage: fill remaining height so the grid scrolls internally (sticky header + both axes) */
.tp-table-fill { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tp-table-fill .table-wrap { flex: 1; min-height: 0; }
.cols-config { gap: 2px; max-height: 360px; overflow: auto; }
.cols-row { display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: var(--r-sm); }
.cols-row:hover { background: var(--bg-hover); }
.cols-row [data-col-down] svg { transform: rotate(90deg); }
.cols-row [data-col-up] svg { transform: rotate(-90deg); }
.cols-row[draggable="true"] { cursor: grab; }
.cols-row .dt-grip { display: inline-flex; color: var(--text-muted); cursor: grab; opacity: .55; }
.cols-row .dt-grip:active { cursor: grabbing; }
.cols-row.dragging { opacity: .45; background: var(--bg-hover); }
.cols-row.drop-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.cols-row.drop-after { box-shadow: inset 0 -2px 0 0 var(--accent); }
.nav-icon-row[draggable="true"] { cursor: grab; }
.nav-icon-row .dt-grip { display: inline-flex; color: var(--text-muted); cursor: grab; opacity: .5; margin-right: 2px; }
.nav-icon-row .dt-grip:active { cursor: grabbing; }
.nav-icon-row.dragging { opacity: .45; background: var(--bg-hover); }
.nav-icon-row.drop-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.nav-icon-row.drop-after { box-shadow: inset 0 -2px 0 0 var(--accent); }
.pager { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); border-top: 1px solid var(--border-1); }
.pager .spacer { flex: 1; }

/* Tree */
.tree { font-size: var(--tree-fs); user-select: none; }
.tree-node { display: flex; align-items: center; gap: 6px; height: var(--tree-row-h); padding: 0 var(--sp-2); border-radius: var(--r-sm); cursor: pointer; color: var(--text-2); white-space: nowrap; }
.tree-node:hover { background: var(--bg-hover); color: var(--text-1); }
.tree-node.selected { background: var(--bg-selected); color: var(--selected-fg); font-weight: var(--fw-bold); }
.tree-node.selected .tnode-icon svg { color: var(--selected-fg); }
.tree-node .twisty { width: 14px; display: inline-grid; place-items: center; color: var(--text-3); }
.tree-node .twisty svg { width: 13px; height: 13px; transition: transform var(--t-fast); }
.tree-node.open .twisty svg { transform: rotate(90deg); }
.tree-node .tnode-icon svg { width: 15px; height: 15px; }
.tree-children { margin-left: 12px; border-left: 1px solid var(--border-1); padding-left: 2px; }
/* Pin Package + CWA folder rows so they stay visible while scrolling a long ISO list */
.left-scroll .tree-node[data-leaf="0"] { position: sticky; z-index: 2; background: var(--bg-surface); }
.left-scroll > .tree > .tree-node[data-leaf="0"] { top: 0; z-index: 4; }
.left-scroll .tree-children > .tree-node[data-leaf="0"] { top: var(--tree-row-h, 28px); z-index: 3; }
/* ISO lifecycle marks (left of the name in tree leaves / list rows) */
.iso-mark { font-size: 9px; font-weight: var(--fw-bold); letter-spacing: .03em; padding: 1px 5px; border-radius: 4px; margin-right: 6px; flex-shrink: 0; color: #fff; }
.iso-mark.del { background: #b3261e; }
.iso-mark.sup { background: #6b7280; }
.iso-mark.hold { background: #b7791f; }
.tree-node.tnode-deleted[data-leaf="1"] > .tnode-label { text-decoration: line-through; opacity: .8; }
.tree-node.tnode-superseded[data-leaf="1"] > .tnode-label { opacity: .85; }
/* Quarantine FOLDERS (top-level Deleted / Superseded nodes) → red, so they stand out from the live tree */
.tree-node.tnode-deleted[data-leaf="0"] .tnode-icon svg,
.tree-node.tnode-deleted[data-leaf="0"] .tnode-label,
.tree-node.tnode-superseded[data-leaf="0"] .tnode-icon svg,
.tree-node.tnode-superseded[data-leaf="0"] .tnode-label { color: #d3302a; font-weight: var(--fw-bold); }
.tree-node.tnode-deleted[data-leaf="0"] .badge,
.tree-node.tnode-superseded[data-leaf="0"] .badge { background: #fdeceb; color: #b3261e; }
/* Corner ribbon over the open drawing when the ISO is deleted / superseded / on hold */
.ws2-viewer { position: relative; }
.iso-ribbon { position: absolute; top: 12px; right: 0; padding: 6px 16px; font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .08em; color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35); z-index: 6; border-radius: 5px 0 0 5px; pointer-events: none; }
.iso-ribbon.deleted { background: #b3261e; }
.iso-ribbon.superseded { background: #6b7280; }
.iso-ribbon.hold { background: #b7791f; }

/* Stacked operator workspace: left tree | right (viewer top + table bottom) */
.ws2 { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kpi-bar { display: flex; align-items: center; gap: var(--sp-5); padding: var(--sp-2) var(--sp-4); background: var(--bg-surface); border-bottom: 1px solid var(--border-1); overflow-x: auto; flex-shrink: 0; }
.kpi-bar .kpi { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.kpi-bar .kpi b { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.kpi-bar .kpi span { font-size: var(--fs-xs); color: var(--text-2); }
.ws2-main { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--ws-left, 240px) 5px 1fr; }
.ws2-left { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-surface); }
.ws2-right { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
/* Cap the viewer so the data table below ALWAYS keeps ≥200px — a stale/oversized persisted
   --ws-viewer-h must never squeeze the table out of view. */
.ws2-viewer { height: var(--ws-viewer-h, 280px); max-height: calc(100% - 200px); flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ws2-viewer .viewer-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ws2-table { min-height: 140px; }
/* Viewer tab strip — ISO drawing ↔ Support standard (shown when a support row is selected) */
.vw-tabs { display: flex; align-items: center; gap: 6px; padding: 4px var(--sp-2); background: var(--bg-surface-2); border-bottom: 1px solid var(--border-1); flex-shrink: 0; }
.vw-tab { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); padding: 3px 9px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.vw-tab:hover { background: var(--bg-hover); }
.vw-tab.active { background: var(--accent-weak); color: var(--text-accent); font-weight: var(--fw-bold); }
.vw-tab svg { width: 14px; height: 14px; }
.ws2-table { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.splitter-x { background: transparent; cursor: col-resize; }
.splitter-x:hover { background: var(--accent-soft); }
/* Collapsible left pane: a chevron in the head shrinks the panel to a thin strip (drawing gets full width) */
.pane-collapse { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 2px 4px; border-radius: 6px; display: flex; align-items: center; flex-shrink: 0; }
.pane-collapse:hover { background: var(--bg-hover); color: var(--text-1); }
.pane-collapse svg { width: 16px; height: 16px; transition: transform .15s ease; transform: rotate(90deg); }
.ws2-left-collapsed .ws2-main { grid-template-columns: 34px 5px 1fr; }
.ws2-left-collapsed .ws2-left .pane-body { display: none; }
.ws2-left-collapsed .ws2-left .pane-head-title, .ws2-left-collapsed .ws2-left .pane-head-icon { display: none; }
.ws2-left-collapsed .ws2-left .pane-head { justify-content: center; padding-left: 0; padding-right: 0; }
.ws2-left-collapsed .pane-collapse svg { transform: rotate(-90deg); }
.ws2-left-collapsed .splitter-x { pointer-events: none; }
.splitter-y { height: 7px; background: var(--bg-surface-2); border-top: 1px solid var(--border-1); border-bottom: 1px solid var(--border-1); cursor: row-resize; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.splitter-y:hover { background: var(--accent-soft); }
.splitter-y .grip { width: 36px; height: 3px; border-radius: 2px; background: var(--border-strong); }
/* table that fills the bottom pane and scrolls internally */
.dt-fill { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dt-fill .table-wrap { flex: 1; min-height: 0; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
.ws2-pane-toolbar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-1); flex-shrink: 0; }
/* selectable list row (parse queue / iso list) */
.pick { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-radius: var(--r-md); cursor: pointer; }
.pick:hover { background: var(--bg-hover); }
.pick.selected { background: var(--bg-selected); }
.pick .pick-top { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.pick.selected .pick-top { color: var(--selected-fg); font-weight: var(--fw-bold); }
.pick .pick-sub { font-size: var(--fs-xs); color: var(--text-2); }
.left-controls { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; background: transparent; }
/* full-height left pane with its own scrolling list + pinned sidebar sub-tabs */
.left-pane-fill { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 8px; padding-top: 2px; }
.left-controls { padding-bottom: 8px; border-bottom: 1px solid var(--border-1); }
.left-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.left-scroll > .empty { margin: auto; padding: var(--sp-6) var(--sp-3); }
/* queue header count chip */
.ws-pane.left .pane-head { gap: 6px; }
.ws-pane.left .pane-head .badge { margin-left: auto; }
.side-cap { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 4px 4px 2px; }
.seg-vert { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.seg-vert button { height: 28px; font-size: var(--fs-xs); border: 1px solid var(--border-1); background: var(--bg-surface); border-radius: var(--r-md); color: var(--text-2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-vert button:hover { background: var(--bg-hover); }
.seg-vert button.active { background: var(--bg-selected); color: var(--selected-fg); border-color: var(--accent); font-weight: var(--fw-bold); }
/* top sub-tab strip scrolls horizontally when it overflows the toolbar */
.seg.seg-scroll { overflow-x: auto; max-width: 70%; scrollbar-width: none; }
.seg.seg-scroll::-webkit-scrollbar { height: 0; }
.seg.seg-scroll button { flex-shrink: 0; }
/* Record-count badge on each ISO data sub-tab (Joints/Spools/BOM…) — hidden when zero/empty */
.subtab-count { margin-left: 5px; font-size: 10px; font-weight: var(--fw-bold); color: var(--text-3); background: var(--bg-surface-2); border-radius: 8px; padding: 0 5px; line-height: 16px; }
.subtab-count:empty, .subtab-count.zero { display: none; }
.seg button.active .subtab-count { background: var(--accent-weak); color: var(--text-accent); }
/* Progress-record activity selector: clearly highlight the active activity in the accent colour. */
.seg[data-rec-act] { gap: 2px; }
.seg[data-rec-act] button { height: 30px; padding: 0 13px; gap: 6px; display: inline-flex; align-items: center; }
.seg[data-rec-act] button:hover { background: var(--bg-hover); color: var(--text-1); }
.seg[data-rec-act] button.active,
.seg[data-rec-act] button.active:hover { background: var(--accent); color: #fff; font-weight: var(--fw-bold); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.seg[data-rec-act] button.active .ic { stroke: #fff; }
/* Progress-record date selector */
.rec-datebox { display: inline-flex; align-items: center; gap: 12px; padding: 6px 8px 6px 12px; border: 1px solid var(--border-2); border-radius: var(--r-md); background: var(--bg-surface); }
.rec-datebox-ic { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--accent-weak); color: var(--text-accent); }
.rec-datebox-ic .ic { stroke: var(--text-accent); }
.rec-datebox-fields { display: flex; flex-direction: column; gap: 1px; }
.rec-dateinput { border: none; background: transparent; color: var(--text-1); font-size: var(--fs-md); font-weight: var(--fw-medium); padding: 0; outline: none; font-family: inherit; }
.rec-dateinput::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; }
.rec-dateinput::-webkit-calendar-picker-indicator:hover { opacity: 1; }
.rec-datequick { display: inline-flex; gap: 4px; padding-left: 8px; border-left: 1px solid var(--border-1); }
.rec-datequick button { height: 26px; padding: 0 10px; font-size: var(--fs-xs); border: 1px solid var(--border-2); background: var(--bg-surface); color: var(--text-2); border-radius: var(--r-sm); cursor: pointer; }
.rec-datequick button:hover { background: var(--bg-hover); color: var(--text-1); border-color: var(--accent-soft); }
.rec-datequick button.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: var(--fw-medium); }
.rec-cwaselect { border: none; background: transparent; color: var(--text-1); font-size: var(--fs-md); font-weight: var(--fw-medium); padding: 0 2px 0 0; outline: none; font-family: inherit; cursor: pointer; max-width: 200px; }
.rec-cwaselect option { color: var(--text-1); background: var(--bg-surface); }
.rec-clear { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 12px; border: 1px solid var(--border-2); background: var(--bg-surface); color: var(--text-2); border-radius: var(--r-md); font-size: var(--fs-sm); cursor: pointer; }
.rec-clear:hover { background: var(--bg-hover); color: var(--text-1); border-color: var(--accent-soft); }
.rec-clear .ic { width: 15px; height: 15px; }
.rec-weekchip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: var(--r-md); background: var(--accent-weak); color: var(--text-accent); font-size: var(--fs-sm); white-space: nowrap; }
.rec-weekchip .ic { width: 15px; height: 15px; stroke: var(--text-accent); }
.rec-weekchip b { color: var(--text-accent); font-weight: var(--fw-bold); }
/* queue / tree left-pane polish */
.ws-pane.left .pane-head { background: var(--bg-surface); font-weight: var(--fw-medium); color: var(--text-1); }
.ws-pane.left .pane-head svg { color: var(--accent); }
.left-controls { gap: 6px; }
.pick { gap: 3px; padding: 6px 8px; }
.pick + .pick { margin-top: 1px; }
.pick .pick-top svg { color: var(--text-3); width: 14px; height: 14px; }
.pick.selected .pick-top svg { color: var(--accent); }

/* Splitter layout (tree | table | preview) */
.workspace { display: grid; grid-template-columns: var(--ws-left, 240px) 1fr var(--ws-right, 280px); height: 100%; min-height: 0; }
.workspace.no-right { grid-template-columns: var(--ws-left, 240px) 1fr; }
.ws-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.ws-pane.left { border-right: 1px solid var(--border-1); }
.ws-pane.right { border-left: 1px solid var(--border-1); background: var(--bg-surface); }
.ws-pane .pane-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-1); font-size: var(--fs-sm); color: var(--text-2); }
.ws-pane .pane-body { flex: 1; min-height: 0; overflow: auto; padding: var(--sp-2); }
.ws-pane .pane-body.flush { padding: 0; }

/* ws2 left pane (tree / queue) — header + body matched to the live workspace markup */
.ws2-left .pane-head { display: flex; align-items: center; gap: 7px; padding: var(--sp-2) var(--sp-3); height: var(--tabbar-h); border-bottom: 1px solid var(--border-1); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-1); flex-shrink: 0; }
.ws2-left .pane-head svg { color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.ws2-left .pane-head .badge { margin-left: auto; }
.ws2-left .pane-body { flex: 1; min-height: 0; overflow: auto; padding: var(--sp-2) var(--sp-3); }
.splitter { width: 5px; cursor: col-resize; background: transparent; }
.splitter:hover { background: var(--accent-soft); }

/* PDF / image viewer */
.viewer { flex: 1; min-height: 0; background: var(--bg-surface-3); display: flex; align-items: safe center; justify-content: safe center; overflow: auto; }
.viewer img, .viewer object, .viewer iframe { max-width: 100%; max-height: 100%; background: #fff; }
.viewer .placeholder { color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.viewer .placeholder svg { width: 34px; height: 34px; }
.viewer-toolbar { display: flex; align-items: center; gap: 4px; padding: 4px var(--sp-2); border-bottom: 1px solid var(--border-1); background: var(--bg-surface); }

/* Modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 1000; padding: var(--sp-4); }
.modal { background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: min(560px, 96vw); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.lg { width: min(880px, 96vw); }
.modal-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-1); }
.modal-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.modal-body { padding: var(--sp-4); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border-1); }

/* Command palette */
.cmdk-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; justify-content: center; padding-top: 12vh; z-index: 1100; }
.cmdk { width: min(620px, 92vw); height: max-content; max-height: 70vh; background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; display: flex; flex-direction: column; }
.cmdk-input { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-1); }
.cmdk-input svg { width: 18px; height: 18px; color: var(--text-3); }
.cmdk-input input { flex: 1; border: none; outline: none; background: transparent; font-size: var(--fs-lg); color: var(--text-1); }
.cmdk-list { overflow-y: auto; padding: var(--sp-1); }
.cmdk-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); cursor: pointer; color: var(--text-1); font-size: var(--fs-md); }
.cmdk-item .hint { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); }
.cmdk-item .cmdk-label { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.cmdk-item .cmdk-sub { font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-regular); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item.active .cmdk-sub, .cmdk-item:hover .cmdk-sub { color: var(--selected-fg); opacity: .8; }
.cmdk-item.active, .cmdk-item:hover { background: var(--bg-selected); color: var(--selected-fg); font-weight: var(--fw-bold); }
.cmdk-group { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: var(--sp-2) var(--sp-3) 4px; }

/* Toasts */
.toast-stack { position: fixed; right: var(--sp-4); bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); z-index: 1200; }
.toast { display: flex; align-items: center; gap: var(--sp-2); min-width: 240px; max-width: 420px; padding: var(--sp-2) var(--sp-3); background: var(--bg-inverse); color: var(--text-inverse); border-radius: var(--r-md); font-size: var(--fs-sm); box-shadow: var(--shadow-pop); animation: toast-in var(--t-med); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.ok svg { color: #6ee7a0; }
.toast.err svg { color: #f49090; }
.toast.warn svg { color: #f5b740; }
.toast-brand { display: inline-flex; }
.toast .toast-brand svg { color: var(--pmp-accent, #14b8a6); }   /* brand mark keeps the PMP accent regardless of toast type */
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Skeleton / loading */
.skeleton { background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-3) 37%, var(--bg-surface-2) 63%); background-size: 400% 100%; animation: sk 1.2s ease-in-out infinite; border-radius: var(--r-sm); }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress { height: 6px; background: var(--bg-surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width var(--t-med); }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-8); color: var(--text-3); text-align: center; }
.empty svg { width: 30px; height: 30px; }

/* Error surface */
.app-error { padding: var(--sp-6); max-width: 720px; margin: 0 auto; }
.app-error pre { background: var(--bg-surface-2); padding: var(--sp-3); border-radius: var(--r-md); overflow: auto; font-size: var(--fs-xs); color: var(--text-2); }

/* Configurable insight widgets */
.widget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.widget { background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--r-lg); padding: var(--sp-4); min-height: 96px; display: flex; flex-direction: column; box-shadow: var(--shadow-card); transition: box-shadow var(--t-fast); }
.widget:hover { box-shadow: var(--shadow-card-hover); }
.widget.w-2 { grid-column: span 2; }
.widget-head { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.widget-head > span { display: flex; align-items: center; gap: 6px; }
.widget-head .icon-btn { margin-left: auto; width: 24px; height: 24px; }
.widget-body { margin-top: 6px; flex: 1; min-height: 0; overflow: hidden; }
.widget .wv { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.widget-head > span { font-weight: var(--fw-medium); color: var(--text-1); }
.widget .wv.ok { color: var(--ok-text); } .widget .wv.warn { color: var(--warn-text); } .widget .wv.err { color: var(--err-text); }
.widget .we { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); margin-top: 2px; }
.wbar { display: flex; flex-direction: column; gap: 6px; }
.wbar-row { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); }
.wbar-k { width: 84px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wbar-t { flex: 1; height: 8px; background: var(--bg-surface-3); border-radius: var(--r-pill); overflow: hidden; }
.wbar-t > span { display: block; height: 100%; border-radius: var(--r-pill); }
.wbar-n { width: 36px; text-align: right; color: var(--text-1); }
.wdonut { display: flex; align-items: center; gap: var(--sp-4); }
.wdonut-ring { width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0; }
.wdonut-ring::after { content: ''; }
.wdonut-leg { font-size: var(--fs-xs); color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.wdonut-leg .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.widget.w-add { border-style: dashed; align-items: center; justify-content: center; cursor: pointer; color: var(--text-3); }
.widget.w-add:hover { color: var(--text-accent); border-color: var(--accent); }
.widget.w-add > div { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wgauge { display: flex; align-items: center; gap: var(--sp-3); }
.wgauge-v { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.wgauge-v.ok { color: var(--ok-text); } .wgauge-v.warn { color: var(--warn-text); } .wgauge-v.err { color: var(--err-text); }
.wfeed { display: flex; flex-direction: column; gap: 8px; }
.wfeed-row { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); }
.wfeed-ic { color: var(--accent); flex-shrink: 0; }
.wfeed-ic svg { width: 16px; height: 16px; }
.wfeed-t { color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfeed-s { font-size: var(--fs-xs); color: var(--text-3); }
.wrec { display: flex; flex-direction: column; }
.wrec-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border-1); font-size: var(--fs-sm); }
.wrec-row:last-child { border-bottom: 0; }
.wrec-k { color: var(--text-2); } .wrec-v { color: var(--text-1); text-align: right; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wlist { display: flex; flex-direction: column; }
.wlist-row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border-1); font-size: var(--fs-sm); }
.wlist-row:last-child { border-bottom: 0; }
.wlist-s { color: var(--text-3); font-size: var(--fs-xs); }
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.wgrid-cell { background: var(--bg-surface-2); border-radius: var(--r-md); padding: 8px; text-align: center; }
.wgrid-n { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.wgrid-k { font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-2); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---- Print: management reports print clean (only the report sheet) ---- */
@media print {
  .rail, .topbar, .tabbar, .no-print, .toast-host, .nav-badge { display: none !important; }
  .report-scroll { overflow: visible !important; height: auto !important; }
  .report-sheet { box-shadow: none !important; border: none !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
  .report-sheet .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body, .content, .module-root, .main-col, .report-scroll { background: #fff !important; overflow: visible !important; }
  .report-sheet .data th, .report-sheet .data td { color: #000 !important; }
}

/* ============================================================ */
/* Mobile responsive (phones ≤ 640px) — rail becomes a drawer,  */
/* topbar compacts, cards/tables reflow.                        */
/* ============================================================ */
.mobile-only { display: none; }
.rail-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
@media (max-width: 640px) {
  .mobile-only { display: inline-flex; }
  /* Rail → off-canvas drawer (full labels regardless of collapse pref) */
  .app-shell, .app-shell.rail-collapsed { grid-template-columns: 1fr; }
  .rail { position: fixed; top: 0; left: 0; bottom: 0; width: 270px; max-width: 84vw; z-index: 60;
          transform: translateX(-100%); transition: transform .22s ease; box-shadow: 2px 0 16px rgba(0,0,0,.3); }
  .app-shell.rail-open .rail { transform: translateX(0); }
  .app-shell.rail-collapsed .rail .label,
  .app-shell.rail-collapsed .rail .rail-brand .brand-text,
  .app-shell.rail-collapsed .rail .rail-group-label { display: block; }
  .app-shell.rail-collapsed .rail .nav-item { justify-content: flex-start; }
  .rail-foot [data-toggle-rail] { display: none; }

  /* Topbar: compact — icon-only search, no project caption, no slim KPIs */
  .topbar { padding: 0 var(--sp-2); gap: var(--sp-2); }
  .cmd-trigger { padding: 0; width: 38px; justify-content: center; }
  .cmd-trigger span:not(.kbd) { display: none; }
  .cmd-trigger .kbd { display: none; }
  .ctx-pill .ctx-cap { display: none; }
  .ctx-pill .ctx-meta { font-size: var(--fs-xs); }
  .tabbar-kpi { display: none; }
  .tabbar { padding: 0 var(--sp-2); }

  /* Content + cards reflow */
  .content { padding: var(--sp-3); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .page-head h1 { font-size: var(--fs-lg); }

  /* Tables scroll horizontally inside their wrapper instead of breaking layout */
  .table-wrap, .dt-fill { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data { min-width: 560px; }

  /* Toolbars wrap instead of overflowing */
  .toolbar { flex-wrap: wrap; row-gap: 8px; }

  /* Progress record: stop the panes collapsing to zero — let them take real height and the page
     scroll to the end (desktop is a fixed-height 3-pane workspace; mobile must flow vertically). */
  [data-rec-body] { flex: 0 0 auto !important; min-height: auto !important; display: block !important; }
  [data-rec-isos] { max-height: 46vh; margin-bottom: 10px; }
  [data-rec-joints] { overflow: visible !important; }
  /* one full-width metric card per row so % / target text isn't cramped or cut */
  .rec-metrics-grid { grid-template-columns: 1fr !important; }
  .rec-metrics-grid [style*="grid-column:span 2"], .rec-metrics-grid [style*="grid-column: span 2"] { grid-column: span 1 !important; }

  /* Generic guard: any full-height workspace becomes scrollable flow on phones */
  .ws2 { height: auto !important; }
  .ws2-main { grid-template-columns: 1fr !important; }
  .ws2-viewer { max-height: 60vh !important; }
}
@media (max-width: 430px) {
  .stat-grid { grid-template-columns: 1fr; }
}
