/* ── Precision White Studio — vessel-3d-schematic palette ──
   Converted from oklch to hex:
   primary        oklch(0.45 0.18 255) → #2B5BD7  steel blue
   primary-light  oklch(0.93 0.02 255) → #E8EEFA  accent bg
   primary-hover  blue-50              → #EFF6FF
   primary-active blue-100             → #DBEAFE
   primary-text   blue-700             → #1D4ED8
   foreground     oklch(0.2 0.01 250)  → #1E2535  dark navy text
   muted          oklch(0.55 0.01 250) → #6B7389  muted text
   border         oklch(0.9 0.005 250) → #E2E6EF
   background     #FFFFFF
   surface        oklch(0.96 0.005 250)→ #F1F3F8
   ─────────────────────────────────────────────────── */

@import "theme/tokens.css";  /* T4D theme tokens (--t4d-*) — authoritative: shared/theme/tokens.css, fanned out by `node sync-theme.mjs` */

:root {
    /* ── The T4D theme tokens (--t4d-accent, --t4d-header-bg, --t4d-font, …)
       now come from theme/tokens.css via the @import above — the single
       source of truth shared with the web apps. To restyle, edit
       shared/theme/tokens.css and run `node sync-theme.mjs`. The variables
       below are T4D-only (ribbon / tree / Babylon) and are NOT shared. ── */

    /* ── Legacy palette (ribbon / tree — pre-theme, kept as-is) ── */
    --primary:        #2B5BD7;
    --primary-hover:  #EFF6FF;
    --primary-active: #DBEAFE;
    --primary-text:   #1D4ED8;
    --foreground:     #1E2535;
    --muted:          #6B7389;
    --border:         #E2E6EF;
    --background:     #FFFFFF;
    --surface:        #F1F3F8;
    --card:           #FAFBFD;

    /* Panel backgrounds (dark sidebar/panel areas) */
    --bg-base:    #1C2535;
    --bg-panel:   #222E3A;
    --bg-surface: #2A3848;
    --bg-input:   #304052;
    --border-dark:#3A5068;

    /* Keep for Babylon.js references */
    --blue:       #81A6C6;
    --blue-light: #AACDDC;
    --tan:        #D2C4B4;
    --cream:      #F3E3D0;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app {
    height: 100%;
    width:  100%;
    overflow: hidden;
    font-family: var(--t4d-font);
    font-size: 8pt;
    background: var(--background);
    color: var(--foreground);
}

/* ── App Shell ─────────────────────────────────────────── */
.app-shell {
    display: grid;
    /* Ribbon row is content-sized (auto) so it can grow to a 2nd row when the
       ribbon wraps on narrow / high-DPI screens; min-height kept on .ribbon. */
    grid-template-rows: auto 1fr auto;
    height: 100%;
    min-height: 0;
}

