/* Appearance behavior and legacy surface selectors. Colors come only from color-system.css. */
.identity{display:flex;align-items:center;gap:14px}
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;min-width:36px;padding:8px;border:1px solid var(--line);border-radius:10px;background:var(--surface-raised);color:var(--muted);box-shadow:none;cursor:pointer}
.theme-toggle:hover{background:var(--brand-soft);color:var(--brand);border-color:var(--line)}
.theme-toggle:focus-visible{outline:2px solid var(--brand);outline-offset:3px}
.theme-toggle svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.theme-sun{display:none}
html[data-theme=dark] .theme-moon{display:none}
html[data-theme=dark] .theme-sun{display:block}
html[data-theme=dark]{color-scheme:dark}
/* Low specificity replaces the unstyled white button base, not chart/heat fills. */
:where(html[data-theme=dark]) button{background:var(--surface-raised);color:var(--muted)}
html[data-theme=dark] body{background:radial-gradient(ellipse at 85% 0,var(--canvas) 0,transparent 45%),radial-gradient(ellipse at 12% 75%,var(--canvas) 0,transparent 40%),var(--canvas)!important;color:var(--text);background-attachment:fixed}
html[data-theme=dark] .topbar{background:var(--surface)!important;border-color:var(--line)!important;box-shadow:0 1px 0 #0002}
html[data-theme=dark] .sidebar{background:var(--surface-raised)!important;border-color:var(--line)!important}
html[data-theme=dark] :is(.brand,.scope,.ws-account-button,.header-context span){color:var(--text)!important}
html[data-theme=dark] :is(.header-context a,.breadcrumb,.scope small,.side-bottom,.side-bottom small,.ws-account-copy small,.nav-group summary,.nav-group[open] summary,#sidenav .nav-children a,footer){color:var(--muted)!important}
html[data-theme=dark] :is(.nav-group[open],.nav-group summary:hover,.ws-account-button:hover){background:var(--surface-raised)!important}
html[data-theme=dark] #sidenav a.active{background:linear-gradient(120deg,var(--brand),var(--brand))!important;color:var(--brand-on)!important;box-shadow:0 4px 14px #0002}
html[data-theme=dark] :is(.scope-icon,.avatar){background:var(--brand-soft)!important;color:var(--brand)!important;border-color:var(--line)!important}
html[data-theme=dark] :is(.scope,.side-bottom){border-color:var(--line)!important}
/* Main cards, nested analysis panes and dynamically created dialogs. */
html[data-theme=dark] :is(.panel,.chart-panel,.dc-filter-host,.analysis-filter-panel,.dc-filter,.overview,.live-card,.kpi,dialog,.org-summary button,.mc-summary button,.ac-summary button,.pw-summary button,.cm-summary button,.bs-summary button,.cw-object-panel,.cw-chart-panel,.cw-records,.org-block,.org-content-grid article,.mc-pair>div){background:var(--surface)!important;border-color:var(--line)!important;box-shadow:0 8px 28px #00000014!important;color:var(--text)!important}
html[data-theme=dark] :is(main,dialog,.filter-popup,.ds-menu,.rp-popover) :is(h1,h2,h3,h4,h5,strong,b,dt,dd,td,label){color:var(--text)!important}
html[data-theme=dark] :is(main,dialog,.filter-popup) :is(p,small,legend,th){color:var(--muted)!important}
html[data-theme=dark] :is(main,dialog){color:var(--text)!important}
html[data-theme=dark] :is(main,dialog) :is([class$="-workspace"],[class$="-note"],[class$="-caption"],[class$="-pages"],[class$="-legend"],[class$="-context"],[class$="-scope"],[class$="-label"],[class$="-date"],[class$="-store"],[class$="-name"],[class$="-values"],[class$="-head"],[class$="-title"],.cv-paired-name>span,.cv-source-values>span,.av-funnel-rate,.mc-muted,.intro,.applied,.metadata,.summary-item,.room-identity,.tagline,.field,.cc-legend,.an-unit){color:var(--muted)!important}
html[data-theme=dark] :is(.dialog-head,.ops-dialog-head,.org-dialog-head,.mc-dialog-head,.pw-dialog-head,.cm-dialog-head,.bs-dialog-head,.cw-head,.cw-footer){background:var(--surface)!important;border-color:var(--line)!important}
html[data-theme=dark] dialog::backdrop{background:#050a15ad!important}
html[data-theme=dark] :is(.ws-identity-detail,.mc-security-note,.mc-check-pairs span,.org-lifecycle,.metric-grid,.notice-inline,.environment,.summary-item,.an-switches,.org-segment,.cw-mode,.pw-mode,.cm-mode,.cw-chip,.mc-chip,.org-active-filters span,.table-wrap thead){background:var(--surface-raised)!important;border-color:var(--line)!important;color:var(--muted)!important}
html[data-theme=dark] :is(table th,table thead){background:var(--surface-raised)!important;border-color:var(--line)!important;color:var(--muted)!important}
html[data-theme=dark] :is(table td,table th,fieldset,.mc-tabs,.org-tabs,.tabs,.analysis-tabs,.analysis-actions,.mc-form-actions,.org-form-actions,.cw-tabs,.cw-filters,.cw-scope,.cw-small-multiples>section,.cv-summary-source p){border-color:var(--line)!important}
html[data-theme=dark] table tbody tr:hover,html[data-theme=dark] .mc-table tr:hover td{background:var(--surface-raised)!important}
/* Controls: keep clickable text and status palettes distinct, never invert charts. */
html[data-theme=dark] :is(button,summary){color:var(--muted)}
html[data-theme=dark] :is(input:not([type=checkbox]):not([type=radio]),textarea,select,.ds-select .ds-trigger,.rp-trigger,.dp-trigger,.filter-popover summary,.inline-select){background:var(--surface-raised)!important;border-color:var(--line)!important;color:var(--text-secondary)!important}
html[data-theme=dark] :is(input,textarea)::placeholder{color:var(--muted)!important;opacity:1}
html[data-theme=dark] :is(button:not(.primary):not(.an-kpi):not(.an-kpi button):not(.theme-toggle):not(.ws-account-button):not(.av-heat-cell):not(.cv-funnel-cell):not(.cv-source-track button):not(.cc-funnel-stage):not(.av-funnel-stage):not(.rp-cell.is-edge):not([aria-selected=true]):not([aria-pressed=true]):not([style*="--heat-color"]):not(.pw-chart button),summary):hover:not(:disabled){background-color:var(--surface-muted)!important;color:var(--text)!important}
html[data-theme=dark] :is(.secondary,.mc-pages button,.org-pages button,.cw-dialog button,.mc-templates button,.av-heat-bottom button,.shortcut){background:var(--surface-raised);border-color:var(--line)!important;color:var(--muted)!important}
html[data-theme=dark] :is(.primary,#dc-query,#cw-apply,.ops-primary-link){background:var(--brand)!important;border-color:var(--line)!important;color:var(--brand-on)!important}
html[data-theme=dark] :is(.primary,#dc-query,#cw-apply,.ops-primary-link):hover:not(:disabled){background:var(--brand-hover)!important;color:var(--brand-on)!important}
html[data-theme=dark] :is(.mc-link,.org-link,.org-name,.cw-detail-link,.cw-object-name,.cv-row-title>b,a:not(.brand):not(#sidenav a),.kpi a){color:var(--accent)!important}
html[data-theme=dark] :is(button[aria-selected=true],button[aria-pressed=true],.ds-trigger[aria-expanded=true],.filter-popover[open]>summary){background-color:var(--brand-soft)!important;color:var(--brand)!important;border-color:var(--line)!important}
html[data-theme=dark] :is(.tabs,.analysis-tabs,.mc-tabs,.org-tabs) button{background:transparent!important}
html[data-theme=dark] :is(.tabs,.analysis-tabs,.mc-tabs,.org-tabs) :is(button[aria-selected=true],button.active){color:var(--brand)!important;border-bottom-color:var(--brand)!important}
html[data-theme=dark] .theme-toggle{background:var(--surface-raised);color:var(--text-secondary);border-color:var(--line)}
html[data-theme=dark] .theme-toggle:hover{background:var(--surface-muted);color:var(--text)}
html[data-theme=dark] :is(button,input,textarea,summary,a):focus-visible{outline:2px solid var(--brand)!important;outline-offset:3px}
/* Top-layer menus and calendar, including those opened after a theme change. */
html[data-theme=dark] :is(.ds-menu,.filter-popup,.dp-popover,.rp-popover){background:var(--surface)!important;border-color:var(--line)!important;color:var(--text)!important;box-shadow:0 12px 38px #0005!important}
html[data-theme=dark] :is(.ds-menu button,.rp-popover button,.dp-popover button,.account-option){color:var(--text-secondary)!important}
html[data-theme=dark] :is(.rp-shortcuts,.rp-footer,.dp-footer){background:var(--surface-raised)!important;border-color:var(--line)!important}
html[data-theme=dark] :is(.rp-weekdays,.rp-navigation,.rp-label,.dp-weekdays){color:var(--muted)!important}
html[data-theme=dark] :is(.rp-cell.in-range,.rp-cell.is-preview){background:var(--brand-soft)!important;color:var(--brand)!important}
html[data-theme=dark] .rp-cell.is-muted{color:var(--muted)!important}
html[data-theme=dark] .rp-cell.is-edge,html[data-theme=dark] .rp-cell.is-edge:hover{background:var(--brand)!important;color:var(--brand-on)!important}
html[data-theme=dark] .rp-footer .primary{color:var(--brand-on)!important}
html[data-theme=dark] dialog button[aria-label^="关闭"]{color:var(--text-secondary)!important;background:transparent!important}
html[data-theme=dark] dialog button[aria-label^="关闭"]:hover:not(:disabled){background:var(--surface-muted)!important;color:var(--text)!important}
html[data-theme=dark] :is(.tag.live,.org-badge,.mc-badge){background:var(--success-soft)!important;color:var(--success)!important}
html[data-theme=dark] :is(.tag.ready,.mc-chip){background:var(--brand-soft)!important;color:var(--brand)!important}
html[data-theme=dark] :is(.org-badge.muted,.mc-badge.off,.mc-chip.off,.tag.unknown){background:var(--surface-raised)!important;color:var(--muted)!important}
html[data-theme=dark] :is(.org-badge.warn,.tag.warning){background:var(--warning-soft)!important;color:var(--warning)!important}
html[data-theme=dark] :is(.mc-error,.org-warning,.org-issues){color:var(--warning)!important}
/* Axes/grid use theme colors; series, heat cells and footage retain data colors. */
html[data-theme=dark] :is(#dc-filter-host,.dc-diagnosis,.an-panel,.an-kpi,.pw-kpi,.cm-card,.ac-block,.ac-kpis article,.ac-state-grid article,.ac-room-grid article,.ms-hero,.ms-counts article,.ms-topology article,.ms-account-grid article,.visual-panel,.trader-primary>div){background:var(--surface)!important;border-color:var(--line)!important;color:var(--text)!important;box-shadow:0 8px 28px #00000014!important}
html[data-theme=dark] :is(.an-kpi.active,.org-summary button[aria-pressed=true],.ac-summary button[aria-pressed=true]){background:var(--brand-soft)!important;border-color:var(--line)!important}
html[data-theme=dark] :is(.an-detail>header,.ac-dialog-head){background:var(--surface)!important;border-color:var(--line)!important}
html[data-theme=dark] :is(.cc-controls>div,.an-not-connected,.an-detail-definition,.ac-segment,.ac-state-callout,.pw-detail-summary,.pw-chart,.pw-chart-tip,.ms-kpi-strip,.cc-source,.cc-ring-number,.cm-card-tags>span,.cm-label,.pw-tag,.an-capability-tags span,.visual-switch,.trader-visible){background:var(--surface-raised)!important;border-color:var(--line)!important;color:var(--muted)!important}
html[data-theme=dark] :is(.an-dashboard,.an-section-title,.an-value>span,.an-unit,.an-operation-metrics button>span,.an-source-legend button>span,.an-rank>span,.an-legend,.cw-card-bar,.an-section-label,.cw-filters>label>span,.rp-state){color:var(--muted)!important}
html[data-theme=dark] :is(.pw-kpi>span,.ac-summary button>span,.org-summary button>span,.mc-summary button>span,.an-section-heading,.section-heading){color:var(--muted)!important}
html[data-theme=dark] :is(.an-card-bottom,.cw-card-bar,.an-source-legend button,.pw-tabs,.ac-tabs,.bs-tabs,.cc-ring-list-head,.cc-ring-row){border-color:var(--line)!important}
html[data-theme=dark] :is(.an-switches button.selected,.pw-views button[aria-pressed=true],.pw-metrics button[aria-pressed=true]){background:var(--brand-soft)!important;color:var(--brand)!important}
html[data-theme=dark] :is(.analysis-actions #af-reset,.cc-select-trigger,.cc-select-menu,.ms-brands button,.bs-table [data-move],.an-pagination button){background:var(--surface-raised)!important;border-color:var(--line)!important;color:var(--muted)!important}
html[data-theme=dark] :is(.ac-status.ok,.pw-status){background:var(--success-soft)!important;color:var(--success)!important}
html[data-theme=dark] :is(.ac-status.warn,.cm-warn){background:var(--warning-soft)!important;color:var(--warning)!important}
html[data-theme=dark] :is(.ac-status,.pw-status.muted){background:var(--surface-raised)!important;color:var(--muted)!important}
html[data-theme=dark] :is(.cm-cover,.cm-preview>img){background:var(--surface-raised)!important}
html[data-theme=dark] :is(.cc-track,.cm-bar-track,.an-bar-track,.ms-region-bars button>i){background:var(--line)!important}
html[data-theme=dark] :is(.pw-tabs,.ac-tabs,.bs-tabs,.report-tabs) button{background:transparent!important}
html[data-theme=dark] :is(.pw-tabs,.ac-tabs,.bs-tabs,.report-tabs) button[aria-selected=true]{color:var(--brand)!important;border-bottom-color:var(--brand)!important}
html[data-theme=dark] :is(main,dialog) svg text{fill:var(--muted)!important}
html[data-theme=dark] :is(.av-grid,.chart-grid,.an-grid){stroke:var(--line)!important}
html[data-theme=dark] svg :is(line[stroke="#e9eef7"],line[stroke="#edf1f7"],line[stroke="#edf2fa"],line[stroke="#e7edf7"],line[stroke="#e8edf7"],line[stroke="#e8edf6"],line[stroke="#e9edf5"],path[stroke="#e9eef7"]){stroke:var(--line)!important}
html[data-theme=dark] :is(.rank-track,.an-rank-track,.cv-paired-track,.cv-source-track){background:var(--line)!important}
html[data-theme=dark] .av-funnel-stage:before{background:color-mix(in srgb,var(--stage-color) 35%,var(--surface-raised))}
html[data-theme=dark] :is(.av-funnel-stage,.cc-funnel-stage,.cv-funnel-cell>b){color:var(--text)!important}
html[data-theme=dark] :is(.av-heat-cell,.cw-heat>button){border-color:var(--line)!important;color:var(--heat-ink)!important}
html[data-theme=dark] #feedback{background:var(--surface-raised)!important;color:var(--text)!important;border-color:var(--line)!important}
@media(max-width:850px){.identity{gap:6px}.theme-toggle{width:32px;height:32px;min-width:32px;padding:6px}}
