/* ============================================================
   CPT — Crédito Para Todos
   Sistema de diseño · dos interfaces: .desktop y .mobile
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Marca */
  --azul-900: #0a2540;
  --azul-800: #10386b;
  --azul-700: #164e9e;
  --azul-600: #1d63c9;
  --azul-500: #2f7ceb;
  --azul-100: #e8f0fe;
  --azul-50:  #f4f8ff;

  /* Semánticos */
  --verde: #077d55;
  --verde-100: #e3f6ec;
  --rojo: #c8302f;
  --rojo-100: #fdecec;
  --ambar: #b4690e;
  --ambar-100: #fdf3e3;

  /* Neutros */
  --tinta: #101828;
  --tinta-2: #475467;
  --tinta-3: #8a94a6;
  --linea: #e6eaf0;
  --linea-2: #f1f3f7;
  --fondo: #f7f8fb;
  --papel: #ffffff;

  /* Formas */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* Sombras (suaves, en capas) */
  --s-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --s-2: 0 2px 4px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
  --s-3: 0 4px 8px rgba(16, 24, 40, .05), 0 12px 28px rgba(16, 24, 40, .1);
  --s-4: 0 8px 16px rgba(10, 37, 64, .1), 0 24px 56px rgba(10, 37, 64, .18);
  --anillo: 0 0 0 3.5px rgba(47, 124, 235, .16);

  /* Movimiento */
  --rapido: 140ms cubic-bezier(.4, 0, .2, 1);
  --medio: 240ms cubic-bezier(.4, 0, .2, 1);
  --suave: 420ms cubic-bezier(.22, 1, .36, 1);
  --resorte: 480ms cubic-bezier(.34, 1.4, .48, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--fondo);
  color: var(--tinta);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; }
