/**
 * Clinic + account theme (be-31).
 * App darkColors under Appearance pref. Landing keeps cool .theme-auto in tokens.css.
 */

/* Shared dark token block (app darkColors) */
.theme-pref-dark,
html.theme-pref-dark {
  color-scheme: dark;

  --bg-page: #0f0f0f;
  --bg-sky: #1a1916;
  --bg-accent: #23221e;
  --surface: #2c2b27;
  --surface-2: #32312c;
  --line: #42413c;
  --text: #f5f5f4;
  --muted: #c9c8c4;
  --navy: #f5f5f4;
  --accent: #8e9bff;
  --accent-ink: #a8b2ff;
  --accent-light: #233252;
  --danger: #ff6b6b;
  --warn: #ffb74d;
  --ok: #5fd068;

  --num-bg: #8e9bff;
  --num-fg: #0f0f0f;

  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.45);

  --portal-ok-bg: #000000;
  --portal-ok-line: #2a2a2a;
  --portal-ok-ink: #5fd068;
  --portal-warn-bg: #332b15;
  --portal-warn-line: #57491d;
  --portal-warn-ink: #ffb74d;
  --portal-err-bg: #3a1a1c;
  --portal-err-line: #5f2226;
  --portal-err-ink: #ff6b6b;
  --portal-neutral-bg: #32312c;
  --portal-neutral-line: #42413c;
  --portal-neutral-ink: #c9c8c4;

  --ws-chart-glucose: #5fd068;
  --ws-chart-hr: #ff6b6b;
  --ws-chart-bmr: #5578a8;
  --ws-chart-steps: #7ba3d8;
  --ws-chart-workout: #a9b6ff;
  --ws-chart-eaten: #ffb74d;
  --ws-chart-total: #5fd068;
  --ws-chart-balance: #a1a09b;
  --ws-chart-fat: #ff6b6b;
  --ws-chart-muscle: #5fd068;
  --ws-chart-weight: #7ba3d8;
  --ws-chart-visceral: #c88be0;
  --ws-chart-ldl: #ff6b6b;
  --ws-chart-tg: #ffb74d;
  --ws-chart-hdl: #5fd068;
  --ws-chart-total-chol: #7ba3d8;
  --ws-chart-grid: #42413c;
  --ws-chart-muted: #c9c8c4;
  --ws-chart-glucose-band: #233252;
  --ws-chart-surplus-zone: #452930;
  --ws-chart-deficit-zone: #1f3f29;
  --ws-chart-deficit-dot: #5fd068;
  --ws-chart-surplus-dot: #ff6b6b;
  --ws-chart-meal: #ffb74d;
  --ws-chart-axis: #c9c8c4;
  --ws-chip-active-line: #8e9bff;
  --ws-overlay: rgba(0, 0, 0, 0.65);
  --ws-strip-title: #ffeec0;
  --ws-chrome-icon: #e6bc2a;
  --ws-chart-plot-bg: #000000;
}

@media (prefers-color-scheme: dark) {
  .theme-pref-system,
  html.theme-pref-system {
    color-scheme: dark;

    --bg-page: #0f0f0f;
    --bg-sky: #1a1916;
    --bg-accent: #23221e;
    --surface: #2c2b27;
    --surface-2: #32312c;
    --line: #42413c;
    --text: #f5f5f4;
    --muted: #c9c8c4;
    --navy: #f5f5f4;
    --accent: #8e9bff;
    --accent-ink: #a8b2ff;
    --accent-light: #233252;
    --danger: #ff6b6b;
    --warn: #ffb74d;
    --ok: #5fd068;

    --num-bg: #8e9bff;
    --num-fg: #0f0f0f;

    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.45);

    --portal-ok-bg: #000000;
    --portal-ok-line: #2a2a2a;
    --portal-ok-ink: #5fd068;
    --portal-warn-bg: #332b15;
    --portal-warn-line: #57491d;
    --portal-warn-ink: #ffb74d;
    --portal-err-bg: #3a1a1c;
    --portal-err-line: #5f2226;
    --portal-err-ink: #ff6b6b;
    --portal-neutral-bg: #32312c;
    --portal-neutral-line: #42413c;
    --portal-neutral-ink: #c9c8c4;

    --ws-chart-glucose: #5fd068;
    --ws-chart-hr: #ff6b6b;
    --ws-chart-bmr: #5578a8;
    --ws-chart-steps: #7ba3d8;
    --ws-chart-workout: #a9b6ff;
    --ws-chart-eaten: #ffb74d;
    --ws-chart-total: #5fd068;
    --ws-chart-balance: #a1a09b;
    --ws-chart-fat: #ff6b6b;
    --ws-chart-muscle: #5fd068;
    --ws-chart-weight: #7ba3d8;
    --ws-chart-visceral: #c88be0;
    --ws-chart-ldl: #ff6b6b;
    --ws-chart-tg: #ffb74d;
    --ws-chart-hdl: #5fd068;
    --ws-chart-total-chol: #7ba3d8;
    --ws-chart-grid: #42413c;
    --ws-chart-muted: #c9c8c4;
    --ws-chart-glucose-band: #233252;
    --ws-chart-surplus-zone: #452930;
    --ws-chart-deficit-zone: #1f3f29;
    --ws-chart-deficit-dot: #5fd068;
    --ws-chart-surplus-dot: #ff6b6b;
    --ws-chart-meal: #ffb74d;
    --ws-chart-axis: #c9c8c4;
    --ws-chip-active-line: #8e9bff;
    --ws-overlay: rgba(0, 0, 0, 0.65);
    --ws-strip-title: #ffeec0;
    --ws-chrome-icon: #e6bc2a;
    --ws-chart-plot-bg: #000000;
  }
}

