/* User-selectable light and dark appearance. Loaded last to cover every tool. */

.page-header-tools.data-updates-hidden {
  display: flex;
}

.page-header-tools.data-updates-hidden #data-update-button {
  display: none;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  display: inline-grid;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid #e0e3e7;
  border-radius: 12px;
  padding: 0;
  color: #4f5963;
  background: #fff;
  box-shadow: 0 4px 14px rgba(31, 43, 55, .05);
  cursor: pointer;
  transition: color var(--motion-base) var(--motion-ease), background var(--motion-base) var(--motion-ease), border-color var(--motion-base) var(--motion-ease), transform var(--motion-fast) var(--motion-ease);
}

.theme-toggle:hover {
  border-color: #bfd0df;
  color: #176fc5;
  background: #f6faff;
}

.theme-toggle:active { transform: scale(.96); }
.theme-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.theme-toggle-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle-moon { fill: currentColor; stroke: none; }
.theme-toggle-sun { display: none; }

.legal-information-header,
.error-page-card { position: relative; }
.legal-theme-toggle,
.error-theme-toggle { position: absolute; top: 0; right: 0; }

:root[data-theme="dark"] {
  color: #e7ebef;
  background: #0f1318;
  --blue: #5aa9ff;
  --blue-dark: #68b1ff;
  --border: #39424c;
  --muted: #9ca6b1;
  --soft: #20262d;
  --sidebar: #14191f;
  --danger: #ff8a80;
}

:root[data-theme="dark"] .theme-toggle {
  border-color: #39424c;
  color: #f4c96b;
  background: #1b2128;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .2);
}

