/* ========================================
   FACTURACIÓN REMOTA R&H — UI Pro
   Colores: Azul #1A3C8F | Fuente: Montserrat
   Responsive: Mobile, Tablet, PC
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

:root {
  --azul: #1A3C8F;
  --azul-dark: #0F2560;
  --azul-light: #2B5CC3;
  --azul-bg: #EDF1F9;
  --azul-hover: #163378;
  --verde: #22C55E;
  --verde-dark: #16A34A;
  --rojo: #EF4444;
  --rojo-light: #FEE2E2;
  --naranja: #F59E0B;
  --naranja-light: #FEF3C7;
  --gris: #64748B;
  --gris-light: #F1F5F9;
  --gris-dark: #334155;
  --blanco: #FFFFFF;
  --texto: #1E293B;
  --borde: #E2E8F0;
  --sombra-sm: 0 1px 3px rgba(0,0,0,0.06);
  --sombra: 0 4px 12px rgba(0,0,0,0.08);
  --sombra-lg: 0 10px 40px rgba(0,0,0,0.12);
  --radio: 10px;
  --radio-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gris-light);
  color: var(--texto);
  font-size: 14px;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════
   HEADER — Con logo del negocio
   ══════════════════════════════════════ */
.header {
  background: linear-gradient(135deg, var(--azul-dark) 0%, var(--azul) 60%, var(--azul-light) 100%);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(15,37,96,0.3);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
  padding: 3px;
  flex-shrink: 0;
}
.header-text { min-width: 0; }
.header h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header .user-info {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.25);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radio);
  cursor: pointer;
  font-size: 12px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-logout:hover { background: rgba(255,255,255,0.22); }
.btn-logout:active { transform: scale(0.96); }

/* ══════════════════════════════════════
   APP LAYOUT — Sidebar + Contenido
   ══════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: calc(100vh - 70px);
}

/* ── SIDEBAR IZQUIERDO ── */
.sidebar-nav {
  width: 210px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--borde);
  padding: 12px 0;
  position: sticky;
  top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  text-decoration: none;
  color: var(--gris-dark);
  font-weight: 600;
  font-size: 13px;
  border-radius: 0;
  transition: var(--transition);
  border-left: 3px solid transparent;
  margin: 0 8px;
  border-radius: var(--radio);
  border-left: 3px solid transparent;
}
.nav-item .nav-icon {
  font-size: 17px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item .nav-label { flex: 1; }
.nav-item:hover {
  background: var(--azul-bg);
  color: var(--azul);
  border-left-color: var(--azul-light);
}
.nav-item.active {
  background: var(--azul-bg);
  color: var(--azul);
  font-weight: 700;
  border-left-color: var(--azul);
}
.sidebar-divider {
  height: 1px;
  background: var(--borde);
  margin: 8px 16px;
}

/* ─── NAV GROUP (acordeón estilo Siigo) ─────────────────── */
.nav-group {
  display: flex;
  flex-direction: column;
}
.nav-parent {
  position: relative;
}
.nav-parent .nav-chevron {
  font-size: 13px;
  color: var(--gris-medio, #94a3b8);
  margin-left: auto;
  transition: transform .25s ease;
  flex-shrink: 0;
}
.nav-group.expanded .nav-parent .nav-chevron {
  transform: rotate(180deg);
  color: var(--azul);
}
.nav-submenu {
  max-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 8px 4px;
  padding: 0 4px;
  transition: max-height .35s ease, padding .25s ease, margin .25s ease;
  background: linear-gradient(180deg, rgba(59,130,246,0.04) 0%, transparent 100%);
  border-radius: 0 0 var(--radio) var(--radio);
}
.nav-submenu.open {
  max-height: 600px;
  padding: 4px 4px 8px;
}
.nav-subitem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 36px;
  text-decoration: none;
  color: #64748b;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-subitem::before {
  content: '';
  position: absolute;
  left: 22px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: background .15s;
}
.nav-subitem {
  position: relative;
}
.nav-subitem:hover {
  background: var(--azul-bg);
  color: var(--azul);
}
.nav-subitem:hover::before { background: var(--azul-light); }
.nav-subitem.active {
  background: var(--azul-bg);
  color: var(--azul);
  font-weight: 700;
  border-left-color: var(--azul);
}
.nav-subitem.active::before { background: var(--azul); }

/* ── ÁREA DE CONTENIDO ── */
.content-area {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}
.container { max-width: 900px; margin: 0 auto; padding: 20px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ══════════════════════════════════════
   LOGIN — Pantalla de acceso
   ══════════════════════════════════════ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--azul-dark) 0%, var(--azul) 40%, var(--azul-light) 100%);
  padding: 20px;
}
.login-box {
  background: white;
  border-radius: var(--radio-lg);
  padding: 44px 32px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
  text-align: center;
}
.login-logo-img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: contain;
  margin-bottom: 8px;
  background: var(--azul-bg);
  padding: 6px;
}
.login-box .logo-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--azul);
  margin-bottom: 2px;
}
.login-box .logo-sub {
  font-size: 11px;
  color: var(--gris);
  margin-bottom: 28px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 500;
}
.login-box h2 {
  font-size: 18px;
  margin-bottom: 24px;
  color: var(--texto);
  font-weight: 700;
}

