body.theme-ui {
  --theme-accent: #00d5ff;
  --theme-accent-contrast: #071219;
  --theme-accent-soft: rgba(0,213,255,.12);
  --theme-accent-faint: rgba(0,213,255,.06);
  --theme-accent-border: rgba(0,213,255,.28);
  --theme-bg: #f8fbfd;
  --theme-bg-soft: #eef5f8;
  --theme-surface: #fff;
  --theme-surface-soft: #f8fafc;
  --theme-text: #111827;
  --theme-text-strong: #030712;
  --theme-muted: #5b6472;
  --theme-border: #dbe4e9;
  --theme-shadow: 0 8px 24px rgba(17,24,39,.065);
  --theme-radius: 8px;
  --theme-success: #15803d;
  --theme-success-soft: #f0fdf4;
  --theme-warning: #a16207;
  --theme-warning-soft: #fffbeb;
  --theme-danger: #dc2626;
  --theme-danger-soft: #fef2f2;
  --theme-info: #1d4ed8;
  --theme-info-soft: #eff6ff;
  --bg: var(--theme-bg);
  --surface: var(--theme-surface);
  --text: var(--theme-text);
  --muted: var(--theme-muted);
  --border: var(--theme-border);
  --primary: var(--theme-accent);
  --ceo-text-muted: var(--theme-muted);
  --ceo-chart-grid: rgba(17,24,39,.1);
  --ceo-danger: #ef4444;
  color: var(--theme-text);
  background: linear-gradient(145deg, #fff 0%, var(--theme-bg) 52%, var(--theme-bg-soft) 100%);
}

body.theme-profile-frost {
  --theme-bg: #f3f7fa;
  --theme-bg-soft: #e7eef3;
  --theme-surface: #fbfdfe;
  --theme-surface-soft: #f0f5f8;
  --theme-border: #cfdae2;
  --theme-shadow: 0 6px 18px rgba(29,52,68,.06);
}

body.theme-profile-minimal {
  --theme-bg: #f7f7f8;
  --theme-bg-soft: #f1f2f3;
  --theme-surface: #fff;
  --theme-surface-soft: #f7f7f8;
  --theme-border: #dedfe2;
  --theme-shadow: none;
  background: var(--theme-bg);
}

.theme-ui :where(.admin-main,.admin-content) { color: var(--theme-text); background: transparent; }
.theme-ui .admin-sidebar { color: var(--theme-text); background: rgba(255,255,255,.97); border-left-color: var(--theme-accent-border); scrollbar-color: var(--theme-accent-border) transparent; }
.theme-ui .admin-sidebar .admin-logo { color: var(--theme-text); background: #fff; border-bottom-color: var(--theme-accent-border); }
.theme-ui .admin-sidebar :where(.admin-logo span,.admin-logo small,.admin-menu-toggle,.admin-menu-link) { color: var(--theme-text); }
.theme-ui :where(.admin-menu-section[open],.admin-menu-section.has-active-child) { background: var(--theme-accent-faint); border-color: var(--theme-accent-border); }
.theme-ui .admin-menu-toggle:hover { color: var(--theme-text-strong); background: var(--theme-accent-faint); }
.theme-ui :where(.admin-menu-toggle.is-open,.admin-menu-toggle.has-active-child) { color: var(--theme-accent); }
.theme-ui .admin-submenu { border-right-color: var(--theme-accent-border); }
.theme-ui .admin-menu-link.is-active { color: var(--theme-text-strong); background: var(--theme-accent-soft); border-color: var(--theme-accent); box-shadow: inset -3px 0 var(--theme-accent); }

.theme-ui .admin-topbar { color: var(--theme-text); background: rgba(255,255,255,.96); border-bottom-color: var(--theme-accent-border); box-shadow: 0 4px 14px rgba(17,24,39,.045); }
.theme-ui .admin-topbar :where(strong,small,span,a) { color: var(--theme-text); }
.theme-ui .admin-user a { padding: 4px 7px; border-radius: 5px; }
.theme-ui .admin-user a:hover { background: var(--theme-accent-faint); color: var(--theme-text-strong); }
.theme-ui .site-header { color: var(--theme-text); background: rgba(255,255,255,.96); border-bottom-color: var(--theme-accent-border); backdrop-filter: none; }
.theme-ui .site-nav,.theme-ui .site-nav a { color: var(--theme-text); }
.theme-ui .site-nav a:hover { color: var(--theme-accent); }
.theme-ui .site-footer { color: var(--theme-text); background: #fff; border-top-color: var(--theme-accent-border); }

.theme-ui :where(.card,.stat-card,.dashboard-access-card,.ceo-mobile-card,.ceo-mobile-kpi,.ceo-settings-card,.ceo-chart-card,.manager-widget,.manager-settings,.sobhan-api-section,.sobhan-ai-panel,.modal,.modal-box,.modal-content,.dialog,dialog,[role="dialog"],.dashboard-source-bar,.ceo-mobile-filterbar,.ceo-settings-tabs,.manager-tabs) {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
  box-shadow: var(--theme-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.theme-ui :where(.card,.stat-card,.dashboard-access-card,.ceo-mobile-card,.ceo-mobile-kpi,.ceo-settings-card,.manager-widget,.manager-settings,.modal,.modal-content) :where(h1,h2,h3,h4,p,span,strong,small,label,legend,dt,dd,summary,li) { color: var(--theme-text); }
.theme-ui :where(h1,h2,h3,h4,.admin-topbar-title strong,.ceo-section-title h2) { color: var(--theme-text-strong); }
.theme-ui :where(.muted,small,.ceo-section-title p,.ceo-mobile-page-head p) { color: var(--theme-muted); }

.theme-ui :where(input,select,textarea) { color: var(--theme-text); background: #fff; border-color: var(--theme-border); caret-color: var(--theme-accent); }
.theme-ui :where(input,select,textarea)::placeholder { color: #77818d; }
.theme-ui :where(input,select,textarea):focus { border-color: var(--theme-accent); box-shadow: 0 0 0 3px var(--theme-accent-soft); outline: 0; }
.theme-ui :where(a,button,input,select,textarea,summary):focus-visible { outline: 2px solid var(--theme-accent); outline-offset: 2px; }
.theme-ui :where(.btn-primary,button.btn-primary) { color: var(--theme-accent-contrast); background: var(--theme-accent); border-color: var(--theme-accent); box-shadow: none; }
.theme-ui :where(.btn-primary,button.btn-primary):hover { color: var(--theme-accent-contrast); filter: brightness(.95); }
.theme-ui .btn:not(.btn-primary):not(.btn-danger):not(.btn-success) { color: var(--theme-text); background: #fff; border-color: var(--theme-border); }
.theme-ui .btn:not(.btn-primary):not(.btn-danger):not(.btn-success):hover { color: var(--theme-text-strong); background: var(--theme-accent-faint); border-color: var(--theme-accent); }

.theme-ui .table-wrap { color: var(--theme-text); background: #fff; border-color: var(--theme-border); box-shadow: none; }
.theme-ui table { color: var(--theme-text); background: #fff; }
.theme-ui th { color: var(--theme-text-strong); background: var(--theme-accent-soft); border-color: var(--theme-accent-border); }
.theme-ui td { color: var(--theme-text); background: #fff; border-color: #e5e9ec; }
.theme-ui tbody tr:hover td,.theme-ui .ceo-total-row td { color: var(--theme-text-strong); background: var(--theme-accent-faint); }
.theme-ui :where(.badge,.achievement-pill) { border: 1px solid var(--theme-accent-border); }

.theme-ui :where(.ceo-mobile-kpi,.ceo-kpi-card,.sobhan-api-kpis .stat-card,.pharmacy-stats .stat-card,.ceo-line-meta-card,.ceo-manager-card,.ceo-visitor-progress-card,.ceo-mobile-row-cards article,.ceo-mobile-rank-list div,.manager-kpis article) { color: var(--theme-text); background: #fff; border-color: var(--theme-border); box-shadow: var(--theme-shadow); }
.theme-ui .ceo-chart-card { border-top: 3px solid var(--theme-accent); }
.theme-ui .ceo-kpi-list div { border-bottom-color: var(--theme-border); }
.theme-ui .ceo-inline-progress { background: #e8edf0; }
.theme-ui .ceo-inline-progress > b,.theme-ui .progress-mid::after { background: var(--theme-accent); }
.theme-ui :where(.checkbox-item,.sobhan-ai-answer,.sobhan-ai-preview,.ai-answer) { color: var(--theme-text); background: #fff; border-color: var(--theme-border); }
.theme-ui :where(.manager-hero,.manager-ai) { color: var(--theme-text); background: var(--theme-surface); border: 1px solid var(--theme-accent-border); box-shadow: var(--theme-shadow); }
.theme-ui .manager-hero :where(h1,p,span,label) { color: var(--theme-text); }
.theme-ui .manager-dialog::backdrop,.theme-ui :where(dialog,.modal,[role="dialog"])::backdrop { background: rgba(17,24,39,.42); backdrop-filter: none; }

/* One visual contract for every authenticated page and dashboard. */
.theme-ui :where(
  .card,.stat-card,.dashboard-access-card,.ceo-mobile-card,.ceo-mobile-kpi,
  .ceo-settings-card,.ceo-chart-card,.manager-widget,.manager-settings,
  .manager-hero,.manager-ai,.manager-history,.sobhan-api-section,.sobhan-ai-panel,
  .personal-planner,.personal-planner-main,.personal-planner-side > section,
  .hr-test-card,.hr-test-run,.hr-question,.org-unit-tree details,
  .profile-details div,.kpi-detail dl div,.planner-task-card,.planner-log,
  .pwa-preview,.score-row,.dashboard-source-bar,.table-wrap,
  .modal,.modal-box,.modal-content,.dialog,dialog,[role="dialog"]
) {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
  border-radius: var(--theme-radius);
  box-shadow: var(--theme-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.theme-ui :where(
  .manager-tabs,.ceo-settings-tabs,.ceo-mobile-filterbar,.dashboard-source-bar,
  .planner-task-row,.planner-check-row,.planner-priority-item,.planner-widget-list article,
  .hr-dimension-grid div,.checkbox-item,.score-row,.profile-details div,
  .kpi-detail dl div,.org-unit-tree details,.sobhan-ai-answer,.sobhan-ai-preview,.ai-answer
) {
  color: var(--theme-text);
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}
.theme-ui :where(
  .card,.stat-card,.dashboard-access-card,.manager-widget,.manager-settings,
  .manager-hero,.manager-ai,.manager-history,.personal-planner,.hr-test-card,
  .hr-test-run,.modal,.modal-box,.modal-content,dialog,[role="dialog"]
) :where(h1,h2,h3,h4,h5,h6,p,span,strong,small,label,legend,dt,dd,summary,li) { color: inherit; }
.theme-ui :where(.muted,small,.help-text,.form-hint,.planner-empty) { color: var(--theme-muted); }
.theme-ui :where(.manager-tabs,.ceo-settings-tabs) a {
  color: var(--theme-text);
  background: transparent;
  border-color: transparent;
  border-radius: 6px;
}
.theme-ui :where(.manager-tabs,.ceo-settings-tabs) a:hover { background: var(--theme-accent-faint); }
.theme-ui :where(.manager-tabs,.ceo-settings-tabs) a.active,
.theme-ui :where(.manager-tabs,.ceo-settings-tabs) a[aria-current="page"] {
  color: var(--theme-text-strong);
  background: var(--theme-accent-soft);
  border-color: var(--theme-accent);
}
.theme-ui :where(.modal,.modal-box,.modal-content,dialog,[role="dialog"]) :where(header,footer) {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
.theme-ui :where(.alert-success,.flash-success) { color: var(--theme-success); background: var(--theme-success-soft); border-color: #86efac; }
.theme-ui :where(.alert-warning,.flash-warning) { color: var(--theme-warning); background: var(--theme-warning-soft); border-color: #fde68a; }
.theme-ui :where(.alert-danger,.flash-danger,.alert-error) { color: var(--theme-danger); background: var(--theme-danger-soft); border-color: #fecaca; }
.theme-ui :where(.alert-info,.flash-info) { color: var(--theme-info); background: var(--theme-info-soft); border-color: #bfdbfe; }
.theme-ui :where(.pagination a,.pagination span) {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
  border-radius: 6px;
}
.theme-ui .pagination :where(.active,[aria-current="page"]) {
  color: var(--theme-accent-contrast);
  background: var(--theme-accent);
  border-color: var(--theme-accent);
}
.theme-ui :where(.progress,.planner-progress,.progress-track) { background: var(--theme-bg-soft); }
.theme-ui :where(.progress > span,.planner-progress span,.progress-bar) { background: var(--theme-accent); }

.theme-effects-reduced * { transition-duration: .01ms!important; animation-duration: .01ms!important; scroll-behavior: auto!important; }
.theme-effects-reduced :where(.card,.stat-card,.dashboard-access-card,.ceo-mobile-card,.ceo-mobile-kpi,.manager-widget,.modal,.modal-content,.admin-topbar) { box-shadow: none!important; }

.theme-settings-panel { max-width: 980px; margin-inline: auto; }
.theme-ui.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.theme-ui .login-card { width: min(430px,100%); color: var(--theme-text); background: #fff; border-color: var(--theme-accent-border); box-shadow: var(--theme-shadow); }
.theme-profile-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 0; padding: 0; border: 0; }
.theme-profile-grid legend { grid-column: 1/-1; margin-bottom: 5px; font-weight: 900; }
.theme-profile-option { display: grid; gap: 7px; min-width: 0; padding: 12px; border: 1px solid var(--theme-border); border-radius: 8px; background: #fff; cursor: pointer; }
.theme-profile-option:has(input:checked) { border-color: var(--theme-accent); box-shadow: 0 0 0 3px var(--theme-accent-soft); }
.theme-profile-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--theme-accent); }
.theme-profile-option small { color: var(--theme-muted); }
.theme-profile-preview { display: grid; grid-template-columns: 30% 1fr; grid-template-rows: 18px 30px; gap: 4px; height: 56px; padding: 5px; border: 1px solid #d7e0e5; border-radius: 6px; background: #f8fbfd; }
.theme-profile-preview i { grid-row: 1/-1; border-radius: 3px; background: #fff; border-left: 2px solid var(--theme-accent); }
.theme-profile-preview b,.theme-profile-preview em { border-radius: 3px; background: #fff; }
.theme-profile-preview-frost { background: #e7eef3; }
.theme-profile-preview-minimal { background: #f2f2f3; box-shadow: none; }
.theme-profile-controls { margin-top: 18px; }

@media (max-width:760px) { .theme-profile-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion:reduce) { .theme-ui * { transition-duration: .01ms!important; animation-duration: .01ms!important; scroll-behavior: auto!important; } }
