/*
  Estilos del panel ERP (tema oscuro).
  Colores:
  - Fondo: #0f172a
  - Panels: #1e293b
  - Acento: #06b6d4
*/

:root {
  --erp-bg: #040404;
  --erp-panel: #01284f;
  --erp-accent: #00b5fa;
  --erp-accent2: #0055b2;
  --erp-text: #e4e2e3;
  --erp-text2: #646567;
  --erp-success: #22c55e;
  --erp-danger: #ef4444;
  --erp-warning: #f59e0b;
  --erp-border: rgba(0, 181, 250, 0.22);
}

body.erp {
  background: var(--erp-bg);
  color: var(--erp-text);
}

.btn-erp-cyan {
  background: rgba(0, 181, 250, 0.18);
  border-color: rgba(0, 181, 250, 0.40);
  color: var(--erp-text);
  font-weight: 800;
}

.btn-erp-cyan:hover {
  filter: brightness(1.08);
  color: var(--erp-text);
}

.erp-login-subtitle {
  color: var(--erp-text2);
}

.erp-login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.erp-input {
  background: rgba(1, 40, 79, 0.45);
  border: 1px solid rgba(100, 101, 103, 0.35);
  color: var(--erp-text);
}

.erp-input:focus {
  background: rgba(1, 40, 79, 0.60);
  border-color: rgba(0, 127, 182, 0.85);
  box-shadow: 0 0 0 0.2rem rgba(0, 181, 250, 0.14);
  color: var(--erp-text);
}

.erp-check .form-check-input {
  background-color: rgba(1, 40, 79, 0.45);
  border-color: rgba(100, 101, 103, 0.45);
}

.erp-check .form-check-input:checked {
  background-color: rgba(0, 181, 250, 0.95);
  border-color: rgba(0, 181, 250, 0.95);
}

.erp-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(0, 181, 250, 0.18);
  border: 1px solid rgba(0, 181, 250, 0.40);
  color: var(--erp-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.erp-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--erp-bg);
  border-right: 1px solid rgba(100, 101, 103, 0.35);
  z-index: 1030;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.erp-sidebar .brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(100, 101, 103, 0.35);
}

.erp-sidebar .brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(1, 40, 79, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--erp-accent);
}

.erp-sidebar .brand .name {
  font-weight: 800;
  letter-spacing: 0.3px;
}

.erp-sidebar .nav-section {
  padding: 14px 12px 6px;
  color: var(--erp-text2);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}