/* ══════════════════════════════════════
   FORMULARIOS
   ══════════════════════════════════════ */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gris-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  transition: var(--transition);
  background: white;
  color: var(--texto);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 4px rgba(26,60,143,0.1);
}
.form-group input::placeholder { color: #94A3B8; }

/* ══════════════════════════════════════
   BOTONES
   ══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radio);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--azul); color: white; }
.btn-primary:hover { background: var(--azul-hover); box-shadow: 0 4px 12px rgba(26,60,143,0.3); }
.btn-success { background: var(--verde); color: white; }
.btn-success:hover { background: var(--verde-dark); box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
.btn-danger { background: var(--rojo); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-outline {
  background: transparent;
  color: var(--azul);
  border: 2px solid var(--azul);
}
.btn-outline:hover { background: var(--azul); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ══════════════════════════════════════
   CARDS / SECCIONES
   ══════════════════════════════════════ */
.card {
  background: white;
  border-radius: var(--radio);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--sombra-sm);
  border: 1px solid var(--borde);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--sombra); }
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--azul);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ══════════════════════════════════════
   CLIENTE SELECCIONADO
   ══════════════════════════════════════ */
.cliente-selected {
  background: linear-gradient(135deg, var(--azul-bg), #DCE5F5);
  border: 2px solid var(--azul);
  border-radius: var(--radio);
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}
.cliente-selected .nombre { font-weight: 700; font-size: 15px; color: var(--azul-dark); }
.cliente-selected .detalle { font-size: 12px; color: var(--gris); margin-top: 4px; }
.cliente-selected .btn-cambiar { font-size: 11px; margin-top: 8px; }

/* ══════════════════════════════════════
   TABLA PRODUCTOS / DETALLE
   ══════════════════════════════════════ */
.tabla-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--azul);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--borde);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--azul-bg); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ══════════════════════════════════════
   BÚSQUEDA
   ══════════════════════════════════════ */
