/* =====================================================================
   CONTROL DE GASTOS — Estilos del sistema (v9)
   Paleta, panel con pestañas, componentes y animaciones.
   ===================================================================== */
:root {
  --brand-dark: #0b1b33;
  --brand: #12315c;
  --brand-light: #2c5ea8;
  --accent: #f59e0b;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --line: #e6eaf1;
  --ink: #1b2536;
  --muted: #6b7587;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15,35,64,.05), 0 1px 3px rgba(15,35,64,.06);
  --shadow: 0 4px 14px rgba(15,35,64,.08);
  --shadow-lg: 0 14px 40px rgba(15,35,64,.18);
  --ease: cubic-bezier(.22,.8,.3,1);
  --sb-w: 252px;
  --sb-w-mini: 68px;
  --bs-primary: #1f4b8f;
  --bs-primary-rgb: 31,75,143;
  --bs-link-color: #1f4b8f;
  --bs-link-hover-color: #12315c;
  --bs-body-font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-color: var(--ink);
}

html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--bs-body-font-family); -webkit-font-smoothing: antialiased; }

/* ---------- Botones y formularios ---------- */
.btn-primary { --bs-btn-bg: #1f4b8f; --bs-btn-border-color: #1f4b8f; --bs-btn-hover-bg: #173d78; --bs-btn-hover-border-color: #173d78; --bs-btn-active-bg: #12315c; --bs-btn-active-border-color: #12315c; --bs-btn-disabled-bg: #1f4b8f; --bs-btn-disabled-border-color: #1f4b8f; }
.btn-outline-primary { --bs-btn-color: #1f4b8f; --bs-btn-border-color: #1f4b8f; --bs-btn-hover-bg: #1f4b8f; --bs-btn-hover-border-color: #1f4b8f; --bs-btn-active-bg: #12315c; --bs-btn-active-border-color:#12315c; }
.btn { font-weight: 500; border-radius: 10px; transition: transform .15s var(--ease), box-shadow .2s var(--ease), background-color .2s, border-color .2s, color .2s; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15,35,64,.14); }
.btn:not(:disabled):active { transform: translateY(0); box-shadow: none; }
.btn-sm { border-radius: 8px; }
.btn .ti, .btn .bi { font-size: 1.1em; }
.btn[data-enviando] { pointer-events: none; opacity: .75; }
.btn[data-enviando]::after { content: ""; width: .95em; height: .95em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: giro .7s linear infinite; }
.form-control, .form-select { border-radius: 10px; border-color: #d5dbe6; transition: border-color .2s, box-shadow .2s; }
.form-control:focus, .form-select:focus { border-color: #4a79bd; box-shadow: 0 0 0 .22rem rgba(44,94,168,.16); }
.form-label { font-weight: 500; font-size: .875rem; color: #394559; }

/* ---------- Tarjetas y tablas ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; border-radius: var(--radius) var(--radius) 0 0 !important; padding: .85rem 1.1rem; }
.kpi-card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi-card .kpi-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; flex-shrink: 0; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
.kpi-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table { --bs-table-bg: transparent; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.table > :not(caption) > * > * { padding: .7rem .85rem; }
.table-hover > tbody > tr { transition: background-color .15s; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f4f7fc; }
.table > tbody > tr > td { border-color: #eef1f6; }
.badge { font-weight: 600; letter-spacing: .01em; border-radius: 8px; }
.badge-tipo-diesel { background: #ffe8cc; color: #b45309; }
.badge-tipo-caseta { background: #dbeafe; color: #1d4ed8; }
.badge-tipo-imprevisto { background: #fee2e2; color: #b91c1c; }
.badge-tipo-otro { background: #e5e7eb; color: #374151; }
.alert { border: 0; border-radius: 12px; box-shadow: var(--shadow-sm); animation: entra-arriba .35s var(--ease); }
.modal-content { border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal.fade .modal-dialog { transform: translateY(16px) scale(.98); transition: transform .3s var(--ease), opacity .2s; }
.modal.show .modal-dialog { transform: none; }
.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: .4rem; animation: entra-arriba .18s var(--ease); }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; font-size: .92rem; }
.nav-tabs .nav-link { border-radius: 10px 10px 0 0; font-weight: 500; transition: color .2s, background-color .2s; }
.thumb-evidencia { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid #dee2e6; }
.utilidad-positiva { color: #157347; font-weight: 700; }
.utilidad-negativa { color: #b91c1c; font-weight: 700; }
h4.fw-bold, h3.fw-bold { letter-spacing: -.01em; }

/* ---------- Animaciones ---------- */
@keyframes giro { to { transform: rotate(360deg); } }
@keyframes entra-arriba { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes entra-pestana { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes sale-pestana { to { opacity: 0; transform: scale(.9); max-width: 0; padding-left: 0; padding-right: 0; margin: 0; } }
@keyframes barra { 0% { width: 0; opacity: 1; } 70% { width: 88%; } 100% { width: 94%; opacity: 1; } }
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }

/* Contenido de cada pantalla (dentro del marco): una sola entrada muy corta, solo opacidad (sin escalonar) */
body.embed { background: var(--bg); }
body.embed .page-content { animation: aparece .12s ease-out; }

/* ---------- PANEL (barra lateral + pestañas) ---------- */
body.shell { overflow: hidden; height: 100vh; height: 100dvh; display: flex; background: var(--bg); }
#barra-carga { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, #2c5ea8, #f59e0b); z-index: 3000; border-radius: 0 3px 3px 0; opacity: 0; transition: width .25s, opacity .3s; }
#barra-carga.activa { animation: barra 8s var(--ease) forwards; }
#barra-carga.fin { width: 100%; opacity: 0; transition: width .2s, opacity .5s .15s; animation: none; }

.sidebar { width: var(--sb-w); flex-shrink: 0; height: 100%; display: flex; flex-direction: column; background: linear-gradient(185deg, #0b1b33 0%, #0f2747 100%); color: #cdd8ea; transition: width .3s var(--ease), transform .3s var(--ease); z-index: 1040; overflow: hidden; }
.sb-marca { display: flex; align-items: center; gap: .75rem; padding: 1rem 1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.07); min-height: 68px; }
.sb-logo { width: 40px; height: 40px; border-radius: 11px; object-fit: contain; background: #fff; padding: 3px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.sb-logo-txt { background: linear-gradient(135deg, #2c5ea8, #f59e0b); color: #fff; font-weight: 700; font-size: .95rem; display: flex; align-items: center; justify-content: center; padding: 0; }
.sb-marca-txt { min-width: 0; line-height: 1.2; }
.sb-empresa { color: #fff; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sub { font-size: .72rem; color: #8ea1c0; }
.sb-nav { flex: 1; overflow-y: auto; padding: .6rem .6rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sb-grupo-titulo { display: flex; width: 100%; align-items: center; justify-content: space-between; background: none; border: 0; color: #7f93b4; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; padding: .8rem .7rem .35rem; cursor: pointer; }
.sb-grupo-titulo:hover { color: #b7c6df; }
.sb-grupo-titulo .ti { transition: transform .25s var(--ease); font-size: .9rem; }
.sb-grupo.cerrado .sb-grupo-titulo .ti { transform: rotate(-90deg); }
.sb-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .3s var(--ease); }
.sb-items > div { overflow: hidden; }
.sb-grupo.cerrado .sb-items { grid-template-rows: 0fr; }
.sb-item { position: relative; display: flex; align-items: center; gap: .75rem; padding: .56rem .75rem; margin: 1px 0; border-radius: 10px; color: #cdd8ea; text-decoration: none; font-size: .91rem; font-weight: 500; white-space: nowrap; transition: background-color .18s, color .18s, transform .18s var(--ease); }
.sb-item .ti { font-size: 1.28rem; flex-shrink: 0; color: #8fa6c9; transition: color .18s, transform .25s var(--ease); }
.sb-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-item:hover .ti { color: #fff; transform: scale(1.08); }
.sb-item.activo { background: linear-gradient(90deg, rgba(44,94,168,.55), rgba(44,94,168,.18)); color: #fff; }
.sb-item.activo .ti { color: #ffc861; }
.sb-item.activo::before { content: ""; position: absolute; left: -.6rem; top: 20%; bottom: 20%; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.sb-badge { margin-left: auto; background: #ef4444; color: #fff; font-size: .68rem; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; animation: latido 2s infinite; }
@keyframes latido { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.sb-pie { padding: .6rem; border-top: 1px solid rgba(255,255,255,.07); }
.sb-colapsar { display: flex; width: 100%; align-items: center; gap: .75rem; background: none; border: 0; color: #8ea1c0; padding: .5rem .75rem; border-radius: 10px; font-size: .85rem; transition: background-color .18s, color .18s; }
.sb-colapsar:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-colapsar .ti { font-size: 1.25rem; transition: transform .3s var(--ease); }

/* Menú contraído (solo íconos) en escritorio */
@media (min-width: 992px) {
  body.sb-mini .sidebar { width: var(--sb-w-mini); }
  body.sb-mini .sb-marca-txt, body.sb-mini .sb-item span, body.sb-mini .sb-grupo-titulo span, body.sb-mini .sb-colapsar span, body.sb-mini .sb-badge { display: none; }
  body.sb-mini .sb-grupo-titulo { justify-content: center; padding: .5rem 0 .1rem; }
  body.sb-mini .sb-grupo-titulo .ti { display: none; }
  body.sb-mini .sb-grupo-titulo::after { content: ""; width: 22px; height: 1px; background: rgba(255,255,255,.12); }
  body.sb-mini .sb-grupo.cerrado .sb-items { grid-template-rows: 1fr; }
  body.sb-mini .sb-item { justify-content: center; padding: .65rem; }
  body.sb-mini .sb-marca { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sb-mini .sb-colapsar { justify-content: center; }
  body.sb-mini .sb-colapsar .ti { transform: rotate(180deg); }
}
/* En celular/tablet el menú es un panel que se desliza */
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(84vw, 300px); transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  body.sb-abierto .sidebar { transform: none; }
  .sb-fondo { position: fixed; inset: 0; background: rgba(8,16,30,.5); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 1030; backdrop-filter: blur(2px); }
  body.sb-abierto .sb-fondo { opacity: 1; pointer-events: auto; }
  .sb-pie { display: none; }
}

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: flex-end; gap: .5rem; padding: .5rem .75rem 0 .75rem; background: #e9edf4; border-bottom: 1px solid var(--line); min-height: 52px; }
.tb-btn { background: none; border: 0; width: 38px; height: 38px; border-radius: 10px; color: #3b4a63; font-size: 1.35rem; display: inline-flex; align-items: center; justify-content: center; position: relative; transition: background-color .18s, transform .15s; margin-bottom: 4px; text-decoration: none; }
.tb-btn:hover { background: rgba(15,35,64,.08); color: var(--brand); }
.tb-btn:active { transform: scale(.94); }
.tb-punto { position: absolute; top: 3px; right: 2px; background: #ef4444; color: #fff; font-size: .62rem; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid #e9edf4; }
.tb-acciones { display: flex; align-items: center; gap: .15rem; margin-left: auto; padding-bottom: 0; }
.tb-usuario { display: flex; align-items: center; gap: .55rem; background: none; border: 0; padding: .25rem .4rem; border-radius: 12px; margin-bottom: 4px; transition: background-color .18s; }
.tb-usuario:hover { background: rgba(15,35,64,.08); }
.tb-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #2c5ea8, #12315c); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.tb-usuario-txt { text-align: left; line-height: 1.15; }
.tb-usuario-txt b { display: block; font-size: .85rem; color: var(--ink); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-usuario-txt small { color: var(--muted); font-size: .72rem; }

.tabs-wrap { flex: 1; min-width: 0; display: flex; align-items: flex-end; position: relative; }
.tabs { display: flex; align-items: flex-end; gap: 3px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-flecha { display: none; border: 0; background: #e9edf4; width: 26px; height: 36px; color: #3b4a63; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 8px; margin-bottom: 0; }
.tabs-wrap.desborda .tabs-flecha { display: inline-flex; }
.tab { position: relative; display: inline-flex; align-items: center; gap: .5rem; min-width: 110px; max-width: 210px; height: 38px; padding: 0 .4rem 0 .85rem; border-radius: 11px 11px 0 0; background: rgba(255,255,255,.45); color: #4a5870; font-size: .86rem; font-weight: 500; cursor: pointer; user-select: none; flex-shrink: 0; transition: background-color .18s, color .18s, transform .18s var(--ease); animation: entra-pestana .28s var(--ease); border: 0; }
.tab:hover { background: rgba(255,255,255,.8); color: var(--ink); }
.tab.dormida .ti-ico { opacity: .5; }
.tab.activa { background: var(--bg); color: var(--brand); font-weight: 600; box-shadow: 0 -2px 8px rgba(15,35,64,.06); }
.tab.activa::before, .tab.activa::after { content: ""; position: absolute; bottom: 0; width: 10px; height: 10px; background: radial-gradient(circle at var(--r), transparent 10px, var(--bg) 10.5px); }
.tab.activa::before { left: -10px; --r: 0 0; }
.tab.activa::after { right: -10px; --r: 100% 0; }
.tab .ti-ico { font-size: 1.05rem; flex-shrink: 0; opacity: .85; }
.tab .tab-titulo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.tab .tab-cerrar { width: 22px; height: 22px; border-radius: 7px; border: 0; background: none; color: inherit; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; opacity: .55; transition: background-color .15s, opacity .15s, color .15s; flex-shrink: 0; }
.tab .tab-cerrar:hover { background: rgba(185,28,28,.14); color: #b91c1c; opacity: 1; }
.tab.cargando .ti-ico { animation: giro 1s linear infinite; }
.tab.saliendo { animation: sale-pestana .2s var(--ease) forwards; overflow: hidden; }

.aviso-soporte { background: #fff4d6; color: #7a5200; padding: .45rem 1rem; font-size: .85rem; border-bottom: 1px solid #f3dc9c; }
.marcos { flex: 1; position: relative; min-height: 0; background: var(--bg); }
.marco { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .25s var(--ease), transform .25s var(--ease), visibility 0s .25s; }
.marco.activo { opacity: 1; visibility: visible; transform: none; transition: opacity .25s var(--ease), transform .25s var(--ease); z-index: 1; }
.vacio { position: absolute; inset: 0; top: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: .5rem; }
.vacio[hidden] { display: none; }
.vacio .ti { font-size: 3.5rem; opacity: .35; }

.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 4000; display: flex; flex-direction: column; gap: .5rem; }
.toast-cg { background: #12223d; color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .9rem; animation: entra-arriba .3s var(--ease); max-width: 340px; }

@media (max-width: 575.98px) {
  .tab { min-width: 90px; max-width: 150px; }
}

/* ---------- Login ---------- */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background: radial-gradient(1200px 600px at 10% -10%, #2c5ea8 0%, transparent 60%), radial-gradient(900px 500px at 100% 110%, #f59e0b33 0%, transparent 55%), linear-gradient(160deg, #0b1b33, #12315c); }
.login-card { border: 0; border-radius: 20px; max-width: 410px; width: 100%; box-shadow: 0 30px 70px rgba(0,0,0,.35); animation: entra-arriba .55s var(--ease); }
.login-logo { width: 62px; height: 62px; border-radius: 18px; background: linear-gradient(135deg, #2c5ea8, #12315c); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 30px; box-shadow: 0 8px 20px rgba(18,49,92,.35); margin-bottom: .75rem; }

/* ---------- Widget de evidencias / escáner ---------- */
.ev-widget { border: 1px dashed #c3ccd9; border-radius: 12px; padding: 14px; background: #fbfcfe; }
.ev-botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ev-lista { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.ev-thumb { position: relative; width: 84px; height: 108px; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; background: #fff; }
.ev-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ev-thumb-num { position: absolute; bottom: 2px; left: 4px; background: rgba(15,35,64,.8); color: #fff; font-size: 11px; padding: 0 6px; border-radius: 6px; }
.ev-thumb-del { position: absolute; top: 2px; right: 2px; border: none; background: rgba(185,28,28,.9); color: #fff; width: 20px; height: 20px; border-radius: 50%; line-height: 1; cursor: pointer; }
.ev-aviso { margin-top: 10px; font-size: .85rem; }
.ev-modal { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.ev-modal-caja { background: #111; border-radius: 14px; overflow: hidden; width: min(96vw, 620px); }
.ev-modal-top { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 10px 14px; background: #1b2b45; }
.ev-video-wrap { position: relative; background: #000; }
.ev-video { width: 100%; display: block; max-height: 65vh; object-fit: contain; }
.ev-guia { position: absolute; inset: 8% 6%; border: 2px dashed rgba(255,255,255,.75); border-radius: 10px; pointer-events: none; }
.ev-estado { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: .9rem; text-shadow: 0 1px 3px #000; }
.ev-modal-bottom { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; background: #1b2b45; flex-wrap: wrap; }
.ev-auto-lbl { color: #fff; font-size: .85rem; display: flex; align-items: center; gap: 6px; margin: 0; }
.ev-flash .ev-video-wrap { outline: 6px solid #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  .kpi-value { font-size: 1.3rem; }
  .kpi-icon { width: 40px; height: 40px; font-size: 18px; }
  .page-content { padding-left: .75rem !important; padding-right: .75rem !important; }
  .card-body { padding: 1rem; }
  h4.fw-bold { font-size: 1.15rem; }
}
@media (min-width: 576px) and (max-width: 991.98px) { .kpi-card .kpi-value { font-size: 1.4rem; } }
@media (max-width: 575.98px) {
  .d-flex.flex-wrap.justify-content-between > .btn,
  .d-flex.flex-wrap.justify-content-between > .btn-group { width: 100%; }
  .btn-group.d-flex { flex-wrap: wrap; }
  .modal-dialog { margin: .75rem; }
}
.modal-dialog { margin-left: auto; margin-right: auto; }
.d-flex.gap-2 { flex-wrap: wrap; }
.kpi-card.p-3.d-flex.flex-row { align-items: center; }
@media (max-width: 767.98px) {
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .nav-tabs .nav-link { white-space: nowrap; }
}

/* Quien prefiere menos movimiento (accesibilidad) no ve animaciones */
/* (ronda 26) El movimiento reducido ya no lo decide cada dispositivo por su cuenta: tema.js pone la clase .mov-reducido en <html> según la
   preferencia elegida en la barra superior (Automático = la del sistema, Siempre, Reducido). Así celular y escritorio se comportan igual. */
html.mov-reducido *, html.mov-reducido *::before, html.mov-reducido *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
@media print { .sidebar, .topbar { display: none !important; } body.shell { display: block; overflow: visible; } }

/* =====================================================================
   MODO OSCURO  (html[data-bs-theme="dark"]) — se activa con el botón de la barra superior
   ===================================================================== */
[data-bs-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1420;
  --surface: #141d2d;
  --line: #25314a;
  --ink: #e4eaf5;
  --muted: #94a2bb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 6px 18px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 44px rgba(0,0,0,.6);
  --bs-body-bg: #0d1420;
  --bs-body-color: #e4eaf5;
  --bs-border-color: #25314a;
  --bs-primary: #5b8fd9;
  --bs-primary-rgb: 91,143,217;
  --bs-link-color: #7fa9e6;
  --bs-link-hover-color: #a9c6f0;
  --bs-tertiary-bg: #101828;
  --bs-secondary-bg: #1a2539;
  --bs-secondary-color: #94a2bb;
  --bs-emphasis-color: #fff;
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #3b72c4; --bs-btn-border-color: #3b72c4; --bs-btn-hover-bg: #4a82d6; --bs-btn-hover-border-color: #4a82d6; --bs-btn-active-bg: #2f62ae; --bs-btn-active-border-color: #2f62ae; --bs-btn-disabled-bg: #3b72c4; --bs-btn-disabled-border-color: #3b72c4; }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #7fa9e6; --bs-btn-border-color: #3b72c4; --bs-btn-hover-bg: #3b72c4; --bs-btn-hover-border-color: #3b72c4; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #2f62ae; }
[data-bs-theme="dark"] .btn:not(:disabled):hover { box-shadow: 0 4px 12px rgba(0,0,0,.45); }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text { background-color: #0f1828; border-color: #2c3a58; color: var(--ink); }
[data-bs-theme="dark"] .form-control::placeholder { color: #66758f; }
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus { border-color: #5b8fd9; box-shadow: 0 0 0 .22rem rgba(91,143,217,.22); background-color: #0f1828; }
[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly] { background-color: #172135; }
[data-bs-theme="dark"] .form-label { color: #b8c3d8; }
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .list-group-item { background-color: var(--surface); color: var(--ink); }
[data-bs-theme="dark"] .dropdown-item { color: var(--ink); }
[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus { background-color: #1e2a42; color: #fff; }
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer { border-color: var(--line); }
[data-bs-theme="dark"] .table thead th { background: #111a2a; }
[data-bs-theme="dark"] .table > tbody > tr > td { border-color: #1f2b42; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { --bs-table-bg-state: #1a2539; }
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > * { --bs-table-bg: #172135; --bs-table-color: var(--ink); --bs-table-border-color: var(--line); background-color: #172135; color: var(--ink); }
[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-white { background-color: #172135 !important; color: var(--ink); }
[data-bs-theme="dark"] .text-dark { color: var(--ink) !important; }
[data-bs-theme="dark"] .badge.text-dark { color: #1b2536 !important; }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: #1e2a42; --bs-btn-border-color: #2c3a58; --bs-btn-color: var(--ink); --bs-btn-hover-bg: #26344f; --bs-btn-hover-border-color: #36466a; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #b8c3d8; --bs-btn-border-color: #3a4a6b; --bs-btn-hover-bg: #26344f; --bs-btn-hover-border-color: #4a5c82; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #2c3b59; }
[data-bs-theme="dark"] .alert-light { background: #172135; color: var(--ink); }
[data-bs-theme="dark"] .alert-light.border { border-color: var(--line) !important; }
[data-bs-theme="dark"] .nav-tabs { border-color: var(--line); }
[data-bs-theme="dark"] .nav-tabs .nav-link { color: #a9b6cd; }
[data-bs-theme="dark"] .nav-tabs .nav-link:hover { border-color: var(--line); color: #fff; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { background: var(--surface); border-color: var(--line) var(--line) var(--surface); color: #fff; }
[data-bs-theme="dark"] .page-link { background: var(--surface); border-color: var(--line); color: #9db9e6; }
[data-bs-theme="dark"] .page-item.active .page-link { background: #3b72c4; border-color: #3b72c4; color: #fff; }
[data-bs-theme="dark"] .page-item.disabled .page-link { background: #101828; color: #5d6b84; }
[data-bs-theme="dark"] .progress { background: #1e2a42; }
[data-bs-theme="dark"] .badge-tipo-diesel { background: rgba(245,158,11,.18); color: #fbbf5d; }
[data-bs-theme="dark"] .badge-tipo-caseta { background: rgba(59,130,246,.2); color: #8db8ff; }
[data-bs-theme="dark"] .badge-tipo-imprevisto { background: rgba(239,68,68,.2); color: #ff9a9a; }
[data-bs-theme="dark"] .badge-tipo-otro { background: rgba(148,163,184,.2); color: #cbd5e1; }
[data-bs-theme="dark"] .thumb-evidencia { border-color: var(--line); }
[data-bs-theme="dark"] .utilidad-positiva { color: #4ade80; }
[data-bs-theme="dark"] .utilidad-negativa { color: #ff8585; }
[data-bs-theme="dark"] .text-success { color: #4ade80 !important; }
[data-bs-theme="dark"] .text-danger { color: #ff8585 !important; }
[data-bs-theme="dark"] .text-warning { color: #fbbf24 !important; }
[data-bs-theme="dark"] .text-primary { color: #7fa9e6 !important; }
[data-bs-theme="dark"] .ev-widget { background: #101828; border-color: #34446a; }
[data-bs-theme="dark"] .ev-thumb { background: #172135; border-color: var(--line); }

/* Panel */
[data-bs-theme="dark"] .sidebar { background: linear-gradient(185deg, #070e1a 0%, #0b1628 100%); border-right: 1px solid #16213a; }
[data-bs-theme="dark"] .topbar { background: #0a111d; border-bottom-color: var(--line); }
[data-bs-theme="dark"] .tb-btn { color: #aab8d0; }
[data-bs-theme="dark"] .tb-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
[data-bs-theme="dark"] .tb-punto { border-color: #0a111d; }
[data-bs-theme="dark"] .tb-usuario:hover { background: rgba(255,255,255,.08); }
[data-bs-theme="dark"] .tabs-flecha { background: #0a111d; color: #aab8d0; }
[data-bs-theme="dark"] .tab { background: rgba(255,255,255,.05); color: #98a7c0; }
[data-bs-theme="dark"] .tab:hover { background: rgba(255,255,255,.1); color: #fff; }
[data-bs-theme="dark"] .tab.activa { background: var(--bg); color: #fff; box-shadow: none; }
[data-bs-theme="dark"] .tab .tab-cerrar:hover { background: rgba(239,68,68,.25); color: #ff9a9a; }
[data-bs-theme="dark"] .aviso-soporte { background: #3a2c08; color: #fcd57a; border-bottom-color: #55400d; }
[data-bs-theme="dark"] .toast-cg { background: #223253; }
[data-bs-theme="dark"] .login-wrapper { background: radial-gradient(1200px 600px at 10% -10%, #1d3f78 0%, transparent 60%), radial-gradient(900px 500px at 100% 110%, #f59e0b22 0%, transparent 55%), linear-gradient(160deg, #060c17, #0d1b33); }
[data-bs-theme="dark"] .sb-logo { background: #e8eefb; }

/* Botón de tema flotante (login y recuperación) */
.btn-tema-flotante { position: fixed; top: .85rem; right: .85rem; z-index: 50; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 1.3rem; display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); transition: background-color .2s, transform .2s var(--ease); }
.btn-tema-flotante:hover { background: rgba(255,255,255,.3); transform: rotate(18deg); }
.tb-btn#btn-tema i { transition: transform .4s var(--ease); }
.tb-btn#btn-tema:hover i { transform: rotate(25deg); }
/* Cambio de tema instantáneo: se suspenden las transiciones y animaciones un instante para que todo cambie junto y sin tirones */
html.tema-anima, html.tema-anima *, html.tema-anima *::before, html.tema-anima *::after { transition: none !important; animation: none !important; }

/* Tarjetas de indicadores en celular: ícono arriba y cifra completa (antes se cortaba) */
@media (max-width: 575.98px) {
  .kpi-card.d-flex { flex-direction: column !important; align-items: flex-start !important; gap: .55rem !important; padding: .85rem !important; }
  .kpi-card .kpi-icon { width: 38px; height: 38px; font-size: 18px; margin: 0 !important; }
  .kpi-card > div:not(.kpi-icon) { min-width: 0; max-width: 100%; }
  .kpi-card .kpi-value { font-size: clamp(1.1rem, 6vw, 1.45rem); white-space: nowrap; }
}
[data-bs-theme="dark"] .btn-outline-danger { --bs-btn-color: #ff8f8f; --bs-btn-border-color: #a94545; --bs-btn-hover-bg: #c0392b; --bs-btn-hover-border-color: #c0392b; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-outline-success { --bs-btn-color: #5fe09a; --bs-btn-border-color: #2f8f5b; --bs-btn-hover-bg: #1f9d5a; --bs-btn-hover-border-color: #1f9d5a; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-outline-warning { --bs-btn-color: #fbbf24; }
[data-bs-theme="dark"] .btn-outline-info { --bs-btn-color: #67d4ee; }

/* Listas vacías: mensaje claro con acción */
.vacio-bloque { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 1.6rem 1rem; color: var(--muted); }
.vacio-bloque > .ti { font-size: 2.4rem; opacity: .45; margin-bottom: .4rem; }
.vacio-bloque .fw-semibold { color: var(--ink); }
.table .fila-vacia > td { border-bottom: 0; }
/* Tablas: tipografía uniforme y datos clave sin partirse */
.table { font-size: .9rem; }
.table td.text-nowrap, .table th.text-nowrap { white-space: nowrap; }
.table .folio { font-weight: 700; white-space: nowrap; }
.cifra-neg { color: #b91c1c; }
[data-bs-theme="dark"] .cifra-neg { color: #ff8585; }

/* Primeros pasos (dashboard) */
.pasos-lista li + li { border-top: 1px solid var(--line); }
.paso { display: flex; align-items: center; gap: .8rem; padding: .65rem .25rem; text-decoration: none; color: var(--ink); border-radius: 10px; transition: background-color .15s, padding .2s var(--ease); }
.paso:hover { background: rgba(44,94,168,.07); padding-left: .6rem; }
.paso-ico { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(44,94,168,.12); color: #2c5ea8; font-size: 1.05rem; flex-shrink: 0; }
.hecho .paso-ico { background: #198754; color: #fff; }
.hecho .paso-txt { text-decoration: line-through; color: var(--muted); }
[data-bs-theme="dark"] .paso-ico { background: rgba(91,143,217,.18); color: #8db8ff; }
[data-bs-theme="dark"] .hecho .paso-ico { background: #1f9d5a; color: #fff; }

/* =====================================================================
   v10 — Cuentas por cobrar, flota y análisis
   ===================================================================== */
.aging-bar { display:flex; height:14px; border-radius:99px; overflow:hidden; background:var(--bs-tertiary-bg, #eef1f6); }
.aging-bar > div { min-width:3px; transition:width .4s var(--ease); }
.aging-chip { display:block; text-align:left; padding:.6rem .8rem; border:1px solid var(--bs-border-color, var(--line)); border-left-width:4px; border-radius:10px; background:var(--bs-body-bg); color:inherit; text-decoration:none; transition:transform .15s var(--ease), box-shadow .15s var(--ease); }
.aging-chip:hover { transform:translateY(-2px); box-shadow:var(--shadow); color:inherit; }
@media (max-width:575.98px) { .aging-chip .fs-5 { font-size:1.05rem !important; } }

/* Pantallas táctiles: el botón de cerrar pestaña necesita un área de toque cómoda */
@media (pointer: coarse), (max-width: 576px) {
  .tab .tab-cerrar { width: 32px; height: 32px; font-size: 1.05rem; }
}

/* ---- Dashboard de almacén: bloque de atención y KPIs agrupados ---- */
.dash-atencion { border-left: 5px solid var(--bs-success); box-shadow: var(--shadow-sm); overflow: hidden; }
.dash-atencion.dash-critico { border-left-color: var(--bs-danger); }
.dash-atencion.dash-aviso { border-left-color: var(--bs-warning); }
.dash-atencion-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem .9rem; }
.dash-resumen { display: flex; gap: 1.5rem; align-items: stretch; flex-wrap: wrap; }
.dash-cifra { display: flex; flex-direction: column; text-decoration: none; color: inherit; line-height: 1.1; }
.dash-cifra:hover .dash-lbl { text-decoration: underline; }
.dash-num { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dash-lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.dash-chips { display: flex; gap: .5rem; flex-wrap: wrap; padding: 0 1.25rem .9rem; }
.dash-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; text-decoration: none; color: inherit; background: transparent; min-height: 32px; }
.dash-chip:hover { border-color: var(--bs-primary); }
.dash-chip.activo { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
.dash-pill { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; font-size: .75rem; text-align: center; line-height: 1.35rem; color: #fff; }
.dash-pill-ag { background: #b02a37; }
.dash-pill-bj { background: #8a5a00; }
.dash-tabla thead th { font-size: .78rem; color: var(--muted); font-weight: 600; background: transparent; white-space: nowrap; }
.dash-tabla tr.fila-agotado td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.dash-barra { height: 8px; border-radius: 4px; background: rgba(128,128,128,.22); overflow: hidden; }
.dash-barra i { display: block; height: 100%; border-radius: 4px; min-width: 0; }
.dash-barra i.ag { background: var(--bs-danger); }
.dash-barra i.bj { background: #d98e00; }
.dash-atencion-pie { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding: .6rem 1.25rem; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.dash-kpi-titulo { padding: .75rem 1.1rem .25rem; font-weight: 600; font-size: .9rem; }
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.dash-kpi { padding: .75rem 1.1rem 1rem; text-decoration: none; color: inherit; border-left: 1px solid var(--line); }
.dash-kpi:first-child { border-left: 0; }
a.dash-kpi:hover { background: rgba(128,128,128,.07); }
.dash-kpi-valor { white-space: nowrap; font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.dash-kpi-etq { font-size: .78rem; color: var(--muted); font-weight: 500; }
@media (max-width: 575.98px) {
  .dash-atencion-head { padding: 1rem; } .dash-chips { padding: 0 1rem .8rem; }
  .dash-kpi { border-left: 0; border-top: 1px solid var(--line); } .dash-kpi:first-child { border-top: 0; }
}

.dash-filtros > summary { padding: .6rem 1rem; cursor: pointer; font-weight: 600; font-size: .9rem; list-style: none; }
.dash-filtros > summary::-webkit-details-marker { display: none; }
@media (min-width: 768px) { .dash-filtros > summary { display: none; } }
.dash-tabla td:first-child { min-width: 150px; }

/* Navegación dentro de la pestaña: atenuado inmediato mientras carga la siguiente pantalla (se siente más rápido) */
html.nav-pend body.embed .page-content { opacity: .55; transition: opacity .15s ease-out; }
html.nav-pend body.embed::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, #2c5ea8, #f59e0b); z-index: 3000; animation: barra 2.2s ease-out forwards; }

/* Enlaces legales al pie del menú lateral */
.sb-legal { padding: .35rem .9rem .6rem; font-size: .75rem; opacity: .85; }
.sb-legal a { color: inherit; text-decoration: underline; }
.sb-legal a:hover, .sb-legal a:focus-visible { opacity: 1; }
body.sb-mini .sb-legal { display: none; }

/* ---- Centro de avisos (campana) ---- */
.tb-punto-ambar { background: #f59e0b; color: #1f2937; }
.avisos-panel { width: 380px; max-width: calc(100vw - 24px); padding: 0; border-radius: 14px; overflow: hidden; }
.avisos-cab { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--bs-border-color, #e5e7eb); font-size: .95rem; }
.avisos-act { background: none; border: 0; width: 30px; height: 30px; border-radius: 8px; color: inherit; opacity: .7; display: inline-flex; align-items: center; justify-content: center; }
.avisos-act:hover { background: rgba(15,35,64,.08); opacity: 1; }
.avisos-act.girando i { animation: avisos-gira .8s linear infinite; }
@keyframes avisos-gira { to { transform: rotate(360deg); } }
.avisos-lista { max-height: min(70vh, 460px); overflow-y: auto; }
.aviso { display: flex; align-items: center; gap: 12px; padding: 11px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,.08)); border-left: 4px solid transparent; }
.aviso:last-child { border-bottom: 0; }
.aviso:hover, .aviso:focus-visible { background: rgba(15,35,64,.05); color: inherit; }
.aviso-rojo { border-left-color: #dc2626; } .aviso-ambar { border-left-color: #f59e0b; } .aviso-azul { border-left-color: #2563eb; }
.aviso-ico { flex: 0 0 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.aviso-rojo .aviso-ico { background: #fee2e2; color: #b91c1c; } .aviso-ambar .aviso-ico { background: #fef3c7; color: #92400e; } .aviso-azul .aviso-ico { background: #dbeafe; color: #1d4ed8; }
.aviso-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.aviso-txt b { font-size: .88rem; font-weight: 600; }
.aviso-txt small { font-size: .78rem; opacity: .75; white-space: normal; }
.aviso-n { flex: 0 0 auto; min-width: 26px; text-align: center; font-weight: 700; font-size: .8rem; padding: 2px 8px; border-radius: 12px; background: rgba(15,35,64,.08); }
.avisos-vacio { margin: 0; padding: 26px 16px; text-align: center; font-size: .88rem; opacity: .75; }
.avisos-vacio i { display: block; font-size: 1.8rem; color: #16a34a; margin-bottom: 6px; }
[data-bs-theme="dark"] .aviso:hover, [data-bs-theme="dark"] .aviso:focus-visible { background: rgba(255,255,255,.06); }
[data-bs-theme="dark"] .aviso-rojo .aviso-ico { background: rgba(220,38,38,.2); color: #fca5a5; } [data-bs-theme="dark"] .aviso-ambar .aviso-ico { background: rgba(245,158,11,.2); color: #fcd34d; } [data-bs-theme="dark"] .aviso-azul .aviso-ico { background: rgba(37,99,235,.25); color: #93c5fd; }
[data-bs-theme="dark"] .aviso-n { background: rgba(255,255,255,.1); } [data-bs-theme="dark"] .avisos-act:hover { background: rgba(255,255,255,.1); }
html.mov-reducido .avisos-act.girando i { animation: none; }
@media (max-width: 575.98px) {
  .avisos-panel { position: fixed !important; top: 56px !important; left: 12px !important; right: 12px !important; width: auto; max-width: none; transform: none !important; inset: 56px 12px auto 12px !important; }
}
.avisos-cab > span { display: inline-flex; gap: 2px; }
.avisos-act.activo { background: rgba(15,35,64,.12); opacity: 1; }
.avisos-ayuda { margin: 0; padding: 10px 16px; font-size: .78rem; opacity: .75; border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,.08)); }
.aviso-op { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,.08)); cursor: pointer; margin: 0; }
.aviso-op:last-child { border-bottom: 0; }
.aviso-op:hover { background: rgba(15,35,64,.04); }
[data-bs-theme="dark"] .aviso-op:hover, [data-bs-theme="dark"] .avisos-act.activo { background: rgba(255,255,255,.08); }
#avisos-opciones[hidden], #avisos-lista[hidden] { display: none; }
