/* Load last. These tokens cover every workspace surface without changing export rendering. */
:root,[data-theme="light"]{--theme-bg:#f4f7fa;--theme-surface:#ffffff;--theme-soft:#edf3f7;--theme-soft-hover:#e1edf5;--theme-text:#253e50;--theme-muted:#526977;--theme-border:#c7d5df;--theme-field-border:#748b99;--theme-accent:#066a9c;--theme-primary:#086e9f;--theme-primary-text:#ffffff;--theme-focus:#066a9c;--theme-error:#af314a;--theme-error-bg:#fff0f3;--theme-warning:#81550c;--theme-warning-bg:#fff6e4;--theme-success:#236d53;--theme-success-bg:#e7f6ee;--theme-shadow:#263c5012;--theme-skeleton:#dce7ee;--theme-backdrop:#12253770;color-scheme:light;--blue:var(--theme-primary);--border:var(--theme-border);--ink:var(--theme-text);--muted:var(--theme-muted)}
[data-theme="dark"]{--theme-bg:#101923;--theme-surface:#182532;--theme-soft:#223343;--theme-soft-hover:#2a4053;--theme-text:#e7eef5;--theme-muted:#b0c0ce;--theme-border:#3d5366;--theme-field-border:#688294;--theme-accent:#65c8ff;--theme-primary:#0b6e9f;--theme-primary-text:#ffffff;--theme-focus:#72ccff;--theme-error:#ff9db0;--theme-error-bg:#3c2430;--theme-warning:#efc87e;--theme-warning-bg:#352e24;--theme-success:#91dbb8;--theme-success-bg:#203b35;--theme-shadow:#00000033;--theme-skeleton:#324b60;--theme-backdrop:#030912bd;color-scheme:dark}
:root{background:var(--theme-bg);min-height:100%}
html,body{background:var(--theme-bg);color:var(--theme-text)}body,#workspace,main{min-height:100vh;min-height:100dvh}#workspace,main{background:var(--theme-bg)}
header,aside,.card,.login-card,dialog,.running-row,.budget-card,.template-card,.schedule-card,.treatment-card,.treatment-assignment,.preview-client{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border);box-shadow:0 3px 12px var(--theme-shadow)}h1,h2,h3,h4,.empty h2,.planning-panel h3,.treatment-card h3,.voice-heading h2{color:var(--theme-text)}button,input,select,textarea,#modalFields textarea,.voice-dialog textarea{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-field-border)}button:hover{background:var(--theme-soft-hover);border-color:var(--theme-field-border)}button:disabled{opacity:1;color:var(--theme-muted);background:var(--theme-soft);border-color:var(--theme-border);cursor:not-allowed}input::placeholder,textarea::placeholder{color:var(--theme-muted);opacity:1}input,select,textarea{accent-color:var(--theme-primary)}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:3px solid var(--theme-focus);outline-offset:3px}input:focus,select:focus{border-color:var(--theme-focus)}.primary{background:var(--theme-primary);border-color:var(--theme-primary);color:var(--theme-primary-text);box-shadow:none}.primary:hover{background:var(--theme-primary);filter:brightness(1.08);border-color:var(--theme-primary)}.primary:disabled{filter:none;color:var(--theme-muted);background:var(--theme-soft);border-color:var(--theme-border)}a,.api-content a,.voice-mac-fallback a,.brand,.running-row .clock,.command-search-icon{color:var(--theme-accent)}.danger{color:var(--theme-error);border-color:var(--theme-field-border)}.workspace-name,#userName,.eyebrow,nav small,.sidebar-foot,.sidebar-foot span,.composer-note,.section-label,.running-row small,.filter-field>span,.search-field>span,.filterbar>span,.totals small,td small,.empty,.empty p,.footnote,label,.login-card p,.list-head,.planning-heading p,.planning-note,.budget-card p,.template-card ul,.schedule-card p,.schedule-card small,.preview-client small,.preview-project p,.history-row span,.fd-panel p,.fd-connection small,.fd-item small,.fd-pagination small,.fd-status-message,.fd-preview dt,.fd-mapping-row small,.treatment-card p,.treatment-assignment small,.treatment-section-title p,.extra-filter-details summary,.extra-filter-details summary span,.extra-filter-note,.extra-filter-set legend,.extra-filter-options label,.extra-filter-options p,.extra-filter-set>small,.voice-description,.voice-status,.voice-choice small,.voice-review-note,.voice-mac-fallback p,.session-tools span,.session-summary-detail,.billing-totals,.time-format-label,.calendar-day>small,.calendar-entry small{color:var(--theme-muted)}nav button{color:var(--theme-muted);background:transparent}nav button.active{background:var(--theme-soft);color:var(--theme-accent);border-left-color:var(--theme-accent)}nav button:hover{background:var(--theme-soft-hover)}th,.summary-top{background:var(--theme-soft);color:var(--theme-muted)}td,.group-row,.composer-note,.datebar,.filter-footer,.templates-heading,.schedule-preview,.history-row,.preview-client,.treatment-section-title,.fd-preview,.fd-mapping-row,.extra-filter-details,.extra-filter-set>small,.exports,.modal-actions,.rate-row{border-color:var(--theme-border)}.filterbar,.extra-filter-set,.fd-connection,.planning-metrics,.calendar-entry,.session-tools{background:var(--theme-soft);border-color:var(--theme-border)}.filter-chip,.filter-count,.section-label span,.planning-badge,.command-icon,.empty .symbol,.token-value,.voice-mac-fallback{background:var(--theme-soft);color:var(--theme-accent);border-color:var(--theme-border)}.active-filters #resetFilters,#resetFilters{color:var(--theme-muted)}.filter-status{background:var(--theme-warning-bg);color:var(--theme-warning);border-color:var(--theme-border)}.filter-status p{color:inherit}.exports button{background:var(--theme-surface);color:var(--theme-accent);border-color:var(--theme-field-border)}.bar,.budget-progress{background:var(--theme-soft)}.bar i,.budget-progress i{background:var(--theme-accent)}.budget-value small{color:var(--theme-muted)}.planning-note,.api-content code,.api-content pre,.fd-preview pre,.voice-mac-fallback{background:var(--theme-soft);border-color:var(--theme-border);color:var(--theme-muted)}.planning-badge.positive{background:var(--theme-success-bg);color:var(--theme-success)}.planning-badge.muted,.unconfigured .planning-badge{background:var(--theme-soft);color:var(--theme-muted)}.near_limit .planning-badge{background:var(--theme-warning-bg);color:var(--theme-warning)}.over_budget .planning-badge{background:var(--theme-error-bg);color:var(--theme-error)}.near_limit .budget-progress i{background:var(--theme-warning)}.over_budget .budget-progress i{background:var(--theme-error)}#loginError,#modalError,.voice-status.error,.history-row p{color:var(--theme-error)}.planning-client-picker,.fd-item,.treatment-assignment,.voice-choice{border-color:var(--theme-field-border);color:var(--theme-text)}.extra-filter-options label:has(input:checked){background:var(--theme-soft-hover);color:var(--theme-accent)}.fd-item span:last-child,.fd-preview dd{color:var(--theme-text)}.preview-project{border-left-color:var(--theme-border)}.login{background:radial-gradient(ellipse at top,var(--theme-soft),var(--theme-bg) 70%)}.login-card{box-shadow:0 16px 60px var(--theme-shadow)}dialog::backdrop,#commandPalette::backdrop{background:var(--theme-backdrop)}.nav-backdrop{background:var(--theme-backdrop)}.running-row{border-color:var(--theme-border);border-left-color:var(--theme-accent)}.running-row .dot{background:var(--theme-accent);box-shadow:0 0 0 4px var(--theme-soft)}.skeleton{background:linear-gradient(90deg,var(--theme-soft) 25%,var(--theme-skeleton) 50%,var(--theme-soft) 75%);background-size:200% 100%}#toast{background:var(--theme-text);color:var(--theme-bg)}.calendar-grid{background:var(--theme-border)}.calendar-day{background:var(--theme-surface);color:var(--theme-text)}.calendar-entry:hover{background:var(--theme-soft-hover)}.entries-table td small[style]{color:var(--theme-muted)!important}
#commandPalette{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}.command-search{border-color:var(--theme-border)}.command-search:focus-within{box-shadow:inset 0 0 0 2px var(--theme-focus)}.command-search input{color:var(--theme-text);background:transparent}.command-search input::placeholder{color:var(--theme-muted)}.command-close{background:var(--theme-soft)!important;color:var(--theme-muted)!important;border-color:var(--theme-field-border)!important}.command-option[aria-selected=true]{background:var(--theme-soft-hover);border-color:var(--theme-field-border)}.command-option[aria-selected=true] .command-icon{background:var(--theme-soft);color:var(--theme-accent)}.command-copy small,.command-status,.command-footer{color:var(--theme-muted)}.command-enter{color:var(--theme-accent)}.command-footer{background:var(--theme-soft);border-color:var(--theme-border)}#commandTrigger{background:var(--theme-soft);color:var(--theme-muted);border-color:var(--theme-field-border)}#commandTrigger kbd{background:var(--theme-surface);color:var(--theme-muted);border-color:var(--theme-border)}#voiceTrigger{background:var(--theme-soft);color:var(--theme-accent);border-color:var(--theme-field-border)}.voice-indicator{background:var(--theme-muted)}.voice-indicator.listening{background:var(--theme-error);box-shadow:0 0 0 5px var(--theme-error-bg)}.voice-review{border-color:var(--theme-border)}
.theme-control{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:0;padding:0 0 16px;font-size:11px;color:var(--theme-muted)}.theme-control select{display:block;flex:1;max-width:118px;min-height:38px;margin:0;padding:8px 10px;font-size:12px;border-color:var(--theme-field-border);background:var(--theme-surface);color:var(--theme-text)}.login-card .theme-control{border-top:1px solid var(--theme-border);padding:18px 0 0;margin-top:22px}.login-card .theme-control select{max-width:150px}.theme-control span{font-size:11px;font-weight:500}.sidebar-foot{padding-top:16px}.sidebar-foot .theme-control{margin-bottom:12px;border-bottom:1px solid var(--theme-border)}
@media(max-width:600px){.entries-table tr,.entity-table tr{border-color:var(--theme-border)}.entries-table td:before,.entity-table td:before{color:var(--theme-muted)}.theme-control{font-size:12px}.theme-control select{min-height:42px}.calendar-grid{grid-template-columns:minmax(0,1fr)}.calendar-day{min-width:0}.calendar-entry{overflow-wrap:anywhere}}
@media(prefers-reduced-motion:reduce){.skeleton,.voice-indicator.listening{animation:none!important}}
@media print{:root,html,body,#workspace,main{background:white!important;color:#111!important}.theme-control{display:none!important}}
.saved-views{background:var(--theme-surface);border-color:var(--theme-border)}.nav-backdrop:hover{background:var(--theme-backdrop);border:0}.calendar-entry:hover{border-color:transparent}.voice-indicator.listening{animation:none}.fd-toolbar input,.treatment-assignment select,.planning-client-picker input{color:var(--theme-text)}
/* Keep the time format readable instead of allowing flex to collapse it to the native arrow. */
@media(max-width:600px){header .time-format-label{flex:0 0 94px;min-width:94px;margin:0;gap:0}header #timeFormat{width:94px;min-width:94px;max-width:94px;flex:0 0 94px;font-size:10px;padding:7px 5px}header #menu,header #commandTrigger,header #voiceTrigger,header #logout{flex-shrink:0}}
@media(max-width:430px){header{gap:6px;padding-left:12px;padding-right:12px}header .brand{flex-shrink:0;gap:0}header .brand b{display:none}header .header-spacer{min-width:0}header #menu{min-width:30px;padding:5px}header #commandTrigger{min-width:36px;padding:7px}header #voiceTrigger{min-width:34px;padding:7px}header #logout{padding:7px 8px;font-size:12px}}

.theme-control .theme-cycle{display:inline-flex;align-items:center;justify-content:center;flex:none;width:44px;height:44px;min-height:44px;padding:0;margin:0;font-size:25px;line-height:1;border-radius:6px;background:var(--theme-surface);color:var(--theme-accent);border-color:var(--theme-field-border)}.login-card .theme-cycle{width:44px;margin-top:0}.theme-cycle:hover{background:var(--theme-soft-hover)}