:root[data-theme="dark"] .theme-toggle:hover { border-color: #526170; background: #232b34; }
:root[data-theme="dark"] .theme-toggle-moon { display: none; }
:root[data-theme="dark"] .theme-toggle-sun { display: block; }

:root[data-theme="dark"] body,
:root[data-theme="dark"] .error-page,
:root[data-theme="dark"] .legal-information-body {
  color: #e7ebef;
  background: #0f1318;
}

:root[data-theme="dark"] .sidebar {
  border-color: #282f37;
  background: #14191f;
}

:root[data-theme="dark"] .nav-button:hover { background: #20262d; }
:root[data-theme="dark"] .nav-button.active { color: #7dbbff; background: #182b40; }
:root[data-theme="dark"] .nav-button:not(.active),
:root[data-theme="dark"] .brand { color: #d7dde4; }
:root[data-theme="dark"] .nav-icon { color: #9aa5b0; }
:root[data-theme="dark"] .nav-separator { background: #2b323a; }

:root[data-theme="dark"] .workspace :is(p, small, label, li, dt, dd, blockquote),
:root[data-theme="dark"] .legal-information-document :is(p, li),
:root[data-theme="dark"] .page-description,
:root[data-theme="dark"] .breadcrumbs,
:root[data-theme="dark"] .home-static-intro,
:root[data-theme="dark"] .sidebar-note {
  color: #aeb7c2;
}

:root[data-theme="dark"] .workspace :is(h1, h2, h3, h4, strong),
:root[data-theme="dark"] .legal-information-document :is(h1, h2, h3, strong),
:root[data-theme="dark"] .legal-information-brand {
  color: #edf2f7;
}

:root[data-theme="dark"] a { color: #72b7ff; }
:root[data-theme="dark"] .eyebrow { color: #68b1ff; }
:root[data-theme="dark"] .nav-group-title { color: #7f8a96; }

/* Keep white button labels readable while blue remains light enough for links. */
:root[data-theme="dark"] :is(.primary-button, .court-search-row button) {
  color: #fff;
  background: #1766ad;
}
:root[data-theme="dark"] :is(.primary-button, .court-search-row button):hover {
  background: #2278c3;
}
:root[data-theme="dark"] .error-page-links a:first-child {
  color: #fff;
  background: #1766ad;
}
:root[data-theme="dark"] .error-page-links a + a {
  color: #a9d3ff;
  background: #203246;
}
:root[data-theme="dark"] .error-page-card > p:not(.eyebrow) { color: #b8c3cd; }

:root[data-theme="dark"] :is(input, select, textarea),
:root[data-theme="dark"] .publication-picker-button,
:root[data-theme="dark"] .production-calendar-region-button,
:root[data-theme="dark"] .currency-picker-button {
  border-color: #3a444e;
  color: #e7ebef;
  background: #181e24;
}

:root[data-theme="dark"] :is(input, textarea)::placeholder { color: #727e89; }
:root[data-theme="dark"] :is(input, select, textarea):hover { border-color: #526170; }
:root[data-theme="dark"] :is(input, select, textarea):focus,
:root[data-theme="dark"] .home-search-control input:focus { background: #1b222a; }
:root[data-theme="dark"] input:disabled,
:root[data-theme="dark"] select:disabled,
:root[data-theme="dark"] textarea:disabled { color: #7e8994; background: #151a20; }

:root[data-theme="dark"] :is(
  .home-group,
  .home-recent-item,
  .home-reference-card,
  .seo-section,
  .seo-catalog-card,
  .error-page-card,
  .legal-information-document,
  .result-card,
  .publication-rule-card,
  .publication-message-card,
  .bankruptcy-rule-card,
  .nonjudicial-legal-card,
  .fixed-rate-card,
  .court-contact-card,
  .moscow-court-card,
  .court-payment-card,
  .auction-rule-card,
  .auction-process-card,
  .auction-continuation,
  .auction-continuation-card,
  .auction-event-button,
  .currency-rate-card,
  .timezone-card,
  .timezone-moscow-card,
  .production-calendar-month,
  .production-calendar-summary article,
  .production-calendar-sources,
  .production-calendar-footer,
  .production-calendar-toolbar,
  .production-calendar-source-links a,
  .production-calendar-legal-toggle,
  .production-calendar-holiday-event,
  .reference-loading,
  .expense-limit-metric,
  .bankruptcy-control-card,
  .limitation-scenario,
  .moratorium-metrics > section,
  .moratorium-payment-summary
) {
  border-color: #303943;
  color: #e7ebef;
  background: #171c22;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
}

:root[data-theme="dark"] .choice-card {
  border-color: #38434e;
  color: #dce3ea;
  background: #1a2027;
}

:root[data-theme="dark"] .reference-loading span { color: #aeb9c3; }
:root[data-theme="dark"] .production-calendar-region-context {
  border-left-color: #5a8db7;
  color: #b5c0ca;
  background: #1b2732;
}

:root[data-theme="dark"] .timezone-quick-picks button {
  border-color: #3a4651;
  color: #b8c5d0;
  background: #1a2027;
}

:root[data-theme="dark"] .timezone-quick-picks button:hover {
  border-color: #55728d;
  color: #9dceff;
  background: #202a34;
}

:root[data-theme="dark"] .choice-card:hover { border-color: #55728d; background: #202a34; }
:root[data-theme="dark"] .choice-card > :is(span, small) { color: #9fabb7; }
:root[data-theme="dark"] .choice-card:is(.active, [aria-pressed="true"], [aria-selected="true"]),
:root[data-theme="dark"] .choice-card:has(input:checked) {
  border-color: #5aa9ff;
  color: #9dceff;
  background: #172a3d;
  box-shadow: inset 0 0 0 1px #5aa9ff;
}

:root[data-theme="dark"] .choice-card:is(.active, [aria-pressed="true"], [aria-selected="true"]) > :is(span, small),
:root[data-theme="dark"] .choice-card:has(input:checked) > :is(span, small) { color: #9ebbd5; }

:root[data-theme="dark"] :is(.court-duty-payer-picker, .compact-accent-choice-picker, .nonjudicial-payer-picker) .choice-card > .choice-card-icon {
  color: color-mix(in srgb, var(--payer-accent) 70%, white);
  background: color-mix(in srgb, var(--payer-accent) 22%, #1a2027);
}

:root[data-theme="dark"] :is(.court-duty-payer-picker, .compact-accent-choice-picker, .nonjudicial-payer-picker) .choice-card:hover {
  border-color: var(--payer-accent);
  background: #202831;
}

:root[data-theme="dark"] :is(.court-duty-payer-picker, .compact-accent-choice-picker, .nonjudicial-payer-picker) .choice-card[aria-pressed="true"] {
  border-color: var(--payer-accent);
  color: #e7edf3;
  background: color-mix(in srgb, var(--payer-accent) 18%, #182029);
}

:root[data-theme="dark"] .home-group-heading :is(.home-group-count, .home-group-chevron) {
  color: #8ec6ff;
  background: #22303d;
}

:root[data-theme="dark"] .home-latest-update-meta > span,
:root[data-theme="dark"] .home-latest-update-meta time,
:root[data-theme="dark"] .home-reference-label,
:root[data-theme="dark"] .home-search-control > span { color: #b9c7d4; }
:root[data-theme="dark"] .home-latest-update,
:root[data-theme="dark"] .home-latest-update-meta { border-color: #343e48; }
:root[data-theme="dark"] .home-calendar-toolbar button {
  border-color: #3a4b5b;
  color: #a9d3ff;
  background: #202a34;
}
:root[data-theme="dark"] .home-calendar-toolbar button:hover:not(:disabled) {
  border-color: #5a8db7;
  background: #263747;
}
:root[data-theme="dark"] .home-calendar-toolbar button:disabled { color: #8997a4; }

:root[data-theme="dark"] :is(
  .home-tool:hover,
  .home-tool:focus-visible,
  .home-recent-item:hover,
  .home-recent-item:focus-visible,
  .court-staff-group summary:hover,
  .auction-process-card:hover,
  .auction-event-button:hover,
  .timezone-card:hover
) { background: #202933; }

:root[data-theme="dark"] :is(
  .home-search-control input,
  .home-tool-icon,
  .home-reference-card,
  .home-production-calendar,
  .seo-passport dl > div,
  .seo-disclaimer,
  .seo-related-links a,
  .publication-intro,
  .bankruptcy-intro,
  .context-note,
  .interest-legal-content section,
  .interest-legal-content blockquote,
  .moratorium-industries,
  .nonjudicial-legal-rate,
  .publication-platform,
  .publication-platform-timing,
  .publication-rule-basis,
  .publication-duration-tile,
  .publication-message-card-heading,
  .publication-message-common,
  .publication-message-selected,
  .publication-inline-warning,
  .publication-rule-note,
  .au-procedure-card[open],
  .au-required-card,
  .au-optional-details,
  .au-optional-details[open],
  .expense-limit-help-grid section,
  .expense-limit-citizen-grid > section,
  .indexation-return-row,
  .limitation-event-row.is-configured,
  .limitation-payment-row,
  .publication-deadline-card,
  .limitation-date-grid > div,
  .court-staff-group,
  .court-payment-code,
  .auction-preparation-routes,
  .auction-guide-figure,
  .auction-public-offer-group,
  .auction-public-terms > div,
  .currency-converter,
  .timezone-featured-result,
  .timezone-placeholder-compact
) {
  border-color: #303943;
  color: #dce2e8;
  background: #1a2027;
}

/* Calculator-specific form panels that use pale backgrounds in the light theme. */
:root[data-theme="dark"] :is(
  .interest-settings[open],
  .form-grid > .nonjudicial-action-grid,
  .nonjudicial-legal-applicability,
  .nonjudicial-fee-highlight,
  .duty-secondary-options-grid,
  .duty-mixed-presets,
  .duty-exemption-catalog .publication-list-options,
  .claim-change-tranche-row,
  .new-independent-claim-row,
  .repeater.claims .duty-claim-row,
  .bankruptcy-guidance-explanation,
  .auction-event-panel,
  .auction-process-branches,
  .auction-continuation-branches,
  .limitation-brief-help[open],
  .au-intro,
  .au-collateral-field-groups > section,
  .au-collateral-help,
  .au-distribution-grid section,
  .bfo-lookup,
  .bfo-lookup-values div,
  .expense-limit-citizen-grid > section,
  .court-compact-panel,
  .court-filter-tabs,
  .auction-task-button,
  .auction-search-control,
  .auction-search-result,
  .auction-process-branch,
  .auction-period-unit-options,
  .bankruptcy-repeater,
  .bankruptcy-entry-card.repeater-row,
  .bankruptcy-field-help p
) {
  border-color: #35414c;
  color: #dce3ea;
  background: #1a2027;
  box-shadow: none;
}

:root[data-theme="dark"] :is(.duty-exemption-mode-button, .duty-preset-buttons button) {
  border-color: #3a4651;
  color: #dfe6ed;
  background: #1c232a;
}

:root[data-theme="dark"] .duty-exemption-mode-button > span { color: #aeb9c3; }
:root[data-theme="dark"] .duty-exemption-mode-button[aria-pressed="true"] {
  border-color: #5aa9ff;
  color: #eaf4ff;
  background: #172b40;
  box-shadow: 0 0 0 2px rgb(90 169 255 / 16%);
}

:root[data-theme="dark"] .duty-exemption-selected {
  border-color: #426078;
  color: #dfeaf4;
  background: #192936;
}

:root[data-theme="dark"] .court-compact-panel :is(label, .field-label) { color: #b9c4cf; }
:root[data-theme="dark"] .court-directory-summary { color: #b9c4cf; }
:root[data-theme="dark"] .court-reference-mode-switch button.active { color: #9dceff; }
:root[data-theme="dark"] .court-compact-meta { color: #9faebb; }
:root[data-theme="dark"] .court-compact-meta span:last-child { color: #aebbc7; }
:root[data-theme="dark"] .court-filter-tab:hover { color: #dfe6ed; background: #242d35; }
:root[data-theme="dark"] .court-filter-tab.active {
  border-color: #506071;
  color: #ecf2f8;
  background: #26313b;
  box-shadow: none;
}

:root[data-theme="dark"] .procedural-category-badge {
  color: #9dceff;
  background: #203246;
}

:root[data-theme="dark"] :is(.debtor-badge, .platform-badge.efrsb, .nonjudicial-legal-card-heading > span) {
  color: #a9d3ff;
  background: #203246;
}

:root[data-theme="dark"] .platform-badge.kommersant {
  color: #c6d0da;
  background: #2a3139;
}

:root[data-theme="dark"] .platform-badge.etp {
  color: #cdb9ed;
  background: #30283e;
}

:root[data-theme="dark"] .publication-message-card-heading-copy :is(strong, small),
:root[data-theme="dark"] .publication-inline-warning strong,
:root[data-theme="dark"] .nonjudicial-fee-highlight p { color: #dce3ea; }

:root[data-theme="dark"] .publication-message-card-chevron {
  border-color: #4a5b6b;
  background: #23313e;
}

:root[data-theme="dark"] .publication-message-card-chevron::before { border-color: #a9d3ff; }

:root[data-theme="dark"] .nonjudicial-fee-highlight.is-pending {
  border-color: #40505f;
  background: #222b34;
}

:root[data-theme="dark"] .nonjudicial-fee-highlight.is-pending :is(h4, p) { color: #b8c6d3; }

:root[data-theme="dark"] .production-calendar-toolbar-controls > .reference-export-actions .productivity-action {
  border-color: #3a444e;
  color: #b9d8f7;
  background: #1b2229;
  box-shadow: none;
}

:root[data-theme="dark"] .auction-event-heading h2,
:root[data-theme="dark"] .auction-event-button strong,
:root[data-theme="dark"] .auction-process-branches h3 { color: #edf2f7; }
:root[data-theme="dark"] .auction-event-button > span:not(.auction-event-term):not(.auction-event-terms) { color: #aeb9c3; }
:root[data-theme="dark"] .auction-event-term {
  border-color: #384958;
  color: #c6d4df !important;
  background: #232d36;
}
:root[data-theme="dark"] .auction-event-term small { color: #95b8d8; }
:root[data-theme="dark"] .auction-applicability-badge {
  color: #cdb9ed !important;
  background: #30283e;
}
:root[data-theme="dark"] .auction-process-branch span { color: #aeb9c3; }
:root[data-theme="dark"] .auction-event-button:is(:hover, .active) { background: #202933; }

:root[data-theme="dark"] :is(.auction-process-marker span, .auction-continuation-number) {
  border-color: #6689a8;
  color: #b9d8f7;
  background: #1c2731;
  box-shadow: 0 0 0 5px rgb(90 169 255 / 7%);
}

:root[data-theme="dark"] :is(.auction-process-timeline li, .auction-continuation > ol > li):not(:last-child)::before {
  background: #506779;
}

:root[data-theme="dark"] :is(.auction-process-copy small, .auction-process-term b, .auction-continuation-copy small, .auction-continuation-term b) {
  color: #aeb9c3;
}

:root[data-theme="dark"] :is(.auction-process-copy small span, .auction-process-term span, .auction-continuation-term span) {
  color: #829bb2;
}

:root[data-theme="dark"] .auction-continuation-note {
  color: #e4c98f;
  background: #2a2418;
}

:root[data-theme="dark"] :is(
  .publication-picker-dropdown,
  .duty-picker-dropdown,
  .production-calendar-region-dropdown,
  .currency-picker-dropdown,
  .publication-history-drawer,
  .production-calendar-holiday-dialog,
  #publication-directory,
  #bankruptcy-directory,
  .workbench-drawer
) {
  border-color: #3a444e;
  color: #e7ebef;
  background: #171c22;
  box-shadow: 0 22px 54px rgba(0, 0, 0, .42);
}

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory) .directory-types {
  background: #242d36;
}

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory) .directory-types button {
  color: #aebbc7;
}

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory) .directory-types button[aria-pressed="true"] {
  border-color: #55728d;
  color: #a9d3ff;
  background: #1b3043;
}

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory) .directory-count {
  color: #b8c6d3;
  background: #263541;
}

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory)[data-view="list"] article:hover {
  border-color: #55728d;
  background: #202a34;
}

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory)[data-view="detail"] .directory-summary {
  background: #1d2a35;
}

:root[data-theme="dark"] .publication-picker-group + .publication-picker-group {
  border-top-color: #343e48;
}

:root[data-theme="dark"] .publication-picker-group-title {
  color: #aebdca;
  background: rgb(35 44 53 / 97%);
}

:root[data-theme="dark"] .duty-picker-group .publication-picker-group-title small {
  color: #92a3b2;
}

:root[data-theme="dark"] .publication-picker-option {
  color: #d8e0e8;
}

:root[data-theme="dark"] .publication-picker-option:is(:hover, [aria-selected="true"], .keyboard-active) {
  color: #a9d3ff;
  background: #203246;
}
:root[data-theme="dark"] .publication-picker-count { color: #aeb9c3; }

:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory) label,
:root[data-theme="dark"] :is(#publication-directory, #bankruptcy-directory) [data-directory-total] {
  color: #b9c7d4;
}

:root[data-theme="dark"] .currency-picker-option,
:root[data-theme="dark"] .production-calendar-region-option { color: #dce3ea; }
:root[data-theme="dark"] .currency-picker-option:is(:hover, :focus-visible, [aria-selected="true"]),
:root[data-theme="dark"] .production-calendar-region-option:is(:hover, .keyboard-active, [aria-selected="true"]) {
  color: #a9d3ff;
  background: #203246;
}
:root[data-theme="dark"] .currency-picker-check,
:root[data-theme="dark"] .production-calendar-region-option i { color: #a9d3ff; }
:root[data-theme="dark"] .currency-picker-search-row > button,
:root[data-theme="dark"] .production-calendar-region-search-row {
  border-color: #3a444e;
  color: #dce3ea;
  background: #1d252d;
}
:root[data-theme="dark"] .production-calendar-region-search-row small { color: #aeb9c3; }

:root[data-theme="dark"] .publication-history-drawer-header {
  border-color: #303943;
  background: rgb(23 28 34 / 97%);
}
:root[data-theme="dark"] .publication-history-drawer-header h2,
:root[data-theme="dark"] .publication-history-section-heading h3,
:root[data-theme="dark"] .publication-history-event h3,
:root[data-theme="dark"] .publication-history-future-list article strong,
:root[data-theme="dark"] .publication-history-empty strong { color: #edf2f7; }
:root[data-theme="dark"] .publication-history-drawer-header span,
:root[data-theme="dark"] .publication-history-section-heading span,
:root[data-theme="dark"] .publication-history-future-list article p,
:root[data-theme="dark"] .publication-history-event p,
:root[data-theme="dark"] .publication-history-empty p { color: #b8c3cd; }
:root[data-theme="dark"] .publication-history-event time { color: #95c9f7; }
:root[data-theme="dark"] .publication-history-close,
:root[data-theme="dark"] .publication-history-future-list article,
:root[data-theme="dark"] .publication-history-empty {
  border-color: #35414c;
  color: #dce3ea;
  background: #1d252d;
}
:root[data-theme="dark"] .publication-history-timeline { border-color: #35414c; }
:root[data-theme="dark"] .publication-history-list::before { background: #3d5061; }
:root[data-theme="dark"] .publication-history-event::before { border-color: #171c22; }

:root[data-theme="dark"] :is(.publication-picker-arrow, .currency-picker-arrow, .production-calendar-region-arrow) {
  color: #b9c7d4;
}
:root[data-theme="dark"] .publication-history-header-action { color: #b9c7d4; }

:root[data-theme="dark"] :is(table, .table-wrap) { background: #151a20; }
:root[data-theme="dark"] :is(th, td) { border-color: #303943; }
:root[data-theme="dark"] th { color: #b7c1cb; background: #1e252d; }
:root[data-theme="dark"] tr:nth-child(even) td { background-color: rgba(255, 255, 255, .018); }
:root[data-theme="dark"] .expense-reference-answer { color: #b8c3cd; }
:root[data-theme="dark"] .expense-reference-answer :is(table, caption, td) { color: inherit; }
:root[data-theme="dark"] .result-card .expense-limit-tags span { background: #26313b; }
:root[data-theme="dark"] :is(.procedural-timeline, .limitation-timeline) time { color: #b8c3cd; }

:root[data-theme="dark"] .moratorium-industries > summary,
:root[data-theme="dark"] .moratorium-industry-list :is(span, code),
:root[data-theme="dark"] .moratorium-industry-footnote { color: #b8c6d3; }
:root[data-theme="dark"] .moratorium-industry-list > div,
:root[data-theme="dark"] .moratorium-industries[open] > summary { border-color: #35414c; }
:root[data-theme="dark"] .production-calendar-control-label { color: #b9c4cf; }
:root[data-theme="dark"] .production-calendar-legend { color: #b9c4cf; }
:root[data-theme="dark"] .production-calendar-legend i { background: #20262d; }
:root[data-theme="dark"] .production-calendar-legend i.weekend { background: #2a2021; }
:root[data-theme="dark"] .production-calendar-legend i.holiday { background: #3a2424; }
:root[data-theme="dark"] .production-calendar-legend i.working-weekend { background: #172b3e; }
:root[data-theme="dark"] .production-calendar-legend i.shortened { background: #30291c; }
:root[data-theme="dark"] .production-calendar-legend i.regional-holiday { background: #30271a; }
:root[data-theme="dark"] .production-calendar-legend i.legal-holiday { background: #29243c; }
:root[data-theme="dark"] .production-calendar-source-links span { color: #8dc5ff; }
:root[data-theme="dark"] :is(.interest-settings, .penalty-settings, .interest-legal-help) > summary,
:root[data-theme="dark"] .simple-options > summary,
:root[data-theme="dark"] .expense-limit-help > summary,
:root[data-theme="dark"] [data-field="engaged_balance_lookup"].bfo-lookup > summary,
:root[data-theme="dark"] .procedural-mode-toggle { color: #8dc5ff; }

/* Results contain many calculator-specific light panels. Normalize their
   surfaces first, then restore a restrained hierarchy for reusable cards. */
:root[data-theme="dark"] .result-card :where(div, section, article, details, blockquote, p, ul, ol) {
  border-color: #343e48;
  background-color: transparent !important;
}

:root[data-theme="dark"] .result-card :where(
  .detail-item,
  [class*="-metric"],
  [class*="-step"],
  [class*="-tile"],
  [class*="-control-card"],
  [class*="-deadline-card"],
  [class*="-calculation"],
  [class*="-classification"] > div,
  [class*="-date-grid"] > div
) {
  border-color: #35414c;
  background-color: #1d242b !important;
}

:root[data-theme="dark"] .result-card :where(span, small, p, li, summary, blockquote) {
  color: #b8c1ca !important;
}

:root[data-theme="dark"] .result-card :where(h2, h3, h4, strong) {
  color: #edf2f7 !important;
}

:root[data-theme="dark"] .result-card a,
:root[data-theme="dark"] .result-card :is(.copy-button, .value-copy-button, .table-copy-button) {
  color: #86c2ff !important;
}

:root[data-theme="dark"] .result-card :is(.result-formula, .result-explanation, .legal-quote) {
  border-color: #3b4854;
  color: #bdc7d0 !important;
  background-color: #1a2128 !important;
}
:root[data-theme="dark"] .au-monthly-total { border-color: #405c76; background-color: #202f3d !important; }
:root[data-theme="dark"] .au-monthly-total strong { color: #9ecfff !important; }
:root[data-theme="dark"] .au-monthly-partials { border-color: #405263; color: #b8c8d8; }
:root[data-theme="dark"] .au-monthly-partials time { color: #a9c0d6; }

:root[data-theme="dark"] .result-card :is(.result-label, [class*="-label"], [class*="-caption"]) {
  color: #98a5b1 !important;
}

:root[data-theme="dark"] :is(.secondary-button, .text-button, .add-button, .remove-button, .productivity-action, .court-payment-copy-all, .value-copy-button, .currency-swap) {
  border-color: #3a444e;
  color: #b9d8f7;
  background: #1b2229;
}

:root[data-theme="dark"] :is(.secondary-button, .text-button, .add-button, .productivity-action, .value-copy-button, .currency-swap):hover { background: #242d36; }
:root[data-theme="dark"] .currency-result-control .value-copy-button:disabled { color: #a2aeba; background: #171c22; }
:root[data-theme="dark"] .primary-button { color: #fff; }

:root[data-theme="dark"] :is(.error-box, [class*="danger"], [class*="error"], .critical, .expired, .exceeded) {
  border-color: #68413f;
  color: #ffb4ac;
  background-color: #291d1d !important;
}

:root[data-theme="dark"] :is([class*="warning"], [class*="warnings"], .manual_review, .needs_input, .today) {
  border-color: #66522d;
  color: #f0c879;
  background-color: #2a2418 !important;
}

:root[data-theme="dark"] :is(.success-box, [class*="success"], [class*="official"], .upcoming, .start, .remaining, .applies) {
  border-color: #315d48;
  color: #9ed8b7;
  background-color: #17271f !important;
}

:root[data-theme="dark"] .result-card :is(
  [class*="danger"], [class*="error"], .critical, .expired, .exceeded,
  [class*="warning"], [class*="warnings"], .manual_review, .needs_input, .today,
  [class*="success"], [class*="official"], .upcoming, .start, .remaining, .applies
) :where(*) {
  color: inherit !important;
}

:root[data-theme="dark"] .production-calendar-day { color: #d8dee5; background: #20262d; }
:root[data-theme="dark"] .production-calendar-day.weekend { color: #ffaaa5; background: #2a2021; }
:root[data-theme="dark"] .production-calendar-day.holiday { color: #ffb0aa; background: #3a2424; }
:root[data-theme="dark"] .production-calendar-day.working-weekend { color: #89c2ff; background: #172b3e; }
:root[data-theme="dark"] .production-calendar-day.empty { background: transparent; }

:root[data-theme="dark"] .legal-information-summary { border-left-color: #c58b32; background: #2a2419; }
:root[data-theme="dark"] .updates-badge { color: #a9d3ff; background: #203246; }
:root[data-theme="dark"] .legal-information-document section + section { border-color: #2f3740; }
:root[data-theme="dark"] .updates-timeline::before { background: #314153; }
:root[data-theme="dark"] .updates-entry::before { border-color: #171c22; box-shadow: 0 0 0 2px #314153; }
:root[data-theme="dark"] .updates-pagination { border-color: #303b46; }
:root[data-theme="dark"] .updates-pagination a { border-color: #354250; color: #a9d3ff; }
:root[data-theme="dark"] .updates-pagination a:hover { border-color: #52779b; background: #203246; }
:root[data-theme="dark"] .updates-page-current { border-color: #2f8cff; color: #fff; background: #2f8cff; }
:root[data-theme="dark"] .sidebar-backdrop.open { background: rgba(0, 0, 0, .58); }

@media (max-width: 900px) {
  .page-header { position: relative; }
  .page-header-copy { padding-right: 52px; }
  .page-header-tools {
    position: absolute;
    top: -8px;
    right: 0;
    width: auto;
    margin: 0;
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition: none; }
}
