* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
}
.pantalla { display: none; min-height: 100vh; }
.pantalla.activa { display: block; }

.login-box {
  max-width: 360px;
  margin: 10vh auto;
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.login-box h1 { font-size: 1.25rem; margin-bottom: 4px; }
.login-box p { color: #6b7280; font-size: 0.85rem; margin-top: 0; }
.login-box input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: #0f766e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}
.login-box button:disabled { opacity: 0.5; cursor: not-allowed; }
.error-msg { color: #b91c1c; font-size: 0.85rem; min-height: 1.2em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f766e;
  color: #fff;
  padding: 12px 16px;
  gap: 12px;
}
.topbar .info { font-size: 0.85rem; flex-shrink: 0; }
.topbar-acciones { display: flex; gap: 8px; }
.topbar button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.app-body { display: flex; gap: 16px; padding: 16px; }
.catalogo { flex: 2; }
.carrito { flex: 1; background: #fff; border-radius: 12px; padding: 16px; align-self: flex-start; }

.input-escaner {
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  border: 2px solid #0f766e;
  border-radius: 8px;
  font-size: 1.05rem;
  box-sizing: border-box;
}
.input-escaner:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.25);
}

.grid-productos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.producto-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  cursor: pointer;
}
.producto-card:hover { outline: 2px solid #0f766e; }
.producto-card .nombre { font-weight: 600; margin-bottom: 4px; }
.producto-card .precio { color: #0f766e; font-weight: 700; }
.producto-card .stock { font-size: 0.75rem; color: #6b7280; }
.producto-card.sin-stock { opacity: 0.5; cursor: not-allowed; }

.item-carrito {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}
.item-carrito button {
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px 8px;
}
.carrito-total { font-size: 1.1rem; font-weight: 700; margin: 12px 0; }
.carrito select, .carrito button.cobrar {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
}
.carrito button.cobrar {
  background: #0f766e;
  color: #fff;
  border: none;
  cursor: pointer;
}
.carrito button.cobrar:disabled { opacity: 0.5; cursor: not-allowed; }

.caja-box {
  max-width: 320px;
  margin: 15vh auto;
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  text-align: center;
}
.caja-box input { width: 100%; padding: 10px; margin: 10px 0; border-radius: 8px; border: 1px solid #d1d5db; }
.caja-box button { width: 100%; padding: 10px; background: #0f766e; color: #fff; border: none; border-radius: 8px; cursor: pointer; }

.oculto { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: min(600px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-header .cerrar {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-box form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-box input, .modal-box select {
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
}
.modal-box .fila-2 { display: flex; gap: 8px; }
.modal-box .fila-2 input { flex: 1; }
.modal-box button[type="submit"], .modal-box #btn-limpiar-form-producto {
  padding: 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}
.modal-box button[type="submit"] { background: #0f766e; color: #fff; }
.modal-box #btn-limpiar-form-producto { background: #e5e7eb; }

.importar-csv {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.importar-csv h3 { margin: 0 0 6px; font-size: 1rem; }
.ayuda-csv {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.5;
  margin: 0 0 8px;
}
.ayuda-csv code {
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
}
.ayuda-csv a { color: #0f766e; }
#csv-resultado { font-size: 0.85rem; margin-top: 6px; }

.tabla-productos { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tabla-productos th, .tabla-productos td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #f0f0f0; }
.tabla-productos button {
  border: none;
  background: #e5e7eb;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-danger {
  background: #fee2e2 !important;
  color: #dc2626 !important;
}
.btn-danger:hover { background: #fca5a5 !important; }

/* ── Mobile/tablet: celular o tablet en el mostrador, no escritorio ── */
@media (max-width: 700px) {
  .topbar { flex-wrap: nowrap; align-items: flex-start; }
  .topbar-acciones {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .topbar-acciones::-webkit-scrollbar { height: 4px; }
  .topbar button {
    min-height: 44px;
    padding: 10px 14px;
    flex-shrink: 0;
  }

  .app-body { flex-direction: column; padding: 12px; gap: 12px; }

  .grid-productos { padding-bottom: 12px; }
  .producto-card { min-height: 44px; }

  .carrito {
    position: sticky;
    bottom: 0;
    align-self: stretch;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.12);
  }
  .carrito h3 { margin-top: 0; }
  #lista-carrito { overflow-y: auto; flex: 1; min-height: 0; }
  .carrito-total, .carrito select, .carrito button.cobrar { flex-shrink: 0; }
  .carrito button.cobrar, .carrito select { min-height: 44px; }

  .item-carrito button { min-height: 32px; min-width: 32px; }
}