.erp-sidebar .nav a {
  color: var(--erp-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 4px 8px;
}

.erp-sidebar .nav a .bi {
  color: var(--erp-text2);
}

.erp-sidebar .nav a:hover {
  background: rgba(30, 41, 59, 0.8);
}

.erp-sidebar .nav a.active {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid var(--erp-border);
}

.erp-sidebar .nav a.active .bi {
  color: var(--erp-accent);
}

.erp-sidebar .badge-soon {
  background: rgba(148, 163, 184, 0.15);
  color: var(--erp-text2);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.erp-main {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.erp-navbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--erp-panel);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.erp-navbar .page-title {
  font-weight: 700;
}

.erp-card {
  background: var(--erp-panel);
  border: 1px solid var(--erp-border);
  border-radius: 14px;
}

a.erp-kpi-link {
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

a.erp-kpi-link:hover {
  transform: translateY(-2px);
  border-color: var(--erp-accent);
  box-shadow: 0 4px 12px rgba(0, 181, 250, 0.15);
}

.erp-metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.erp-metric .label {
  color: var(--erp-text2);
  font-size: 0.85rem;
}

.erp-metric .value {
  font-size: 1.4rem;
  font-weight: 800;
}

.erp-metric .trend {
  color: var(--erp-accent);
  font-size: 0.85rem;
}

.erp-table {
  color: var(--erp-text);
  font-size: 0.875rem;
  --bs-table-bg: transparent;
  --bs-table-color: var(--erp-text);
  margin-bottom: 0;
}

.erp-table thead th {
  color: var(--erp-accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--erp-border);
  background: rgba(1, 40, 79, 0.5);
  white-space: nowrap;
}

.erp-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  vertical-align: middle;
}

.erp-table tbody tr {
  transition: background 0.15s;
}

/* Sortable headers */
.erp-table thead th[style*="cursor"] {
  transition: color 0.15s;
}

.erp-table thead th[style*="cursor"]:hover {
  color: var(--erp-accent);
}

.erp-table thead th .sort-arrow {
  transition: opacity 0.15s;
}

.erp-table tbody tr:hover {
  background: rgba(0, 181, 250, 0.06);
}

.erp-table tbody tr:nth-child(even) {
  background: rgba(1, 40, 79, 0.2);
}

.erp-table tbody tr:nth-child(even):hover {
  background: rgba(0, 181, 250, 0.08);
}

.erp-table .prod-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.erp-table .prod-status.activo {
  background: rgba(34, 197, 94, 0.12);
  color: var(--erp-success);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.erp-table .prod-status.inactivo {
  background: rgba(239, 68, 68, 0.12);
  color: var(--erp-danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.erp-table img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--erp-border);
}

.erp-table .prod-row-alerta td:first-child {
  border-left: 3px solid var(--erp-warning);
}

/* Pagination dark theme */
.pagination .page-link {
  background: var(--erp-panel);
  border-color: var(--erp-border);
  color: var(--erp-text);
  font-size: 0.8rem;
  padding: 4px 10px;
}

.pagination .page-link:hover {
  background: rgba(0, 181, 250, 0.15);
  border-color: var(--erp-accent);
  color: var(--erp-accent);
}

.pagination .page-item.active .page-link {
  background: var(--erp-accent);
  border-color: var(--erp-accent);
  color: #fff;
  font-weight: 700;
}

.pagination .page-item.disabled .page-link {
  background: rgba(1, 40, 79, 0.3);
  border-color: rgba(148, 163, 184, 0.1);
  color: var(--erp-text2);
}

/* Table info text */
.erp-table-info {
  font-size: 0.8rem;
  color: var(--erp-text2);
}

/* Fix: botón celeste con texto negro (mejor contraste) */
.btn-info {
  color: #000 !important;
}

.btn-info:hover,
.btn-info:focus,
.btn-info:active {
  color: #000 !important;
}

/* ══════════════════════════════════════════════
   CONTRASTE GLOBAL: fondo oscuro = texto claro
   ══════════════════════════════════════════════ */

/* Textos Bootstrap que son oscuros por defecto */
.erp .text-muted,
.erp .text-secondary,
.erp-table .text-muted,
.erp-table .text-secondary {
  color: #94a3b8 !important;
}

/* Labels de formularios */
.erp .form-label,
.erp .form-check-label,
.erp label {
  color: #c8ccd0;
}

/* Inputs: fondo oscuro, texto claro, iconos visibles */
.erp input[type="date"],
.erp input[type="time"],
.erp input[type="datetime-local"],
.erp .form-select,
.erp .form-control {
  color-scheme: dark;
}

.erp .input-group-text {
  color: #94a3b8;
}

/* Placeholders */
.erp .form-control::placeholder {
  color: #64748b;
}

/* Badges: siempre legibles */
.erp .badge.bg-info {
  color: #000 !important;
}

.erp .badge.bg-success,
.erp .badge.bg-danger,
.erp .badge.bg-warning {
  color: #000 !important;
}

.erp .badge.bg-secondary {
  color: #e4e2e3 !important;
}

/* Badge modo (COMPROBANTE SUNAT / PROFORMA) */
.erp .badge.bg-info.bg-opacity-10,
.erp .badge.bg-warning.bg-opacity-10 {
  color: #fff !important;
}

/* Nav pills / tabs */
.erp .nav-pills .nav-link,
.erp .nav-tabs .nav-link,
.erp .erp-tabs .nav-link {
  color: #94a3b8;
}

.erp .nav-pills .nav-link.active {
  background: var(--erp-accent);
  color: #000;
}

.erp .nav-pills .nav-link:not(.active):hover {
  color: #fff;
}

.erp .erp-tabs .nav-link.active {
  color: #fff;
  border-bottom-color: var(--erp-accent);
}

/* Botones outline */
.erp .btn-outline-info {
  color: var(--erp-accent);
  border-color: var(--erp-accent);
}

.erp .btn-outline-info:hover {
  background: var(--erp-accent);
  color: #000;
}

.erp .btn-outline-light:hover,
.erp .btn-outline-light:focus {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.erp .btn-outline-light:hover i,
.erp .btn-outline-light:focus i {
  color: #fff !important;
}

.erp .btn-outline-secondary {
  color: #94a3b8;
  border-color: #64748b;
}

.erp .btn-outline-secondary:hover {
  background: rgba(148, 163, 184, 0.15);
  color: #fff;
}

/* Dropdown menus */
.erp .dropdown-menu {
  background: var(--erp-panel);
  border-color: var(--erp-border);
}

.erp .dropdown-item {
  color: #e4e2e3;
}

.erp .dropdown-item:hover,
.erp .dropdown-item:focus {
  background: rgba(0, 181, 250, 0.1);
  color: #fff;
}

.erp .dropdown-header {
  color: #94a3b8;
}

.erp .dropdown-divider {
  border-color: rgba(148, 163, 184, 0.12);
}

/* Modal */
.erp .modal-content {
  color: #e4e2e3;
}

/* Alerts */
.erp .alert-success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.erp .alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.erp .alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

/* Form switch */
.erp .form-check-input {
  background-color: #1e293b;
  border-color: #475569;
}

.erp .form-check-input:checked {
  background-color: var(--erp-accent);
  border-color: var(--erp-accent);
}

/* Totales en facturación */
.erp .small.text-secondary,
.erp .small.text-danger {
  color: #94a3b8 !important;
}

.erp .small.text-danger {
  color: #fca5a5 !important;
}

/* Alertas dropdown: header blanco */
#alertasDropdown .dropdown-header {
  color: #fff !important;
  font-weight: 700;
}

/* Fix: links en tablas sin subrayado */
.erp-table a {
  text-decoration: none;
}

.erp-table a:hover {
  text-decoration: none;
  filter: brightness(1.2);
}

/* Fix: alinear acciones a la derecha */
.erp-table th.text-end,
.erp-table td.text-end,
table.erp-table thead tr th.text-end,
table.erp-table tbody tr td.text-end {
  text-align: right !important;
  white-space: nowrap;
}

.erp-table td.text-end .btn {
  vertical-align: middle;
}

.erp-table .fila-prod:hover,
.erp-table .fila-prod.table-active {
  background: rgba(0, 181, 250, 0.12);
}

.erp-table .fila-prod.fila-sin-stock:hover {
  background: rgba(239, 68, 68, 0.08);
}

.erp-table .fila-prod.flash-error {
  animation: flashRed 0.3s ease 2;
}

@keyframes flashRed {
  0%, 100% { background: transparent; }
  50% { background: rgba(239, 68, 68, 0.25); }
}

.erp-table .fila-prod.table-active {
  outline: 1px solid rgba(0, 181, 250, 0.35);
}

#panel-busqueda-productos {
  border: 1px solid var(--erp-border);
  border-radius: 8px;
}

#panel-busqueda-productos thead {
  background: var(--erp-panel);
}

.badge-estado {
  font-weight: 700;
}

.badge-aceptado {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--erp-success);
}

