@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@400;500;600;700&display=swap');

/* 
 * Estilos de la Aplicación Web Distribuidora de Snacks
 * Cuenca, Azuay, Ecuador
 * Diseño responsivo optimizado para móviles (vendedores) y escritorio (administración/bodega)
 */

:root {
  --primary: #ab3427;
  --primary-dark: #8c281d;
  --primary-light: #fdf2f0;
  --accent: #c6b231;
  --accent-dark: #a89624;
  --secondary: #3d2813;
  --dark-brown: #3d2813;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #c6b231;
  --text-main: #3d2813;
  --text-muted: #6b7280;
  --bg-app: #faf8f5;
  --bg-card: #ffffff;
  --border: #e8e3dc;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgba(61, 40, 19, 0.08), 0 2px 4px -1px rgba(61, 40, 19, 0.04);
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

/* TOPBAR */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-subtitle {
  font-size: 11px;
  opacity: 0.85;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-online { background: #065f46; color: #a7f3d0; }
.badge-offline { background: #991b1b; color: #fecaca; }
.badge-printer-off { background: #374151; color: #d1d5db; cursor: pointer; }
.badge-printer-on { background: #047857; color: #d1fae5; cursor: pointer; }
.badge-print-queue {
  background: var(--secondary);
  color: #fdf2f0;
  cursor: pointer;
  border: 1px solid var(--accent);
  transition: all 0.2s ease;
}
.badge-print-queue:hover {
  background: #2b1c0d;
  color: #fff;
}
.badge-print-queue.has-pending {
  background: #b91c1c;
  color: #fef2f2;
  border-color: #ef4444;
}

/* COMPROBANTES Y VISTA PREVIA TÉRMICA 80 MM */
.thermal-receipt {
  background: #ffffff;
  color: #111827;
  font-family: 'Comfortaa', cursive, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 18px 14px;
  max-width: 390px;
  margin: 0 auto;
  border: 1px dashed #cbd5e1;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  border-radius: 6px;
  letter-spacing: 0.2px;
}
.thermal-receipt, .thermal-receipt * {
  font-family: 'Comfortaa', cursive, sans-serif !important;
}
.thermal-receipt-header {
  text-align: center;
  border-bottom: 1.5px dashed #64748b;
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.thermal-receipt-header h3 {
  font-family: 'Comfortaa', cursive, sans-serif !important;
  font-size: 17.5px;
  font-weight: 700;
  margin: 0 0 3px 0;
  letter-spacing: 0.5px;
}
.thermal-line {
  display: flex;
  justify-content: space-between;
  margin: 3px 0;
  font-size: 14px;
}
.thermal-separator {
  border-top: 1px dashed #64748b;
  margin: 8px 0;
}
.thermal-double-sep {
  border-top: 2px solid #0f172a;
  margin: 10px 0;
}
.thermal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-family: 'Comfortaa', cursive, sans-serif !important;
}
.thermal-table th, .thermal-table td {
  padding: 4px 2px;
}
.thermal-table th {
  border-bottom: 1px dashed #64748b;
  font-weight: 700;
}

@media print {
  @page {
    size: 80mm auto;
    margin: 2mm;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }
  body * {
    visibility: hidden;
  }
  .printable-receipt-modal, .printable-receipt-modal * {
    visibility: visible;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }
  .no-print, .no-print * {
    display: none !important;
    visibility: hidden !important;
  }
  .modal-overlay {
    position: static !important;
    background: transparent !important;
    display: block !important;
    padding: 0 !important;
  }
  .modal-content {
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 80mm !important;
    max-width: 80mm !important;
  }
  .modal-header, .close-btn {
    display: none !important;
  }
  .printable-receipt-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
  }
  .thermal-receipt {
    border: none !important;
    box-shadow: none !important;
    padding: 2mm 0 !important;
    max-width: 80mm !important;
    width: 100% !important;
    font-size: 14.5px !important;
    line-height: 1.45 !important;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }
  .thermal-table {
    font-size: 13.5px !important;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }
}

/* USER PILL */
.user-pill {
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(255, 255, 255, 0.2); }

/* NAVIGATION TABS */
.nav-tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  padding: 0 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* MAIN CONTAINER */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

/* LOGIN VIEW */
.login-wrapper {
  max-width: 420px;
  margin: 30px auto;
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  font-size: 32px;
  margin-bottom: 8px;
}

.login-logo img {
  border-radius: 20px;
  overflow: hidden;
}

.brand-title img {
  border-radius: 8px;
  overflow: hidden;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.demo-users-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.demo-user-card {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.demo-user-card:hover, .demo-user-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.demo-user-name { font-weight: 700; font-size: 12px; }
.demo-user-role { font-size: 11px; color: var(--text-muted); }
.demo-user-pin { font-size: 11px; color: var(--primary); font-weight: bold; }

/* PIN DISPLAY */
.pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 15px 0;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: transparent;
  transition: all 0.2s;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.15);
}

/* KEYPAD */
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto 15px auto;
}

.key-btn {
  height: 56px;
  font-size: 22px;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-main);
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s;
}

.key-btn:active {
  background: #e2e8f0;
  transform: scale(0.96);
}

/* CARDS & PANELS */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* GRID LAYOUTS */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 100%;
}

.grid-2 > * {
  min-width: 0;
  max-width: 100%;
}

.pos-catalog-column {
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

#cartColumn {
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* KPI STATS CARDS */
.stat-box {
  background: #fff;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--primary); margin: 4px 0; }
.stat-sub { font-size: 11px; color: var(--text-muted); }

/* PRODUCT CATALOG CARDS */
.category-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.product-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.prod-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  width: 100%;
  min-width: 0;
}

.prod-code {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.prod-stock-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.stock-ok { background: #dcfce7; color: #166534; }
.stock-low { background: #fef9c3; color: #854d0e; }
.stock-zero { background: #fee2e2; color: #991b1b; }

.prod-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-dark);
  line-height: 1.3;
  word-break: break-word;
}

.prod-brand { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }

.pres-selector {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.pres-btn {
  padding: 6px 4px;
  font-size: 11px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  transition: all 0.15s ease;
  line-height: 1.35;
}

.pres-btn.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 700;
}

.pres-stock-sub {
  display: block;
  font-size: 10px;
  opacity: 0.85;
  white-space: nowrap;
}

.prod-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
  margin-top: 4px;
  gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.prod-footer-price-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 0;
}

.prod-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.pres-stock-disp {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.prod-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.card-stepper {
  display: flex;
  align-items: center;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  flex: 0 0 auto;
  height: 44px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-stepper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.15);
}

.card-stepper-btn {
  border: none;
  background: #f1f5f9;
  width: 44px;
  height: 100%;
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e293b;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}

.card-stepper-btn:hover {
  background: #e2e8f0;
  color: var(--primary);
}

.card-stepper-btn:active {
  background: #cbd5e1;
  transform: scale(0.95);
}

.card-stepper-input {
  width: 54px;
  height: 100%;
  text-align: center;
  border: none;
  font-weight: 800;
  font-size: 20px !important;
  color: #0f172a;
  padding: 0 2px;
  margin: 0;
  background: #ffffff;
  -moz-appearance: textfield;
}

.card-stepper-input::-webkit-outer-spin-button,
.card-stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.card-add-btn {
  flex: 1;
  min-width: 110px;
  padding: 0 14px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 86, 179, 0.2);
  transition: background 0.15s, transform 0.1s;
}

.card-add-btn:active {
  transform: scale(0.98);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: #f8fafc; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 18px; font-size: 15px; }

/* CART SECTION */
.cart-card {
  background: #fff;
  border-radius: var(--radius);
  border: 2px solid var(--primary-light);
  padding: 16px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.cart-qty-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cart-qty-input {
  width: 44px;
  height: 26px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px;
}

.cart-qty-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-weight: bold;
  cursor: pointer;
}

/* TABLES */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  margin-bottom: 8px;
}

table.data-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 12px;
}

table.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  text-align: left;
  padding: 10px;
  border-bottom: 2px solid var(--border);
}

table.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

table.data-table tr:hover {
  background: #f9fafb;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

/* FORM CONTROLS */
.form-group {
  margin-bottom: 12px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* TOAST NOTIFICATION */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease-out;
}

.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #0284c7; }

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

/* ========================================== */
/* RESPONSIVIDAD Y OPTIMIZACIÓN MÓVIL CELULAR */
/* Adaptado para teléfonos de vendedores (360px - 480px) */
/* ========================================== */

/* Clases de utilidad móvil */
.hide-mobile {
  display: inline;
}
.show-mobile {
  display: none !important;
}

/* BARRA FLOTANTE MÓVIL DEL CARRITO */
.mobile-cart-bar {
  display: none;
}

/* TABLETS Y MÓVILES (max-width: 768px) */
@media (max-width: 768px) {
  /* BARRA FLOTANTE MÓVIL (VENDEDOR EN RUTA) */
  .mobile-cart-bar {
    position: fixed;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    right: 10px;
    z-index: 45;
    padding: 10px 14px;
    background: #0f172a;
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.18);
    animation: slideUp 0.25s ease-out;
    touch-action: manipulation;
  }

  .mobile-cart-bar:active {
    transform: scale(0.98);
  }

  .mobile-cart-badge {
    background: var(--accent);
    color: #000;
    font-weight: 800;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 6px;
  }

  .mobile-cart-price {
    font-size: 15px;
    font-weight: 800;
    color: #38bdf8;
  }

  .mobile-cart-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
  }

  #viewVentas {
    padding-bottom: 75px;
  }

  /* Modales en móvil: estilo bottom-sheet suave */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 18px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .modal-header h3 {
    font-size: 15px !important;
  }
}