a { color: var(--azul-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
::selection { background: var(--azul-100); }

/* Iconos */
.ico { flex: none; vertical-align: -.18em; }
svg.ico [stroke-width] { stroke: currentColor; }

/* Scrollbar discreta */
* { scrollbar-width: thin; scrollbar-color: #cfd6e2 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #cfd6e2; border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #b3bccd; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Animaciones base ---------- */
@keyframes surgir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes entrarModal { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes subirHoja { from { transform: translateY(100%); } to { transform: none; } }
@keyframes entrarToast { from { opacity: 0; transform: translateX(20px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes brillo { 100% { transform: translateX(100%); } }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes latir { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .75; } }
@keyframes crecerBarra { from { width: 0 !important; } }

/* Entrada escalonada de las tarjetas de una vista */
.anim > * { animation: surgir var(--suave) both; }
.anim > *:nth-child(1) { animation-delay: 0ms; }
.anim > *:nth-child(2) { animation-delay: 45ms; }
.anim > *:nth-child(3) { animation-delay: 90ms; }
.anim > *:nth-child(4) { animation-delay: 135ms; }
.anim > *:nth-child(5) { animation-delay: 180ms; }
.anim > *:nth-child(6) { animation-delay: 215ms; }
.anim > *:nth-child(n+7) { animation-delay: 250ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--azul-700); color: #fff;
  border-radius: var(--r-sm); padding: 9px 15px;
  font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  box-shadow: var(--s-1);
  transition: background var(--rapido), box-shadow var(--medio), transform var(--rapido);
  position: relative; overflow: hidden; white-space: nowrap;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .28), transparent 60%);
  opacity: 0; transition: opacity var(--medio);
}
.btn:hover { background: var(--azul-800); box-shadow: var(--s-2); transform: translateY(-1px); }
.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(0) scale(.985); box-shadow: var(--s-1); transition-duration: 60ms; }
.btn:focus-visible { outline: none; box-shadow: var(--anillo); }
.btn .ico { transition: transform var(--medio); }
.btn:hover .ico { transform: scale(1.08); }

.btn.sec { background: var(--azul-100); color: var(--azul-700); box-shadow: none; }
.btn.sec:hover { background: #dbe7fd; box-shadow: var(--s-1); }
.btn.verde { background: var(--verde); }
.btn.verde:hover { background: #066544; }
.btn.rojo { background: var(--rojo); }
.btn.rojo:hover { background: #a82625; }
.btn.ghost { background: transparent; color: var(--tinta-2); box-shadow: none; }
.btn.ghost:hover { background: var(--linea-2); color: var(--tinta); box-shadow: none; transform: none; }
.btn.mini { padding: 6px 11px; font-size: 13px; border-radius: 7px; gap: 5px; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 22px; font-size: 15px; border-radius: var(--r-md); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn.cargando { color: transparent !important; pointer-events: none; }
.btn.cargando::before {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: girar .6s linear infinite;
}
.btn.sec.cargando::before { border-color: rgba(22, 78, 158, .3); border-top-color: var(--azul-700); }

/* ---------- Formularios ---------- */
.field { margin-bottom: 13px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--tinta-2); margin-bottom: 5px; letter-spacing: -.005em;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--linea); border-radius: var(--r-sm);
  background: var(--papel); color: var(--tinta); outline: none;
  transition: border-color var(--rapido), box-shadow var(--medio), background var(--rapido);
}
.field input::placeholder, .field textarea::placeholder { color: var(--tinta-3); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #cfd8e6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--azul-500); box-shadow: var(--anillo); background: var(--azul-50);
}
.field select { appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 15px;
}
.field select:disabled { background-color: var(--linea-2); color: var(--tinta-2); cursor: not-allowed; }
.field textarea { resize: vertical; min-height: 62px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 13px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 13px; }
@media (max-width: 620px) { .grid3, .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--r-lg); box-shadow: var(--s-1);
  padding: 18px 20px; margin-bottom: 14px;
  transition: box-shadow var(--medio), border-color var(--medio);
}
.card:hover { box-shadow: var(--s-2); }
.card h3 {
  font-size: 14.5px; margin-bottom: 13px; display: flex; align-items: center; gap: 8px;
  color: var(--tinta);
}
.card h3 .ico { color: var(--azul-600); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 650; letter-spacing: .01em;
  border: 1px solid transparent; text-transform: capitalize;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip.normal { background: var(--azul-100); color: var(--azul-700); border-color: #cfe0fb; }
.chip.pagado, .chip.aprobado { background: var(--verde-100); color: var(--verde); border-color: #bfe8d3; }
.chip.atrasado, .chip.rechazado { background: var(--rojo-100); color: var(--rojo); border-color: #f6cfcf; }
.chip.atrasado::before { animation: latir 1.6s ease-in-out infinite; }
.chip.pendiente { background: var(--ambar-100); color: var(--ambar); border-color: #f3ddb9; }

/* ---------- Utilidades ---------- */
.muted { color: var(--tinta-2); font-size: 13px; }
.right { text-align: right; }
.money { font-variant-numeric: tabular-nums; font-weight: 650; letter-spacing: -.01em; }
.verde-t { color: var(--verde); } .rojo-t { color: var(--rojo); } .naranja-t { color: var(--ambar); }

.empty { text-align: center; padding: 48px 22px; color: var(--tinta-2); animation: aparecer var(--suave); }
.empty .ico-big {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: var(--r-md);
  background: var(--azul-50); color: var(--azul-500);
  display: flex; align-items: center; justify-content: center;
}
.empty .ico-big .ico { width: 26px; height: 26px; }

/* Skeleton de carga */
.skel { display: grid; gap: 12px; }
.skel-row {
  height: 66px; border-radius: var(--r-md);
  background: var(--papel); border: 1px solid var(--linea);
  position: relative; overflow: hidden;
}
.skel-row::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(16, 24, 40, .045), transparent);
  animation: brillo 1.3s infinite;
}
.skel-row:nth-child(2) { animation-delay: .1s; }
.skel-row.alto { height: 96px; }

/* Progreso */
.progress { height: 6px; background: var(--linea-2); border-radius: 99px; overflow: hidden; }
.progress > div {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--verde), #10a56f);
  animation: crecerBarra 1s cubic-bezier(.22, 1, .36, 1) both;
  transition: width var(--suave);
}
.progress.warn > div { background: linear-gradient(90deg, var(--ambar), #d98a2b); }
.progress.bad > div { background: linear-gradient(90deg, var(--rojo), #e05555); }

/* ---------- Tablas ---------- */
.tabla-wrap {
  overflow-x: auto; border: 1px solid var(--linea);
  border-radius: var(--r-lg); background: var(--papel); box-shadow: var(--s-1);
}
table.tabla { width: 100%; border-collapse: collapse; }
table.tabla th {
  text-align: left; font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; color: var(--tinta-3);
  padding: 11px 14px; background: #fbfcfe; border-bottom: 1px solid var(--linea);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--linea-2); font-size: 13.5px; }
table.tabla tr:last-child td { border-bottom: none; }
table.tabla tr.click { cursor: pointer; transition: background var(--rapido); }
table.tabla tr.click:hover { background: var(--azul-50); }
table.tabla tr.click:hover td:first-child { box-shadow: inset 3px 0 0 var(--azul-500); }
.card > .tabla-wrap { border: none; box-shadow: none; border-radius: 0; }
.card > .tabla-wrap table.tabla th { background: transparent; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
body.mobile #toasts { top: auto; bottom: 96px; left: 14px; right: 14px; }
.toast {
  background: var(--tinta); color: #fff;
  padding: 11px 16px; border-radius: var(--r-md);
  box-shadow: var(--s-4); font-size: 13.5px; font-weight: 600;
  animation: entrarToast var(--resorte); display: flex; gap: 9px; align-items: center;
  transition: opacity var(--medio), transform var(--medio);
}
body.mobile .toast { animation: surgir var(--resorte); }
.toast .ico { flex: none; }
.toast.ok { background: var(--verde); }
.toast.err { background: var(--rojo); }
.toast.saliendo { opacity: 0; transform: translateX(20px); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10, 25, 47, .45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: aparecer var(--medio);
}
.modal {
  background: var(--papel); border-radius: var(--r-xl); box-shadow: var(--s-4);
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  animation: entrarModal var(--resorte);
}
.modal.grande { max-width: 840px; }
.modal-head {
  position: sticky; top: 0; z-index: 2;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  padding: 17px 20px 13px; border-bottom: 1px solid var(--linea);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.modal-head h2 { font-size: 16.5px; }
.modal-body { padding: 17px 20px 20px; }
.modal-x {
  background: var(--linea-2); border-radius: var(--r-sm);
  width: 30px; height: 30px; color: var(--tinta-2); flex: none;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--rapido), color var(--rapido), transform var(--rapido);
}
.modal-x:hover { background: var(--rojo-100); color: var(--rojo); transform: rotate(90deg); }
body.mobile .modal-bg { padding: 0; align-items: flex-end; }
body.mobile .modal { max-width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; animation: subirHoja var(--suave); }
body.mobile .modal-head { border-radius: var(--r-xl) var(--r-xl) 0 0; }
body.mobile .modal-head::before {
  content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  width: 34px; height: 4px; border-radius: 99px; background: var(--linea);
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 15% 0%, var(--azul-700) 0%, var(--azul-900) 55%, #06192c 100%);
  padding: 22px; position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(47, 124, 235, .3), transparent 68%);
}
.login-wrap::before { width: 620px; height: 620px; top: -230px; right: -170px; }
.login-wrap::after { width: 520px; height: 520px; bottom: -200px; left: -130px; background: radial-gradient(circle, rgba(7, 125, 85, .18), transparent 68%); }

/* Marca de agua: logo gigante con su centro clavado en la esquina inferior
   izquierda, así solo asoma su cuarto superior derecho. El translate(-50%,50%)
   mantiene el centro en la esquina sea cual sea el tamaño. */
.login-bg {
  position: absolute; z-index: 0; pointer-events: none; user-select: none;
  left: 0; bottom: 0; transform: translate(-50%, 50%);
  width: clamp(520px, min(132vh, 165vw), 1500px);
  height: clamp(520px, min(132vh, 165vw), 1500px);
  opacity: .09; /* valor final: la animación solo hace el fade-in */
  filter: saturate(1.6) brightness(1.5);
  animation: entrarMarca 1.4s cubic-bezier(.22, 1, .36, 1) backwards;
}
@keyframes entrarMarca {
  from { opacity: 0; transform: translate(-50%, 50%) scale(.92) rotate(-5deg); }
}
.login-card {
  background: var(--papel); border-radius: var(--r-xl); padding: 36px 32px;
  width: 100%; max-width: 384px; box-shadow: var(--s-4);
  position: relative; z-index: 1; animation: entrarModal var(--suave);
}
/* Logo circular: la imagen ya viene recortada con fondo transparente */
.login-logo {
  width: 82px; height: 82px; margin: 0 auto 14px; display: block;
  border-radius: 50%; object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(22, 78, 158, .28));
  animation: entrarModal var(--resorte);
}
.login-card h1 { text-align: center; font-size: 20px; color: var(--azul-900); }
.login-card .sub { text-align: center; color: var(--tinta-2); font-size: 13px; margin: 5px 0 24px; }
.login-card form { animation: surgir var(--suave) 120ms both; }
.login-pie {
  text-align: center; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--linea-2);
  color: var(--tinta-3); font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ============================================================
   ESCRITORIO
   ============================================================ */
body.desktop .shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; background: var(--azul-900); color: #fff;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 50;
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar .brand .logo {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  object-fit: contain; background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
}
.sidebar .brand b { font-size: 14.5px; display: block; letter-spacing: -.015em; }
.sidebar .brand span { font-size: 11px; color: rgba(255, 255, 255, .55); }
.sidebar nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar nav .grupo {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255, 255, 255, .34); padding: 14px 12px 6px;
}
.sidebar nav .item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border-radius: var(--r-sm); color: rgba(255, 255, 255, .74);
  font-size: 13.5px; font-weight: 550; width: 100%; text-align: left;
  margin-bottom: 2px; position: relative;
  transition: background var(--rapido), color var(--rapido), transform var(--rapido);
}
.sidebar nav .item .ico { width: 18px; height: 18px; opacity: .78; transition: opacity var(--rapido), transform var(--medio); }
.sidebar nav .item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav .item:hover .ico { opacity: 1; transform: translateX(1px); }
.sidebar nav .item.act { background: rgba(47, 124, 235, .18); color: #fff; font-weight: 650; }
.sidebar nav .item.act .ico { opacity: 1; color: var(--azul-500); }
.sidebar nav .item.act::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: 0 3px 3px 0; background: var(--azul-500);
  animation: surgir var(--medio);
}
.sidebar nav .item .badge {
  margin-left: auto; background: var(--ambar); color: #fff;
  font-size: 10.5px; border-radius: 99px; padding: 1px 7px; font-weight: 700;
}
.sidebar .foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar .foot .usr {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  padding: 7px 8px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .05);
}
.sidebar .foot .ava {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--azul-500), var(--azul-700));
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.sidebar .foot b { font-size: 13px; display: block; letter-spacing: -.01em; }
.sidebar .foot span { font-size: 11px; color: rgba(255, 255, 255, .5); }
.sidebar .foot .btn { justify-content: flex-start; }
.sidebar .foot .btn.sec { background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .8); }
.sidebar .foot .btn.sec:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.sidebar .foot .btn.rojo { background: transparent; color: #ff9a9a; }
.sidebar .foot .btn.rojo:hover { background: rgba(200, 48, 47, .22); color: #ffbdbd; }

body.desktop .main { flex: 1; margin-left: 244px; padding: 24px 30px 60px; max-width: 1560px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 14px; flex-wrap: wrap;
  animation: surgir var(--medio);
}
.topbar h1 { font-size: 21px; color: var(--azul-900); }
.topbar .acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* Métricas */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--r-lg); padding: 15px 16px; box-shadow: var(--s-1);
  position: relative; overflow: hidden;
  transition: box-shadow var(--medio), transform var(--medio), border-color var(--medio);
  animation: surgir var(--suave) both;
}
.stats .stat:nth-child(2) { animation-delay: 40ms; }
.stats .stat:nth-child(3) { animation-delay: 80ms; }
.stats .stat:nth-child(4) { animation-delay: 120ms; }
.stats .stat:nth-child(5) { animation-delay: 160ms; }
.stats .stat:nth-child(6) { animation-delay: 200ms; }
.stat::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--azul-500); opacity: .9;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--s-3); border-color: #d8e1ee; }
.stat.verde::before { background: var(--verde); }
.stat.rojo::before { background: var(--rojo); }
.stat.naranja::before { background: var(--ambar); }
.stat .lbl {
  font-size: 11.5px; color: var(--tinta-2); font-weight: 600;
  text-transform: uppercase; letter-spacing: .045em;
  display: flex; align-items: center; gap: 6px;
}
.stat .lbl .ico { width: 14px; height: 14px; color: var(--tinta-3); }
.stat .val {
  font-size: 22px; font-weight: 700; margin-top: 5px;
  color: var(--tinta); font-variant-numeric: tabular-nums; letter-spacing: -.025em;
}
.stat .sub2 { font-size: 11.5px; color: var(--tinta-3); margin-top: 2px; }

/* Filtros */
.filtros {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center;
  animation: surgir var(--medio);
}
.filtros input, .filtros select {
  padding: 8px 12px; border: 1.5px solid var(--linea); border-radius: var(--r-sm);
  background: var(--papel); outline: none; font-size: 13.5px;
  transition: border-color var(--rapido), box-shadow var(--medio);
}
.filtros select { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
}
.filtros input:focus, .filtros select:focus { border-color: var(--azul-500); box-shadow: var(--anillo); }
.filtros input[type="search"] { min-width: 240px; }
.busca-wrap { position: relative; display: flex; align-items: center; }
.busca-wrap .ico { position: absolute; left: 10px; color: var(--tinta-3); width: 16px; height: 16px; pointer-events: none; }
.busca-wrap input { padding-left: 32px !important; }

/* ============================================================
   MÓVIL
   ============================================================ */
body.mobile .shell { padding-bottom: 82px; min-height: 100vh; }
.m-top {
  position: sticky; top: 0; z-index: 40;
  background: var(--azul-900); color: #fff;
  padding: 13px 16px calc(13px + env(safe-area-inset-top)) 16px;
  padding-top: max(13px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 11px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), var(--s-2);
}
.m-top .logo {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  object-fit: contain; background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.m-top h1 { font-size: 16px; flex: 1; letter-spacing: -.02em; }
.m-top .back {
  background: rgba(255, 255, 255, .1); color: #fff; width: 32px; height: 32px;
  border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center;
  transition: background var(--rapido), transform var(--rapido);
}
.m-top .back:active { transform: scale(.9); background: rgba(255, 255, 255, .18); }
body.mobile .main { padding: 14px 14px 24px; }
body.mobile .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
body.mobile .stat { padding: 13px 14px; }
body.mobile .stat .val { font-size: 18px; }
body.mobile .stat .lbl { font-size: 10.5px; }
body.mobile .topbar { margin-bottom: 12px; }
body.mobile .topbar h1 { display: none; }
body.mobile .card { padding: 15px 16px; }
body.mobile .filtros input[type="search"] { min-width: 0; flex: 1; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 60;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(14px) saturate(180%); -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-top: 1px solid var(--linea);
  display: flex; justify-content: space-around; align-items: flex-end;
  padding: 5px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar .tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 650; color: var(--tinta-3);
  width: 60px; padding: 5px 0 3px; position: relative;
  transition: color var(--rapido);
}
.tabbar .tab .ic {
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--resorte);
}
.tabbar .tab .ic .ico { width: 21px; height: 21px; }
.tabbar .tab:active .ic { transform: scale(.86); }
.tabbar .tab.act { color: var(--azul-700); }
.tabbar .tab.act .ic { transform: translateY(-1px); }
.tabbar .tab.big { margin-top: -22px; }
.tabbar .tab.big .ic {
  width: 50px; height: 50px; border-radius: 50%;
  background: linear-gradient(140deg, var(--azul-600), var(--azul-800)); color: #fff;
  box-shadow: 0 6px 18px rgba(22, 78, 158, .42); border: 3.5px solid var(--fondo);
}
.tabbar .tab.big .ic .ico { width: 22px; height: 22px; }
.tabbar .tab.big:active .ic { transform: scale(.92); }
.tabbar .tab .bdg {
  position: absolute; top: 2px; left: 50%; margin-left: 4px;
  background: var(--rojo); color: #fff; font-size: 9.5px; border-radius: 99px;
  padding: 0 5px; font-weight: 700; border: 1.5px solid #fff;
}

/* Tarjetas de lista (móvil) */
.lista-cards .item-card {
  background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--r-md); box-shadow: var(--s-1);
  padding: 13px 14px; margin-bottom: 9px; cursor: pointer;
  transition: transform var(--rapido), box-shadow var(--medio), border-color var(--rapido);
  animation: surgir var(--medio) both;
}
.lista-cards .item-card:nth-child(2) { animation-delay: 35ms; }
.lista-cards .item-card:nth-child(3) { animation-delay: 70ms; }
.lista-cards .item-card:nth-child(4) { animation-delay: 100ms; }
.lista-cards .item-card:nth-child(n+5) { animation-delay: 130ms; }
.lista-cards .item-card:active { transform: scale(.985); box-shadow: var(--s-1); }
.lista-cards .item-card:hover { border-color: #d8e1ee; box-shadow: var(--s-2); }
.item-card .fila1 { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-bottom: 4px; }
.item-card .fila1 b { font-size: 14.5px; letter-spacing: -.01em; }
.item-card .fila2 { display: flex; justify-content: space-between; align-items: center; gap: 9px; font-size: 12.5px; color: var(--tinta-2); }

/* ---------- Fotos ---------- */
.fotos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foto-slot {
  border: 1.5px dashed #ccd6e5; border-radius: var(--r-md); padding: 15px 12px;
  text-align: center; cursor: pointer; background: var(--azul-50);
  transition: border-color var(--rapido), background var(--rapido), transform var(--rapido);
  position: relative; overflow: hidden;
}
.foto-slot:hover { border-color: var(--azul-500); background: var(--azul-100); transform: translateY(-1px); }
.foto-slot:active { transform: scale(.985); }
.foto-slot .ic-wrap {
  width: 34px; height: 34px; margin: 0 auto 7px; border-radius: 10px;
  background: var(--papel); color: var(--azul-600); box-shadow: var(--s-1);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--resorte);
}
.foto-slot:hover .ic-wrap { transform: scale(1.06) rotate(-3deg); }
.foto-slot .tt { font-size: 12.5px; font-weight: 650; }
.foto-slot .ss { font-size: 10.5px; color: var(--tinta-3); margin-top: 1px; }
.foto-slot.lleno { border-style: solid; border-color: var(--verde); padding: 0; background: none; }
.foto-slot.lleno img { width: 100%; height: 104px; object-fit: cover; display: block; }
.foto-slot.lleno .tt2 {
  position: absolute; inset: auto 0 0 0;
  background: linear-gradient(transparent, rgba(10, 25, 47, .82));
  color: #fff; font-size: 10.5px; padding: 14px 6px 5px; font-weight: 650;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.foto-slot.lleno .tt2 .ico { width: 12px; height: 12px; }
.fotos-vista { display: flex; gap: 9px; flex-wrap: wrap; }
.fotos-vista a { display: block; border-radius: var(--r-sm); overflow: hidden; box-shadow: var(--s-1); transition: transform var(--medio), box-shadow var(--medio); }
.fotos-vista a:hover { transform: scale(1.05); box-shadow: var(--s-3); }
.fotos-vista img { width: 86px; height: 86px; object-fit: cover; display: block; }

/* Ubicación */
.ubi-box {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 1.5px dashed #ccd6e5; border-radius: var(--r-md); background: var(--azul-50); cursor: pointer;
  transition: border-color var(--rapido), background var(--rapido);
}
.ubi-box:hover { border-color: var(--azul-500); background: var(--azul-100); }
.ubi-box.ok { border-style: solid; border-color: var(--verde); background: var(--verde-100); cursor: default; }
.ubi-box .ic-wrap {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--papel); color: var(--azul-600); box-shadow: var(--s-1);
  display: flex; align-items: center; justify-content: center;
}
.ubi-box.ok .ic-wrap { color: var(--verde); }
.ubi-box.buscando .ic-wrap .ico { animation: latir 1.2s ease-in-out infinite; }

/* Secciones del formulario */
.sec-titulo {
  display: flex; align-items: center; gap: 9px;
  font-size: 14.5px; font-weight: 700; color: var(--azul-900);
  margin: 26px 0 14px; padding-bottom: 9px; border-bottom: 1px solid var(--linea);
}
.sec-titulo:first-child { margin-top: 0; }
.sec-titulo .n {
  width: 23px; height: 23px; border-radius: 7px; flex: none;
  background: var(--azul-100); color: var(--azul-700);
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 750;
}
.sec-titulo .ico { color: var(--azul-500); margin-left: auto; opacity: .5; }

/* Resumen del plan */
.plan-box {
  background: linear-gradient(140deg, var(--azul-800), var(--azul-900));
  color: #fff; border-radius: var(--r-md); padding: 16px; margin: 13px 0;
  box-shadow: var(--s-2); animation: surgir var(--medio);
}
.plan-box .fila { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; color: rgba(255, 255, 255, .82); }
.plan-box .fila b { color: #fff; font-variant-numeric: tabular-nums; }
.plan-box .fila.total {
  border-top: 1px solid rgba(255, 255, 255, .18); margin-top: 8px; padding-top: 10px;
  font-size: 16px; font-weight: 700; color: #fff;
}
.plan-box .fila.total span:last-child { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* Detalle */
.detalle-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; align-items: baseline; }
.kv .k { color: var(--tinta-3); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.acciones-pago { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
body.mobile .acciones-pago { grid-template-columns: 1fr; }

.pago-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--linea-2);
  animation: surgir var(--medio) both;
}
.pago-item:last-child { border: none; padding-bottom: 0; }
.pago-item .ic-wrap {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--verde-100); color: var(--verde);
}
.pago-item .ic-wrap.rojo { background: var(--rojo-100); color: var(--rojo); }
.pago-item .ic-wrap.azul { background: var(--azul-100); color: var(--azul-700); }

/* Auditoría */
.aud-item {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-md);
  box-shadow: var(--s-1); padding: 13px 15px; margin-bottom: 8px;
  animation: surgir var(--medio) both; transition: box-shadow var(--medio);
}
.aud-item:hover { box-shadow: var(--s-2); }
.aud-item .ic-wrap {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: var(--azul-100); color: var(--azul-700);
  display: flex; align-items: center; justify-content: center;
}
.aud-item .cambio {
  background: #fbfcfe; border: 1px solid var(--linea-2); border-radius: var(--r-sm);
  padding: 7px 11px; margin-top: 8px; font-size: 12px;
  font-family: 'SF Mono', Consolas, monospace; color: var(--tinta-2); overflow-x: auto;
}

