.theme-toggle {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.theme-toggle:hover {
  border-color: var(--zentro-terracotta);
  background: #fff7f1;
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(212, 107, 70, .24);
  outline-offset: 2px;
}

.theme-toggle-icon {
  width: 16px;
  color: var(--zentro-terracotta-dark);
  font-size: 18px;
  line-height: 1;
  text-align: center;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --zentro-plum: #f2e5e2;
  --zentro-plum-deep: #251923;
  --zentro-terracotta: #ee875f;
  --zentro-terracotta-dark: #f09a78;
  --zentro-blush: #d9ada2;
  --zentro-sage: #a8b6a4;
  --zentro-oat: #3a302c;
  --zentro-cream: #241c22;
  --zentro-white: #2a2128;
  --ink: #f2e5e2;
  --muted: #c0afb7;
  --navy: #f2e5e2;
  --navy-deep: #251923;
  --teal: #ee875f;
  --teal-dark: #f09a78;
  --mint: #3a302c;
  --cream: #171217;
  --paper: #241c22;
  --line: #4a3943;
  --soft-line: #352832;
  --danger: #f08a82;
  --danger-soft: #48282b;
  --amber: #edb66c;
  --amber-soft: #45341f;
  --green: #a9c5a4;
  --green-soft: #29382d;
  --blue-soft: #302936;
  --shadow: 0 18px 44px rgba(0, 0, 0, .28);
  --shadow-soft: 0 6px 20px rgba(0, 0, 0, .18);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .workspace,
html[data-theme="dark"] #mainContent,
html[data-theme="dark"] .view {
  background: var(--cream);
  color: var(--ink);
}

html[data-theme="dark"] .topbar {
  border-bottom-color: var(--line);
  background: rgba(36, 28, 34, .94);
}

html[data-theme="dark"] .settings-page-heading {
  border-color: var(--line);
  background: linear-gradient(135deg, #2d242a 0%, #241c22 100%);
}

html[data-theme="dark"] .privacy-banner {
  border-color: #553d36;
  background: #30231f;
  color: #dfc0b5;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] strong,
html[data-theme="dark"] .metric-card strong,
html[data-theme="dark"] .clock-card strong,
html[data-theme="dark"] .calendar-header h3,
html[data-theme="dark"] .settings-page-heading h3,
html[data-theme="dark"] .eod-page-heading h3,
html[data-theme="dark"] .eod-metrics strong {
  color: var(--ink);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .clock-card,
html[data-theme="dark"] .callback-card,
html[data-theme="dark"] .calendar-panel,
html[data-theme="dark"] .eod-detail-panel,
html[data-theme="dark"] .settings-tabs,
html[data-theme="dark"] .settings-section-toggle,
html[data-theme="dark"] .lead-status-group,
html[data-theme="dark"] .lead-group,
html[data-theme="dark"] .clinic-folder,
html[data-theme="dark"] .notification-panel,
html[data-theme="dark"] .activity-toast,
html[data-theme="dark"] .activity-thread-content,
html[data-theme="dark"] .row-comment-thread,
html[data-theme="dark"] .row-comment-composer,
html[data-theme="dark"] .task-comment,
html[data-theme="dark"] .task-attachment,
html[data-theme="dark"] .settings-summary-grid article,
html[data-theme="dark"] .settings-approver-list,
html[data-theme="dark"] .settings-workflow,
html[data-theme="dark"] .tracker-settings-grid > section,
html[data-theme="dark"] .tracker-setting-row,
html[data-theme="dark"] .payroll-card,
html[data-theme="dark"] .roster-card,
html[data-theme="dark"] .ops-report-filters,
html[data-theme="dark"] .ops-agent-summary,
html[data-theme="dark"] .lead-lifecycle-toolbar,
html[data-theme="dark"] .drawer {
  border-color: var(--line) !important;
  background: var(--paper) !important;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .marketing-metrics article,
html[data-theme="dark"] .marketing-inline-form,
html[data-theme="dark"] .marketing-project-card,
html[data-theme="dark"] .marketing-task-card,
html[data-theme="dark"] .marketing-task-details,
html[data-theme="dark"] .marketing-comment-thread article,
html[data-theme="dark"] .marketing-calendar-list article {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .marketing-task-details {
  background: #21191f;
}

html[data-theme="dark"] .marketing-files a {
  background: #342a31;
  color: #f0d5cd;
}

html[data-theme="dark"] .client-agent-assignment-card,
html[data-theme="dark"] .client-agent-choice,
html[data-theme="dark"] .user-clinic-access-choices,
html[data-theme="dark"] .staff-clinic-list {
  border-color: var(--line);
  background: #2a2128;
  color: var(--ink);
}

html[data-theme="dark"] .user-clinic-access-user,
html[data-theme="dark"] .user-clinic-access-choices legend {
  color: var(--muted);
}

html[data-theme="dark"] .staff-clinic-list span {
  background: #342a31;
  color: var(--ink);
}

html[data-theme="dark"] .knowledge-search-panel {
  border-color: #58434f;
  background:
    radial-gradient(circle at 100% 0, rgba(238, 135, 95, .12), transparent 34%),
    linear-gradient(135deg, #332832 0%, #2b222a 100%);
  color: var(--ink);
}

html[data-theme="dark"] .knowledge-quick-searches button,
html[data-theme="dark"] .knowledge-section-card,
html[data-theme="dark"] .knowledge-reference-card,
html[data-theme="dark"] .practice-profile-card,
html[data-theme="dark"] .practice-profile-card.available,
html[data-theme="dark"] .practice-profile-admin-row,
html[data-theme="dark"] .notification-type-option,
html[data-theme="dark"] .timesheet-filters,
html[data-theme="dark"] .roster-create-form,
html[data-theme="dark"] .initial-password-option,
html[data-theme="dark"] .payroll-total-grid article,
html[data-theme="dark"] .payroll-live-total-group article {
  border-color: #58434f;
  background: #30262e;
  color: var(--ink);
  box-shadow: none;
}

html[data-theme="dark"] .payroll-privacy-note,
html[data-theme="dark"] .payroll-warning,
html[data-theme="dark"] .payroll-rate-table output {
  border-color: #58434f;
  background: #30262e;
  color: var(--muted);
  box-shadow: none;
}

html[data-theme="dark"] .payroll-privacy-note strong,
html[data-theme="dark"] .payroll-rate-table output {
  color: #f0b29a;
}

html[data-theme="dark"] .payroll-warning {
  border-color: #735743;
  background: #352a2b;
}

html[data-theme="dark"] .payroll-warning strong {
  color: #f1c589;
}

html[data-theme="dark"] .knowledge-quick-searches button:hover,
html[data-theme="dark"] .knowledge-quick-searches button:focus-visible,
html[data-theme="dark"] .knowledge-section-card:hover,
html[data-theme="dark"] .knowledge-section-card:focus-visible {
  border-color: var(--zentro-terracotta);
  background: #40313b;
  color: #fff3ed;
}

html[data-theme="dark"] .knowledge-answer,
html[data-theme="dark"] .knowledge-answer-section,
html[data-theme="dark"] .practice-profile-viewer,
html[data-theme="dark"] .knowledge-document-reader,
html[data-theme="dark"] .knowledge-preview-fallback {
  border-color: #58434f;
  background: #2b222a;
  color: var(--ink);
}

html[data-theme="dark"] .knowledge-answer-section {
  border-left-color: var(--zentro-terracotta);
  background: #332832;
}

html[data-theme="dark"] .knowledge-search-heading p,
html[data-theme="dark"] .knowledge-privacy,
html[data-theme="dark"] .knowledge-section-card span,
html[data-theme="dark"] .knowledge-reference-card span,
html[data-theme="dark"] .knowledge-reference-card p,
html[data-theme="dark"] .knowledge-result-message,
html[data-theme="dark"] .knowledge-preview-fallback span,
html[data-theme="dark"] .practice-profile-card span,
html[data-theme="dark"] .payroll-total-grid small,
html[data-theme="dark"] .payroll-live-total-group small {
  color: var(--muted);
}

html[data-theme="dark"] .knowledge-source-icon,
html[data-theme="dark"] .knowledge-source-state,
html[data-theme="dark"] .knowledge-result-state {
  background: #40313b;
  color: #f0b29a;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .segmented,
html[data-theme="dark"] .tracker-view-toggle,
html[data-theme="dark"] .tracker-filter-disclosure > summary,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .file-button,
html[data-theme="dark"] .row-comment-paperclip,
html[data-theme="dark"] .lead-row-cancel {
  border-color: var(--line) !important;
  background: #2b222a !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] .notification-button {
  border-color: var(--line);
  background: #2b222a;
  color: var(--ink);
}

html[data-theme="dark"] label,
html[data-theme="dark"] legend {
  color: var(--muted);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #9f8d96;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: var(--zentro-terracotta) !important;
  box-shadow: 0 0 0 3px rgba(238, 135, 95, .17) !important;
}

html[data-theme="dark"] table,
html[data-theme="dark"] thead,
html[data-theme="dark"] tbody,
html[data-theme="dark"] tr,
html[data-theme="dark"] th,
html[data-theme="dark"] td,
html[data-theme="dark"] .lead-group-header,
html[data-theme="dark"] .lead-table-wrap,
html[data-theme="dark"] .add-task-row,
html[data-theme="dark"] .row-comment-composer-row > td,
html[data-theme="dark"] .clinic-folder-body {
  border-color: var(--line) !important;
  background-color: transparent !important;
  color: var(--ink);
}

html[data-theme="dark"] th,
html[data-theme="dark"] .lead-group-header,
html[data-theme="dark"] .add-task-row {
  background-color: #21191f !important;
}

html[data-theme="dark"] .notification-item,
html[data-theme="dark"] .mini-row,
html[data-theme="dark"] .callback-row,
html[data-theme="dark"] .presence-row,
html[data-theme="dark"] .clinic-volume-item,
html[data-theme="dark"] .timesheet-row,
html[data-theme="dark"] .history-row {
  border-color: var(--line) !important;
  background: #2a2128 !important;
  color: var(--ink);
}

html[data-theme="dark"] .notification-item.unread,
html[data-theme="dark"] .clock-card.active,
html[data-theme="dark"] .row-comment-summary,
html[data-theme="dark"] .comment-entry .activity-thread-content {
  border-color: #6d4a3e !important;
  background: #32241f !important;
}

html[data-theme="dark"] .settings-tabs button,
html[data-theme="dark"] .segmented button,
html[data-theme="dark"] .tracker-view-toggle button,
html[data-theme="dark"] .text-button {
  color: #e6c9c0;
}

html[data-theme="dark"] .settings-tabs button:hover,
html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .text-button:hover {
  background: #382a32 !important;
  color: #fff3ed !important;
}

html[data-theme="dark"] .segmented button.active,
html[data-theme="dark"] .tracker-view-toggle button.active {
  background: #49323d;
  color: #fff3ed;
  box-shadow: none;
}

html[data-theme="dark"] .muted,
html[data-theme="dark"] small,
html[data-theme="dark"] .panel-heading p,
html[data-theme="dark"] .settings-page-heading p:last-child,
html[data-theme="dark"] .lead-tracker-intro p,
html[data-theme="dark"] .notification-item span,
html[data-theme="dark"] .activity-toast p,
html[data-theme="dark"] .activity-thread-content > p,
html[data-theme="dark"] .row-comment-latest,
html[data-theme="dark"] .settings-summary-grid small {
  color: var(--muted) !important;
}

html[data-theme="dark"] .marketing-metrics strong,
html[data-theme="dark"] .marketing-section-heading h3,
html[data-theme="dark"] .marketing-title-input,
html[data-theme="dark"] .marketing-task-title {
  color: var(--ink);
}

html[data-theme="dark"] .marketing-metrics span,
html[data-theme="dark"] .marketing-section-heading p:last-child,
html[data-theme="dark"] .marketing-activity-list span,
html[data-theme="dark"] .marketing-activity-list small,
html[data-theme="dark"] .marketing-project-card header span,
html[data-theme="dark"] .marketing-card-meta label,
html[data-theme="dark"] .marketing-card-meta > span,
html[data-theme="dark"] .marketing-task-head,
html[data-theme="dark"] .marketing-task-actions span,
html[data-theme="dark"] .marketing-comment-thread article small,
html[data-theme="dark"] .marketing-calendar-list div span {
  color: var(--muted);
}

html[data-theme="dark"] .marketing-activity-list > div {
  border-bottom-color: var(--line);
}

html[data-theme="dark"] .badge,
html[data-theme="dark"] .lead-row-meta span,
html[data-theme="dark"] .clinic-status-count,
html[data-theme="dark"] .activity-kind {
  border-color: var(--line);
  background: #342a31;
  color: #d6c4cb !important;
}

html[data-theme="dark"] .eod-clinic-checklist,
html[data-theme="dark"] .activity-change-values > div,
html[data-theme="dark"] .pending-comment-attachment,
html[data-theme="dark"] .empty-activity,
html[data-theme="dark"] .task-edit-lock {
  border-color: var(--line) !important;
  background: #2d242a !important;
  color: var(--muted);
}

html[data-theme="dark"] .booked-patient-list span {
  border-color: var(--line);
  background: #30252d;
  color: var(--ink);
}

html[data-theme="dark"] ::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #1b151a;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  border: 2px solid #1b151a;
  border-radius: 999px;
  background: #624d59;
}

@media (max-width: 700px) {
  .theme-toggle {
    min-width: 38px;
    justify-content: center;
    padding-inline: 9px;
  }

  .theme-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    transition: none;
  }
}
html[data-theme="dark"] .department-day-card,
html[data-theme="dark"] .ops-report-notice,
html[data-theme="dark"] .ops-staff-performance {
  border-color: var(--line) !important;
  background: var(--paper) !important;
  color: var(--ink);
}
html[data-theme="dark"] .calendar-arrow,
html[data-theme="dark"] .calendar-day { border-color: var(--line); background: #2a2128; color: var(--ink); }
html[data-theme="dark"] .calendar-day.outside { background: #211a20; color: #8d7f87; }
html[data-theme="dark"] .calendar-day.has-reports { background: #30272d; }
html[data-theme="dark"] .eod-metrics article {
  border: 1px solid var(--line);
  background: #2a2128;
}
html[data-theme="dark"] .day-report-card:hover {
  border-color: #6b4a4d;
  background: #302329;
}
html[data-theme="dark"] .day-report-card.active {
  border-color: var(--zentro-terracotta);
  background: #35262c;
}
html[data-theme="dark"] .agent-eod-profile h4 { color: var(--zentro-terracotta-dark); }
html[data-theme="dark"] .agent-eod-profile p { color: var(--muted); }
html[data-theme="dark"] .ops-report-notice strong { color: #f0b19a; }
html[data-theme="dark"] .attendance-hours-chart {
  border-color: #58434f;
  background: #30262e;
  color: var(--ink);
}

html[data-theme="dark"] .hours-chart-track {
  background: #2c3433;
}