/* ═══════════════════════════════════════════════════
   KINETIX BILLING SYSTEM — styles.css v2
   Estilo: Apple-inspired · Grises refinados · Azul eléctrico
════════════════════════════════════════════════════ */

/* ── Variables del sistema ── */
:root {
  --blue:        #1a6fd4;
  --blue-light:  #3b8fe8;
  --blue-dark:   #0d4fa0;
  --blue-ghost:  #eef4fd;
  --blue-glow:   rgba(26, 111, 212, 0.14);

  /* Grises refinados — escala de 7 niveles */
  --bg:          #f0f2f5;      /* fondo general — gris frío */
  --bg-2:        #e8eaed;      /* fondo secundario */
  --surface:     #ffffff;      /* tarjetas y modales */
  --surface-2:   #f7f8fa;      /* filas alternas, inputs */
  --surface-3:   #f0f2f5;      /* headers de tabla */

  --border:      rgba(0, 0, 0, 0.07);
  --border-md:   rgba(0, 0, 0, 0.11);
  --border-dark: rgba(0, 0, 0, 0.16);

  --text-1:      #1a1a1c;      /* titulos principales */
  --text-2:      #48484a;      /* texto normal */
  --text-3:      #8a8a8e;      /* placeholders y labels */
  --text-4:      #aeaeb2;      /* texto deshabilitado */
  --text-inv:    #ffffff;

  --warning:     #d97706;
  --warning-bg:  #fef3c7;
  --danger:      #dc2626;
  --danger-bg:   #fee2e2;
  --success:     #16a34a;
  --success-bg:  #dcfce7;

  --sidebar-w:   248px;
  --topbar-h:    62px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;

  --shadow-xs:   0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:   0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.06);

  --transition:  all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: linear-gradient(180deg, #f7f8fa 0%, #eef1f5 100%);
  border-right: 1px solid rgba(16,24,40,0.08);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  width: 100%;
  padding: 20px 16px 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid rgba(16,24,40,0.06);
  min-height: 84px;
}

.logo-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 136px;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: none;
}

/* ── Navegación ── */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: rgba(15,23,42,0.68);
  font-size: 14px;
  font-weight: 400;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(15,23,42,0.05);
  color: rgba(15,23,42,0.92);
}

.nav-item.active {
  background: var(--blue);
  color: #ffffff;
  font-weight: 500;
  box-shadow: 0 8px 18px rgba(26,111,212,0.22);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-label { flex: 1; white-space: nowrap; }

.nav-badge {
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
  display: none;
}
.nav-badge.visible { display: inline-block; }

/* ── Footer sidebar ── */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(16,24,40,0.06);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.76);
  border: 1px solid rgba(16,24,40,0.08);
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-light), var(--blue-dark));
  color: white;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon,
.nav-label {
  color: inherit;
}

.nav-icon svg {
  stroke: currentColor;
}

.facturador-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.canal-venta-select {
  min-width: 150px;
  padding-left: 14px;
  padding-right: 14px;
  flex: 1 1 auto;
}

.brand-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,248,250,0.9));
  border: 1px solid rgba(16,24,40,0.08);
}

.brand-chip.compact {
  padding: 6px;
  flex: 0 0 auto;
}

.brand-chip .brand-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-chip .brand-kicker {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-chip .brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(26,111,212,0.08), rgba(26,111,212,0.18));
  border: 1px solid rgba(26,111,212,0.14);
  color: var(--blue-dark);
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 0.22s ease, opacity 0.22s ease, background 0.22s ease;
}

.brand-mark-compact {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: #f5f5f7;
  border: 1px solid rgba(16,24,40,0.06);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.brand-mark span {
  font-size: 14px;
}

.brand-mark svg {
  width: 28px;
  height: 28px;
}

.company-logo-preview {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 58px;
}

.company-logo-preview .brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
}

.variant-pill {
  border: 1px solid var(--border-md);
  background: #fff;
  color: var(--text-1);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  line-height: 1;
  transition: all .18s ease;
}

.variant-pill:hover:not(:disabled),
.variant-pill.active {
  border-color: rgba(37,99,235,.28);
  background: rgba(37,99,235,.08);
  color: var(--text-1);
}

.variant-pill:disabled {
  pointer-events: none;
}

.conta-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .facturador-brand-row,
  .conta-2col {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}

.user-info { display: flex; flex-direction: column; overflow: hidden; }

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-ruc { font-size: 11px; color: rgba(255,255,255,0.4); }

/* ═══════════════════════════════════════════════════
   CONTENIDO PRINCIPAL
════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: rgba(240,242,245,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-md);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-title {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

.topbar-date { font-size: 13px; color: var(--text-3); }

/* ── Páginas ── */
.page {
  display: none;
  padding: 26px 28px;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.22s ease;
}

.page.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* 1. Asegurar la cabecera de la tarjeta con Flexbox alineado */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px; /* Reducido un poco para dar más simetría estilo Apple */
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  gap: 16px;
}

