:root {
  color-scheme: light;
  --site-bg: #f4f4f4;
  --site-surface: #ffffff;
  --site-surface-raised: #f4f7fa;
  --site-text: #1c2b39;
  --site-muted: #64748b;
  --site-border: #d9e4f1;
  --site-navy: #265372;
  --site-gold: #fada88;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* Core tokens shared with inline page stylesheets and mobile app palette */
  --bg: #101820;
  --card-bg: #1b2835;
  --ink: #e6edf3;
  --danger: #ff9a95;
  --gold: #fada88;
  --gold-line: #e6c562;
  --night-bg: #101820;
  --night-header: #162433;
  --night-subnav: #192a3c;
  --night-surface: #1b2835;
  --night-raised: #263747;
  --night-elevated: #2f4356;
  --night-border: #3d5266;
  --night-muted: #b4c2cf;
  --night-accent: #acd8f5;

  /* Site-level aliases (also used in faq.html, guest-checkout.html, newsletters.html) */
  --site-bg: #101820;
  --site-surface: #1b2835;
  --site-surface-raised: #263747;
  --site-text: #e6edf3;
  --site-muted: #b4c2cf;
  --site-border: #3d5266;
  --background: #101820;
  --surface: #1b2835;
  --panel: #1b2835;
  --text: #e6edf3;
  --muted: #b4c2cf;
  --border: #3d5266;
  --line: #3d5266;
}

/* ==========================================================================
   Theme Toggle Button (Light + Dark)
   ========================================================================== */
#themeToggleBtn {
  width: 40px;
  height: 40px;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid rgba(28, 28, 28, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  color: #1c3c52;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 17px;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

#themeToggleBtn:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

#themeToggleBtn:focus-visible {
  outline: 3px solid #265372;
  outline-offset: 2px;
}

body,
header,
.site-header,
.dashboard-wrapper,
.dashboard-content,
.content-card,
.editor-section-card,
.card,
.modal-content,
input,
select,
textarea {
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

@media (prefers-reduced-motion: reduce) {
  body,
  body * {
    transition: none !important;
  }
}

/* ==========================================================================
   1. Global Shell, Public Sections & Top Navigation (Dark Mode)
   ========================================================================== */
html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--bg) !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] :is(
  main,
  #homeSection,
  #aboutSection,
  #resourcesSection,
  #trainingsSection,
  #subscriptionsSection,
  #findSubSection,
  #privacySection,
  #privacyEsSection,
  #handbookWorkshopSection,
  #flyerWorkshopSection,
  #newsletterWorkshopSection,
  #dashboardSection,
  #ownerDashboardSection,
  .dashboard-wrapper,
  .dashboard-content,
  .dashboard-content-drkmde,
  .dashboard-content-lghtmde,
  .dashboard-main-content
) {
  background: var(--bg) !important;
  color: var(--ink) !important;
}

/* Sleek Dark Navy Top Header (matching mobile app #appHeader) */
html[data-theme="dark"] :is(header:not(.page-header), .site-header) {
  background: var(--night-header) !important;
  color: var(--ink) !important;
  border-bottom: 1px solid #2c4156 !important;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] :is(
  header .logo,
  .site-header .logo-link,
  header .brand,
  header .brand span
) {
  color: #f8fafc !important;
}

html[data-theme="dark"] :is(
  header nav button:not(.nav-pill-btn):not(#themeToggleBtn),
  .site-nav a,
  header > a:not(.brand),
  #hamburgerBtn
) {
  color: #e6edf3 !important;
}

html[data-theme="dark"] :is(
  header nav button:not(.nav-pill-btn):not(#themeToggleBtn):hover,
  .site-nav a:hover,
  .site-nav a:focus-visible,
  .site-nav a[aria-current="page"],
  header > a:not(.brand):hover,
  #hamburgerBtn:hover
) {
  color: var(--gold) !important;
}

html[data-theme="dark"] .nav-pill-btn {
  background: var(--gold) !important;
  color: #101820 !important;
  border: 1px solid var(--gold) !important;
}

html[data-theme="dark"] .nav-pill-btn:hover {
  background: #ffe39e !important;
  color: #101820 !important;
}

html[data-theme="dark"] #themeToggleBtn {
  background: var(--night-raised) !important;
  color: var(--gold) !important;
  border-color: rgba(250, 218, 136, 0.45) !important;
}

html[data-theme="dark"] #themeToggleBtn:hover {
  background: var(--night-elevated) !important;
}

html[data-theme="dark"] #themeToggleBtn:focus-visible {
  outline-color: var(--gold);
}

/* Hamburger Dropdown Menu */
html[data-theme="dark"] #dropdownMenu {
  background: var(--card-bg) !important;
  color: var(--ink) !important;
  border: 1px solid var(--night-border) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45) !important;
}

html[data-theme="dark"] .dropdown-item {
  background: transparent !important;
  color: var(--ink) !important;
  border-bottom-color: var(--night-border) !important;
}