/* SMARTPHONES Y PANTALLAS PEQUEÑAS (max-width: 600px) */
@media (max-width: 600px) {
  .hide-mobile {
    display: none !important;
  }
  .show-mobile {
    display: block !important;
  }

  /* PREVENIR ZOOM ACCIDENTAL EN IOS */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 15px !important;
  }

  /* CONTENEDOR GENERAL */
  .container {
    padding: 8px 6px;
  }

  .card {
    padding: 12px 10px;
    margin-bottom: 10px;
    border-radius: 8px;
  }

  .card-title {
    font-size: 14px;
    margin-bottom: 8px;
    gap: 6px;
  }

  /* TOPBAR HEADER MÓVIL COMPACTO */
  .app-header {
    padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px 8px;
    gap: 4px;
    height: 48px;
    flex-wrap: nowrap;
  }

  .brand-title {
    font-size: 12.5px;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
  }

  .brand-full-name {
    display: none !important;
  }

  .brand-short-name {
    display: inline !important;
  }

  .brand-subtitle {
    display: none !important;
  }

  .header-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  #printerStatusText,
  #onlineStatusText {
    display: none !important;
  }

  .badge-status {
    padding: 4px 6px;
    font-size: 10.5px;
    gap: 2px;
  }

  .user-pill {
    padding: 2px 6px;
    gap: 3px;
    font-size: 10.5px;
    max-width: 105px;
  }

  #userNameDisplay {
    display: inline-block;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    vertical-align: middle;
  }

  #userRoleBadge {
    display: none !important;
  }

  .btn-logout {
    padding: 2px 5px;
    font-size: 9.5px;
  }

  /* PESTAÑAS DE NAVEGACIÓN STICKY (CONFORT TÁCTIL) */
  .nav-tabs {
    position: sticky;
    top: 48px;
    z-index: 40;
    padding: 0 4px;
    height: 48px;
    align-items: center;
  }

  .tab-btn {
    padding: 10px 14px;
    font-size: 13px;
    min-height: 48px;
    gap: 6px;
    font-weight: 600;
    touch-action: manipulation;
  }

  .tab-btn.active {
    background: var(--primary-light);
    border-bottom: 3px solid var(--primary);
  }

  /* SELECTOR DE CLIENTE EN RUTA (BOTONES AMPLIOS) */
  .client-header-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .client-header-buttons {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .client-header-buttons button {
    flex: 1;
    text-align: center;
    padding: 10px 10px;
    font-size: 12.5px;
    font-weight: 600;
    min-height: 44px;
    border-radius: 8px;
    touch-action: manipulation;
  }

  /* SUB-PESTAÑAS SEGMENTADAS (BODEGA Y COMPROBANTES) */
  .segmented-controls-row {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .segmented-controls-row button {
    flex: 1 !important;
    text-align: center !important;
    padding: 10px 8px !important;
    font-size: 12.5px !important;
    min-height: 44px !important;
    justify-content: center !important;
    white-space: normal !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    touch-action: manipulation;
  }

  /* TECLADOS NUMÉRICOS TÁCTILES */
  .keypad-grid {
    gap: 8px;
    max-width: 100%;
  }

  .key-btn {
    height: 56px;
    font-size: 24px;
    font-weight: 700;
    border-radius: 12px;
    touch-action: manipulation;
  }

  /* TABLAS EN PANTALLAS PEQUEÑAS CON BOTONES CÓMODOS */
  .table-responsive {
    border-radius: 8px;
    margin-bottom: 10px;
  }

  table.data-table,
  table.table {
    min-width: 500px;
    font-size: 11.5px;
  }

  table.data-table th,
  table.table th {
    padding: 9px 6px;
    font-size: 11px;
  }

  table.data-table td,
  table.table td {
    padding: 9px 6px;
    font-size: 11.5px;
  }

  table.data-table td button,
  table.table td button,
  table.data-table td .btn,
  table.table td .btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
    min-height: 38px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  /* BOTONES GENERALES AMPLIADOS PARA VENDEDORES EN MÓVIL */
  .btn,
  button.btn,
  a.btn {
    min-height: 44px !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .btn-sm,
  button.btn-sm,
  a.btn-sm {
    min-height: 38px !important;
    padding: 7px 12px !important;
    font-size: 12.5px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    touch-action: manipulation;
  }

  .btn-lg,
  button.btn-lg,
  a.btn-lg {
    min-height: 52px !important;
    padding: 14px 22px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    touch-action: manipulation;
  }

  /* SELECTOR DE CANTIDAD EN CARRITO Y ARQUEOS */
  .qty-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .cart-qty-input {
    width: 48px !important;
    height: 38px !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    text-align: center !important;
    border-radius: 6px !important;
  }

  .form-input, .form-select {
    min-height: 44px;
    font-size: 14.5px;
    padding: 9px 12px;
    border-radius: 8px;
  }

  .close-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 22px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .modal-footer button,
  .printable-receipt-modal .no-print button {
    min-height: 46px !important;
    padding: 11px 18px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  /* RESPUESTA TÁCTIL INMEDIATA */
  button:active,
  .btn:active,
  .card-add-btn:active,
  .card-stepper-btn:active,
  .qty-btn:active,
  .pres-btn:active,
  .tab-btn:active,
  .key-btn:active {
    transform: scale(0.96) !important;
    transition: transform 0.08s ease-in-out !important;
  }

  /* KPI STATS */
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .stat-box {
    padding: 8px 10px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 17px;
  }

  .stat-sub {
    font-size: 10px;
  }

  /* VISTA PREVIA DEL COMPROBANTE TÉRMICO (80 MM) */
  .thermal-receipt {
    padding: 14px 10px;
    font-size: 14px;
    max-width: 100%;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }

  .thermal-receipt-header h3 {
    font-size: 16.5px;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }

  .thermal-table {
    font-size: 13px;
    font-family: 'Comfortaa', cursive, sans-serif !important;
  }
}

/* SMARTPHONES PEQUEÑOS (max-width: 480px) */
@media (max-width: 480px) {
  /* LOGIN VIEW */
  .login-wrapper {
    margin: 8px auto;
    padding: 16px 12px;
    width: 100%;
    border-radius: 8px;
  }

  .demo-users-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .demo-user-card {
    padding: 8px 6px;
  }

  .demo-user-name {
    font-size: 11px;
  }

  .demo-user-role {
    font-size: 9.5px;
  }

  .demo-user-pin {
    font-size: 10px;
  }

  /* CATÁLOGO EN COLUMNA ÚNICA MÓVIL (COMPACTO Y VISIBLE COMO EN PC) */
  .products-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .product-card {
    padding: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .prod-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
  }

  .prod-stock-badge {
    font-size: 10.5px;
    padding: 2px 6px;
    flex-shrink: 0;
  }

  .pres-selector {
    display: grid;
    gap: 4px;
    margin-bottom: 6px;
    width: 100%;
    min-width: 0;
  }

  .pres-btn {
    padding: 6px 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    min-height: 44px !important;
    min-width: 0;
    box-sizing: border-box;
    line-height: 1.3;
    border-radius: 7px !important;
    touch-action: manipulation;
  }

  .prod-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    padding-top: 6px;
    margin-top: 4px;
    width: 100%;
    min-width: 0;
  }

  .prod-price {
    font-size: 15px;
  }

  .pres-stock-disp {
    font-size: 10px;
  }

  .prod-footer-actions {
    gap: 8px;
  }

  .card-stepper {
    height: 48px !important;
  }

  .card-stepper-btn {
    width: 46px !important;
    height: 48px !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    touch-action: manipulation;
  }

  .card-stepper-input {
    width: 52px !important;
    height: 48px !important;
    font-size: 20px !important;
    font-weight: 800 !important;
  }

  .card-add-btn {
    flex: 1;
    min-width: 105px !important;
    height: 48px !important;
    min-height: 48px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    padding: 0 14px !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  .cat-pill {
    padding: 8px 14px !important;
    font-size: 12.5px !important;
    min-height: 38px !important;
    font-weight: 600 !important;
    border-radius: 20px !important;
    touch-action: manipulation;
    display: inline-flex !important;
    align-items: center !important;
  }

  /* CARRITO DE COMPRAS MÓVIL */
  .cart-item {
    padding: 8px 0;
  }

  .cart-card {
    padding: 12px;
  }

  /* BOTONES Y FORMULARIOS EN SMARTPHONES PEQUEÑOS */
  .btn-lg {
    min-height: 52px !important;
    padding: 13px 20px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    touch-action: manipulation;
  }
}

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

/* CATEGORÍAS DE CLIENTES (GENERAL, MAYORISTA, ESPECIAL) */
.badge-cat-general {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-cat-mayorista {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-cat-especial {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.cat-filter-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
  transition: all 0.2s;
}

.cat-filter-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.cat-filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.special-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 6px;
  transition: all 0.15s;
}

.special-price-row:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

/* ========================================================= */
/* VENDOR MOBILE ERGONOMICS & ENLARGED TOUCH CONTROLS        */
/* Diseñado especialmente para vendedores en ruta y camiones */
/* ========================================================= */
@media (max-width: 768px) {
  /* Botones primarios, secundarios y de acción */
  .btn,
  button.btn,
  a.btn {
    min-height: 46px !important;
    padding: 11px 18px !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .btn-sm,
  button.btn-sm,
  a.btn-sm,
  table.data-table td button,
  table.table td button,
  table.data-table td .btn,
  table.table td .btn {
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 12.5px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .btn-lg,
  button.btn-lg,
  a.btn-lg {
    min-height: 52px !important;
    padding: 14px 22px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    touch-action: manipulation;
  }

  /* Filtros y Pills de categoría */
  .cat-filter-btn,
  .cat-pill {
    min-height: 40px !important;
    padding: 9px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 20px !important;
    touch-action: manipulation;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Controles de cliente en cabecera de ruta */
  .client-header-buttons button {
    min-height: 46px !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  /* Controles de cantidad en carrito (+ / -) */
  .qty-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    font-size: 20px !important;
    font-weight: 800 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .cart-qty-input {
    width: 52px !important;
    height: 40px !important;
    font-size: 17px !important;
    font-weight: 800 !important;
    text-align: center !important;
    border-radius: 6px !important;
  }

  /* Selector de presentaciones en tarjetas de snacks */
  .pres-btn {
    min-height: 44px !important;
    padding: 6px 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    border-radius: 7px !important;
    touch-action: manipulation;
  }

  /* Stepper (+ / -) y botón Agregar en catálogo */
  .card-stepper {
    height: 48px !important;
  }

  .card-stepper-btn {
    width: 48px !important;
    height: 48px !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    touch-action: manipulation;
  }

  .card-stepper-input {
    width: 54px !important;
    height: 48px !important;
    font-size: 20px !important;
    font-weight: 800 !important;
  }

  .card-add-btn {
    height: 48px !important;
    min-height: 48px !important;
    font-size: 15.5px !important;
    font-weight: 700 !important;
    padding: 0 16px !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  /* Botón barra inferior flotante de carrito móvil */
  .mobile-cart-btn {
    min-height: 46px !important;
    padding: 10px 18px !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  /* Pestañas de navegación superiores */
  .nav-tabs {
    height: 48px !important;
  }

  .tab-btn {
    min-height: 48px !important;
    padding: 10px 16px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    touch-action: manipulation;
  }

  /* Subpestañas segmentadas */
  .segmented-controls-row button {
    min-height: 44px !important;
    padding: 10px 10px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  /* Teclado numérico táctil PIN */
  .key-btn {
    height: 56px !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    border-radius: 12px !important;
    touch-action: manipulation;
  }

  /* Inputs de formulario y modales */
  .form-input, .form-select {
    min-height: 44px;
    font-size: 15px;
    padding: 9px 12px;
    border-radius: 8px;
  }

  .close-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 24px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  .modal-footer button,
  .printable-receipt-modal .no-print button {
    min-height: 46px !important;
    padding: 11px 18px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  /* Feedback táctil reactivo */
  button:active,
  .btn:active,
  .card-add-btn:active,
  .card-stepper-btn:active,
  .qty-btn:active,
  .pres-btn:active,
  .tab-btn:active,
  .key-btn:active {
    transform: scale(0.96) !important;
    transition: transform 0.08s ease-in-out !important;
  }
}
