/* ---------- Botón de tema ---------- */
#btnTema {
    position: fixed; right: 14px; bottom: 14px; z-index: 45;
    width: 44px; height: 44px; border-radius: 9999px; cursor: pointer;
    background: #312e81; color: #fff; border: 2px solid #6366f1;
    box-shadow: 0 2px 10px rgba(0,0,0,.3); font-size: 18px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
#btnTema:hover { background: #4338ca; }
@media print { #btnTema { display: none !important; } }

/* ---------- Modo oscuro ---------- */
html.oscuro { color-scheme: dark; }
html.oscuro body { background: #0f172a; color: #e2e8f0; }
html.oscuro .bg-white { background-color: #1e293b; }
html.oscuro .bg-slate-50 { background-color: #0f172a; }
html.oscuro .bg-slate-50\/50 { background-color: rgba(15,23,42,.55); }
html.oscuro .bg-slate-50\/80 { background-color: rgba(15,23,42,.8); }
html.oscuro .bg-slate-100 { background-color: #334155; }
html.oscuro .bg-slate-200 { background-color: #475569; }
html.oscuro .bg-slate-800 { background-color: #334155; }
html.oscuro .bg-slate-900 { background-color: #475569; }
html.oscuro .text-slate-800, html.oscuro .text-slate-700 { color: #e2e8f0; }
html.oscuro .text-slate-600 { color: #cbd5e1; }
html.oscuro .text-slate-500, html.oscuro .text-slate-400 { color: #94a3b8; }
html.oscuro .border-slate-100, html.oscuro .border-slate-200, html.oscuro .border-slate-300 { border-color: #334155; }
html.oscuro .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: #334155; }
html.oscuro .bg-rose-50, html.oscuro .bg-rose-100, html.oscuro .bg-rose-50\/40 { background-color: rgba(244,63,94,.16); }
html.oscuro .bg-indigo-50, html.oscuro .bg-indigo-100 { background-color: rgba(99,102,241,.2); }
html.oscuro .bg-emerald-50, html.oscuro .bg-emerald-100 { background-color: rgba(16,185,129,.16); }
html.oscuro .bg-amber-50, html.oscuro .bg-amber-100 { background-color: rgba(245,158,11,.16); }
html.oscuro .text-rose-500, html.oscuro .text-rose-600, html.oscuro .text-rose-700, html.oscuro .text-rose-800 { color: #fda4af; }
html.oscuro .text-indigo-600, html.oscuro .text-indigo-700, html.oscuro .text-indigo-800, html.oscuro .text-indigo-900 { color: #a5b4fc; }
html.oscuro .text-emerald-600, html.oscuro .text-emerald-700 { color: #6ee7b7; }
html.oscuro .text-amber-600, html.oscuro .text-amber-700, html.oscuro .text-amber-900 { color: #fcd34d; }
html.oscuro .border-rose-100, html.oscuro .border-rose-200 { border-color: rgba(244,63,94,.35); }
html.oscuro .border-indigo-100, html.oscuro .border-indigo-300 { border-color: rgba(99,102,241,.4); }
html.oscuro .border-emerald-100 { border-color: rgba(16,185,129,.35); }
html.oscuro .border-amber-100, html.oscuro .border-amber-300 { border-color: rgba(245,158,11,.4); }
/* los botones claros de la cabecera y de los avisos conservan su contraste */
html.oscuro header .bg-white { background-color: #e0e7ff; }
html.oscuro header .bg-white.text-indigo-700, html.oscuro header .bg-white .text-indigo-700 { color: #312e81; }
html.oscuro .hover\:bg-slate-50\/80:hover { background-color: rgba(51,65,85,.55); }
html.oscuro .hover\:bg-slate-100:hover, html.oscuro .hover\:bg-slate-200:hover { background-color: #475569; }
html.oscuro .hover\:bg-slate-900:hover { background-color: #64748b; }
html.oscuro .hover\:bg-rose-100:hover { background-color: rgba(244,63,94,.28); }
html.oscuro .hover\:bg-indigo-100:hover, html.oscuro .hover\:bg-indigo-50:hover { background-color: rgba(99,102,241,.3); }
html.oscuro .hover\:bg-emerald-100:hover { background-color: rgba(16,185,129,.28); }
html.oscuro .hover\:bg-amber-100:hover { background-color: rgba(245,158,11,.28); }
html.oscuro input, html.oscuro select, html.oscuro textarea { color: #e2e8f0; border-color: #475569; }
html.oscuro input::placeholder, html.oscuro textarea::placeholder { color: #64748b; }
html.oscuro .focus\:bg-white:focus { background-color: #1e293b; }
html.oscuro table { color: #e2e8f0; }
/* La hoja del reporte imprimible siempre es blanca, como saldrá en papel */
html.oscuro #vistaReporte { background: #475569; }

/* ---------- Celular ---------- */
@media (max-width: 640px) {
    header.sticky { position: static; }
    main { padding-top: 1rem !important; padding-bottom: 4.5rem !important; }
    input, select, textarea { font-size: 16px !important; }
    button, .cursor-pointer { min-height: 38px; }
    .justify-end { flex-wrap: wrap; }
    table th, table td { padding-left: .5rem !important; padding-right: .5rem !important; }
    .overflow-x-auto > table { min-width: 620px; }
    .fixed.inset-0 > div { max-height: 92vh; overflow-y: auto; }
    #btnTema { right: 10px; bottom: 10px; }
}

/* ---------- Presentación (solo estética, no toca funciones) ---------- */
html:not(.oscuro) body.bg-slate-50 {
    background: radial-gradient(1000px 500px at 80% -10%, #dbe2ff 0%, rgba(219,226,255,0) 60%), linear-gradient(165deg, #eef2ff 0%, #f8fafc 45%, #fff7ed 100%) fixed;
}
html body header.bg-indigo-700 {
    background: linear-gradient(100deg, #1e3a8a 0%, #4338ca 60%, #6366f1 100%);
    border-bottom: 3px solid #f97316;
    box-shadow: 0 4px 16px rgba(30, 58, 138, .3);
}
html body header.bg-indigo-700 h1 { letter-spacing: .04em; text-shadow: 0 1px 4px rgba(0,0,0,.25); }
html:not(.oscuro) main .bg-white.rounded-2xl, html:not(.oscuro) main .bg-white.rounded-xl {
    border-color: #e0e7ff;
    box-shadow: 0 6px 18px rgba(67, 56, 202, .08), 0 1px 3px rgba(15, 23, 42, .06);
}
html:not(.oscuro) main .bg-white.rounded-2xl { border-radius: 18px; }
html:not(.oscuro) tbody tr:hover { background-color: rgba(238, 242, 255, .65); }
html:not(.oscuro) thead { background-color: #eef2ff; }
html:not(.oscuro) thead th { color: #3730a3; letter-spacing: .04em; }
button { transition: background-color .15s, box-shadow .15s, transform .1s; }
button:not(:disabled):active { transform: translateY(1px); }
button.rounded-lg:not(:disabled):hover, button.rounded-xl:not(:disabled):hover, a.rounded-lg:hover { box-shadow: 0 4px 12px rgba(67, 56, 202, .2); }
input:focus, select:focus, textarea:focus {
    outline: none !important; border-color: #6366f1 !important; box-shadow: 0 0 0 3px rgba(99, 102, 241, .22) !important;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #a5b4fc; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
@media print { html body header.bg-indigo-700 { box-shadow: none; } }