html[data-theme="dark"] .dropdown-item:hover {
  background: var(--night-raised) !important;
  color: var(--gold) !important;
}

/* Sticky Logged-In Dashboard Secondary Nav */
html[data-theme="dark"] :is(
  #loggedInDashboardNav,
  #loggedInDashboardNav .logged-in-dashboard-nav-left,
  #loggedInDashboardNav .logged-in-dashboard-nav-tabs,
  .dashboard-top-nav,
  .dashboard-top-nav-left,
  .dashboard-top-nav-tabs
) {
  background: var(--night-subnav) !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] :is(#loggedInDashboardNav, .dashboard-top-nav) {
  border-bottom: 1px solid var(--night-border) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32) !important;
}

html[data-theme="dark"] .tab-btn {
  background: transparent !important;
  color: #cbd5e1 !important;
  border: 1px solid transparent !important;
}

html[data-theme="dark"] .tab-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

html[data-theme="dark"] :is(
  .tab-btn.active,
  .dashboard-top-nav-tabs .tab-btn.active,
  .logged-in-dashboard-nav-tabs .tab-btn.active
) {
  background: rgba(250, 218, 136, 0.14) !important;
  color: var(--gold) !important;
  border-color: rgba(250, 218, 136, 0.5) !important;
}

/* Footer */
html[data-theme="dark"] footer {
  background: #0b1218 !important;
  color: var(--night-muted) !important;
  border-top: 1px solid #233343 !important;
}

/* ==========================================================================
   2. Primary Card Surfaces & Modals
   ========================================================================== */
html[data-theme="dark"] :is(
  .app-container,
  .content-card,
  .dashboard-card,
  .dashboard-summary-card,
  .dashboard-card-block,
  .dashboard-stat-card,
  .dashboard-tab-shell,
  .metric-card,
  #licensingTrackerCard,
  .editor-section-card,
  .editor-save-bar,
  .profile-card-shell,
  .profile-id-card,
  .record-editor,
  .staff-card,
  .staff-member-card,
  .training-card,
  .training-hub-panel,
  .training-hub-card,
  .training-library-card,
  .pathway-card,
  .resource-main-card,
  .resource-card,
  .resource-link,
  .legal-disclaimer-card,
  .sub-card,
  .sub-board-card,
  .sub-tier-card,
  .sub-purchase-section,
  .sub-comparison-card,
  .sub-ledger-card,
  .pay-modal-card,
  .contact-corporate-profile-card,
  .contact-info-card,
  .leadership-compact-card,
  .leadership-officer-card,
  .team-card,
  .tf-container,
  .workshop-form-card,
  .workshop-live-preview-panel,
  .inv-card,
  .inv-table-wrap,
  .owner-card,
  .owner-attendance-overview,
  .owner-status-table-wrap,
  .owner-members-list,
  .owner-member-editor,
  .owner-voting-section,
  .owner-voting-deleted-shell,
  .owner-voting-modal-card,
  .owner-meetings-panel,
  .owner-meeting-detail,
  .owner-meeting-form-shell,
  .owner-birthday-month-panel,
  .owner-birthday-all-month-card,
  .owner-birthday-modal-card,
  .bday-accordion-card,
  .owner-review-card,
  .owner-pay-row,
  .support-chat-panel,
  .modal-content,
  .card,
  .card-box,
  .room-card,
  /* Standalone pages (faq.html, guest-checkout.html, newsletters.html) */
  .search-panel,
  .faq-item,
  .walkthrough,
  .purchase-summary,
  .newsletter-card
) {
  background: var(--card-bg) !important;
  color: var(--ink) !important;
  border-color: var(--night-border) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* Profile ID Card special gradients & birthday state */
html[data-theme="dark"] .profile-id-card {
  background: linear-gradient(145deg, #1b2835 0%, #213244 100%) !important;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32) !important;
}

html[data-theme="dark"] .profile-id-card.birthday-mode {
  border-color: rgba(250, 218, 136, 0.65) !important;
  background: linear-gradient(145deg, #232d38 0%, #1c2b3c 100%) !important;
}

html[data-theme="dark"] .profile-birthday-banner {
  background: linear-gradient(90deg, rgba(250, 218, 136, 0.2) 0%, rgba(38, 55, 71, 0.92) 100%) !important;
  border-color: rgba(250, 218, 136, 0.5) !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] .profile-birthday-banner strong {
  color: var(--gold) !important;
}

html[data-theme="dark"] .account-page-subtitle {
  color: var(--night-muted) !important;
}

html[data-theme="dark"] .account-details-tabs {
  background: var(--night-raised) !important;
  border-color: var(--night-border) !important;
}

html[data-theme="dark"] .account-details-tab {
  color: var(--night-muted) !important;
}

html[data-theme="dark"] .account-details-tab:hover,
html[data-theme="dark"] .account-details-tab[aria-selected="true"] {
  color: var(--gold) !important;
}

html[data-theme="dark"] .account-details-tab[aria-selected="true"] {
  border-bottom-color: var(--gold) !important;
  background: rgba(250, 218, 136, 0.04);
}

html[data-theme="dark"] .account-details-card {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28) !important;
}

/* Featured Subscription Card */
html[data-theme="dark"] .sub-tier-card.featured {
  background: linear-gradient(160deg, #213244 0%, #1b2835 100%) !important;
  border: 2px solid var(--gold) !important;
}

/* Licensing Tracker Warning / Overdue Cards */
html[data-theme="dark"] #licensingTrackerCard.licensing-card-warning {
  background: #2b2618 !important;
  border-color: #9e8236 !important;
}

html[data-theme="dark"] #licensingTrackerCard.licensing-card-overdue {
  background: #331f22 !important;
  border-color: #9e4747 !important;
}

/* ==========================================================================
   3. Raised Sub-Surfaces, Form Controls, Chips & Nested Blocks
   ========================================================================== */
html[data-theme="dark"] :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  textarea,
  select,
  .tf-input,
  .tf-card-pane,
  .search-input,
  .search-box,
  .filter-mini-field,
  .next-oro-step-select,
  .next-oro-select,
  .next-oro-pathway-card,
  .metric-split-block,
  .licensing-stat-card,
  .hours-item,
  .hours-slot,
  .staff-summary-box,
  .staff-licensing-block,
  .account-site-card,
  .sub-dashboard-stat,
  .sub-avail-badge,
  .sub-day-row,
  .scholarship-info-card-box,
  .resource-link-item-row,
  .legal-disclaimer-gate,
  .contact-channel-row-link,
  .leadership-officer-toggle-bar,
  .pathway-card summary,
  .training-library-summary,
  .training-library-details,
  .training-price-icon-option,
  .editor-paired-row,
  .card-mode-toggle,
  .card-theme-swatch,
  .card-layout-option,
  .pay-method-card,
  .pay-term-card,
  .pay-summary,
  .owner-attendance-summary-card,
  .owner-attendance-item,
  .owner-member-card-preview,
  .owner-member-staff-list,
  .owner-member-training-panel,
  .owner-inline-metric-row-item,
  .owner-voting-poll-card,
  .owner-voting-deleted-toggle,
  .voting-modal-slider-wrapper,
  .owner-meetings-panel-header,
  .owner-meeting-detail-header,
  .owner-meeting-form-header,
  .owner-meeting-section,
  .owner-meeting-attendee,
  .owner-meeting-custom-section-card,
  .owner-meeting-note-card,
  .owner-birthday-item,
  .owner-birthday-all-entry,
  .bday-checklist-drawer,
  .support-chat-transcript p,
  .support-chat-avatar,
  /* Standalone pages */
  .contact-card,
  .scholarship-card,
  .disclaimer-card,
  .tier,
  .billing-options label,
  .notice
) {
  background: var(--night-raised) !important;
  color: var(--ink) !important;
  border-color: var(--night-border) !important;
}

