/* Shared surfaces for the settings panel and the dark appearance. */
:root{--ui-page:#f3f6fa;--ui-surface:#fff;--ui-raised:#f3f7fc;--ui-border:#dce5f0;--ui-text:#20354c;--ui-muted:#687f98;--ui-accent:#286de0;--ui-soft:#eaf2ff}
:root[data-theme=dark]{color-scheme:dark;--ui-page:#0e1827;--ui-surface:#172538;--ui-raised:#203249;--ui-border:#33475f;--ui-text:#e4edf8;--ui-muted:#a2b5cb;--ui-accent:#92bcff;--ui-soft:#253e5f;color:var(--ui-text);background:var(--ui-page)}
#appearance-button{display:flex;align-items:center;gap:5px;font-size:12px;white-space:nowrap}
#appearance-button span{font-size:18px;line-height:1}
.appearance-dialog{position:fixed;inset:12px 12px 12px auto;margin:0;width:370px;max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);padding:0;border:1px solid var(--ui-border);border-radius:16px;background:var(--ui-surface);color:var(--ui-text);box-shadow:0 20px 70px #07162944;overflow:auto;overscroll-behavior:contain}
.appearance-dialog::backdrop{background:#07152766}
.appearance-head{display:flex;justify-content:space-between;align-items:center;padding:24px;border-bottom:1px solid var(--ui-border)}
.appearance-kicker{font-size:12px;color:var(--ui-muted);margin-bottom:7px;letter-spacing:1px}
.appearance-head h2{font-size:22px;letter-spacing:.5px}
.appearance-close{border:0;background:var(--ui-raised);color:var(--ui-muted);width:34px;height:34px;font-size:24px;border-radius:8px}
.appearance-section,.appearance-account{margin:0 24px;padding:22px 0;border-bottom:1px solid var(--ui-border)}
.appearance-dialog h3{font-size:16px;margin:0 0 18px}
.appearance-setting{display:flex;align-items:center;justify-content:space-between;gap:15px;margin:0 0 16px}
.appearance-setting:last-child{margin-bottom:0}
.appearance-setting strong{font-size:14px;font-weight:500}
.appearance-setting p{font-size:12px;color:var(--ui-muted);margin-top:6px;line-height:1.6}
.appearance-switch,.appearance-theme-switch{position:relative;border:1px solid var(--ui-border);flex-shrink:0;cursor:pointer}
.appearance-theme-switch{display:flex;align-items:center;justify-content:space-between;width:88px;height:40px;border-radius:24px;background:#102338;padding:0 10px;color:#f9d467;font-size:23px}
.appearance-theme-switch i{position:absolute;width:30px;height:30px;top:4px;left:4px;background:#fff;border-radius:50%;box-shadow:0 1px 4px #0003;transition:transform .18s}
.appearance-theme-switch[aria-checked=true] i{transform:translateX(48px)}
.appearance-switch{width:44px;height:25px;border-radius:20px;background:#a8b7c8}
.appearance-switch i{position:absolute;left:3px;top:3px;width:17px;height:17px;border-radius:50%;background:#fff;transition:transform .18s}
.appearance-switch[aria-checked=true]{background:#377ee9;border-color:#377ee9}
.appearance-switch[aria-checked=true] i{transform:translateX(19px)}
.appearance-select-label{font-size:14px;color:var(--ui-muted);font-weight:400;margin:23px 0 9px}
.appearance-dialog select{width:100%;height:44px;border:1px solid var(--ui-border);border-radius:8px;padding:0 12px;background:var(--ui-raised);color:var(--ui-text);font-size:14px}
.appearance-preview{margin:20px 0 12px;padding:20px;background:var(--ui-page);border:1px solid var(--ui-border);border-radius:10px;overflow:hidden}
.appearance-preview-card{border:1px solid var(--ui-border);border-radius:8px;background:var(--ui-surface);padding:16px}
.appearance-preview-card>span{display:block;font-size:12px;color:var(--ui-accent);margin-bottom:9px}
.appearance-preview-card>strong{font-size:15px}
.appearance-preview-card>div{display:flex;gap:7px;margin-top:14px}
.appearance-preview-card i{height:22px;flex:1;background:var(--ui-soft);border-radius:4px}
.appearance-dialog .appearance-preview-button{width:100%;font-size:13px;background:var(--ui-raised);border-color:var(--ui-border);color:var(--ui-text);padding:10px}
.appearance-motion-note{font-size:12px;line-height:1.7;color:var(--ui-muted);margin:12px 0 0}
.appearance-footer{font-size:12px;line-height:1.7;color:var(--ui-muted);padding:18px 24px}
.appearance-account #accounts-nav-button{width:100%;text-align:left;font-size:14px;padding:12px;background:var(--ui-soft);color:var(--ui-accent);border-color:var(--ui-border)}

/* Dark theme does not alter source values or explicitly chosen cell colors. */
:root[data-theme=dark] body{background:var(--ui-page);color:var(--ui-text)}
:root[data-theme=dark] :is(.workspace,.auth-main){background:var(--ui-page)}
:root[data-theme=dark] .sidebar,:root[data-theme=dark] .auth-aside{background:#0a1422}
:root[data-theme=dark] :is(.topbar,.metric-card,.date-pill,.data-panel,.account-panel,.spend-panel,.spend-preview:not(:empty),.personal-editor,.date-range-dialog,.account-dialog,.finance-dialog){background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] :is(.secondary,.quiet,.date-range-trigger,.search,.personal-editor input,.personal-editor select,.personal-editor textarea,.account-create input,.account-dialog input,.spend-panel input,.spend-panel textarea,.spend-panel select,.finance-form input,.finance-form select,.finance-filters select,.finance-filters input,.auth-card input,.date-range-fields input,.collection-filters select){background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] :is(input,select,textarea):focus-visible{background-color:var(--ui-raised)}
:root[data-theme=dark] :is(input,textarea)::placeholder{color:#8ca0b8;opacity:1}
:root[data-theme=dark] .search input{color:var(--ui-text);background:transparent}
:root[data-theme=dark] :is(.secondary:hover,.quiet:hover){background:var(--ui-raised)}
:root[data-theme=dark] :is(label,.page-heading h1,.auth-card h2,.account-panel h2,.spend-panel h2,.spend-preview h2,.spend-guide h2,.account-permissions legend,.personal-editor h3,.personal-editor label,.finance-form label){color:var(--ui-text)}
:root[data-theme=dark] :is(.muted,.breadcrumb,.eyebrow,.metric-label,.metric-source,.date-pill span,.table-footer,.report-foot,.history-coverage,.job-banner,.note,.account-help,.account-owner,.account-date,.account-permission-option small,.spend-help,.finance-hint,.finance-filters label,.finance-wallet,.overall-context,.overall-caption,.overall-footnote,.overall-metric-label,.personal-formula-note,.personal-toolbar-status,.date-range-caption,.date-range-hint,.small-label,.auth-card>p){color:var(--ui-muted)}
:root[data-theme=dark] #current-account,:root[data-theme=dark] #analysis-main .metric-label{color:var(--ui-muted)}
:root[data-theme=dark] :is(.data-tabs,.table-footer,.account-permissions,.accounts-table td,.accounts-table th,.spend-scroll,.spend-table td,.finance-provider-list>div,.date-range-footer,.date-range-shortcuts,.personal-editor-head,.personal-editor-tabs,.personal-editor-footer,.analysis-loading-head){border-color:var(--ui-border)}
:root[data-theme=dark] :is(.data-tabs button,#analysis-main .data-tabs button){color:var(--ui-muted)}
:root[data-theme=dark] :is(.data-tabs button.selected,#analysis-main .data-tabs button.selected,.account-link){color:var(--ui-accent)}
:root[data-theme=dark] :is(.count-badge,.spend-guide,.personal-toolbar,.personal-more-menu,.personal-choices label,.personal-column-item,.personal-rule,.personal-new-rule,.personal-pending,.personal-column-item small,.account-permission-tag,.account-permission-tag.base){background:var(--ui-raised);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] :is(.personal-choices label:has(input:checked),.personal-column-item.drag-over,.personal-editor-tabs button.selected){background:var(--ui-soft);color:var(--ui-accent);border-color:#608aba}
:root[data-theme=dark] :is(.personal-editor button,.personal-toolbar button){border-color:var(--ui-border)}
:root[data-theme=dark] :is(.personal-editor-head,.personal-editor-footer,.personal-more[open]>button){background:var(--ui-raised);color:var(--ui-text)}
:root[data-theme=dark] :is(.personal-help,.personal-toolbar>strong,.personal-editor-tabs button,.personal-icon,.personal-field,.personal-more){color:var(--ui-muted)}
:root[data-theme=dark] .personal-editor :is(input:not([type=checkbox]):not([type=color]),textarea,select){background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] :is(.note,.schema-title,.attempt-wrap){background:var(--ui-raised);color:var(--ui-muted)}
:root[data-theme=dark] :is(.source-grid,.chart-text,.extra-section h3){color:var(--ui-muted)}
:root[data-theme=dark] .extra-section{border-color:var(--ui-border)}
:root[data-theme=dark] .attempt-wrap select{background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] .personal-rule-sample{background:#fff;color:#20354c}
:root[data-theme=dark] :is(.error:not(:empty),.spend-warning){background:#412b29;color:#ffbbb0;border-color:#71463e}
:root[data-theme=dark] :is(.account-status.enabled,.account-feedback.success,.spend-feedback.success){background:#173d35;color:#98dfbf;border-color:#315e51}
:root[data-theme=dark] :is(.account-status.disabled){background:#3e2c36;color:#e7bbc4}
:root[data-theme=dark] :is(.metric-negative,.finance-negative,.finance-bad,.overall-negative){color:#ff929b!important}
:root[data-theme=dark] :is(.finance-good,.finance-address-result,.overall-check-good){color:#87d7b9}
:root[data-theme=dark] :is(.account-danger,.overall-check-bad){color:#ffac9d}
:root[data-theme=dark] :is(.spend-rate,.finance-feedback){color:var(--ui-text)}

/* Raw and finance tables. */
:root[data-theme=dark] :is(.report-table:not(.analysis-table),.finance-table,.accounts-table,.spend-table) :is(th,td){background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] :is(.report-table:not(.analysis-table),.finance-table,.accounts-table,.spend-table) thead th{background:var(--ui-raised);color:#b8cce3}
:root[data-theme=dark] :is(.report-table:not(.analysis-table),.finance-table,.accounts-table,.spend-table) tbody tr:nth-child(even)>*{background:#1c2c41}
:root[data-theme=dark] :is(.report-table:not(.analysis-table),.finance-table,.accounts-table,.spend-table) tbody tr:hover>*{background:#263c57}
:root[data-theme=dark] .finance-table tfoot td{background:#28476a;color:#deebff}
:root[data-theme=dark] .finance-table .finance-good{color:#87d7b9}
:root[data-theme=dark] .report-table .summary-row td{background:var(--ui-raised)!important;color:var(--ui-text)}

/* Preserve the color grouping of the sheets, with dimmed surfaces and legible text. */
:root[data-theme=dark] #analysis-main .analysis-table{border-color:var(--ui-border)}
:root[data-theme=dark] #analysis-main .analysis-table :is(th,td):not([data-personal-color]){background:color-mix(in srgb,var(--sheet-background-color,#ffffff) 13%,#122135);color:var(--sheet-dark-color,#e4edf8);border-color:#3d526b}
:root[data-theme=dark] #analysis-main .analysis-table .sheet-column-headings th:not([data-personal-color]){background:color-mix(in srgb,var(--sheet-background-color,#dce8fa) 28%,#142338);color:#f1f6ff}
:root[data-theme=dark] #analysis-main .analysis-table[data-report-kind=summary] .sheet-summary-row>:not([data-personal-color]){background:#285792;color:#fff}
:root[data-theme=dark] #analysis-main .analysis-table :is(.sheet-summary-row,.sheet-baseline-row)>:not([data-personal-color]){font-weight:700}
:root[data-theme=dark] #analysis-main .analysis-table .sheet-detail-row>th:first-child:not([data-personal-color]){color:#c4d8f1}
:root[data-theme=dark] #analysis-main .analysis-table[data-header-bands] .sheet-detail-row>*{background-color:color-mix(in srgb,var(--sheet-column-color,#fff) 12%,#122135)}
:root[data-theme=dark] #analysis-main .analysis-table[data-header-bands] .sheet-detail-row:nth-child(even)>*{background-color:color-mix(in srgb,var(--sheet-column-color,#fff) 24%,#122135)}
:root[data-theme=dark] #analysis-main .analysis-table :is(.sheet-negative-format,.sheet-negative-backend,.sheet-negative-ads):not([data-personal-color]){color:#ff929b}
:root[data-theme=dark] #analysis-main .analysis-table .sheet-heading-controls>.sheet-column-toggle{background:#15253bcc;color:#b9d4ff;border-color:#7494b8}
:root[data-theme=dark] #analysis-main .analysis-table :is(th,td):first-child{box-shadow:2px 0 0 #516980}
:root[data-theme=dark] #analysis-main .sheet-total-note{background:var(--ui-surface);color:var(--ui-muted);border-color:var(--ui-border)}
:root[data-theme=dark] #analysis-main.report-expanded,:root[data-theme=dark] .overall-report-expanded #overall-main{background:var(--ui-page)}
:root[data-theme=dark] :is(.table-scroll,.finance-scroll,.overall-scroll,#analysis-main .table-scroll){scrollbar-color:#516980 #162538}

/* Overall view retains a different hue for each product group. */
:root[data-theme=dark] .overall-metric{background:var(--ui-surface);border-color:var(--ui-border)}
:root[data-theme=dark] .overall-key{background:#213c60;border-color:#3c5e88}
:root[data-theme=dark] .overall-key .overall-metric-value{color:#b2d1ff}
:root[data-theme=dark] .overall-table :is(th,td){border-color:var(--ui-border);color:var(--ui-text)}
:root[data-theme=dark] .overall-table thead th{background:var(--ui-raised);color:#bed0e7}
:root[data-theme=dark] .overall-table tbody{--group:#273e5e;--tint:#1b2c43;--ink:#a4c9f4}
:root[data-theme=dark] .overall-table tbody[data-tone=green]{--group:#26443a;--tint:#1b312e;--ink:#a9dab3}
:root[data-theme=dark] .overall-table tbody[data-tone=purple]{--group:#3c3254;--tint:#2a263d;--ink:#c8b5ee}
:root[data-theme=dark] .overall-table tbody[data-tone=rose]{--group:#503345;--tint:#372635;--ink:#e7b2c7}
:root[data-theme=dark] .overall-table tbody[data-tone=orange]{--group:#4a3d2c;--tint:#332d26;--ink:#e8c28b}
:root[data-theme=dark] .overall-table tbody[data-tone=teal]{--group:#22453f;--tint:#1a312f;--ink:#96d7c4}

/* Date selection and native controls. */
:root[data-theme=dark] :is(.date-range-day,.single-date-dialog .date-range-day:disabled){background:var(--ui-surface);color:var(--ui-text)}
:root[data-theme=dark] :is(.date-range-shortcuts button,.date-range-month button){background:var(--ui-raised);color:var(--ui-text);border-color:var(--ui-border)}
:root[data-theme=dark] .date-range-day.in-range{background:#294a76;color:#d6e8ff}
:root[data-theme=dark] :is(.date-range-day.range-edge,.date-range-shortcuts button.selected){background:#3776d5;color:#fff}
:root[data-theme=dark] :is(.date-range-day.outside-month,.single-date-dialog .date-range-day:disabled){color:#6b809b}
:root[data-theme=dark] .single-date-dialog .date-range-month button:disabled{background:var(--ui-surface);color:#6b809b}
@media(prefers-reduced-motion:reduce){.appearance-dialog *{transition:none!important}}
@media(max-width:760px){.topbar{height:auto;min-height:72px;gap:12px;flex-wrap:wrap;padding-top:12px;padding-bottom:12px}.top-actions{flex-wrap:wrap}.appearance-dialog{width:350px}.appearance-head{padding:20px}.appearance-section,.appearance-account{margin:0 20px}.appearance-footer{padding:16px 20px}}

:root[data-theme=dark] :is(.sheet-style-5,.sheet-style-6,.sheet-style-7,.sheet-style-8,.sheet-style-10,.sheet-style-11,.sheet-style-12,.sheet-style-13,.sheet-style-39,.sheet-style-50,.sheet-style-51,.sheet-style-56,.sheet-style-61,.sheet-style-66,.sheet-style-71,.sheet-style-76,.sheet-style-81,.sheet-style-86,.sheet-style-96,.sheet-style-101,.sheet-style-106,.sheet-style-108,.sheet-style-110,.sheet-style-116,.sheet-style-117){--sheet-dark-color:#9cc4ff}