.search-box { position: relative; }
.search-box input {
  padding: 12px 14px 12px 40px;
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  width: 100%;
  transition: var(--transition);
  background: white;
}
.search-box input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 4px rgba(26,60,143,0.1);
}
.search-box .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gris);
  font-size: 16px;
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 2px solid var(--azul);
  border-radius: var(--radio);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  box-shadow: var(--sombra-lg);
}
.search-results.visible { display: block; animation: fadeIn 0.15s ease; }
.search-results .item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--borde);
  transition: var(--transition);
}
.search-results .item:last-child { border-bottom: none; }
.search-results .item:hover { background: var(--azul-bg); }
.search-results .item:active { background: #D6DEF0; }
.search-results .item .nombre { font-weight: 600; font-size: 13px; color: var(--texto); }
.search-results .item .info { font-size: 11px; color: var(--gris); margin-top: 2px; }
.search-results .item .stock-ok { color: var(--verde); font-weight: 700; }
.search-results .item .stock-bajo { color: var(--naranja); font-weight: 700; }
.search-results .item .stock-cero { color: var(--rojo); font-weight: 700; }

/* ══════════════════════════════════════
   INPUT CANTIDAD EN TABLA
   ══════════════════════════════════════ */
.input-cant {
  width: 60px;
  padding: 6px 8px;
  border: 2px solid var(--borde);
  border-radius: 6px;
  text-align: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  transition: var(--transition);
}
.input-cant:focus { border-color: var(--azul); outline: none; }

/* ══════════════════════════════════════
   TOTALES
   ══════════════════════════════════════ */
.totales-box {
  background: linear-gradient(135deg, var(--azul-dark), var(--azul));
  color: white;
  border-radius: var(--radio);
  padding: 18px;
  margin-top: 14px;
}
.totales-box .linea {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
  font-weight: 500;
}
.totales-box .linea.total {
  font-size: 22px;
  font-weight: 800;
  border-top: 2px solid rgba(255,255,255,0.2);
  margin-top: 10px;
  padding-top: 10px;
}

/* ══════════════════════════════════════
   MEMBRETE FACTURA (IMPRESIÓN)
   ══════════════════════════════════════ */
.factura-print {
  background: white;
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
  font-size: 12px;
  color: #000;
}
.factura-print .membrete {
  text-align: center;
  border-bottom: 3px solid var(--azul);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.factura-print .membrete .logo-membrete {
  height: 56px;
  margin-bottom: 6px;
  object-fit: contain;
}
.factura-print .membrete .negocio {
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--azul-dark);
  letter-spacing: 1px;
}
.factura-print .membrete .nit { font-size: 14px; font-weight: 700; color: var(--azul); margin-top: 2px; }
.factura-print .membrete .info { font-size: 11px; line-height: 1.6; color: #333; margin-top: 4px; }
.factura-print .membrete .resolucion {
  font-size: 9.5px;
  margin-top: 8px;
  line-height: 1.4;
  white-space: pre-line;
  color: #555;
  padding: 6px 12px;
  background: #F8FAFC;
  border-radius: 4px;
  border: 1px solid #E2E8F0;
}
.factura-print .factura-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #CBD5E1;
  gap: 16px;
}
.factura-print .factura-header .col { font-size: 11px; line-height: 1.7; }
.factura-print .factura-header .cod-factura {
  font-size: 20px;
  font-weight: 800;
  color: var(--azul);
}
.factura-print table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.factura-print table th {
  background: var(--azul);
  color: #fff;
  padding: 6px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.factura-print table td {
  padding: 5px 8px;
  border-bottom: 1px solid #E2E8F0;
  font-size: 11px;
}
.factura-print .totales { text-align: right; margin-top: 10px; }
.factura-print .totales .linea {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  font-size: 12px;
  padding: 3px 0;
}
.factura-print .totales .linea.total {
  font-size: 18px;
  font-weight: 800;
  border-top: 3px solid var(--azul);
  padding-top: 6px;
  margin-top: 4px;
  color: var(--azul-dark);
}
.factura-print .footer {
  text-align: center;
  font-size: 10px;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #E2E8F0;
  color: #64748B;
}

/* ══════════════════════════════════════
   CARTERA — Badges
   ══════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-pendiente { background: var(--naranja-light); color: #92400E; }
.badge-cancelada { background: #DCFCE7; color: #166534; }
.monto { font-weight: 700; font-family: 'Montserrat', monospace; }
.monto-pendiente { color: var(--rojo); }
.monto-total { color: var(--azul-dark); }

/* ══════════════════════════════════════
   ALERTAS
   ══════════════════════════════════════ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radio);
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-error { background: var(--rojo-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ══════════════════════════════════════
   MODAL
   ══════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: white;
  border-radius: var(--radio-lg);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--sombra-lg);
}
.modal-close {
  float: right;
  background: var(--gris-light);
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gris);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--rojo-light); color: var(--rojo); }

/* ══════════════════════════════════════
   LOADING
   ══════════════════════════════════════ */
.loading { text-align: center; padding: 30px; color: var(--gris); }
.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--borde);
  border-top-color: var(--azul);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════
   RESPONSIVE — TABLET (601px – 1024px)
   ══════════════════════════════════════ */
@media (min-width: 601px) and (max-width: 1024px) {
  .sidebar-nav { width: 68px; padding: 8px 0; }
  .nav-item { padding: 12px 0; justify-content: center; margin: 0 4px; border-left: none; border-bottom: 3px solid transparent; flex-direction: column; gap: 4px; }
  .nav-item.active { border-left: none; border-bottom-color: var(--azul); }
  .nav-item:hover { border-left: none; }
  .nav-item .nav-label { font-size: 9px; text-align: center; }
  .nav-item .nav-icon { font-size: 20px; width: auto; }
  .sidebar-divider { display: none; }
  .container { padding: 16px; }
  .header { padding: 14px 20px; }
  .header h1 { font-size: 15px; }
  .card { padding: 18px; }

  /* Tablet: ocultar sub-menu en sidebar comprimido — se usa quick-nav dentro del dashboard */
  .nav-submenu { display: none !important; }
  .nav-parent .nav-chevron { display: none; }
}

/* ══════════════════════════════════════
   RESPONSIVE — PC (1025px+)
   ══════════════════════════════════════ */
@media (min-width: 1025px) {
  .container { padding: 24px; max-width: 980px; }
  .header { padding: 16px 32px; }
  .header h1 { font-size: 18px; }
  .header-logo { width: 200px; height: 48px; }
  .header .user-info { font-size: 12px; }
  .card { padding: 24px; margin-bottom: 16px; }
  .card-title { font-size: 15px; }
  th, td { padding: 12px 14px; }
  .search-box input { padding: 14px 14px 14px 44px; font-size: 15px; }
  .totales-box { padding: 24px; }
  .totales-box .linea.total { font-size: 26px; }
  .btn-hamburger { display: flex; }

  /* ══ SIDEBAR DESKTOP — Estilo POS Mario ══
     Estado 1 (collapsed/default): barra delgada solo íconos
     Estado 2 (expanded): panel overlay con nombres  */

  .sidebar-nav {
    width: 200px;
    padding: 10px 0;
    overflow-y: auto;
    transition: width 0.2s ease;
    z-index: 50;
  }
  .sidebar-nav .sidebar-section-label { display: block; }
  .nav-item {
    font-size: 14px;
    padding: 9px 14px;
    gap: 10px;
    justify-content: flex-start;
    margin: 1px 4px;
    border-left: none;
    border-radius: 8px;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-item .nav-label { display: block; flex: 1; }
  .nav-item .nav-chevron { display: block; }
  .nav-item .nav-icon { width: auto; font-size: 19px; flex-shrink: 0; }
  .nav-item.active {
    background: var(--azul);
    color: #fff;
    border-left: none;
  }

  /* Tooltip al hover (solo cuando NO expanded) */
  .sidebar-nav:not(.sb-expanded) .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    transform: translateY(-50%);
    background: #1E293B;
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  }
  .sidebar-nav:not(.sb-expanded) .nav-item:hover::after { opacity: 1; }
  .sidebar-nav:not(.sb-expanded) .nav-item:hover { background: var(--azul-bg); }

  /* ── Estado EXPANDED (click ☰) ── */
  .sidebar-nav.sb-expanded {
    width: 240px;
    position: fixed;
    top: 70px;
    left: 0;
    height: calc(100vh - 70px);
    box-shadow: 4px 0 20px rgba(0,0,0,0.12);
    z-index: 500;
    background: #fff;
    padding: 8px 0;
    overflow-y: auto;
  }
  .sidebar-nav.sb-expanded .nav-label { display: block; }
  .sidebar-nav.sb-expanded .nav-chevron { display: block; }
  .sidebar-nav.sb-expanded .sidebar-section-label { display: block; }
  .sidebar-nav.sb-expanded .nav-item {
    padding: 11px 18px;
    gap: 12px;
    justify-content: flex-start;
    margin: 0 8px;
  }
  .sidebar-nav.sb-expanded .nav-item.active {
    background: var(--azul-bg);
    color: var(--azul);
    font-weight: 700;
  }
  .sidebar-nav.sb-expanded .nav-item::after { display: none; }

  /* Scrim para el overlay expanded */
  .sb-scrim {
    display: none;
    position: fixed;
    inset: 0;
    top: 70px;
    background: rgba(0,0,0,0.15);
    z-index: 499;
  }
  .sb-scrim.active { display: block; }
}

/* ══════════════════════════════════════
   RESPONSIVE — MOBILE (≤600px)
   ══════════════════════════════════════ */
@media (max-width: 600px) {
  /* Header compacto */
  .header { padding: 10px 12px; }
  .header h1 { font-size: 13px; }
  .header-logo { width: 34px; height: 34px; border-radius: 6px; }
  .header-left { gap: 8px; }
  .header .user-info { font-size: 10px; }
  .btn-logout { padding: 6px 10px; font-size: 11px; }

  /* Drawer lateral — reemplaza bottom nav */
  .sidebar-nav {
    position: fixed;
    top: 0; left: 0;
    width: min(280px, 85vw);
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 10px;
    border-right: 1px solid var(--borde);
    border-top: none;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar-nav.drawer-open { transform: translateX(0); }
  .nav-item {
    flex: unset;
    flex-direction: row;
    gap: 12px;
    padding: 0 16px;
    min-height: 52px;
    margin: 0;
    border-radius: 0;
    border-left: 3px solid transparent;
    border-top: none;
    justify-content: flex-start;
    align-items: center;
    font-size: 14px;
  }
  .nav-item.active { border-top: none; border-left-color: var(--azul); }
  .nav-item:hover { border-left-color: var(--azul-light); }
  .nav-item .nav-icon { font-size: 20px; width: 28px; flex-shrink: 0; }
  .nav-item .nav-label { font-size: 14px; font-weight: 500; }
  .sidebar-divider { display: none; }
  .nav-group { flex-direction: column; }
  .nav-group .nav-parent { flex: unset; }
  .btn-hamburger { display: flex; }
  .drawer-header { display: flex; }
  .sidebar-section-label { display: block; }
  .content-area { padding-bottom: 0; }
  .container { padding: 10px; }
  .card { padding: 14px; margin-bottom: 10px; border-radius: 8px; }
  .card-title { font-size: 13px; margin-bottom: 10px; }
  th { padding: 8px 6px; font-size: 10px; }
  td { padding: 8px 6px; font-size: 12px; }
  .input-cant { width: 52px; font-size: 13px; padding: 5px 4px; }
  .totales-box .linea.total { font-size: 18px; }
  .factura-print { padding: 12px; font-size: 11px; }
  .factura-print .membrete .negocio { font-size: 16px; }
  .factura-print .factura-header { flex-direction: column; gap: 8px; }
  .modal { padding: 18px; border-radius: 12px; }
  .login-box { padding: 32px 24px 28px; }
}

/* ── Botón hamburguesa — visible por defecto, oculto en tablet/desktop ── */
.btn-hamburger {
  display: flex;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0 8px;
  border-radius: 8px;
  color: white;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  transition: background 0.2s;
  flex-shrink: 0;
  line-height: 1;
}
.btn-hamburger:hover { background: rgba(255,255,255,0.15); }
@media (min-width: 601px) and (max-width: 1024px) { .btn-hamburger { display: none; } }

/* ── Drawer: header azul fijo en la parte superior ── */
.drawer-header {
  display: none;
  background: var(--azul);
  color: white;
  padding: 0 16px;
  height: 60px;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.drawer-header .drawer-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  transition: background 0.2s;
  flex-shrink: 0;
}
.drawer-header .drawer-close:hover { background: rgba(255,255,255,0.28); }

/* ── Section labels (ocultos en desktop, visibles en móvil) ── */
.sidebar-section-label {
  display: none;
  font-size: 10px;
  font-weight: 800;
  color: var(--gris);
  letter-spacing: 1.2px;
  padding: 14px 16px 5px;
  text-transform: uppercase;
  border-top: 1px solid var(--borde);
  background: var(--gris-light);
}
.sidebar-section-label:first-of-type { border-top: none; }

/* ── Scrim oscuro detrás del drawer ── */
.drawer-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
}
.drawer-scrim.active {
  display: block;
  animation: scrimIn 0.25s ease;
}
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }

/* ══════════════════════════════════════
   ABONOS — Módulo 2
   ══════════════════════════════════════ */
.abono-factura-item {
  padding: 10px 14px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  margin-bottom: 6px;
  cursor: pointer;
  transition: var(--transition);
  background: white;
}
.abono-factura-item:hover { border-color: var(--azul); background: var(--azul-bg); }
.abono-resultado-vacio {
  padding: 14px;
  color: var(--gris);
  font-size: 13px;
  text-align: center;
}
.abono-fact-num   { font-weight: 700; font-size: 14px; color: var(--azul); }
.abono-fact-cliente { font-size: 13px; font-weight: 600; margin-top: 2px; }
.abono-fact-meta  { font-size: 11px; color: var(--gris); margin-top: 2px; }
.abono-saldo-pendiente {
  font-size: 14px;
  font-weight: 700;
  color: var(--rojo);
}

/* Inputs y selects del módulo abonos */
.abono-input, .abono-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  font-size: 13px;
  color: var(--texto);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.abono-input:focus, .abono-select:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,60,143,.1);
}
.abono-select { cursor: pointer; }

.abono-info-grid { display: flex; flex-direction: column; gap: 6px; }
.abono-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--gris-light);
}
.abono-info-row--destacado {
  background: linear-gradient(135deg, #FEE2E2, #FEF2F2);
  border: 1px solid #FECACA;
}
.abono-info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gris-dark);
  letter-spacing: 0.2px;
  margin-bottom: 4px;
  display: block;
}
.abono-info-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--texto);
}