/* Keep nested inputs inside raised containers distinct */
html[data-theme="dark"] :is(
  .editor-input-wrap input,
  .editor-input-wrap textarea,
  .editor-paired-row .editor-input-wrap input,
  .tf-card-pane .tf-input,
  .owner-meeting-attendee select,
  .owner-meeting-section input:not([type="checkbox"]):not([type="radio"]),
  .owner-meeting-section textarea,
  .voting-modal-slider-wrapper input:not([type="range"]),
  .sub-day-row input[type="time"]
) {
  background: #172330 !important;
  color: var(--ink) !important;
  border-color: #465d73 !important;
}

html[data-theme="dark"] .search-box input {
  background: transparent !important;
  border: 0 !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--night-muted) !important;
  opacity: 0.85;
}

html[data-theme="dark"] :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
  textarea:focus,
  select:focus
) {
  border-color: var(--night-accent) !important;
  box-shadow: 0 0 0 3px rgba(172, 216, 245, 0.16) !important;
}

/* Interactive row & card hover states */
html[data-theme="dark"] :is(
  .contact-channel-row-link:hover,
  .resource-link-item-row:hover,
  .training-library-summary:hover,
  .card-theme-swatch:hover,
  .card-layout-option:hover,
  .pay-method-card:hover,
  .pay-term-card:hover
) {
  background: var(--night-elevated) !important;
  border-color: var(--night-accent) !important;
}

html[data-theme="dark"] :is(
  .card-theme-swatch.active,
  .card-layout-option.active,
  .pay-method-card.selected,
  .pay-term-card.selected,
  .billing-options label:has(input:checked)
) {
  background: #233b52 !important;
  border-color: var(--gold) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(250, 218, 136, 0.2) !important;
}

html[data-theme="dark"] .pay-method-card.recommended.selected {
  background: #1a372b !important;
  border-color: #4ade80 !important;
}

/* ==========================================================================
   4. Buttons, Chips, Pills & Status Badges (Preserving Semantic Hierarchy)
   ========================================================================== */