/* ── Bottom status bar (selected element model data) ───────────────────── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 26px;
    padding: 0 12px;
    background: var(--t4d-accent, #0277BD);
    color: #fff;
    font-family: var(--t4d-font);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    border-top: 1px solid rgba(0,0,0,0.15);
}
.status-bar .sb-item { display: inline-flex; align-items: baseline; gap: 5px; }
.status-bar .sb-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: .3px; opacity: .8; }
.status-bar .sb-sep { opacity: .45; }
.status-bar .sb-muted { opacity: .7; }
.status-bar .sb-hint { opacity: .75; font-style: italic; margin-left: 4px; }
/* t(min) turns bright red when the specified shell thickness fails the Check. */
.status-bar .sb-fail { color: #ff5252; font-weight: 700; }

/* ── Report window (full-screen) ───────────────────────────────────────── */
.report-window {
    position: fixed; inset: 0; z-index: 1500;
    display: flex; flex-direction: column;
    background: var(--t4d-panel-bg, #fff);
    font-family: var(--t4d-font);
}

/* ── Help window — same shape as the report window (full-screen overlay,
   TOC sidebar on the left, article on the right). Topic content is plain
   HTML; we just style headings, lists, code, and the active TOC button. */
.help-window {
    position: fixed; inset: 0; z-index: 1500;
    display: flex; flex-direction: column;
    background: var(--t4d-panel-bg, #fff);
    font-family: var(--t4d-font);
}
.help-titlebar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px;
    background: var(--t4d-accent, #5F7282); color: #FFF;
    border-bottom: 1px solid rgba(0,0,0,0.18);
}
.help-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; letter-spacing: 0.02em; }
.help-titlebar-icon { width: 16px; height: 16px; filter: brightness(0) invert(1); }
.help-close {
    background: transparent; color: #FFF; border: 1px solid rgba(255,255,255,0.55);
    border-radius: 3px; padding: 3px 10px; cursor: pointer; font-size: 12px;
}
.help-close:hover { background: rgba(255,255,255,0.15); }

.help-body { flex: 1; display: flex; min-height: 0; }
.help-toc {
    width: 240px; flex-shrink: 0;
    background: #F5F7FA; border-right: 1px solid #D8DEE6;
    overflow-y: auto; padding: 6px 0;
}
.help-toc-head {
    padding: 8px 14px 6px; font-size: 11px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase; color: #5F7282;
}
.help-toc-item {
    display: block; width: 100%; text-align: left;
    background: transparent; border: 0; cursor: pointer;
    padding: 7px 14px; font-size: 13px; color: #2A3340;
    border-left: 3px solid transparent;
}
.help-toc-item:hover { background: #E8EDF3; }
.help-toc-item.active {
    background: #E3EAF1; border-left-color: var(--t4d-accent, #5F7282);
    font-weight: 600;
}

.help-content {
    flex: 1; overflow-y: auto; padding: 22px 36px 60px;
    font-size: 13.5px; line-height: 1.55; color: #1f2530;
    max-width: 900px;
}
.help-h1 {
    font-size: 22px; font-weight: 700; margin: 0 0 14px;
    color: var(--t4d-accent-dark, #3F525E);
    border-bottom: 2px solid var(--t4d-accent, #5F7282); padding-bottom: 6px;
}
.help-content p { margin: 8px 0 10px; }
.help-content ul, .help-content ol { margin: 6px 0 12px; padding-left: 26px; }
.help-content li { margin: 3px 0; }
.help-content code {
    background: #EEF1F5; padding: 1px 5px; border-radius: 3px;
    font-family: Consolas, "Courier New", monospace; font-size: 12.5px;
    color: #1A4FBF;
}
.help-content strong { color: #2A3340; }
.help-content em { color: #5F7282; }
/* Heads help: figure + K-factor table. */
.help-fig-cap { margin: 18px 0 6px; font-size: 13px; }
.help-figure {
    width: 420px; max-width: 100%; height: auto;
    background: #FBFCFD; border: 1px solid #DDE3EB; border-radius: 6px;
    padding: 8px; display: block;
}
.help-ktable {
    border-collapse: collapse; margin: 4px 0 8px; font-size: 12px;
}
.help-ktable th, .help-ktable td {
    border: 1px solid #C7CFDA; padding: 3px 8px; text-align: center;
    font-family: Consolas, "Courier New", monospace;
}
.help-ktable th {
    background: var(--t4d-accent, #5F7282); color: #fff; font-weight: 600;
}
.help-ktable td { background: #fff; color: #1A2535; }
.help-note { font-size: 12.5px; color: #5F7282; font-style: italic; }
.report-titlebar {
    display: flex; align-items: center; justify-content: space-between;
    height: 40px; padding: 0 12px; flex-shrink: 0;
    background: var(--t4d-accent, #0277BD); color: #fff;
}
.report-title { font-size: 13px; font-weight: 600; }
.report-tb-actions { display: flex; align-items: center; gap: 8px; }
.report-close {
    background: rgba(255,255,255,0.18); color: #fff; border: 0;
    padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.report-close:hover { background: rgba(255,255,255,0.32); }
.report-body { flex: 1; display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
.report-list {
    border-right: 1px solid var(--t4d-border); overflow-y: auto;
    background: var(--t4d-header-bg, #f5f7fa);
}
.report-list-head {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
    padding: 8px 12px; color: var(--t4d-text-secondary); border-bottom: 1px solid var(--t4d-border);
}
.report-list-sub {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    padding: 10px 12px 4px; color: var(--t4d-text-secondary); margin-top: 4px;
    border-top: 1px solid var(--t4d-border);
}
.report-list-item {
    padding: 6px 14px; font-size: 12px; cursor: pointer; color: var(--t4d-text-primary);
    border-left: 3px solid transparent;
}
.report-list-item:hover { background: var(--t4d-accent-light, #e3f0fa); }
.report-list-item.active {
    background: var(--t4d-panel-bg, #fff); border-left-color: var(--t4d-accent);
    font-weight: 600; color: var(--t4d-accent);
}
.report-list-el { padding-left: 22px; }
.report-content { overflow-y: auto; padding: 24px 32px; font-size: 12px; color: var(--t4d-text-primary); }
.rpt-cover h1 { font-size: 20px; margin: 0 0 4px; }
.rpt-cover h2 { font-size: 15px; margin: 24px 0 8px; letter-spacing: .5px; }
.rpt-draw { color: var(--t4d-text-secondary); margin: 2px 0 0; }
.rpt-em { font-style: italic; color: var(--t4d-text-secondary); }
.rpt-soft { margin-top: 24px; font-weight: 700; }
.rpt-h { font-size: 15px; margin: 0 0 10px; border-bottom: 2px solid var(--t4d-accent); padding-bottom: 4px; color: var(--t4d-accent); }
.rpt-h4 { font-size: 13px; margin: 16px 0 6px; }
.rpt-subhead { font-size: 12px; font-weight: 600; margin: 12px 0 4px; color: var(--t4d-accent-dark, #3a4a57); }
.ring-dialog-card { width: 780px; max-width: 95vw; }
.ring-result-line { border-top: 1px solid var(--t4d-border, #ddd); margin-top: 6px; padding-top: 8px; font-size: 12px; }
.ring-actions { gap: 6px; flex-wrap: wrap; }
.cs-pick-btn { margin-left: 4px; padding: 2px 9px; cursor: pointer; border: 1px solid var(--t4d-border, #bbb); border-radius: 3px; background: #f3f5f7; }
.tree-ring-child .tree-el-label { font-size: 12px; }
.rpt-kv { border-collapse: collapse; margin: 8px 0; }
.rpt-kv td { padding: 3px 16px 3px 0; vertical-align: top; }
.rpt-kv td:first-child { color: var(--t4d-text-secondary); white-space: nowrap; }
.rpt-ok { color: #2E7D32; font-weight: 600; }
.rpt-warn { margin: 8px 0; padding-left: 18px; }
.rpt-warn li { margin: 4px 0; color: #C62828; }
.rpt-warn-inline { color: #C62828; font-style: italic; }
.report-content .calc-results-table { width: 100%; max-width: 780px; }
/* Keep the Adequacy / Margin "derived" lines aligned to the table's right edge
   instead of stretching all the way across the report content. */
.report-content .cs-derived-row { max-width: 780px; }

/* Report-list: Select all / Clear quick links */
.report-list-tools {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-bottom: 1px solid var(--t4d-border);
}
.report-sel-link {
    background: none; border: 0; padding: 0; cursor: pointer;
    font-size: 11px; color: var(--t4d-accent); font-weight: 600;
}
.report-sel-link:hover { text-decoration: underline; }
.report-sel-sep { color: var(--t4d-text-secondary); font-size: 11px; }

/* Report-list: checkbox rows (multi-select for print) */
.report-check { display: flex; align-items: center; gap: 8px; user-select: none; }
.report-check input[type="checkbox"] { flex-shrink: 0; cursor: pointer; margin: 0; }
.report-check.active { font-weight: 600; color: var(--t4d-accent); border-left-color: var(--t4d-accent); }
.report-list-el.report-check { padding-left: 22px; }

/* Report list — element entry turns red when its Check or Test case fails. */
.report-list-fail { background: #fef2f2; }
.report-list-fail span { color: #C62828; font-weight: 600; }
.report-list-fail.active span { color: #b71c1c; }
.report-list-fail.active { background: #ffebee; border-left-color: #C62828; }

/* Print button (icon + label) in the report titlebar */
.report-print-btn { display: inline-flex; align-items: center; gap: 6px; }
.report-btn-icon { width: 16px; height: 16px; }

/* Element-tab export buttons (PDF / Word) */
.cs-export-row { display: flex; gap: 8px; padding: 10px 0 2px; }

/* Stacked report sections in the preview/print area */
.rpt-section + .rpt-section {
    margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--t4d-border);
}
.rpt-empty-sel { padding: 20px 4px; }

/* Export mode (WebView2 PrintToPdf): hide report chrome so only the
   selected sections render into the PDF. Applies in all media. */
body.exporting .report-titlebar,
body.exporting .report-list { display: none !important; }
body.exporting .report-body { display: block !important; }
body.exporting .report-content { overflow: visible !important; height: auto !important; }

/* Element export: isolate the element's calc results (#element-calc-print)
   so a WebView2 PrintToPdf render captures only that, not the whole modal/app. */
body.exporting-el * { visibility: hidden !important; }
body.exporting-el #element-calc-print,
body.exporting-el #element-calc-print * { visibility: visible !important; }
body.exporting-el #element-calc-print {
    position: fixed; left: 0; top: 0; width: 100%;
    background: #fff; padding: 16px; overflow: visible !important; z-index: 99999;
}

/* ── Print: show ONLY the selected report sections (#report-print-root) ── */
/* Header + footer repeat on every page via the <table><thead>/<tfoot>
   pattern in ReportWindow.razor — both Chromium PrintToPdfAsync and
   Microsoft Word treat thead/tfoot rows as repeating page groups when the
   tbody content paginates. counter(page) / counter(pages) inside the
   thead's .page-num / .page-total ::after slots are substituted by the
   print engine on each page. */
@media print {
    body * { visibility: hidden !important; }
    #report-print-root, #report-print-root * { visibility: visible !important; }
    #report-print-root {
        position: absolute; left: 0; top: 0; width: 100%;
        padding: 0; margin: 0; overflow: visible !important;
        background: #fff; color: #000;
    }
    .report-window { position: static !important; }
    .report-body { display: block !important; }
    .report-content { overflow: visible !important; }
    .report-titlebar, .report-list { display: none !important; }
    .rpt-section { break-inside: avoid; page-break-inside: avoid; border-top: 0; margin-top: 0; padding-top: 0; }

    /* The wrapping table fills the printable area. thead/tfoot are repeating
       page groups; each section lives in its OWN <tr class="rpt-page-row">
       so page-break-before lands cleanly between rows (both Chromium and
       Word break between table rows; they DON'T break inside a single td). */
    .rpt-page-wrap { width: 100%; border-collapse: collapse; }
    .rpt-page-head { display: table-header-group; }
    .rpt-page-foot { display: table-footer-group; }
    .rpt-page-wrap td, .rpt-page-wrap th { border: 0; padding: 0; }
    .rpt-page-row { page-break-before: always; break-before: page; }
    .rpt-page-row:first-child { page-break-before: auto; break-before: auto; }

    /* Page numbers (Chromium substitutes these in print context). */
    .page-num::after   { content: counter(page); }
    .page-total::after { content: counter(pages); }

    @page { margin: 14mm; }
}

/* ── Running header (3-col: project | logo | tag/licensee/page) ──────── */
.rpt-running-header {
    width: 100%;
    border-bottom: 1px solid #888;
    padding-bottom: 4px;
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    font-size: 10px;
    color: #222;
}
.rpt-hdr-tbl { width: 100%; border-collapse: collapse; }
.rpt-hdr-tbl td {
    vertical-align: middle;
    padding: 2px 4px;
    border: 0;
}
.rpt-hdr-left  { width: 35%; text-align: left;   }
.rpt-hdr-mid   { width: 30%; text-align: center; }
.rpt-hdr-right { width: 35%; text-align: right;  }
.rpt-hdr-strong { font-weight: 700; font-size: 11px; }
.rpt-hdr-soft   { color: #555; font-size: 9px; }
.rpt-hdr-page   { font-family: 'Cascadia Mono', Consolas, monospace; font-size: 9px; }
.rpt-hdr-logo {
    display: inline-block;
    padding: 2px 12px;
    background: #5F7282;
    color: #FFFFFF;
    font-weight: 700;
    font-family: 'Cascadia Mono', Consolas, monospace;
    letter-spacing: 0.18em;
    border-radius: 2px;
}

/* ── Running footer ──────────────────────────────────────────────────── */
.rpt-running-footer {
    width: 100%;
    text-align: center;
    border-top: 1px solid #888;
    padding-top: 4px;
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    font-size: 9px;
    color: #555;
    font-style: italic;
}

/* Hide running elements on screen — they only belong in the print output. */
@media screen {
    /* Hide the repeating header/footer rows on screen — only print needs them. */
    .rpt-page-head, .rpt-page-foot { display: none !important; }
    .rpt-running-header, .rpt-running-footer { display: none; }
}

/* ── Cover page (redesigned) ─────────────────────────────────────────── */
.rpt-cover-section { padding-top: 30mm; }
.rpt-cover-title {
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.10em;
    color: #1A2535;
    text-align: center;
    margin: 0 0 28px;
}
.rpt-cover-3d {
    text-align: center;
    margin: 0 auto 32px;
}
.rpt-cover-3d img {
    width: 70%;
    max-width: 480px;
    max-height: 240px;
    object-fit: contain;
    display: inline-block;
    border: 1px solid #C8D0DA;
}
.rpt-cover-tbl {
    margin: 0 auto;
    border-collapse: collapse;
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    font-size: 13px;
    min-width: 360px;
}
.rpt-cover-tbl td {
    padding: 6px 14px;
    border: 1px solid #BCC4D0;
}
.rpt-cover-tbl td:first-child {
    color: #5F7282;
    font-weight: 600;
    background: #F5F7FA;
    width: 40%;
}
.rpt-cover-meta {
    text-align: center;
    margin-top: 22px;
    font-size: 11px;
}

/* ── Table of Contents ───────────────────────────────────────────────── */
.rpt-toc-section { padding-top: 12mm; }
.rpt-toc-tbl {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    font-size: 12px;
}
.rpt-toc-tbl td {
    padding: 4px 0;
    vertical-align: bottom;
    /* Override the global .rpt td border so the label cell isn't underlined. */
    border: 0;
}
.rpt-toc-label  {
    color: #1A2535;
    white-space: nowrap;          /* don't wrap "Vessel Design Summary" */
    width: 1%;                    /* collapse to content; dots cell takes rest */
    padding-right: 8px;
}
.rpt-toc-label a { color: inherit; text-decoration: none; }
.rpt-toc-dots {
    width: auto;                  /* fill the remaining row width */
    border-bottom: 1px dotted #888;
    height: 1em;
}
.rpt-toc-page {
    text-align: right;
    color: #5F7282;
    font-family: 'Cascadia Mono', Consolas, monospace;
    width: 1%;                    /* collapse to content (currently empty) */
    white-space: nowrap;
    padding-left: 8px;
}
/* TOC right-column is left blank — Chromium's HTML→PDF doesn't reliably
   resolve target-counter() across pages, so page-numbers in the TOC are a
   follow-up. The PDF bookmarks (from heading hierarchy) cover most of the
   navigation need anyway. */

/* ── Pressure Test Results comparison table ──────────────────────────── */
.rpt-test-results {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0 8px;
    font-family: 'Cascadia Mono', Consolas, monospace;
    font-size: 11px;
}
.rpt-test-results td {
    padding: 4px 8px;
    border-bottom: 1px solid #E5E5E5;
}
.rpt-test-results td:first-child { width: 22%; font-weight: 700; color: #1A2535; }
.rpt-test-results .rpt-eq   { color: #555; }
.rpt-test-results .rpt-pval { text-align: right; font-weight: 700; color: #1A4FBF; width: 20%; }

/* ── Cylindrical-shell dimension drawing + values table ──────────────── */
.rpt-cyl-dim {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 8px 0 12px;
}
.rpt-cyl-dim-img {
    max-width: 360px;
    max-height: 200px;
    object-fit: contain;
}
/* Ellipsoidal-head schematic — 70% of the cylinder image width
   (0.70 × 360 = 252 px); height scales to keep the aspect ratio. */
.rpt-head-dim-img {
    width: 252px;
    height: auto;
    object-fit: contain;
}
.rpt-cyl-dim-tbl {
    border-collapse: collapse;
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    font-size: 12px;
}
.rpt-cyl-dim-tbl td {
    padding: 4px 12px;
    border-bottom: 1px solid #E5E5E5;
}
.rpt-cyl-dim-tbl td:first-child { color: #5F7282; }
.rpt-cyl-dim-tbl td:last-child  { font-weight: 700; color: #1A2535; }

/* ── Ribbon ────────────────────────────────────────────── */
.ribbon {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;            /* groups wrap to a 2nd row instead of h-scrolling */
    align-items: stretch;
    align-content: flex-start;  /* pack wrapped rows from the top */
    row-gap: 2px;
    width: 100%;
    height: auto;
    min-height: 10vh;           /* one-row baseline (matches the old fixed 10vh) */
    background: var(--background);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: visible;          /* no horizontal scrollbar — content wraps instead */
    flex-shrink: 0;
    padding: 0 6px;
    gap: 0;
}

/* Ribbon is suppressed while a modal dialog is open — visually dimmed and
   pointer-events: none so the user can't click File / Edit / View buttons
   while a dialog has focus. Driven by .ribbon-disabled toggled in razor. */
.ribbon-disabled {
    pointer-events: none;
    opacity: 0.45;
    filter: grayscale(0.25);
    user-select: none;
}

/* Ribbon group container */
.ribbon-group {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 6px 0 6px;
    min-width: fit-content;
}

/* Row of buttons inside a group */
.ribbon-buttons {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
}

/* Group label at bottom */
.ribbon-group-label {
    text-align: center;
    font-size: 10px;
    color: var(--tan);
    letter-spacing: 0.5px;
    padding: 2px 0 3px 0;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

/* Vertical separator between groups */
.ribbon-separator {
    width: 1px;
    background: var(--border);
    margin: 6px 4px;
    flex-shrink: 0;
}

/* Spacer is disabled now the ribbon wraps — a growing spacer (flex:1) forces
   odd multi-row wrapping. Groups flow left→right and wrap as needed. */
.ribbon-spacer {
    display: none;
}

/* Individual ribbon button — Precision White Studio */
.ribbon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--muted);
    font-family: var(--t4d-font);
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    min-width: 46px;
    height: 100%;
}

.ribbon-btn:hover {
    background: var(--primary-hover);
    color: var(--primary-text);
    border-color: transparent;
}

.ribbon-btn:active {
    background: var(--primary-active);
    color: var(--primary-text);
}

.ribbon-btn.active {
    background: var(--primary-active);
    color: var(--primary-text);
}

/* Disabled ribbon button — dim icon + label and block interaction so the
   user can see at a glance that the action is unavailable. */
.ribbon-btn:disabled {
    opacity: 0.38;
    cursor: default;
    pointer-events: none;
}
.ribbon-btn:disabled .ribbon-icon { color: var(--muted); }

/* Icon inside ribbon button — SVG or IMG */
.ribbon-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: var(--foreground);
    transition: color 0.15s;
}

.ribbon-btn:hover  .ribbon-icon { color: var(--primary-text); }
.ribbon-btn:active .ribbon-icon { color: var(--primary-text); }
.ribbon-btn.active .ribbon-icon { color: var(--primary-text); }

/* Label below icon */
.ribbon-label {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    color: inherit;
    white-space: nowrap;
}

/* Group label */
.ribbon-group-label {
    text-align: center;
    font-size: 10px;
    font-weight: 400;
    color: var(--muted);
    letter-spacing: 0.4px;
    padding: 2px 4px 3px 4px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

/* Vertical separator between groups */
.ribbon-separator {
    width: 1px;
    background: var(--border);
    margin: 6px 4px;
    flex-shrink: 0;
}

/* ── Main content (3 columns: panel | handle | viewport) ── */
.workspace {
    display: grid;
    grid-template-columns: var(--left-w, 200px) 6px 1fr;
    overflow: hidden;
}

/* ── Resize handle (vertical drag strip between panels) ─────────────────── */
.resize-handle-v {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    z-index: 2;
}
.resize-handle-v:hover,
.resize-handle-v:active {
    background: var(--primary);
}

/* ── Left panel — element tree ─────────────────────────── */
.panel-left {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--card);
    font-family: var(--t4d-font);
}

.element-tree {
    flex: 1;
    overflow-y: auto;
    padding: 6px 4px;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    margin: 1px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    border: 1px solid transparent;
}

.tree-item:hover {
    background: var(--primary-hover);
    color: var(--primary-text);
}

.tree-item.active {
    background: var(--primary-active);
    color: var(--primary-text);
    font-weight: 600;
}

.tree-item .icon { font-size: 13px; flex-shrink: 0; opacity: 0.85; }

/* ── Assembly tree ─────────────────────────────────────── */
.tree-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 2px;
    font-family: var(--t4d-font);
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 11px;
    color: #475569;
    user-select: none;
    transition: background 0.1s;
}

.tree-node:hover   { background: #f1f5f9; }
.tree-node.tree-child { padding-left: 10px; }
.tree-node.selected { background: #DBEAFE; color: #1e40af; }

.tree-chevron {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.tree-chevron.open { transform: rotate(90deg); }
.tree-chevron.invisible { visibility: hidden; }

.tree-icon { flex-shrink: 0; }

.tree-assembly-label {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.tree-name-text {
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: text;
}

.tree-name-input {
    flex: 1;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--t4d-font);
    color: #1e293b;
    background: #fff;
    border: 1px solid #3B82F6;
    border-radius: 3px;
    padding: 0 4px;
    height: 20px;
    outline: none;
    width: 100%;
}

.tree-count {
    font-size: 9px;
    color: #94a3b8;
    flex-shrink: 0;
}

.tree-el-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.tree-delete-btn {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #cbd5e1;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    transition: color .15s, background .15s, opacity .15s;
    opacity: 0;
}
.tree-node:hover .tree-delete-btn { opacity: 1; }
.tree-delete-btn:hover {
    color: #dc2626;
    background: transparent;
}

/* ── Add-shell dialog ───────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-card {
    background: var(--t4d-panel-bg);
    border: 1px solid var(--t4d-border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(33, 33, 33, 0.18);
    padding: 18px 20px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: var(--t4d-font);
}
.modal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--t4d-text-primary);
    margin-bottom: 4px;
}
.modal-label {
    font-size: 11px;
    color: var(--t4d-text-secondary);
    margin-top: 6px;
}
.modal-select {
    font-family: var(--t4d-font);
    font-size: 11px;
    padding: 4px 8px;
    border: 1px solid var(--t4d-border);
    border-radius: 3px;
    background: var(--t4d-input-bg);
    color: var(--t4d-text-primary);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}
.modal-btn {
    font-size: 11px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 3px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.modal-btn-secondary {
    background: var(--t4d-panel-bg);
    color: var(--t4d-accent);
    border-color: var(--t4d-accent);
}
.modal-btn-secondary:hover { background: var(--t4d-accent-light); }
.modal-btn-primary {
    background: var(--t4d-accent);
    color: #FFFFFF;
}
.modal-btn-primary:hover { background: var(--t4d-accent-dark); }
.modal-btn-primary:disabled,
.modal-btn-secondary:disabled {
    background: var(--t4d-text-disabled);
    color: #FFFFFF;
    border-color: var(--t4d-text-disabled);
    cursor: not-allowed;
}

.modal-card-wide { min-width: 380px; }

/* Run-Analysis progress overlay — gradient fill + moving stripes. */
.progress-backdrop { background: rgba(15, 23, 42, 0.45); }
.progress-card { min-width: 380px; max-width: 460px; }
.progress-title {
    font-size: 14px; font-weight: 600; color: var(--t4d-text-primary);
}
.progress-msg {
    font-size: 12px; color: var(--t4d-text-secondary);
    min-height: 1.2em; margin-top: 2px;
}
.progress-bar-track {
    margin-top: 10px;
    width: 100%; height: 14px;
    background: #eef2f7;
    border-radius: 7px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.10);
}
.progress-bar-fill {
    height: 100%;
    background:
        linear-gradient(45deg,
            rgba(255,255,255,0.20) 25%, transparent 25%,
            transparent 50%, rgba(255,255,255,0.20) 50%,
            rgba(255,255,255,0.20) 75%, transparent 75%, transparent),
        linear-gradient(90deg, var(--t4d-accent, #0277BD), #4FB3DD);
    background-size: 24px 24px, 100% 100%;
    border-radius: 7px;
    transition: width 220ms ease;
    animation: pvd-progress-stripes 900ms linear infinite;
}
@keyframes pvd-progress-stripes {
    from { background-position: 0 0,     0 0; }
    to   { background-position: 24px 0,  0 0; }
}
.progress-pct {
    font-size: 11px; font-weight: 600; color: var(--t4d-accent);
    text-align: right; margin-top: 4px;
}

/* Custom alert dialog — replaces the native browser alert ("0.0.0.1 says").
   Shows the exclamation icon beside the message instead of the origin text. */
.alert-card { min-width: 340px; max-width: 460px; }
.alert-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 4px 2px;
}
.alert-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
}
.alert-msg {
    font-size: 13px;
    line-height: 1.4;
    color: var(--t4d-text-primary);
    white-space: pre-line;
    align-self: center;
}

/* Static backdrop = no click-to-close + transparent so the user can interact
   with the app behind the floating, draggable form. */
.modal-backdrop-static {
    background: transparent;
    pointer-events: none;     /* let clicks pass through to the app underneath */
}
.modal-backdrop-static > .modal-card {
    pointer-events: auto;     /* but the card itself stays interactive */
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}

/* Draggable title bar (header strip on the floating form) */
.modal-title-draggable {
    cursor: move;
    user-select: none;
    padding: 8px 12px;
    margin: -18px -20px 8px -20px;   /* extend over the card's padding */
    background: var(--t4d-header-bg);
    color: var(--t4d-text-primary);
    border-bottom: 1px solid var(--t4d-border);
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    font-weight: 600;
    font-family: var(--t4d-font);
    font-size: 12px;
}

/* ── Cylindrical Shell user form (mirrors vessel-3d-schematic ElementPanel) ── */
.cyl-shell-form {
    width: 380px;
    max-height: 80vh;
    padding: 0;            /* body owns its padding so scroll fits cleanly */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.cyl-shell-form .modal-title-draggable {
    margin: 0;            /* title strip aligned to card edges */
    border-radius: 6px 6px 0 0;
}
.cs-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--t4d-font);
    background: var(--t4d-header-bg);
}
.cyl-shell-form .modal-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--t4d-border);
    margin: 0;
    background: var(--t4d-header-bg);
}

/* Header strip: node pill + description */
.cs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--t4d-border);
    margin-bottom: 4px;
}
.cs-node-pill {
    font-size: 9px;
    color: var(--t4d-accent);
    background: var(--t4d-accent-light);
    border: 1px solid var(--t4d-accent);
    border-radius: 3px;
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: var(--t4d-font);
    font-weight: 600;
}
.cs-desc-input {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--t4d-text-primary);
    border: 0;
    border-bottom: 1px dashed var(--t4d-border);
    background: transparent;
    outline: none;
    padding: 2px 0;
    font-family: var(--t4d-font);
}
.cs-desc-input:focus { border-bottom-color: var(--t4d-accent); }

/* ── GroupBox-style box around each logical group (mirrors WPF FormGroup) ─── */
.cs-group {
    border: 1px solid var(--t4d-border);
    border-radius: 3px;
    background: var(--t4d-panel-bg);
    margin: 0 0 10px 0;
    padding: 6px 12px 10px 12px;
    min-width: 0;       /* override fieldset's default min-content sizing  */
}
.cs-group:last-of-type { margin-bottom: 0; }

/* Section headers — coloured legend that sits in the top border of cs-group */
.cs-section {
    font-size: 11px;
    color: var(--t4d-accent);
    font-weight: 600;
    padding: 0 6px;
    margin: 0;
    font-family: var(--t4d-font);
}
/* When .cs-section is used as a <legend>, the special positioning is automatic.
   When it appears as a <div> outside a fieldset, fall back to underline style. */
div.cs-section {
    margin-top: 10px;
    margin-bottom: 4px;
    padding: 0 0 2px 0;
    border-bottom: 1px solid var(--t4d-border);
}
.cs-section-inline { margin-top: 0; border-bottom: 0; padding-bottom: 0; }

/* Long. Welds legend: section title + "+ Add" button laid out on one line */
legend.cs-section {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Field row: label + input + unit */
.cs-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

/* Joint-efficiency picker: <select> fills the row; when "User Defined" is
   picked, a small numeric input appears next to it so the user can type a
   custom value without losing the dropdown. */
.cs-je-combo {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.cs-je-select      { flex: 1; min-width: 0; }
.cs-je-user-input  { width: 70px; flex-shrink: 0; text-align: right; }
.cs-row > label {
    font-size: 10px;
    color: var(--t4d-text-secondary);
    width: 96px;
    flex-shrink: 0;
    line-height: 1;
    font-family: var(--t4d-font);
}
.cs-row > input,
.cs-row > select {
    flex: 1;
    min-width: 0;
    height: 24px;
    font-size: 11px;
    font-family: var(--t4d-font);
    border: 1px solid var(--t4d-border);
    border-radius: 3px;
    padding: 0 6px;
    background: var(--t4d-input-bg);
    color: var(--t4d-text-primary);
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}
.cs-row > input[type="number"] { text-align: right; }
.cs-row > select { background: var(--t4d-dropdown-bg); }   /* dropdown — light grey */
.cs-row > select.cs-unit-select { flex: 0 0 56px; width: 56px; }   /* narrow unit picker */
.cs-row > input:focus,
.cs-row > select:focus {
    border-color: var(--t4d-accent);
    box-shadow: 0 0 0 2px rgba(2, 119, 189, .22);
}
.cs-row > input[readonly] {
    background: var(--t4d-input-readonly-bg);
    color: var(--t4d-text-secondary);
    cursor: default;
    font-style: italic;
}
.cs-row > select:disabled {
    background: var(--t4d-input-disabled-bg);
    color: var(--t4d-text-disabled);
    cursor: default;
}
.cs-unit {
    font-size: 10px;
    color: var(--t4d-text-secondary);
    width: 22px;
    flex-shrink: 0;
    font-family: var(--t4d-font);
}

/* Toggle row (Nominal / Da / Di and Thickness / Schedule) */
.cs-toggle {
    display: flex;
    gap: 3px;
    margin-bottom: 4px;
}
.cs-toggle > button {
    flex: 1;
    padding: 5px 6px;
    font-size: 11px;
    font-family: var(--t4d-font);
    border: 1px solid var(--t4d-border);
    border-radius: 3px;
    background: var(--t4d-panel-bg);
    color: var(--t4d-text-secondary);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.cs-toggle > button:hover { border-color: var(--t4d-accent); color: var(--t4d-accent); }
.cs-toggle > button.active {
    background: var(--t4d-accent);
    border-color: var(--t4d-accent);
    color: #FFFFFF;
}

/* Cascade (indented sub-section, left blue marker) */
.cs-cascade {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-left: 8px;
    border-left: 2px solid var(--t4d-accent-light);
    margin: 2px 0 4px;
}

/* Derived (read-only summary) */
.cs-derived-box {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--t4d-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cs-derived-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--t4d-text-secondary);
    font-family: var(--t4d-font);
}
.cs-derived-row > span:last-child { color: var(--t4d-text-primary); font-weight: 600; }
.cs-warn {
    font-size: 10px;
    color: #C62828;
    font-family: var(--t4d-font);
    margin-top: 2px;
}

/* Checkbox row */
.cs-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 2px;
}
.cs-check > input { width: 13px; height: 13px; accent-color: var(--t4d-accent); }
.cs-check > span { font-size: 11px; color: var(--t4d-text-primary); font-family: var(--t4d-font); }

/* Section header (label + + Add button) */
.cs-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    border-bottom: 1px solid var(--t4d-border);
    padding-bottom: 2px;
    margin-bottom: 4px;
}
.cs-section-header .cs-section {
    border-bottom: 0;
    margin: 0;
    padding: 0;
}
.cs-add-btn {
    font-size: 10px;
    font-weight: 600;
    font-family: var(--t4d-font);
    color: var(--t4d-accent);
    border: 1px solid var(--t4d-accent);
    border-radius: 3px;
    padding: 2px 8px;
    background: var(--t4d-panel-bg);
    cursor: pointer;
    transition: background .12s;
}
.cs-add-btn:hover { background: var(--t4d-accent-light); }

.cs-note {
    font-size: 10px;
    color: var(--t4d-text-secondary);
    font-style: italic;
    font-family: var(--t4d-font);
}

/* Long. welds grid */
.cs-weld-head {
    display: grid;
    grid-template-columns: 22px 56px 1fr 1fr 22px;
    gap: 3px;
    font-size: 9px;
    color: var(--t4d-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 2px;
    font-family: var(--t4d-font);
}
.cs-weld-row {
    display: grid;
    grid-template-columns: 22px 56px 1fr 1fr 22px;
    gap: 3px;
    align-items: center;
}
.cs-weld-num {
    font-size: 11px;
    color: var(--t4d-text-secondary);
    font-weight: 600;
    font-family: var(--t4d-font);
}
.cs-weld-row > input,
.cs-weld-row > select {
    height: 22px;
    font-size: 11px;
    font-family: var(--t4d-font);
    border: 1px solid var(--t4d-border);
    border-radius: 3px;
    padding: 0 4px;
    background: var(--t4d-input-bg);
    color: var(--t4d-text-primary);
    outline: none;
    min-width: 0;
}
.cs-weld-row > input[type="number"] { text-align: right; }
.cs-weld-row > select { background: var(--t4d-dropdown-bg); }   /* dropdown — light grey */
.cs-weld-row > input:focus,
.cs-weld-row > select:focus {
    border-color: var(--t4d-accent);
    box-shadow: 0 0 0 2px rgba(2, 119, 189, .22);
}
.cs-weld-del {
    width: 18px;
    height: 18px;
    background: transparent;
    border: 0;
    color: var(--t4d-text-disabled);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    border-radius: 3px;
    transition: color .12s, background .12s;
    padding: 0;
}
.cs-weld-del:hover { color: #C62828; background: #FFEBEE; }

/* ── Tab strip inside the Cylindrical Shell form ────────────────────── */
.cyl-shell-form { width: 760px; }     /* wider for Material Data layout */
.cs-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--t4d-border);
    background: var(--t4d-header-bg);
    padding: 0 8px;
    flex-shrink: 0;
}
.cs-tab {
    padding: 8px 16px;
    font-size: 12px;
    font-family: var(--t4d-font);
    font-weight: 500;
    background: var(--t4d-tab-unselected);   /* unselected tab */
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--t4d-text-secondary);
    cursor: pointer;
    transition: color .12s, border-color .12s, background .12s;
}
.cs-tab:hover { color: var(--t4d-accent); background: var(--t4d-accent-light); }
.cs-tab.active {
    color: var(--t4d-accent);
    border-bottom-color: var(--t4d-accent);
    background: var(--t4d-panel-bg);          /* selected tab — white */
    font-weight: 600;
}
.cs-tab:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    color: var(--t4d-text-secondary);
    background: var(--t4d-tab-unselected);
}
.cs-tab:disabled:hover { color: var(--t4d-text-secondary); background: var(--t4d-tab-unselected); }

.cs-header-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 6px 14px;
    border-bottom: 1px solid var(--t4d-border);
    background: var(--t4d-panel-bg);
    flex-shrink: 0;
    font-family: var(--t4d-font);
}

/* Material Data tab body fills the whole inner area */
.cs-body-material {
    padding: 8px;
    overflow: hidden;
    gap: 6px;
}

/* ── Design Data dialog ─────────────────────────────────────────────── */
.design-data-card {
    width: 640px;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.design-data-card .modal-title-draggable {
    margin: 0;
    border-radius: 6px 6px 0 0;
}
.design-data-body {
    flex: 1;
    padding: 12px 14px;
    overflow-y: auto;
    background: var(--t4d-header-bg);
    min-height: 260px;
    font-family: var(--t4d-font);
}
.design-data-card .modal-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--t4d-border);
    margin: 0;
    background: var(--t4d-header-bg);
}
/* Wider labels in Design Data form (longer field names than Shell form) */
.design-data-body .cs-row > label {
    width: 140px;
}

/* ── Material Data tab content ──────────────────────────────────────── */
.mat-tab {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-height: 0;
    font-family: var(--t4d-font);
}

/* ZONA 0 — DB label */
.mat-zone0 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}
.mat-z0-lbl     { color: #555; }
.mat-z0-edition { color: #0277bd; font-weight: 600; }
.mat-z0-err     { color: #dc2626; font-size: 10px; margin-left: 6px; }

/* ZONA 1 — search bar */
.mat-zone1 {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.mat-search {
    flex: 1;
    height: 28px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    background: #fafafa;
    outline: none;
}
.mat-search:focus { border-color: #0277bd; }
.mat-btn-clear {
    padding: 4px 10px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
}
.mat-btn-clear:hover { background: #eceff1; }

/* ZONA 2 + 3 — results list + details */
.mat-zone23 {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 8px;
    flex: 1;
    min-height: 0;
}
.mat-results {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.mat-result-count {
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
}
.mat-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #dddddd;
    background: #fff;
    min-height: 0;
}
.mat-list-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--t4d-font);
    font-size: 11px;
}
.mat-list-table thead th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    border-bottom: 1px solid #dddddd;
    text-align: left;
    padding: 4px 6px;
    font-weight: 600;
    font-size: 10px;
    color: #555;
    z-index: 1;
}
.mat-list-table tbody tr {
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.mat-list-table tbody td { padding: 3px 6px; }
.mat-list-table tbody tr:hover    { background: #f0f7ff; }
.mat-list-table tbody tr.selected { background: #d4eaf7; color: #01579b; }

.mat-btn-select {
    margin-top: 6px;
    padding: 7px 0;
    background: #0277bd;
    color: #fff;
    border: 0;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.mat-btn-select:hover                { background: #01579b; }
.mat-btn-select:disabled             { background: #bdbdbd; cursor: default; }

.mat-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

/* GroupBox-like container */
.mat-groupbox {
    border: 1px solid #cfd8dc;
    border-radius: 3px;
    padding: 4px 8px 8px 8px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.mat-gb-header {
    font-size: 11px;
    font-weight: 600;
    color: #1565c0;
    padding: 2px 0 4px 0;
}
.mat-groupbox-curve { flex: 1; min-height: 0; }

/* Material Properties grid: 4 columns (label/value/label/value) */
.mat-prop-grid {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 4px 8px;
    font-size: 11px;
}
.mat-lbl { color: #555; align-self: center; }
.mat-val {
    background: #f5f5f5;
    border: 0;
    padding: 3px 6px;
    color: var(--t4d-text-primary);
    font-family: var(--t4d-font);
    min-height: 18px;
    border-radius: 2px;
}
.mat-val-wide   { grid-column: span 3; }
.mat-val-strong { font-weight: 600; }

/* Stress curve table */
.mat-curve-wrap {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #eeeeee;
    background: #fff;
}
.mat-curve-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--t4d-font);
    font-size: 11px;
}
.mat-curve-table thead th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    border-bottom: 1px solid #dddddd;
    text-align: left;
    padding: 3px 6px;
    font-weight: 600;
    font-size: 10px;
    color: #555;
}
.mat-curve-table tbody td {
    padding: 2px 6px;
    border-bottom: 1px solid #f0f0f0;
}

/* ZONA 4 — temperature tabs */
.mat-zone4 {
    flex-shrink: 0;
    min-height: 210px;
}
.mat-temp-tabstrip {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    border-bottom: 1px solid #cfd8dc;
    margin-bottom: 6px;
}
.mat-temp-tab {
    padding: 4px 10px;
    font-size: 11px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: #64748b;
    cursor: pointer;
}
.mat-temp-tab:hover { color: #1565c0; }
.mat-temp-tab.active {
    color: #0277bd;
    border-bottom-color: #0277bd;
    font-weight: 600;
}

.mat-temp-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 6px;
}
.mat-temp-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.mat-tt-lbl       { font-size: 10px; color: #555; }
.mat-tt-temp {
    width: 70px;
    height: 22px;
    padding: 0 6px;
    font-size: 11px;
    font-family: var(--t4d-font);
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    background: #fafafa;
    outline: none;
    text-align: right;
}
.mat-tt-unit      { font-size: 10px; color: #555; }
.mat-tt-update {
    padding: 4px 10px;
    background: #0277bd;
    color: #fff;
    border: 0;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 8px;
}
.mat-tt-update:hover { background: #01579b; }

/* Properties table inside the temperature tab */
.mat-prop-head,
.mat-prop-row {
    display: grid;
    grid-template-columns: 120px 85px 85px 160px 1fr;
    gap: 4px;
    align-items: center;
}
.mat-head {
    font-size: 10px;
    font-weight: 600;
    color: #555;
}
.mat-tt-prop-lbl { font-size: 11px; color: #424242; }
.mat-tt-db,
.mat-tt-user {
    height: 22px;
    padding: 0 6px;
    font-size: 11px;
    font-family: var(--t4d-font);
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    outline: none;
    width: 100%;
}
.mat-tt-db   { background: #f0f0f0; color: var(--t4d-text-primary); }
.mat-tt-user { background: #ffffcc; color: var(--t4d-text-primary); }
.mat-tt-modulus      { display: flex; align-items: center; gap: 4px; }
.mat-tt-poisson-cell { display: flex; align-items: center; gap: 4px; }
.mat-tt-density-cell { display: flex; align-items: center; gap: 4px; }
.mat-tt-poisson      { width: 60px; }
.mat-tt-density      { width: 70px; }

.modal-input {
    font-family: var(--t4d-font);
    font-size: 12px;
    padding: 5px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.modal-input:focus {
    border-color: #2B5BD7;
    box-shadow: 0 0 0 2px rgba(43, 91, 215, 0.15);
}

/* ── Context menu (right-click on tree element) ─────────────────────── */
.ctx-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: transparent;
}
.ctx-menu {
    position: fixed;
    min-width: 170px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
    padding: 4px 0;
    font-family: var(--t4d-font);
    font-size: 12px;
    color: #1e293b;
}
.ctx-item {
    padding: 6px 14px;
    cursor: pointer;
    user-select: none;
    transition: background .1s, color .1s;
}
.ctx-item:hover {
    background: #EFF6FF;
    color: #1D4ED8;
}

.tree-empty {
    padding-left: 36px;
    font-size: 10px;
    color: #94a3b8;
    font-style: italic;
    font-family: var(--t4d-font);
    padding-top: 4px;
}

/* ── Properties empty state ────────────────────────────── */
.props-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    text-align: center;
    padding: 20px;
}

.props-empty-icon { color: #cbd5e1; }

.props-empty-text {
    font-size: 11px;
    font-family: var(--t4d-font);
    color: #94a3b8;
    line-height: 1.6;
}

/* ── Node badge ────────────────────────────────────────── */
.node-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.node-tag {
    font-size: 9px;
    font-family: var(--t4d-font);
    color: #2B5BD7;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 3px;
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.node-desc {
    flex: 1;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--t4d-font);
    color: #1e293b;
    border: 0;
    border-bottom: 1px dashed #e2e8f0;
    background: transparent;
    outline: none;
    padding: 2px 0;
    min-width: 0;
}

.node-desc:focus { border-bottom-color: #2B5BD7; }

/* ── Section label ─────────────────────────────────────── */
.section-label {
    font-size: 9px;
    font-family: var(--t4d-font);
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 6px;
}

/* ── Center — 3D viewport ──────────────────────────────── */
.viewport-container {
    position: relative;
    background: #ffffff;
    overflow: hidden;
}

.viewport-canvas {
    width:  100%;
    height: 100%;
    display: block;
}

.viewport-overlay {
    position: absolute;
    bottom: 10px;
    left: 12px;
    font-size: 11px;
    color: var(--blue);
    pointer-events: none;
    letter-spacing: 0.3px;
}

/* ── Right panel — properties ───────────────────────────── */
.panel-right {
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.props-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Input group */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
    font-family: var(--t4d-font);
}

.input-group input {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--foreground);
    padding: 5px 9px;
    font-size: 12px;
    font-family: var(--t4d-font);
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(43, 91, 215, 0.15);
}

.input-group input.invalid {
    border-color: #DC2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.unit {
    font-size: 10px;
    color: var(--muted);
    margin-left: 2px;
}

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2px 0;
}

/* Result box */
.result-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
}

.result-label { color: var(--muted); }

.result-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    font-family: var(--t4d-font);
}

.result-value.warning { color: #D97706; }
.result-value.error   { color: #DC2626; }

.result-formula {
    font-size: 11px;
    color: var(--muted);
    font-family: var(--t4d-font);
    font-style: italic;
}

/* View preset buttons overlay (bottom-right of viewport) */
.viewport-view-buttons {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.view-btn {
    background: rgba(255,255,255,0.88);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--foreground);
    font-family: var(--t4d-font);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.4px;
    padding: 3px 8px;
    cursor: pointer;
    text-align: center;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    min-width: 46px;
    backdrop-filter: blur(2px);
}

.view-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary);
    color: var(--primary-text);
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Process Data / Results tab ─────────────────────────────────────── */
.calc-results-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--t4d-font);
    font-size: 11px;
    margin-top: 4px;
}
.calc-results-table th {
    background: var(--t4d-accent);
    color: #fff;
    padding: 5px 8px;
    text-align: left;
    font-size: 10px;
    font-weight: 600;
}
.calc-results-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--t4d-border);
}
.calc-results-table tr:nth-child(even) td { background: #F5F5F5; }
.calc-results-table .row-governing td { font-weight: 700; background: #E3F2FD; }
.calc-pass  { color: #2E7D32; font-weight: 700; }
.calc-fail  { color: #C62828; font-weight: 700; }
.calc-badge-pass { background: #E8F5E9; color: #2E7D32; border: 1px solid #A5D6A7; border-radius: 3px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
.calc-badge-fail { background: #FFEBEE; color: #C62828; border: 1px solid #EF9A9A; border-radius: 3px; padding: 2px 8px; font-size: 11px; font-weight: 700; }

/* ── Design Data dialog — wider for new fields ───────────────────────── */
.design-data-card { width: 720px; }

/* ── X-Ray opacity overlay (bottom-left of viewport) ─────────────────── */
.xray-opacity-panel {
    position: absolute;
    left: 16px;
    bottom: 56px;
    z-index: 19;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.96);
    border: 1px solid #C8D0DA;
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    user-select: none;
}
.xray-opacity-cap {
    font-size: 10px;
    font-weight: 600;
    color: #5F7282;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.xray-opacity-slider {
    width: 140px;
    accent-color: #5F7282;
}
.xray-opacity-val {
    font-size: 11px;
    font-weight: 700;
    color: #1A4FBF;
    font-family: 'Cascadia Mono', Consolas, monospace;
    min-width: 32px;
    text-align: right;
}

/* ── Slice / cut plane overlays ──────────────────────────────────────── */
/* Plane-picker (during cutState == "selecting"): a centred card that takes
   pointer events; the rest of the viewport is unclickable because Viewport3D
   has detached the Babylon camera controls. */
.slice-picker-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 30, 50, 0.20);
    pointer-events: auto;
}
.slice-picker-card {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #C8D0DA;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
    padding: 18px 18px 12px;
    min-width: 280px;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}
.slice-picker-title {
    font-size: 10px;
    font-weight: 700;
    color: #6B7389;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 12px;
}
.slice-picker-options {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.slice-picker-opt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    background: #FFFFFF;
    border: 2px solid #E2E6EF;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.12s, background 0.12s;
}
.slice-picker-opt:hover {
    border-color: #5F7282;
    background: #F2F4F8;
}
.slice-picker-label {
    font-size: 16px;
    font-weight: 700;
    font-family: 'Cascadia Mono', Consolas, monospace;
    color: #1E2535;
}
.slice-picker-sub {
    font-size: 9px;
    color: #8A92A6;
    font-family: 'Cascadia Mono', Consolas, monospace;
}
.slice-picker-cancel {
    width: 100%;
    background: transparent;
    border: 0;
    color: #8A92A6;
    font-size: 10px;
    font-family: 'Cascadia Mono', Consolas, monospace;
    cursor: pointer;
    padding: 4px 0;
}
.slice-picker-cancel:hover { color: #5F7282; }

/* Active-slice panel (during cutState == "active"): right side, plane label,
   offset slider, OK / Cancel. Camera still locked. */
.slice-active-panel {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 140px;
    background: rgba(255,255,255,0.96);
    border: 1px solid #C8D0DA;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.16);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    user-select: none;
}
.slice-active-info { text-align: center; }
.slice-active-cap {
    font-size: 9px;
    color: #8A92A6;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-family: 'Cascadia Mono', Consolas, monospace;
    margin-top: 2px;
}
.slice-active-val {
    font-size: 16px;
    font-weight: 700;
    color: #1A4FBF;
    font-family: 'Cascadia Mono', Consolas, monospace;
}
.slice-active-pct {
    font-size: 13px;
    font-weight: 700;
    color: #1E2535;
    font-family: 'Cascadia Mono', Consolas, monospace;
}
.slice-active-slider {
    width: 100%;
    accent-color: #5F7282;
}
.slice-active-ok, .slice-active-cancel {
    border: 0;
    border-radius: 8px;
    padding: 7px 0;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: #FFFFFF;
    font-family: inherit;
    transition: background 0.12s;
}
.slice-active-ok      { background: #3A8E55; }
.slice-active-ok:hover{ background: #2E7647; }
.slice-active-cancel      { background: #B53F3F; }
.slice-active-cancel:hover{ background: #973434; }

/* ── Viewport right-click context menu ───────────────────────────────── */
/* Wrapper sits in the third .workspace grid cell — needs to fill it and
   force its child .viewport-container to 100% × 100% so the canvas keeps
   the same footprint as before the wrap was introduced. */
.viewport-wrap {
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
}
.viewport-wrap > .viewport-container {
    width: 100%;
    height: 100%;
}
.viewport-menu {
    position: fixed;
    background: #FFFFFF;
    border: 1px solid #8A8A8A;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.18);
    padding: 4px 0;
    min-width: 200px;
    z-index: 9999;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 12px;
}
.viewport-menu-item {
    padding: 5px 18px;
    cursor: pointer;
    user-select: none;
    color: #1A1A1A;
}
.viewport-menu-item:hover { background: #2B5BD7; color: #FFFFFF; }

/* ── Adjust Element Colours dialog (Windows-Forms property-grid look) ── */
.colors-card {
    width: 360px;
    padding: 0;
    background: #F0F0F0;
    border: 1px solid #707070;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.18);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    user-select: none;
}

/* Title bar — narrow dark band, drag handle, pin + close on the right. */
.colors-titlebar {
    display: flex;
    align-items: center;
    height: 22px;
    background: linear-gradient(to bottom, #4773B5 0%, #3B62A0 100%);
    color: #FFFFFF;
    padding: 0 4px 0 8px;
    cursor: move;
    font-size: 12px;
    border-bottom: 1px solid #2B4D8A;
}
.colors-titlebar-text { flex: 1; font-weight: 600; }
.colors-titlebar-btn {
    width: 18px; height: 18px;
    margin-left: 2px;
    background: transparent;
    border: 0;
    color: #FFFFFF;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.colors-titlebar-btn:hover { background: rgba(255,255,255,0.20); }

/* Action toolbar (Apply / Cancel / Reset All) — text-link style. */
.colors-toolbar {
    display: flex;
    gap: 0;
    background: #ECECEC;
    border-bottom: 1px solid #C8C8C8;
    padding: 3px 4px;
    align-items: center;
}
.colors-tb-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #1A1A1A;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    border-radius: 1px;
}
.colors-tb-btn:hover {
    background: #DDE9F8;
    border-color: #B5CEEC;
}
.colors-tb-primary {
    color: #1A1A1A;
    font-weight: 600;
}

/* Tools strip (category / sort) — small icon buttons. */
.colors-tools {
    display: flex;
    gap: 0;
    background: #ECECEC;
    border-bottom: 1px solid #C8C8C8;
    padding: 2px 4px;
}
.colors-tools-btn {
    width: 22px; height: 22px;
    background: transparent;
    border: 1px solid transparent;
    color: #555;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1px;
}
.colors-tools-btn:hover {
    background: #DDE9F8;
    border-color: #B5CEEC;
    color: #1A1A1A;
}
.colors-tools-btn.active {
    background: #DDE9F8;
    border-color: #99B7DE;
    color: #1A4FBF;
}

/* "Colors" master section header. */
.colors-section {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #FFFFFF;
    color: #1A1A1A;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 6px;
    border-bottom: 1px solid #C0C0C0;
    cursor: pointer;
}
.colors-section-chevron {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    color: #555;
    text-align: center;
}

/* Subgroup header — Background / Elements / Details. */
.colors-group-head {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #FAFAFA;
    padding: 3px 6px 3px 14px;
    font-size: 11px;
    color: #404040;
    font-weight: 600;
    border-bottom: 1px solid #E5E5E5;
    cursor: pointer;
}
.colors-group-head:hover { background: #F2F4F8; }
.colors-group-chevron {
    display: inline-block;
    width: 10px;
    font-size: 9px;
    color: #777;
    text-align: center;
}

/* Row — label | swatch | RGB | ... — 4-column grid. */
.colors-row {
    display: grid;
    grid-template-columns: 1fr 26px 78px 22px;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 28px;
    background: #FFFFFF;
    border-bottom: 1px solid #F2F2F2;
    cursor: pointer;
    font-size: 12px;
    min-height: 20px;
}
.colors-row:hover { background: #F2F6FC; }
.colors-row.selected,
.colors-row.selected:hover { background: #DDE9F8; }
.colors-row-label { color: #1A1A1A; }
.colors-swatch {
    width: 24px;
    height: 13px;
    border: 1px solid #707070;
    display: inline-block;
}
.colors-rgb {
    color: #1A4FBF;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 11px;
    text-align: right;
}
.colors-ellipsis {
    width: 20px;
    height: 16px;
    border: 1px solid #707070;
    background: linear-gradient(to bottom, #FAFAFA, #E1E1E1);
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    line-height: 12px;
    color: #1A1A1A;
    font-family: inherit;
}
.colors-ellipsis:hover {
    background: linear-gradient(to bottom, #E5EEF8, #C9DBF0);
    border-color: #5A7DB5;
}
.colors-ellipsis-spacer { width: 20px; }

/* Slider row — used for "Screen Mesh Size" under the Helpers samples. */
.colors-slider-row {
    background: #FFFFFF;
    padding: 4px 10px 6px 28px;
    border-bottom: 1px solid #F2F2F2;
    font-size: 11px;
}
.colors-slider-label {
    display: flex;
    justify-content: space-between;
    color: #1A1A1A;
    margin-bottom: 2px;
}
.colors-slider-value { color: #1A4FBF; font-weight: 600; }
.colors-slider {
    width: 100%;
    height: 14px;
    margin: 0;
    accent-color: #4773B5;
}

.colors-picker-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

/* ── Utilization Chart (per-element page in the report) ───────────────────
   A small bar-chart that mirrors the VVD / Hexagon PPM "COMPONENTS
   UTILIZATION CHART" the user referenced — one bar per case
   (Design / Check / Test), height proportional to σ_governing / σ_allow. */
.rpt-util-section { padding-top: 6mm; }
.rpt-util-subtitle {
    text-align: center;
    font-weight: 600;
    color: #0277BD;
    margin: 4pt 0 10pt;
    font-size: 11pt;
}
.rpt-util-chart {
    display: grid;
    grid-template-columns: 40pt 1fr 150pt;
    grid-template-rows: 280pt 22pt;       /* plot row + x-axis label row */
    gap: 0;
    border: 1pt solid #999;
    background: #FFF;
}
.rpt-util-yaxis {
    grid-column: 1; grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 9pt;
    color: #444;
    text-align: right;
    padding: 4pt 4pt 4pt 6pt;
    border-right: 1pt solid #888;
}
.rpt-util-ytick { line-height: 1; }
.rpt-util-plot {
    grid-column: 2; grid-row: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 4pt 12pt 0;                  /* NO bottom padding — 0% gridline IS the bottom */
    border-bottom: 1pt solid #888;        /* the 0-axis baseline */
}
.rpt-util-gridline {
    position: absolute;
    left: 0; right: 0;
    height: 0; border-top: 0.5pt dotted #BBB;
    z-index: 0;
}
.rpt-util-bar-wrap {
    position: relative;
    width: 60pt;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1;
}
.rpt-util-bar {
    width: 100%;
    background: #2E7D32;                  /* default green; razor overrides per-bar */
    border: 1pt solid #1B5E20;
    box-shadow: 0 1pt 2pt rgba(0,0,0,0.15);
    /* Chromium / WebView2 sometimes drops solid backgrounds on large filled
       elements in the print preview unless `print-color-adjust: exact` is
       set. The bars are the whole point of the chart, so force exact. */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.rpt-util-swatch {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.rpt-util-legend {
    grid-column: 3; grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6pt;
    font-size: 9pt;
    color: #1A2535;
    border-left: 1pt solid #DDD;
    padding: 6pt 10pt;
}
.rpt-util-legend-row {
    display: flex; align-items: center; gap: 6pt;
}
.rpt-util-swatch {
    display: inline-block;
    width: 14pt; height: 10pt;
    background: #2E7D32;
    border: 0.75pt solid #1B5E20;
}
/* Row-2 cells: x-axis labels aligned under the bars. */
.rpt-util-xspacer { /* fills the y-axis and legend columns in row 2 */ }
.rpt-util-xaxis {
    grid-column: 2; grid-row: 2;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 4pt 12pt 0;
}
.rpt-util-xlabel {
    width: 60pt;
    text-align: center;
    font-size: 9pt;
    font-weight: 600;
    color: #1A2535;
}
.rpt-util-avg {
    text-align: center;
    font-size: 10pt;
    font-weight: 600;
    color: #1A2535;
    margin-top: 10pt;
}
.rpt-util-foot {
    text-align: center;
    font-size: 9pt;
    font-style: italic;
    color: #5F7282;
    margin-top: 4pt;
}

/* Graphic Properties → Helpers: Screen Mesh On/Off checkbox. Sits directly
   above the size slider so disable-state is visually unambiguous. */
.colors-toggle-row {
    padding: 4px 18px 2px 38px;
}
.colors-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #1A2535;
    cursor: pointer;
    user-select: none;
}
.colors-toggle input { margin: 0; cursor: pointer; }
.colors-slider-disabled { opacity: 0.45; pointer-events: none; }
.colors-slider-disabled .colors-slider-value { color: #94a3b8; }

/* Reference Line Options dialog */
.ref-opts-card { min-width: 340px; }
.ref-opts-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-size: 13px;
    color: #1A2535;
}
.ref-opts-label { flex: 1; }
.ref-opts-input {
    width: 110px;
    padding: 4px 6px;
    border: 1px solid #BCC4D0;
    border-radius: 3px;
    font-size: 13px;
    text-align: right;
}
.ref-opts-hint {
    font-size: 11px;
    color: #6B7785;
    font-style: italic;
    margin: 6px 0 0;
    line-height: 1.4;
}

/* Settings dialog (GA Drawing setup can be long) — scrollable + resizable so
   the content never overflows the screen. Body scrolls; OK/Cancel stay pinned. */
.ref-opts-card {
    width: 460px;
    max-height: 88vh;
    max-width: 92vw;
    resize: both;
    overflow: hidden;
}
.ref-opts-card > .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* GA Drawing setup — per-group enable boxes */
.ga-group {
    border: 1px solid #D4DAE3;
    border-radius: 4px;
    padding: 6px 8px;
    margin: 6px 0;
    background: #FAFBFC;
}
.ga-group-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #1A2535;
    cursor: pointer;
}
.ga-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0 0 22px;
    font-size: 12.5px;
    color: #1A2535;
}
.ga-label { flex: 0 0 150px; color: #44505F; }
.ga-input {
    flex: 1;
    min-width: 80px;
    padding: 3px 6px;
    border: 1px solid #BCC4D0;
    border-radius: 3px;
    font-size: 12.5px;
}

/* ── Recent files dropdown — rendered at page level with FIXED position
   (left/top inline from the click point); the ribbon's overflow-y:hidden
   would clip an absolutely-positioned child to a single row. ── */
.recent-menu {
    position: fixed;
    z-index: 10000;
    min-width: 280px;
    max-width: 420px;
    background: #FFF;
    border: 1px solid #C8D0DA;
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    padding: 4px 0;
}
.recent-menu-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.recent-menu-item:hover { background: #EEF3F9; }
.recent-menu-name {
    font-size: 12px; font-weight: 600; color: #1A2535;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-menu-path {
    font-size: 10px; color: #8A94A0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-menu-shield { position: fixed; inset: 0; z-index: 9999; }

/* ── Units / Code ribbon group (always-visible selectors) ───────────────── */
.ribbon-uc {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 4px 8px;
    flex: 1;
}
.ribbon-uc-row { display: flex; align-items: center; gap: 6px; }
.ribbon-uc-lbl {
    font-size: 11px; color: #475569; min-width: 76px; text-align: right;
}
.ribbon-uc-select {
    font-size: 11px;
    font-family: var(--t4d-font);
    padding: 2px 4px;
    border: 1px solid #C8D0DA;
    border-radius: 3px;
    background: #FFF;
    color: #1A2535;
    min-width: 150px;
}
.ribbon-uc-select:disabled { color: #8A94A0; background: #F4F6F9; }

/* ── Status bar: element navigation + PASS/FAIL chip ────────────────────── */
.sb-nav { display: inline-flex; gap: 2px; align-items: center; }
.sb-nav-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: inherit;
    font-size: 10px;
    line-height: 1;
    padding: 3px 6px;
    cursor: pointer;
}
.sb-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.35); }
.sb-nav-btn:disabled { opacity: 0.35; cursor: default; }
.sb-chip {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}
.sb-chip-pass { background: #2E7D32; color: #FFF; }
.sb-chip-fail { background: #C62828; color: #FFF; }

/* Export-DXF dialog reuses the ref-opts layout; its <select> needs more room
   than the numeric input the class was sized for. */
select.ref-opts-input { width: 180px; text-align: left; }

/* File dropdown menu — shares the .recent-menu container shell. */
.file-menu { min-width: 220px; }
.file-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 7px 14px;
    font-size: 12px;
    color: #1A2535;
    cursor: pointer;
}
.file-menu-item:hover { background: #EEF3F9; }
/* Head dropdown rows: icon left of label, left-aligned (no space-between). */
.file-menu-item:has(.head-menu-icon) { justify-content: flex-start; gap: 10px; }
.head-menu-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    object-fit: contain;
}
.file-menu-key {
    font-size: 10px;
    color: #8A94A0;
    font-family: Consolas, monospace;
}
.file-menu-sep {
    height: 1px;
    background: #DDE3EB;
    margin: 4px 0;
}

/* Settings dialog — tab strip + 3-way segmented control (single select). */
.settings-tab-strip {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #D8DEE6;
    margin-bottom: 12px;
}
.settings-tab {
    padding: 6px 14px;
    font-size: 12px;
    color: #5F7282;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}
.settings-tab.active {
    color: #1A2535;
    font-weight: 600;
    background: #FFF;
    border-color: #D8DEE6;
    border-bottom: 2px solid var(--t4d-accent, #5F7282);
}
.seg3 {
    display: flex;
    width: 100%;
    border: 1px solid #BCC4D0;
    border-radius: 4px;
    overflow: hidden;
}
.seg3-btn {
    flex: 1;
    padding: 7px 0;
    font-size: 12px;
    font-family: var(--t4d-font);
    background: #FFF;
    color: #1A2535;
    border: none;
    border-right: 1px solid #BCC4D0;
    cursor: pointer;
}
.seg3-btn:last-child { border-right: none; }
.seg3-btn:hover { background: #EEF3F9; }
.seg3-btn.active {
    background: var(--t4d-accent, #5F7282);
    color: #FFF;
    font-weight: 600;
}
