/* Semantic colors also cover the custom staff navigation and customer workspace. */
:root { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --theme-canvas: #0f172a;
  --theme-surface: #182334;
  --theme-surface-muted: #243247;
  --theme-border: #334155;
  --theme-border-strong: #475569;
  --theme-text: #f1f5f9;
  --theme-text-secondary: #cbd5e1;
  --theme-text-muted: #a3b2c7;
}

html[data-theme="dark"] body {
  background: var(--theme-canvas);
  color: var(--theme-text);
}

/* Neutral utilities retain their hierarchy across existing views and Turbo frames. */
html[data-theme="dark"] {
  --color-gray-50: #1b283b;
  --color-gray-100: #243247;
  --color-gray-200: #334155;
  --color-gray-300: #475569;
  --color-gray-400: #a3b2c7;
  --color-gray-500: #a3b2c7;
  --color-gray-600: #b6c3d5;
  --color-gray-700: #cbd5e1;
  --color-gray-800: #e2e8f0;
  --color-gray-900: #f1f5f9;
}
html[data-theme="dark"] .bg-white { background-color: var(--theme-surface); }
html[data-theme="dark"] .bg-white\/60 { background-color: rgb(24 35 52 / .6); }
html[data-theme="dark"] .bg-white\/10 { background-color: rgb(24 35 52 / .8); }
html[data-theme="dark"] .hover\:bg-white:hover { background-color: var(--theme-surface-muted); }
html[data-theme="dark"] :is(.hover\:bg-gray-50, .hover\:bg-gray-100, .hover\:bg-gray-200, .hover\:bg-gray-300, .hover\:bg-slate-200):hover { background-color: var(--theme-surface-muted); }
html[data-theme="dark"] .hover\:bg-amber-100:hover { background-color: var(--theme-amber-bg); }
html[data-theme="dark"] .to-white { --tw-gradient-to: var(--theme-canvas); }
html[data-theme="dark"] :is(.text-black, .text-slate-800) { color: var(--theme-text); }
html[data-theme="dark"] :is(input, textarea, select)::placeholder { color: var(--theme-text-muted); }
html[data-theme="dark"] :is(input, textarea, select, trix-editor):not([class*="bg-"]) { background-color: var(--theme-surface); }
html[data-theme="dark"] :is(input, textarea, select):not([class*="text-"]) { color: var(--theme-text); }
html[data-theme="dark"] .ring-offset-2 { --tw-ring-offset-color: var(--theme-surface); }

