/* ============================================================
   EUROBAR - Control de almacen
   Paleta de marca: blanco, rojo #BC162E y negro.
   Pensado para usarse de pie y con una sola mano.
   ============================================================ */

:root {
  /* Marca */
  --rojo:        #BC162E;   /* el rojo exacto del logo */
  --rojo-hover:  #9E1226;
  --rojo-tenue:  #FBE9EC;   /* fondo de avisos y estados en rojo */
  --rojo-borde:  #F2C9D0;

  /* Neutros */
  --blanco:      #FFFFFF;
  --negro:       #16181D;
  --bg:          #F5F6F8;   /* fondo de pantalla */
  --panel:       #FFFFFF;   /* tarjetas */
  --panel-2:     #F0F2F5;   /* campos y botones secundarios */
  --panel-3:     #E4E7EC;   /* controles pulsables */
  --linea:       #DFE3E9;

  --texto:       #16181D;
  --texto-2:     #545C69;
  --texto-3:     #8A93A1;

  /* Unico color funcional fuera de la paleta: confirmaciones */
  --ok:          #0F7A46;
  --ok-tenue:    #E7F5EE;

  --r:   14px;
  --r-s: 10px;
  --sombra:    0 1px 2px rgba(22,24,29,.06), 0 4px 16px rgba(22,24,29,.05);
  --sombra-alta: 0 8px 32px rgba(22,24,29,.16);

  --tab-h: 62px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.oculto { display: none !important; }

/* ---------- Encabezado ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--linea);
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px;
}
.app-header .logo-cab {
  height: 26px; width: auto; display: block; flex: 0 0 auto;
}
.app-header .divisoria {
  width: 1px; height: 26px; background: var(--linea); flex: 0 0 auto;
}
.app-header .titulo {
  font-size: 16px; font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .sub {
  font-size: 11.5px; color: var(--texto-3); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 400px) {
  .app-header .logo-cab { height: 22px; }
}

main { padding: 16px; max-width: 1180px; margin: 0 auto; }

/* ---------- Barra de navegacion inferior ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--linea);
  display: flex;
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--texto-3); font-size: 10.5px; font-weight: 600;
  transition: color .15s; position: relative;
}
.tabbar button .ico { font-size: 20px; line-height: 1; }
.tabbar button.activo { color: var(--rojo); }
.tabbar button.activo::before {
  content: ''; position: absolute; top: 0; left: 24%; right: 24%;
  height: 3px; background: var(--rojo); border-radius: 0 0 3px 3px;
}
@media (max-width: 380px) {
  .tabbar button { font-size: 9.5px; }
  .tabbar button .ico { font-size: 18px; }
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--sombra);
}
.card + .card { margin-top: 12px; }
.card-titulo {
  font-size: 11.5px; font-weight: 750; letter-spacing: .09em;
  text-transform: uppercase; color: var(--texto-3); margin-bottom: 12px;
}

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi {
  background: var(--panel); border: 1px solid var(--linea);
  border-radius: var(--r); padding: 14px; box-shadow: var(--sombra);
}
.kpi .valor { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--negro); }
.kpi .etiqueta { font-size: 11.5px; color: var(--texto-3); font-weight: 600; margin-top: 2px; }
.kpi.oro   .valor,
.kpi.rojo  .valor { color: var(--rojo); }
.kpi.verde .valor { color: var(--ok); }
.kpi.azul  .valor { color: var(--negro); }
.kpi.rojo  { border-color: var(--rojo-borde); background: var(--rojo-tenue); }

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi .valor { font-size: 28px; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--r-s);
  background: var(--panel); color: var(--texto);
  font-weight: 650; font-size: 15px;
  border: 1px solid var(--linea);
  transition: background .15s, border-color .15s, transform .08s;
  min-height: 46px;
}
.btn:active { transform: scale(.975); }
.btn:hover  { background: var(--panel-2); }

/* Accion principal: rojo de marca */
.btn-oro    { background: var(--rojo); color: #fff; border-color: var(--rojo); }
.btn-oro:hover { background: var(--rojo-hover); border-color: var(--rojo-hover); }

/* Confirmar / cerrar: negro, para no competir con el rojo */
.btn-verde  { background: var(--negro); color: #fff; border-color: var(--negro); }
.btn-verde:hover { background: #000; }

.btn-rojo   { background: var(--rojo); color: #fff; border-color: var(--rojo); }
.btn-fantasma { background: transparent; }
.btn-bloque { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 8px 12px; min-height: 36px; font-size: 13.5px; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 14px; }
.campo label {
  display: block; font-size: 11.5px; font-weight: 750;
  color: var(--texto-2); margin-bottom: 6px;
  letter-spacing: .04em; text-transform: uppercase;
}
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px;
  background: var(--blanco); border: 1px solid var(--linea);
  border-radius: var(--r-s); font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
  color: var(--texto);
}
.input:focus { border-color: var(--rojo); box-shadow: 0 0 0 3px var(--rojo-tenue); }
.input:disabled { background: var(--panel-2); color: var(--texto-2); }
select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--texto-3) 50%),
                    linear-gradient(135deg, var(--texto-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px;
}

.buscador { position: relative; margin-bottom: 12px; }
.buscador .input { padding-left: 42px; }
.buscador::before {
  content: '🔍'; position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%); font-size: 15px; opacity: .45;
}

.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--linea);
  font-size: 13px; font-weight: 650; color: var(--texto-2); white-space: nowrap;
}
.chip.activo { background: var(--rojo); border-color: var(--rojo); color: #fff; }

/* ---------- Lista de productos ---------- */
.grupo-titulo {
  font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--rojo); margin: 20px 0 8px; padding-bottom: 6px;
  border-bottom: 2px solid var(--rojo-borde);
}
.grupo-titulo:first-child { margin-top: 0; }

