/* The PHP views share Tailwind utilities; these semantic overrides let one root
   class theme every view without duplicating light/dark markup in each form. */
html.dark {
  color-scheme: dark;
  --app-canvas: #000;
  --app-surface: #111;
  --app-surface-raised: #1b1b1b;
  --app-border: #343434;
  --app-text: #f5f5f5;
  --app-muted: #aaa;
}

html.dark,
html.dark body,
html.dark main,
html.dark [class~="bg-[#f5f7fc]"],
html.dark [class~="bg-[#f5f7fb]"] {
  background-color: var(--app-canvas) !important;
  color: var(--app-text);
}

html.dark main[class~="bg-white"] { background-color: var(--app-canvas) !important; }
html.dark aside[class~="bg-white"],
html.dark aside > [class~="bg-white"] { background-color: #090909 !important; }

html.dark :is([class~="bg-white"], [class~="bg-white/95"], [class~="bg-white/90"], [class~="bg-white/80"], [class~="bg-white/60"], [class~="bg-white/50"]) {
  background-color: var(--app-surface) !important;
}
html.dark :is([class~="bg-slate-50"], [class~="bg-slate-50/90"], [class~="bg-slate-50/80"], [class~="bg-slate-50/70"], [class~="bg-slate-50/60"], [class~="bg-slate-50/50"], [class~="bg-slate-50/30"], [class~="bg-gray-50"], [class~="bg-gray-50/90"], [class~="bg-gray-50/80"], [class~="bg-gray-50/75"], [class~="bg-gray-50/70"], [class~="bg-gray-50/60"], [class~="bg-gray-50/50"], [class~="bg-gray-50/30"], [class~="bg-[#f8f9fa]"]) {
  background-color: #171717 !important;
}
html.dark :is([class~="bg-slate-100"], [class~="bg-slate-100/90"], [class~="bg-slate-100/80"], [class~="bg-slate-100/70"], [class~="bg-slate-100/60"], [class~="bg-gray-100"], [class~="bg-gray-100/80"]) {
  background-color: var(--app-surface-raised) !important;
}
html.dark :is([class~="bg-slate-200"], [class~="bg-slate-200/70"], [class~="bg-slate-300"], [class~="bg-gray-200"], [class~="bg-gray-200/50"]) {
  background-color: #252525 !important;
}

html.dark :is([class~="text-slate-950"], [class~="text-slate-900"], [class~="text-slate-800"], [class~="text-gray-950"], [class~="text-gray-900"], [class~="text-gray-800"], [class~="text-black"], [class~="text-[#2a3547]"], [class~="text-[#2b3148]"]) {
  color: var(--app-text) !important;
}
html.dark :is([class~="text-slate-700"], [class~="text-slate-600"], [class~="text-gray-700"], [class~="text-gray-600"]) {
  color: #d1d1d1 !important;
}
html.dark :is([class~="text-slate-500"], [class~="text-slate-400"], [class~="text-slate-300"], [class~="text-gray-500"], [class~="text-gray-400"], [class~="text-gray-300"]) {
  color: var(--app-muted) !important;
}
html.dark :is([class~="text-mint-600"], [class~="text-mint-700"], [class~="text-mint-800"], [class~="text-mint-900"], [class~="text-emerald-600"], [class~="text-emerald-700"], [class~="text-green-600"]) {
  color: var(--color-mint-300) !important;
}
html.dark :is([class~="text-rose-600"], [class~="text-rose-700"], [class~="text-red-600"], [class~="text-red-700"]) { color: #fda4af !important; }
html.dark :is([class~="text-violet-600"], [class~="text-violet-700"], [class~="text-purple-700"], [class~="text-indigo-700"]) { color: #c4b5fd !important; }
html.dark :is([class~="text-amber-700"], [class~="text-amber-800"], [class~="text-orange-700"]) { color: #fcd34d !important; }

html.dark :is([class~="border-slate-50"], [class~="border-slate-100"], [class~="border-slate-200"], [class~="border-slate-200/80"], [class~="border-slate-200/70"], [class~="border-slate-200/60"], [class~="border-slate-300"], [class~="border-gray-50"], [class~="border-gray-100"], [class~="border-gray-200"], [class~="border-gray-300"], [class~="border-white"]) {
  border-color: var(--app-border) !important;
}
html.dark :is([class~="divide-slate-50"], [class~="divide-slate-100"], [class~="divide-slate-200"], [class~="divide-gray-50"], [class~="divide-gray-100"], [class~="divide-gray-200"]) > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--app-border) !important;
}

html.dark :is([class~="bg-mint-50"], [class~="bg-mint-50/30"], [class~="bg-mint-50/40"], [class~="bg-mint-50/50"], [class~="bg-mint-50/60"], [class~="bg-mint-50/70"], [class~="bg-mint-50/80"], [class~="bg-mint-50/90"], [class~="bg-mint-100"], [class~="bg-mint-100/40"], [class~="bg-mint-100/70"], [class~="bg-mint-200/40"], [class~="bg-emerald-50"], [class~="bg-emerald-50/20"], [class~="bg-emerald-50/30"], [class~="bg-emerald-50/40"], [class~="bg-emerald-50/70"], [class~="bg-emerald-100"], [class~="bg-emerald-200"], [class~="bg-green-50"], [class~="bg-green-100"], [class~="bg-teal-50"], [class~="bg-teal-100"], [class~="bg-[#d1fae5]"], [class~="bg-[#e6fffa]"], [class~="bg-[#e6fff7]"], [class~="bg-[#ecfdf5]"]) { background-color: color-mix(in srgb, var(--color-mint-900) 65%, #111) !important; }
html.dark :is([class~="bg-rose-50"], [class~="bg-rose-50/50"], [class~="bg-rose-50/80"], [class~="bg-rose-100"], [class~="bg-rose-100/50"], [class~="bg-rose-200"], [class~="bg-red-50"], [class~="bg-red-100"], [class~="bg-pink-50"], [class~="bg-pink-100"], [class~="bg-[#fde2e4]"], [class~="bg-[#fef1f2]"], [class~="bg-[#ffe6ec]"]) { background-color: #301a21 !important; }
html.dark :is([class~="bg-violet-50"], [class~="bg-violet-100"], [class~="bg-purple-50"], [class~="bg-purple-100"], [class~="bg-indigo-50"], [class~="bg-indigo-100"], [class~="bg-[#ede9fe]"], [class~="bg-[#f4edff]"], [class~="bg-[#f3ebff]"], [class~="bg-[#e6d7ff]"]) { background-color: #251d37 !important; }
html.dark :is([class~="bg-sky-50"], [class~="bg-sky-100"], [class~="bg-blue-50"], [class~="bg-blue-100"], [class~="bg-cyan-50"], [class~="bg-cyan-100"], [class~="bg-[#e0f2fe]"], [class~="bg-[#e6f6ff]"]) { background-color: #152738 !important; }
html.dark :is([class~="bg-amber-50"], [class~="bg-amber-50/60"], [class~="bg-amber-50/80"], [class~="bg-amber-100"], [class~="bg-yellow-50"], [class~="bg-yellow-100"], [class~="bg-orange-50"], [class~="bg-orange-100"], [class~="bg-[#fef3c7]"], [class~="bg-[#fff8e6]"], [class~="bg-[#ffeecd]"]) { background-color: #302719 !important; }

html.dark :is([class~="border-mint-100"], [class~="border-mint-200"], [class~="border-emerald-200"], [class~="border-green-200"]) { border-color: var(--color-mint-800) !important; }
html.dark :is([class~="border-rose-100"], [class~="border-rose-200"], [class~="border-red-200"]) { border-color: #663341 !important; }
html.dark :is([class~="border-amber-200"], [class~="border-amber-200/50"], [class~="border-amber-300/40"]) { border-color: #75602d !important; }
html.dark :is([class~="text-amber-800/80"], [class~="text-amber-600"]) { color: #fcd34d !important; }

html.dark :is([class~="hover:bg-slate-50"], [class~="hover:bg-slate-100"], [class~="hover:bg-gray-50"], [class~="hover:bg-gray-100"]):hover { background-color: #252525 !important; }
html.dark :is([class~="hover:bg-mint-50"], [class~="hover:bg-mint-100"], [class~="hover:bg-emerald-50"]):hover { background-color: color-mix(in srgb, var(--color-mint-800) 70%, #111) !important; }
html.dark :is([class~="hover:bg-rose-50"], [class~="hover:bg-red-50"]):hover { background-color: #3c2028 !important; }

html.dark :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea, [data-remote-input]) {
  background-color: #151515 !important;
  border-color: #3b3b3b !important;
  color: var(--app-text) !important;
  caret-color: var(--color-mint-300);
}
html.dark :is(input, textarea)::placeholder { color: #898989 !important; opacity: 1; }
html.dark :is(input, textarea)::selection { background: #14574c; color: #fff; }
html.dark :is(input, select, textarea):disabled { background-color: #202020 !important; color: #999 !important; }
html.dark :is(input[type="checkbox"], input[type="radio"]) { background-color: #151515; border-color: #666; accent-color: var(--color-mint-500); }
html.dark :is(input[type="checkbox"], input[type="radio"]):checked { background-color: var(--color-mint-500); border-color: var(--color-mint-500); }
html.dark input::-webkit-calendar-picker-indicator { filter: invert(1); }
html.dark input:-webkit-autofill,
html.dark input:-webkit-autofill:hover,
html.dark input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--app-text) !important;
  -webkit-box-shadow: 0 0 0 1000px #151515 inset !important;
  caret-color: var(--color-mint-300);
}

/* La búsqueda remota de Ubigeo tenía texto gris oscuro con !important y mayor especificidad. */
html.dark #configUbigeo_remote input[data-remote-input] { color: var(--app-text) !important; border-color: #3b3b3b !important; }
html.dark #configUbigeo_remote input[data-remote-input]:focus { border-color: var(--color-mint-500) !important; }
html.dark .jodit-container { background: var(--app-surface) !important; border-color: var(--app-border) !important; }
html.dark :is(.jodit-toolbar__box, .jodit-status-bar) { background: var(--app-surface-raised) !important; border-color: var(--app-border) !important; }
html.dark .jodit-wysiwyg { background: var(--app-surface) !important; color: var(--app-text) !important; }
html.dark .jodit-container :is(button, .jodit-toolbar-button__button, .jodit-status-bar) { color: var(--app-text) !important; }
html.dark .prose { color: #d1d1d1; --tw-prose-body: #d1d1d1; --tw-prose-headings: #f5f5f5; --tw-prose-bold: #f5f5f5; --tw-prose-links: var(--color-mint-300); }

html.dark :is(.badge-status-success, .badge-status.badge-success) { background-color: #123c2d !important; color: #a7f3d0 !important; }
html.dark :is(.badge-status-danger, .badge-status.badge-danger) { background-color: #49202c !important; color: #fda4af !important; }
html.dark :is(.badge-status-warning, .badge-status.badge-warning) { background-color: #443216 !important; color: #fcd34d !important; }
html.dark :is(.badge-status-info, .badge-status.badge-info) { background-color: #15334b !important; color: #7dd3fc !important; }
html.dark :is(.badge-status-neutral, .badge-status-secondary, .badge-status-slate, .badge-status.badge-neutral, .badge-status.badge-secondary, .badge-status.badge-slate) { background-color: #292929 !important; color: #d4d4d4 !important; }
html.dark :is(.badge-status-purple, .badge-status.badge-purple) { background-color: #302348 !important; color: #c4b5fd !important; }

html.dark .swal2-popup { background: #151515 !important; color: var(--app-text) !important; border: 1px solid var(--app-border); }
html.dark :is(.swal2-title, .swal2-html-container, .swal2-close) { color: var(--app-text) !important; }
html.dark :is(.swal2-input, .swal2-select, .swal2-textarea, .swal2-validation-message) { background: #202020 !important; border-color: #444 !important; color: var(--app-text) !important; }
html.dark .swal2-timer-progress-bar { background: var(--color-mint-500) !important; }

html.dark .dashboard-panel { background: var(--app-surface) !important; border-color: var(--app-border) !important; box-shadow: none !important; }
html.dark [class*="linear-gradient(180deg,#ffffff"] { background-image: none !important; background-color: var(--app-surface) !important; }
html.dark :is(#cuotasTable, #seguimientoTable) tbody tr[data-row-type="group"] { background: #202020 !important; color: var(--app-text) !important; border-color: var(--app-border) !important; }
html.dark :is(#cuotasTable, #seguimientoTable) tbody tr[data-row-type="subtotal"],
html.dark :is(#cuotasTable, #seguimientoTable) tfoot { background: #252525 !important; color: var(--app-text) !important; border-color: var(--app-border) !important; }
html.dark :is(#cuotasTable, #seguimientoTable) :is(tbody tr[data-row-type="group"], tbody tr[data-row-type="subtotal"], tfoot) td { color: var(--app-text) !important; }
html.dark :is(#cuotasTable, #seguimientoTable) tr[data-subrow="true"] > td { background: var(--app-surface) !important; }

html.dark .auth-visual { background-image: none !important; background-color: #000 !important; }
html.dark .auth-panel { background-color: #000 !important; border-left: 1px solid var(--app-border); }
html.dark * { scrollbar-color: #434343 transparent; }
html[data-theme="dark"] [data-remote-results] { background-color: #090909 !important; color: #e5e7eb !important; border-color: #292929 !important; }