/* Primary Brand Action Buttons */
html[data-theme="dark"] :is(
  .action-btn,
  .payment-choice-btn.primary-sub,
  .pay-open-app-btn,
  .owner-voting-create-btn,
  .saved-card-actions a,
  .saved-card-actions button,
  #checkoutButton
) {
  background-color: #2b5f84;
  color: #ffffff !important;
  border-color: #3f769d;
}

html[data-theme="dark"] :is(
  .action-btn:hover,
  .payment-choice-btn.primary-sub:hover,
  .pay-open-app-btn:hover,
  .owner-voting-create-btn:hover,
  #checkoutButton:hover
) {
  background-color: #35729d;
}

/* Secondary / Neutral / Outline Buttons */
html[data-theme="dark"] :is(
  .inv-btn,
  .staff-find-btn,
  .payment-choice-btn.secondary-pay,
  .owner-voting-btn:not(.active),
  .sub-dashboard-subnav button:not(.active),
  .find-sub-mode-tabs button:not(.active),
  .leadership-action-icon-btn,
  .leadership-action-pill-btn,
  .leadership-compact-vcard-btn,
  .leadership-add-vcard-inner-btn,
  .leadership-add-vcard-corner-btn,
  .owner-attendance-toggle,
  .owner-birthday-modal-close,
  .sub-card-save-btn:not(.saved),
  .support-chat button:not(.support-chat-launch),
  #supportChatHistory button,
  .btn-outline
) {
  background: var(--night-raised) !important;
  color: var(--night-accent) !important;
  border: 1px solid var(--night-border) !important;
}

html[data-theme="dark"] :is(
  .inv-btn:hover,
  .staff-find-btn:hover,
  .payment-choice-btn.secondary-pay:hover,
  .owner-voting-btn:not(.active):hover,
  .sub-dashboard-subnav button:not(.active):hover,
  .find-sub-mode-tabs button:not(.active):hover,
  .leadership-action-icon-btn:hover,
  .leadership-action-pill-btn:hover,
  .owner-attendance-toggle:hover,
  .support-chat button:not(.support-chat-launch):hover,
  #supportChatHistory button:hover
) {
  background: var(--night-elevated) !important;
  color: #ffffff !important;
  border-color: var(--night-accent) !important;
}

/* Active Segment / Mode Toggle Buttons */
html[data-theme="dark"] :is(
  .owner-voting-btn.active,
  .sub-dashboard-subnav button.active,
  .find-sub-mode-tabs button.active,
  .card-mode-btn.active
) {
  background: #2b5f84 !important;
  color: #ffffff !important;
  border-color: #639ec7 !important;
}

html[data-theme="dark"] .card-mode-btn:not(.active) {
  background: transparent !important;
  color: var(--night-muted) !important;
}

/* Gold CTA Buttons & Badges — MUST always keep dark #101820 text */
html[data-theme="dark"] :is(
  .btn-gold,
  .profile-edit-btn,
  .editor-save-btn,
  .scholarship-action-footer-btn,
  .btn-link,
  .workshop-download-btn.pdf-type,
  .training-complete-btn:not(.is-submitted),
  .status-badge,
  .sub-board-type-pill,
  .tf-active-badge,
  [style*="background-color: #fada88"],
  [style*="background-color:#fada88"],
  [style*="background: #fada88"],
  [style*="background:#fada88"]
) {
  background-color: var(--gold) !important;
  color: #101820 !important;
  border-color: var(--gold-line) !important;
}

/* Danger / Destructive Buttons */
html[data-theme="dark"] :is(
  .btn-danger,
  .staff-delete-btn,
  .owner-training-notification,
  [style*="background-color: #d9534f"],
  [style*="background-color:#d9534f"],
  [style*="background: #d9534f"],
  [style*="background:#d9534f"]
) {
  background: #a43b37 !important;
  border-color: #c24d48 !important;
  color: #ffffff !important;
}

/* Filter Chips & Interest Pills */
html[data-theme="dark"] :is(.chip, .tf-chip, .filter-label, .training-interest-btn:not(.is-active)) {
  background: var(--night-raised) !important;
  color: var(--ink) !important;
  border: 1px solid var(--night-border) !important;
}

html[data-theme="dark"] :is(.tf-chip:hover, .filter-label:hover, .training-interest-btn:not(.is-active):hover) {
  border-color: var(--gold) !important;
  color: var(--gold) !important;
}

html[data-theme="dark"] :is(.tf-chip.active, .training-interest-btn.is-active) {
  background: var(--gold) !important;
  color: #101820 !important;
  border-color: var(--gold) !important;
}

html[data-theme="dark"] .training-complete-btn.is-submitted {
  background: var(--night-raised) !important;
  color: var(--night-muted) !important;
  border-color: var(--night-border) !important;
}

