.view-theme{display:inline-flex;align-items:center;gap:5px;white-space:nowrap;font-size:11px;color:#526a7e}
.view-theme select{padding:4px 6px;font-size:11px;min-height:28px}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(.topbar,.commandbar,.panel,.inspector,.viewer-head,.viewer-foot,.selection-toolbar,.work-bottom,.table-toolbar,.tabs,.cards,.card,.menu,.feature-navigator,.feature-card,.detail-section,.symbol-text-preview,.result-box,dialog){background:#171d25!important;color:#c5d0dc!important;border-color:#35414e!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(.center,.layout,.table-wrap,.insight-content,.feature-list){background:#101419!important;color:#c5d0dc}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(.inspection-summary,.summary-card,.inspection-summary-card,.list-row,.drawing-insights){background:#202833!important;border-color:#35414e!important;color:#c5d0dc!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(input,select,textarea,button:not(.balloon),summary){color:#bdcbd9;border-color:#35414e}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(input,select,textarea,button:not(.balloon)){background:#202833!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(input,textarea)::placeholder{color:#9fb0c1}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(button:not(.balloon),summary):hover{background:#354555!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) button.primary{background:#b94c12!important;color:#fff!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(button.active,.feature-card.active,.tabs button.active){background:#334655!important;color:#70d7ff!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(h1,h2,h3,h4,strong,.pane-heading,.inspection-facts dt,.inspection-facts dd,.feature-description,.header-identity,.account-identity,.balloon-heading,.gdt-bracket-frame){color:inherit}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(small,.small,.view-theme,.viewer-foot,.feature-meta,.inspection-result,.inspection-facts dt){color:#9aafc2!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(a,.tabs button,.feature-card small){color:#79cfff}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .table-wrap :is(td,th){background:#171d25!important;color:#c5d0dc!important;border-color:#323d49!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .table-wrap th{background:#2b3745!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .table-wrap tr:hover td{background:#354352!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .table-wrap tr.selected td{background:#354b60!important;color:#edf8ff!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .table-wrap td button{color:inherit!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) #drawing-scroll{background:#101419!important}
/* Source artwork and status colors stay faithful to the inspection drawing. */
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) #drawing-sheet{background:#fff;color:#233447}
@media print{html[data-theme=dark]{color-scheme:light}}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(#header-search,.drawing-view-menu>summary,.selection-toolbar label,.rail-action-visual){background:#202833!important;color:#bdcbd9!important;border-color:#35414e!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(.feature-card small span,.inspection-summary span,.insight-content h4,.header-activity summary){color:#9aafc2!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .rail-action-visual svg{color:#bdcbd9!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) .gdt-bracket-frame :is(span,b){color:#c5d0dc!important}
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(.timeline,.audit-history) :is(p,span,div){color:#9aafc2}

/* Keep the application shell in its established Light appearance. */
html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog){color-scheme:dark;--line:#323d49;--muted:#9aafc2;background:#171d25!important;color:#c5d0dc!important;border-color:#323d49!important}
/* Dark-only quiet controls; Light retains its original style.css / controls.css borders. */
html:where([data-theme=dark]) body.approved-controls :is(button:not(.balloon),summary,input,select,textarea,.rail-action-visual,.selection-toolbar label){border-color:transparent!important;box-shadow:none!important}
html body.approved-controls :is(button,summary,input,select,textarea):focus-visible{outline:2px solid #28a8ed!important;outline-offset:2px}
html:where([data-theme=dark]) body.approved-controls .feature-card{border-color:transparent!important}
html[data-theme=dark] .layout{background:#101419}
html[data-theme=dark] body.approved-controls :is(.center,.inspector,.commandbar,dialog) :is(button:not(.balloon),summary,input,select,textarea,.rail-action-visual,.balloon-tools,.selection-toolbar label){border-color:transparent!important;box-shadow:none!important}
html[data-theme=dark] .selection-toolbar .balloon-tools{background:transparent!important}
/* Dark history: subdued connector and solid markers without white halos. */
html[data-theme=dark] :is(.center,.inspector,dialog) .event{color:#b9c8d7;border-left-color:#333e4b}
html[data-theme=dark] :is(.center,.inspector,dialog) .event::before{box-shadow:none;background:#8397ab}
html[data-theme=dark] :is(.center,.inspector,dialog) .event.tone-pass::before{background:#57c982}
html[data-theme=dark] :is(.center,.inspector,dialog) .event.tone-fail::before{background:#ff7187}
html[data-theme=dark] :is(.center,.inspector,dialog) .event time{color:#91a4b8}

html[data-theme=dark] :is(.center,.inspector,.commandbar,dialog) :is(.panel,.detail-section,.inspection-summary,.drawing-insights,.viewer-head,.viewer-foot,.tabs){border-color:#323d49!important}
/* Softer header brightness alongside the dark workspace. */
html[data-theme=dark] .topbar.light-header{background:#c5cfd8;border-bottom-color:#aebbc7}
html[data-theme=dark] .topbar :is(#header-search,input,select){background:#d2dbe3}
/* Keep feature-search focus inside the field so the panel cannot clip it. */
html[data-theme] body.approved-controls .inspector .insight-search :is(input,select):focus{outline:none!important;outline-offset:0;box-shadow:inset 0 0 0 1px #64859e!important}
/* User-approved reversal: black main header with light lettering. */
html[data-theme=dark] .topbar.light-header{background:#000!important;color:#d7dfe7!important;border-bottom-color:#1e2935}
html[data-theme=dark] .topbar.light-header :is(.header-identity,.header-identity span,.account-identity,.account-identity strong,.account-identity small,.header-activity summary){color:#d7dfe7!important}
html[data-theme=dark] .topbar.light-header :is(#header-search,input,select){background:#171c23!important;color:#d7dfe7!important;color-scheme:dark}
html[data-theme=dark] .topbar.light-header input::placeholder{color:#9aaab9}
html[data-theme=dark] .topbar.light-header #save-label{color:#acd4bc}
html[data-theme=dark] .topbar.light-header #save-label small{color:#9aaab9}
html[data-theme=dark] .topbar.light-header .header-phase{background:#253139;color:#a6d6df}
html[data-theme=dark] .topbar.light-header .menu{background:#171c23;color:#d7dfe7}
/* One quiet focus boundary for the whole header search, not nested rings. */
html[data-theme] body.approved-controls .topbar #header-search:focus-within{outline:none!important;box-shadow:inset 0 0 0 1px #64859e!important;border-color:transparent!important}
html[data-theme] body.approved-controls .topbar #header-search input:focus{outline:none!important;box-shadow:none!important}
/* Approved Dark-mode focus: one muted 1px inset, with no bright outer ring. */
html[data-theme=dark] body.approved-controls :is(button,summary,input,select,textarea,[tabindex]):focus-visible{outline:none!important;box-shadow:inset 0 0 0 1px #64859e!important}
html[data-theme=dark] body.approved-controls :is(input,select,textarea):focus{outline:none!important;box-shadow:inset 0 0 0 1px #64859e!important}
html[data-theme=dark] body.approved-controls .topbar #header-search:focus-within{outline:none!important;box-shadow:inset 0 0 0 1px #64859e!important}
html[data-theme=dark] body.approved-controls .topbar #header-search input:focus{outline:none!important;box-shadow:none!important}

/* Search is one composite control in both themes, including autofill focus. */
html body.approved-controls .topbar #header-search:focus-within{outline:none!important;border-color:transparent!important;box-shadow:inset 0 0 0 1px #64859e!important}
html body.approved-controls .topbar #header-search input:is(:focus,:focus-visible){outline:none!important;border:0!important;box-shadow:none!important}
/* The inner input must not paint over the composite search's inset boundary. */
html[data-theme] body.approved-controls .topbar.light-header #header-search input{background:transparent!important;border-radius:0}
/* Dark structural borders; preserve original Light panel and table styling. */
html{--workspace-border:#dce4eb}
html[data-theme=dark]{--workspace-border:rgba(220,230,240,.18)}
html:where([data-theme=dark]) body.approved-controls :is(.center,.inspector,dialog) :is(.panel,.card,.summary-card,.inspection-summary,.inspection-summary-card,.drawing-insights,.feature-navigator,.overview-metrics>div,fieldset,.list-row,.detail-section){border-color:var(--workspace-border)!important;border-width:1px!important;box-shadow:none!important}
html:where([data-theme=dark]) body.approved-controls dialog{border:1px solid var(--workspace-border)!important}
html:where([data-theme=dark]) body.approved-controls :is(.center,.inspector,dialog) :is(th,td,hr){border-color:var(--workspace-border)!important}
/* Slightly raised surfaces for overview status metrics. */
html[data-theme=dark] .overview-metrics>div{background:#293440}

/* Entry field labels only; control values retain the existing theme colors. */
html[data-theme=dark] .entry-inspector{--entry-label-color:#70d7ff}
html[data-theme=dark] .entry-inspector :is(label.field,.calibration>strong){color:var(--entry-label-color)}

/* Compact native radio choices follow Entry across Drawing and Results widths. */
.entry-dimension-units{border:0;padding:0;margin:14px 0;min-width:0}
.entry-dimension-units legend{padding:0;margin-bottom:8px;font-size:12px;font-weight:600}
.entry-dimension-units>div{display:flex;flex-wrap:wrap;gap:20px}
.entry-dimension-units label{display:inline-flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}
.entry-dimension-units input[type=radio]{appearance:auto;width:14px;height:14px;min-height:0;padding:0;margin:0;accent-color:#1687a9}
.entry-dimension-units small{display:block;margin-top:7px;font-size:10px}
html[data-theme=dark] .entry-inspector .entry-dimension-units :is(legend,label){color:var(--entry-label-color,#70d7ff)}

.entry-mean{margin:0}

.entry-tolerance-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.entry-tolerance-grid input{width:100%;min-width:0}
.tolerance-actions{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin:-4px 0 12px}
.tolerance-actions small{flex:1 1 180px;font-size:10px}
.tolerance-actions button{font-size:10px;padding:4px 7px}

/* Limits share the tolerance row columns; the first column belongs to Mean. */
.entry-inspector .entry-limit-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.entry-limit-grid>label:first-child{grid-column:2}
.entry-limit-grid>label:last-child{grid-column:3}
.entry-limit-grid input{width:100%;min-width:0}

/* Compact contextual extraction help; stays reachable while hovering or tabbing into it. */
.entry-value-field{min-width:0}
.entry-value-heading{display:flex;align-items:center;gap:4px;margin-bottom:6px}
.entry-value-heading>label{font-size:12px;font-weight:600}
html[data-theme=dark] .entry-value-heading>label{color:var(--entry-label-color,#70d7ff)}
.entry-value-help{position:relative;display:inline-flex}
body.approved-controls .entry-value-help .entry-help-bulb{display:inline-flex;align-items:center;justify-content:center;background:transparent!important;color:#d9ac37!important;border:0!important;padding:0;width:20px;height:20px;min-height:0;cursor:help}
.entry-help-panel{position:absolute;z-index:30;left:-110px;top:100%;width:min(270px,65vw);box-sizing:border-box;padding:12px;display:flex;flex-direction:column;gap:9px;visibility:hidden;opacity:0;pointer-events:none;border:1px solid var(--workspace-border);border-radius:6px;background:#fff;color:#33465b;font-size:11px;line-height:1.45;font-weight:400;box-shadow:0 4px 12px #0002}
.entry-value-help:hover .entry-help-panel,.entry-value-help:focus-within .entry-help-panel{visibility:visible;opacity:1;pointer-events:auto}
.entry-help-panel button{align-self:flex-start;font-size:11px;padding:5px 8px}
html[data-theme=dark] .entry-help-panel{background:#293440;color:#bdcbd9}
.entry-mean>.tolerance-actions{justify-content:flex-end}
.entry-value-heading{margin-bottom:0;line-height:inherit}
.entry-value-help{width:20px;height:0;align-self:center}
body.approved-controls .entry-value-help .entry-help-bulb{position:absolute;left:0;top:-10px}
.entry-value-help .entry-help-panel{top:10px}

/* Keep calculated limits close to their matching tolerance inputs. */
.entry-inspector .entry-tolerance-grid>.field{margin-bottom:4px}
.entry-inspector .entry-limit-grid>.field{margin-top:4px}

.entry-inspector #tolerance-mean{font-weight:600}
.entry-samples{margin:10px 0 16px}
.entry-samples>label.field{max-width:120px;margin:0 0 6px}
.entry-sample-row{display:grid;grid-template-columns:minmax(65px,.8fr) minmax(0,1fr) minmax(65px,.7fr);gap:10px;align-items:center}
.entry-inspector .entry-sample-row>.field{margin:4px 0}
.entry-sample-name{font-size:11px;color:var(--muted)}
.entry-sample-status{display:flex;align-items:center;min-height:34px;font-weight:700;font-size:13px}
.entry-sample-status.pass{color:#23994d}
.entry-sample-status.fail{color:#ee8a32}
.entry-sample-status.pending{color:var(--muted);font-weight:400}
html[data-theme=dark] .entry-samples .field>span{color:var(--entry-label-color,#70d7ff)}
.entry-samples>small{display:block;font-size:10px;margin-top:8px;color:var(--muted)}
.entry-inspector .entry-limit-grid.has-sample-count>.field{grid-column:auto}
.entry-sample-row{grid-template-columns:repeat(3,minmax(0,1fr));align-items:start}

/* Match the verification form's outer labels to its shared Entry field labels. */
html[data-theme=dark] #editor.requirement-editor #modal-form>label.field{color:#70d7ff}

/* Keep feature quantity readable at its existing size in dark balloon headings. */
html[data-theme=dark] .balloon-heading .gdt-quantity{color:#c5d0dc}

/* Preparation has its own light surface; scope dark overrides to this panel. */
html[data-theme=dark] #requirement-preparation{background:#171d25;border-color:#35414e;color:#c5d0dc}
html[data-theme=dark] #requirement-preparation .zone-teaching{background:#202833;border-color:#35414e;color:#c5d0dc}
html[data-theme=dark] #requirement-preparation .field{color:#70d7ff}
html[data-theme=dark] #requirement-preparation .prep-status{color:#9aafc2}
html[data-theme=dark] #requirement-preparation :is(.preparation-error,[role=alert]){color:#ffb4a9!important}
