/**
 * aeapc.css — AEAPC-v3  REDESIGN
 * ─────────────────────────────────────────────────────────────────
 * Sistema de diseño visual para Dashboard Financiero AE-APC.
 * Paleta moderna: degradados, glassmorphism, dark mode elegante.
 * ─────────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════════════════
   0. DESIGN TOKENS
═══════════════════════════════════════════════════════════════ */
:root {
  --aeapc-radius-card:  18px;
  --aeapc-radius-sm:    12px;
  --aeapc-radius-xs:     8px;
  --aeapc-transition:   .20s cubic-bezier(.4,0,.2,1);

  /* Sombras por nivel */
  --aeapc-shadow-xs:  0 1px 4px rgba(0,0,0,.06);
  --aeapc-shadow-sm:  0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --aeapc-shadow-md:  0 8px 28px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  --aeapc-shadow-lg:  0 16px 48px rgba(0,0,0,.16), 0 4px 12px rgba(0,0,0,.08);

  /* Colores acento del proyecto */
  --aeapc-blue:    #2563eb;
  --aeapc-violet:  #7c3aed;
  --aeapc-rose:    #f43f5e;
  --aeapc-teal:    #06b6d4;
  --aeapc-amber:   #f59e0b;
  --aeapc-green:   #10b981;
  --aeapc-coral:   #ff6b6b;
  --aeapc-indigo:  #6366f1;
  --aeapc-fuchsia: #d946ef;
  --aeapc-lime:    #84cc16;
}

/* ═══════════════════════════════════════════════════════════════
   1. FUENTE GLOBAL
═══════════════════════════════════════════════════════════════ */
body {
  font-family: 'Plus Jakarta Sans', 'Nunito Sans', sans-serif !important;
}

/* ═══════════════════════════════════════════════════════════════
   2. CARDS — base con glassmorphism suave
═══════════════════════════════════════════════════════════════ */
[data-bs-theme="light"] .card {
  border: 1px solid rgba(0,0,0,.07) !important;
  border-radius: var(--aeapc-radius-card) !important;
  box-shadow: var(--aeapc-shadow-sm) !important;
  background: rgba(255,255,255,.95) !important;
  transition: transform var(--aeapc-transition), box-shadow var(--aeapc-transition);
  overflow: hidden;
}
[data-bs-theme="light"] .card:hover {
  box-shadow: var(--aeapc-shadow-md) !important;
  transform: translateY(-1px);
}

[data-bs-theme="dark"] .card {
  border: 1px solid rgba(255,255,255,.07) !important;
  border-radius: var(--aeapc-radius-card) !important;
  background: rgba(30,36,60,.72) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
  box-shadow: 0 4px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05) !important;
  transition: transform var(--aeapc-transition), box-shadow var(--aeapc-transition);
  overflow: hidden;
}
[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 8px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08) !important;
  transform: translateY(-1px);
}

/* Franja de color en el borde superior de cada card con gráfico */
.card-body h6.fw-semibold::before {
  content: '';
  display: block;
  width: 36px;
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--aeapc-blue), var(--aeapc-violet));
  margin-bottom: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   3. KPI CARDS
═══════════════════════════════════════════════════════════════ */
.kpi-card {
  position: relative;
  border-radius: var(--aeapc-radius-card);
  padding: 20px 20px 18px;
  transition: transform var(--aeapc-transition), box-shadow var(--aeapc-transition);
  overflow: hidden;
}

/* Light mode normal */
[data-bs-theme="light"] .kpi-card:not(.hero) {
  background: linear-gradient(145deg, #fff 60%, rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.05) 100%);
  border: 1px solid rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.14);
  border-left: 3px solid rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.55);
  box-shadow:
    0 4px 16px rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.10),
    0 1px 4px rgba(0,0,0,.04);
}
[data-bs-theme="light"] .kpi-card:not(.hero):hover {
  transform: translateY(-3px);
  box-shadow:
    0 10px 32px rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.22),
    0 4px 12px rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.12),
    0 1px 4px rgba(0,0,0,.05);
}

/* Dark mode normal */
[data-bs-theme="dark"] .kpi-card:not(.hero) {
  background: rgba(30,36,60,.72);
  border: 1px solid rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.18);
  border-left: 3px solid rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.55);
  box-shadow:
    0 4px 24px rgba(0,0,0,.30),
    0 0 0 0 rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.0),
    inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