/* Semantic Status Badges (Green / Red / Amber / Info) */
html[data-theme="dark"] :is(
  .badge-inc,
  .status-pill-badge.active-sub,
  .status-pill-badge.site-sub,
  .pathway-met-badge,
  .owner-status-pill.is-yes,
  .owner-voting-status-pill.pass,
  .training-listing-pill:not(.unlisted),
  .inv-type-pill.restock,
  .bday-status-pill.is-complete,
  .sub-cert-pill:not(.expired),
  .sub-recommend-pill.yes,
  .staff-connection-badge,
  .staff-search-result:not(.not-found)
) {
  background: #183b2d !important;
  color: #91ddb0 !important;
  border-color: #2f6a4c !important;
}

html[data-theme="dark"] :is(
  .badge-not,
  .status-pill-badge.inactive-sub,
  .owner-status-pill.is-no,
  .owner-voting-status-pill.fail,
  .inv-type-pill.usage,
  .sub-cert-pill.expired,
  .sub-recommend-pill.no,
  .pathway-gap-item,
  .next-oro-needs-gap,
  .staff-search-result.not-found,
  .sub-card-save-btn.saved
) {
  background: #492527 !important;
  color: #ffb4b0 !important;
  border-color: #824044 !important;
}

html[data-theme="dark"] :is(
  .badge-lim,
  .owner-attendance-pill.excused,
  .dashboard-completed-denied,
  .pay-instructions,
  .empty-state
) {
  background: #332a17 !important;
  color: #f6dfa4 !important;
  border-color: #6e5928 !important;
}

html[data-theme="dark"] :is(
  .sub-tier-badge,
  .profile-id-badge,
  .owner-member-id-badge,
  .owner-attendance-pill.present,
  .owner-voting-status-pill:not(.pass):not(.fail),
  .status-pill-badge.site-sup,
  .newsletter-dept,
  .topic-nav a
) {
  background: #21374d !important;
  color: var(--night-accent) !important;
  border-color: #395b7c !important;
}

html[data-theme="dark"] :is(
  .training-listing-pill.unlisted,
  .owner-attendance-pill.absent,
  .bday-status-pill:not(.is-complete)
) {
  background: #283542 !important;
  color: var(--night-muted) !important;
  border-color: var(--night-border) !important;
}

html[data-theme="dark"] .sub-tier-card.featured .sub-tier-badge {
  background: var(--gold) !important;
  color: #101820 !important;
}

/* Completed Birthday Items */
html[data-theme="dark"] :is(.owner-birthday-item.completed, .bday-accordion-card.completed-card) {
  background: #173227 !important;
  border-color: #2f6a4c !important;
}

