
/* UCC-ERS UI v4.4 — Light-default dashboard theme with complete dark mode support */
:root {
  --ui-font: Inter, 'Segoe UI', Arial, sans-serif;
  --bg: #f4f6f8;
  --bg-elev: #ffffff;
  --bg-soft: #f1f4f7;
  --bg-muted: #edf1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef3f6;
  --text: #17212b;
  --text-strong: #0c131a;
  --text-soft: #607180;
  --text-muted: #7d8a96;
  --line: #d8e0e6;
  --line-strong: #c7d1d9;
  --accent: #35c46d;
  --accent-strong: #23a956;
  --accent-soft: rgba(53,196,109,.12);
  --accent-soft-2: rgba(53,196,109,.18);
  --warning: #f0b24a;
  --danger: #f87171;
  --shadow-sm: 0 8px 26px rgba(12, 19, 26, .06);
  --shadow-md: 0 14px 40px rgba(12, 19, 26, .08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-bg: linear-gradient(180deg, #0b1216 0%, #0b1614 100%);
  --sidebar-surface: rgba(255,255,255,.04);
  --sidebar-active: rgba(255,255,255,.14);
  --sidebar-text: rgba(255,255,255,.88);
  --sidebar-muted: rgba(255,255,255,.56);
  --topbar-bg: rgba(255,255,255,.88);
  --topbar-border: rgba(23,33,43,.06);
  --page-max: 1440px;
}
body.theme-dark, html[data-theme="dark"] body {
  --bg: #0b1114;
  --bg-elev: #10181c;
  --bg-soft: #0f171b;
  --bg-muted: #121d21;
  --surface: #121b20;
  --surface-2: #0f171b;
  --surface-3: #172127;
  --text: #edf2f7;
  --text-strong: #ffffff;
  --text-soft: #b3bec8;
  --text-muted: #93a0ab;
  --line: #1d2a30;
  --line-strong: #22343d;
  --accent: #39d074;
  --accent-strong: #1fc95f;
  --accent-soft: rgba(57,208,116,.16);
  --accent-soft-2: rgba(57,208,116,.24);
  --warning: #f3b64f;
  --danger: #f87171;
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, .25);
  --shadow-md: 0 24px 60px rgba(0, 0, 0, .28);
  --sidebar-bg: linear-gradient(180deg, #070b0e 0%, #0b1114 100%);
  --sidebar-surface: rgba(255,255,255,.04);
  --sidebar-active: rgba(255,255,255,.10);
  --sidebar-text: rgba(255,255,255,.92);
  --sidebar-muted: rgba(255,255,255,.48);
  --topbar-bg: rgba(18,27,32,.84);
  --topbar-border: rgba(255,255,255,.05);
}
html, body { background: var(--bg) !important; color: var(--text) !important; font-family: var(--ui-font) !important; }
body { letter-spacing: -.01em; }
a { color: inherit; }
.ers-admin, .ers-app.ers-user, .ers-app.ers-public { background: var(--bg) !important; color: var(--text) !important; }
.admin-container, .user-container { background: var(--bg) !important; }
.main-content, .user-main { background: var(--bg) !important; min-height: 100vh; }
.content-area { max-width: var(--page-max); margin: 0 auto; padding: 24px 26px 40px !important; }
.ers-sidebar, .sidebar, .user-sidebar {
  background: var(--sidebar-bg) !important;
  color: var(--sidebar-text) !important;
  border-right: 1px solid rgba(255,255,255,.05);
  box-shadow: none !important;
}
.sidebar-header { padding: 14px 14px 12px !important; margin-bottom: 18px !important; border-bottom: 1px solid rgba(255,255,255,.05) !important; }
.sidebar-brand-lockup, .sidebar-header .sidebar-brand-lockup { display:flex; align-items:center; gap:14px; padding:14px; border-radius: 16px; background: var(--sidebar-surface); border: 1px solid rgba(255,255,255,.06); }
.sidebar-logo { width: 42px !important; height: 42px !important; padding: 5px !important; border-radius: 12px !important; background: rgba(255,255,255,.96) !important; box-shadow: none !important; }
.sidebar-title { font-size: 1.05rem !important; font-weight: 800 !important; color: #fff !important; letter-spacing: -.02em !important; }
.sidebar-subtitle { font-size: .76rem !important; color: var(--sidebar-muted) !important; opacity: 1 !important; margin-top: 2px !important; }
.nav-menu { padding: 0 12px 96px !important; }
.nav-section-label { color: var(--sidebar-muted) !important; font-size: .74rem !important; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; margin: 18px 12px 10px; }
.nav-link {
  color: var(--sidebar-text) !important;
  padding: 11px 14px !important;
  border-radius: 14px !important;
  font-weight: 700 !important;
  font-size: .95rem !important;
  gap: 12px !important;
  border: 1px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.08) !important; text-decoration: none !important; }
.nav-link.active {
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.12)) !important;
  border-color: rgba(255,255,255,.06) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.nav-icon { width: 20px !important; height: 20px !important; display: inline-flex !important; align-items: center; justify-content: center; color: inherit !important; }
.ers-icon { width: 18px; height: 18px; }
.nav-divider { background: rgba(255,255,255,.05) !important; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.05) !important; color: var(--sidebar-muted) !important; font-size: .72rem !important; background: transparent !important; }
.ers-topbar, .topbar, .user-topbar {
  position: sticky; top: 0; z-index: 90;
  backdrop-filter: blur(18px);
  background: var(--topbar-bg) !important;
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: none !important;
  padding: 14px 26px !important;
}
.topbar-leading, .page-title-block { display:flex; align-items:center; gap:14px; }
.page-eyebrow { display:block; font-size: .72rem !important; letter-spacing: .15em; text-transform: uppercase; color: var(--text-muted) !important; font-weight: 800; margin-bottom: 4px; }
.page-title { color: var(--text-strong) !important; font-size: 2rem !important; font-weight: 800 !important; letter-spacing: -.03em !important; }
@media (max-width: 980px){ .page-title { font-size: 1.45rem !important; } }
.topbar-icon-button, .ers-icon-button, .user-profile-trigger, .theme-toggle-btn, .notification-bell, .qr-code-btn, .ers-mobile-menu-toggle {
  border: 1px solid var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: 14px !important;
  box-shadow: none !important;
}
.topbar-icon-button:hover, .theme-toggle-btn:hover, .ers-mobile-menu-toggle:hover, .user-profile-trigger:hover { background: var(--surface-2) !important; }
.ers-mobile-menu-toggle { padding: 10px !important; display:inline-flex; align-items:center; justify-content:center; }
.user-menu { gap: 10px !important; }
.user-info .user-name, .user-name { color: var(--text-strong) !important; font-weight: 800 !important; }
.user-role, .user-email { color: var(--text-muted) !important; }
.user-avatar {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%) !important;
  color: #07110b !important;
  font-weight: 900 !important;
  box-shadow: none !important;
}
.user-profile-trigger { gap: 12px; padding: 7px 10px 7px 7px !important; }
.user-profile-menu, .notification-dropdown, .qr-modal, .modal-content {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 18px !important;
  box-shadow: var(--shadow-md) !important;
}
.profile-menu-header { border-bottom: 1px solid var(--line) !important; color: var(--text-muted) !important; }
.profile-menu-item { color: var(--text) !important; }
.profile-menu-item:hover { background: var(--surface-2) !important; }
.system-clock {
  background: var(--surface) !important;
  color: var(--text-strong) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}