/* ══════════════════════════════════════
   ADMIN — Usuarios y Permisos
   ══════════════════════════════════════ */
.usuarios-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.usuario-card {
  background: white;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 14px;
  transition: var(--transition);
}
.usuario-card:hover { box-shadow: var(--sombra); border-color: var(--azul); }
.usuario-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.usuario-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.usuario-info { flex: 1; min-width: 0; }
.usuario-nombre {
  font-weight: 700;
  font-size: 14px;
  color: var(--texto);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.usuario-clave {
  font-size: 11px;
  color: var(--gris);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.badge-rol {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-admin { background: #DBEAFE; color: #1E40AF; }
.badge-vendedor { background: #DCFCE7; color: #166534; }
.badge-bodega { background: var(--naranja-light); color: #92400E; }

.usuario-permisos-resumen {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  padding: 8px;
  background: var(--gris-light);
  border-radius: 8px;
}
.perm-dot {
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 6px;
  transition: var(--transition);
}
.perm-dot.on { background: #DCFCE7; }
.perm-dot.off { background: var(--rojo-light); opacity: 0.4; filter: grayscale(1); }

.usuario-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.usuario-actions { display: flex; gap: 6px; }

/* ── PERMISOS GRID (Modal toggles) ── */
.permisos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.permiso-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  -webkit-user-select: none;
}
.permiso-toggle:hover { border-color: var(--azul-light); }
.permiso-toggle.activo {
  border-color: var(--verde);
  background: #F0FDF4;
}
.permiso-icon { font-size: 18px; flex-shrink: 0; }
.permiso-label { font-size: 12px; font-weight: 600; color: var(--texto); flex: 1; }
.permiso-switch { flex-shrink: 0; }
.switch-track {
  width: 36px;
  height: 20px;
  background: #CBD5E1;
  border-radius: 10px;
  position: relative;
  transition: var(--transition);
}
.permiso-toggle.activo .switch-track { background: var(--verde); }
.switch-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.permiso-toggle.activo .switch-thumb { left: 18px; }

/* ══════════════════════════════════════
   RESPONSIVE — Admin
   ══════════════════════════════════════ */
@media (min-width: 601px) {
  .usuarios-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1025px) {
  .usuarios-grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 600px) {
  .permisos-grid { grid-template-columns: 1fr; }
  .permiso-toggle { padding: 8px 10px; }
  .permiso-label { font-size: 11px; }
}

/* ══════════════════════════════════════
   MÓDULO RUTAS
   ══════════════════════════════════════ */
.ruta-card {
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s;
}
.ruta-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.ruta-inactiva  { opacity: 0.6; background: #F8FAFC; }
.ruta-header    { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ruta-nombre    { font-weight: 700; font-size: 15px; color: var(--azul); margin-bottom: 3px; }
.ruta-meta      { font-size: 12px; color: var(--gris); margin-top: 2px; }
.ruta-acciones  { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.ruta-badge     { font-size: 11px; padding: 3px 9px; border-radius: 12px; font-weight: 600; }
.badge-verde    { background: #DCFCE7; color: #166534; }
.badge-gris     { background: #F1F5F9; color: var(--gris); }

/* ══════════════════════════════════════
   PRINT
   ══════════════════════════════════════ */
@media print {
  body { background: white; }
  .header, .nav-tabs, .no-print { display: none !important; }
  .modal-overlay { position: static; background: none; backdrop-filter: none; padding: 0; }
  .modal { box-shadow: none; max-width: 100%; padding: 0; border-radius: 0; }
  .factura-print { box-shadow: none; max-width: 100%; padding: 0; }
  .factura-print .membrete { border-bottom-color: #000; }
  .factura-print table th { background: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ══ LISTA GLOBAL DE PRECIOS ══ */
.btn-lista-g {
  padding: 6px 12px;
  border: 1.5px solid #CBD5E1;
  border-radius: 20px;
  background: white;
  color: #475569;
  font-family: Montserrat, sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-lista-g:hover  { border-color: #1A3C8F; color: #1A3C8F; background: #EFF6FF; }
.btn-lista-g.activa { border-color: #1A3C8F; background: #1A3C8F; color: white; }

/* === ABONOS V2 === */
.ab-kpi-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;padding:20px 20px 0}
@media(max-width:700px){.ab-kpi-grid{grid-template-columns:1fr}}
.ab-kpi-card{background:#fff;border-radius:12px;padding:18px 20px;border-left:4px solid transparent;box-shadow:0 2px 8px rgba(0,0,0,.07)}
.ab-kpi-blue{border-left-color:#1A3C8F}.ab-kpi-orange{border-left-color:#f59e0b}.ab-kpi-red{border-left-color:#ef4444}
.ab-kpi-label{font-size:10px;font-weight:700;letter-spacing:1.2px;color:var(--gris);text-transform:uppercase;margin-bottom:8px}
.ab-kpi-val{font-size:24px;font-weight:800;color:#1e293b;letter-spacing:-.5px}
.ab-kpi-sub{font-size:11px;color:var(--gris);font-weight:500;margin-top:4px}
.ab-aging-bar{display:flex;height:12px;border-radius:99px;overflow:hidden;background:#f1f5f9;margin-bottom:10px}
.ab-aging-seg{height:100%;min-width:2px;transition:width .5s ease}
.ab-aging-legend{display:flex;flex-wrap:wrap;gap:12px}
.ab-aging-leg-item{display:flex;align-items:center;gap:5px;font-size:12px;font-weight:600}
.ab-aging-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}
.ab-tag{display:inline-block;padding:2px 8px;border-radius:99px;font-size:10px;font-weight:700;letter-spacing:.5px}
.ab-tag-mora{background:#fee2e2;color:#dc2626}.ab-tag-vencido{background:#fff7ed;color:#ea580c}.ab-tag-aldia{background:#dcfce7;color:#16a34a}
.ab-factura-row{display:flex;align-items:flex-start;padding:14px 16px;border:1.5px solid var(--borde);border-radius:10px;margin-bottom:10px;background:#fafafa;gap:12px}
.ab-factura-row:hover{border-color:#1A3C8F;background:#f0f4ff}
.ab-monto-input{width:110px;text-align:right;font-size:15px;font-weight:800;color:var(--verde-dark);border:2px solid var(--borde);border-radius:8px;padding:6px 10px;font-family:'Montserrat',sans-serif;background:#fff;outline:none;transition:border-color .2s}
.ab-monto-input:focus{border-color:#1A3C8F}
.ab-total-row{display:flex;justify-content:space-between;align-items:center;background:#f0f9f4;border:1.5px solid #bbf7d0;border-radius:10px;padding:12px 16px;font-size:14px;font-weight:700;color:#166534}
.progress-bar-wrap{height:6px;background:#e2e8f0;border-radius:99px;overflow:hidden;margin-bottom:2px}
.progress-bar-fill{height:100%;background:linear-gradient(90deg,#1A3C8F,#2251b8);border-radius:99px;transition:width .4s ease}

/* ABONOS-V3 */
.ab-kpi-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;padding:20px 20px 0}
@media(max-width:700px){.ab-kpi-grid{grid-template-columns:1fr}}
.ab-kpi-card{background:#fff;border-radius:12px;padding:18px 20px;border-left:4px solid transparent;box-shadow:0 2px 8px rgba(0,0,0,.07)}
.ab-kpi-blue{border-left-color:#1A3C8F}.ab-kpi-orange{border-left-color:#f59e0b}.ab-kpi-red{border-left-color:#ef4444}
.ab-kpi-label{font-size:10px;font-weight:700;letter-spacing:1.2px;color:var(--gris);text-transform:uppercase;margin-bottom:8px}
.ab-kpi-val{font-size:24px;font-weight:800;color:#1e293b;letter-spacing:-.5px}
.ab-kpi-sub{font-size:11px;color:var(--gris);font-weight:500;margin-top:4px}
.ab-aging-bar{display:flex;height:12px;border-radius:99px;overflow:hidden;background:#f1f5f9;margin-bottom:10px}
.ab-aging-seg{height:100%;min-width:2px;transition:width .5s ease}
.ab-aging-legend{display:flex;flex-wrap:wrap;gap:12px}
.ab-aging-leg-item{display:flex;align-items:center;gap:5px;font-size:12px;font-weight:600}
.ab-aging-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}
.ab-tag{display:inline-block;padding:2px 8px;border-radius:99px;font-size:10px;font-weight:700;letter-spacing:.5px}
.ab-tag-mora{background:#fee2e2;color:#dc2626}.ab-tag-vencido{background:#fff7ed;color:#ea580c}.ab-tag-aldia{background:#dcfce7;color:#16a34a}
.ab-factura-row{display:flex;align-items:flex-start;padding:14px 16px;border:1.5px solid var(--borde);border-radius:10px;margin-bottom:10px;background:#fafafa;gap:12px}
.ab-factura-row:hover{border-color:#1A3C8F;background:#f0f4ff}
.ab-monto-input{width:110px;text-align:right;font-size:15px;font-weight:800;color:var(--verde-dark);border:2px solid var(--borde);border-radius:8px;padding:6px 10px;font-family:'Montserrat',sans-serif;background:#fff;outline:none;transition:border-color .2s}
.ab-monto-input:focus{border-color:#1A3C8F}
.ab-total-row{display:flex;justify-content:space-between;align-items:center;background:#f0f9f4;border:1.5px solid #bbf7d0;border-radius:10px;padding:12px 16px;font-size:14px;font-weight:700;color:#166534}
.progress-bar-wrap{height:6px;background:#e2e8f0;border-radius:99px;overflow:hidden;margin-bottom:2px}
.progress-bar-fill{height:100%;background:linear-gradient(90deg,#1A3C8F,#2251b8);border-radius:99px;transition:width .4s ease}

/* ABONOS-V4 */
.ab-kpi-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;padding:20px 20px 0}
@media(max-width:700px){.ab-kpi-grid{grid-template-columns:1fr}}
.ab-kpi-card{background:#fff;border-radius:12px;padding:18px 20px;border-left:4px solid transparent;box-shadow:0 2px 8px rgba(0,0,0,.07)}
.ab-kpi-blue{border-left-color:#1A3C8F}.ab-kpi-orange{border-left-color:#f59e0b}.ab-kpi-red{border-left-color:#ef4444}
.ab-kpi-label{font-size:10px;font-weight:700;letter-spacing:1.2px;color:var(--gris);text-transform:uppercase;margin-bottom:8px}
.ab-kpi-val{font-size:24px;font-weight:800;color:#1e293b;letter-spacing:-.5px}
.ab-kpi-sub{font-size:11px;color:var(--gris);font-weight:500;margin-top:4px}
.ab-aging-bar{display:flex;height:12px;border-radius:99px;overflow:hidden;background:#f1f5f9;margin-bottom:10px}
.ab-aging-seg{height:100%;min-width:2px;transition:width .5s ease}
.ab-aging-legend{display:flex;flex-wrap:wrap;gap:12px}
.ab-aging-leg-item{display:flex;align-items:center;gap:5px;font-size:12px;font-weight:600}
.ab-aging-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}
.ab-tag{display:inline-block;padding:2px 8px;border-radius:99px;font-size:10px;font-weight:700;letter-spacing:.5px}
.ab-tag-mora{background:#fee2e2;color:#dc2626}.ab-tag-vencido{background:#fff7ed;color:#ea580c}.ab-tag-aldia{background:#dcfce7;color:#16a34a}
.ab-factura-row{display:flex;align-items:flex-start;padding:14px 16px;border:1.5px solid var(--borde);border-radius:10px;margin-bottom:10px;background:#fafafa;gap:12px}
.ab-factura-row:hover{border-color:#1A3C8F;background:#f0f4ff}
.ab-monto-input{width:110px;text-align:right;font-size:15px;font-weight:800;color:var(--verde-dark);border:2px solid var(--borde);border-radius:8px;padding:6px 10px;font-family:Montserrat,sans-serif;background:#fff;outline:none;transition:border-color .2s}
.ab-monto-input:focus{border-color:#1A3C8F}
.ab-total-row{display:flex;justify-content:space-between;align-items:center;background:#f0f9f4;border:1.5px solid #bbf7d0;border-radius:10px;padding:12px 16px;font-size:14px;font-weight:700;color:#166534}
.progress-bar-wrap{height:6px;background:#e2e8f0;border-radius:99px;overflow:hidden;margin-bottom:2px}
.progress-bar-fill{height:100%;background:linear-gradient(90deg,#1A3C8F,#2251b8);border-radius:99px;transition:width .4s ease}
