* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  background: #f4f6f8;
  color: #222;
}

.navbar {
  background: #1f6f43;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  color: white;
}
.navbar-logo {
  height: 15px;
  width: auto;
  object-fit: contain;
  background: #ffffff;
  padding: 2px 5px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.navbar-brand:hover .navbar-logo {
  transform: scale(1.04);
  box-shadow: 0 4px 10px rgba(0,0,0,0.28);
}
.navbar-title {
  font-weight: 700;
  font-size: 1.15em;
  color: #ffffff;
  letter-spacing: 0.3px;
}
.navbar-links a {
  color: white;
  text-decoration: none;
  margin-left: 16px;
  font-size: 0.95em;
}
.navbar-links a:hover { text-decoration: underline; }
.navbar-links a.nav-highlight {
  background: #f39c12;
  padding: 5px 12px;
  border-radius: 4px;
  font-weight: bold;
  color: #111;
}
.navbar-links a.nav-highlight:hover { background: #e67e22; text-decoration: none; }
.navbar-user { margin-left: 16px; opacity: 0.9; }

.container {
  max-width: 1200px;
  margin: 20px auto;
  background: white;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

h2 { margin-top: 0; color: #1f6f43; }
h3 { color: #1f6f43; }

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

table.tabla-venta, table.tabla-listado, table.tabla-boleta {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}
table.tabla-venta th, table.tabla-venta td,
table.tabla-listado th, table.tabla-listado td,
table.tabla-boleta th, table.tabla-boleta td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}
table.tabla-venta th, table.tabla-listado th, table.tabla-boleta th {
  background: #eef5ef;
}
table.tabla-venta input { width: 100%; padding: 6px; }

.btn-primario, button {
  background: #1f6f43;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.95em;
  text-decoration: none;
  display: inline-block;
}
.btn-primario:hover, button:hover { background: #175a35; }
.btn-secundario { background: #7f8c8d; color: white; border-radius: 5px; padding: 8px 14px; text-decoration: none; display: inline-block; }
.btn-secundario:hover { background: #606d6e; }
.btn-secundario-sm { background: #95a5a6; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.85em; }

.btn-sm { padding: 4px 8px; font-size: 0.85em; border-radius: 4px; text-decoration: none; display: inline-block; }
.btn-toggle { background: #e67e22; color: white; border: none; cursor: pointer; }
.btn-toggle:hover { background: #d35400; }
.btn-quitar { background: #c0392b; padding: 4px 10px; border: none; color: white; border-radius: 4px; cursor: pointer; }
.btn-quitar:hover { background: #922b21; }

.error { color: #c0392b; font-weight: bold; }
.ok { color: #1f6f43; font-weight: bold; }

.form-simple { display: flex; flex-direction: column; max-width: 400px; gap: 2px; }
.form-simple input, .form-simple select { padding: 8px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; }

.filtro { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filtro label { display: flex; flex-direction: column; font-size: 0.9em; }
.filtro input, .filtro select { padding: 6px; border: 1px solid #ccc; border-radius: 4px; }

/* Badges & Thumbnails */
.thumb-producto { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; }
.thumb-placeholder { font-size: 1.5em; display: inline-block; }

.badge-cat { background: #e8f5e9; color: #2e7d32; padding: 3px 8px; border-radius: 12px; font-size: 0.8em; font-weight: 600; }
.stock-badge { padding: 3px 8px; border-radius: 12px; font-size: 0.85em; font-weight: bold; }
.stock-ok { background: #e8f5e9; color: #2e7d32; }
.stock-bajo { background: #ffebee; color: #c62828; }

.estado-badge { padding: 3px 8px; border-radius: 12px; font-size: 0.8em; font-weight: 600; }
.estado-activo { background: #e8f5e9; color: #1f6f43; }
.estado-inactivo { background: #eee; color: #777; }
.fila-inactiva { opacity: 0.6; }

/* Badges de Ganancia y Margen */
.badge-ganancia {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: bold;
  display: inline-block;
}
.ganancia-positiva { background: #e8f5e9; color: #1f6f43; }
.ganancia-negativa { background: #ffebee; color: #c62828; }
.ganancia-cero { background: #f1f5f9; color: #64748b; }

.resumen-ganancia-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 6px 0 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9em;
}

/* ============================================================
   ESTILOS PUNTO DE VENTA (POS)
   ============================================================ */
.pos-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.pos-catalogo {
  flex: 1.4;
  background: #fafbfc;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e1e4e8;
}

.pos-carrito {
  flex: 1;
  background: #ffffff;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #d1d5da;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  position: sticky;
  top: 20px;
}

.pos-bar-busqueda input {
  width: 100%;
  padding: 10px 14px;
  font-size: 1em;
  border: 2px solid #1f6f43;
  border-radius: 6px;
  outline: none;
}
.pos-bar-busqueda input:focus {
  box-shadow: 0 0 6px rgba(31, 111, 67, 0.3);
}

.pos-categorias {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cat-pill {
  background: #eef2f5;
  color: #444;
  border: 1px solid #d0d7de;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.cat-pill:hover { background: #e2e8f0; }
.cat-pill.active {
  background: #1f6f43;
  color: white;
  border-color: #1f6f43;
  font-weight: bold;
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.pos-card {
  background: white;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}
.pos-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: #1f6f43;
}
.pos-card:active {
  transform: scale(0.98);
}

.pos-card-img {
  text-align: center;
  margin-bottom: 6px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pos-card-img img {
  max-height: 70px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.pos-card-icon { font-size: 2.2em; }

.pos-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pos-card-cat {
  font-size: 0.7em;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pos-card-title {
  font-size: 0.88em;
  font-weight: bold;
  color: #222;
  line-height: 1.25;
  height: 2.5em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pos-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.pos-card-price {
  font-weight: bold;
  color: #1f6f43;
  font-size: 0.95em;
}
.pos-card-stock {
  font-size: 0.75em;
  color: #666;
}
.stock-critico { color: #d32f2f; font-weight: bold; }

.pos-sin-productos {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: #666;
}

/* Tabla del Carrito */
.tabla-carrito-wrapper {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 10px;
}
.tabla-carrito-wrapper table { margin: 0; }

.qty-control {
  display: flex;
  align-items: center;
  gap: 2px;
}
.qty-control input {
  text-align: center;
  padding: 4px;
}
.btn-qty {
  background: #e2e8f0;
  color: #333;
  border: 1px solid #cbd5e1;
  width: 24px;
  height: 26px;
  border-radius: 4px;
  padding: 0;
  font-weight: bold;
  cursor: pointer;
}
.btn-qty:hover { background: #cbd5e1; }

.input-readonly {
  background: transparent;
  border: none !important;
  font-weight: 600;
  color: #222;
  cursor: default;
}

.row-highlight {
  animation: highlightAnim 0.4s ease;
}
@keyframes highlightAnim {
  0% { background-color: #d4edda; }
  100% { background-color: transparent; }
}

.carrito-acciones {
  margin-bottom: 16px;
}

.resumen-pos {
  background: #f8fafc;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.resumen-campo {
  margin-bottom: 12px;
}
.resumen-campo label {
  font-size: 0.85em;
  font-weight: bold;
  color: #555;
  display: block;
  margin-bottom: 4px;
}
.select-metodo {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 0.95em;
}
.resumen-total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0;
  padding-top: 10px;
  border-top: 2px dashed #cbd5e1;
}
.resumen-total-box span { font-weight: bold; font-size: 1.1em; color: #444; }
.resumen-total-box h2 { margin: 0; font-size: 1.8em; color: #1f6f43; }

.btn-emitir {
  width: 100%;
  padding: 12px;
  font-size: 1.1em;
  font-weight: bold;
  background: #1f6f43;
  border-radius: 6px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
  transition: background 0.2s ease;
}
.btn-emitir:hover { background: #175a35; }

/* Responsive POS */
@media (max-width: 850px) {
  .pos-layout {
    flex-direction: column;
  }
  .pos-catalogo, .pos-carrito {
    width: 100%;
    position: static;
  }
}

/* Login / instalación */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1f6f43, #2e9e63);
  margin: 0;
}
.login-box {
  background: white;
  padding: 36px 32px 32px 32px;
  border-radius: 12px;
  width: 350px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  text-align: center;
}
.login-logo-container {
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.login-logo-img {
  max-width: 65px;
  height: auto;
  object-fit: contain;
}
.login-title {
  font-size: 1.05em;
  color: #1f6f43;
  margin-top: 4px;
  margin-bottom: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.login-box label { display: block; text-align: left; margin-top: 12px; font-size: 0.9em; font-weight: 600; color: #444; }
.login-box input { width: 100%; padding: 10px; margin-top: 4px; border: 1px solid #ccc; border-radius: 5px; }
.login-box button { width: 100%; margin-top: 20px; padding: 10px; }

/* Boleta */
.boleta {
  width: 100%;
  max-width: 340px;
  margin: 20px auto;
  padding: 16px 14px;
  background: white;
  border: 1px dashed #aaa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  font-family: 'Courier New', Courier, monospace, 'Segoe UI', sans-serif;
  border-radius: 4px;
}
.boleta h2 { text-align: center; font-size: 1.15em; margin-bottom: 6px; font-weight: bold; }
.boleta p { margin: 3px 0; font-size: 0.88em; }
.boleta hr { border: none; border-top: 1px dashed #ccc; margin: 8px 0; }
.boleta .tabla-boleta {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.85em;
  table-layout: fixed;
}
.boleta .tabla-boleta th,
.boleta .tabla-boleta td {
  border: none;
  border-bottom: 1px dashed #eee;
  padding: 5px 2px;
  word-wrap: break-word;
}
.boleta .tabla-boleta th {
  border-bottom: 1px solid #333;
  background: none;
  font-weight: bold;
}
.boleta .tabla-boleta th:nth-child(1), .boleta .tabla-boleta td:nth-child(1) { text-align: left; width: 42%; }
.boleta .tabla-boleta th:nth-child(2), .boleta .tabla-boleta td:nth-child(2) { text-align: center; width: 16%; }
.boleta .tabla-boleta th:nth-child(3), .boleta .tabla-boleta td:nth-child(3) { text-align: right; width: 21%; }
.boleta .tabla-boleta th:nth-child(4), .boleta .tabla-boleta td:nth-child(4) { text-align: right; width: 21%; }

.boleta .mensaje { text-align: center; margin-top: 12px; font-style: italic; font-size: 0.82em; color: #555; }
.boleta .aviso-interno { text-align: center; font-size: 0.72em; color: #777; margin-top: 8px; }
.no-print { text-align: center; margin: 20px auto; max-width: 480px; }
.no-print a { margin-left: 12px; }

.guia-impresora {
  background: #eef6fc;
  border: 1px solid #b6d4fe;
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 16px;
  text-align: left;
  font-size: 0.85em;
  color: #1e3a8a;
}
.guia-impresora h4 { margin: 0 0 6px 0; color: #1e3a8a; display: flex; align-items: center; gap: 6px; }
.guia-impresora ul { margin: 4px 0 0 0; padding-left: 20px; }

@media print {
  @page {
    size: 48mm auto;
    margin: 0mm !important;
  }

  html, body {
    width: 48mm !important;
    max-width: 48mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-family: Arial, 'Helvetica Neue', sans-serif, monospace !important;
    font-size: 9.5px !important;
    line-height: 1.05 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .navbar, .no-print, header, footer, .guia-impresora {
    display: none !important;
  }

  .boleta {
    width: 48mm !important;
    max-width: 48mm !important;
    margin: 0 !important;
    padding: 0mm !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
  }

  .boleta h2 {
    font-size: 11px !important;
    margin: 0 0 1px 0 !important;
    padding: 0 !important;
    text-align: center !important;
    font-weight: bold !important;
    line-height: 1.1 !important;
  }

  .boleta h3 {
    font-size: 10.5px !important;
    margin: 2px 0 1px 0 !important;
    padding: 0 !important;
    text-align: right !important;
    font-weight: bold !important;
  }

  .boleta p {
    font-size: 9px !important;
    margin: 0.5px 0 !important;
    padding: 0 !important;
    line-height: 1.05 !important;
  }

  .boleta hr {
    border: none !important;
    border-top: 1px dashed #000 !important;
    margin: 2px 0 !important;
    padding: 0 !important;
    height: 0 !important;
  }

  .boleta .tabla-boleta {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 2px 0 !important;
    font-size: 8.5px !important;
    table-layout: fixed !important;
  }

  .boleta .tabla-boleta th,
  .boleta .tabla-boleta td {
    border: none !important;
    border-bottom: 1px dashed #888 !important;
    padding: 1px 0px !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.05 !important;
  }

  .boleta .tabla-boleta th {
    border-bottom: 1px solid #000 !important;
    font-weight: bold !important;
  }

  .boleta .tabla-boleta th:nth-child(1), .boleta .tabla-boleta td:nth-child(1) { text-align: left; width: 44%; }
  .boleta .tabla-boleta th:nth-child(2), .boleta .tabla-boleta td:nth-child(2) { text-align: center; width: 14%; }
  .boleta .tabla-boleta th:nth-child(3), .boleta .tabla-boleta td:nth-child(3) { text-align: right; width: 21%; }
  .boleta .tabla-boleta th:nth-child(4), .boleta .tabla-boleta td:nth-child(4) { text-align: right; width: 21%; }

  .boleta .mensaje {
    font-size: 8px !important;
    text-align: center !important;
    margin-top: 2px !important;
    margin-bottom: 1px !important;
  }

  .boleta .aviso-interno {
    font-size: 7px !important;
    text-align: center !important;
    margin-top: 1px !important;
    margin-bottom: 0 !important;
    color: #000 !important;
  }
}

/* Barcode & Scanner Styles */
.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.pos-header h2 { margin: 0; }
.barcode-status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.barcode-badge {
  background: #e8f5e9;
  color: #1f6f43;
  border: 1px solid #a5d6a7;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.85em;
  font-weight: 600;
}
.pos-card-codigo {
  font-size: 0.72em;
  color: #555;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  margin-top: 2px;
  width: fit-content;
}

/* Toast Notificación lectura */
.toast-scan {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #1f6f43;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  font-weight: bold;
  font-size: 1em;
  z-index: 9999;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: translateY(-10px);
}
.toast-scan.show {
  opacity: 1;
  transform: translateY(0);
}
.hidden { display: none !important; }

/* Modal Escáner Cámara */
.modal-camara {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.modal-camara-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.modal-camara-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-camara-header h4 { margin: 0; color: #1f6f43; }
.modal-camara-body {
  position: relative;
  width: 100%;
  height: 260px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.modal-camara-body video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-laser {
  position: absolute;
  top: 50%; left: 10%; right: 10%;
  height: 2px;
  background: #e74c3c;
  box-shadow: 0 0 8px #e74c3c;
  animation: scanLaser 1.5s infinite ease-in-out alternate;
}
@keyframes scanLaser {
  0% { top: 15%; }
  100% { top: 85%; }
}

/* Cards de Resumen de Reportes */
.reporte-resumen-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.card-resumen {
  background: white;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #e1e4e8;
  box-shadow: 0 2px 5px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-resumen .card-title {
  font-size: 0.85em;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-resumen .card-monto {
  font-size: 1.35em;
  font-weight: bold;
  color: #1f6f43;
}

.card-resumen.total-general {
  border-left: 4px solid #1f6f43;
  background: #f4fbf7;
}

.card-resumen.ganancia {
  border-left: 4px solid #16a085;
  background: #f0fdfa;
}

.card-resumen.efectivo {
  border-left: 4px solid #27ae60;
}

.card-resumen.debito {
  border-left: 4px solid #2980b9;
}

.card-resumen.credito {
  border-left: 4px solid #8e44ad;
}

.card-resumen.transferencia {
  border-left: 4px solid #e67e22;
}