.fila {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--linea); border-radius: var(--r-s);
  margin-bottom: 8px;
}
.fila .info { flex: 1; min-width: 0; }
.fila .nombre { font-size: 14.5px; font-weight: 650; line-height: 1.25; }
.fila .meta { font-size: 11.5px; color: var(--texto-3); margin-top: 3px; }
.fila.contada {
  border-color: var(--negro);
  background: linear-gradient(90deg, #F2F3F5 0%, var(--panel) 55%);
}
.fila.bajo { border-color: var(--rojo-borde); background: var(--rojo-tenue); }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--panel-3); color: var(--texto);
  font-size: 19px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.stepper button:active { background: var(--rojo); color: #fff; }
.stepper input {
  width: 54px; height: 38px; text-align: center;
  background: var(--blanco); border: 1px solid var(--linea);
  border-radius: 9px; font-size: 16px; font-weight: 700; outline: none;
  -moz-appearance: textfield; color: var(--texto);
}
.stepper input:focus { border-color: var(--rojo); }
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 750; letter-spacing: .03em;
}
.badge-oro   { background: var(--rojo-tenue); color: var(--rojo); }
.badge-rojo  { background: var(--rojo);       color: #fff; }
.badge-verde { background: var(--ok-tenue);   color: var(--ok); }
.badge-azul  { background: #EDEFF3;           color: var(--negro); }
.badge-gris  { background: var(--panel-2);    color: var(--texto-2); }

/* ---------- Selector de botella abierta ---------- */
.abiertas-zona { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--linea); }
.abiertas-lista { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }

.botella {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px; border-radius: var(--r-s);
  background: var(--panel-2); border: 1px solid var(--linea);
  min-width: 78px;
}
.botella svg { display: block; }
.botella .quitar { font-size: 11px; color: var(--texto-3); font-weight: 600; }
.botella .quitar:hover { color: var(--rojo); }

.botella-nueva {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 78px; min-height: 118px;
  border: 1px dashed var(--texto-3); border-radius: var(--r-s);
  color: var(--texto-3); font-size: 12px; font-weight: 650;
  background: transparent;
}
.botella-nueva:hover { border-color: var(--rojo); color: var(--rojo); background: var(--rojo-tenue); }
.botella-nueva .mas { font-size: 22px; line-height: 1; }

.niveles { display: flex; gap: 4px; margin-top: 2px; }
.niveles button {
  padding: 4px 7px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: var(--panel-3); color: var(--texto-2);
}
.niveles button.activo { background: var(--rojo); color: #fff; }

/* ---------- Tabla ---------- */
.tabla-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: right; padding: 9px 10px; font-size: 10.5px; font-weight: 750;
  letter-spacing: .07em; text-transform: uppercase; color: var(--texto-3);
  border-bottom: 2px solid var(--linea); white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
td { padding: 10px; border-bottom: 1px solid var(--linea); text-align: right; white-space: nowrap; }
td:first-child { white-space: normal; min-width: 180px; font-weight: 600; }
tbody tr:hover { background: var(--panel-2); }
.num-0 { color: #C3C9D2; }

/* ---------- Modal ---------- */
.modal-fondo {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(22,24,29,.45); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-fondo { align-items: center; } }
.modal {
  background: var(--panel); border: 1px solid var(--linea);
  border-radius: var(--r) var(--r) 0 0;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--sombra-alta);
}
@media (min-width: 640px) { .modal { border-radius: var(--r); } }
.modal h3 { font-size: 18px; margin-bottom: 4px; }
.modal .modal-sub { font-size: 13px; color: var(--texto-3); margin-bottom: 18px; }
.modal-acciones { display: flex; gap: 10px; margin-top: 20px; }
.modal-acciones .btn { flex: 1; }

/* ---------- Avisos ---------- */
.toast-zona {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: calc(100% - 32px); max-width: 420px;
}
.toast {
  background: var(--negro); color: #fff;
  border-radius: var(--r-s); padding: 12px 16px; font-size: 14px; font-weight: 600;
  box-shadow: var(--sombra-alta); animation: sube .25s ease;
  width: 100%; text-align: center;
}
.toast.ok    { background: var(--negro); }
.toast.error { background: var(--rojo); }
@keyframes sube { from { opacity: 0; transform: translateY(12px); } }

.vacio { text-align: center; padding: 48px 20px; color: var(--texto-3); }
.vacio .ico { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

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

/* ---------- Login ---------- */
.login-pantalla {
  position: fixed; inset: 0; z-index: 300;
  background: var(--blanco);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-caja { width: 100%; max-width: 380px; }
.login-caja .logo {
  display: flex; justify-content: center; margin-bottom: 6px;
}
.login-caja .logo img { width: 200px; max-width: 62%; height: auto; display: block; }
.login-caja .lema {
  text-align: center; font-size: 11.5px; color: var(--texto-3);
  letter-spacing: .14em; text-transform: uppercase; margin-bottom: 34px;
}

/* ---------- Barra de progreso ---------- */
.progreso { height: 6px; background: var(--panel-3); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progreso div { height: 100%; background: var(--rojo); border-radius: 999px; transition: width .3s; }

.linea-dato { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; font-size: 14px; }
.linea-dato + .linea-dato { border-top: 1px solid var(--linea); }
.linea-dato .etq { color: var(--texto-2); }
.linea-dato .val { font-weight: 700; }