/* Menú "Más" */
.mas-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-md);
  box-shadow: var(--s-1); padding: 13px 14px; margin-bottom: 8px; width: 100%;
  font-size: 14px; font-weight: 600; color: var(--tinta); text-align: left;
  transition: transform var(--rapido), box-shadow var(--medio), border-color var(--rapido);
  animation: surgir var(--medio) both;
}
.mas-item:nth-child(2) { animation-delay: 30ms; }
.mas-item:nth-child(3) { animation-delay: 60ms; }
.mas-item:nth-child(4) { animation-delay: 90ms; }
.mas-item:nth-child(n+5) { animation-delay: 120ms; }
.mas-item:active { transform: scale(.985); }
.mas-item:hover { border-color: #d8e1ee; box-shadow: var(--s-2); }
.mas-item .ic-wrap {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--azul-100); color: var(--azul-700);
  display: flex; align-items: center; justify-content: center;
}
.mas-item.peligro .ic-wrap { background: var(--rojo-100); color: var(--rojo); }
.mas-item.peligro { color: var(--rojo); }
.mas-item .fl { margin-left: auto; color: var(--tinta-3); display: flex; transition: transform var(--medio); }
.mas-item:hover .fl { transform: translateX(3px); }

/* Tabla de descuentos */
.desc-tabla { width: 100%; border-collapse: collapse; margin-top: 8px; border-radius: var(--r-sm); overflow: hidden; }
.desc-tabla th {
  background: var(--azul-900); color: #fff; padding: 7px 10px;
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
}
.desc-tabla td { border: 1px solid var(--linea); padding: 6px 10px; text-align: center; font-size: 13px; }
.desc-tabla tr.act td {
  background: var(--verde-100); font-weight: 700; color: var(--verde); border-color: #bfe8d3;
}

/* Avatar de perfil (móvil) */
.perfil-card { display: flex; align-items: center; gap: 13px; }
.perfil-card .ava {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--azul-600), var(--azul-800)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
  box-shadow: var(--s-2);
}

/* Escritorio angosto (900–1100px): menú lateral más compacto.
   Debajo de 900px el JS cambia a la interfaz móvil (body.mobile). */
@media (max-width: 1100px) {
  .sidebar { width: 210px; }
  body.desktop .main { margin-left: 210px; padding: 20px 18px 50px; }
  .stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
