html[data-theme="light"] { color-scheme: light; }

html[data-theme="dark"] {
    color-scheme: dark;
    --theme-background: #111827;
    --theme-surface: #1b2638;
    --theme-surface-soft: #141f30;
    --theme-border: #334155;
    --theme-text: #e5e7eb;
    --theme-muted: #a0aec0;
}

html[data-theme="dark"] body {
    background-color: var(--theme-background) !important;
    color: var(--theme-text) !important;
    transition: background-color .18s ease, color .18s ease;
}

html[data-theme="dark"] .bg-surface,
html[data-theme="dark"] [class~="bg-white"],
html[data-theme="dark"] [class~="bg-white/90"],
html[data-theme="dark"] [class~="bg-white/95"] {
    background-color: var(--theme-surface) !important;
}

html[data-theme="dark"] body.bg-surface,
html[data-theme="dark"] body.bg-white {
    background-color: var(--theme-background) !important;
}

/* The financial report cards use inline styles, so give them explicit dark surfaces. */
html[data-theme="dark"] .report-card {
    background-color: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

html[data-theme="dark"] .report-card[class~="!bg-violet"] {
    background-color: #5146e5 !important;
    border-color: #5146e5 !important;
    color: #fff !important;
}

html[data-theme="dark"] #report-trend line { stroke: #3a4b62 !important; }
html[data-theme="dark"] #report-trend text { fill: #aab7ca !important; }
html[data-theme="dark"] .report-card .divide-y > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] [class*="bg-[#f"],
html[data-theme="dark"] [class*="bg-[#e"],
html[data-theme="dark"] [class~="bg-cloud"],
html[data-theme="dark"] [class~="bg-gray-50"],
html[data-theme="dark"] [class~="bg-gray-100"],
html[data-theme="dark"] [class~="bg-slate-50"],
html[data-theme="dark"] [class~="bg-slate-100"] {
    background-color: var(--theme-surface-soft) !important;
}

html[data-theme="dark"] [class*="hover:bg-[#f"]:hover,
html[data-theme="dark"] [class*="hover:bg-white"]:hover,
html[data-theme="dark"] [class~="hover:bg-gray-50"]:hover {
    background-color: #202d42 !important;
}

html[data-theme="dark"] [class~="bg-violet-soft"],
html[data-theme="dark"] [class~="bg-brand-soft"],
html[data-theme="dark"] [class~="bg-brand-section"] {
    background-color: #24243b !important;
}

html[data-theme="dark"] [class*="bg-blue-50"],
html[data-theme="dark"] [class*="bg-sky-50"] {
    background-color: #172d48 !important;
    color: #bfdbfe !important;
}

html[data-theme="dark"] [class*="bg-emerald-50"],
html[data-theme="dark"] [class*="bg-green-50"] {
    background-color: #14352f !important;
    color: #a7f3d0 !important;
}

html[data-theme="dark"] [class*="bg-amber-50"],
html[data-theme="dark"] [class*="bg-yellow-50"] {
    background-color: #392e19 !important;
    color: #fde68a !important;
}

html[data-theme="dark"] [class*="bg-rose-50"],
html[data-theme="dark"] [class*="bg-red-50"] {
    background-color: #3a202b !important;
    color: #fecdd3 !important;
}

html[data-theme="dark"] [class*="border-[#e"],
html[data-theme="dark"] [class*="border-gray-1"],
html[data-theme="dark"] [class*="border-slate-1"],
html[data-theme="dark"] [class*="divide-[#e"] > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] [class~="text-ink"],
html[data-theme="dark"] [class*="text-[#17172f]"],
html[data-theme="dark"] [class*="text-[#1F2937]"],
html[data-theme="dark"] [class~="text-gray-700"],
html[data-theme="dark"] [class~="text-gray-800"],
html[data-theme="dark"] [class~="text-gray-900"],
html[data-theme="dark"] [class~="text-slate-700"],
html[data-theme="dark"] [class~="text-slate-800"],
html[data-theme="dark"] [class~="text-slate-900"] {
    color: var(--theme-text) !important;
}

html[data-theme="dark"] [class~="text-muted"],
html[data-theme="dark"] [class*="text-[#77788f]"],
html[data-theme="dark"] [class*="text-[#777]"],
html[data-theme="dark"] [class*="text-[#aaaabd]"],
html[data-theme="dark"] [class~="text-gray-400"],
html[data-theme="dark"] [class~="text-gray-500"],
html[data-theme="dark"] [class~="text-gray-600"],
html[data-theme="dark"] [class~="text-slate-400"],
html[data-theme="dark"] [class~="text-slate-500"],
html[data-theme="dark"] [class~="text-slate-600"] {
    color: var(--theme-muted) !important;
}

html[data-theme="dark"] [class~="text-violet"],
html[data-theme="dark"] [class~="text-brand"] {
    color: #b6adff !important;
}

html[data-theme="dark"] [class*="border-amber-"],
html[data-theme="dark"] [class*="border-yellow-"],
html[data-theme="dark"] [class*="border-rose-"],
html[data-theme="dark"] [class*="border-red-"],
html[data-theme="dark"] [class*="border-emerald-"],
html[data-theme="dark"] [class*="border-green-"] {
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] [class*="text-blue-700"],
html[data-theme="dark"] [class*="text-sky-700"] { color: #bfdbfe !important; }
html[data-theme="dark"] [class*="text-emerald-700"],
html[data-theme="dark"] [class*="text-green-700"] { color: #a7f3d0 !important; }
html[data-theme="dark"] [class*="text-amber-700"],
html[data-theme="dark"] [class*="text-amber-800"],
html[data-theme="dark"] [class*="text-yellow-700"] { color: #fde68a !important; }
html[data-theme="dark"] [class*="text-rose-700"],
html[data-theme="dark"] [class*="text-red-700"] { color: #fecdd3 !important; }

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background-color: #131d2c !important;
    border-color: #3a4960 !important;
    color: var(--theme-text) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #a0aec0 !important; }
html[data-theme="dark"] option { background: #1b2638; color: var(--theme-text); }

/* The POS toolbar intentionally stays navy, including its selected white tab. */
html[data-theme="dark"] .pos-chrome [class~="bg-white"] {
    background-color: #fff !important;
    color: #11142b !important;
}

html[data-theme="dark"] .pos-chrome [class~="text-posnavy"] { color: #11142b !important; }

@media print {
    html[data-theme="dark"],
    html[data-theme="dark"] body { background: #fff !important; color: #111 !important; }
}