.clock-time { color: var(--accent) !important; }
.clock-date { color: var(--text-muted) !important; }
.card, .dashboard-card, .stat-card, .calendar-wrapper, .scheduled-events, .upcoming-events,
.campuses-list, .establishments-list, .campuses-section, .establishments-section,
.settings-card, .guide-section, .reservation-card, .summary-card, .chat-container,
.chat-list-panel, .chat-main-panel, .reports-panel, .content-card, .panel-card, .status-card,
.info-card, .table-card, .vehicle-card, .request-card, .welcome-banner, .auth-card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 22px !important;
  box-shadow: var(--shadow-sm) !important;
}
.section-header, .card-header, .calendar-header, .panel-header {
  border-bottom: 1px solid var(--line) !important;
}
.section-title, .card-title, .month-title, .campus-name, .stat-label, .activity-action, .summary-title, .settings-title, .panel-title {
  color: var(--text-strong) !important;
}
.card-subtitle, .campus-label, .activity-detail, .result-count, .empty-state, .help-text, .section-subtitle, .stat-trend,
.info-label, .day-caption, .campus-code, .campus-address {
  color: var(--text-muted) !important;
}
.stat-card::before { background: var(--accent) !important; }
.stat-value, .campus-value, .info-value { color: var(--text-strong) !important; }
.stat-icon, .activity-icon { background: var(--surface-3) !important; color: var(--accent) !important; }
.welcome-banner { background: linear-gradient(180deg, rgba(57,208,116,.12), rgba(57,208,116,.08)) !important; border-color: rgba(57,208,116,.18) !important; }
.welcome-banner .welcome-text, .welcome-banner * { color: var(--text) !important; }
input, select, textarea, .search-input, .filter-select, .form-group input, .form-group textarea, .form-group select {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}
input::placeholder, textarea::placeholder { color: var(--text-muted) !important; }
label, .form-group label, .filter-group label, .rows-per-page label { color: var(--text-soft) !important; }
.btn, button, .btn-add, .btn-submit, .btn-view, .nav-btn, .today-btn, .submit-btn, .action-btn-primary {
  border-radius: 12px !important;
}
.btn-add, .btn-submit, .btn-view, .today-btn, .submit-btn, .action-btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%) !important;
  color: #08120d !important;
  border: none !important;
  font-weight: 800 !important;
}
.btn-view:hover, .btn-add:hover, .btn-submit:hover, .today-btn:hover { filter: brightness(.98); }
.nav-btn { background: var(--surface-2) !important; color: var(--text) !important; border: 1px solid var(--line) !important; }
.nav-btn.active { background: var(--accent-soft) !important; color: var(--accent) !important; border-color: rgba(57,208,116,.26) !important; }
.action-btn { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--line) !important; }
.action-btn:hover { background: var(--surface-2) !important; }
.data-table, .user-table, .establishment-table, table {
  color: var(--text) !important;
  background: transparent !important;
}
.data-table th, .user-table th, .establishment-table th, table th {
  background: var(--surface-2) !important;
  color: var(--text-soft) !important;
  border-bottom: 1px solid var(--line) !important;
  text-transform: uppercase; letter-spacing: .06em; font-size: .72rem !important;
}
.data-table td, .user-table td, .establishment-table td, table td { border-bottom: 1px solid var(--line) !important; color: var(--text) !important; }
.data-table tr:hover td, .user-table tr:hover td, .establishment-table tr:hover td, table tr:hover td { background: var(--surface-2) !important; }
.badge, .status-badge, .card-type, .activity-role, .role-user, .role-admin {
  background: var(--accent-soft) !important; color: var(--accent) !important; border: 1px solid rgba(57,208,116,.22) !important;
}
.status-inactive { background: rgba(148,163,184,.14) !important; color: #93a0ab !important; border-color: rgba(148,163,184,.18) !important; }
.notification-item, .chat-item, .message-bubble, .toast-notification, .calendar-day, .event-item, .event-row, .availability-card, .filter-card {
  background: var(--surface-2) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
}
.message-bubble.sent { background: rgba(57,208,116,.13) !important; border-color: rgba(57,208,116,.2) !important; }
.calendar-day:hover, .notification-item:hover, .event-item:hover { background: var(--surface-3) !important; }
.weekday { background: var(--surface-2) !important; color: var(--text-soft) !important; }
.calendar-day.selected { background: var(--accent-soft) !important; border-color: rgba(57,208,116,.35) !important; }
.calendar-day.today { box-shadow: inset 0 0 0 1px rgba(57,208,116,.35); }
.event-badge { background: rgba(57,208,116,.11) !important; color: var(--accent) !important; border-left-color: var(--accent) !important; }
.pagination .page-link, .pagination a, .pagination span { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important; }
.pagination .page-link:hover, .pagination a:hover, .pagination .active span, .pagination span.active { background: var(--accent) !important; color: #07110b !important; border-color: transparent !important; }
.campus-card, .establishment-card {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}
.campus-card.selected, .establishment-card:hover { border-color: rgba(57,208,116,.35) !important; box-shadow: 0 0 0 3px rgba(57,208,116,.08) !important; }
.campus-card .campus-content, .campus-card .campus-name, .campus-card .campus-code, .campus-card .campus-address { color: var(--text) !important; text-shadow: none !important; }
.campus-card::before { background: linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,.02)) !important; }
.card-header, .establishment-card > .card-header { background: linear-gradient(180deg, rgba(57,208,116,.16), rgba(57,208,116,.10)) !important; color: var(--text) !important; }
.card-header h3, .establishment-card > .card-header h3 { color: var(--text-strong) !important; }
.empty-state { color: var(--text-muted) !important; }
.selected-campus-info { background: var(--surface-2) !important; color: var(--text) !important; border: 1px solid var(--line) !important; }
.notification-badge, .nav-count-badge { background: #ff6363 !important; color: #fff !important; }
.ers-page-progress { background: linear-gradient(90deg, var(--accent), #7bed9f) !important; }
.ers-sidebar-overlay { background: rgba(0,0,0,.55) !important; }
/* Public / auth */
.auth-page, .public-layout, .hero-panel, .form-panel { background: var(--bg) !important; }
.auth-card, .form-card, .availability-card, .maintenance-card, .pending-card, .rejected-card { background: var(--surface) !important; border: 1px solid var(--line) !important; color: var(--text) !important; }
.hero-panel { background: radial-gradient(circle at top left, rgba(57,208,116,.18), transparent 40%), linear-gradient(180deg, #0b1216 0%, #10181c 100%) !important; }
.hero-title, .hero-description, .hero-stat-value, .hero-stat-label, .hero-tag { color: #fff !important; }
/* Theme toggle */
.theme-toggle-btn { width: 46px; height: 46px; padding: 0 !important; display:inline-flex; align-items:center; justify-content:center; }
.theme-toggle-btn .theme-icon-sun, .theme-toggle-btn .theme-icon-moon { position:absolute; transition: opacity .2s ease, transform .2s ease; }
.theme-toggle-btn { position: relative; }
body.theme-dark .theme-toggle-btn .theme-icon-sun { opacity: 1; transform: scale(1); }
body.theme-dark .theme-toggle-btn .theme-icon-moon { opacity: 0; transform: scale(.75); }
body:not(.theme-dark) .theme-toggle-btn .theme-icon-sun { opacity: 0; transform: scale(.75); }
body:not(.theme-dark) .theme-toggle-btn .theme-icon-moon { opacity: 1; transform: scale(1); }
/* Responsive */
@media (max-width: 1200px){
  .content-area { padding: 20px !important; }
}
@media (max-width: 980px){
  .ers-topbar, .topbar, .user-topbar { padding: 12px 16px !important; }
  .content-area { padding: 16px !important; }
}


/* Shared admin content sections for v4 consistency */
.admin-page-stack { display: grid; gap: 22px; }
.admin-card, .filters-shell, .table-shell, .section-shell {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: 22px !important;
  box-shadow: var(--shadow-sm) !important;
}
.filters-shell, .table-shell, .section-shell, .admin-card { padding: 20px; }
.filters-form { display: grid; gap: 18px; }
.filters-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; align-items: end; }
.filters-grid.filters-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.filters-grid.filters-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filter-field { display: grid; gap: 8px; min-width: 0; }
.filter-field.filter-span-2 { grid-column: span 2; }
.filter-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--text-muted) !important; }
.filters-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-soft, .btn-outline, .btn-danger-soft, .btn-warning-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; text-decoration: none; cursor: pointer; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
.btn-soft:hover, .btn-outline:hover { text-decoration: none; background: var(--surface-3); }
.btn-outline { background: transparent; border-color: rgba(57,208,116,.35); color: var(--accent); }
.btn-warning-soft { background: rgba(240,178,74,.16); color: var(--warning); border-color: rgba(240,178,74,.24); }
.btn-danger-soft { background: rgba(248,113,113,.14); color: var(--danger); border-color: rgba(248,113,113,.22); }
.page-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.table-shell { overflow: hidden; }
.table-toolbar { display:flex; align-items:center; justify-content:space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.table-title { font-size: 1.35rem; font-weight: 800; color: var(--text-strong); letter-spacing: -.02em; }
.table-meta { font-size: .88rem; color: var(--text-muted); }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 960px; width: 100%; }
.compact-table th, .compact-table td { padding: 14px 12px !important; }
.cell-actions { display:flex; gap: 8px; align-items:center; flex-wrap: wrap; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; display:inline-flex; align-items:center; justify-content:center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration:none; cursor:pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--surface-3); text-decoration:none; }
.icon-btn.success { color: var(--accent); border-color: rgba(57,208,116,.25); background: rgba(57,208,116,.08); }
.icon-btn.warning { color: var(--warning); border-color: rgba(240,178,74,.25); background: rgba(240,178,74,.08); }
.icon-btn.danger { color: var(--danger); border-color: rgba(248,113,113,.22); background: rgba(248,113,113,.08); }
.section-heading { display:flex; align-items:center; justify-content:space-between; gap: 12px; flex-wrap:wrap; margin-bottom: 16px; }
.section-title-lg { font-size: 1.2rem; font-weight: 800; color: var(--text-strong); display:flex; align-items:center; gap: 10px; }
.section-count {
  display:inline-flex; align-items:center; justify-content:center; min-width: 26px; height: 26px; padding: 0 10px;
  border-radius: 999px; background: var(--surface-3); color: var(--text-soft); font-size: .8rem; font-weight: 800;
}
.info-note { font-size: .88rem; color: var(--text-muted); }
.inline-form { display:inline; }
.settings-grid-v4 { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card-v4 { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: 22px !important; box-shadow: var(--shadow-sm) !important; padding: 20px; }
.settings-card-v4.full-span { grid-column: 1 / -1; }
.settings-title-row { display:flex; align-items:center; justify-content:space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 18px; border-bottom:1px solid var(--line); }
.settings-title-row h3 { margin: 0; font-size: 1.15rem; color: var(--text-strong); }
@media (max-width: 1200px){ .filters-grid, .filters-grid.filters-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px){ .settings-grid-v4, .filters-grid, .filters-grid.filters-grid-5, .filters-grid.filters-grid-2 { grid-template-columns: 1fr; } .filter-field.filter-span-2 { grid-column: span 1; } }

.alert { padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); }
.alert-success { background: rgba(57,208,116,.12); color: var(--text); border-color: rgba(57,208,116,.2); }
.alert-error { background: rgba(248,113,113,.12); color: var(--text); border-color: rgba(248,113,113,.18); }
.status-approved { background: rgba(57,208,116,.12) !important; color: var(--accent) !important; border-color: rgba(57,208,116,.22) !important; }
.status-pending { background: rgba(240,178,74,.14) !important; color: var(--warning) !important; border-color: rgba(240,178,74,.22) !important; }
.status-rejected, .status-cancelled { background: rgba(248,113,113,.12) !important; color: var(--danger) !important; border-color: rgba(248,113,113,.2) !important; }
.pagination-container { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap: 14px; flex-wrap: wrap; }
.pagination-info, .rows-per-page label { color: var(--text-muted); font-size: .9rem; }
.rows-per-page { display:flex; align-items:center; gap: 10px; }
.rows-per-page select { min-width: 78px; }
@media (max-width: 900px){ .pagination-container { flex-direction: column; align-items: flex-start; } }


/* v4.3 theme coverage: light by default, dark across all shared-layout pages */
.ers-floating-theme-toggle {
  position: fixed !important;
  top: 18px;
  right: 18px;
  z-index: 1200;
  box-shadow: var(--shadow-sm) !important;
}

html[data-theme="dark"] .ers-app,
html[data-theme="dark"] .ers-admin,
html[data-theme="dark"] .auth-page,
html[data-theme="dark"] .public-layout,
html[data-theme="dark"] .user-container,
html[data-theme="dark"] .admin-container,
html[data-theme="dark"] .user-main,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .content-area {
  background: var(--bg) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .filters-bar,
html[data-theme="dark"] .users-section,
html[data-theme="dark"] .reservations-table,
html[data-theme="dark"] .vehicle-modal,
html[data-theme="dark"] .vehicle-form-grid,
html[data-theme="dark"] .settings-container,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .summary-section,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .details-card,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .guide-card,
html[data-theme="dark"] .guide-section,
html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .chat-sidebar,
html[data-theme="dark"] .chat-main,
html[data-theme="dark"] .reservation-form,
html[data-theme="dark"] .reservation-details,
html[data-theme="dark"] .form-section,
html[data-theme="dark"] .calendar-section,
html[data-theme="dark"] .availability-section,
html[data-theme="dark"] .search-filter-card,
html[data-theme="dark"] .search-filter-wrapper,
html[data-theme="dark"] .update-entry,
html[data-theme="dark"] .toggle-row,
html[data-theme="dark"] .backup-item {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow-sm) !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .page-title,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .panel-title,
html[data-theme="dark"] .form-title {
  color: var(--text-strong) !important;
}

html[data-theme="dark"] p,
html[data-theme="dark"] small,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .help-text,
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .form-hint {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] input:disabled,
html[data-theme="dark"] input[readonly],
html[data-theme="dark"] textarea:disabled,
html[data-theme="dark"] select:disabled {
  background: var(--surface-3) !important;
  color: var(--text-muted) !important;
}

html[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-soft); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #32424a; }

@media (max-width: 600px) {
  .ers-floating-theme-toggle { top: 12px; right: 12px; width: 42px; height: 42px; }
}

/* ========================================================================== 
   UCC-ERS v4.4 — DARK MODE NORMALIZATION
   High-specificity overrides for legacy/page-level styles.
   Light mode remains the default; these rules run only when data-theme=dark.
   ========================================================================== */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

/* Core shell: beat legacy body.ers-* selectors from older stylesheets. */
html[data-theme="dark"] body.ers-admin,
html[data-theme="dark"] body.ers-app.ers-user,
html[data-theme="dark"] body.ers-app.ers-auth,
html[data-theme="dark"] body.ers-app.ers-public,
html[data-theme="dark"] body.ers-admin .admin-container,
html[data-theme="dark"] body.ers-admin .main-content,
html[data-theme="dark"] body.ers-admin .content-area,
html[data-theme="dark"] body.ers-app.ers-user .user-container,
html[data-theme="dark"] body.ers-app.ers-user .user-main,
html[data-theme="dark"] body.ers-app.ers-user .content-area {
  background: var(--bg) !important;
  color: var(--text) !important;
}

/* Topbars and account controls. */
html[data-theme="dark"] body.ers-admin .topbar,
html[data-theme="dark"] body.ers-admin .ers-topbar,
html[data-theme="dark"] body.ers-app.ers-user .user-topbar,
html[data-theme="dark"] body.ers-app.ers-user .ers-topbar {
  background: rgba(15, 23, 27, .96) !important;
  border-bottom-color: var(--line) !important;
  color: var(--text) !important;
}
html[data-theme="dark"] body.ers-admin .topbar .page-title,
html[data-theme="dark"] body.ers-admin .topbar .user-name,
html[data-theme="dark"] body.ers-app.ers-user .user-topbar .page-title,
html[data-theme="dark"] body.ers-app.ers-user .user-topbar .user-name {
  color: var(--text-strong) !important;
}
html[data-theme="dark"] body.ers-admin .topbar .page-eyebrow,
html[data-theme="dark"] body.ers-admin .topbar .user-role,
html[data-theme="dark"] body.ers-app.ers-user .user-topbar .page-eyebrow,
html[data-theme="dark"] body.ers-app.ers-user .user-topbar .user-email {
  color: var(--text-muted) !important;
}
html[data-theme="dark"] body.ers-admin .topbar-icon-button,
html[data-theme="dark"] body.ers-admin .theme-toggle-btn,
html[data-theme="dark"] body.ers-admin .notification-bell,
html[data-theme="dark"] body.ers-admin .qr-code-btn,
html[data-theme="dark"] body.ers-app.ers-user .theme-toggle-btn,
html[data-theme="dark"] body.ers-app.ers-user .user-profile-trigger,
html[data-theme="dark"] body.ers-app.ers-user .system-clock {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .user-profile-menu,
html[data-theme="dark"] body.ers-admin .notification-dropdown,
html[data-theme="dark"] body.ers-admin .qr-modal {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .profile-menu-header,
html[data-theme="dark"] body.ers-app.ers-user .profile-menu-item,
html[data-theme="dark"] body.ers-app.ers-user .profile-menu-item span,
html[data-theme="dark"] body.ers-admin .notification-item,
html[data-theme="dark"] body.ers-admin .notification-header,
html[data-theme="dark"] body.ers-admin .notification-footer {
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .profile-menu-item:hover,
html[data-theme="dark"] body.ers-admin .notification-item:hover {
  background: var(--surface-2) !important;
}

/* Forms: force every field, including date/select controls, into the same palette. */
html[data-theme="dark"] body.ers-admin input,
html[data-theme="dark"] body.ers-admin select,
html[data-theme="dark"] body.ers-admin textarea,
html[data-theme="dark"] body.ers-app.ers-user input,
html[data-theme="dark"] body.ers-app.ers-user select,
html[data-theme="dark"] body.ers-app.ers-user textarea,
html[data-theme="dark"] body.ers-app.ers-auth input,
html[data-theme="dark"] body.ers-app.ers-auth select,
html[data-theme="dark"] body.ers-app.ers-auth textarea,
html[data-theme="dark"] body.ers-app.ers-public input,
html[data-theme="dark"] body.ers-app.ers-public select,
html[data-theme="dark"] body.ers-app.ers-public textarea {
  background-color: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  -webkit-text-fill-color: var(--text) !important;
}
html[data-theme="dark"] body select option { background: #10181c !important; color: #eef4f7 !important; }
html[data-theme="dark"] body input::placeholder,
html[data-theme="dark"] body textarea::placeholder { color: #73818b !important; -webkit-text-fill-color: #73818b !important; }
html[data-theme="dark"] body input[readonly],
html[data-theme="dark"] body input:disabled,
html[data-theme="dark"] body textarea:disabled,
html[data-theme="dark"] body select:disabled { background: var(--surface-3) !important; color: var(--text-muted) !important; -webkit-text-fill-color: var(--text-muted) !important; }

/* Tables: eliminate dark-on-dark text and leftover white rows. */
html[data-theme="dark"] body.ers-admin table,
html[data-theme="dark"] body.ers-app.ers-user table {
  background: transparent !important;
  color: var(--text) !important;
}
html[data-theme="dark"] body.ers-admin table thead,
html[data-theme="dark"] body.ers-app.ers-user table thead,
html[data-theme="dark"] body.ers-admin table th,
html[data-theme="dark"] body.ers-app.ers-user table th {
  background: #0c1519 !important;
  color: #9fb0bb !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin table td,
html[data-theme="dark"] body.ers-app.ers-user table td {
  background: transparent !important;
  color: #e8eef2 !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin table tbody tr:hover td,
html[data-theme="dark"] body.ers-app.ers-user table tbody tr:hover td { background: rgba(255,255,255,.025) !important; }
html[data-theme="dark"] body.ers-admin .pagination-container,
html[data-theme="dark"] body.ers-app.ers-user .pagination-container,
html[data-theme="dark"] body.ers-admin .pagination,
html[data-theme="dark"] body.ers-app.ers-user .pagination { border-color: var(--line) !important; color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-admin .pagination a,
html[data-theme="dark"] body.ers-admin .pagination span,
html[data-theme="dark"] body.ers-app.ers-user .pagination a,
html[data-theme="dark"] body.ers-app.ers-user .pagination span,
html[data-theme="dark"] body.ers-app.ers-user .page-btn {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

/* ADMIN — Dashboard */
html[data-theme="dark"] body.ers-admin .welcome-banner,
html[data-theme="dark"] body.ers-admin .stat-card,
html[data-theme="dark"] body.ers-admin .dashboard-card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .welcome-title,
html[data-theme="dark"] body.ers-admin .stat-value,
html[data-theme="dark"] body.ers-admin .stat-label,
html[data-theme="dark"] body.ers-admin .card-title,
html[data-theme="dark"] body.ers-admin .campus-name,
html[data-theme="dark"] body.ers-admin .campus-value,
html[data-theme="dark"] body.ers-admin .activity-action { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .welcome-subtitle,
html[data-theme="dark"] body.ers-admin .stat-trend,
html[data-theme="dark"] body.ers-admin .card-subtitle,
html[data-theme="dark"] body.ers-admin .campus-label,
html[data-theme="dark"] body.ers-admin .activity-detail,
html[data-theme="dark"] body.ers-admin .activity-time { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-admin .campus-item,
html[data-theme="dark"] body.ers-admin .activity-item {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .utilization-bar { background: #223039 !important; }
html[data-theme="dark"] body.ers-admin .activity-icon { background: var(--surface-3) !important; color: var(--accent) !important; }
html[data-theme="dark"] body.ers-admin .role-user { background: rgba(148,163,184,.12) !important; color: #b8c3ca !important; }
html[data-theme="dark"] body.ers-admin .role-admin { background: var(--accent-soft) !important; color: var(--accent) !important; }

/* ADMIN + USER — Availability calendars */
html[data-theme="dark"] body.ers-admin .availability-container .calendar-wrapper,
html[data-theme="dark"] body.ers-admin .events-panel .scheduled-events,
html[data-theme="dark"] body.ers-admin .events-panel .upcoming-events,
html[data-theme="dark"] body.ers-app.ers-user .dashboard-layout .calendar-wrapper,
html[data-theme="dark"] body.ers-app.ers-user .events-panel .scheduled-events,
html[data-theme="dark"] body.ers-app.ers-user .events-panel .upcoming-events {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .calendar-header,
html[data-theme="dark"] body.ers-app.ers-user .calendar-header,
html[data-theme="dark"] body.ers-admin .panel-header,
html[data-theme="dark"] body.ers-app.ers-user .panel-header { border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .month-title,
html[data-theme="dark"] body.ers-app.ers-user .month-title,
html[data-theme="dark"] body.ers-admin .panel-title,
html[data-theme="dark"] body.ers-app.ers-user .panel-title,
html[data-theme="dark"] body.ers-admin .event-name,
html[data-theme="dark"] body.ers-app.ers-user .event-name { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .weekday,
html[data-theme="dark"] body.ers-app.ers-user .weekday {
  background: var(--surface-2) !important;
  color: #aebac2 !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .calendar-day,
html[data-theme="dark"] body.ers-app.ers-user .calendar-day,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-cell {
  background: #111b20 !important;
  color: var(--text) !important;
  border-color: #1c2a31 !important;
}
html[data-theme="dark"] body.ers-admin .calendar-day:hover,
html[data-theme="dark"] body.ers-app.ers-user .calendar-day:hover,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-cell:hover { background: #17242a !important; border-color: #2b414a !important; }
html[data-theme="dark"] body.ers-admin .calendar-day.other-month,
html[data-theme="dark"] body.ers-app.ers-user .calendar-day.other-month,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-cell.other-month { background: #0d1519 !important; color: #53626c !important; opacity: .8 !important; }
html[data-theme="dark"] body.ers-admin .calendar-day.today,
html[data-theme="dark"] body.ers-app.ers-user .calendar-day.today { background: rgba(57,208,116,.10) !important; border-color: rgba(57,208,116,.42) !important; }
html[data-theme="dark"] body.ers-admin .day-number,
html[data-theme="dark"] body.ers-app.ers-user .day-number { color: #dce5ea !important; }
html[data-theme="dark"] body.ers-admin .calendar-day.today .day-number,
html[data-theme="dark"] body.ers-app.ers-user .calendar-day.today .day-number { color: var(--accent) !important; }
html[data-theme="dark"] body.ers-admin .event-item,
html[data-theme="dark"] body.ers-app.ers-user .event-item,
html[data-theme="dark"] body.ers-admin .no-events,
html[data-theme="dark"] body.ers-app.ers-user .no-events {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .event-time,
html[data-theme="dark"] body.ers-app.ers-user .event-time { background: var(--surface-3) !important; color: var(--text) !important; }
html[data-theme="dark"] body.ers-admin .event-venue,
html[data-theme="dark"] body.ers-admin .event-campus,
html[data-theme="dark"] body.ers-app.ers-user .event-venue,
html[data-theme="dark"] body.ers-app.ers-user .event-campus { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-admin .legend,
html[data-theme="dark"] body.ers-app.ers-user .legend { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .legend-title,
html[data-theme="dark"] body.ers-admin .legend-item,
html[data-theme="dark"] body.ers-app.ers-user .legend-title,
html[data-theme="dark"] body.ers-app.ers-user .legend-item { color: var(--text) !important; }
html[data-theme="dark"] body.ers-admin .selected-date-badge,
html[data-theme="dark"] body.ers-app.ers-user .selected-date-badge { background: var(--accent-soft) !important; color: var(--accent) !important; border-color: rgba(57,208,116,.2) !important; }
html[data-theme="dark"] body.ers-admin .calendar-nav .nav-btn,
html[data-theme="dark"] body.ers-app.ers-user .calendar-nav .nav-btn,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-nav button,
html[data-theme="dark"] body.ers-app.ers-user .calendar-nav button {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .calendar-nav .today-btn,
html[data-theme="dark"] body.ers-app.ers-user .calendar-nav .today-btn,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-nav .today-btn { background: var(--accent-soft) !important; color: var(--accent) !important; border-color: rgba(57,208,116,.3) !important; }

/* ADMIN — Users, admins, reservations, vehicles. */
html[data-theme="dark"] body.ers-admin .filters-shell,
html[data-theme="dark"] body.ers-admin .section-shell,
html[data-theme="dark"] body.ers-admin .table-shell,
html[data-theme="dark"] body.ers-admin .filters-bar,
html[data-theme="dark"] body.ers-admin .users-section,
html[data-theme="dark"] body.ers-admin .reservations-table,
html[data-theme="dark"] body.ers-admin .admins-table {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow-sm) !important;
}
html[data-theme="dark"] body.ers-admin .admins-table th,
html[data-theme="dark"] body.ers-admin .admins-table td { color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .warning { background: var(--accent-soft) !important; color: var(--text) !important; border-color: rgba(57,208,116,.22) !important; }
html[data-theme="dark"] body.ers-admin .table-title,
html[data-theme="dark"] body.ers-admin .section-title-lg { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .table-meta,
html[data-theme="dark"] body.ers-admin .pagination-info { color: var(--text-muted) !important; }

/* ADMIN — Campuses and establishments. */
html[data-theme="dark"] body.ers-admin .campuses-list,
html[data-theme="dark"] body.ers-admin .establishments-list,
html[data-theme="dark"] body.ers-admin #establishmentsContent,
html[data-theme="dark"] body.ers-admin .search-filter-bar {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .campus-card {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .campus-content { background: var(--surface) !important; color: var(--text) !important; }
html[data-theme="dark"] body.ers-admin .campus-name { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .campus-code,
html[data-theme="dark"] body.ers-admin .campus-address { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-admin .campus-actions .action-btn,
html[data-theme="dark"] body.ers-admin .action-btn { background: rgba(13,21,25,.94) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .selected-campus-info { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .selected-campus-info * { color: inherit !important; }
html[data-theme="dark"] body.ers-admin .establishment-table th { background: #0c1519 !important; color: #9fb0bb !important; }
html[data-theme="dark"] body.ers-admin .establishment-table td { color: var(--text) !important; }

/* ADMIN — Chat. */
html[data-theme="dark"] body.ers-admin .chat-container,
html[data-theme="dark"] body.ers-admin .chat-sidebar,
html[data-theme="dark"] body.ers-admin .chat-main,
html[data-theme="dark"] body.ers-admin .chat-sidebar-header,
html[data-theme="dark"] body.ers-admin .chat-header,
html[data-theme="dark"] body.ers-admin .chat-messages,
html[data-theme="dark"] body.ers-admin .chat-input-area,
html[data-theme="dark"] body.ers-admin .new-chat-modal {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .chat-messages { background: #0d1519 !important; }
html[data-theme="dark"] body.ers-admin .session-item { background: transparent !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .session-item:hover,
html[data-theme="dark"] body.ers-admin .session-item.active { background: var(--surface-3) !important; }
html[data-theme="dark"] body.ers-admin .session-user,
html[data-theme="dark"] body.ers-admin .chat-header h4,
html[data-theme="dark"] body.ers-admin .new-chat-modal-header h3 { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .session-last,
html[data-theme="dark"] body.ers-admin .message-time,
html[data-theme="dark"] body.ers-admin .no-chat-selected { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-admin .message.received .message-bubble { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .message.sent .message-bubble { background: var(--accent-soft) !important; color: var(--text) !important; border-color: rgba(57,208,116,.2) !important; }
html[data-theme="dark"] body.ers-admin .new-chat-modal-overlay > div[style*="background: white"],
html[data-theme="dark"] body.ers-admin [style*="background: white"][style*="border-radius"] { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important; }

/* ADMIN — Settings. */
html[data-theme="dark"] body.ers-admin .settings-card-v4,
html[data-theme="dark"] body.ers-admin .toggle-row,
html[data-theme="dark"] body.ers-admin .update-entry {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-admin .toggle-row { background: var(--surface-2) !important; }
html[data-theme="dark"] body.ers-admin .toggle-row-label,
html[data-theme="dark"] body.ers-admin .settings-title-row h3,
html[data-theme="dark"] body.ers-admin .update-entry-version { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .toggle-row-sub,
html[data-theme="dark"] body.ers-admin .update-entry-date { color: var(--text-muted) !important; }

/* USER — Summary and generic sections. */
html[data-theme="dark"] body.ers-app.ers-user .section,
html[data-theme="dark"] body.ers-app.ers-user .summary-card,
html[data-theme="dark"] body.ers-app.ers-user .table-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .section-header,
html[data-theme="dark"] body.ers-app.ers-user .section-title { color: var(--text-strong) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .section-count,
html[data-theme="dark"] body.ers-app.ers-user .section-badge { background: var(--surface-3) !important; color: var(--text-soft) !important; }
html[data-theme="dark"] body.ers-app.ers-user .empty-state { background: var(--surface-2) !important; color: var(--text-muted) !important; border-color: var(--line) !important; }

/* USER — Venue reservations. */
html[data-theme="dark"] body.ers-app.ers-user .campuses-section,
html[data-theme="dark"] body.ers-app.ers-user .establishments-section,
html[data-theme="dark"] body.ers-app.ers-user .search-filter-card,
html[data-theme="dark"] body.ers-app.ers-user .search-filter-wrapper,
html[data-theme="dark"] body.ers-app.ers-user .establishment-card,
html[data-theme="dark"] body.ers-app.ers-user .calendar-section,
html[data-theme="dark"] body.ers-app.ers-user .form-section {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .campus-card { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .campus-content { background: var(--surface) !important; color: var(--text) !important; }
html[data-theme="dark"] body.ers-app.ers-user .campus-kicker,
html[data-theme="dark"] body.ers-app.ers-user .campus-select-hint,
html[data-theme="dark"] body.ers-app.ers-user .campus-code,
html[data-theme="dark"] body.ers-app.ers-user .campus-address { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-user .campus-name,
html[data-theme="dark"] body.ers-app.ers-user .establishment-card > .card-header h3 { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-app.ers-user .selected-campus-info { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .selected-campus-info * { color: inherit !important; }
html[data-theme="dark"] body.ers-app.ers-user .establishment-card > .card-header { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .establishment-card > .card-body { background: var(--surface) !important; color: var(--text) !important; }
html[data-theme="dark"] body.ers-app.ers-user .info-row { border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .info-label { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-user .info-value { color: var(--text-strong) !important; }

/* USER — Vehicle reservations. */
html[data-theme="dark"] body.ers-app.ers-user .panel-card,
html[data-theme="dark"] body.ers-app.ers-user .calendar-card,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-card,
html[data-theme="dark"] body.ers-app.ers-user .calendar-details,
html[data-theme="dark"] body.ers-app.ers-user .selected-date-list,
html[data-theme="dark"] body.ers-app.ers-user .radio-option,
html[data-theme="dark"] body.ers-app.ers-user .request-card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .panel-title,
html[data-theme="dark"] body.ers-app.ers-user .calendar-month,
html[data-theme="dark"] body.ers-app.ers-user .calendar-details h4,
html[data-theme="dark"] body.ers-app.ers-user .request-purpose { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-app.ers-user .form-hint,
html[data-theme="dark"] body.ers-app.ers-user .request-detail-row span:first-child,
html[data-theme="dark"] body.ers-app.ers-user .date-picker-note { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-user .request-detail-row,
html[data-theme="dark"] body.ers-app.ers-user .calendar-details .detail-item { border-color: var(--line) !important; color: var(--text) !important; }
html[data-theme="dark"] body.ers-app.ers-user .selected-date-chip { background: var(--accent-soft) !important; color: var(--accent) !important; border-color: rgba(57,208,116,.2) !important; }

/* USER — Messages. */
html[data-theme="dark"] body.ers-app.ers-user .chat-container,
html[data-theme="dark"] body.ers-app.ers-user .chat-header,
html[data-theme="dark"] body.ers-app.ers-user .chat-messages,
html[data-theme="dark"] body.ers-app.ers-user .chat-input-area {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .chat-messages { background: #0d1519 !important; }
html[data-theme="dark"] body.ers-app.ers-user .chat-header h3 { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-app.ers-user .chat-header p,
html[data-theme="dark"] body.ers-app.ers-user .message-time,
html[data-theme="dark"] body.ers-app.ers-user .no-messages { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-user .message.received .message-bubble { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .message.sent .message-bubble { background: var(--accent-soft) !important; color: var(--text) !important; border-color: rgba(57,208,116,.2) !important; }

/* USER — Guide + Account Settings. */
html[data-theme="dark"] body.ers-app.ers-user .guide-card,
html[data-theme="dark"] body.ers-app.ers-user .settings-card,
html[data-theme="dark"] body.ers-app.ers-user .info-text {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .guide-header,
html[data-theme="dark"] body.ers-app.ers-user .card-title { border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .guide-title,
html[data-theme="dark"] body.ers-app.ers-user .card-title { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-app.ers-user .card-subtitle,
html[data-theme="dark"] body.ers-app.ers-user .info-text { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-user .pdf-viewer { background: #111922 !important; border-color: var(--line) !important; }

/* Chatbot: full dark-theme support. */
html[data-theme="dark"] body .chatbot-window {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow-md) !important;
}
html[data-theme="dark"] body .chatbot-window-header { background: #0f6f46 !important; color: #fff !important; border-color: #0f6f46 !important; }
html[data-theme="dark"] body .chatbot-messages { background: #0d1519 !important; color: var(--text) !important; }
html[data-theme="dark"] body .chat-message.bot .chat-message-bubble { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body .chat-message.user .chat-message-bubble { background: var(--accent-soft) !important; color: var(--text) !important; border-color: rgba(57,208,116,.22) !important; }
html[data-theme="dark"] body .chatbot-quick-actions,
html[data-theme="dark"] body .chatbot-input-area,
html[data-theme="dark"] body .file-list { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body .quick-action-btn,
html[data-theme="dark"] body .suggestion-btn,
html[data-theme="dark"] body .file-item { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body .quick-action-btn:hover,
html[data-theme="dark"] body .suggestion-btn:hover { background: var(--surface-3) !important; }
html[data-theme="dark"] body .chatbot-input { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body .typing-indicator { background: var(--surface-3) !important; border-color: var(--line) !important; }

/* Dynamic inline fragments created by page JavaScript. This is intentionally scoped
   to logged-in ERS content so email/report/public markup is not changed. */
html[data-theme="dark"] body.ers-admin .content-area [style*="background: white"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background:#fff"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background: #fff"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background:#ffffff"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background: #ffffff"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background: white"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background:#fff"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background: #fff"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background:#ffffff"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background: #ffffff"] {
  background: var(--surface) !important;
  color: var(--text) !important;
}
html[data-theme="dark"] body.ers-admin .content-area [style*="background: #f7faf8"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background:#f7faf8"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background: #f0faf3"],
html[data-theme="dark"] body.ers-admin .content-area [style*="background:#f0faf3"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background: #f7faf8"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background:#f7faf8"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background: #f0faf3"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="background:#f0faf3"] {
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
html[data-theme="dark"] body.ers-admin .content-area [style*="color: #1a7a3e"],
html[data-theme="dark"] body.ers-admin .content-area [style*="color:#1a7a3e"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="color: #1a7a3e"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="color:#1a7a3e"] { color: var(--accent) !important; }
html[data-theme="dark"] body.ers-admin .content-area [style*="color: #3c4a3f"],
html[data-theme="dark"] body.ers-admin .content-area [style*="color:#3c4a3f"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="color: #3c4a3f"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="color:#3c4a3f"] { color: var(--text) !important; }
html[data-theme="dark"] body.ers-admin .content-area [style*="color: #6e7f72"],
html[data-theme="dark"] body.ers-admin .content-area [style*="color:#6e7f72"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="color: #6e7f72"],
html[data-theme="dark"] body.ers-app.ers-user .content-area [style*="color:#6e7f72"] { color: var(--text-muted) !important; }

/* Keep semantic colored controls readable. */
html[data-theme="dark"] body .btn-submit,
html[data-theme="dark"] body .btn-primary,
html[data-theme="dark"] body .btn-save,
html[data-theme="dark"] body .btn-add,
html[data-theme="dark"] body .btn-view:not(.btn-outline) { color: #07110b !important; }
html[data-theme="dark"] body .btn-danger,
html[data-theme="dark"] body .btn-delete { color: #ffd8d8 !important; }

/* Mobile dark mode should never introduce a light strip around content. */
@media (max-width: 980px) {
  html[data-theme="dark"] body.ers-admin .main-content,
  html[data-theme="dark"] body.ers-app.ers-user .user-main { background: var(--bg) !important; }
}

/* Remaining CRUD/detail pages and shared modal coverage. */
html[data-theme="dark"] body.ers-admin .reservation-create,
html[data-theme="dark"] body.ers-admin .reservation-header,
html[data-theme="dark"] body.ers-admin .reservation-body,
html[data-theme="dark"] body.ers-admin .panel-card,
html[data-theme="dark"] body.ers-admin .calendar-card,
html[data-theme="dark"] body.ers-admin .form-card,
html[data-theme="dark"] body.ers-admin .edit-card,
html[data-theme="dark"] body.ers-admin .detail-container,
html[data-theme="dark"] body.ers-admin .detail-card,
html[data-theme="dark"] body.ers-admin .date-picker-card,
html[data-theme="dark"] body.ers-admin .selected-date-list,
html[data-theme="dark"] body.ers-admin .requester-readonly,
html[data-theme="dark"] body.ers-admin .existing-attachment-item,
html[data-theme="dark"] body.ers-admin .attachment-item,
html[data-theme="dark"] body.ers-admin .reject-form,
html[data-theme="dark"] body.ers-admin .note-box,
html[data-theme="dark"] body.ers-admin .venue-summary,
html[data-theme="dark"] body.ers-admin .selected-dates-box,
html[data-theme="dark"] body.ers-admin .info-text {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow-sm) !important;
}
html[data-theme="dark"] body.ers-admin .calendar-toolbar,
html[data-theme="dark"] body.ers-admin .date-picker-header,
html[data-theme="dark"] body.ers-admin .detail-row,
html[data-theme="dark"] body.ers-admin .existing-attachment-item,
html[data-theme="dark"] body.ers-admin .attachment-item { border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .reservation-header h1,
html[data-theme="dark"] body.ers-admin .calendar-title,
html[data-theme="dark"] body.ers-admin .venue-summary h2,
html[data-theme="dark"] body.ers-admin .detail-value,
html[data-theme="dark"] body.ers-admin .requester-readonly strong { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-admin .reservation-header p,
html[data-theme="dark"] body.ers-admin .day-note,
html[data-theme="dark"] body.ers-admin .form-note,
html[data-theme="dark"] body.ers-admin .detail-label,
html[data-theme="dark"] body.ers-admin .venue-summary p,
html[data-theme="dark"] body.ers-admin .info-text { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-admin .radio-option,
html[data-theme="dark"] body.ers-admin .equipment-item,
html[data-theme="dark"] body.ers-admin .date-list li { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-admin .highlight-reservation { background: rgba(240,178,74,.08) !important; border-color: rgba(240,178,74,.22) !important; }

/* Full-page user chatbot screen. */
html[data-theme="dark"] body.ers-app.ers-user .chatbot-container,
html[data-theme="dark"] body.ers-app.ers-user .chatbot-header,
html[data-theme="dark"] body.ers-app.ers-user .chatbot-messages,
html[data-theme="dark"] body.ers-app.ers-user .chat-input-area,
html[data-theme="dark"] body.ers-app.ers-user .quick-actions {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-user .chatbot-messages { background: #0d1519 !important; }
html[data-theme="dark"] body.ers-app.ers-user .chatbot-title h2 { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-app.ers-user .chatbot-title p { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-user .message.bot .message-content { background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-user .message.user .message-content { background: var(--accent-soft) !important; color: var(--text) !important; border-color: rgba(57,208,116,.22) !important; }
html[data-theme="dark"] body.ers-app.ers-user .quick-btn,
html[data-theme="dark"] body.ers-app.ers-user .suggestion-btn { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }

/* System update modal. */
html[data-theme="dark"] body .system-update-modal-overlay { background: rgba(0,0,0,.68) !important; }
html[data-theme="dark"] body .system-update-modal,
html[data-theme="dark"] body .system-update-modal-header,
html[data-theme="dark"] body .system-update-modal-body,
html[data-theme="dark"] body .system-update-modal-footer {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body .system-update-modal-header h3 { color: var(--text-strong) !important; }
html[data-theme="dark"] body .system-update-list li { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }

/* Public availability page. */
html[data-theme="dark"] body.ers-app.ers-public .availability-page,
html[data-theme="dark"] body.ers-app.ers-public .availability-top { background: var(--bg) !important; color: var(--text) !important; }
html[data-theme="dark"] body.ers-app.ers-public .calendar-panel,
html[data-theme="dark"] body.ers-app.ers-public .availability-panel,
html[data-theme="dark"] body.ers-app.ers-public .selected-info,
html[data-theme="dark"] body.ers-app.ers-public .event-card,
html[data-theme="dark"] body.ers-app.ers-public .vehicle-card,
html[data-theme="dark"] body.ers-app.ers-public .cta-box,
html[data-theme="dark"] body.ers-app.ers-public .no-events-box {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-theme="dark"] body.ers-app.ers-public .availability-heading h1,
html[data-theme="dark"] body.ers-app.ers-public .availability-heading h2,
html[data-theme="dark"] body.ers-app.ers-public .calendar-title,
html[data-theme="dark"] body.ers-app.ers-public .selected-info h2,
html[data-theme="dark"] body.ers-app.ers-public .cta-box h3,
html[data-theme="dark"] body.ers-app.ers-public .event-card strong { color: var(--text-strong) !important; }
html[data-theme="dark"] body.ers-app.ers-public .availability-heading p,
html[data-theme="dark"] body.ers-app.ers-public .selected-info p,
html[data-theme="dark"] body.ers-app.ers-public .event-meta { color: var(--text-muted) !important; }
html[data-theme="dark"] body.ers-app.ers-public .weekday,
html[data-theme="dark"] body.ers-app.ers-public .calendar-day { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] body.ers-app.ers-public .calendar-day:hover { background: var(--surface-3) !important; }

/* Auth/status pages: use theme surfaces without touching the green hero image overlay. */
html[data-theme="dark"] body.ers-app.ers-auth .auth-card,
html[data-theme="dark"] body.ers-app.ers-auth .form-panel,
html[data-theme="dark"] body.ers-app .pending-card,
html[data-theme="dark"] body.ers-app .rejected-card,
html[data-theme="dark"] body.ers-app .maintenance-card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

/* Last-resort contrast guard for content areas. It only changes legacy dark green/gray
   text colors that are unreadable on dark surfaces; semantic accent colors stay intact. */
html[data-theme="dark"] body.ers-admin .content-area :is(p, span, div, td, li)[style*="color: #33413a"],
html[data-theme="dark"] body.ers-app.ers-user .content-area :is(p, span, div, td, li)[style*="color: #33413a"] { color: var(--text) !important; }
html[data-theme="dark"] body.ers-admin .content-area :is(p, span, div, td, li)[style*="color: #b0bdb3"],
html[data-theme="dark"] body.ers-app.ers-user .content-area :is(p, span, div, td, li)[style*="color: #b0bdb3"] { color: var(--text-muted) !important; }