[data-bs-theme="dark"] .kpi-card:not(.hero):hover {
  transform: translateY(-3px);
  box-shadow:
    0 10px 40px rgba(0,0,0,.40),
    0 4px 20px rgba(var(--kpi-r,99),var(--kpi-g,102),var(--kpi-b,241),.25),
    inset 0 1px 0 rgba(255,255,255,.09);
}

/* Decoración de fondo en las KPI cards normales */
.kpi-card:not(.hero)::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.10) 0%, transparent 70%);
  pointer-events: none;
}

/* Textos KPI */
.kpi-card .kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .65px;
  color: var(--bs-secondary-color);
  margin-bottom: 6px;
}
.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 5px;
  letter-spacing: -.5px;
}
.kpi-card .kpi-value.sm { font-size: 19px; letter-spacing: -.3px; }
.kpi-card .kpi-sub      { font-size: 11px; min-height: 16px; }
.kpi-card .kpi-top      { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.kpi-card .kpi-text-wrap{ flex: 1; min-width: 0; }

/* Icono wrap — normal */
.kpi-card .kpi-icon-wrap {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* Delta badges */
.kpi-delta        { font-weight: 700; font-size: 11px; }
.kpi-delta.pos    { color: #10b981; }
.kpi-delta.neg    { color: #ef4444; }
.kpi-delta.neu    { color: var(--bs-secondary-color); }

/* ── Hero / gradient cards ──────────────────────────── */
.kpi-card.hero {
  color: #fff;
  border: none !important;
  position: relative;
  overflow: hidden;
}
/* Brillito diagonal en hero cards */
.kpi-card.hero::before {
  content: '';
  position: absolute;
  top: -40%; left: -40%;
  width: 80%; height: 80%;
  background: radial-gradient(ellipse, rgba(255,255,255,.22) 0%, transparent 65%);
  pointer-events: none;
  border-radius: 50%;
}
.kpi-card.hero .kpi-label,
.kpi-card.hero .kpi-value,
.kpi-card.hero .kpi-sub,
.kpi-card.hero .kpi-delta { color: rgba(255,255,255,.95) !important; }
.kpi-card.hero .kpi-delta.pos,
.kpi-card.hero .kpi-delta.neg,
.kpi-card.hero .kpi-delta.neu { color: rgba(255,255,255,.78) !important; }
.kpi-card.hero:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0,0,0,.30) !important;
}
.kpi-card.hero .kpi-icon-wrap {
  background: rgba(255,255,255,.20) !important;
  box-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════
   4. PALETA DE DEGRADADOS — ampliada y más vibrante
═══════════════════════════════════════════════════════════════ */
/* Clásicos mejorados */
.grad-blue    { background: linear-gradient(135deg, #1240c4 0%, #4f8eff 100%); }
.grad-rose    { background: linear-gradient(135deg, #c11752 0%, #ff4580 100%); }
.grad-green   { background: linear-gradient(135deg, #027a55 0%, #14c78e 100%); }
.grad-amber   { background: linear-gradient(135deg, #b45309 0%, #ffb830 100%); }
.grad-teal    { background: linear-gradient(135deg, #0369a1 0%, #22d3ee 100%); }
.grad-violet  { background: linear-gradient(135deg, #5b21b6 0%, #c084fc 100%); }
.grad-pink    { background: linear-gradient(135deg, #9d174d 0%, #f472b6 100%); }
.grad-indigo  { background: linear-gradient(135deg, #3730a3 0%, #818cf8 100%); }
.grad-orange  { background: linear-gradient(135deg, #c2410c 0%, #fb923c 100%); }
.grad-navy    { background: linear-gradient(135deg, #0a1535 0%, #1e3a8a 100%); }

/* Nuevos — paleta moderna poco común */
.grad-coral   { background: linear-gradient(135deg, #d4145a 0%, #fbb03b 100%); }
.grad-aurora  { background: linear-gradient(135deg, #00c9ff 0%, #92fe9d 100%); color: #0a3622 !important; }
.grad-candy   { background: linear-gradient(135deg, #fd297b 0%, #9b51e0 100%); }
.grad-lime    { background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%); color: #1a3a0a !important; }
.grad-neon    { background: linear-gradient(135deg, #7303c0 0%, #ec38bc 100%); }
.grad-sunset  { background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%); color: #4a2700 !important; }
.grad-ocean   { background: linear-gradient(135deg, #1a6b9e 0%, #38b2ac 100%); }
.grad-magma   { background: linear-gradient(135deg, #1a0533 0%, #9b51e0 40%, #ff4b2b 100%); }
.grad-frost   { background: linear-gradient(135deg, #355c7d 0%, #6c5b7b 50%, #c06c84 100%); }
.grad-cyber   { background: linear-gradient(135deg, #0f3460 0%, #533483 50%, #e94560 100%); }

/* Glows en hero cards dark mode */
[data-bs-theme="dark"] .kpi-card.hero {
  box-shadow: 0 8px 32px rgba(0,0,0,.40), 0 0 0 1px rgba(255,255,255,.06) !important;
}

/* ═══════════════════════════════════════════════════════════════
   5. KPI GRID
═══════════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ═══════════════════════════════════════════════════════════════
   6. CHART WRAPPER
═══════════════════════════════════════════════════════════════ */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-wrap canvas {
  position: absolute;
  inset: 0;
}

/* ═══════════════════════════════════════════════════════════════
   7. PAGE HEADER
═══════════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--bs-border-color);
}
.page-header h4 {
  font-size: 21px;
  font-weight: 900;
  margin: 0;
  background: linear-gradient(135deg, var(--aeapc-blue) 0%, var(--aeapc-violet) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
[data-bs-theme="dark"] .page-header h4 {
  background: linear-gradient(135deg, #60a5fa 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-header .page-subtitle {
  font-size: 12.5px;
  color: var(--bs-secondary-color);
  margin-top: 3px;
  -webkit-text-fill-color: unset;
}

/* ═══════════════════════════════════════════════════════════════
   8. NAV PILLS (tabs)
═══════════════════════════════════════════════════════════════ */
.nav-pills .nav-link {
  border-radius: var(--aeapc-radius-sm) !important;
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 16px;
  color: var(--bs-secondary-color);
  transition: background var(--aeapc-transition), color var(--aeapc-transition), box-shadow var(--aeapc-transition);
}
.nav-pills .nav-link.active {
  background: linear-gradient(135deg, var(--aeapc-blue) 0%, var(--aeapc-indigo) 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(37,99,235,.40);
}
[data-bs-theme="dark"] .nav-pills .nav-link:not(.active):hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   9. SECTION DIVIDER
═══════════════════════════════════════════════════════════════ */
.section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--bs-secondary-color);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, var(--aeapc-blue), transparent) 1;
}

/* ═══════════════════════════════════════════════════════════════
   10. INSIGHT BOX
═══════════════════════════════════════════════════════════════ */
.insight-box {
  border-radius: var(--aeapc-radius-sm);
  padding: 14px 18px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--bs-body-color);
  position: relative;
  overflow: hidden;
}
[data-bs-theme="light"] .insight-box {
  background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
  border: 1px solid rgba(99,102,241,.18);
}
[data-bs-theme="dark"] .insight-box {
  background: linear-gradient(135deg, rgba(37,99,235,.12) 0%, rgba(124,58,237,.08) 100%);
  border: 1px solid rgba(99,102,241,.22);
}

/* ═══════════════════════════════════════════════════════════════
   11. BADGES SEMÁFORO — más vibrantes con glow
═══════════════════════════════════════════════════════════════ */
.badge.verde {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(16,185,129,.25);
}
.badge.amarillo {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(245,158,11,.25);
}
.badge.rojo {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(239,68,68,.25);
}
[data-bs-theme="dark"] .badge.verde {
  background: linear-gradient(135deg, #064e3b, #065f46);
  color: #6ee7b7;
  box-shadow: 0 0 10px rgba(16,185,129,.35);
}
[data-bs-theme="dark"] .badge.amarillo {
  background: linear-gradient(135deg, #451a03, #78350f);
  color: #fcd34d;
  box-shadow: 0 0 10px rgba(245,158,11,.35);
}
[data-bs-theme="dark"] .badge.rojo {
  background: linear-gradient(135deg, #4c0519, #7f1d1d);
  color: #fca5a5;
  box-shadow: 0 0 10px rgba(239,68,68,.35);
}

/* ═══════════════════════════════════════════════════════════════
   12. TABLE
═══════════════════════════════════════════════════════════════ */
.table-responsive { border-radius: var(--aeapc-radius-sm); overflow: hidden; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.table > thead > tr > th {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding-top: 12px;
  padding-bottom: 12px;
}
[data-bs-theme="light"] .table > thead {
  background: linear-gradient(90deg, #f0f4ff 0%, #faf5ff 100%);
}
[data-bs-theme="dark"] .table > thead {
  background: linear-gradient(90deg, rgba(37,99,235,.14) 0%, rgba(124,58,237,.10) 100%);
}

/* Líneas de tabla más sutiles */
[data-bs-theme="light"] .table > tbody > tr:hover > td {
  background: rgba(99,102,241,.04);
}
[data-bs-theme="dark"] .table > tbody > tr:hover > td {
  background: rgba(99,102,241,.10);
}

/* ═══════════════════════════════════════════════════════════════
   13. SIDEBAR — active item resaltado + prevenir FOUC
═══════════════════════════════════════════════════════════════ */
/* Ocultar submenús por defecto (antes de que corra el JS) */
.sidebar-wrapper-nav .has-submenu > .submenu { display: none; }
/* Mostrar cuando el padre tiene clase open (estado hardcodeado en HTML) */
.sidebar-wrapper-nav .has-submenu.open > .submenu { display: block; }
.sidebar-nav-link.active,
a.sidebar-nav-link.active {
  background: linear-gradient(90deg, rgba(37,99,235,.15) 0%, rgba(99,102,241,.06) 100%) !important;
  color: var(--aeapc-blue) !important;
  font-weight: 700;
  border-left: 3px solid var(--aeapc-blue);
  padding-left: calc(1rem - 3px);
  border-radius: 0 var(--aeapc-radius-xs) var(--aeapc-radius-xs) 0;
}
[data-bs-theme="dark"] .sidebar-nav-link.active,
[data-bs-theme="dark"] a.sidebar-nav-link.active {
  background: linear-gradient(90deg, rgba(99,102,241,.22) 0%, rgba(99,102,241,.06) 100%) !important;
  color: #818cf8 !important;
  border-left-color: #818cf8;
}

/* ═══════════════════════════════════════════════════════════════
   14. MODULE LINK CARDS (Home)
═══════════════════════════════════════════════════════════════ */
.aeapc-module-card {
  transition: transform var(--aeapc-transition), box-shadow var(--aeapc-transition);
  cursor: pointer;
  border-radius: var(--aeapc-radius-card) !important;
}
.aeapc-module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--aeapc-shadow-md) !important;
}

/* ═══════════════════════════════════════════════════════════════
   15. TOPHEADER FILTERS
═══════════════════════════════════════════════════════════════ */
@media (max-width: 991px) {
  #globalFilters { display: none !important; }
  .topheader-middle { display: none !important; }
}

/* Selects en topheader */
[data-bs-theme="light"] .topheader .form-select,
[data-bs-theme="light"] .topheader .input-group-text {
  border-color: rgba(0,0,0,.10) !important;
  background: rgba(255,255,255,.9);
}
[data-bs-theme="dark"] .topheader .form-select,
[data-bs-theme="dark"] .topheader .input-group-text {
  border-color: rgba(255,255,255,.12) !important;
  background: rgba(30,36,60,.80);
}

/* ═══════════════════════════════════════════════════════════════
   16. LOADING OVERLAY
═══════════════════════════════════════════════════════════════ */
.aeapc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--bs-secondary-color);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   17. LOGO
═══════════════════════════════════════════════════════════════ */
[data-bs-theme="light"] .logo-img {
  background-color: #1e2d6b;
  padding: 4px;
  border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   18. LOTES — APTITUD CARDS
═══════════════════════════════════════════════════════════════ */
.lotes-apt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.lotes-apt-card {
  border-radius: var(--aeapc-radius-card);
  padding: 16px 16px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform var(--aeapc-transition), box-shadow var(--aeapc-transition);
  overflow: hidden;
  position: relative;
}
.lotes-apt-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 32px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.16);
}
.lotes-apt-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18) 0%, transparent 70%);
  pointer-events: none;
}
.lotes-apt-card .apt-name {
  font-size: 12.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lotes-apt-card .apt-status {
  font-size: 9.5px; font-weight: 900;
  letter-spacing: .1em; margin-top: 1px;
}
.lotes-apt-card .apt-pct {
  font-size: 24px; font-weight: 900; line-height: 1; flex-shrink: 0;
}
.lotes-apt-card .apt-bar-track {
  height: 8px;
  background: rgba(0,0,0,.18);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.lotes-apt-card .apt-bar-fill {
  height: 100%; border-radius: 6px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  background: rgba(255,255,255,.75);
}
.lotes-apt-card .apt-issues {
  font-size: 10px; color: rgba(255,255,255,.70);
  display: flex; align-items: center; gap: 4px;
}

/* ── Lotes: tabla sortable ── */
.lotes-table { font-size: 12.5px; }
.lotes-table th { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.lotes-table td { font-size: 12.5px; vertical-align: middle; }
.lotes-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.lotes-table th.sortable:hover { opacity: 0.8; }
.lotes-table th.sortable::after      { content: ' ↕'; opacity: 0.4; font-size: 10px; }
.lotes-table th.sortable.asc::after  { content: ' ↑'; opacity: 1; }
.lotes-table th.sortable.desc::after { content: ' ↓'; opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   19. TIPOLOGÍA WIDGET (mat-tipo)
═══════════════════════════════════════════════════════════════ */
.tipo-widget        { display: flex; flex-direction: column; gap: 16px; padding: 4px 0; }
.tipo-header        { display: flex; align-items: baseline; gap: 10px; }
.tipo-total-num     { font-size: 34px; font-weight: 900; line-height: 1; color: var(--bs-body-color); }
.tipo-total-label   { font-size: 12px; font-weight: 600; color: var(--bs-secondary-color); }
.tipo-bar-wrap      { display: flex; height: 12px; border-radius: 8px; overflow: hidden; gap: 2px; }
.tipo-seg           { height: 100%; border-radius: 3px; min-width: 4px; }
.tipo-gap           { flex: 0 0 2px; height: 100%; }
.tipo-cards-grid    { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tipo-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--aeapc-radius-sm);
  transition: transform var(--aeapc-transition);
}
[data-bs-theme="light"] .tipo-card {
  background: linear-gradient(135deg, #f8faff 0%, #f5f0ff 100%);
  border: 1px solid rgba(99,102,241,.14);
}
[data-bs-theme="dark"] .tipo-card {
  background: rgba(99,102,241,.10);
  border: 1px solid rgba(99,102,241,.18);
}
.tipo-card:hover { transform: translateY(-2px); }
.tipo-icon-wrap {
  width: 38px; height: 38px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tipo-card-text { flex: 1; min-width: 0; }
.tipo-card-count { font-size: 19px; font-weight: 900; line-height: 1.1; color: var(--bs-body-color); }
.tipo-card-label {
  font-size: 10px; font-weight: 700;
  color: var(--bs-secondary-color);
  text-transform: uppercase; letter-spacing: .5px;
}
.tipo-card-pct { font-size: 11px; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════
   20. CUSTOM SELECTS (cs-)
═══════════════════════════════════════════════════════════════ */
.cs-trigger {
  cursor: pointer !important; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cs-trigger:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,.25);
  border-color: rgba(99,102,241,.55) !important;
}
.cs-dropdown {
  position: fixed; z-index: 1065;
  background: var(--bs-body-bg, #1a1f36);
  border: 1px solid var(--bs-border-color, rgba(255,255,255,.15));
  border-radius: var(--aeapc-radius-sm);
  box-shadow: var(--aeapc-shadow-lg);
  padding: 5px; display: none;
  max-height: 260px; overflow-y: auto; min-width: 140px;
}
.cs-dropdown.open { display: block; }
.cs-dropdown::-webkit-scrollbar { width: 4px; }
.cs-dropdown::-webkit-scrollbar-track { background: transparent; }
.cs-dropdown::-webkit-scrollbar-thumb {
  background: var(--bs-border-color, rgba(255,255,255,.2));
  border-radius: 4px;
}
.cs-option {
  padding: 7px 13px; border-radius: 8px;
  cursor: pointer; font-size: 12.5px; font-weight: 500;
  color: var(--bs-body-color); transition: background-color .10s; white-space: nowrap;
}
.cs-option:hover { background: rgba(99,102,241,.12); }
.cs-option.selected {
  background: linear-gradient(90deg, rgba(37,99,235,.15), rgba(99,102,241,.10));
  color: var(--aeapc-blue); font-weight: 700;
}
[data-bs-theme="dark"] .cs-option.selected { color: #818cf8; }
[data-bs-theme="light"] .cs-dropdown {
  background: #fff;
  border-color: rgba(0,0,0,.10);
  box-shadow: var(--aeapc-shadow-lg);
}

/* ═══════════════════════════════════════════════════════════════
   21. GTH CARDS (kpi-card con icono bx)
═══════════════════════════════════════════════════════════════ */
.kpi-card .kpi-icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.kpi-card .kpi-body {
  flex: 1; min-width: 0;
}
.kpi-card .kpi-body .kpi-value {
  font-size: 26px; font-weight: 900;
  line-height: 1.1; margin-bottom: 2px;
  letter-spacing: -.5px;
}
.kpi-card .kpi-body .kpi-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .65px;
  color: var(--bs-secondary-color); margin-bottom: 2px;
}
.kpi-card .kpi-body .kpi-sub {
  font-size: 11px; color: var(--bs-secondary-color);
}
.kpi-card.d-flex { gap: 14px; align-items: center; }

/* ═══════════════════════════════════════════════════════════════
   22. RESPONSIVE — MÓVIL
═══════════════════════════════════════════════════════════════ */

/* Tablet: ≤ 991px */
@media (max-width: 991px) {
  .main-content { padding: 18px 16px !important; }
  .page-header h4 { font-size: 18px; }
}

/* Móvil: ≤ 767px */
@media (max-width: 767px) {
  .main-content { padding: 14px 10px !important; }
  .page-header {
    flex-direction: column; align-items: flex-start;
    gap: 10px; margin-bottom: 16px;
  }
  .page-header h4 { font-size: 17px; }
  .page-header .page-subtitle { font-size: 11px; }

  #indTabs, #matTabs, .aeapc-nav-pills {
    flex-wrap: nowrap !important; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    width: 100%; padding-bottom: 2px;
  }
  #indTabs::-webkit-scrollbar,
  #matTabs::-webkit-scrollbar,
  .aeapc-nav-pills::-webkit-scrollbar { display: none; }
  #indTabs .nav-link, #matTabs .nav-link {
    white-space: nowrap; font-size: 11.5px; padding: 5px 10px;
  }

  .card-body { padding: 12px 12px !important; }
  .row.g-3, .row.g-4 { --bs-gutter-x: 0.5rem; --bs-gutter-y: 0.5rem; }
  .mb-4 { margin-bottom: 1rem !important; }
  .mb-3 { margin-bottom: .6rem !important; }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 16px;
  }
  .kpi-card { padding: 12px 14px; border-radius: 14px; }
  .kpi-card .kpi-value { font-size: 18px; }
  .kpi-card .kpi-value.sm { font-size: 15px; }
  .kpi-card .kpi-label { font-size: 9.5px; letter-spacing: .3px; }
  .kpi-card .kpi-sub { font-size: 10px; }
  .kpi-card .kpi-icon-wrap { width: 36px; height: 36px; border-radius: 10px; }
  .kpi-card .kpi-icon-wrap i { font-size: 1rem !important; }
  .kpi-card .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }

  /* Ocultar franja decorativa en móvil */
  .card-body h6.fw-semibold::before { display: none; }

  .lotes-apt-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .lotes-apt-card { padding: 9px 11px; border-radius: 12px; }
  .lotes-apt-card .apt-pct { font-size: 17px; }
  .lotes-apt-card .apt-name { font-size: 11px; }
  .lotes-apt-card .apt-status { font-size: 9px; }
  .lotes-apt-card .apt-issues { font-size: 9.5px; }

  .chart-wrap { height: 190px !important; }

  .tipo-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .tipo-card { padding: 8px 10px; gap: 7px; }
  .tipo-icon-wrap { width: 30px; height: 30px; border-radius: 8px; }
  .tipo-card-count { font-size: 15px; }
  .tipo-total-num { font-size: 24px; }

  #homeKpis .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
  #homeKpis .col-sm-6.col-xl { flex: 0 0 50%; max-width: 50%; }
  #homeKpis .card-body h4 { font-size: 16px !important; }
  .insight-box { font-size: 11px; padding: 9px 11px; border-radius: 10px; }
  .lotes-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #homePeriodBadge { font-size: 10px !important; padding: 4px 8px !important; }
}

/* Móvil ≤ 768px */
@media (max-width: 768px) {
  .topheader-middle { display: none !important; }
  .table-responsive, .lotes-table-wrapper {
    overflow-x: scroll !important; -webkit-overflow-scrolling: touch !important; max-width: 100%;
  }
  .table-responsive::after, .lotes-table-wrapper::after {
    content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 24px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, rgba(0,0,0,.08));
  }
  .table-responsive, .lotes-table-wrapper { position: relative; }
  .table { min-width: 480px; }
  .lotes-table { min-width: 560px !important; }
}

/* Móvil ≤ 640px */
@media (max-width: 640px) {
  .topheader-middle {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 0 4px;
    max-width: calc(100vw - 120px);
  }
  .topheader-middle::-webkit-scrollbar { display: none; }
  .topheader-middle .d-flex { flex-wrap: nowrap !important; gap: 4px !important; }
  .topheader-middle .input-group { width: 90px !important; }
  .topheader-middle .input-group:last-of-type { width: 110px !important; }
  .topheader-middle .input-group-text { padding: 3px 5px !important; font-size: 12px; }
  .topheader-middle .form-select-sm { font-size: 11px !important; padding: 3px 20px 3px 4px !important; }

  .page-header { flex-direction: column; gap: 8px; padding-bottom: 8px; margin-bottom: 12px !important; }
  .page-header h4 { font-size: 16px; margin-bottom: 2px !important; }
  .page-header .page-subtitle { font-size: 10.5px; }

  .kpi-card.hero { padding: 12px 14px !important; border-radius: 14px !important; }
  .kpi-card.hero .kpi-value { font-size: 19px !important; }
  .kpi-card.hero .kpi-value.sm { font-size: 15px !important; }
  .kpi-card.hero .kpi-label { font-size: 9.5px !important; }
  .kpi-card.hero .kpi-sub { font-size: 9.5px !important; }
  .kpi-card.hero .kpi-icon-wrap { width: 32px !important; height: 32px !important; border-radius: 9px !important; }
  .kpi-card.hero .kpi-icon-wrap i { font-size: .9rem !important; }

  .chart-wrap { height: 200px !important; min-height: 160px; }

  .row > [class*="col-lg"],
  .row > [class*="col-md"] { flex: 0 0 100% !important; max-width: 100% !important; }
  .row > .col-6 { flex: 0 0 50% !important; max-width: 50% !important; }

  #indTabs, #matTabs, #efTabs, .nav-pills {
    flex-wrap: nowrap !important; overflow-x: auto !important;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding-bottom: 2px; gap: 2px !important;
  }
  #indTabs::-webkit-scrollbar, #matTabs::-webkit-scrollbar,
  #efTabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar { display: none; }
  .nav-pills .nav-link { white-space: nowrap; font-size: 11px !important; padding: 5px 9px !important; }

  .card-body { padding: 10px !important; }
  .card-header.bg-transparent { padding: 10px 10px 6px !important; }
  .lotes-apt-grid { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .apt-pct { font-size: 18px !important; }
  .apt-name { font-size: 10.5px !important; }
  .apt-status { font-size: 9px !important; }
  .table-responsive { -webkit-overflow-scrolling: touch; font-size: 11.5px; }
  .lotes-table { font-size: 11px !important; }
  .lotes-table th { font-size: 10px !important; }
  .insight-box { font-size: 10.5px !important; padding: 8px 10px !important; }
  .hide-mobile { display: none !important; }
  #homePeriodBadge { font-size: 9px !important; padding: 3px 7px !important; }
  #auth-user-badge .d-none.d-md-block { display: none !important; }
  .btn-toggle { min-width: 36px; min-height: 36px; }
  .gap-3 { gap: 6px !important; }
  .gap-4 { gap: 8px !important; }
  .mb-4 { margin-bottom: 12px !important; }
  .mb-3 { margin-bottom: 8px !important; }
  .user-email-wrap, .user-dept-wrap { display: none !important; }
  .user-avatar { width: 34px !important; height: 34px !important; font-size: 12px !important; }
}

/* Muy pequeño ≤ 399px */
@media (max-width: 399px) {
  .main-content { padding: 10px 8px !important; }
  .kpi-grid { gap: 6px; }
  .kpi-card .kpi-value { font-size: 15px; }
  .lotes-apt-grid { grid-template-columns: 1fr 1fr; gap: 5px; }
  .lotes-apt-card .apt-pct { font-size: 15px; }
  .chart-wrap { height: 170px !important; }
  .tipo-cards-grid { grid-template-columns: 1fr; }
}

/* Landscape móvil */
@media (max-height: 500px) and (orientation: landscape) {
  .chart-wrap { height: 150px !important; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .page-header { margin-bottom: 8px !important; }
}

/* ═══════════════════════════════════════════════════════════════
   23. ANIMACIONES SUTILES
═══════════════════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kpi-card {
  animation: fadeSlideUp .35s cubic-bezier(.4,0,.2,1) both;
}
/* Escalonar entrada de cards */
.kpi-card:nth-child(1) { animation-delay: .04s; }
.kpi-card:nth-child(2) { animation-delay: .08s; }
.kpi-card:nth-child(3) { animation-delay: .12s; }
.kpi-card:nth-child(4) { animation-delay: .16s; }
.kpi-card:nth-child(5) { animation-delay: .20s; }
.kpi-card:nth-child(6) { animation-delay: .24s; }

/* Preferencia de reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  .kpi-card, .card, .lotes-apt-card { animation: none !important; transition: none !important; }
}

/* ── Toggle pill (reutilizable) ─────────────────────────────── */
.toggle-pill {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  vertical-align: middle;
}
.toggle-pill input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-pill .pill-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  transition: background 0.3s, border-color 0.3s;
  cursor: pointer;
}
.toggle-pill input:checked + .pill-track {
  background: linear-gradient(90deg, #06b6d4, #2563eb);
  border-color: transparent;
}
.toggle-pill .pill-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1), box-shadow 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.toggle-pill input:checked + .pill-track::after {
  transform: translateX(20px);
  box-shadow: 0 2px 8px rgba(6,182,212,0.5);
}

/* ── EERR Otorgamientos control card ────────────────────────── */
.eerr-otorg-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 10px 18px 10px 12px;
  background: linear-gradient(130deg, rgba(6,182,212,0.12) 0%, rgba(37,99,235,0.1) 100%);
  border: 1px solid rgba(6,182,212,0.3);
  border-radius: 18px;
  cursor: pointer;
  user-select: none;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
  box-shadow: 0 0 20px rgba(6,182,212,0.12), inset 0 1px 0 rgba(255,255,255,0.07);
}
.eerr-otorg-ctrl:hover {
  background: linear-gradient(130deg, rgba(6,182,212,0.2) 0%, rgba(37,99,235,0.18) 100%);
  border-color: rgba(6,182,212,0.55);
  box-shadow: 0 0 28px rgba(6,182,212,0.22), inset 0 1px 0 rgba(255,255,255,0.1);
}
.eerr-otorg-ctrl.off {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.1);
  box-shadow: none;
}
.eoc-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #06b6d4 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.3s;
  box-shadow: 0 4px 12px rgba(6,182,212,0.35);
}
.eerr-otorg-ctrl.off .eoc-icon {
  background: rgba(255,255,255,0.08);
  box-shadow: none;
}
.eoc-labels { display: flex; flex-direction: column; gap: 2px; }
.eoc-title  { font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.92); line-height: 1; }
.eoc-sub    { font-size: 10px; color: rgba(255,255,255,0.45); line-height: 1; transition: color 0.3s; }
.eerr-otorg-ctrl.off .eoc-sub { color: rgba(255,255,255,0.28); }
.eoc-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 50px;
  background: linear-gradient(90deg, #06b6d4, #2563eb);
  color: #fff;
  flex-shrink: 0;
  transition: background 0.3s, color 0.3s;
  box-shadow: 0 2px 8px rgba(6,182,212,0.3);
}
.eerr-otorg-ctrl.off .eoc-badge {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.3);
  box-shadow: none;
}

/* ── Overrides LIGHT THEME ─────────────────────────────────────── */

/* Toggle Otorgamientos en tema claro */
[data-bs-theme="light"] .eerr-otorg-ctrl {
  background: linear-gradient(130deg, rgba(6,182,212,0.07) 0%, rgba(37,99,235,0.07) 100%);
  border-color: rgba(6,182,212,0.35);
  box-shadow: 0 0 16px rgba(6,182,212,0.08), inset 0 1px 0 rgba(255,255,255,0.8);
}
[data-bs-theme="light"] .eerr-otorg-ctrl:hover {
  background: linear-gradient(130deg, rgba(6,182,212,0.13) 0%, rgba(37,99,235,0.13) 100%);
  border-color: rgba(6,182,212,0.5);
  box-shadow: 0 0 22px rgba(6,182,212,0.16), inset 0 1px 0 rgba(255,255,255,0.9);
}
[data-bs-theme="light"] .eerr-otorg-ctrl.off {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.13);
  box-shadow: none;
}
[data-bs-theme="light"] .eoc-title {
  color: rgba(0,0,0,0.80);
}
[data-bs-theme="light"] .eoc-sub {
  color: rgba(0,0,0,0.45);
}
[data-bs-theme="light"] .eerr-otorg-ctrl.off .eoc-icon {
  background: rgba(0,0,0,0.08);
}
[data-bs-theme="light"] .eerr-otorg-ctrl.off .eoc-sub {
  color: rgba(0,0,0,0.28);
}
[data-bs-theme="light"] .toggle-pill .pill-track {
  background: rgba(0,0,0,0.12);
  border-color: rgba(0,0,0,0.18);
}
[data-bs-theme="light"] .eerr-otorg-ctrl.off .eoc-badge {
  background: rgba(0,0,0,0.07);
  color: rgba(0,0,0,0.30);
  box-shadow: none;
}

/* Aptitud cards (Meta Morosidad + Lotes) en tema claro */
[data-bs-theme="light"] .lotes-apt-card .apt-issues {
  color: rgba(0,0,0,0.52);
}
[data-bs-theme="light"] .lotes-apt-card .apt-bar-track {
  background: rgba(0,0,0,0.10);
}
