/* Loaded after each page stylesheet. Light colours remain owned by those files. */
:root {
  color-scheme: light;
}

.public-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

button.theme-toggle,
.header-actions button.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1;
}

button.theme-toggle:hover {
  background: var(--accent-light);
  color: var(--accent);
  filter: none;
}

.theme-toggle [data-theme-icon] {
  width: 21px;
  height: 21px;
  pointer-events: none;
}

.theme-toggle [data-theme-icon][hidden] {
  display: none;
}

@media (max-width: 600px) {
  .public-header {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .public-header-actions {
    margin-left: auto;
    flex-wrap: wrap;
    gap: 8px;
  }
  .public-header > small {
    flex-basis: 100%;
    order: 3;
  }
}

/* Screen-only tokens keep the existing privacy print layout on white paper. */
@media screen {
  html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1522;
    --paper: #162233;
    --ink: #e6edf7;
    --muted: #a8b8cc;
    --line: #3b4c63;
    --accent: #8eb2ff;
    --accent-fill: #355ed8;
    --accent-light: #223754;
    --navy: #101c2d;
    --lime: #daf68e;
    --green: #7cd9b0;
    --red: #ffa5af;
    --amber: #f1c27b;
    --purple: #cfb0f4;
    --panel-soft: #1d2c40;
    --panel-hover: #273a53;
    --field: #111e2f;
    --focus: #a4bfff;
    --success-bg: #183c31;
    --success-line: #397c62;
    --danger-bg: #482731;
    --danger-line: #9a5262;
    --warning-bg: #44351f;
    --warning-line: #92703d;
    --purple-bg: #352746;
    --purple-line: #8460a6;
    --shadow: 0 3px 14px #00000026;
  }

  html[data-theme="dark"] body {
    background: var(--bg);
    color: var(--ink);
  }

  /* Keep the default button specificity low so specialised controls retain
     their own layouts, transparent surfaces and semantic variants. */
  :where(html[data-theme="dark"]) button,
  :where(html[data-theme="dark"]) .button {
    background: var(--accent-fill);
    color: #fff;
  }

  html[data-theme="dark"] :is(button.quiet, .button.quiet) {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(button.secondary, .button.secondary) {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(button.text-button, .text-button) {
    background: transparent;
    color: var(--accent);
  }
  html[data-theme="dark"] button.danger {
    background: var(--danger-bg);
    color: var(--red);
    border-color: var(--danger-line);
  }
  html[data-theme="dark"] :is(button, .button):disabled {
    opacity: .65;
  }
  html[data-theme="dark"] :is(button, a, summary):focus-visible {
    outline-color: var(--focus);
  }
  html[data-theme="dark"] :is(input, select, textarea) {
    background: var(--field);
    color: var(--ink);
    border-color: var(--line);
    accent-color: var(--accent);
  }
  html[data-theme="dark"] :is(input, textarea)::placeholder {
    color: var(--muted);
    opacity: 1;
  }
  html[data-theme="dark"] :is(input, select, textarea):focus {
    outline: 3px solid #8eb2ff55;
    border-color: var(--accent);
  }
  html[data-theme="dark"] :is(input, select, textarea):disabled {
    background: var(--panel-soft);
    color: var(--muted);
    opacity: .75;
  }
  html[data-theme="dark"] :is(input, textarea)[readonly] {
    background: var(--panel-soft);
    color: var(--muted);
    border-style: dashed;
  }
  html[data-theme="dark"] :is(input, select, textarea)[aria-invalid="true"] {
    border-color: var(--red);
  }
  html[data-theme="dark"] option,
  html[data-theme="dark"] optgroup {
    background: var(--field);
    color: var(--ink);
  }
  html[data-theme="dark"] input::file-selector-button {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] ::selection {
    background: #466cb0;
    color: #fff;
  }

  /* Shell, menus and overlays. */
  html[data-theme="dark"] :is(.workspace-header, .public-header, .account-menu-panel,
    .mobile-nav, .mobile-more-panel, .subscription-alert-panel, dialog) {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.account-menu-panel, .mobile-more-panel,
    .subscription-alert-panel, dialog) {
    box-shadow: 0 16px 50px #00000055;
  }
  html[data-theme="dark"] .sidebar {
    color: var(--ink);
  }
  html[data-theme="dark"] .brand-mark {
    color: #142337;
  }
  html[data-theme="dark"] .sidebar :is(.brand-caption, .nav-caption, .sidebar-bottom small) {
    color: var(--muted);
  }
  html[data-theme="dark"] .sidebar nav a:hover {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] .sidebar :is(nav a.active, .sidebar-bottom a.active) {
    background: var(--accent-fill);
    color: #fff;
  }
  html[data-theme="dark"] .sidebar-bottom a {
    color: #bfcee1;
  }
  html[data-theme="dark"] .sidebar-tablet-action button {
    background: var(--lime);
    color: #16283e;
  }
  html[data-theme="dark"] .sidebar-tablet-action small {
    color: var(--muted);
  }
  html[data-theme="dark"] .header-summary > a {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] .header-summary > a:hover {
    background: var(--accent-light);
  }
  html[data-theme="dark"] .account-menu summary {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] .account-menu[open] summary {
    background: var(--accent-light);
    border-color: var(--accent);
  }
  html[data-theme="dark"] :is(.account-menu-avatar, .account-id) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--line);
  }
  html[data-theme="dark"] .account-menu-panel :is(a, button) {
    color: var(--ink);
  }
  html[data-theme="dark"] .account-menu-panel :is(a:hover, a.active, button:hover) {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.mobile-nav > a, .mobile-more > summary) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.mobile-nav > a:hover, .mobile-more > summary:hover,
    .mobile-more-links a:hover) {
    background: var(--panel-hover);
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.mobile-nav > a.active, .mobile-more > summary.active,
    .mobile-more[open] > summary, .mobile-more-links a.active) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
  }
  html[data-theme="dark"] .mobile-tablet-action button {
    background: #2d4125;
    color: var(--lime);
  }
  html[data-theme="dark"] .subscription-alert > summary {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.subscription-alert > summary:hover,
    .subscription-alert[open] > summary) {
    background: var(--accent-light);
    border-color: var(--accent);
  }
  html[data-theme="dark"] .subscription-alert #subscription-alert-count {
    border-color: var(--paper);
    background: #b93e56;
    color: #fff;
  }
  html[data-theme="dark"] .subscription-alert-panel article {
    border-color: var(--line);
  }
  html[data-theme="dark"] .subscription-alert-panel article a {
    color: var(--ink);
  }
  html[data-theme="dark"] .subscription-alert-panel > .row > a {
    color: var(--accent);
  }
  html[data-theme="dark"] .subscription-alert-panel p,
  html[data-theme="dark"] .attendance-live-status {
    color: var(--muted);
  }
  html[data-theme="dark"] .attendance-live-status[data-state="connected"]::before {
    background: var(--green);
  }
  html[data-theme="dark"] .attendance-live-status:is([data-state="reconnecting"],
    [data-state="paused"])::before {
    background: var(--amber);
  }
  html[data-theme="dark"] dialog::backdrop {
    background: #02060dcc;
  }
  html[data-theme="dark"] :is(dialog.member-dialog, .member-dialog-header,
    dialog.master-dialog, .master-dialog-header) {
    background: var(--bg);
  }
  html[data-theme="dark"] :is(.skip-link, .stat, .summary-card) {
    background: var(--paper);
    color: var(--ink);
  }
  html[data-theme="dark"] .stat.accent {
    background: var(--accent-light);
    border-color: #526fa2;
  }

  /* Shared table, form feedback and member states. */
  html[data-theme="dark"] th {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] .member-table .member-row:nth-child(even) {
    background: #192739;
  }
  html[data-theme="dark"] :is(.member-row:hover, .member-table .member-row:focus-within) {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] :is(.member-row.selected,
    .member-table .member-row.selected, .member-table .member-row.bulk-selected) {
    background: var(--accent-light);
    border-color: var(--accent);
  }
  html[data-theme="dark"] .avatar,
  html[data-theme="dark"] :is(.filter-chips button.active, .member-bulk-toolbar),
  html[data-theme="dark"] #today-attendance[aria-pressed="true"] {
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.entry-reason, .attendance-calendar-card,
    .attendance-metric, .member-detail-main .detail-tabs) {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] .detail-tabs button {
    background: transparent;
    color: var(--muted);
  }
  html[data-theme="dark"] .detail-tabs button.active {
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.member-detail-main .detail-tabs button.active,
    .month-buttons button.chosen, .month-buttons button[aria-pressed="true"],
    .attendance-calendar button.calendar-day.date-selected,
    .attendance-calendar button.calendar-day.date-selected:hover) {
    background: var(--accent-fill);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 2px #8eb2ff44;
  }
  html[data-theme="dark"] .notice {
    background: var(--accent-light);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.notice.error, .error) {
    background: var(--danger-bg);
    color: var(--red);
    border-color: var(--danger-line);
  }
  html[data-theme="dark"] .notice.success {
    background: var(--success-bg);
    color: var(--green);
    border-color: var(--success-line);
  }
  html[data-theme="dark"] .notice.warning {
    background: var(--warning-bg);
    color: var(--amber);
    border-color: var(--warning-line);
  }
  html[data-theme="dark"] .badge {
    background: var(--panel-soft);
    color: #c0cee0;
  }
  html[data-theme="dark"] :is(.badge.valid, .calendar-day.attended,
    .attendance-calendar button.calendar-day.attended) {
    background: var(--success-bg);
    color: var(--green);
    border-color: var(--success-line);
  }
  html[data-theme="dark"] .badge.expired {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] :is(.badge.warn, .badge.expiring) {
    background: var(--warning-bg);
    color: var(--amber);
  }
  html[data-theme="dark"] :is(.badge.holding, .badge.badge-refunded,
    .hold-notice, .attendance-calendar button.calendar-day.held) {
    background: var(--purple-bg);
    color: var(--purple);
    border-color: var(--purple-line);
  }
  html[data-theme="dark"] .attendance-calendar button.calendar-day {
    background: var(--panel-soft);
    color: var(--ink);
  }
  html[data-theme="dark"] .attendance-calendar button.calendar-day:not(:disabled):hover {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] .attendance-calendar button.calendar-day.date-selected,
  html[data-theme="dark"] .attendance-calendar button.calendar-day.date-selected:hover {
    background: var(--accent-fill);
    color: #fff;
  }
  html[data-theme="dark"] :is(.status-active, .status-paid) {
    --member-tone: var(--green);
    --member-tint: var(--success-bg);
    --member-border: var(--success-line);
  }
  html[data-theme="dark"] :is(.status-holding, .status-scheduled) {
    --member-tone: var(--purple);
    --member-tint: var(--purple-bg);
    --member-border: var(--purple-line);
  }
  html[data-theme="dark"] :is(.status-expired, .status-unpaid) {
    --member-tone: var(--red);
    --member-tint: var(--danger-bg);
    --member-border: var(--danger-line);
  }
  html[data-theme="dark"] :is(.status-expiring, .status-partial) {
    --member-tone: var(--amber);
    --member-tint: var(--warning-bg);
    --member-border: var(--warning-line);
  }
  html[data-theme="dark"] .status-upcoming {
    --member-tone: var(--accent);
    --member-tint: var(--accent-light);
    --member-border: #526fa2;
  }
  html[data-theme="dark"] .status-unregistered {
    --member-tone: #bfcede;
    --member-tint: var(--panel-soft);
    --member-border: var(--line);
  }
  html[data-theme="dark"] .member-status-icon {
    color: var(--bg);
  }
  html[data-theme="dark"] :is(.badge.badge-active, .badge.badge-paid) {
    background: #176449;
    color: #fff;
  }
  html[data-theme="dark"] :is(.badge.badge-holding, .badge.badge-scheduled) {
    background: #7134a1;
    color: #fff;
  }
  html[data-theme="dark"] :is(.badge.badge-expired, .badge.badge-unpaid) {
    background: #a52d3b;
    color: #fff;
  }
  html[data-theme="dark"] :is(.badge.badge-expiring, .badge.badge-partial) {
    background: #86520b;
    color: #fff;
  }
  html[data-theme="dark"] .badge.badge-upcoming {
    background: #2754ac;
    color: #fff;
  }
  html[data-theme="dark"] .badge.badge-unregistered {
    background: #4b5a70;
    color: #fff;
  }
  html[data-theme="dark"] :is(.member-profile-actions button:disabled,
    .member-quick-actions button:disabled, .overview-card button:disabled,
    .member-period button:disabled, .commerce-primary:disabled) {
    background: var(--panel-soft);
    color: var(--muted);
    border-color: var(--line);
    opacity: 1;
  }
  html[data-theme="dark"] .overview-action-complete {
    color: var(--green);
  }
  html[data-theme="dark"] :is(.member-bulk-actions .danger, #bulk-delete-confirm.danger) {
    background: #a52d3b;
    border-color: var(--red);
    color: #fff;
  }
  html[data-theme="dark"] .member-demographic-controls > label {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.member-demographic-controls select.is-filtered,
    .member-demographic-active) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
  }
  html[data-theme="dark"] .member-demographic-active button {
    background: var(--paper);
    color: var(--accent);
    border-color: #526fa2;
  }

  /* Dashboard and charts inherit text/currentColor without changing the data. */
  html[data-theme="dark"] .dashboard-workspace {
    --dashboard-border: var(--line);
    --dashboard-soft: var(--panel-soft);
    --dashboard-hover: var(--panel-hover);
    --dashboard-success-bg: var(--success-bg);
    --dashboard-warning-bg: var(--warning-bg);
    --dashboard-attention-bg: var(--danger-bg);
    --dashboard-attention: var(--red);
    --dashboard-info-bg: var(--accent-light);
    --dashboard-info-ink: var(--accent);
  }
  html[data-theme="dark"] :is(.dashboard-eyebrow, .dashboard-welcome p,
    .dashboard-as-of, .dashboard-number small, .dashboard-card-note,
    .dashboard-state > span, .dashboard-member small, .dashboard-member-meta,
    .dashboard-empty, .dashboard-empty p, .demographic-link-arrow) {
    color: var(--muted);
  }
  html[data-theme="dark"] .dashboard-members {
    background: var(--paper);
  }
  html[data-theme="dark"] .dashboard-card-arrow {
    color: #b6c7df;
  }
  html[data-theme="dark"] :is(.dashboard-card-icon, .dashboard-member-avatar) {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] .dashboard-operation[data-card="expiring"] .dashboard-card-icon {
    background: var(--warning-bg);
    color: var(--amber);
  }
  html[data-theme="dark"] .dashboard-operation[data-card="expired_last_month"] .dashboard-card-icon {
    background: var(--purple-bg);
    color: var(--purple);
  }
  html[data-theme="dark"] .dashboard-operation[data-card="birthday"] .dashboard-card-icon {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .dashboard-member {
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.dashboard-card-footer, .demographic-note a) {
    color: var(--accent);
  }
  html[data-theme="dark"] .dashboard-revenue {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.dashboard-revenue .dashboard-card-note,
    .dashboard-revenue-note, .dashboard-revenue-breakdown span) {
    color: #bdcee4;
  }
  html[data-theme="dark"] :is(.dashboard-state-active i, .dashboard-as-of::before) {
    background: var(--green);
  }
  html[data-theme="dark"] .dashboard-state-holding i {
    background: var(--purple);
  }
  html[data-theme="dark"] .dashboard-state-expiring i {
    background: var(--amber);
  }
  html[data-theme="dark"] .dashboard-state-upcoming i {
    background: var(--accent);
  }
  html[data-theme="dark"] :is(.sex-distribution, .age-bar-track, .demographic-empty) {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] :is(.sex-distribution .male, .demographic-dot.male) {
    background: #83adf0;
  }
  html[data-theme="dark"] :is(.sex-distribution .female, .demographic-dot.female) {
    background: #c6a5e8;
  }
  html[data-theme="dark"] .age-bar-track > span {
    background: var(--age-color, #83adf0);
  }
  html[data-theme="dark"] .sex-legend-link {
    border-color: var(--line);
  }
  html[data-theme="dark"] .demographic-link:hover {
    background: var(--accent-light);
    box-shadow: inset 0 0 0 1px #526fa2;
  }
  html[data-theme="dark"] .demographic-link:active {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] .sex-distribution > a:focus-visible {
    outline-color: #fff;
  }
  html[data-theme="dark"] .chart-bar {
    background: #789bd6;
  }
  html[data-theme="dark"] .chart-column.current .chart-bar {
    background: var(--accent);
  }
  html[data-theme="dark"] .chart-bar.negative {
    background: #e491a1;
  }

  /* Auth, privacy and support. */
  html[data-theme="dark"] :is(.public-auth-links a, .login-support-actions a) {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.public-auth-links a:hover,
    .login-support-actions a:hover, .login-support-actions .login-signup-action) {
    background: var(--accent-light);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.login-action-icon, .privacy-toc a) {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] .privacy-method-guide {
    background: #1b3434;
    border-color: #3c6767;
  }
  html[data-theme="dark"] .privacy-method-guide summary {
    color: var(--green);
  }
  html[data-theme="dark"] .support-dialog {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] .support-dialog .support-close {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.support-eyebrow, .support-consent a,
    .support-overseas summary) {
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.support-intro, .support-attachments small,
    .support-privacy, .support-consent p, .support-overseas, .support-submit-status,
    .support-company, .support-success p, .support-success small) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.support-field > label, .support-consent legend,
    .support-consent-choice) {
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.support-form input:not([type="hidden"]),
    .support-form select, .support-form textarea) {
    background: var(--field);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] .support-form [aria-invalid="true"] {
    border-color: var(--red);
  }
  html[data-theme="dark"] .support-form input[type="file"] {
    background: transparent;
  }
  html[data-theme="dark"] .support-form input[type="file"]::file-selector-button {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.support-attachments, .support-consent) {
    background: var(--panel-soft);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.support-consent-optional, .support-company) {
    border-color: var(--line);
  }
  html[data-theme="dark"] .support-file-list {
    color: var(--accent);
  }
  html[data-theme="dark"] .support-file-list span {
    background: var(--accent-light);
  }
  html[data-theme="dark"] :is(.support-field-error, .support-load-error) {
    color: var(--red);
  }
  html[data-theme="dark"] .support-send {
    background: var(--accent-fill);
    color: #fff;
  }
  html[data-theme="dark"] .support-send:hover {
    background: #426ce6;
  }
  html[data-theme="dark"] .support-success-symbol {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .preview-banner {
    background: var(--warning-bg);
    color: #f4d59c;
    border-color: var(--warning-line);
  }
  html[data-theme="dark"] .preview-banner small {
    color: #e3c99f;
  }

  /* Excel import: review, exclusion, error and selection stay separate. */
  html[data-theme="dark"] .import-steps li {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] .import-steps li > span {
    background: var(--paper);
  }
  html[data-theme="dark"] .import-steps li[aria-current="step"] {
    background: var(--accent-light);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px #526fa2;
  }
  html[data-theme="dark"] .import-steps li[aria-current="step"] > span {
    background: var(--accent-fill);
    color: #fff;
  }
  html[data-theme="dark"] .import-upload {
    background: linear-gradient(130deg, var(--paper), var(--panel-soft));
    border-color: #637da4;
  }
  html[data-theme="dark"] :is(.import-upload-symbol, .import-progress,
    .import-selected-file) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.import-file-picker > span, .import-upload-help,
    .import-column-match, .import-row-messages, .import-commit-bar p,
    .import-empty) {
    color: var(--muted);
  }
  html[data-theme="dark"] .import-upload-help {
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.import-file-type, .import-result-symbol) {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] :is(.import-analysis-label, .import-sheet-controls,
    .import-optional) {
    background: var(--panel-soft);
    color: var(--muted);
    border-color: var(--line);
  }
  html[data-theme="dark"] .import-column {
    border-color: var(--line);
  }
  html[data-theme="dark"] .import-column.is-review {
    background: var(--warning-bg);
    border-color: var(--warning-line);
  }
  html[data-theme="dark"] .is-review .import-column-match {
    color: var(--amber);
  }
  html[data-theme="dark"] :is(.import-column.is-sensitive, .import-column.is-excluded) {
    background: #202b39;
    color: var(--muted);
    border-color: var(--line);
  }
  html[data-theme="dark"] .is-excluded .import-column-match {
    background: #2c3a4c;
    color: #bfcee0;
  }
  html[data-theme="dark"] .import-summary button {
    background: var(--panel-soft);
    color: var(--muted);
    border-color: var(--line);
  }
  html[data-theme="dark"] .import-summary button strong {
    color: var(--ink);
  }
  html[data-theme="dark"] .import-summary button[aria-pressed="true"] {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
  }
  html[data-theme="dark"] .import-summary button[data-import-filter="error"] strong {
    color: var(--red);
  }
  html[data-theme="dark"] .import-summary button:is([data-import-filter="review"],
    [data-import-filter="duplicate"]) strong {
    color: var(--amber);
  }
  html[data-theme="dark"] :is(.import-table-toolbar, .import-table th, .import-table td) {
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.import-table thead, .import-table th) {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] .import-table tbody tr.is-selected {
    background: var(--accent-light);
  }
  html[data-theme="dark"] .import-table tbody tr[data-status="error"] {
    background: #34232e;
  }
  html[data-theme="dark"] .import-table tbody tr[data-status="duplicate"] {
    background: #352e21;
  }
  html[data-theme="dark"] .import-table tbody tr.is-selected[data-status] {
    box-shadow: inset 4px 0 var(--accent);
  }
  html[data-theme="dark"] :is(.import-table td input, .import-table td select) {
    border-color: var(--line);
  }
  html[data-theme="dark"] .import-row-state {
    background: var(--panel-soft);
    color: #bfcee0;
  }
  html[data-theme="dark"] .import-row-state.ready {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .import-row-state.error {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] :is(.import-row-state.review, .import-row-state.duplicate,
    .import-duplicate-allow[aria-pressed="true"]) {
    background: var(--warning-bg);
    color: var(--amber);
    border-color: var(--warning-line);
  }
  html[data-theme="dark"] .import-row-messages .row-error {
    color: var(--red);
  }
  html[data-theme="dark"] .import-commit-bar {
    border-color: #526fa2;
    box-shadow: 0 8px 30px #00000055;
  }
  html[data-theme="dark"] .import-commit-actions > span {
    color: var(--amber);
  }
  html[data-theme="dark"] .import-result > strong {
    color: var(--green);
  }
  html[data-theme="dark"] .import-table input.is-edited {
    border-color: var(--accent);
    background: var(--accent-light);
  }
  html[data-theme="dark"] .import-drop-instruction {
    color: #c5d6ee;
  }
  html[data-theme="dark"] .import-upload.is-dragging {
    background: var(--accent-light);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px #8eb2ff44;
  }
  html[data-theme="dark"] .import-upload.is-dragging .import-upload-symbol {
    background: var(--accent-fill);
    color: #fff;
  }

  /* Revenue and locker layout. */
  html[data-theme="dark"] .billing-workspace {
    --billing-ink: var(--ink);
    --billing-blue: var(--accent);
  }
  html[data-theme="dark"] :is(.billing-eyebrow, .billing-period-form label,
    .billing-period-tabs a, .billing-detail-tabs a, .billing-period-tabs span,
    .billing-card-action, .billing-count, .billing-entry-table small, .billing-empty,
    .billing-pagination, .billing-footnote) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.billing-period-tabs a[aria-current],
    .billing-detail-tabs a[aria-current], .billing-month-table .billing-selected-month) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] .billing-total {
    border-color: var(--line);
  }
  html[data-theme="dark"] .billing-total.accent {
    background: linear-gradient(135deg, #223754, var(--paper));
  }
  html[data-theme="dark"] :is(.billing-refund .billing-card-action,
    .billing-negative) {
    color: var(--red);
  }
  html[data-theme="dark"] .billing-kind {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .billing-kind.is-refund {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] :is(.billing-back-to-trend,
    .billing-chart a.current small, .billing-month-table .billing-selected-month th a) {
    color: var(--accent);
  }
  html[data-theme="dark"] .billing-chart a:hover {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] .billing-month-table tfoot {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] .locker-board-wrap {
    background: var(--field);
  }
  html[data-theme="dark"] .locker-board {
    background-image: linear-gradient(#34455d 1px, transparent 1px),
      linear-gradient(90deg, #34455d 1px, transparent 1px);
  }
  html[data-theme="dark"] :is(.locker-block, .locker-group) {
    background: #233b5c;
    color: #cee0ff;
    border-color: #6380aa;
  }
  html[data-theme="dark"] .locker-block small {
    color: #bfcee0;
  }
  html[data-theme="dark"] :is(.locker-block.selected, .locker-group.selected) {
    background: var(--accent-light);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px #8eb2ff44;
  }
  html[data-theme="dark"] .locker-cell {
    background: var(--panel-soft);
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.locker-cell.occupied,
    .locker-member-choice[data-current="true"]),
  html[data-theme="dark"] #locker-save-state[data-state="saved"],
  html[data-theme="dark"] #save-locker-layout[data-state="saved"]:disabled {
    background: var(--success-bg);
    color: var(--green);
    border-color: var(--success-line);
  }
  html[data-theme="dark"] .locker-cell.expired,
  html[data-theme="dark"] #locker-save-state[data-state="dirty"],
  html[data-theme="dark"] #locker-save-state[data-state="saving"] {
    background: var(--warning-bg);
    color: var(--amber);
    border-color: var(--warning-line);
  }
  html[data-theme="dark"] #locker-save-state[data-state="error"] {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] #save-locker-layout[data-state="error"] {
    background: #a52d3b;
    color: #fff;
  }
  html[data-theme="dark"] .locker-member-results button {
    background: var(--panel-soft);
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.locker-preset[aria-pressed="true"],
    .locker-block[aria-pressed="true"], .locker-member-choice[aria-pressed="true"]),
  html[data-theme="dark"] #custom-locker-group[aria-pressed="true"] {
    background: var(--accent-fill);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px #8eb2ff44;
  }
  html[data-theme="dark"] .locker-cell[aria-pressed="true"] {
    background: var(--accent-light);
    border-color: var(--accent);
    outline-color: var(--accent);
  }
  html[data-theme="dark"] .legend-dot.expired {
    background: var(--amber);
  }
  html[data-theme="dark"] :is(.locker-toolbar button:active,
    .locker-front-panel .actions button:active) {
    background: var(--accent-fill);
    color: #fff;
  }

  /* Product, message and notification surfaces. */
  html[data-theme="dark"] .product-card {
    background: var(--paper);
  }
  html[data-theme="dark"] .product-price {
    color: var(--ink);
  }
  html[data-theme="dark"] .product-price.unset {
    color: var(--muted);
  }
  html[data-theme="dark"] .product-category {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] .product-card-actions .product-delete {
    color: var(--red);
  }
  html[data-theme="dark"] .product-delete-confirm {
    background: var(--danger-bg);
    border-color: var(--danger-line);
  }
  html[data-theme="dark"] .message-wallet > strong {
    color: var(--accent);
  }
  html[data-theme="dark"] .message-section-heading > strong {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.message-readiness .message-small,
    .message-selection-actions small, .message-member small, .message-pagination,
    .message-history-row .row small, .message-history summary,
    .message-preview-facts small, .message-restriction) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.message-readiness .message-small,
    .message-member-list, .message-member, .message-history-row, .message-ledger-row,
    .message-result-list p) {
    border-color: var(--line);
  }
  html[data-theme="dark"] .message-history-row p {
    color: #cfdaea;
  }
  html[data-theme="dark"] .message-dialog {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.message-preview-facts div, .message-preview-body) {
    background: var(--panel-soft);
    border-color: var(--line);
  }
  html[data-theme="dark"] .message-topup-option {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] .message-topup-option:hover {
    background: var(--accent-light);
  }
  html[data-theme="dark"] .notification-mode {
    background: var(--accent-light);
    color: var(--ink);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.notification-mode-icon, .notification-tile-icon) {
    background: var(--panel-soft);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.notification-tile, .notification-row,
    .notification-reason) {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.notification-tile:hover, .notification-reason:hover) {
    background: var(--panel-hover);
    border-color: var(--accent);
  }
  html[data-theme="dark"] :is(.notification-tile[aria-pressed="true"],
    .notification-channels button[aria-pressed="true"],
    .notification-reason[aria-pressed="true"]) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px #8eb2ff44;
  }
  html[data-theme="dark"] .notification-tile[aria-pressed="true"] .notification-tile-icon {
    background: #2a4369;
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.notification-tile strong,
    .notification-row-member > a, .notification-row-member > strong) {
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.notification-empty, .notification-row-member > small,
    .notification-reason > small, .notification-pagination) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.notification-toolbar, .notification-row details,
    .notification-excluded-heading, .notification-pagination) {
    border-color: var(--line);
  }
  html[data-theme="dark"] .notification-chip {
    background: var(--panel-soft);
    color: #bfcee0;
  }
  html[data-theme="dark"] :is(.notification-chip-sms, .notification-chip-accepted,
    .notification-chip-processing) {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.notification-chip-alimtalk, .notification-chip-unknown) {
    background: var(--warning-bg);
    color: var(--amber);
  }
  html[data-theme="dark"] :is(.notification-chip-simulation, #notification-simulation-result) {
    background: var(--purple-bg);
    color: var(--purple);
  }
  html[data-theme="dark"] .notification-chip-delivered {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .notification-chip-failed {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] :is(.notification-row summary, .notification-reason-count) {
    color: var(--accent);
  }
  html[data-theme="dark"] .notification-message {
    background: var(--panel-soft);
    color: var(--ink);
  }
  html[data-theme="dark"] .notification-reason-note {
    color: var(--amber);
  }

  /* Contract and checkout pages; the external payment provider is separate. */
  html[data-theme="dark"] .subscription-shortcuts {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] .subscription-shortcuts a {
    color: var(--muted);
  }
  html[data-theme="dark"] .subscription-shortcuts a:hover {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] .subscription-shortcuts a[aria-selected="true"] {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.subscription-state-description, .subscription-facts small,
    .subscription-note small, .subscription-online-summary p, .subscription-waiting > span,
    .subscription-methods strong, .subscription-methods small, .subscription-current-payment p,
    .subscription-legacy-test summary, .subscription-payment-guide p,
    .commerce-plan-heading small, .commerce-help, .commerce-plan-benefits, .commerce-terms,
    .commerce-facts dt, .commerce-empty, .commerce-order p, .commerce-order small) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.subscription-facts > div, .subscription-waiting,
    .subscription-methods li, .commerce-methods li, .commerce-unavailable) {
    background: var(--panel-soft);
    border-color: var(--line);
  }
  html[data-theme="dark"] .subscription-online {
    background: var(--paper);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.subscription-online-summary, .subscription-current-payment,
    .subscription-payment-guide) {
    background: var(--accent-light);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.subscription-payment-symbol,
    .subscription-payment-guide > span, .subscription-methods li > span,
    .subscription-empty-icon) {
    background: var(--panel-soft);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.subscription-current-payment > span,
    .subscription-notice-editor summary, .commerce-methods li > span) {
    color: var(--accent);
  }
  html[data-theme="dark"] .subscription-test {
    background: var(--purple-bg);
    color: var(--purple);
  }
  html[data-theme="dark"] .subscription-connection.is-ready::before {
    background: var(--green);
  }
  html[data-theme="dark"] :is(.subscription-notice-editor, .commerce-history) {
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.subscription-pending, .subscription-grace,
    .subscription-expiring, .subscription-scheduled, .commerce-test-banner,
    .commerce-test-chip) {
    background: var(--warning-bg);
    color: var(--amber);
  }
  html[data-theme="dark"] :is(.subscription-confirmed, .subscription-active,
    .subscription-trial, .commerce-order .commerce-order-paid) {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] :is(.subscription-expired, .subscription-suspended,
    .subscription-changed, .commerce-order .commerce-order-failed,
    .commerce-order .commerce-order-review, .commerce-order .commerce-order-unknown) {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] .subscription-notice-form .errorlist {
    color: var(--red);
  }
  html[data-theme="dark"] .commerce-plan-card {
    background: linear-gradient(145deg, var(--accent-light), var(--paper) 72%);
    border-color: #526fa2;
  }
  html[data-theme="dark"] .commerce-plan-icon {
    color: #172a44;
  }
  html[data-theme="dark"] .commerce-plan-benefits li::marker {
    color: var(--lime);
  }
  html[data-theme="dark"] :is(.commerce-detail-card, .commerce-order,
    .commerce-plan-choice) {
    background: var(--paper);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.commerce-card-heading .badge,
    .commerce-order .commerce-order-refunded, .commerce-order .commerce-order-cancelled) {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] .commerce-unavailable {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.commerce-feedback, .commerce-admin-feedback) {
    background: var(--success-bg);
    color: var(--green);
    border-color: var(--success-line);
  }
  html[data-theme="dark"] :is(.commerce-feedback.is-error,
    .commerce-admin-feedback.is-error) {
    background: var(--danger-bg);
    color: var(--red);
    border-color: var(--danger-line);
  }
  html[data-theme="dark"] .commerce-plan-choice:has(input:checked) {
    background: var(--accent-light);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px #8eb2ff44;
  }
  html[data-theme="dark"] .commerce-plan-choice small {
    color: var(--accent);
  }

  /* Service operator and price administration. */
  html[data-theme="dark"] :is(.master-overview-card, .master-info-strip,
    .master-contract-note) {
    background: var(--paper);
  }
  html[data-theme="dark"] .master-state-banner {
    background: var(--success-bg);
    border-color: var(--success-line);
    border-left-color: var(--green);
  }
  html[data-theme="dark"] :is(.master-state-expired, .master-state-suspended) {
    background: var(--danger-bg);
    border-color: var(--danger-line);
    border-left-color: var(--red);
  }
  html[data-theme="dark"] :is(.master-state-expiring, .master-state-scheduled) {
    background: var(--warning-bg);
    border-color: var(--warning-line);
    border-left-color: var(--amber);
  }
  html[data-theme="dark"] .master-state-trial {
    background: var(--accent-light);
    border-color: #526fa2;
    border-left-color: var(--accent);
  }
  html[data-theme="dark"] .master-detail-tabs {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] .master-detail-tabs button {
    background: transparent;
    color: var(--muted);
  }
  html[data-theme="dark"] .master-detail-tabs button.active {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] .commerce-admin-connection {
    background: var(--panel-soft);
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.commerce-admin-connection p,
    .commerce-admin td small, .commerce-admin-note, .commerce-admin-empty,
    .commerce-price-editor summary small, .commerce-price-field small) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.commerce-admin-connection > .badge,
    .commerce-price-meta .badge) {
    background: var(--paper);
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.commerce-admin-table, .commerce-admin td,
    .commerce-price-form) {
    border-color: var(--line);
  }
  html[data-theme="dark"] .commerce-admin th {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] .commerce-admin-refund {
    color: var(--red);
  }
  html[data-theme="dark"] .commerce-admin-state-paid {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .commerce-admin-state-refunded {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.commerce-admin-state-unknown,
    .commerce-admin-state-review, .commerce-admin-state-refund_pending) {
    background: var(--warning-bg);
    color: var(--amber);
  }
  html[data-theme="dark"] .commerce-admin-empty h3 {
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.commerce-price-new summary, .commerce-price-form) {
    background: var(--panel-soft);
  }
  html[data-theme="dark"] :is(.commerce-price-plus, .commerce-price-publish) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] .commerce-price-edit-label {
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] .commerce-price-form .errorlist {
    color: var(--red);
  }

  /* Tablet setup and the public kiosk retain their branded surround. */
  html[data-theme="dark"] .tablet-mode-card {
    background: linear-gradient(115deg, var(--paper) 45%, var(--accent-light));
  }
  html[data-theme="dark"] :is(.tablet-feature-label, .settings-icon) {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.tablet-mode-safety, .tablet-mode-benefits,
    .tablet-preview-caption, .tablet-device-empty, .settings-test-note,
    .tablet-device-history summary, .tablet-device-history time) {
    color: var(--muted);
  }
  html[data-theme="dark"] :is(.tablet-preview-screen, .tablet-device-empty,
    .settings-channel-toggles label, .tablet-device-history summary span) {
    background: var(--panel-soft);
    border-color: var(--line);
  }
  html[data-theme="dark"] .tablet-preview-code i {
    background: var(--accent-light);
    border-color: #526fa2;
  }
  html[data-theme="dark"] .tablet-preview-pad span {
    background: var(--field);
  }
  html[data-theme="dark"] :is(.tablet-toggle, .tablet-advanced,
    .tablet-device-history) {
    border-color: var(--line);
  }
  html[data-theme="dark"] .tablet-toggle-state {
    background: #64758c;
  }
  html[data-theme="dark"] .tablet-toggle input:checked + .tablet-toggle-state {
    background: var(--accent-fill);
  }
  html[data-theme="dark"] .tablet-device-row [data-device-status] {
    background: var(--accent-light);
    color: var(--accent);
  }
  html[data-theme="dark"] :is(.tablet-advanced summary, .settings-help summary) {
    color: var(--accent);
  }
  html[data-theme="dark"] .tablet-device-count {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .tablet-device-history .tablet-device-row small {
    background: var(--panel-soft);
    color: var(--muted);
  }
  html[data-theme="dark"] body.kiosk-shell {
    background: #101c2d;
    color: var(--ink);
  }
  html[data-theme="dark"] .kiosk-shell .public-header {
    background: transparent;
  }
  html[data-theme="dark"] :is(.kiosk-card, .kiosk-manager-card) {
    background: var(--paper);
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.kiosk-manager-icon, .kiosk-choices [data-selection]) {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #526fa2;
  }
  html[data-theme="dark"] :is(.kiosk-card-caption, .kiosk-manager-eyebrow,
    .kiosk-manager-cancel, .kiosk-other-login, .kiosk-manager-card .kiosk-manager-hint,
    .kiosk-keypad .key-action, .kiosk-choices p, .kiosk-privacy-hint) {
    color: var(--muted);
  }
  html[data-theme="dark"] .kiosk-manager-card .kiosk-manager-hint {
    border-color: var(--line);
  }
  html[data-theme="dark"] :is(.kiosk-code-slots span, .kiosk-keypad button, .keypad button) {
    background: var(--panel-soft);
    color: var(--ink);
    border-color: var(--line);
  }
  html[data-theme="dark"] .kiosk-code-slots span:empty::after {
    color: #8598b2;
  }
  html[data-theme="dark"] .kiosk-code-slots span.is-next {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px #8eb2ff44;
  }
  html[data-theme="dark"] .kiosk-code-field:focus-within .kiosk-code-slots span.is-next {
    outline-color: var(--focus);
  }
  html[data-theme="dark"] .kiosk-keypad button:hover {
    background: var(--panel-hover);
  }
  html[data-theme="dark"] :is(.kiosk-keypad button:active,
    .kiosk-keypad button:focus-visible) {
    background: var(--accent-light);
    outline-color: var(--focus);
  }
  html[data-theme="dark"] :is(.kiosk-result[data-state="success"],
    .kiosk-result[data-state="duplicate"]) {
    background: var(--success-bg);
    color: var(--green);
  }
  html[data-theme="dark"] .kiosk-result[data-state="error"] {
    background: var(--danger-bg);
    color: var(--red);
  }
  html[data-theme="dark"] .kiosk-result[data-state="working"] {
    color: var(--accent);
  }
  html[data-theme="dark"] .kiosk-choices [data-selection][aria-pressed="true"] {
    background: var(--accent-fill);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px #8eb2ff44;
  }
  html[data-theme="dark"] .kiosk-state-icon {
    background: var(--warning-bg);
    color: var(--amber);
  }
}

@media print {
  :root {
    color-scheme: light;
  }
  button.theme-toggle,
  .header-actions button.theme-toggle,
  .mobile-nav,
  .owner-workspace .mobile-nav {
    display: none;
  }
}