.theme-pref-light,
html.theme-pref-light {
  color-scheme: light;
}

/* Case-strip body metrics pill — black fill in dark (matches ok chips). */
.theme-pref-dark .ws-banner-stats,
html.theme-pref-dark .ws-banner-stats {
  background: #000000;
  border-color: #2a2a2a;
}

/* Chart range chips (6H…32D) — black fill; active keeps accent border/text. */
.theme-pref-dark .chip,
html.theme-pref-dark .chip {
  background: #000000;
  border-color: #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .chip.active,
html.theme-pref-dark .chip.active {
  background: #000000;
  color: var(--accent-ink);
  border-color: var(--ws-chip-active-line);
}
.theme-pref-dark .chip.ok,
html.theme-pref-dark .chip.ok {
  color: var(--portal-ok-ink);
}
.theme-pref-dark .chip.soon,
html.theme-pref-dark .chip.soon {
  color: var(--portal-warn-ink);
}
.theme-pref-dark .chip.gone,
html.theme-pref-dark .chip.gone {
  color: var(--portal-err-ink);
}
.theme-pref-dark .chip.off,
html.theme-pref-dark .chip.off {
  color: var(--portal-neutral-ink);
}

/* Worklist Name / Email cells (headers stay surface-2) */
.theme-pref-dark .worklist-table td.name-cell,
.theme-pref-dark .worklist-table td.email-cell,
html.theme-pref-dark .worklist-table td.name-cell,
html.theme-pref-dark .worklist-table td.email-cell {
  background: #000000;
}
.theme-pref-dark .worklist-table tbody tr:hover td.name-cell,
.theme-pref-dark .worklist-table tbody tr:hover td.email-cell,
.theme-pref-dark .worklist-table tbody tr:focus-within td.name-cell,
.theme-pref-dark .worklist-table tbody tr:focus-within td.email-cell,
html.theme-pref-dark .worklist-table tbody tr:hover td.name-cell,
html.theme-pref-dark .worklist-table tbody tr:hover td.email-cell,
html.theme-pref-dark .worklist-table tbody tr:focus-within td.name-cell,
html.theme-pref-dark .worklist-table tbody tr:focus-within td.email-cell {
  background: #0a0a0a;
}

/* Plot + axis region only — card chrome (title/chips/legend) stays surface. */
.theme-pref-dark .chart-wrap,
.theme-pref-dark .lipid-chart-box,
html.theme-pref-dark .chart-wrap,
html.theme-pref-dark .lipid-chart-box {
  background: #000000;
  border-radius: 8px;
}

/* Food log meal cards */
.theme-pref-dark .meal-chip,
html.theme-pref-dark .meal-chip {
  background: #000000;
  border-color: #2a2a2a;
}

/* Energy balance pill */
.theme-pref-dark .food-log-card .balance-pill.deficit,
.theme-pref-dark .food-log-card .balance-pill.surplus,
html.theme-pref-dark .food-log-card .balance-pill.deficit,
html.theme-pref-dark .food-log-card .balance-pill.surplus {
  background: #000000;
  border: 1px solid #2a2a2a;
}

/* Macro meter tracks */
.theme-pref-dark .macro-row .track,
html.theme-pref-dark .macro-row .track {
  background: #000000;
}

/* Nutrition report body */
.theme-pref-dark .nutrition-detail-body,
html.theme-pref-dark .nutrition-detail-body {
  background: #000000;
  border-color: #2a2a2a;
}

/* Labs table rows */
.theme-pref-dark .lab-panel .data-table th,
.theme-pref-dark .lab-panel .data-table td,
html.theme-pref-dark .lab-panel .data-table th,
html.theme-pref-dark .lab-panel .data-table td {
  background: #000000;
  border-bottom-color: #2a2a2a;
}
.theme-pref-dark .lab-panel,
html.theme-pref-dark .lab-panel {
  border-bottom-color: #2a2a2a;
}

/* Chat mentor picker + profile mentor pills */
.theme-pref-dark .mentor-nav button,
html.theme-pref-dark .mentor-nav button {
  background: #000000;
  border-color: #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .mentor-nav button.active,
html.theme-pref-dark .mentor-nav button.active {
  background: #000000;
  color: var(--accent-ink);
  border-color: var(--ws-chip-active-line);
}
.theme-pref-dark .mentor-pill,
html.theme-pref-dark .mentor-pill {
  background: #000000;
  border-color: #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .mentor-pill.active,
html.theme-pref-dark .mentor-pill.active {
  background: #000000;
  border-color: var(--ws-chip-active-line);
  color: var(--accent-ink);
}

/* AI chat assistant bubbles */
.theme-pref-dark .bubble.assistant,
html.theme-pref-dark .bubble.assistant {
  background: #000000;
  border-color: #2a2a2a;
}

/* Rules editor + clinical text blocks */
.theme-pref-dark .rules-fold,
html.theme-pref-dark .rules-fold {
  background: #000000;
  border-color: #2a2a2a;
}
.theme-pref-dark .rules-fold-toggle,
html.theme-pref-dark .rules-fold-toggle {
  background: #000000;
}
.theme-pref-dark .rules-editor-section textarea,
.theme-pref-dark .rules-editor-section #rules-raw,
html.theme-pref-dark .rules-editor-section textarea,
html.theme-pref-dark .rules-editor-section #rules-raw {
  background: #000000;
  border-color: #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .rules-history-detail,
html.theme-pref-dark .rules-history-detail {
  background: #000000;
  border: 1px solid #2a2a2a;
}
.theme-pref-dark .rules-raw,
.theme-pref-dark .coach-summary,
.theme-pref-dark .reasoning-block,
html.theme-pref-dark .rules-raw,
html.theme-pref-dark .coach-summary,
html.theme-pref-dark .reasoning-block {
  background: #000000;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 12px;
}

/* Worklist column filters */
.theme-pref-dark .ux-filter-input,
html.theme-pref-dark .ux-filter-input {
  background: #000000;
  border-color: #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .ux-filter-clear:hover,
html.theme-pref-dark .ux-filter-clear:hover {
  background: #1a1a1a;
}

/* Worklist action buttons (Workspace / Cover AI / Revoke) */
.theme-pref-dark .row-actions .portal-btn,
html.theme-pref-dark .row-actions .portal-btn {
  background: #000000;
  border: 1px solid #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .row-actions .portal-btn.secondary,
html.theme-pref-dark .row-actions .portal-btn.secondary {
  background: #000000;
  border-color: #2a2a2a;
  color: var(--text);
}
.theme-pref-dark .row-actions .portal-btn.danger,
html.theme-pref-dark .row-actions .portal-btn.danger {
  background: #000000;
  border-color: var(--portal-err-line);
  color: var(--portal-err-ink);
}
.theme-pref-dark .row-actions .portal-btn.danger:hover,
html.theme-pref-dark .row-actions .portal-btn.danger:hover {
  background: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  .theme-pref-system .ws-banner-stats,
  html.theme-pref-system .ws-banner-stats {
    background: #000000;
    border-color: #2a2a2a;
  }

  .theme-pref-system .chip,
  html.theme-pref-system .chip {
    background: #000000;
    border-color: #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .chip.active,
  html.theme-pref-system .chip.active {
    background: #000000;
    color: var(--accent-ink);
    border-color: var(--ws-chip-active-line);
  }
  .theme-pref-system .chip.ok,
  html.theme-pref-system .chip.ok {
    color: var(--portal-ok-ink);
  }
  .theme-pref-system .chip.soon,
  html.theme-pref-system .chip.soon {
    color: var(--portal-warn-ink);
  }
  .theme-pref-system .chip.gone,
  html.theme-pref-system .chip.gone {
    color: var(--portal-err-ink);
  }
  .theme-pref-system .chip.off,
  html.theme-pref-system .chip.off {
    color: var(--portal-neutral-ink);
  }

  .theme-pref-system .worklist-table td.name-cell,
  .theme-pref-system .worklist-table td.email-cell,
  html.theme-pref-system .worklist-table td.name-cell,
  html.theme-pref-system .worklist-table td.email-cell {
    background: #000000;
  }
  .theme-pref-system .worklist-table tbody tr:hover td.name-cell,
  .theme-pref-system .worklist-table tbody tr:hover td.email-cell,
  .theme-pref-system .worklist-table tbody tr:focus-within td.name-cell,
  .theme-pref-system .worklist-table tbody tr:focus-within td.email-cell,
  html.theme-pref-system .worklist-table tbody tr:hover td.name-cell,
  html.theme-pref-system .worklist-table tbody tr:hover td.email-cell,
  html.theme-pref-system .worklist-table tbody tr:focus-within td.name-cell,
  html.theme-pref-system .worklist-table tbody tr:focus-within td.email-cell {
    background: #0a0a0a;
  }

  .theme-pref-system .chart-wrap,
  .theme-pref-system .lipid-chart-box,
  html.theme-pref-system .chart-wrap,
  html.theme-pref-system .lipid-chart-box {
    background: #000000;
    border-radius: 8px;
  }

  .theme-pref-system .meal-chip,
  html.theme-pref-system .meal-chip {
    background: #000000;
    border-color: #2a2a2a;
  }

  .theme-pref-system .food-log-card .balance-pill.deficit,
  .theme-pref-system .food-log-card .balance-pill.surplus,
  html.theme-pref-system .food-log-card .balance-pill.deficit,
  html.theme-pref-system .food-log-card .balance-pill.surplus {
    background: #000000;
    border: 1px solid #2a2a2a;
  }

  .theme-pref-system .macro-row .track,
  html.theme-pref-system .macro-row .track {
    background: #000000;
  }

  .theme-pref-system .nutrition-detail-body,
  html.theme-pref-system .nutrition-detail-body {
    background: #000000;
    border-color: #2a2a2a;
  }

  .theme-pref-system .lab-panel .data-table th,
  .theme-pref-system .lab-panel .data-table td,
  html.theme-pref-system .lab-panel .data-table th,
  html.theme-pref-system .lab-panel .data-table td {
    background: #000000;
    border-bottom-color: #2a2a2a;
  }
  .theme-pref-system .lab-panel,
  html.theme-pref-system .lab-panel {
    border-bottom-color: #2a2a2a;
  }

  .theme-pref-system .mentor-nav button,
  html.theme-pref-system .mentor-nav button {
    background: #000000;
    border-color: #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .mentor-nav button.active,
  html.theme-pref-system .mentor-nav button.active {
    background: #000000;
    color: var(--accent-ink);
    border-color: var(--ws-chip-active-line);
  }
  .theme-pref-system .mentor-pill,
  html.theme-pref-system .mentor-pill {
    background: #000000;
    border-color: #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .mentor-pill.active,
  html.theme-pref-system .mentor-pill.active {
    background: #000000;
    border-color: var(--ws-chip-active-line);
    color: var(--accent-ink);
  }

  .theme-pref-system .bubble.assistant,
  html.theme-pref-system .bubble.assistant {
    background: #000000;
    border-color: #2a2a2a;
  }

  .theme-pref-system .rules-fold,
  html.theme-pref-system .rules-fold {
    background: #000000;
    border-color: #2a2a2a;
  }
  .theme-pref-system .rules-fold-toggle,
  html.theme-pref-system .rules-fold-toggle {
    background: #000000;
  }
  .theme-pref-system .rules-editor-section textarea,
  .theme-pref-system .rules-editor-section #rules-raw,
  html.theme-pref-system .rules-editor-section textarea,
  html.theme-pref-system .rules-editor-section #rules-raw {
    background: #000000;
    border-color: #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .rules-history-detail,
  html.theme-pref-system .rules-history-detail {
    background: #000000;
    border: 1px solid #2a2a2a;
  }
  .theme-pref-system .rules-raw,
  .theme-pref-system .coach-summary,
  .theme-pref-system .reasoning-block,
  html.theme-pref-system .rules-raw,
  html.theme-pref-system .coach-summary,
  html.theme-pref-system .reasoning-block {
    background: #000000;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 12px;
  }

  .theme-pref-system .ux-filter-input,
  html.theme-pref-system .ux-filter-input {
    background: #000000;
    border-color: #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .ux-filter-clear:hover,
  html.theme-pref-system .ux-filter-clear:hover {
    background: #1a1a1a;
  }

  .theme-pref-system .row-actions .portal-btn,
  html.theme-pref-system .row-actions .portal-btn {
    background: #000000;
    border: 1px solid #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .row-actions .portal-btn.secondary,
  html.theme-pref-system .row-actions .portal-btn.secondary {
    background: #000000;
    border-color: #2a2a2a;
    color: var(--text);
  }
  .theme-pref-system .row-actions .portal-btn.danger,
  html.theme-pref-system .row-actions .portal-btn.danger {
    background: #000000;
    border-color: var(--portal-err-line);
    color: var(--portal-err-ink);
  }
  .theme-pref-system .row-actions .portal-btn.danger:hover,
  html.theme-pref-system .row-actions .portal-btn.danger:hover {
    background: #1a1a1a;
  }
}

.theme-pref-select {
  min-width: 7.5rem;
  max-width: 9rem;
}
