/* Shared appearance for the workspace, sign-in/security and mobile guide. */
:root{color-scheme:light;}
:root[data-theme=dark]{color-scheme:dark;color:var(--color-text);background:var(--color-canvas);}
[data-appearance-switch]{flex:none;min-width:0}
.appearance-switch{display:inline-flex;align-items:center;gap:var(--space-hair);padding:var(--space-xs);background:var(--appearance-raised);border:1px solid var(--appearance-line);border-radius:var(--radius-inset);line-height:1;letter-spacing:0}
.appearance-switch button{display:flex;align-items:center;justify-content:center;gap:var(--space-xs);min-width:32px;min-height:32px;padding:var(--space-sm) var(--space-sm);border:0;border-radius:var(--radius-control);background:transparent;color:var(--appearance-muted);font:inherit;font-size:var(--type-caption);line-height:1.3;white-space:nowrap;cursor:pointer;touch-action:manipulation}
.appearance-switch button:hover{background:var(--appearance-surface);color:var(--appearance-text)}
.appearance-switch button[aria-pressed=true]{background:var(--appearance-surface);color:var(--appearance-accent);box-shadow:0 1px 4px #0000000d}
.appearance-switch button:focus-visible{outline:2px solid var(--appearance-accent);outline-offset:2px}
.appearance-switch svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex:none}
/* One shared top bar for every workspace tab. */
body[data-page] .topbar{height:64px;min-height:64px;box-sizing:border-box}
body[data-page] .topbar-actions{gap:var(--space-md);flex:none}
/* Four event categories must fit in a sidebar date cell on every platform. */
@media(min-width:381px){.calendar-month-markers .calendar-category-marker{width:8px;font-size:var(--type-micro)}}
.masthead-actions{display:flex;align-items:center;gap:var(--space-lg)}
.auth-main .top-note{gap:var(--space-md);letter-spacing:1px}
.auth-main .top-note [data-appearance-switch]{margin-left:auto}
.auth-main .top-note #install-entry{margin-left:0}
@media(max-width:1279px){.appearance-switch button span{display:none}}
@media(max-width:700px){body[data-page] .topbar{height:calc(64px + env(safe-area-inset-top));min-height:64px;padding-top:env(safe-area-inset-top)}body[data-page] .topbar-actions{gap:var(--space-sm)}.topbar #mode-badge{display:none}.topbar .breadcrumbs{flex:none}.appearance-switch button{padding:var(--space-sm);min-width:32px}.masthead-actions{gap:var(--space-md)}.masthead .quiet-link{font-size:0}.masthead .quiet-link>span{font-size:var(--type-value)}.auth-main .top-note{flex-wrap:wrap}.auth-main .top-note [data-appearance-switch]{margin-left:auto}}
@media(max-width:380px){body[data-page] .topbar{padding-left:var(--space-md);padding-right:var(--space-md)}.topbar .breadcrumbs>span{display:none}.topbar .breadcrumbs strong{margin:0;font-size:var(--type-card)}body[data-page] .topbar-actions{gap:var(--space-xs)}.masthead{padding-left:var(--space-lg);padding-right:var(--space-lg)}.masthead .brand{font-size:var(--type-title);letter-spacing:1px}.appearance-switch{gap:0;padding:var(--space-hair)}}
/* Neutral surfaces; QR images retain their own white quiet zone for scanning. */
html[data-theme=dark] :is(.sidebar,.card,.stock-tile,.small-metric,.task-disclosure,.calendar-event,.watch-entry,.analysis-time-detail,.delivery-card,.auth-main){background:var(--appearance-surface);color:var(--appearance-text);border-color:var(--border)}
html[data-theme=dark] :is(.topbar,.mobile-nav){background:#162127f5;border-color:var(--border)}
html[data-theme=dark] .auth-main{background:linear-gradient(145deg,var(--color-button),var(--color-canvas))}
html[data-theme=dark] :is(.main-shell,.auth-main,.delivery-grid,.installation-notes) :where(div,section,article,details,table,td,th,dl,li,input,select,button,span,summary,form,hr,p){border-color:var(--border)}
html[data-theme=dark] :is(.data-table th,.segmented,.risk-explainer,.metric-symbol,.stock-monogram,.empty-icon,.strategy-description,.result-metric,.task-description,.calendar-holdings,.calendar-month,.calendar-impact,.macro-driver,.portfolio-item-detail,.candidate-model-totals>div,.macro-trend-empty,.divider-label,.approval-device,.recovery-secret,.release-state,.install-confirmation,.app-icon,.web-icon){background:var(--appearance-raised);color:var(--appearance-muted);border-color:var(--border)}
html[data-theme=dark] :is(.data-table tbody tr:hover,.backtest-history tbody tr.selected,.watch-entry:hover,.watch-entry.active,.desktop-nav a:hover,.desktop-nav a.active,.mobile-nav a.active .icon){background:var(--appearance-selected)}
html[data-theme=dark] :is(.button-secondary,.button.secondary,.field input,.field select,.calendar-month-nav,.calendar-symbols span,.sector-selection select,.segmented button.active,.secondary-button){background:var(--appearance-surface);color:var(--appearance-text);border-color:var(--border)}
html[data-theme=dark] :is(.button-secondary:hover,.button.secondary:hover,.secondary-button:hover,.calendar-month-nav:hover:enabled){background:var(--appearance-selected);border-color:var(--appearance-accent)}
html[data-theme=dark] :is(.button-primary,.button.primary,.submit-button){background:var(--color-button);color:var(--color-on-accent);border-color:var(--color-border-strong)}
html[data-theme=dark] :is(.button-primary:hover,.button.primary:hover,.submit-button:hover){background:var(--color-button)}
html[data-theme=dark] :is(.field input:disabled,.field select:disabled,.button-primary:disabled){background:var(--appearance-raised);color:var(--appearance-muted)}
html[data-theme=dark] :is(.field input:focus,.field select:focus){border-color:var(--appearance-accent)}
html[data-theme=dark] .field input::placeholder{color:var(--color-muted)}
html[data-theme=dark] :is(.notice,.sync-strip,.message){background:var(--color-button);border-color:var(--color-border-strong);color:var(--color-muted)}
html[data-theme=dark] :is(.notice-demo,.notice-warning,.sync-pending,.calendar-notices,.historical-candidate-notice,.portfolio-summary-warnings,.chart-notice,.message.warning,.inline-message,.noscript){background:var(--dark-warning-bg);border-color:var(--color-warning-border);color:var(--dark-warning)}
html[data-theme=dark] :is(.notice-error,.message.error){background:var(--dark-danger-bg);border-color:var(--color-danger-border);color:var(--color-danger)}
html[data-theme=dark] .badge-neutral,html[data-theme=dark] .macro-indicator .badge-neutral{color:var(--appearance-muted);background:var(--appearance-raised)}
html[data-theme=dark] :is(.badge-live,.status-chip.ready,.current-tag){color:var(--color-muted);background:var(--color-button)}
html[data-theme=dark] :is(.badge-demo,.badge-warning,.calendar-importance,.status-chip.pending){color:var(--dark-warning);background:var(--dark-warning-bg)}
html[data-theme=dark] :is(.badge-error,.status-chip.error){color:var(--color-danger);background:var(--dark-danger-bg)}
html[data-theme=dark] :is(.calendar-medium,.risk-icon){color:var(--appearance-muted);background:var(--appearance-raised)}
html[data-theme=dark] body[data-page] .access-info{background:var(--appearance-surface);color:var(--appearance-muted);border-color:var(--border)}
html[data-theme=dark] .portfolio-compact .portfolio-item{background:var(--appearance-surface);border-color:var(--border)}
html[data-theme=dark] .portfolio-compact .risk-summary,html[data-theme=dark] .portfolio-compact .risk-summary .definition-row{background:var(--appearance-raised)}
html[data-theme=dark] .home-lead .portfolio-compact .risk-summary{background:transparent}
html[data-theme=dark] .portfolio-card-days{background:var(--dark-warning-bg)}
html[data-theme=dark] .portfolio-card-days>strong{color:var(--dark-warning)}
/* Text roles on the new dark surfaces. */
html[data-theme=dark] :is(.macro-summary,.macro-overview-details,.macro-meta,.macro-series-heading,.sector-iv-status,.sector-opportunity,.calendar-heading p,.calendar-holdings p,.calendar-kind,.calendar-event-time,.calendar-event-meta,.calendar-event-source,.calendar-detail-hint,.calendar-sources,.calendar-sources summary,.calendar-empty,.calendar-month-weekday,.calendar-month-day,.calendar-month-note,.portfolio-summary-option-type,.portfolio-card-field>span,.portfolio-probability-label,.portfolio-risk-heading,.candidate-current-empty,.candidate-source-message,.historical-candidate-asof,.historical-candidate-empty,.historical-candidate-contract,.candidate-diagnostics,.historical-candidate-context,.historical-candidate-quick,.sector-selection>label,.sector-metadata,.calendar-metadata,.candidate-record-count,.portfolio-shared-notices,.candidate-risk-profile,.candidate-model-fields dt,.candidate-model-reason,.candidate-model-assumptions,.candidate-model-stress,.candidate-model-totals,.candidate-empty-asof,.put-stock-label span,.put-stock-label small,.put-last-trade,.task-description p,.field>span,.check-label,.form-footnote,.private-note,.auth-footer,.section-intro,.reveal,.back-link,.qr-status,.qr-help,.match-caption,.block-note,.session-row p,.web-intro,.steps p,.action-note,.compatibility,.release-details dt,.installation-notes summary,.installation-notes>div,.release-state p,.install-confirmation>p,.install-entry-description,.install-entry-footnote){color:var(--appearance-muted)}
html[data-theme=dark] .portfolio-compact .risk-summary dt{color:var(--appearance-muted)}
html[data-theme=dark] :is(.empty-state strong,.loading-state h1,.calendar-day-label>strong,.calendar-local-time,.calendar-impact-heading h4,.calendar-impact-section h5,.calendar-put-note h5,.calendar-empty strong,.candidate-diagnostics dd,.macro-index-comparison>strong,.historical-candidate-quick>strong,.candidate-risk-profile>strong,.candidate-model-quick b,.candidate-model-totals dd,.approval-code,.approval-device strong,.security-block h3,.session-row strong,.match-line strong,.steps strong,.release-state h3,.release-details dd){color:var(--appearance-text)}
html[data-theme=dark] :is(.desktop-nav a,.portfolio-toggle,.put-detail-close,.calendar-impact-close,.event-calendar a,.button-plain,.text-button,.top-note>a,.auth-tabs button[aria-selected=true],.sync-strip strong,.success-seal){color:var(--appearance-accent)}
html[data-theme=dark] .auth-tabs button[aria-selected=true]::after{background:var(--appearance-accent)}
html[data-theme=dark] .home-lead .data-details:not([open])>summary{color:var(--appearance-muted)}
html[data-theme=dark] :is(.historical-candidate-brief,.sector-map-historical,.home-lead .portfolio-warning-caption,.danger-button){color:var(--dark-warning)}
/* Brokerage direction is preserved in every theme: red gains, green losses. */
html[data-theme=dark]{}
html[data-theme=dark] .macro-driver.macro-indicator,html[data-theme=dark] .sector-tile.sector-block{background:var(--market-cell-bg);border-color:var(--market-cell-border)}
html[data-theme=dark] .positive{color:var(--dark-up)}
html[data-theme=dark] .negative{color:var(--dark-down)}
html[data-theme=dark] .neutral{color:var(--appearance-muted)}
html[data-theme=dark] .risk-shortfall{color:var(--dark-up)}
html[data-theme=dark] .macro-regime.regime-low{--risk-color:var(--color-accent)}
html[data-theme=dark] .macro-regime.regime-moderate{--risk-color:var(--color-warning)}
html[data-theme=dark] .macro-regime.regime-high,html[data-theme=dark] .macro-regime.regime-extreme{--risk-color:var(--color-danger)}
html[data-theme=dark] .macro-meter,html[data-theme=dark] .macro-meter::-webkit-progress-bar{background:var(--appearance-raised)}
html[data-theme=dark] .home-lead .macro-trend-chart[data-selected-sample] .macro-trend-readout{background:var(--appearance-surface)}
html[data-theme=dark] .sector-treemap{background:var(--appearance-surface)}
/* Sticky cells, detail rows and all calendar states stay opaque and readable. */
html[data-theme=dark] .put-contract-table th,html[data-theme=dark] .put-contract-table td{background:var(--appearance-surface);border-color:var(--border)}
html[data-theme=dark] .put-contract-table thead th{background:var(--appearance-raised);color:var(--appearance-muted)}
html[data-theme=dark] .put-contract-table .put-stock-heading th{background:var(--color-button);color:var(--appearance-text)}
html[data-theme=dark] .put-contract-table .put-contract-row>th{color:var(--appearance-text)}
html[data-theme=dark] .put-contract-table .put-contract-row:hover>th,html[data-theme=dark] .put-contract-table .put-contract-row:hover>td,html[data-theme=dark] .put-contract-table .put-expanded-row>td{background:var(--appearance-raised)}
html[data-theme=dark] .put-detail-toggle{background:var(--appearance-surface);color:var(--appearance-accent);border-color:var(--border)}
html[data-theme=dark] .put-detail-toggle:hover,html[data-theme=dark] .put-detail-toggle[aria-expanded=true]{background:var(--appearance-selected);border-color:var(--appearance-accent)}
html[data-theme=dark] .calendar-month-day.has-events .calendar-month-day-number{background:var(--color-button);color:var(--color-muted);border-color:var(--color-border-strong)}
html[data-theme=dark] .calendar-month-day:not(.has-events):not(.is-selected) .calendar-month-day-number{border-color:transparent}
html[data-theme=dark] .calendar-month-day.has-events:hover .calendar-month-day-number{background:var(--color-button);border-color:var(--color-border-strong)}
html[data-theme=dark] .calendar-month-day.is-selected .calendar-month-day-number{background:var(--color-button);color:var(--color-on-accent);border-color:var(--color-border-strong)}
html[data-theme=dark] .category-earnings{color:var(--color-info)}html[data-theme=dark] .category-fed{color:var(--color-event-fed)}html[data-theme=dark] .category-economic{color:var(--color-warning)}html[data-theme=dark] .category-other,html[data-theme=dark] .category-unknown{color:var(--color-muted)}
/* The public access popover and authentication states use the same palette. */
html[data-theme=dark] #install-entry-toggle,html[data-theme=dark] #install-entry-popover{background:var(--appearance-surface);border-color:var(--border);color:var(--appearance-text)}
html[data-theme=dark] #install-entry-toggle:hover,html[data-theme=dark] #install-entry-toggle[aria-expanded=true],html[data-theme=dark] #install-entry-close:hover{background:var(--appearance-selected)}
html[data-theme=dark] #install-entry-close{color:var(--appearance-muted)}
html[data-theme=dark] .qr-overlay{background:#172229f5;color:var(--appearance-muted)}
html[data-theme=dark] .chart-overlay{background:#182329e8;color:var(--appearance-muted)}

html[data-theme=dark] :is(.macro-series-state,.install-entry-subtitle){color:var(--dark-warning)}
