/* Shared dark theme and persistent page-wide toggle. */
html.dark-mode { color-scheme:dark; }
html.dark-mode body { background:#101827 !important; color:#e5edf8 !important; }
html.dark-mode body :is(main, .main, .main-shell, .content, .content-wrapper, .page-content, .panel, .card, .stat-card, .table-card, .summary-box, .receipt, .announcement-panel, .announcement-list, .modal-content, .form-card, .dashboard-card, .topbar, body > header, main > header, main > section, main > article) {
  background-color:#172337 !important; color:#e5edf8 !important; border-color:#2b3a50 !important;
}
html.dark-mode body :is(h1,h2,h3,h4,h5,p,label,th,td,legend,small,.muted,.breadcrumb,.page-heading,.user-name,.profile-name,.profile-role,.admin-header-heading strong,.admin-header-user) { color:#e5edf8 !important; }
html.dark-mode body :is(.muted,small,.breadcrumb,.profile-role,.admin-header-user) { color:#a7b5c9 !important; }
html.dark-mode body :is(input,select,textarea) { background:#101a29 !important; color:#e5edf8 !important; border-color:#40516a !important; }
html.dark-mode body :is(input,select,textarea)::placeholder { color:#91a0b5 !important; }
html.dark-mode body :is(table,thead,tbody,tr,th,td) { background-color:#172337 !important; color:#e5edf8 !important; border-color:#2b3a50 !important; }
html.dark-mode body :is(a:not(.nav-item):not(.nav-link):not(.admin-logout), .link) { color:#9fc1ff; }
html.dark-mode body :is(.empty,.empty-state) { color:#a7b5c9 !important; }
html.dark-mode body :is(.admin-logout,.icon-button,.icon-btn,.toggle-btn,.user-avatar,.avatar) { background-color:#20314a !important; color:#e5edf8 !important; border-color:#3a4b64 !important; }
html.dark-mode body :is(.sidebar,aside.sidebar,.nav-sidebar) { background-color:#101a29 !important; color:#dce5f1 !important; }
#globalThemeToggle {
  position:fixed; right:22px; bottom:22px; z-index:1600; width:46px; height:46px;
  display:grid; place-items:center; border:1px solid #dbe3ed; border-radius:50%;
  background:#fff; color:#34445b; box-shadow:0 7px 22px #17233822;
  font:700 21px/1 Arial,sans-serif; cursor:pointer; transition:transform .16s ease, box-shadow .16s ease;
}
#globalThemeToggle:hover { transform:translateY(-2px); box-shadow:0 10px 26px #17233830; }
#globalThemeToggle:focus-visible { outline:3px solid #77a7f5; outline-offset:3px; }
html.dark-mode #globalThemeToggle { background:#20314a; color:#ffe08a; border-color:#40516a; }
.global-theme-sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@media(max-width:600px) { #globalThemeToggle { right:15px; bottom:15px; width:43px; height:43px; } }
@media print { #globalThemeToggle { display:none !important; } }

/* Admin-specific surfaces that use page-local light styles. */
html.dark-mode body :is(.kpi,.date-label,.profile-menu,.filter,.note) {
  background-color:#172337 !important;
  color:#e5edf8 !important;
  border-color:#2b3a50 !important;
}
html.dark-mode body :is(.kpi-title,.kpi-note,.date-label,.note,.filter label,.chart-day,.department-top,.department-item) {
  color:#a7b5c9 !important;
}
html.dark-mode body .profile-menu a:hover { background-color:#273750 !important; }
html.dark-mode body .kpi-icon.blue { background-color:#203b63 !important; color:#b8d1ff !important; }
html.dark-mode body .kpi-icon.green { background-color:#1e4538 !important; color:#a6e4c2 !important; }
html.dark-mode body .kpi-icon.orange { background-color:#513c27 !important; color:#ffd39b !important; }
html.dark-mode body .kpi-icon.purple { background-color:#3d3159 !important; color:#d7c2ff !important; }
html.dark-mode body .chart {
  background-image:repeating-linear-gradient(to bottom,transparent 0,transparent 48px,#2b3a50 49px,transparent 50px) !important;
  border-color:#2b3a50 !important;
}
html.dark-mode body .progress { background-color:#2b3a50 !important; }
html.dark-mode body .notification-count { border-color:#172337 !important; }

/* Shared cards and popovers used by registration and workflow pages. */
html.dark-mode body :is(.option,.modal-box,.slideout-menu,.dropdown,.search-box,.billing-metric,.billing-panel,.details-panel) {
  background-color:#172337 !important;
  color:#e5edf8 !important;
  border-color:#2b3a50 !important;
}
html.dark-mode body .option :is(h2,p) { color:#e5edf8 !important; }
html.dark-mode body :is(.slideout-header,.dropdown .user-info) {
  background-color:#20314a !important;
  color:#e5edf8 !important;
  border-color:#2b3a50 !important;
}
html.dark-mode body :is(.slideout-menu a,.dropdown a,.modal-box a) {
  color:#d7e4f7 !important;
  border-color:#2b3a50 !important;
}
html.dark-mode body :is(.slideout-menu .menu-item,.dropdown a):hover { background-color:#273750 !important; }
html.dark-mode body > header { background-color:#172337 !important; color:#e5edf8 !important; border-color:#2b3a50 !important; }
html.dark-mode body :is(.btn-outline,.btn-danger) { background-color:#20314a !important; color:#d7e4f7 !important; border-color:#40516a !important; }

/* Pharmacy dashboard and stock page surfaces. */
html.dark-mode body :is(.metric-card,.dashboard-panel,.today-chip) {
  background-color:#172337 !important;
  color:#e5edf8 !important;
  border-color:#2b3a50 !important;
}
html.dark-mode body :is(.metric-card span,.dashboard-panel .sub,.stock-empty,.today-chip) {
  color:#a7b5c9 !important;
}
html.dark-mode body .metric-card strong { color:#e5edf8 !important; }
html.dark-mode body .metric-card a { color:#9fc1ff !important; }
html.dark-mode body .status-pill,
html.dark-mode body .tag {
  background-color:#3b321f !important;
  color:#f5d58a !important;
}
html.dark-mode body .warn { color:#f5d58a !important; }


/* Login surfaces use the same card treatment in every role, including dark mode. */
html.dark-mode body.login-page { background:#101827 !important; color:#e5edf8 !important; }
html.dark-mode body.login-page .login-card { background:#172337 !important; color:#e5edf8 !important; border-color:#2b3a50 !important; }
html.dark-mode body.login-page .login-card :is(h1,p,label,.brand,.copyright) { color:#e5edf8 !important; }
html.dark-mode body.login-page .login-card :is(input,select) { background:#101a29 !important; color:#f1f5f9 !important; border-color:#40516a !important; }
html.dark-mode body.login-page .login-card .primary { background:#3569c8 !important; color:#fff !important; }
html.dark-mode body.login-page .login-card .back-link { color:#b9d0ff !important; }
html.dark-mode body.login-page .login-card .flash.error { background:#45232c !important; color:#ffd5d9 !important; border-color:#74404a !important; }

/* Billing and lab secondary copy stays comfortably readable in dark mode. */
html.dark-mode body :is(.billing-metric,.billing-panel,.billing-dashboard,.billing-dashboard-grid,.lab-metric,.lab-panel,.lab-activity,.lab-dashboard,.lab-dashboard-grid) { color:#e5edf8 !important; }
html.dark-mode body :is(.billing-metric span,.billing-metric small,.billing-panel p,.billing-panel small,.billing-dashboard small,.lab-metric span,.lab-metric small,.lab-panel p,.lab-panel small,.lab-activity p,.lab-activity small,.page-description,.result-count,.info-label,.user-area,.user-button,.user-menu-btn) { color:#d2dced !important; }
html.dark-mode body :is(.billing-metric strong,.billing-panel strong,.lab-metric strong,.lab-panel strong,.user-icon) { color:#f1f5f9 !important; }
html.dark-mode body :is(.billing-dashboard a,.lab-dashboard a,.user-dropdown a) { color:#b9d0ff !important; }
html.dark-mode body :is(.user-icon,.user-avatar) { background:#20314a !important; border-color:#40516a !important; }

/* Change password form surfaces and copy. */
html.dark-mode body.change-password-page { background:#101827 !important; color:#e5edf8 !important; }
html.dark-mode body.change-password-page .change-password-card { background:#172337 !important; color:#e5edf8 !important; border:1px solid #2b3a50 !important; box-shadow:0 18px 50px #0005 !important; }
html.dark-mode body.change-password-page .change-password-card :is(h1,label) { color:#f1f5f9 !important; }
html.dark-mode body.change-password-page .change-password-card .intro { color:#d2dced !important; }
html.dark-mode body.change-password-page .change-password-card input { background:#101a29 !important; color:#f1f5f9 !important; border-color:#40516a !important; }
html.dark-mode body.change-password-page .change-password-card input::placeholder { color:#a7b5c9 !important; }
html.dark-mode body.change-password-page .change-password-card .message.error { background:#45232c !important; color:#ffd5d9 !important; border:1px solid #74404a !important; }
html.dark-mode body.change-password-page .change-password-card .message.success { background:#173b2c !important; color:#b9f1ce !important; border:1px solid #2f6b4c !important; }
html.dark-mode body.change-password-page .change-password-card button { background:#3569c8 !important; color:#fff !important; }
html.dark-mode body.change-password-page .change-password-card .back { color:#b9d0ff !important; }