/* 2. Forzar a que las acciones (buscador y botón) no se desnivelen */
.card-actions {
  display: flex;
  align-items: center;
  gap: 12px; /* Espaciado uniforme entre buscador y botón */
}

/* 3. Evitar que el buscador se estire de golpe de manera agresiva */
.input-search {
  height: 36px;
  padding: 0 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  outline: none;
  transition: var(--transition);
  width: 210px;
}

/* Ajuste sutil al hacer foco en el buscador sin romper el espacio del botón */
.input-search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
  width: 240px; /* Cambiado de 270px a 240px para que no empuje el botón bruscamente */
  background: var(--surface);
}

/* 4. Asegurar que la tabla y sus columnas se distribuyan simétricamente */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed; /* 💡 CLAVE: Esto obliga al navegador a respetar anchos fijos */
}

/* Asignamos pesos visuales fijos a las columnas para que JavaScript no las deforme */
.data-table th:nth-child(1) { width: 12%; } /* Código */
.data-table th:nth-child(2) { width: 28%; } /* Producto */
.data-table th:nth-child(3) { width: 15%; } /* Categoría */
.data-table th:nth-child(4) { width: 12%; } /* Precio */
.data-table th:nth-child(5) { width: 10%; } /* Stock */
.data-table th:nth-child(6) { width: 13%; } /* Estado */
.data-table th:nth-child(7) { width: 10%; } /* Acciones (Botones) */

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-md);
}

.data-table td {
  padding: 12px 16px;
  color: var(--text-1);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  /* Si el texto del producto es muy largo, no romperá la estructura */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; 
}

/* ═══════════════════════════════════════════════════
   STATS GRID
════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-dark);
}

.stat-card:hover::before { opacity: 1; }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.5px;
}

.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }
.stat-value.success { color: var(--success); }

/* ═══════════════════════════════════════════════════
   TABLAS GENERALES OPTIMIZADAS
════════════════════════════════════════════════════ */
.table-wrapper { 
  overflow-x: auto; 
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed; /* 💡 OBLIGA al navegador a respetar las medidas de las columnas */
}

.data-table thead tr {
  background: var(--surface-3); /* El fondo gris de los encabezados */
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-md);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  color: var(--text-1);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* Si un nombre de cliente es larguísimo, añade '...' en vez de romper la línea */
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--blue-ghost); }

.empty-row td {
  text-align: center;
  color: var(--text-3);
  padding: 48px;
  font-size: 14px;
}

/* ── CONFIGURACIÓN DE COLUMNAS ESPECÍFICAS ── 
   Aquí le damos el control matemático al diseño para que no dependa de JS */

/* 1. Tabla de Inventario */
#tabla-inventario th:nth-child(1) { width: 12%; } /* Código */
#tabla-inventario th:nth-child(2) { width: 28%; } /* Producto */
#tabla-inventario th:nth-child(3) { width: 15%; } /* Categoría */
#tabla-inventario th:nth-child(4) { width: 11%; } /* Precio */
#tabla-inventario th:nth-child(5) { width: 9%; }  /* Stock */
#tabla-inventario th:nth-child(6) { width: 12%; } /* Estado */
#tabla-inventario th:nth-child(7) { width: 13%; } /* Acciones */

/* 2. Tabla de Historial de Facturas (Corrigiendo el desfase) */
#tabla-historial th:nth-child(1) { width: 15%; } /* N° Factura */
#tabla-historial th:nth-child(2) { width: 13%; } /* Fecha */
#tabla-historial th:nth-child(3) { width: 22%; } /* Cliente */
#tabla-historial th:nth-child(4) { width: 12%; } /* Vendedor / Rol */
#tabla-historial th:nth-child(5) { width: 10%; } /* Total */
#tabla-historial th:nth-child(6) { width: 13%; } /* Estado SRI */
#tabla-historial th:nth-child(7) { width: 15%; } /* Acciones (Ver / PDF) */

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-info    { background: var(--blue-ghost);  color: var(--blue-dark); }

/* ═══════════════════════════════════════════════════
   FORMULARIOS
════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 22px 14px;
}

.form-group:first-of-type { padding-top: 18px; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input {
  width: 100%;
  height: 40px;
  padding: 0 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  outline: none;
  transition: var(--transition);
  appearance: none;
}

.form-input:hover  { border-color: var(--blue-light); background: var(--surface); }
.form-input:focus  { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 3px var(--blue-glow); }
.form-input::placeholder { color: var(--text-4); }

select.form-input {
  cursor: pointer;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-row { display: flex; gap: 8px; }
.input-row .form-input { flex: 1; }

.input-search {
  height: 36px;
  padding: 0 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  outline: none;
  transition: var(--transition);
  width: 210px;
}

.input-search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
  width: 270px;
  background: var(--surface);
}

/* ═══════════════════════════════════════════════════
   BOTONES
════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.btn-primary:hover {
  background: var(--blue-light);
  border-color: var(--blue-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--blue-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-dark);
}
.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--blue-light);
}

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-3);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.btn-icon:hover { background: var(--blue-ghost); color: var(--blue); }

.btn-full { width: 100%; }

/* ═══════════════════════════════════════════════════
   FACTURADOR
════════════════════════════════════════════════════ */
.billing-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.billing-left { display: flex; flex-direction: column; gap: 20px; }

