.theme-toggle[data-theme-toggle] { display:inline-grid; place-items:center; width:40px; height:40px; padding:0; flex:none; }
.theme-toggle .night-sun, html[data-theme="dark"] .theme-toggle .night-moon { display:none; }
html[data-theme="dark"] .theme-toggle .night-sun { display:inline; }
html[data-theme="dark"] {
  color-scheme:dark;
  --night-bg:#191b1d; --night-card:#222426; --night-raised:#2d3033;
  --night-line:#393d40; --night-text:#e9edf0; --night-muted:#b2bbc3; --night-focus:#a8c9dd;
  --surface:var(--night-card); --text:var(--night-text); --line:var(--night-line);
  --button-hover-background:#d9dcde; --button-hover-foreground:#202224;
}
html[data-theme="dark"] body { background:var(--night-bg); color:var(--night-text); }
html[data-theme="dark"] :is(.shell,.main,.tech-content,.owner-content,.portal-login) {background-color:var(--night-bg);color:var(--night-text)}
html[data-theme="dark"] :is(.sidebar,.topbar,.tech-panel,.tech-kpis article,.portal-login section,.chief-lead-list,.chief-lead-dialog,.tech-dialog,.owner-dialog,.payroll-panel,.tech-edit-variant,.tech-order-service,.tech-pricing-category,.tech-edit-jaw-layout,.staff-chat-main,.staff-chat-people,.staff-chat-head,.staff-chat-compose) {background-color:var(--night-card);color:var(--night-text);border-color:var(--night-line)}
html[data-theme="dark"] .chief-leads {--lead-secondary:var(--night-muted);--lead-soft:var(--night-raised)}
html[data-theme="dark"] :is(.tech-panel,.chief-leads,.owner-content,.tech-dialog,.payroll-panel) :is(h1,h2,h3,h4,dt,legend,.tech-breakdown-name,.payroll-service strong,.chief-lead-name,.expense-summary output) {color:var(--night-text)}
html[data-theme="dark"] :is(.payroll-help,.expense-summary span,.payroll-bulk small,.tech-team-snapshot>div,.chief-lead-history small,.chief-lead-history time,.owner-updated,.tech-chart .tech-month-value) {color:var(--night-muted)}
html[data-theme="dark"] :is(.payroll-bulk,.payroll-rate-row,.tech-team-snapshot>div,.chief-lead-history li,.expense-summary) {border-color:var(--night-line)}
html[data-theme="dark"] :is(input:not([type=checkbox],[type=radio],[type=range],[type=file],[type=color],[type=submit]),select,textarea) {background-color:#1b1f23;color:var(--night-text);border-color:var(--night-line)}
html[data-theme="dark"] :is(input,textarea)::placeholder {color:#9aa5ae}
html[data-theme="dark"] :is(.btn.outline,.theme-toggle[data-theme-toggle],.chief-lead-tag,.tech-segment) {background-color:var(--night-raised);border-color:var(--night-line);color:var(--night-text)}
html[data-theme="dark"] .btn.primary {background-color:#c8ccce;border-color:#c8ccce;color:#202224}
html[data-theme="dark"] :focus-visible {outline:2px solid var(--night-focus);outline-offset:3px}
html[data-theme="dark"] ::selection {background:#445f71;color:white}
@media(max-width:760px){.theme-toggle[data-theme-toggle]{width:44px;height:44px}}

/* The cabinet canvas runs continuously behind the header and content. */
html[data-theme="dark"] :is(.shell,.tech-shell,.main,.tech-content,.owner-content) {background:var(--night-bg)}
html[data-theme="dark"] .sidebar {background:#1d1f21;box-shadow:none}
html[data-theme="dark"] :is(.topbar,.tech-panel,.tech-kpis article,.dashboard-card) {box-shadow:none}
html[data-theme="dark"] :is(.brand,.tech-sidebar .brand,.portal-login) .portal-logo {
  content:url('/assets/create-dental-logo-transparent.png');background:transparent;filter:brightness(0) invert(.92)
}
html[data-theme="dark"] :is(.tech-sidebar,.chief-mobile-menu) .tech-nav-group>summary {color:var(--night-text)}
html[data-theme="dark"] :is(.tech-sidebar,.chief-mobile-menu) .tech-nav-group>summary svg {color:var(--night-muted)}
html[data-theme="dark"] :is(.tech-sidebar,.chief-mobile-menu) .tech-nav-group[open]>summary,
html[data-theme="dark"] :is(.tech-sidebar,.chief-mobile-menu) .tech-nav-group>summary:hover {background:var(--night-raised);color:var(--night-text)}
html[data-theme="dark"] :is(.tech-eyebrow,.tech-side-label,.calendar-weekday,.tech-demo-note,.down-select-group) {color:var(--night-muted)}
html[data-theme="dark"] .tech-segment button {color:var(--night-muted)}
html[data-theme="dark"] .tech-segment button.active,
html[data-theme="dark"] .chief-lead-filters button[aria-pressed="true"] {background:#44484c;color:#fafafa;box-shadow:0 1px 3px #0003}
html[data-theme="dark"] .down-select-trigger,
html[data-theme="dark"] .date-picker-trigger {background:var(--night-raised);color:var(--night-text);border-color:#505559}
html[data-theme="dark"] .down-select-trigger>svg {color:var(--night-muted)}
html[data-theme="dark"] .down-select-trigger[aria-expanded="true"] {border-color:var(--night-focus)}
html[data-theme="dark"] :is(.down-select-menu,.date-picker-popover) {background:var(--night-card);color:var(--night-text);border-color:#505559;box-shadow:0 8px 24px #0004}
html[data-theme="dark"] .down-select-option[aria-selected="true"] {background:#393d40;color:var(--night-text)}
html[data-theme="dark"] .down-select-option:is(:hover,.is-focused) {background:#454a4e;color:#fff}
html[data-theme="dark"] .down-select-trigger:disabled,
html[data-theme="dark"] .down-select-option[aria-disabled="true"] {background:var(--night-card);color:#90969c}
html[data-theme="dark"] .down-select-trigger[aria-invalid="true"] {border-color:#de9898}
html[data-theme="dark"] :is(.down-select-error,.form-error,.chief-lead-error) {color:#f3aaaa}
html[data-theme="dark"] .calendar-day {background:transparent;color:var(--night-text)}
html[data-theme="dark"] .calendar-day:hover {background:var(--night-raised)}
html[data-theme="dark"] .calendar-day.selected {background:#c9cdcf;color:#202224;box-shadow:none}
html[data-theme="dark"] .calendar-markers b {background:#b4bec5}
html[data-theme="dark"] .calendar-day.selected .calendar-markers b {background:#363b40}
html[data-theme="dark"] .tech-chart .tech-bar-track i {background:#666d72}
html[data-theme="dark"] .tech-chart .tech-bar.active .tech-bar-track i {background:#d2d6d8}
html[data-theme="dark"] .tech-chart .tech-bar.active small {color:var(--night-text)}
html[data-theme="dark"] .tech-dialog.tech-order-edit-modal {
  --edit-paper:var(--night-card);--edit-soft:var(--night-raised);--edit-line:var(--night-line);
  --edit-ink:var(--night-text);--edit-muted:var(--night-muted)
}
html[data-theme="dark"] .messages-layout {
  --chat-ink:var(--night-text);--chat-muted:var(--night-muted);--chat-line:var(--night-line);--chat-surface:var(--night-raised)
}
html[data-theme="dark"] .messages-layout .conversation .chat-bubbles .bubble {
  --bubble-text:var(--night-text);--bubble-muted:#b9c0c5;--bubble-rule:#4b5054;background:#303336!important
}
html[data-theme="dark"] .messages-layout .conversation .chat-bubbles .bubble.me {
  --bubble-text:#f3f5f6;--bubble-muted:#d1d6da;--bubble-rule:#62696f;background:#44494e!important
}
html[data-theme="dark"] .messages-layout .conversation .chat-compose-files,
html[data-theme="dark"] .messages-layout .conversation .chat-bubbles .bubble .chat-attachment,
html[data-theme="dark"] .staff-message-file {background:var(--night-raised);border-color:var(--night-line);color:var(--night-text)}
html[data-theme="dark"] .staff-message-file svg {background:#404449;color:var(--night-text)}
html[data-theme="dark"] .messages-layout .conversation .chat-bubbles .bubble .chat-attachment strong {color:var(--night-text)}
html[data-theme="dark"] :is(.down-select-trigger,.tech-nav-group>summary,.tech-segment button):focus-visible {outline:2px solid var(--night-focus);outline-offset:2px}

/* Shared surfaces for legacy cabinet components. */
html[data-theme="dark"] {
  --cd-night-paper: #242729;
  --cd-night-soft: #2a2d30;
  --cd-night-hover: #34383b;
  --cd-night-edge: #454a4e;
  --cd-night-ink: #e6e9eb;
  --cd-night-secondary: #b9c1c6;
  --cd-night-alert: #efaaaa;
  --cd-night-alert-bg: #402c2e;
  --cd-night-good: #a7d6b7;
  --cd-night-good-bg: #283a30;
}

html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table .tech-order-group-row .tech-order-group-summary {
  background:var(--cd-night-soft)!important; color:var(--cd-night-ink)!important;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table .tech-order-group-row .tech-order-group-summary:hover {
  background:var(--cd-night-hover)!important;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-order-view-toggle {
  background:var(--cd-night-soft)!important;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-order-view-toggle button.active {
  background:#45494c!important; color:var(--cd-night-ink)!important;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-order-view-toggle button,
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table :is(th,.order-sort,.tech-order-group-stat,.tech-order-group-primary small) {
  color:var(--cd-night-secondary)!important;
}

/* Keep the header on the cabinet canvas and avoid double-painted row edges. */
html[data-theme="dark"] body .topbar {
  background:var(--night-bg);
  border-color:transparent;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table-grouped tbody tr.tech-order-group-row {
  box-shadow:none;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table thead {
  background:#26292c;
}
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table thead tr,
html[data-theme="dark"] #app[data-tech-orders-restored] .tech-orders-table thead th {
  background:transparent;
}
html[data-theme="dark"] .chief-leads .chief-lead-search {
  background:#1b1f23;
}
html[data-theme="dark"] .chief-leads .chief-lead-search input {
  background:transparent;
}
html[data-theme="dark"] .chief-leads .chief-lead-filters {
  background:transparent;
}

/* Filled actions must keep the same text colour in WebKit and other browsers. */
html[data-theme="dark"] body :is(.btn.primary,.support-page .primary,.upload-page .submit) {
  background:#c8ccce;
  border-color:#c8ccce;
  color:#202224;
  -webkit-text-fill-color:currentColor;
  box-shadow:none;
}
html[data-theme="dark"] body :is(.btn.primary,.support-page .primary,.upload-page .submit):is(:hover,:focus-visible,:active):not(:disabled) {
  background:#e0e3e5;
  border-color:#e0e3e5;
  color:#202224;
  -webkit-text-fill-color:currentColor;
}
html[data-theme="dark"] body :is(.btn.primary,.support-page .primary,.upload-page .submit):disabled {
  background:#3c4145;
  border-color:#3c4145;
  color:#b9c1c6;
  -webkit-text-fill-color:currentColor;
  opacity:1;
  cursor:default;
}
html[data-theme="dark"] .portal-login .auth-consent,
html[data-theme="dark"] .portal-login .auth-consent a {color:var(--night-muted)}
html[data-theme="dark"] :is(.support-page,.upload-page) :is(header,.login,.threads,.thread,.chat h2,.compose,.card) {
  background:var(--night-card);color:var(--night-text);border-color:var(--night-line);box-shadow:none;
}
html[data-theme="dark"] :is(.support-page,.upload-page) :is(.support-brand img,.login-logo,.logo img) {
  background:transparent;filter:brightness(0) invert(.92);
}
html[data-theme="dark"] .support-page :is(.thread:hover,.thread.active,.message),
html[data-theme="dark"] .upload-page :is(.order,.file-icon,.track,.drop:hover,.drop.drag) {
  background:var(--night-raised);color:var(--night-text);
}
html[data-theme="dark"] .support-page .message.support {background:#44494e}
html[data-theme="dark"] :is(.support-page,.upload-page) :is(p,small,time,.eyebrow,.order span,.empty,header a) {color:var(--night-muted)}
html[data-theme="dark"] .upload-page :is(.selected,.drop) {border-color:var(--night-line)}
html[data-theme="dark"] .upload-page :is(.selected.ready,.selected.sent,.feedback.success,.success i) {background:#283a30;color:#a7d6b7;border-color:#496553}
html[data-theme="dark"] .upload-page :is(.selected.ready,.selected.sent) .file-icon {background:#344d3f;color:#a7d6b7}
html[data-theme="dark"] .upload-page :is(.selected.error,.feedback.error,.selected.error .file-icon) {background:#402c2e;color:#efaaaa;border-color:#765053}
html[data-theme="dark"] .support-page .error {color:#efaaaa}
html[data-theme="dark"] .upload-page .bar {background:#c8ccce}
html[data-theme="dark"] .portal-login .auth-recovery a {
  color:var(--night-text);
  text-decoration:underline;
  text-underline-offset:3px;
}
html[data-theme="dark"] .portal-login .auth-recovery a:hover {color:#fff}

/* The composite search field owns its focus ring, including the search icon. */
html[data-theme="dark"] .chief-leads .chief-lead-search:focus-within {
  outline:2px solid var(--night-focus);
  outline-offset:2px;
}
html[data-theme="dark"] .chief-leads .chief-lead-search input:focus-visible {
  outline:none;
  box-shadow:none;
}
