/* Semantic theme layer. The default values match the existing Portal palette. */
:root {
  --theme-page: #f5f5f6; --theme-card: #ffffff; --theme-raised: #ffffff; --theme-overlay: #ffffff;
  --theme-primary: #09b3a0; --theme-primary-hover: #078f80; --theme-primary-text: #102024;
  --theme-secondary: #ffffff; --theme-secondary-hover: #f1f2f4; --theme-secondary-text: #1f1f23; --theme-secondary-border: #e3e5e8;
  --theme-text: #1f1f23; --theme-muted: #72757e; --theme-border: #e3e5e8;
  --theme-danger: #b91c1c; --theme-warning: #d88500; --theme-success: #06966f; --theme-info: #1d4ed8;
  --theme-header: #ffffff; --theme-footer: #ffffff; --theme-menu: #ffffff; --theme-submenu: #ffffff;
  --theme-menu-text: #23252d; --theme-menu-hover: #f1f2f4;
  --theme-table: #ffffff; --theme-table-header: #f8f9fa; --theme-table-hover: #f3f4f6;
  --theme-input: #ffffff; --theme-input-text: #1f1f23; --theme-placeholder: #72757e;
  --theme-focus: #09b3a0; --theme-icon: #262932; --theme-shadow: #0f172a;
  --bg: var(--theme-page); --card: var(--theme-card); --text: var(--theme-text);
  --muted: var(--theme-muted); --primary: var(--theme-primary); --border: var(--theme-border);
}
html[data-theme-active] { --brand: var(--theme-primary); --success: var(--theme-success); --danger: var(--theme-danger); --warning: var(--theme-warning); --info: var(--theme-info); }
html[data-theme-active] { background: var(--theme-page); }
html[data-theme-active] body { color: var(--theme-text); background: var(--theme-page); }
html[data-theme-active] :is(.app-top-banner, .top-banner-profile-btn) { background: var(--theme-header); color: var(--theme-text); }
html[data-theme-active] footer { background: var(--theme-footer); color: var(--theme-muted); border-color: var(--theme-border); }
html[data-theme-active] .sidebar-nav { background: var(--theme-menu); color: var(--theme-menu-text); }
html[data-theme-active] .submenu-list { background: var(--theme-submenu); border-radius: calc(8px * var(--app-component-scale, 1)); }
html[data-theme-active] :is(.menu-item, .menu-item svg, .menu-caret-pair) { color: var(--theme-menu-text); }
html[data-theme-active] :is(.menu-item.active, .menu-item:hover, .submenu-item.active, .submenu-item:hover) { background: var(--theme-menu-hover); color: var(--theme-menu-text); }
html[data-theme-active] .submenu-item { color: var(--theme-muted); }
html[data-theme-active] :is(.panel-card, .metric-card, .modal-card, .card, .table-wrap, .role-badge, .ghost-btn) { background: var(--theme-card); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.record-modal-card, .attachment-modal-card) { background: var(--theme-overlay); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(input, select, textarea) { background-color: var(--theme-input); color: var(--theme-input-text); border-color: var(--theme-border); }
html[data-theme-active] :is(input, textarea)::placeholder { color: var(--theme-placeholder); }
html[data-theme-active] :is(input, select, textarea, button, a):focus-visible { outline: 2px solid var(--theme-focus); outline-offset: 2px; }
html[data-theme-active] :is(.simple-table, table) { color: var(--theme-text); background: var(--theme-table); }
html[data-theme-active] :is(.simple-table, table) :is(th, td) { border-color: var(--theme-border); color: var(--theme-text); }
html[data-theme-active] :is(.simple-table, table) th { background: var(--theme-table-header); }
html[data-theme-active] :is(.simple-table, table) tr:hover td { background: var(--theme-table-hover); }
html[data-theme-active] :is(.muted, .dashboard-header p, .metric-head) { color: var(--theme-muted); }
html[data-theme-active] .icon { color: var(--theme-icon); }
html[data-theme-active] :is(.success, .tone-good, .email-status--sent) { color: var(--theme-success); }
html[data-theme-active] :is(.danger, .tone-bad, .error-text, .menu-logout-item, .email-status--failed) { color: var(--theme-danger); }
html[data-theme-active] :is(.warn, .tone-warn) { color: var(--theme-warning); }
html[data-theme-active] :is(.info, .tone-info, .email-status--outgoing) { color: var(--theme-info); }
html[data-theme-active] :is(.email-status--sent, .email-status--failed, .email-status--outgoing) { background: var(--theme-raised); }
html[data-theme-active] :is(.record-modal, .attachment-modal) { background: color-mix(in srgb, var(--theme-shadow) 55%, transparent); }
html[data-theme-active] :is(.global-loading-layer, .loading-overlay) { background: color-mix(in srgb, var(--theme-shadow) 60%, transparent); }
html[data-theme-active] :is(.mobile-menu-btn, .profile-picture-preview, .profile-picture-preview--image, .entity-history-panel) { background: var(--theme-card); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.role-badge, .entity-history-item) { background: var(--theme-raised); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] .mobile-pull-refresh-orb { color: var(--theme-primary); }
html[data-theme-active][data-theme-mode="dark"] .mobile-pull-refresh-orb { background: color-mix(in srgb, var(--theme-card) 92%, transparent); border-color: var(--theme-border); }
/* The supplied brand artwork is designed for light surfaces. Invert it whenever
   the effective theme has a dark page, including dark custom themes. */
html[data-theme-active][data-theme-mode="dark"] img[src$="/assets/pa-logo.png"] { filter: invert(1); }
html[data-theme-active] :is(.breakdown-table th, .breakdown-table td, .attachment-type, .back-to-top-btn) { color: var(--theme-text); }
html[data-theme-active] :is(.table-btn, .form-actions button, .pwa-install-confirm) { background: var(--theme-primary); color: var(--theme-primary-text); border-color: var(--theme-primary); }
html[data-theme-active] :is(.table-btn, .form-actions button, .pwa-install-confirm):hover { background: var(--theme-primary-hover); border-color: var(--theme-primary-hover); }
html[data-theme-active] :is(.danger-btn, .table-delete-btn) { background: var(--theme-danger); color: var(--theme-page); border-color: var(--theme-danger); }
html[data-theme-active] .back-to-top-btn:hover { background: var(--theme-menu-hover); color: var(--theme-primary); border-color: var(--theme-primary); }
html[data-theme-active] input:disabled, html[data-theme-active] select:disabled, html[data-theme-active] textarea:disabled { background: var(--theme-raised); color: var(--theme-muted); }
html[data-theme-active] .theme-primary-button { background: var(--theme-primary); color: var(--theme-primary-text); }
html[data-theme-active] .theme-primary-button:hover { background: var(--theme-primary-hover); }
html[data-theme-active] :is(.import-file-dropzone, .cleanup-source-empty) { background: var(--theme-raised); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.import-file-dropzone:hover, .import-file-dropzone:focus-within, .import-file-dropzone.dragover) { background: var(--theme-menu-hover); border-color: var(--theme-focus); }
html[data-theme-active] :is(.import-file-dropzone .title, .import-file-dropzone .sub b, .import-file-selected) { color: var(--theme-text); }
html[data-theme-active] :is(.import-file-dropzone .sub, .import-file-dropzone svg) { color: var(--theme-muted); }
html[data-theme-active] :is(.cleanup-summary-card, .cleanup-source-card, .cleanup-diagnostics-card, .interactive-draw-card) { background: var(--theme-card); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.draw-title, .winner-name, .winner-ticket) { color: var(--theme-text); }
html[data-theme-active] :is(.gift-description, .spinner-text) { color: var(--theme-muted); }
html[data-theme-active] .spinner-wrap { border-color: var(--theme-border); border-top-color: var(--theme-info); }
html[data-theme-active] .draw-btn { background: var(--theme-primary); color: var(--theme-primary-text); }
html[data-theme-active] :is(.chart-wrap, .recent-transactions-table tr, .insight-potential-impact) { background: var(--theme-card); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.metric-label, .metric-note, .data-table th, .recent-transactions-table td::before) { color: var(--theme-muted); }
html[data-theme-active] :is(.metric-value, .insight-potential-impact strong) { color: var(--theme-text); }
html[data-theme-active] :is(.bar-track, .stack-track) { background: var(--theme-raised); }
html[data-theme-active] :is(.sales-target-chip, .insight-chip, .filter-chip) { background: var(--theme-raised); color: var(--theme-text); }
html[data-theme-active] :is(.sales-target-chip.good, .insight-chip.good, .filter-chip.category) { background: color-mix(in srgb, var(--theme-success) 15%, var(--theme-card)); color: var(--theme-text); }
html[data-theme-active] :is(.sales-target-chip.warn, .insight-chip.warn, .filter-chip.vendor) { background: color-mix(in srgb, var(--theme-warning) 15%, var(--theme-card)); color: var(--theme-text); }
html[data-theme-active] :is(.sales-target-chip.alert, .insight-chip.bad) { background: color-mix(in srgb, var(--theme-danger) 15%, var(--theme-card)); color: var(--theme-text); }
html[data-theme-active] .filter-chip.date { background: color-mix(in srgb, var(--theme-info) 15%, var(--theme-card)); color: var(--theme-text); }
/* Shared list filters, sorting, and column menus. */
html[data-theme-active] :is(.reusable-filter, .reusable-list-sort, .reusable-column-selector) { color: var(--theme-text); }
html[data-theme-active] :is(.reusable-filter__bar, .reusable-filter__dropdown, .reusable-filter__modal, .reusable-list-sort__dropdown, .reusable-column-selector__dropdown, .reusable-column-selector__toggle, .reusable-list-sort__toggle, .reusable-filter__modal-actions button) { background: var(--theme-card); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.reusable-filter__chip, .reusable-filter__top-card, .reusable-filter__groups-grid .reusable-filter__group) { background: var(--theme-raised); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] :is(.reusable-filter__menu-row, .reusable-filter__input, .reusable-filter__group-title, .reusable-filter__modal-grid label) { color: var(--theme-text); }
html[data-theme-active] :is(.reusable-filter__section-title, .reusable-filter__chip-remove, .reusable-filter__toggle, .reusable-filter__modal-x, .reusable-filter__remove-rule, .reusable-list-sort__empty, .reusable-column-selector__empty) { color: var(--theme-muted); }
html[data-theme-active] :is(.reusable-filter__menu-row:hover, .reusable-filter__menu-row:focus-visible, .reusable-filter__toggle:hover, .reusable-filter__chip-remove:hover, .reusable-filter__modal-x:hover, .reusable-filter__remove-rule:hover, .reusable-list-sort__row:hover, .reusable-list-sort__toggle:hover, .reusable-column-selector__row:hover, .reusable-column-selector__toggle:hover) { background: var(--theme-menu-hover); color: var(--theme-text); }
html[data-theme-active] :is(.reusable-filter__link, .reusable-filter__check) { color: var(--theme-info); }
html[data-theme-active] .reusable-filter__delete { color: var(--theme-danger); }
html[data-theme-active] :is(.reusable-column-selector__checkbox, .reusable-list-sort__row input) { accent-color: var(--theme-primary); }
html[data-theme-active] .reusable-filter__modal-actions button[data-primary="true"] { background: var(--theme-primary); color: var(--theme-primary-text); border-color: var(--theme-primary); }
html[data-theme-active] :is(.split-save-menu, .feature-group) { background: var(--theme-card); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] .split-save-menu button { background: transparent; color: var(--theme-text); }
html[data-theme-active] .split-save-menu button:hover { background: var(--theme-menu-hover); }
html[data-theme-active] .split-save-toggle { background: var(--theme-primary); color: var(--theme-primary-text); }
html[data-theme-active] :is(#usersTbody, #rolesTbody) .list-action-btn { background: transparent; color: var(--theme-icon); }
html[data-theme-active] :is(#usersTbody, #rolesTbody) .list-action-btn[data-edit]:hover .list-action-icon { color: var(--theme-info); }
html[data-theme-active] :is(#usersTbody, #rolesTbody) .list-action-btn[data-del]:hover .list-action-icon { color: var(--theme-danger); }
@media (min-width:901px) {
  html[data-theme-active] .simple-table .list-action-btn { color: var(--theme-icon) !important; }
  html[data-theme-active] .simple-table .dn-approve-btn:hover { color: var(--theme-success) !important; }
  html[data-theme-active] .simple-table .dn-submit-btn:hover { color: var(--theme-info) !important; }
  html[data-theme-active] .simple-table .dn-reject-btn:hover { color: var(--theme-danger) !important; }
}

/* Buttons are primary by default on every page, including buttons built in JavaScript. */
html[data-theme-active] button:not(:where(.app-tab)) {
  background: var(--theme-primary);
  color: var(--theme-primary-text);
  border-color: var(--theme-primary);
}
html[data-theme-active] button:not(:disabled, :where(.app-tab)):hover {
  background: var(--theme-primary-hover);
  border-color: var(--theme-primary-hover);
}
/* Back to top is a structural control: keep only its arrow and circular outline visible. */
html[data-theme-active] .back-to-top-btn,
html[data-theme-active] .back-to-top-btn:not(:disabled):hover {
  background: transparent;
  color: var(--theme-primary);
  border-color: var(--theme-primary);
  box-shadow: none;
}
/* Navigation controls are structural controls, never primary action buttons. */
html[data-theme-active] :is(.app-top-banner-brand, .app-top-banner .menu-item, .app-top-banner .submenu-item) {
  background: transparent;
  color: var(--theme-menu-text);
  border-color: transparent;
}
html[data-theme-active] .app-top-banner .submenu-list .submenu-list:not(.app-menu-panel) {
  background: transparent;
  border-radius: 0;
}
html[data-theme-active] :is(.app-top-banner .menu-item, .app-top-banner .submenu-item):not(:disabled):hover,
html[data-theme-active] :is(.menu-entry.active, .menu-entry.active-ancestor) > :is(.menu-item, .submenu-item) {
  background: var(--theme-menu-hover);
  color: var(--theme-menu-text);
  border-color: transparent;
}
html[data-theme-active] .app-top-banner-brand:not(:disabled):hover {
  background: transparent;
  color: var(--theme-text);
  border-color: transparent;
}
@media (max-width: 900px) {
  html[data-theme-active] .app-top-banner .submenu-list {
    background: transparent;
    border-radius: 0;
  }
}
/* Search choices and text actions are menu controls, not primary actions. */
html[data-theme-active] :is(.reusable-filter__menu-row, .reusable-filter__link) {
  background: transparent;
  color: var(--theme-text);
  border-color: transparent;
}
html[data-theme-active] .reusable-filter__link { color: var(--theme-info); }
html[data-theme-active] :is(.reusable-filter__menu-row, .reusable-filter__link):not(:disabled):hover,
html[data-theme-active] :is(.reusable-filter__menu-row, .reusable-filter__link):focus-visible {
  background: var(--theme-menu-hover);
  border-color: transparent;
}
/* Secondary controls keep a surface treatment instead of becoming primary actions. */
html[data-theme-active] :is(.secondary-btn, .ghost-btn, .top-banner-profile-btn, .mobile-menu-btn, .reusable-filter__toggle, .reusable-list-sort__toggle, .reusable-column-selector__toggle, .rte-btn) {
  background: var(--theme-secondary);
  color: var(--theme-secondary-text);
  border-color: var(--theme-secondary-border);
}
html[data-theme-active] :is(.secondary-btn, .ghost-btn, .top-banner-profile-btn, .mobile-menu-btn, .reusable-filter__toggle, .reusable-list-sort__toggle, .reusable-column-selector__toggle, .rte-btn):not(:disabled):hover {
  background: var(--theme-secondary-hover);
  color: var(--theme-secondary-text);
  border-color: var(--theme-focus);
}
/* A popup has one primary save/create action; its remaining non-danger actions are secondary. */
html[data-theme-active] :is(.record-modal, .attachment-modal) button:not(.app-tab),
html[data-theme-active] .form-actions .ghost-btn {
  background: var(--theme-secondary);
  color: var(--theme-secondary-text);
  border-color: var(--theme-secondary-border);
}
html[data-theme-active] :is(.record-modal, .attachment-modal) button:not(.app-tab):not(:disabled):hover,
html[data-theme-active] .form-actions .ghost-btn:not(:disabled):hover {
  background: var(--theme-secondary-hover);
  color: var(--theme-secondary-text);
  border-color: var(--theme-focus);
}
html[data-theme-active] :is(.record-modal, .attachment-modal) :is(button[type="submit"], button[id*="save" i], .theme-primary-button):not([role=menuitem],[aria-haspopup=menu]),
html[data-theme-active] :is(.record-modal, .attachment-modal) :is(.save-split-toggle, .split-save-toggle, .transfer-save-toggle) {
  background: var(--theme-primary);
  color: var(--theme-primary-text);
  border-color: var(--theme-primary);
}
html[data-theme-active] :is(.record-modal, .attachment-modal) :is(button[type="submit"], button[id*="save" i], .theme-primary-button):not([role=menuitem],[aria-haspopup=menu],:disabled):hover,
html[data-theme-active] :is(.record-modal, .attachment-modal) :is(.save-split-toggle, .split-save-toggle, .transfer-save-toggle):not(:disabled):hover {
  background: var(--theme-primary-hover);
  border-color: var(--theme-primary-hover);
}
html[data-theme-active] :is(.danger-btn, .table-delete-btn, .form-actions .danger-btn, .form-actions .table-delete-btn, .ghost-btn.logout-btn) {
  background: var(--theme-danger);
  color: var(--theme-card);
  border-color: var(--theme-danger);
}
html[data-theme-active] :is(.danger-btn, .table-delete-btn, .form-actions .danger-btn, .form-actions .table-delete-btn, .ghost-btn.logout-btn):not(:disabled):hover {
  background: color-mix(in srgb, var(--theme-danger) 85%, var(--theme-shadow));
  border-color: var(--theme-danger);
  color: var(--theme-card);
}
html[data-theme-active] :is(.record-modal, .attachment-modal) :is(.danger-btn, .table-delete-btn) {
  background: var(--theme-danger);
  color: var(--theme-card);
  border-color: var(--theme-danger);
}
html[data-theme-active] :is(.record-modal, .attachment-modal) :is(.danger-btn, .table-delete-btn):not(:disabled):hover {
  background: color-mix(in srgb, var(--theme-danger) 85%, var(--theme-shadow));
  color: var(--theme-card);
  border-color: var(--theme-danger);
}
/* Toolbar, tab, chip, and row-icon buttons are controls rather than filled actions. */
html[data-theme-active] :is(.attachment-open-btn, .report-filter-btn, .refresh-icon-btn, .filter-chip button, .app-tab .tab-reload-btn, .split-save-menu button, .save-split-menu button, .transfer-save-menu button, .reusable-filter__menu-row, .reusable-filter__link, .reusable-filter__delete, .reusable-filter__chip-remove, .reusable-filter__modal-x, .reusable-filter__remove-rule) {
  background: transparent;
  color: var(--theme-text);
  border-color: transparent;
}
html[data-theme-active] :is(.attachment-open-btn, .report-filter-btn, .refresh-icon-btn, .filter-chip button, .app-tab .tab-reload-btn, .split-save-menu button, .save-split-menu button, .transfer-save-menu button, .reusable-filter__menu-row, .reusable-filter__link, .reusable-filter__delete, .reusable-filter__chip-remove, .reusable-filter__modal-x, .reusable-filter__remove-rule):not(:disabled):hover {
  background: var(--theme-menu-hover);
  color: var(--theme-text);
  border-color: transparent;
}
html[data-theme-active] .reusable-filter__link {
  color: var(--theme-info);
}
html[data-theme-active] .reusable-filter__delete {
  color: var(--theme-danger);
}
@media (min-width: 901px) {
html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn) {
  background: transparent !important;
  color: var(--theme-icon) !important;
  border-color: transparent !important;
}
html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):not(:disabled):hover {
  background: var(--theme-menu-hover) !important;
}
html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is([data-edit], [data-submit], [data-approve]):is(:hover, :focus-visible) { color: var(--theme-info) !important; }
html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is([data-del], [data-delete], [data-reject], .table-delete-btn, .danger-btn):is(:hover, :focus-visible) { color: var(--theme-danger) !important; }
html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is([data-publish]):is(:hover, :focus-visible) { color: var(--theme-success) !important; }
html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is(:hover, :focus-visible) :is(.list-action-icon, .campaign-action-icon, .vp-action-icon) { color: currentColor !important; }
}
@media (max-width: 900px) {
  html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn) {
    background: var(--theme-secondary) !important;
    color: var(--theme-secondary-text) !important;
    border-color: var(--theme-secondary-border) !important;
  }
  html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):not(:disabled):hover {
    background: var(--theme-secondary-hover) !important;
    border-color: var(--theme-focus) !important;
  }
  html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is([data-submit],[data-approve],[data-publish]) {
    background: var(--theme-primary) !important;
    color: var(--theme-primary-text) !important;
    border-color: var(--theme-primary) !important;
  }
  html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is([data-submit],[data-approve],[data-publish]):not(:disabled):hover {
    background: var(--theme-primary-hover) !important;
    border-color: var(--theme-primary-hover) !important;
  }
  html[data-theme-active] :is(.config-action-btn, .fr-action-btn, .mc-expected-action-btn, .po-action-btn, .campaign-action-btn, .draw-action-btn, .gift-action-btn, .tx-action-btn, .transfer-action-btn, .vp-action-btn, .list-action-btn):is(.danger-btn, .table-delete-btn, .config-delete-btn, .po-delete-btn, [data-del], [data-delete], [data-reject]) {
    background: var(--theme-danger) !important;
    color: var(--theme-card) !important;
    border-color: var(--theme-danger) !important;
  }
}
html[data-theme-active] .theme-list button,
html[data-theme-active] .theme-list button:hover { background: var(--theme-raised); color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-active] .theme-preview-card button,
html[data-theme-active] .theme-preview-card button:hover { background: var(--preview-primary); color: var(--preview-primary-text); border-color: var(--preview-primary); }
html[data-theme-active] .theme-preview-card .theme-preview-secondary,
html[data-theme-active] .theme-preview-card .theme-preview-secondary:hover { background:var(--preview-secondary); color:var(--preview-secondary-text); border-color:var(--preview-secondary-border); }
html[data-theme-active] .theme-preview-card :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { background-color:var(--preview-input); color:var(--preview-input-text); border-color:var(--preview-border); }
html[data-theme-active] .theme-preview-card :is(input[type="checkbox"], input[type="radio"]) { accent-color:var(--preview-primary); }
/* Keep the editor preview isolated from the currently selected application theme. */
html[data-theme-active] .theme-preview-card { background:var(--preview-card); color:var(--preview-text); border-color:var(--preview-border); }
html[data-theme-active] .theme-preview-card table { background:var(--preview-table); color:var(--preview-text); }
html[data-theme-active] .theme-preview-card table :is(th, td) { color:var(--preview-text); border-color:var(--preview-border); }
html[data-theme-active] .theme-preview-card table th { background:var(--preview-table-header); }
html[data-theme-active] .theme-preview-card table tr:hover td { background:var(--preview-table-hover); }
@media (max-width: 900px) {
  /* Tables become record cards on small screens; those cards are themed surfaces too. */
  html[data-theme-active] :is(.simple-table, .recent-transactions-table, .raffle-results-table) tbody tr {
    background:var(--theme-card);
    color:var(--theme-text);
    border-color:var(--theme-border);
  }
  html[data-theme-active] :is(.simple-table, .recent-transactions-table, .raffle-results-table) td::before {
    color:var(--theme-muted);
  }
  html[data-theme-active] .theme-preview-table thead { display:none; }
  html[data-theme-active] .theme-preview-table,
  html[data-theme-active] .theme-preview-table tbody,
  html[data-theme-active] .theme-preview-table tr,
  html[data-theme-active] .theme-preview-table td { display:block; width:100%; }
  html[data-theme-active] .theme-preview-table tr {
    padding:calc(10px * var(--app-component-scale, 1)) calc(12px * var(--app-component-scale, 1));
    border:1px solid var(--preview-border);
    border-radius:calc(10px * var(--app-component-scale, 1));
    background:var(--preview-table);
  }
  html[data-theme-active] .theme-preview-table tr:hover td { background:transparent; }
  html[data-theme-active] .theme-preview-table td {
    display:grid;
    grid-template-columns:minmax(calc(90px * var(--app-component-scale, 1)), 44%) minmax(0, 1fr);
    gap:calc(10px * var(--app-component-scale, 1));
    padding:calc(6px * var(--app-component-scale, 1)) 0;
    border:0;
  }
  html[data-theme-active] .theme-preview-table td::before {
    content:attr(data-label);
    color:var(--preview-muted);
    font-weight:700;
  }
}
/* The centered brand navigates home but must remain visually unfilled. */
html[data-theme-active] .app-top-banner-brand,
html[data-theme-active] .app-top-banner-brand:not(:disabled):hover {
  background: transparent;
  color: var(--theme-text);
  border-color: transparent;
}
/* Keep semantic status colors after generic card and metric text rules. */
html[data-theme-active] :is(.success, .tone-good, .email-status--sent, .metric-value.tone-good) { color: var(--theme-success); }
html[data-theme-active] :is(.warn, .tone-warn, .metric-value.tone-warn) { color: var(--theme-warning); }
html[data-theme-active] :is(.info, .tone-info, .email-status--outgoing, .metric-value.tone-info) { color: var(--theme-info); }
html[data-theme-active] :is(.danger, .tone-bad, .error-text, .email-status--failed, .metric-value.tone-bad) { color: var(--theme-danger); }
