html[data-bs-theme="dark"] {
  --fabric-dark-bg: #151b26;
  --fabric-dark-surface: #202938;
  --bs-body-color: #ffffff;
  --bs-body-color-rgb: 255, 255, 255;
  --bs-emphasis-color: #ffffff;
  --bs-emphasis-color-rgb: 255, 255, 255;
  --bs-secondary-color: #cbd5e1;
  --bs-body-bg: var(--fabric-dark-bg);
  --bs-secondary-bg: var(--fabric-dark-surface);
  --bs-tertiary-bg: var(--fabric-dark-surface);
}
html[data-bs-theme="dark"][data-fabric-dark-color="charcoal"] { --fabric-dark-bg: #111111; --fabric-dark-surface: #242424; }
html[data-bs-theme="dark"][data-fabric-dark-color="navy"] { --fabric-dark-bg: #071427; --fabric-dark-surface: #14263d; }
html[data-bs-theme="dark"][data-fabric-dark-color="plum"] { --fabric-dark-bg: #211025; --fabric-dark-surface: #36213b; }
html[data-bs-theme="dark"][data-fabric-dark-color="forest"] { --fabric-dark-bg: #0b211b; --fabric-dark-surface: #19382e; }
/* Bootstrap 5.3 handles controls, tables, cards, dialogs and alerts. These rules
   adapt the Fabric shell and shared components that use fixed light colors. */
html[data-bs-theme="dark"] .fabric-shell {
  background: var(--fabric-dark-bg) !important;
  color: var(--bs-body-color);
}
html[data-bs-theme="dark"] :is(.fabric-subnav, .fabric-page-header, .fabric-summary-card, .fabric-encounter-panel, .fabric-mobile-nav-panel) {
  background: var(--fabric-dark-surface);
  color: #ffffff;
  border-color: #455269;
}
html[data-bs-theme="dark"] :is(.fabric-encounter-link, .fabric-encounter-board-link, .fabric-mobile-nav-link, .fabric-mobile-nav summary, .fabric-page-chip) {
  background: var(--fabric-dark-surface);
  color: #ffffff;
  border-color: #455269;
}
html[data-bs-theme="dark"] :is(.fabric-encounter-link, .fabric-encounter-board-link, .fabric-mobile-nav-link):hover {
  background: #31415a;
  color: #fff;
}
html[data-bs-theme="dark"] :is(.fabric-page-header-title, .fabric-summary-card-value, .bg-swatch) { color: #ffffff; }
html[data-bs-theme="dark"] :is(.fabric-page-header-kicker, .fabric-page-header-subtitle, .fabric-summary-card-title, .fabric-summary-card-meta, .fabric-encounter-meta) { color: #adb5bd; }
html[data-bs-theme="dark"] .fabric-summary-card-value.is-success { color: #75d8a0; }
html[data-bs-theme="dark"] .fabric-summary-card-value.is-warning { color: #ffc879; }
html[data-bs-theme="dark"] .fabric-encounter-link.is-active { background: #163c2b; color: #9ae6b4; }
html[data-bs-theme="dark"] .fabric-status-banner.is-danger { background: #46252c; color: #ffb9c0; }
html[data-bs-theme="dark"] :is(.fabric-status-banner.is-success, .fabric-status-banner.is-soft-success) { background: #163c2b; color: #9ae6b4; }
html[data-bs-theme="dark"] :is(.bg-white, .bg-light) { background-color: var(--fabric-dark-surface) !important; }
html[data-bs-theme="dark"] :is(.text-dark, .text-black) { color: #ffffff !important; }
html[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #adb5bd; --bs-btn-border-color: #adb5bd; }

html[data-bs-theme="dark"] :is(.card, .modal-content, .dropdown-menu) { background-color: var(--fabric-dark-surface); }

/* Module styles are emitted inside page content, after this stylesheet. Use
   theme-scoped selectors so their fixed light surfaces cannot override it. */
html[data-bs-theme="dark"] :is(.fc-shell, .cp-shell, .ca-shell, .av-shell) {
  --fc-ink: #fff; --fc-muted: #cbd5e1; --fc-border: #455269;
  --fc-blue: #93c5fd; --fc-green: #5eead4; --fc-amber: #fcd34d; --fc-red: #fda4af;
  --cp-ink: #fff; --cp-muted: #cbd5e1; --cp-border: #455269; --cp-panel: var(--fabric-dark-surface);
  --ca-ink: #fff; --ca-muted: #cbd5e1; --ca-border: #455269;
  --ca-blue: #93c5fd; --ca-green: #5eead4; --ca-amber: #fcd34d; --ca-red: #fda4af;
  --av-ink: #fff; --av-muted: #cbd5e1; --av-border: #455269;
  --av-blue: #2563eb; --av-green: #5eead4;
  color: #fff;
}
html[data-bs-theme="dark"] :is(
  .fabric-workspace-panel, .inv-panel, .fabric-dashboard-list, .fabric-contact-desk,
  .fabric-contact-action, .fabric-eco-card, .fabric-eco-bridge,
  .fc-band, .fc-kpi, .fc-event, .fc-resource, .fc-handoff, .fc-window,
  .fc-day, .fc-day-head, .fc-cal-event, .fc-month-day, .fc-month-event,
  .fc-clinic-lane, .fc-clinic-head, .fc-clinic-event, .fc-modal, .fc-nav-btn, .fc-today-btn,
  .fc-segment, .fc-tz, .fc-calendars .fc-calendars-panel, .fc-hs-chip,
  .cp-band, .cp-service, .cp-window, .ca-band, .ca-card, .av-card, .av-rule-row,
  .hs-day, .hs-lesson, .hs-late,
  .hk-kid, .hk-views a, .hk-nav a, .hk-progress, .hk-lesson, .hk-state,
  .hk-empty, .hk-col, .hk-mini, .hk-cell, .hk-late, .hk-finish,
  .hk-refresh-msg, .hk-updated
) {
  background: var(--fabric-dark-surface);
  color: #fff;
  border-top-color: #455269;
  border-right-color: #455269;
  border-bottom-color: #455269;
}
html[data-bs-theme="dark"] :is(.card, .card-header, .card-footer, .list-group-item, .modal-content, .dropdown-menu) {
  background: var(--fabric-dark-surface) !important;
  color: #fff;
  border-color: #455269;
}
html[data-bs-theme="dark"] :is(.fabric-dashboard-row-title, .fabric-domain-title, .fc-segment a, .fc-tz a, .fc-tz-label) { color: #fff; }
html[data-bs-theme="dark"] :is(.fabric-dashboard-row-meta, .fabric-domain-count, .fabric-contact-action-meta) { color: #cbd5e1; }
html[data-bs-theme="dark"] :is(.fc-month-day.is-outside, .hk-bar) { background: var(--fabric-dark-bg); }
html[data-bs-theme="dark"] :is(.fc-day.is-today, .fc-month-day.is-today, .hs-day.is-today, .hk-cell.is-today) {
  background: color-mix(in srgb, var(--fabric-dark-surface) 80%, #2563eb);
  border-color: #93c5fd;
}
html[data-bs-theme="dark"] .fc-hours-backdrop {
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(10% - 1px), #455269 calc(10% - 1px), #455269 10%);
}
html[data-bs-theme="dark"] .fc-hour-row { border-top-color: #455269; color: #cbd5e1; }
html[data-bs-theme="dark"] :is(.fc-inline-create:hover, .fc-month-add:hover, .fc-nav-btn:hover, .fc-today-btn:hover, .avc-day:hover, .fabric-contact-action:hover) {
  background: color-mix(in srgb, var(--fabric-dark-surface) 80%, #2563eb);
  color: #fff;
}
html[data-bs-theme="dark"] :is(.fc-segment a.is-active, .hk-views a.is-on) { background: #25549f; color: #fff; }
html[data-bs-theme="dark"] .fc-tz a.is-active { background: #735900; color: #fff; }
html[data-bs-theme="dark"] .hk-today { background: #735900 !important; color: #fff; }
html[data-bs-theme="dark"] :is(.fc-badge-requested, .ca-requested) { background: #483600; color: #fde68a; }
html[data-bs-theme="dark"] :is(.fc-badge-confirmed, .ca-confirmed, .av-badge-available, .hk-state-done) { background: #123e32; color: #99f6e4; }
html[data-bs-theme="dark"] :is(.fc-badge-completed, .ca-completed) { background: #334155; color: #fff; }
html[data-bs-theme="dark"] :is(.fc-badge-cancelled, .ca-cancelled, .av-badge-busy, .hk-state-late, .hs-lesson.late, .hs-late, .hk-late, .hk-refresh-msg.is-error, .fc-hs-chip.is-late) { background: #46252c; color: #ffb9c0; }
html[data-bs-theme="dark"] :is(.fc-badge-progress, .ca-progress) { background: #1e3a5f; color: #bfdbfe; }
html[data-bs-theme="dark"] .hk-state-todo { background: #3b2858; color: #ddd6fe; }
html[data-bs-theme="dark"] .fc-view-toggle .btn.is-active { background: #25549f; border-color: #93c5fd; color: #fff; }
html[data-bs-theme="dark"] :is(.fc-range-title, .fc-subbar, .fc-subbar-links a, .fc-filters summary, .fc-calendars summary, .fc-month-weekdays div, .hk-month .hk-wd, .hs-day h3, .fabric-eco-lead, .fabric-eco-card ul, .fabric-eco-link, .fabric-eco-bridge strong) { color: #fff; }
html[data-bs-theme="dark"] :is(.hk-kid small, .hk-lesson .hk-notes, .hk-mini small, .hk-cell .hk-count, .hk-finish li, .hk-foot, .hs-student h2 small, .hs-lesson .n, .hs-key, .fc-month-event.is-all-day .fc-month-time) { color: #cbd5e1; }
html[data-bs-theme="dark"] :is(.hk-kid:hover, .hk-cell:hover, .fc-hs-chip:hover) { color: #fff; }

/* Clinical duty calendar has its own Google-style calendar and popup UI. */
html[data-bs-theme="dark"] :is(.gc, .gc-pop) {
  --bg: var(--fabric-dark-bg);
  --surface: var(--fabric-dark-surface);
  --text: #fff;
  --muted: #cbd5e1;
  --dim: #a5b4c7;
  --line: #455269;
  --hline: #39485e;
  --hover: color-mix(in srgb, var(--fabric-dark-surface) 80%, #2563eb);
  --soft: #25476b;
  --clinic: color-mix(in srgb, var(--fabric-dark-surface) 85%, #059669);
  --closed: repeating-linear-gradient(135deg, var(--fabric-dark-bg) 0 6px, var(--fabric-dark-surface) 6px 12px);
  color: #fff;
}
html[data-bs-theme="dark"] :is(.gc-btn, .gc-seg, .gc-mini, .gc-palette, .gc-palette .def, .gc-grip, .gc-pop .btn-add) {
  background: var(--fabric-dark-surface);
  color: #fff;
  border-color: #455269;
}
html[data-bs-theme="dark"] :is(.gc-title, .gc-mini-head, .gc-side h3, .gc-mini a.r, .gc-pop h2) { color: #fff; }
html[data-bs-theme="dark"] :is(.gc-pop .sub, .gc-pop h3, .gc-pop .x, .gc-tabs button, .gc-ef .ic) { color: #cbd5e1; }
html[data-bs-theme="dark"] .gc-pop .modal-content { color: #fff; }
html[data-bs-theme="dark"] .gc-pop .row1 { border-color: #455269; }
html[data-bs-theme="dark"] :is(.gc-mc:hover, .gc-btn:hover, .gc-tabs button:hover, .gc-tabs button.on, .gc-ef .plain:hover, .gc-ef .plain:focus) { background: var(--hover); color: #fff; }
html[data-bs-theme="dark"] :is(.gc-ttl, .gc-ef input[type="date"], .gc-ef input[type="time"], .gc-ef .plain, .gc-ap .ap-new input, .gc-ap select, .gc-ap input[type="number"]) {
  background: var(--fabric-dark-surface);
  color: #fff;
  border-color: #455269;
  color-scheme: dark;
}
html[data-bs-theme="dark"] .gc-cal input:not(:checked) { background: var(--fabric-dark-surface); }
html[data-bs-theme="dark"] .gc-chip.duty:not([style]) { background: #163c2b; color: #d1fae5; }
html[data-bs-theme="dark"] .gc-chip.duty.me:not([style]) { background: #166534; color: #fff; }
html[data-bs-theme="dark"] .gc-pop .x:hover { background: #46252c; color: #ffb9c0; }
html[data-bs-theme="dark"] :is(.gc-ap .ap-picked, .gc-ap .ap-results button:hover, .gc-ap .ap-results button:focus) { background: var(--hover); color: #fff; }
html[data-bs-theme="dark"] :is(.gc-rec span, .gc-recchip, .ap-rec, .ap-rec button) { background: #163c2b; color: #d1fae5; }
html[data-bs-theme="dark"] .gc-ap .ap-err { color: #ffb9c0; }