/* Staff Accordion Tone Headers */
html[data-theme="dark"] .staff-member-toggle,
html[data-theme="dark"] .staff-member-toggle.staff-tone-primary {
  background: linear-gradient(90deg, #1f3347 0%, #263b50 100%) !important;
  color: var(--night-accent) !important;
}

html[data-theme="dark"] .staff-member-toggle.staff-tone-success {
  background: linear-gradient(90deg, #19382b 0%, #204234 100%) !important;
  color: #9be2b6 !important;
}

html[data-theme="dark"] .staff-member-toggle.staff-tone-warning {
  background: linear-gradient(90deg, #382e18 0%, #42361d 100%) !important;
  color: #f8dfa1 !important;
}

html[data-theme="dark"] .staff-member-toggle.staff-tone-overdue {
  background: linear-gradient(90deg, #3f2224 0%, #4a282b 100%) !important;
  color: #ffb8b5 !important;
}

html[data-theme="dark"] .staff-toggle {
  background: transparent !important;
  color: var(--ink) !important;
}

/* ==========================================================================
   5. Public Banners, Free Hours Box, Tables & List Items
   ========================================================================== */
html[data-theme="dark"] .hero-banner-image {
  background-color: var(--bg) !important;
}

html[data-theme="dark"] :is(.hero-banner, .gold-bar) {
  background: var(--card-bg) !important;
  color: var(--gold) !important;
  border-top: 2px solid var(--gold) !important;
  border-bottom: 2px solid var(--gold) !important;
}

html[data-theme="dark"] .dashboard-free-hours {
  background: #252218 !important;
  border-color: rgba(250, 218, 136, 0.65) !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] .dashboard-free-hours-label,
html[data-theme="dark"] #dashboardFreeSet1Usage {
  color: var(--gold) !important;
}

/* Find a Sub Important Notice Banner (#fffacd) */
html[data-theme="dark"] [style*="background-color: #fffacd"],
html[data-theme="dark"] [style*="background:#fffacd"] {
  background: #2d2617 !important;
  color: #f7e1a8 !important;
  border-color: rgba(250, 218, 136, 0.5) !important;
  padding: 8px 14px;
}

/* Tables & Comparison Matrices */
html[data-theme="dark"] :is(
  table,
  .sub-matrix-table,
  .subscription-pricing-table,
  .certs-table,
  .sub-ledger-table,
  .inv-table,
  .owner-status-table,
  .owner-training-table,
  .staff-mini-table
) {
  background: var(--card-bg) !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] :is(
  .sub-matrix-table th,
  .subscription-pricing-table th,
  .inv-table th,
  .owner-status-table th,
  .owner-training-table th,
  .certs-table th,
  .sub-ledger-table th,
  .faq-section table th
) {
  background: var(--night-raised) !important;
  color: var(--night-accent) !important;
  border-color: var(--night-border) !important;
}

/* Paid Subscriptions column header in comparison matrix */
html[data-theme="dark"] th[style*="background: #ebf5fb"],
html[data-theme="dark"] th[style*="background:#ebf5fb"] {
  background: #233c53 !important;
  color: var(--gold) !important;
}

html[data-theme="dark"] :is(
  table td,
  .certs-table td,
  .sub-ledger-table td,
  .inv-table td,
  .owner-status-table td,
  .owner-training-table td,
  .staff-mini-table td,
  .sub-matrix-table td,
  .subscription-row-label,
  .subscription-cell-soft,
  .subscription-cell-highlight,
  .subscription-price-row td,
  .faq-section tbody tr:nth-child(even)
) {
  background: transparent !important;
  color: var(--ink) !important;
  border-color: var(--night-border) !important;
}

html[data-theme="dark"] :is(
  .sub-matrix-table tbody tr:hover,
  .inv-table tbody tr:hover,
  .owner-status-table tbody tr:hover,
  .faq-section tbody tr:nth-child(even)
) {
  background: rgba(255, 255, 255, 0.03) !important;
}

/* Master-Detail List Items (Owner Supporters & Owner Meetings) */
html[data-theme="dark"] :is(.owner-member-item, .owner-meeting-item) {
  background: var(--card-bg) !important;
  color: var(--ink) !important;
  border-bottom-color: var(--night-border) !important;
}

html[data-theme="dark"] :is(.owner-member-item:hover, .owner-meeting-item:hover) {
  background: var(--night-raised) !important;
}

html[data-theme="dark"] :is(.owner-member-item.active, .owner-meeting-item.active) {
  background: #2b5f84 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .owner-member-actions {
  background: var(--card-bg) !important;
  border-top-color: var(--night-border) !important;
}

/* Progress Tracks & Dividers */
html[data-theme="dark"] :is(.licensing-progress-track, .progress-track) {
  background: #263747 !important;
}

html[data-theme="dark"] :is(
  .dashboard-mini-item,
  .dashboard-completed-item,
  .mini-list-item,
  .cert-row,
  .pd-class-row,
  .saved-card-entry,
  .sub-meta-list li,
  .sub-rating-row,
  .sub-review-item,
  .hours-full-row,
  .hours-extra,
  .account-site-staff,
  .owner-member-field-section,
  .owner-meeting-create-area,
  .card-layout-divider,
  .guest-import-section,
  fieldset,
  .consent,
  .stripe-note
) {
  border-color: var(--night-border) !important;
}

html[data-theme="dark"] .dashboard-training-image,
html[data-theme="dark"] .dashboard-training-image img {
  background: var(--night-raised) !important;
}

/* ==========================================================================
   6. Typography: Headings, Accents, Labels & Muted Copy
   ========================================================================== */
html[data-theme="dark"] :is(
  #dashboardHeaderTitle,
  #ownerDashboardHeaderTitle,
  .card-title,
  .editor-section-title,
  .profile-id-name,
  .profile-id-role,
  .dashboard-welcome-text,
  .dashboard-training-name,
  .dashboard-mini-value,
  .metric-value-large,
  .licensing-stat-value,
  .hours-item strong,
  .hours-slot strong,
  .hours-extra strong,
  .snapshot-value,
  .mini-value,
  .mini-inline,
  .training-card h3,
  .training-library-title,
  .sub-tier-title,
  .sub-tier-price,
  .price-container,
  .sub-card-name,
  .sub-card-rate,
  .sub-dashboard-stat strong,
  .contact-corporate-profile-card h3,
  .leadership-compact-name,
  .leadership-officer-toggle-bar h3,
  .leadership-officer-card h3,
  .resource-subsegment-block h3,
  .resource-link-left-content i,
  .scholarship-info-card-box h4,
  .legal-disclaimer-card h2,
  .workshop-form-card h3,
  .preview-panel-title,
  .next-oro-pathway-title,
  .pathway-code-title,
  .pathway-toggle-arrow,
  .staff-cert-name,
  .staff-summary-box strong,
  .pay-modal-title,
  .pay-section-label,
  .pay-method-name,
  .pay-summary-row.total,
  .owner-attendance-overview h4,
  .owner-attendance-summary-value,
  .owner-attendance-item-name,
  .owner-member-id-name,
  .owner-member-id-role,
  .owner-member-site-summary > strong,
  .owner-member-field-section > summary,
  .card-box-title,
  .trn-hours,
  .owner-birthday-month-title,
  .owner-birthday-all-month-title,
  .owner-birthday-name,
  .owner-voting-section-header h4,
  .owner-voting-poll-title,
  .owner-voting-modal-title,
  .owner-voting-timer-line:not(.urgent-countdown),
  .owner-meeting-section-title,
  .owner-meeting-note-card h5,
  .inv-card-title,
  .inv-qty-badge:not(.low),
  /* Standalone pages */
  .section-heading h2,
  .faq-item summary,
  .faq-item summary::after,
  .walkthrough h3,
  .search-panel label,
  .contact-card strong,
  .scholarship-card strong,
  .tier strong,
  #checkoutTotal,
  .newsletter-card h3
) {
  color: var(--night-accent) !important;
}

/* Filter toolkit headers & labels (override inline #1f3e58 on Find a Sub) */
html[data-theme="dark"] :is(.tf-title, .tf-label, .category-title, .resource-card h2, .resource-card h3) {
  color: var(--gold) !important;
}

html[data-theme="dark"] :is(
  .contact-channel-meta-pane span,
  .resource-link-title-string,
  .scholarship-info-card-box p,
  .scholarship-info-card-box ul,
  .legal-disclaimer-gate label,
  .pathway-body,
  .pathway-reqs-list,
  .next-oro-list,
  .pay-summary-row,
  .pay-send-headline,
  .pay-instructions strong,
  .owner-member-id-value,
  .owner-member-staff-list li,
  .owner-meeting-summary-value,
  .owner-meeting-attendee-text,
  .owner-voting-poll-motion,
  .sub-board-description,
  .bday-check-item,
  .owner-birthday-main-btn,
  .faq-answer,
  .newsletter-card p
) {
  color: var(--ink) !important;
}

html[data-theme="dark"] :is(
  .profile-id-label,
  .profile-id-topline,
  #profileDetails p,
  .card-subtitle,
  .editor-section-subtitle,
  .editor-field-label,
  .mini-list-date,
  .mini-list-meta,
  .dashboard-mini-date,
  .dashboard-mini-empty,
  .dashboard-completed-meta,
  .dashboard-free-hours-note,
  .metric-sub-value,
  .metric-footer-date,
  .metric-split-title,
  .metric-split-footer,
  .licensing-stat-label,
  .licensing-stat-value span,
  .licensing-stat-help,
  .licensing-progress-label,
  .licensing-status-note,
  .next-oro-step-current,
  .next-oro-step-controls label,
  .next-oro-step-summary,
  .next-oro-pathway-subtitle,
  .next-oro-needs-title,
  .next-oro-note,
  .pathway-sublabel,
  .pathway-still-needed-title,
  .pathway-note,
  .training-card .meta,
  .training-hub-meta,
  .training-library-preview,
  .training-library-field strong,
  .sub-tier-price span,
  .sub-tier-specs,
  .price-duration,
  .indv-duration,
  .sub-purchase-options p,
  .sub-dashboard-stat span,
  .sub-board-meta,
  .sub-card-preview-meta,
  .sub-review-item .sub-review-meta,
  .contact-channel-meta-pane strong,
  .leadership-compact-role,
  .leadership-officer-card p,
  .resource-link-title-string span,
  .workshop-input-field label,
  .workshop-input-field .field-hint,
  .staff-licensing-title,
  .staff-hsn-title,
  .staff-hsn-training-title,
  .staff-progress-label,
  .staff-add-status,
  .staff-upload-status,
  .pay-modal-sub,
  .pay-autopay-note,
  .owner-pay-meta,
  .owner-attendance-overview p,
  .owner-attendance-summary-label,
  .owner-attendance-item-role,
  .owner-status-subtext,
  .owner-member-id-org,
  .owner-member-id-label,
  .owner-member-edit-title,
  .owner-member-field label,
  .owner-member-staff-title,
  .owner-member-staff-step-title,
  .owner-member-staff-step,
  .owner-member-staff-training,
  .trn-ckc,
  .trn-title,
  .trn-date,
  .owner-birthday-date,
  .owner-birthday-complete,
  .owner-birthday-empty,
  .owner-voting-stats,
  .owner-voting-empty,
  .owner-voting-status-line,
  .owner-voting-modal-field label,
  .owner-meeting-summary-label,
  .owner-meeting-attendee-subtext,
  .owner-meeting-field label,
  .owner-meeting-form-note,
  .owner-meeting-empty-state,
  .inv-meta-row,
  .card-layout-option-desc,
  .support-chat-handoff-status,
  /* Standalone pages */
  .section-heading p,
  figcaption,
  .intro,
  .hint,
  .summary-rate,
  .total-label,
  #billingSummary,
  .stripe-note,
  .results-summary,
  .newsletter-date
) {
  color: var(--night-muted) !important;
}

html[data-theme="dark"] a:not(.action-btn):not(.btn-link):not(.scholarship-action-footer-btn):not(.social-link-home):not(.footer-social-link):not(.logo-link):not(.brand):not(.button) {
  color: var(--night-accent);
}

/* ==========================================================================
   7. Inline Style Normalization (Safe Scoped Catch-Alls)
   ========================================================================== */
html[data-theme="dark"] :is(
  [style*="background: #fff"],
  [style*="background:#fff"],
  [style*="background: white"],
  [style*="background-color: #fff"],
  [style*="background-color:#fff"],
  [style*="background: #ffffff"],
  [style*="background:#ffffff"],
  [style*="background: #f9f9f9"],
  [style*="background:#f9f9f9"],
  [style*="background-color: #f9f9f9"],
  [style*="background: #f4f7fa"],
  [style*="background:#f4f7fa"],
  [style*="background: #f7fbff"],
  [style*="background:#f7fbff"],
  [style*="background-color: #f4f4f4"],
  [style*="background: #edf2f7"],
  [style*="background:#edf2f7"],
  [style*="background: #eef2f6"],
  [style*="background:#eef2f6"],
  [style*="background: #eef4f9"],
  [style*="background:#eef4f9"],
  [style*="background: #edf4fa"],
  [style*="background:#edf4fa"],
  [style*="background: #f0f4f8"],
  [style*="background:#f0f4f8"],
  [style*="background: #f1f6fa"],
  [style*="background:#f1f6fa"],
  [style*="background: #f4f9fc"],
  [style*="background:#f4f9fc"],
  [style*="background: #f8fbfd"],
  [style*="background:#f8fbfd"],
  [style*="background: #fbfdff"],
  [style*="background:#fbfdff"],
  [style*="background: #fafafa"],
  [style*="background:#fafafa"]
):not(img):not(canvas):not(.preview-page-mock):not(.preview-page-mock *):not(#cardQrCode):not(.pay-qr-panel):not(.pay-qr-panel *) {
  background: var(--night-raised) !important;
  color: var(--ink) !important;
  border-color: var(--night-border) !important;
}

html[data-theme="dark"] :is(
  [style*="color: #333"],
  [style*="color:#333"],
  [style*="color: #444"],
  [style*="color:#444"],
  [style*="color: #555"],
  [style*="color:#555"],
  [style*="color: #666"],
  [style*="color:#666"],
  [style*="color: #777"],
  [style*="color:#777"],
  [style*="color: #888"],
  [style*="color:#888"],
  [style*="color: #999"],
  [style*="color:#999"],
  [style*="color: #1c1c1c"],
  [style*="color:#1c1c1c"],
  [style*="color: #243746"],
  [style*="color:#243746"],
  [style*="color: #1f3e58"],
  [style*="color:#1f3e58"],
  [style*="color: #265372"],
  [style*="color:#265372"],
  [style*="color: #64748b"],
  [style*="color:#64748b"],
  [style*="color: #5d6d7e"],
  [style*="color:#5d6d7e"],
  [style*="color: #6d7f90"],
  [style*="color:#6d7f90"],
  [style*="color: #52677a"],
  [style*="color:#52677a"],
  [style*="color: #6b7b8d"],
  [style*="color:#6b7b8d"],
  [style*="color: #78889b"],
  [style*="color:#78889b"],
  [style*="color: #667789"],
  [style*="color:#667789"],
  [style*="color: #1a2f45"],
  [style*="color:#1a2f45"],
  [style*="color: #2a5679"],
  [style*="color:#2a5679"]
):not([style*="background-color: #fada88"]):not([style*="background: #fada88"]):not([style*="background:#fada88"]):not(.tf-title):not(.tf-label):not(.preview-page-mock):not(.preview-page-mock *):not(.pay-qr-panel *) {
  color: var(--ink) !important;
}

/* ==========================================================================
   8. Protected Bright Surfaces (QR Codes, Whiteboard, Print Simulators, E-Card)
   ========================================================================== */
html[data-theme="dark"] #cardQrCode,
html[data-theme="dark"] .pay-qr-panel {
  background: #ffffff !important;
  color: #1e293b !important;
}

html[data-theme="dark"] .pay-qr-caption {
  color: #475569 !important;
}

html[data-theme="dark"] #ownerWhiteboardCanvas {
  background: #ffffff !important;
  border-color: var(--night-border) !important;
}

/* Printable document/flyer page simulators inside workshops must stay paper-white */
html[data-theme="dark"] .preview-page-mock,
html[data-theme="dark"] .preview-page-mock * {
  color-scheme: light;
}

html[data-theme="dark"] .preview-page-mock {
  background: #ffffff !important;
  color: #1c1c1c !important;
}

/* E-business card preview wrapper: card.html manages its own light/dark preview */
html[data-theme="dark"] #myViewBusinessCardTab > div > div:first-child {
  background: var(--card-bg) !important;
  border-color: var(--night-border) !important;
}

html[data-theme="dark"] #myViewBusinessCardTab #cardPreviewStatus {
  background: var(--card-bg) !important;
  color: var(--night-muted) !important;
}