/* Preserve status colors while making pale badges and colored links readable. */
html[data-theme="dark"] {
  --theme-blue-bg: #172c50;
  --theme-blue-text: #93c5fd;
  --theme-blue-border: #1e40af;
}
html[data-theme="dark"] :is(.bg-blue-50, .bg-blue-100, .bg-blue-200) { background-color: var(--theme-blue-bg); }
html[data-theme="dark"] :is(.text-blue-600, .text-blue-700, .text-blue-800, .text-blue-900, .text-blue-950) { color: var(--theme-blue-text); }
html[data-theme="dark"] :is(.hover\:text-blue-600, .hover\:text-blue-700, .hover\:text-blue-800, .hover\:text-blue-900):hover { color: #bfdbfe; }
html[data-theme="dark"] :is(.border-blue-200, .border-blue-300) { border-color: var(--theme-blue-border); }
html[data-theme="dark"] {
  --theme-indigo-bg: #24264f;
  --theme-indigo-text: #a5b4fc;
  --theme-indigo-border: #3730a3;
}
html[data-theme="dark"] :is(.bg-indigo-50, .bg-indigo-100, .bg-indigo-200) { background-color: var(--theme-indigo-bg); }
html[data-theme="dark"] :is(.text-indigo-600, .text-indigo-700, .text-indigo-800, .text-indigo-900, .text-indigo-950) { color: var(--theme-indigo-text); }
html[data-theme="dark"] :is(.hover\:text-indigo-600, .hover\:text-indigo-700, .hover\:text-indigo-800, .hover\:text-indigo-900):hover { color: #c7d2fe; }
html[data-theme="dark"] :is(.border-indigo-200, .border-indigo-300) { border-color: var(--theme-indigo-border); }
html[data-theme="dark"] {
  --theme-red-bg: #3d202c;
  --theme-red-text: #fca5a5;
  --theme-red-border: #991b1b;
}
html[data-theme="dark"] :is(.bg-red-50, .bg-red-100, .bg-red-200) { background-color: var(--theme-red-bg); }
html[data-theme="dark"] :is(.text-red-600, .text-red-700, .text-red-800, .text-red-900, .text-red-950) { color: var(--theme-red-text); }
html[data-theme="dark"] :is(.hover\:text-red-600, .hover\:text-red-700, .hover\:text-red-800, .hover\:text-red-900):hover { color: #fecaca; }
html[data-theme="dark"] :is(.border-red-200, .border-red-300) { border-color: var(--theme-red-border); }
html[data-theme="dark"] {
  --theme-green-bg: #15382f;
  --theme-green-text: #86efac;
  --theme-green-border: #166534;
}
html[data-theme="dark"] :is(.bg-green-50, .bg-green-100, .bg-green-200) { background-color: var(--theme-green-bg); }
html[data-theme="dark"] :is(.text-green-600, .text-green-700, .text-green-800, .text-green-900, .text-green-950) { color: var(--theme-green-text); }
html[data-theme="dark"] :is(.hover\:text-green-600, .hover\:text-green-700, .hover\:text-green-800, .hover\:text-green-900):hover { color: #bbf7d0; }
html[data-theme="dark"] :is(.border-green-200, .border-green-300) { border-color: var(--theme-green-border); }
html[data-theme="dark"] {
  --theme-yellow-bg: #39301f;
  --theme-yellow-text: #fde047;
  --theme-yellow-border: #854d0e;
}
html[data-theme="dark"] :is(.bg-yellow-50, .bg-yellow-100, .bg-yellow-200) { background-color: var(--theme-yellow-bg); }
html[data-theme="dark"] :is(.text-yellow-600, .text-yellow-700, .text-yellow-800, .text-yellow-900, .text-yellow-950) { color: var(--theme-yellow-text); }
html[data-theme="dark"] :is(.hover\:text-yellow-600, .hover\:text-yellow-700, .hover\:text-yellow-800, .hover\:text-yellow-900):hover { color: #fef08a; }
html[data-theme="dark"] :is(.border-yellow-200, .border-yellow-300) { border-color: var(--theme-yellow-border); }
html[data-theme="dark"] {
  --theme-amber-bg: #3d2c22;
  --theme-amber-text: #fcd34d;
  --theme-amber-border: #92400e;
}
html[data-theme="dark"] :is(.bg-amber-50, .bg-amber-100, .bg-amber-200) { background-color: var(--theme-amber-bg); }
html[data-theme="dark"] :is(.text-amber-600, .text-amber-700, .text-amber-800, .text-amber-900, .text-amber-950) { color: var(--theme-amber-text); }
html[data-theme="dark"] :is(.hover\:text-amber-600, .hover\:text-amber-700, .hover\:text-amber-800, .hover\:text-amber-900):hover { color: #fde68a; }
html[data-theme="dark"] :is(.border-amber-200, .border-amber-300) { border-color: var(--theme-amber-border); }
html[data-theme="dark"] {
  --theme-orange-bg: #3d2924;
  --theme-orange-text: #fdba74;
  --theme-orange-border: #9a3412;
}
html[data-theme="dark"] :is(.bg-orange-50, .bg-orange-100, .bg-orange-200) { background-color: var(--theme-orange-bg); }
html[data-theme="dark"] :is(.text-orange-600, .text-orange-700, .text-orange-800, .text-orange-900, .text-orange-950) { color: var(--theme-orange-text); }
html[data-theme="dark"] :is(.hover\:text-orange-600, .hover\:text-orange-700, .hover\:text-orange-800, .hover\:text-orange-900):hover { color: #fed7aa; }
html[data-theme="dark"] :is(.border-orange-200, .border-orange-300) { border-color: var(--theme-orange-border); }
html[data-theme="dark"] {
  --theme-purple-bg: #322347;
  --theme-purple-text: #d8b4fe;
  --theme-purple-border: #6b21a8;
}
html[data-theme="dark"] :is(.bg-purple-50, .bg-purple-100, .bg-purple-200) { background-color: var(--theme-purple-bg); }
html[data-theme="dark"] :is(.text-purple-600, .text-purple-700, .text-purple-800, .text-purple-900, .text-purple-950) { color: var(--theme-purple-text); }
html[data-theme="dark"] :is(.hover\:text-purple-600, .hover\:text-purple-700, .hover\:text-purple-800, .hover\:text-purple-900):hover { color: #e9d5ff; }
html[data-theme="dark"] :is(.border-purple-200, .border-purple-300) { border-color: var(--theme-purple-border); }
html[data-theme="dark"] {
  --theme-violet-bg: #2d254c;
  --theme-violet-text: #c4b5fd;
  --theme-violet-border: #5b21b6;
}
html[data-theme="dark"] :is(.bg-violet-50, .bg-violet-100, .bg-violet-200) { background-color: var(--theme-violet-bg); }
html[data-theme="dark"] :is(.text-violet-600, .text-violet-700, .text-violet-800, .text-violet-900, .text-violet-950) { color: var(--theme-violet-text); }
html[data-theme="dark"] :is(.hover\:text-violet-600, .hover\:text-violet-700, .hover\:text-violet-800, .hover\:text-violet-900):hover { color: #ddd6fe; }
html[data-theme="dark"] :is(.border-violet-200, .border-violet-300) { border-color: var(--theme-violet-border); }
html[data-theme="dark"] {
  --theme-teal-bg: #153839;
  --theme-teal-text: #5eead4;
  --theme-teal-border: #115e59;
}
html[data-theme="dark"] :is(.bg-teal-50, .bg-teal-100, .bg-teal-200) { background-color: var(--theme-teal-bg); }
html[data-theme="dark"] :is(.text-teal-600, .text-teal-700, .text-teal-800, .text-teal-900, .text-teal-950) { color: var(--theme-teal-text); }
html[data-theme="dark"] :is(.hover\:text-teal-600, .hover\:text-teal-700, .hover\:text-teal-800, .hover\:text-teal-900):hover { color: #99f6e4; }
html[data-theme="dark"] :is(.border-teal-200, .border-teal-300) { border-color: var(--theme-teal-border); }
html[data-theme="dark"] {
  --theme-emerald-bg: #14382f;
  --theme-emerald-text: #6ee7b7;
  --theme-emerald-border: #065f46;
}
html[data-theme="dark"] :is(.bg-emerald-50, .bg-emerald-100, .bg-emerald-200) { background-color: var(--theme-emerald-bg); }
html[data-theme="dark"] :is(.text-emerald-600, .text-emerald-700, .text-emerald-800, .text-emerald-900, .text-emerald-950) { color: var(--theme-emerald-text); }
html[data-theme="dark"] :is(.hover\:text-emerald-600, .hover\:text-emerald-700, .hover\:text-emerald-800, .hover\:text-emerald-900):hover { color: #a7f3d0; }
html[data-theme="dark"] :is(.border-emerald-200, .border-emerald-300) { border-color: var(--theme-emerald-border); }

html[data-theme="dark"] :is(.from-blue-50, .from-blue-100) { --tw-gradient-from: var(--theme-blue-bg); }
html[data-theme="dark"] .to-teal-100 { --tw-gradient-to: var(--theme-teal-bg); }
html[data-theme="dark"] :is(.admin-nav-group > button[aria-expanded="true"], .admin-nav-links a[aria-current="page"], .customer-avatar, .customer-link, .customer-tab:hover, .customer-tab.is-active, .customer-stat-icon) { color: var(--theme-blue-text); }
html[data-theme="dark"] .guide-content :is(h2, h3) { color: var(--theme-text); }
html[data-theme="dark"] .guide-content :is(p, ul, ol, td) { color: var(--theme-text-secondary); }
html[data-theme="dark"] .guide-content :is(code, th) { background: var(--theme-surface-muted); color: var(--theme-text-secondary); }
html[data-theme="dark"] .guide-content td { border-color: var(--theme-border); }
html[data-theme="dark"] .guide-content .guide-note { background: var(--theme-blue-bg); color: var(--theme-blue-text); }
html[data-theme="dark"] .guide-content .guide-warning { background: var(--theme-amber-bg); color: var(--theme-amber-text); }
html[data-theme="dark"] :is(trix-toolbar .trix-dialog, trix-toolbar .trix-input--dialog, .attachment__metadata) { background: var(--theme-surface); color: var(--theme-text); }
html[data-theme="dark"] trix-toolbar .trix-button { color: var(--theme-text-secondary); border-color: var(--theme-border); }
html[data-theme="dark"] trix-toolbar .trix-button--icon::before { filter: invert(1); }
html[data-theme="dark"] trix-toolbar .trix-button.trix-active { background: var(--theme-blue-bg); }
html[data-theme="dark"] .trix-content pre { background: var(--theme-surface-muted); }
