:root {
  color-scheme: light;
  --surface: #fff;
  --surface-raised: #f0f3f8;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--navy);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
}
.theme-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }
.theme-toggle:hover { background: var(--surface-raised); }
.header-actions > .avatar { flex-shrink: 0; }

/* Keep the existing FCSD blue and teal palette on darker surfaces. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1724;
  --surface: #182334;
  --surface-raised: #202e42;
  --navy: #e5edf8;
  --muted: #a4b3c8;
  --border: #334258;
  --blue: #82b6ff;
  --green: #78d9be;
  --blue-surface: #213958;
  --green-surface: #193e38;
  --amber-surface: #433622;
  --red-surface: #482c33;
  --amber: #f2cc82;
  --red: #ffb0aa;
}
[data-theme="dark"] :is(aside, header, .stat, .card, .user-summary,
  .department-summary, .department-card, .department-empty, .balance-explainer,
  .room-credit-summary, .permission-option, dialog) {
  background: var(--surface);
  color: var(--navy);
}
[data-theme="dark"] :is(input, select, textarea, .identity select,
  .schedule-upload-box input) {
  background: #111d2e;
  color: var(--navy);
  border-color: var(--border);
}
[data-theme="dark"] ::placeholder { color: #95a7bf; opacity: 1; }
[data-theme="dark"] :is(input, select, textarea):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
[data-theme="dark"] .primary { background: #2169d6; color: #fff; }
[data-theme="dark"] .secondary {
  background: var(--surface-raised);
  color: #d4e2f6;
}
[data-theme="dark"] :is(.danger, .rejected, .cancelled) {
  background: var(--red-surface);
  color: var(--red);
}
[data-theme="dark"] :is(.error, .balance-live-preview .error) { color: var(--red); }
[data-theme="dark"] .schedule-error { color: var(--red) !important; }
[data-theme="dark"] .schedule-warning { color: var(--amber) !important; }
[data-theme="dark"] .schedule-row-error { background: #35252f; }
[data-theme="dark"] :is(nav button, .breadcrumb, .stat-top, .stat-note,
  .nav-label, .section-foot, .role-tag, footer, td small, .department-lead small,
  .department-card-bottom > span, .member-department, .membership-preview,
  .balance-opening summary, .balance-event p, .balance-row-actions .secondary-link,
  .room-hours, .room-credit-empty, .room-tabs button) { color: var(--muted); }
[data-theme="dark"] .breadcrumb strong { color: var(--navy); }
[data-theme="dark"] .breadcrumb span { color: #7a8da8; }
[data-theme="dark"] :is(nav button.active, .count, .demo-pill, .avatar,
  .stat-icon, .type-icon, .you-pill, .form-section-title > span,
  .balance-year, .balance-explainer > div > span, .room-table .in-progress,
  .room-tabs button.selected, .theme-toggle[aria-pressed="true"]) {
  background: var(--blue-surface);
  color: #a4caff;
  border-color: #395d89;
}
[data-theme="dark"] nav button:hover { background: var(--surface-raised); }
[data-theme="dark"] .custom-pill { background: #352e50; color: #cfb9fa; }
[data-theme="dark"] :is(.hero, .room-hero, .schedule-creator) {
  background: linear-gradient(110deg, #1c3150, #1b383b);
  border-color: #34536b;
}
[data-theme="dark"] :is(.hero p, .schedule-creator p, .schedule-steps,
  .room-meta, .approval-flow strong, .room-empty strong) { color: #b7cbe3; }
[data-theme="dark"] :is(.hero .hero-art, .room-now) { border-color: #3a5868; }
[data-theme="dark"] :is(.notice, .approval-flow, .schedule-upload-box) {
  background: #1d304b;
  color: #bad1ee;
  border-color: #3b587c;
}
[data-theme="dark"] :is(.approval-flow span, .schedule-steps b) {
  background: var(--surface);
  border-color: #456180;
}
[data-theme="dark"] .department-icon {
  background: linear-gradient(135deg, #233e63, #1b4b46);
  color: #9bc7ff;
}
[data-theme="dark"] th,
[data-theme="dark"] .schedule-preview-table th {
  background: #202d40;
  color: #b1c0d5;
  border-color: var(--border);
}
[data-theme="dark"] :is(td, .person-row, .balance-detail, .department-lead,
  .department-card-bottom, .department-member-option) { border-color: var(--border); }
[data-theme="dark"] .member-stack .avatar { border-color: var(--surface); }
[data-theme="dark"] :is(.permission-option:has(input:checked),
  .department-member-option:has(input:checked)) {
  background: #213650;
  border-color: #46658c;
}
[data-theme="dark"] .selection-count { background: var(--blue-surface) !important; }
[data-theme="dark"] :is(.close, .department-pending, .room-tabs,
  .schedule-import-stats, .room-credit-heading > span, .progress, .room-day-track) {
  background: var(--surface-raised);
  color: var(--muted);
}
[data-theme="dark"] :is(.approved, .verified, .published, .active.badge,
  .lead-assigned, .badge.add, .room-table .confirmed, .calendar .away,
  .base-access, .routing-note, .room-empty > span) {
  background: var(--green-surface);
  color: #9ce3ca;
}
[data-theme="dark"] :is(.submitted, .awaiting-document, .cancellation-requested,
  .needs-a-lead, .pending-days, .badge.update) {
  background: var(--amber-surface);
  color: var(--amber);
}
[data-theme="dark"] :is(.draft, .reported, .closed, .inactive.badge,
  .badge.unchanged, .room-table .completed) {
  background: #2b374a;
  color: #bdc9da;
}
[data-theme="dark"] .balance-totals .stat:nth-child(3) .stat-value,
[data-theme="dark"] .room-credit-stats .room-credit-available strong,
[data-theme="dark"] :is(.stat-note.teal, .remaining-days, .balance-preview-heading > strong,
  .balance-event > div > span, .room-now) {
  color: var(--green);
}
[data-theme="dark"] .balance-totals .stat:nth-child(3),
[data-theme="dark"] :is(.balance-live-preview, .room-slot-preview) {
  background: #1b3834;
  color: #a0e2ca;
  border-color: #355d50;
}
[data-theme="dark"] :is(.balance-preview-heading, .balance-preview-available) {
  color: #b2d6c9;
  border-color: #355d50;
}
[data-theme="dark"] :is(.balance-live-preview p, .balance-preview-available small,
  .balance-preview-heading i, .room-now small) { color: #a7c5bc; }
[data-theme="dark"] :is(.room-now.room-busy, .member-department small) { color: var(--amber); }
[data-theme="dark"] .room-slot-preview.slot-unavailable {
  background: var(--amber-surface);
  color: var(--amber);
  border-color: #775f39;
}
[data-theme="dark"] .shift { background: #243c5a; color: #bdd8ff; }
[data-theme="dark"] .shift.off { background: #263144; color: #b3c0d2; }
[data-theme="dark"] .shift.leave { background: var(--green-surface); color: #a2e1c7; }
[data-theme="dark"] .shift.shift-draft { background: #403721; outline-color: #b79453; }
[data-theme="dark"] .shift small { color: var(--amber); }
[data-theme="dark"] .calendar .dow { color: var(--muted); }
[data-theme="dark"] .calendar .outside { color: #7c8da6; }
[data-theme="dark"] .calendar .today { background: #2169d6; }
[data-theme="dark"] .room-mark { background: #dbe9f6; }
[data-theme="dark"] .room-day-track > span { border-right-color: var(--surface); }
[data-theme="dark"] dialog { box-shadow: 0 20px 100px #0008; }
[data-theme="dark"] dialog::backdrop { background: #050b16b3; }
[data-theme="dark"] #toast {
  background: #dbe9fa;
  color: #142940;
  box-shadow: 0 5px 20px #0005;
}
@media (max-width: 1250px) { .header-actions .demo-pill { display: none; } }
@media (min-width: 721px) and (max-width: 1000px) {
  header .breadcrumb { display: none; }
  header { justify-content: flex-end; }
}
@media (max-width: 720px) {
  .header-actions { gap: 10px; }
  .theme-toggle { min-height: 40px; }
  .identity { min-width: 0; }
  .identity select { min-width: 0; max-width: 190px; width: 100%; }
}
@media (max-width: 420px) {
  .theme-toggle { width: 40px; padding: 10px; flex-shrink: 0; }
  .theme-toggle span, .identity > span { display: none; }
}
