/* V14: one semantic palette layer, loaded after legacy component styles.
   Normal text, muted text and accent text are contrast-tested on all neutral surfaces. */
:root, html[data-theme="dark"] {
  color-scheme:dark;
  --bg:#0e1014;--panel:#181b21;--panel2:#232730;--input:#101319;--line:#697280;
  --text:#f5f6f8;--muted:#b7c0cd;--accent:#e3c17e;--accent-soft:#30291c;--on-accent:#17130a;
  --success:#9ae1bb;--success-bg:#153b2a;--danger:#ffb7b2;--danger-bg:#482427;
  --warning:#f5d38b;--warning-bg:#40351d;--info:#b6d6ff;--info-bg:#203a56;
}
html[data-theme="light"] {
  color-scheme:light;
  --bg:#f6f5f1;--panel:#ffffff;--panel2:#eceae4;--input:#ffffff;--line:#747b85;
  --text:#18212d;--muted:#4d5765;--accent:#785018;--accent-soft:#f5ead5;--on-accent:#ffffff;
  --success:#165b38;--success-bg:#e0f2e7;--danger:#942830;--danger-bg:#fce7e7;
  --warning:#6d4809;--warning-bg:#fff0cb;--info:#1f4e83;--info-bg:#e3effd;
}
html[data-theme="navy"] {
  color-scheme:dark;
  --bg:#0b1323;--panel:#142039;--panel2:#20314d;--input:#0d182c;--line:#6b83a3;
  --text:#f4f8ff;--muted:#b8c9e0;--accent:#a9ccff;--accent-soft:#243a58;--on-accent:#0d1c32;
  --success:#a0e4be;--success-bg:#153b2a;--danger:#ffb7b2;--danger-bg:#482427;
  --warning:#f5d38b;--warning-bg:#40351d;--info:#b6d6ff;--info-bg:#203a56;
}
html[data-theme="ocean"] {
  color-scheme:light;
  --bg:#edf5f9;--panel:#ffffff;--panel2:#e2eef5;--input:#ffffff;--line:#657e8e;
  --text:#122c3b;--muted:#3b5969;--accent:#075c85;--accent-soft:#dceef8;--on-accent:#ffffff;
  --success:#165b38;--success-bg:#e0f2e7;--danger:#942830;--danger-bg:#fce7e7;
  --warning:#6d4809;--warning-bg:#fff0cb;--info:#1f4e83;--info-bg:#e3effd;
}
html[data-theme="forest"] {
  color-scheme:light;
  --bg:#eef5f0;--panel:#ffffff;--panel2:#e4eee6;--input:#ffffff;--line:#687e70;
  --text:#173225;--muted:#405d4b;--accent:#24633e;--accent-soft:#dceee1;--on-accent:#ffffff;
  --success:#165b38;--success-bg:#e0f2e7;--danger:#942830;--danger-bg:#fce7e7;
  --warning:#6d4809;--warning-bg:#fff0cb;--info:#1f4e83;--info-bg:#e3effd;
}
html[data-theme="slate"] {
  color-scheme:dark;
  --bg:#171620;--panel:#22212d;--panel2:#302e3f;--input:#1a1923;--line:#848096;
  --text:#f7f5ff;--muted:#c5c0d7;--accent:#d1beff;--accent-soft:#3a3050;--on-accent:#231b35;
  --success:#a0e4be;--success-bg:#153b2a;--danger:#ffb7b2;--danger-bg:#482427;
  --warning:#f5d38b;--warning-bg:#40351d;--info:#b6d6ff;--info-bg:#203a56;
}
html[data-theme="high-contrast"] {
  color-scheme:dark;
  --bg:#000000;--panel:#080808;--panel2:#161616;--input:#000000;--line:#b0b0b0;
  --text:#ffffff;--muted:#f1f1f1;--accent:#ffdf70;--accent-soft:#29220b;--on-accent:#000000;
  --success:#b3ffd0;--success-bg:#092d19;--danger:#ffcac6;--danger-bg:#380f12;
  --warning:#ffe299;--warning-bg:#302306;--info:#c6e0ff;--info-bg:#102640;
}
/* Aliases keep every existing module on the same semantic palette. */
html[data-theme] {--gold:var(--accent);--gold2:var(--accent);--green:var(--success);--red:var(--danger);--amber:var(--warning);--blue:var(--info);--border:var(--line);scrollbar-color:var(--line) var(--bg)}
html[data-theme] body {background:var(--bg);color:var(--text);font-size:15px;line-height:1.6}
html[data-theme] :is(h1,h2,h3,.brand b,.workspace-label b,.breadcrumb b,.metric b,.metric-card strong,.metric-card b,td b) {color:var(--text)}
html[data-theme] :is(.sidebar,.panel,.metric,.metric-card,.reportcard,.plancard,.workspace-label,.quick-action,.workspace-section,.period-picker,.authcard,.hub-stats>div,.hub-metrics>div,.finding,.trade-item,.stock-row,.ad-row) {background:var(--panel);color:var(--text);border-color:var(--line)}
html[data-theme] :is(.panel,.metric,.metric-card,.reportcard,.workspace-section) {border-radius:12px}
html[data-theme] :is(.termsbox,.extract,.insight,.funnel>div,.ratioGrid>div,.trade-summary,.scenarioResult,.stock-save,.ad-save,.ad-readonly,.evidence-section pre,#command-dialog,.command-head,.chart-column .bar-value,kbd) {background:var(--panel2);color:var(--text);border-color:var(--line)}
html[data-theme] :is(.stmt-group,.stmt-save) {background:var(--panel2);color:var(--text);border-color:var(--line)}
html[data-theme] .stmt-save span {color:var(--text)}
html[data-theme] .stmt-issue {background:var(--accent-soft);color:var(--text);border-color:var(--accent)}
html[data-theme] .stmt-schedule {border-color:var(--line)}
html[data-theme] #command-results a {color:var(--text);font-size:14px;min-height:44px}
html[data-theme] #command-results a:hover {background:var(--accent-soft);color:var(--accent)}
html[data-theme] :is(.pagehead p,.hero p,.muted,.quiet-note,.control-row small,.metric small,.metric span,.metric .measure-icon,.brand small,.sidefoot small,.workspace-label small,.workspace-meta,.workspace-footer,.calendar-summary b,.calendar-summary b span,.mini-label,.lens-tabs span,.lens-tabs a,.signal-item p,.signal-item small,.health-help,.scoregrid span,.scoregrid b,.chart-caption,.chart-footer,.chart-lines span,.chart-column>small,.barcol small,.event small,.event p,.reportcard small,.plancard small,.plancard ul,.details-grid p,.term-list,.trade-editor-details>summary>span,.item-amount span,.metrics .exact-value,.filterbar .result-count,.breadcrumb,.breadcrumb span,.divider,.date-dash,.navhead,.insight p,.hub-stats span,.hub-metrics small,.document-drop small,.document-drop span,.hub-empty-intelligence p,.hub-alerts p,.finding p,.finding small,.finding blockquote,.form-feedback) {color:var(--muted)}
html[data-theme] :is(label,td,.hub-sync-panel p,.hub-review-banner strong,.ai-summary p,.hub-metrics span) {color:var(--text)}
html[data-theme] :is(.kicker,.control-value,.section-link,.reportcard span,.report-index,.qmark,.health-number,.item-row-head>b,.item-amount b,.trade-summary .bigresult b,.trade-summary .bigresult span,.doc-section-label,.audit-details summary,.processing-status,.stock-metrics b,.ad-metrics b,.suggestion>b,.hub-metrics b,.planname,.authcard a,td a) {color:var(--accent)}
html[data-theme] :is(.note,.answer,.suggestion,.bigresult,.health,.ai-summary,.document-drop,.hub-review-banner,.hub-sync-panel,.hub-inline-note,.stock-issue,.ad-notice,.planpill) {background:var(--accent-soft);color:var(--text);border-color:var(--accent)}
html[data-theme] :is(.note p,.answer p,.planpill small,.audit-details pre) {color:var(--text)}
html[data-theme] .staging-banner {background:var(--warning-bg);color:var(--warning);text-align:center;padding:7px 16px;font-size:12px}
html[data-theme] :is(input,select,textarea) {background:var(--input);border:1px solid var(--line);color:var(--text);border-radius:8px;font-size:15px;min-height:44px;max-width:100%;color-scheme:inherit}
html[data-theme] :is(input,textarea)::placeholder {color:var(--muted);opacity:1}
html[data-theme] :is(input[type=checkbox],input[type=radio]) {accent-color:var(--accent);width:19px;min-height:19px;height:19px;flex-shrink:0}
html[data-theme] :is(.check,.checkline) {flex-direction:row;align-items:flex-start;gap:10px}
html[data-theme] input[type=range] {min-height:32px}
html[data-theme] input[type=date] {color-scheme:inherit}
html[data-theme] input[type=date]::-webkit-calendar-picker-indicator {filter:none;opacity:1}
html[data-theme] input[type=file] {min-width:0;white-space:normal}
html[data-theme] input::file-selector-button {background:var(--panel2);color:var(--text);border:1px solid var(--line);border-radius:5px;padding:7px 10px;margin-right:10px;cursor:pointer}
html[data-theme] :is(.btn,.icon-btn,.jump-trigger) {background:var(--panel2);color:var(--text);border-color:var(--line);min-height:44px;border-radius:8px;font-size:14px}
html[data-theme] :is(.icon-btn,.mobile-menu) {min-width:44px}
html[data-theme] .btn.primary {background:var(--accent);color:var(--on-accent);border-color:var(--accent)}
html[data-theme] .btn.primary:hover {background:var(--accent);color:var(--on-accent);box-shadow:0 0 0 2px var(--panel),0 0 0 3px var(--accent)}
html[data-theme] .btn.ghost {background:transparent;color:var(--text)}
html[data-theme] .btn.ghost:hover {background:var(--panel2);border-color:var(--accent)}
html[data-theme] .btn.danger {background:var(--danger-bg);color:var(--danger);border-color:var(--danger)}
html[data-theme] :is(.btn.small,.sidebar .signout) {font-size:13px;min-height:44px}
html[data-theme] :is(button:disabled,input:disabled,select:disabled,textarea:disabled,.reportcard.locked) {opacity:1;color:var(--muted);background:var(--panel2);cursor:not-allowed}
html[data-theme] :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible {outline:3px solid var(--accent);outline-offset:3px;box-shadow:none}
html[data-theme] :is(.avatar,.workspace-avatar) {background:var(--accent-soft);color:var(--accent);border-color:var(--accent)}
html[data-theme] .sidebar {padding:24px 16px 16px}
html[data-theme] .workspace-nav :is(a,summary) {color:var(--text);font-size:14px;min-height:44px;line-height:1.5}
html[data-theme] .workspace-nav .nav-group-links a {font-size:13px;min-height:44px}
html[data-theme] .workspace-nav a .icon {color:var(--muted)}
html[data-theme] .workspace-nav :is(a:hover,summary:hover,.nav-group[open]>summary) {background:var(--panel2);color:var(--text)}
html[data-theme] .workspace-nav a.active {background:var(--accent-soft);border-color:var(--accent);color:var(--accent)}
html[data-theme] .workspace-nav a.active .icon {color:var(--accent)}
html[data-theme] .signout {color:var(--muted)}
html[data-theme] .main :is(.chip-row .chip,.hub-tags>a,.hub-tags>span,.hub-method span,.stock-jump a,.ad-section-nav a) {background:var(--panel2);color:var(--text);border-color:var(--line);font-size:13px}
html[data-theme] .main .chip-row:not(nav) {flex-wrap:wrap}
html[data-theme] .main .chip-row .chip:is(:hover,[aria-current=page]) {background:var(--accent-soft);color:var(--accent);border-color:var(--accent)}
html[data-theme] :is(.hub-method span,.hub-tags>span,.stock-jump a,.ad-section-nav a) {display:inline-flex;align-items:center;min-height:44px}
html[data-theme] :is(.status,.hub-workflow li span) {background:var(--panel2);color:var(--text);border-color:var(--line);font-size:12px;line-height:1.5}
html[data-theme] :is(.status.approved,.status.posted,.status.reviewed,.status.reconciled,.status.reference_reviewed,.status.active,.status.accepted,.status.resolved,.flash,.hub-sync-panel.success,.hub-workflow .done span) {background:var(--success-bg);color:var(--success);border-color:var(--success)}
html[data-theme] :is(.status.draft,.status.pending_review,.status.review_required,.status.acknowledged) {background:var(--warning-bg);color:var(--warning);border-color:var(--warning)}
html[data-theme] :is(.status.rejected,.status.high,.flash.error) {background:var(--danger-bg);color:var(--danger);border-color:var(--danger)}
html[data-theme] :is(.status.sent,.status.send_queued) {background:var(--info-bg);color:var(--info);border-color:var(--info)}
html[data-theme] .hub-success {color:var(--success)}
html[data-theme] :is(.hub-sync-panel.success p,.hub-sync-panel.success h3) {color:var(--success)}
html[data-theme] :is(th,td,.tablewrap,.lineitem,.item-row-head,.event,.signal-item,.hub-alerts article,.hub-history a,.related-sources,.evidence-section,.ad-sources,.ad-evidence,.chart-lines div,.empty,.hub-workflow li) {border-color:var(--line)}
html[data-theme] th {background:var(--panel2);color:var(--text);font-weight:700;font-size:12px;text-transform:none;letter-spacing:0}
html[data-theme] td {font-size:14px}
html[data-theme] td :is(b,small) {font-size:13px}
html[data-theme] td small {color:var(--muted)}
html[data-theme] .tablewrap {max-width:100%;overflow-x:auto;overscroll-behavior-x:contain}
html[data-theme] .tablewrap table {min-width:560px}
html[data-theme] .lens-tabs a.active {color:var(--accent);border-color:var(--accent)}
html[data-theme] :is(.bar,.chart-fill,.chart-column:last-child .chart-fill,.progress i,.live-dot,.signal-dot,.event:before,.chart-caption i) {background:var(--accent)}
html[data-theme] .signal-dot.high {background:var(--danger)}
html[data-theme] .progress {background:var(--panel2);border:1px solid var(--line);height:6px}
html[data-theme] .chart-column .bar-value {border:1px solid var(--line);font-size:13px}
html[data-theme] :is(.authwrap,.authcard) {background:var(--bg)}
html[data-theme] .skip-link {background:var(--accent);color:var(--on-accent)}
/* Shared layout vocabulary: People cards used these classes without any definitions. */
.metric-grid {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin:0 0 24px}
.metric-card {display:flex;flex-direction:column;align-items:flex-start;gap:8px;border:1px solid var(--line);border-radius:12px;padding:21px;min-width:0;overflow-wrap:anywhere}
.metric-card strong {font-size:clamp(27px,2.5vw,36px);font-weight:700;line-height:1.25;font-variant-numeric:tabular-nums;letter-spacing:-.03em}
.metric-card b {display:block;font-size:15px;line-height:1.5}
.metric-card small {display:block;font-size:13px;color:var(--muted);line-height:1.6}
html[data-theme] a.metric-card:hover {border-color:var(--accent);background:var(--panel2)}
.section-head {display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:20px;flex-wrap:wrap}
.section-head>div {min-width:0}.section-head h2 {margin:4px 0 0}.section-head>.quiet-note {margin:4px 0 0}
.feature-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
html[data-theme] :is(.layout2,.layout3,.twocol,.gridform.two,.details-grid,.trade-top,.trade-lower)>* {min-width:0}
html[data-theme] :is(.panel h2,.hub-primary h2) {font-size:20px;line-height:1.4}
html[data-theme] .panel h3 {font-size:16px;line-height:1.5}
html[data-theme] :is(.panel p,.panel label,.formstack label,.gridform label) {font-size:14px}
html[data-theme] :is(.quiet-note,.formstack small,.gridform small,.control-row small,.workspace-footer,.reportcard small,.workspace-label small,.sidefoot small,.authcard>p) {font-size:12px;line-height:1.6}
html[data-theme] :is(.reportcard b,.control-row b,.event b) {font-size:14px}
html[data-theme] .control-list {display:flex;flex-direction:column;gap:0}
html[data-theme] .control-row {display:flex;align-items:center;justify-content:space-between;gap:20px;padding:14px 0;border-bottom:1px solid var(--line);font-size:14px;min-width:0}
.control-row:last-child {border-bottom:0}.control-row>div {min-width:0}.control-row small {display:block;margin-top:4px;overflow-wrap:anywhere}
html[data-theme] a.control-row:hover {color:var(--accent)}
html[data-theme] .control-value {font-size:13px;white-space:normal;flex-shrink:0;max-width:40%}
html[data-theme] :is(.kicker,.mini-label) {font-size:11px;line-height:1.6;letter-spacing:.1em}
html[data-theme] :is(.breadcrumb,.breadcrumb b,.jump-trigger,.workspace-label b) {font-size:13px}
html[data-theme] .workspace-meta {font-size:11px;letter-spacing:.04em;gap:12px;flex-wrap:wrap}
html[data-theme] .topbar>div:first-child {flex-direction:row;min-width:0}
html[data-theme] :is(.pagehead,.hero) {gap:18px}.pagehead>div,.hero>div {min-width:0}
html[data-theme] :is(.pagehead h1,.hero h1) {font-size:clamp(27px,3vw,38px);line-height:1.25;letter-spacing:-.04em}
html[data-theme] .filterbar {flex-wrap:wrap}.filterbar>* {min-width:0}
html[data-theme] :is(.dochead,.docactions,.trade-status-actions,.page-toolbar,.sectitle) {flex-wrap:wrap}
html[data-theme] :is(.layout2,.layout3,.twocol) {align-items:stretch}
html[data-theme] .main {width:100%;max-width:1700px;margin:0 auto}
html[data-theme] :is(code,pre) {overflow-wrap:anywhere;word-break:break-word}
/* Appearance chooser remains legible while the rest of the page previews a theme. */
.theme-fieldset {margin:20px 0 0;padding:0;border:0;min-width:0}.theme-fieldset legend {font-size:14px;font-weight:700;padding:0 0 12px}
.theme-options {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}
.theme-option {position:relative;display:block;cursor:pointer;min-width:0}
html[data-theme] .theme-option input {position:absolute;top:14px;right:14px;z-index:1;margin:0}
.theme-choice {display:flex;flex-direction:column;gap:7px;padding:12px;border:2px solid var(--line);background:var(--panel);border-radius:12px;min-height:176px}
.theme-option input:checked+.theme-choice {border-color:var(--accent);background:var(--accent-soft)}
.theme-option input:focus-visible+.theme-choice {outline:3px solid var(--accent);outline-offset:3px}
.theme-label {font-size:14px;font-weight:700;color:var(--text)}.theme-choice>small {font-size:12px;color:var(--muted)}
.theme-preview {position:relative;display:grid;grid-template-columns:22px 1fr;gap:6px;height:74px;padding:9px 34px 9px 9px;border:1px solid var(--line);border-radius:7px;background:var(--preview-bg);color:var(--preview-text)}
.theme-preview>span {grid-row:span 2;background:var(--preview-accent);border-radius:3px}.theme-preview>i {display:block;background:var(--preview-panel);border:1px solid var(--preview-text);opacity:.55;border-radius:3px}.theme-preview>b {position:absolute;right:12px;bottom:12px;font-size:18px;font-style:normal}
.preview-dark {--preview-bg:#0e1014;--preview-panel:#232730;--preview-text:#f5f6f8;--preview-accent:#e3c17e}
.preview-light {--preview-bg:#f6f5f1;--preview-panel:#ffffff;--preview-text:#18212d;--preview-accent:#785018}
.preview-navy {--preview-bg:#0b1323;--preview-panel:#20314d;--preview-text:#f4f8ff;--preview-accent:#a9ccff}
.preview-ocean {--preview-bg:#edf5f9;--preview-panel:#ffffff;--preview-text:#122c3b;--preview-accent:#075c85}
.preview-forest {--preview-bg:#eef5f0;--preview-panel:#ffffff;--preview-text:#173225;--preview-accent:#24633e}
.preview-slate {--preview-bg:#171620;--preview-panel:#302e3f;--preview-text:#f7f5ff;--preview-accent:#d1beff}
.preview-high-contrast {--preview-bg:#000000;--preview-panel:#161616;--preview-text:#ffffff;--preview-accent:#ffdf70}
.appearance-actions {display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:20px}.appearance-actions .quiet-note {flex:1;min-width:200px;margin:0}
[hidden] {display:none!important}
/* Printed/report previews retain a paper palette regardless of the user's workspace. */
html[data-theme] .report-sheet {--bg:#ffffff;--panel:#ffffff;--panel2:#efefed;--input:#ffffff;--line:#747b85;--text:#18212d;--muted:#4d5765;--accent:#785018;--accent-soft:#f5ead5;--on-accent:#ffffff;background:var(--panel);color:var(--text)}
@media(min-width:1101px) {.metric-grid .metric-card {min-height:180px}}
@media(max-width:1100px) {.metric-grid,.theme-options,.feature-grid {grid-template-columns:repeat(2,minmax(0,1fr))}.layout3 {grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px) {
  html[data-theme] body {font-size:15px}html[data-theme] .main {padding:0 16px 24px}
  html[data-theme] .topbar {height:auto;min-height:68px;gap:8px}html[data-theme] .breadcrumb {font-size:0;gap:0}html[data-theme] .breadcrumb b {font-size:12px}
  html[data-theme] .topactions {gap:5px}html[data-theme] .jump-trigger {min-width:44px;width:44px;padding:8px}
  html[data-theme] .workspace-meta {font-size:10px}html[data-theme] .workspace-meta>span:last-child {display:none}
  html[data-theme] :is(.gridform input,.gridform textarea,.gridform select,.formstack input,.formstack select,.formstack textarea,.main input:not([type=checkbox]):not([type=radio]):not([type=range]),.main select,.main textarea) {font-size:16px}
  html[data-theme] :is(.pagehead,.hero) {align-items:stretch}.pagehead>.btn {align-self:flex-start}
  .feature-grid,.layout3 {grid-template-columns:1fr}.metric-card {padding:18px}.theme-choice {min-height:174px}
  html[data-theme] .control-row {gap:12px}.control-value {max-width:32%}.section-head {gap:10px}
  html[data-theme] .dochead {flex-direction:column}.appearance-actions .quiet-note {flex-basis:100%}
  html[data-theme] .workspace-footer>span:last-child {white-space:normal}
}
@media(max-width:540px) {.metric-grid {grid-template-columns:1fr}.theme-options {grid-template-columns:1fr 1fr;gap:9px}.theme-choice {padding:10px}.theme-label {font-size:13px}.theme-preview {padding-right:24px}.theme-preview>b {right:8px}.section-head>.status {white-space:normal}.control-row {align-items:flex-start}.metric-card strong {font-size:30px}}
@media(prefers-reduced-motion:reduce) {html[data-theme] * {scroll-behavior:auto;transition:none}}
@media print {html[data-theme] body {background:#ffffff;color:#000000}.staging-banner,.appearance-panel {display:none!important}html[data-theme] .tablewrap {overflow:visible}html[data-theme] .tablewrap table {min-width:0}}