.product-results {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 22px 16px;
}

.product-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: var(--transition);
}

.product-result-item:hover {
  background: var(--blue-ghost);
  border-color: var(--blue-light);
}

.product-result-name  { font-size: 14px; font-weight: 500; }
.product-result-price { font-size: 14px; color: var(--blue); font-weight: 700; }

/* ── Carrito ── */
.cart-card { display: flex; flex-direction: column; }
.cart-count { font-size: 13px; color: var(--text-3); }

.cart-items {
  flex: 1;
  padding: 12px 22px;
  min-height: 120px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
}

.cart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  color: var(--text-3);
  font-size: 14px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-md);
  box-shadow: var(--shadow-xs);
}

.cart-item-name  { flex: 1; font-size: 13px; font-weight: 500; }
.cart-item-qty   { display: flex; align-items: center; gap: 6px; }
.cart-item-price { font-size: 13px; font-weight: 700; color: var(--blue); min-width: 64px; text-align: right; }
.cart-item-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-4); font-size: 15px; line-height: 1;
  padding: 3px 5px; border-radius: 4px; transition: var(--transition);
}
.cart-item-remove:hover { color: var(--danger); background: var(--danger-bg); }

.cart-totals {
  padding: 14px 22px;
  border-top: 1px solid var(--border-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-2);
}

.total-final {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  padding-top: 10px;
  border-top: 2px solid var(--border-md);
  margin-top: 4px;
}

.cart-actions {
  padding: 14px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ═══════════════════════════════════════════════════
   AJUSTES
════════════════════════════════════════════════════ */
.ajustes-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ═══════════════════════════════════════════════════
   ALERTAS
════════════════════════════════════════════════════ */
.alertas-list {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alerta-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-md);
  background: var(--surface-2);
}

.alerta-item.danger  { border-color: #fca5a5; background: #fff5f5; }
.alerta-item.warning { border-color: #fcd34d; background: #fffbeb; }

.alerta-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.alerta-item.danger  .alerta-dot { background: var(--danger); }
.alerta-item.warning .alerta-dot { background: var(--warning); }

.alerta-text { font-size: 14px; font-weight: 500; color: var(--text-1); }
.alerta-sub  { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px;
  color: var(--text-3);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════
   MODALES
════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  animation: overlayIn 0.18s ease;
}

.modal-overlay.open { display: flex; }

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  border: 1px solid var(--border-md);
  animation: modalIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-md);
  background: var(--surface-2);
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--text-1); }

.btn-close {
  background: var(--surface-3);
  border: 1px solid var(--border-md);
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-3);
  font-size: 13px;
  transition: var(--transition);
}
.btn-close:hover { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }

.modal-body { padding-bottom: 4px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-md);
  background: var(--surface-2);
}

/* ═══════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 17px;
  background: #1c1c1e;
  color: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
  border: 1px solid rgba(255,255,255,0.08);
}

.toast.success { background: #14532d; border-color: rgba(255,255,255,0.1); }
.toast.warning { background: #78350f; border-color: rgba(255,255,255,0.1); }
.toast.danger  { background: #7f1d1d; border-color: rgba(255,255,255,0.1); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(16px); }
}
.toast.removing { animation: toastOut 0.22s ease forwards; }

/* ═══════════════════════════════════════════════════
   SCROLLBAR
════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════════════════
   UTILIDADES
════════════════════════════════════════════════════ */
.text-muted { color: var(--text-3); }
.text-blue  { color: var(--blue); }
.text-sm    { font-size: 13px; }
.fw-600     { font-weight: 600; }
.mt-1       { margin-top: 8px; }
.mt-2       { margin-top: 16px; }

/* ═══════════════════════════════════════════════════
   ESCÁNER DE CÁMARA
════════════════════════════════════════════════════ */
#qr-reader {
  border: none !important;
}

#qr-reader video {
  border-radius: 0 0 16px 16px;
  object-fit: cover;
}

#qr-reader__dashboard,
#qr-reader__dashboard_section {
  display: none !important;
}

/* Animación de carga */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Ocultar texto en móviles */
@media (max-width: 600px) {
  .hide-mobile { display: none !important; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 62px; }
  .nav-label, .user-info { display: none; }
  .sidebar-logo .logo-img { max-width: 36px; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-logo { justify-content: center; padding: 18px 0; }
  .user-card { justify-content: center; padding: 8px; }
  .billing-layout  { grid-template-columns: 1fr; }
  .ajustes-layout  { grid-template-columns: 1fr; }
  .input-search    { width: 170px; }
  .input-search:focus { width: 210px; }
}
