/* Light mode keeps the existing workspace palette unchanged. */
html[data-theme="light"]{color-scheme:light}
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;padding:8px;flex:none}
.theme-toggle svg{width:20px;height:20px}
.gte-header #themeToggle{grid-column:3;grid-row:1/3;background:#ffffff0c;color:#e7f2f1;border:1px solid #ffffff2b}
.gte-header #themeToggle:hover{background:#ffffff20;color:#fff}
.theme-toggle:focus-visible{outline:3px solid #75dfb9;outline-offset:3px}
.login-card{position:relative}
.login-card #themeToggle{position:absolute;right:24px;top:24px;width:38px;background:#edf3f1;border:1px solid #ccdad4;color:#073b3c}
@media(max-width:760px){.gte-header #themeToggle{grid-column:2;grid-row:1/4;align-self:start}.header-actions{column-gap:8px}}

html[data-theme="dark"]{color-scheme:dark;background:#1b2226;color:#e1e7e5;--workspace:#1b2226;--surface:#232a2e;--ink:#e1e7e5;--subtle:#afbfbe;--line:#45545a;--brand:#8bd6bd;--brand-dark:#173d3e;--brand-soft:#304640;--search:#356c83;--gr:#a5574f;--gr-soft:#49312f;--heading:#edf3f1;--complete:#2d4538;--partial:#4c432d;--empty:#493330;--dark-raised:#293237;--dark-head:#303c40;--dark-hover:#354442;--dark-danger:#f0a9a0;--dark-warning:#ead39d}
html[data-theme="dark"] body{background:var(--workspace);color:var(--ink)}
html[data-theme="dark"] :is(section,dialog){background:var(--surface);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] :is(button,input,select,textarea){background:var(--dark-raised);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] .month-picker summary{background:var(--dark-raised);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:#a1b1b4;opacity:1}
html[data-theme="dark"] button:hover,html[data-theme="dark"] .month-picker summary:hover{background:var(--dark-hover);border-color:var(--brand)}
html[data-theme="dark"] :is(input,select,textarea,button,summary):focus-visible{outline-color:#8bd6bd88}
html[data-theme="dark"] .primary{background:#356f60;border-color:#4c8b78;color:#f3faf7}
html[data-theme="dark"] .primary:hover{background:#40816e;color:#fff}
html[data-theme="dark"] :is(th,tfoot th){background:var(--dark-head);color:var(--subtle);border-color:var(--line)}
html[data-theme="dark"] td{border-color:var(--line)}
html[data-theme="dark"] tbody tr:nth-child(even){background:var(--dark-raised)}
html[data-theme="dark"] tbody tr:hover{background:var(--dark-hover)}
html[data-theme="dark"] #rows tr:hover>td{box-shadow:inset 0 0 0 999px #ffffff08}
html[data-theme="dark"] #rows tr>td.block-train{background:var(--surface)}
html[data-theme="dark"] #rows tr>td.block-train.marked{background:var(--complete)}
html[data-theme="dark"] #rows tr.block-train-row>td.block-train.marked{background:var(--partial)}
html[data-theme="dark"] :is(.month-panel,.color-options,.account-actions,.excel-export-menu){background:var(--dark-raised);color:var(--ink);border-color:var(--line);box-shadow:0 12px 30px #0005}
html[data-theme="dark"] :is(.account-menu[open]>summary,.account-menu>summary:hover,.account-actions button:hover,.excel-export-menu button:hover,.excel-export>summary:hover){background:var(--dark-hover);color:var(--brand)}
html[data-theme="dark"] :is(.account-role,.account-actions button:last-child){color:var(--subtle);border-color:var(--line)}
html[data-theme="dark"] .account-bar{color:var(--brand)}
html[data-theme="dark"] :is(.file-library-folder summary,.history-events summary){background:var(--dark-raised);color:var(--ink)}
html[data-theme="dark"] .history-events details{border-color:var(--line)}
html[data-theme="dark"] .file-download:hover{background:var(--dark-hover)}
html[data-theme="dark"] .account-form [role=status]{color:var(--brand)}
html[data-theme="dark"] :is(.account-actions button,.copy-number,.document-file-icon,.summary-link,#dateSort,.invoice-panel-footer button){background:transparent;color:var(--brand)}
html[data-theme="dark"] :is(.copy-number:hover,.document-file-icon:hover){background:var(--dark-hover)}
html[data-theme="dark"] :is(.muted,.finance-card span,.invoice-panel-heading p,.invoice-controls>label:not(.appendix-option),.archive-tracking-note,.archive-download-log,.expense-note,.combined-grid small){color:var(--subtle)}
html[data-theme="dark"] :is(.invoice-panel-heading h3,#invoiceSettingsButton,.profit-value,.doc-link,.gr-ready){color:var(--brand)}
html[data-theme="dark"] :is(.invoice-panel,.invoice-drawer .invoice-panel,.summary,.company-editor,.gr-install,.gr-source-card,.gr-preview-grid>div,.pdf-folder-example,.gr-pdf-option,.advanced-filters>.toolbar,.archive-extra-filters>.toolbar,#combinedExpenses,.archive-view-switch,.distribution-track){background:var(--dark-raised);border-color:var(--line)}
html[data-theme="dark"] .invoice-controls :is(input[type=text],select),html[data-theme="dark"] .invoice-reference textarea{background:var(--surface);color:var(--ink)}
html[data-theme="dark"] :is(.invoice-panel-footer,.invoice-drawer,.type-filters,hr){border-color:var(--line)}
html[data-theme="dark"] .badge{background:#34444c;color:#dce8ed}
html[data-theme="dark"] :is(.badge.review,.review,.finance-notice:not(:empty),.missing-filter-bar,.review-warnings,.distribution-warning,.archive-download-status){background:var(--partial);color:var(--dark-warning);border-color:#6e6040}
html[data-theme="dark"] .badge.done{background:#356f60;color:#f3faf7;border-color:#4c8b78}
html[data-theme="dark"] .invoice-number-tag{background:#304453;color:#bdd9f4}
html[data-theme="dark"] :is(.cancel-invoice-button,.gr-errors,.conflict-table tbody tr,.conflict-table th,#dailyResult.error,#message.error,.pdf-folder-notice.error,.archive-download-status.changed){background:var(--empty);color:var(--dark-danger);border-color:#73514b}
html[data-theme="dark"] :is(.conflict-notice,#docIssues,.profit-value.negative,.expense-total,#expenseError){color:var(--dark-danger)!important}
html[data-theme="dark"] #message:not(:empty):not(.error),html[data-theme="dark"] .archive-download-status.downloaded{background:var(--complete);color:#b5e1c5}
html[data-theme="dark"] .cancelled-invoice,html[data-theme="dark"] .cancelled-invoice a{background:var(--dark-raised);color:var(--subtle)}
html[data-theme="dark"] .archive-view-switch button[aria-pressed="true"]{background:var(--dark-hover);color:var(--brand)}
html[data-theme="dark"] .distribution-panel{--distribution-expense:#d5a07e;--distribution-profit:#78bbaa;--distribution-loss:#e18f88;--distribution-income:#7abacb}
html[data-theme="dark"] dialog::backdrop{background:#080e13bb}
html[data-theme="dark"] #reviewTooltip{background:#d8e4e2;color:#182b2c}

/* The sign-in page uses the same saved choice as the workspace. */
html[data-theme="dark"] body:has(.login-card){background:radial-gradient(ellipse at top left,#23423b,transparent 65%),#1b2226}
html[data-theme="dark"] .login-card{background:var(--surface);border-color:var(--line);box-shadow:0 20px 70px #0003}
html[data-theme="dark"] .login-card :is(#intro,.footnote,.eyebrow){color:var(--subtle)}
html[data-theme="dark"] .login-card #submit{background:#356f60;color:#f3faf7}
html[data-theme="dark"] .login-card #notice{color:var(--dark-danger)}
html[data-theme="dark"] .login-card #themeToggle{background:var(--dark-raised);border-color:var(--line);color:var(--ink)}