.badge-pendiente {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--erp-warning);
}

.badge-rechazado {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--erp-danger);
}

.erp-actions .btn {
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
}

.erp-actions .btn-primary {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.35);
  color: #dbeafe;
}

.erp-actions .btn-accent {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.35);
  color: #cffafe;
}

.erp-actions .btn-success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.35);
  color: #dcfce7;
}

.erp-actions .btn:hover {
  filter: brightness(1.08);
}

/* ── Tiles módulos (estilo Keyfacil) ── */
.erp-tile {
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  transition: transform 120ms, box-shadow 120ms;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.erp-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  color: #fff;
}
.erp-tile:active { transform: scale(0.97); }
.erp-tile i { font-size: 1.6rem; }

.erp-tile-venta {
  background: linear-gradient(135deg, #e91e63, #c2185b);
}
.erp-tile-ventas-list {
  background: linear-gradient(135deg, #4caf50, #388e3c);
}
.erp-tile-proformas {
  background: linear-gradient(135deg, #f44336, #d32f2f);
}
.erp-tile-productos {
  background: linear-gradient(135deg, #607d8b, #455a64);
}
.erp-tile-clientes {
  background: linear-gradient(135deg, #3f51b5, #303f9f);
}
.erp-tile-guias {
  background: linear-gradient(135deg, #9c27b0, #7b1fa2);
}
.erp-tile-compras {
  background: linear-gradient(135deg, #00bcd4, #0097a7);
}
.erp-tile-reportes {
  background: linear-gradient(135deg, #ff9800, #f57c00);
}
.erp-tile-nueva-proforma {
  background: linear-gradient(135deg, #ff9800, #f57c00);
}

/* ── Tiles secundarios ── */
.erp-tile-secondary {
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  color: var(--erp-text);
  font-weight: 600;
  font-size: 0.78rem;
  background: var(--erp-panel);
  border: 1px solid var(--erp-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 150ms;
}
.erp-tile-secondary:hover {
  background: rgba(6,182,212,0.12);
  color: var(--erp-text);
}
.erp-tile-secondary i {
  font-size: 1.2rem;
  color: var(--erp-accent);
}

/* ── Pills búsqueda cliente ── */
#seccion-buscar-cliente .nav-pills .nav-link {
  background: rgba(100,101,103,0.2);
  color: var(--erp-text2);
  border: 1px solid rgba(100,101,103,0.3);
  font-weight: 600;
}
#seccion-buscar-cliente .nav-pills .nav-link.active {
  background: var(--erp-accent2);
  color: #fff;
  border-color: var(--erp-accent2);
}

/* ── Tabs estilo Keyfacil ── */
.erp-tabs {
  background: var(--erp-accent2);
}
.erp-tabs .nav-link {
  color: rgba(255,255,255,0.6);
  border: none;
  border-radius: 0;
  padding: 14px 0;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  transition: all 150ms;
}
.erp-tabs .nav-link:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.06);
}
.erp-tabs .nav-link.active {
  background: transparent;
  color: #fff;
  border-bottom: 3px solid #fff;
}

/* ── Item cards (productos) ── */
.item-card {
  transition: box-shadow 150ms;
}
.item-card:hover {
  box-shadow: 0 0 0 1px var(--erp-accent);
}

/* Rojo visible sobre fondo oscuro (coral/salmón) */
.erp .text-stock-zero,
.erp-table .text-stock-zero {
  color: #ff6b6b !important;
}

.erp .btn-outline-coral {
  color: #ff6b6b;
  border-color: #ff6b6b;
}
.erp .btn-outline-coral:hover {
  background: #ff6b6b;
  color: #000;
}

.erp-footer {
  color: var(--erp-text2);
  padding: 16px 0;
}

/* ── Overlay para sidebar mobile ── */
.erp-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1029;
}
.erp-sidebar-overlay.show {
  display: block;
}

/* ══════════════════════════════════════════════
   RESPONSIVE: Tablet (≤991px)
   ══════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .erp-sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease-in-out;
  }
  .erp-sidebar.open {
    transform: translateX(0);
  }
  .erp-main {
    margin-left: 0;
  }

  .erp-card .row.g-3 > [class*="col-md-2"],
  .erp-card .row.g-3 > [class*="col-md-3"],
  .erp-card .row.g-3 > [class*="col-md-4"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  #buscar-producto { min-width: 0 !important; }
  #btn-emitir, #btnProcesarGuia { width: 100%; }

  .erp-navbar .page-title { font-size: 0.95rem; }

  /* Tiles un poco más compactos */
  .erp-tile { min-height: 90px; padding: 18px 12px; }
  .erp-tile i { font-size: 1.3rem; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE: Móvil (≤575px)
   ══════════════════════════════════════════════ */
@media (max-width: 575.98px) {
  /* ── Layout general ── */
  main.container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .erp-card {
    padding: 12px !important;
    border-radius: 10px;
  }

  /* ── Navbar ── */
  .erp-navbar {
    padding: 0 !important;
  }
  .erp-navbar .page-title {
    font-size: 0.85rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .erp-navbar a.btn,
  .erp-navbar button.btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }
  .erp-navbar .d-flex.align-items-center.gap-2 {
    gap: 0.3rem !important;
  }

  /* ── Títulos de sección ── */
  h5.fw-bold {
    font-size: 0.95rem;
  }
  h6.fw-bold {
    font-size: 0.85rem;
  }

  /* ── Formularios: campos apilados ── */
  .erp-card .row.g-3 > [class*="col-md"],
  .erp-card .row.g-3 > [class*="col-6"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Filtros de búsqueda apilados */
  .row.g-2 > .col,
  .row.g-2 > .col-auto {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Selects con min-width reset */
  select.form-select[style*="min-width"] {
    min-width: 0 !important;
    width: 100% !important;
  }

  .form-control, .form-select {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
  }
  .form-label {
    font-size: 0.78rem;
    margin-bottom: 0.2rem;
  }

  /* ── Tablas ── */
  .erp-table {
    font-size: 0.75rem;
  }
  .erp-table thead th {
    font-size: 0.65rem;
    padding: 6px 4px;
    letter-spacing: 0;
  }
  .erp-table tbody td {
    padding: 7px 4px;
  }
  .erp-table img {
    width: 24px;
    height: 24px;
  }

  /* Ocultar columnas menos importantes en móvil */
  .erp-table .d-none-mobile {
    display: none !important;
  }

  /* Botones de acción más pequeños */
  .erp-table .btn-sm,
  .btn-group-sm > .btn {
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
  }

  /* ── Paginación ── */
  .pagination .page-link {
    padding: 3px 7px;
    font-size: 0.7rem;
  }

  /* ── KPIs del dashboard ── */
  .erp-kpi-link,
  .erp-card.p-3.text-center {
    padding: 10px 8px !important;
  }
  .erp-kpi-link .small,
  .erp-card .small {
    font-size: 0.7rem;
  }
  .erp-card .fw-bold.fs-5,
  .erp-card .fw-bold.text-info {
    font-size: 0.95rem !important;
  }

  /* ── Tiles del dashboard ── */
  .erp-tile {
    min-height: 70px;
    padding: 14px 8px;
    font-size: 0.75rem;
    border-radius: 12px;
    gap: 4px;
  }
  .erp-tile i {
    font-size: 1.1rem;
  }

  .erp-tile-secondary {
    padding: 10px 6px;
    font-size: 0.7rem;
    gap: 3px;
  }
  .erp-tile-secondary i {
    font-size: 1rem;
  }

  /* ── Modales fullscreen en móvil ── */
  .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    min-height: 100vh;
  }
  .modal-dialog.modal-dialog-centered {
    align-items: stretch;
  }
  .modal-content {
    border-radius: 0 !important;
    min-height: 100vh;
  }
  .modal-body {
    max-height: none !important;
    overflow-y: auto;
  }
  .modal-lg {
    max-width: 100% !important;
  }

  /* ── Facturación ── */
  .erp-tabs .nav-link {
    font-size: 0.75rem;
    padding: 10px 4px;
  }
  #panel-busqueda-productos {
    max-height: 200px;
  }
  .item-card {
    padding: 10px !important;
  }
  .item-card .fw-bold {
    font-size: 0.85rem;
  }
  .item-card .small {
    font-size: 0.72rem;
  }
  .item-card .btn-sm {
    padding: 0.15rem 0.3rem;
    font-size: 0.65rem;
  }

  /* Tabla búsqueda productos en facturación */
  #tabla-productos-factura {
    font-size: 0.72rem;
  }
  #tabla-productos-factura th,
  #tabla-productos-factura td {
    padding: 5px 3px;
  }

  /* ── Botones principales full width ── */
  #btn-emitir,
  #btn-ir-productos,
  #btnProcesarGuia,
  #btnGuardarConfig,
  #btnNuevoProducto,
  #btnNuevoCliente,
  #btnNuevaGuia,
  .modal-footer .btn {
    width: 100%;
    margin-bottom: 4px;
  }
  .modal-footer {
    flex-direction: column;
    gap: 4px;
  }
  .modal-footer .d-flex {
    flex-direction: column;
    width: 100%;
  }

  /* ── Vista previa comprobante en móvil ── */
  #prevComprobanteBody > div,
  #prevGuiaBody > div {
    padding: 14px !important;
    font-size: 10px !important;
  }
  #prevComprobanteBody table,
  #prevGuiaBody table {
    font-size: 9px !important;
  }

  /* ── Header empresa en dashboard ── */
  .text-center.mb-4 img {
    height: 60px !important;
  }
  .text-center.mb-4 .fw-bold.fs-6 {
    font-size: 0.85rem !important;
  }

  /* ── Alertas dropdown ── */
  #alertasDropdown .dropdown-menu {
    min-width: 280px !important;
    max-width: 95vw !important;
    right: -60px !important;
  }

  /* ── Footer ── */
  .erp-footer {
    padding: 10px 0;
    font-size: 0.7rem;
  }

  /* ── Reportes ── */
  .erp-card .row.g-2 > [class*="col-md-3"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* ── Login ── */
  .card[style*="max-width:400px"] {
    max-width: 100% !important;
    margin: 8px !important;
    border-radius: 10px !important;
  }
}

/* ══════════════════════════════════════════════
   FACTURACIÓN: Layout dos columnas (escritorio)
   ══════════════════════════════════════════════ */

.factura-badge-items {
  font-size: 0.72rem;
  font-weight: 700;
}

@media (min-width: 992px) {
  .factura-layout {
    height: calc(100vh - 155px);
  }

  .factura-col-productos {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  .factura-col-productos #panel-busqueda-productos {
    flex: 1 1 0;
    min-height: 0;
    max-height: none !important;
  }

  .factura-col-carrito {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-left: 1px solid var(--erp-border);
  }

  .factura-items-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
  }

  .factura-totales {
    flex-shrink: 0;
    margin-top: auto !important;
    padding-top: 8px;
  }
}

@media (max-width: 991.98px) {
  .factura-col-carrito {
    border-top: 1px solid var(--erp-border);
    margin-top: 8px;
    padding-top: 12px !important;
  }

  .factura-items-scroll {
    max-height: 220px;
    overflow-y: auto;
  }

  #panel-busqueda-productos {
    max-height: 250px;
  }
}

/* ══════════════════════════════════════════════
   RESPONSIVE: Móvil muy pequeño (≤375px)
   ══════════════════════════════════════════════ */
@media (max-width: 375px) {
  .erp-table {
    font-size: 0.68rem;
  }
  .erp-table thead th {
    font-size: 0.6rem;
    padding: 4px 2px;
  }
  .erp-table tbody td {
    padding: 5px 2px;
  }

  .erp-tile {
    min-height: 60px;
    padding: 10px 6px;
    font-size: 0.7rem;
  }

  .erp-navbar .page-title {
    font-size: 0.75rem;
    max-width: 90px;
  }

  .erp-kpi-link .small {
    font-size: 0.62rem;
  }
}
