:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --txt: #e2e8f0;
  --muted: #94a3b8;
  --ok: #22c55e;
  --pronto: #eab308;
  --critico: #f97316;
  --caducado: #ef4444;
  --pri: #3b82f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
}

header {
  padding: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
header h1 { margin: 0; font-size: 1.3rem; }
.btn-avisos {
  background: #334155; color: var(--txt); border: none;
  border-radius: 999px; padding: 8px 14px; font-size: .85rem; cursor: pointer;
}
.btn-avisos:disabled { opacity: .7; cursor: default; }

.lista {
  padding: 8px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.vacio { color: var(--muted); text-align: center; margin-top: 40px; }

.item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel);
  border-left: 5px solid var(--muted);
  border-radius: 10px;
  padding: 12px 14px;
}
.item.ok { border-color: var(--ok); }
.item.pronto { border-color: var(--pronto); }
.item.critico { border-color: var(--critico); }
.item.caducado { border-color: var(--caducado); opacity: .85; }

.item h3 { margin: 0 0 4px; font-size: 1rem; }
.item .cant { color: var(--muted); font-weight: normal; font-size: .85rem; }
.item .fecha { margin: 0; font-size: .85rem; color: var(--muted); }
.item .notas { margin: 4px 0 0; font-size: .8rem; color: var(--muted); }

.item-acc { display: flex; flex-direction: column; gap: 4px; }
.item-acc button {
  background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 2px;
}

.fab {
  position: fixed; right: 20px; bottom: 20px;
  width: 60px; height: 60px; border-radius: 50%;
  border: none; background: var(--pri); color: #fff;
  font-size: 2rem; line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
  cursor: pointer;
}

.modal { display: none; position: fixed; inset: 0; z-index: 10; }
.modal.abierto { display: block; }
.modal-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.modal-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  max-height: 92vh; overflow: auto;
}
.modal-panel h2 { margin: 0 0 14px; font-size: 1.1rem; }

.captura { display: flex; gap: 10px; margin-bottom: 10px; }
.captura-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #334155; border: 1px dashed var(--muted); border-radius: 10px;
  padding: 14px; cursor: pointer; color: var(--txt); font-size: 1.5rem;
}
.captura-btn span { font-size: .8rem; color: var(--muted); }
.captura-full { width: 100%; flex-direction: row; gap: 8px; font-size: 1.3rem; }
.captura-full span { font-size: 1rem; color: var(--txt); }
.preview { display: none; width: 100%; border-radius: 8px; margin-bottom: 8px; }

.producto-img {
  display: none; width: 100%; max-height: 180px; object-fit: contain;
  border-radius: 10px; margin-bottom: 10px; background: #0f172a;
}

/* Selector de fecha con swipe (DD / MM / AÑO) */
.fp-hint { font-size: .7rem; color: #64748b; font-weight: normal; }
.fecha-picker { display: flex; gap: 10px; justify-content: center; margin: 6px 0 14px; }
.fp-col {
  flex: 1; max-width: 96px; text-align: center; user-select: none;
  cursor: ns-resize; touch-action: none;
  background: #0f172a; border: 1px solid #334155; border-radius: 12px; padding: 6px 0;
}
.fp-prev, .fp-next { color: #475569; font-size: 1rem; line-height: 1.5; cursor: pointer; }
.fp-cur { color: var(--txt); font-size: 1.9rem; font-weight: 600; line-height: 1.3; }
.fp-label { color: var(--muted); font-size: .65rem; letter-spacing: 1px; margin-top: 4px; }

/* Aviso verde "ya trackeado" */
.aviso-verde {
  display: none;
  background: #14532d; color: #bbf7d0; border: 1px solid #22c55e;
  border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; font-size: .85rem;
}

/* Swipe en la lista */
.swipe-wrap { position: relative; border-radius: 10px; overflow: hidden; }
.swipe-hint {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: space-between; padding: 0 22px; font-size: 1.4rem; background: var(--panel);
}
.swipe-wrap.hint-del .swipe-hint { background: var(--caducado); }
.swipe-wrap.hint-cesta .swipe-hint { background: #16a34a; }
.swipe-wrap .item { position: relative; will-change: transform; touch-action: pan-y; }

/* Hoja de selección de tienda (cesta) */
.cesta-overlay { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; }
.cesta-sheet { background: var(--panel); width: 100%; border-radius: 16px 16px 0 0; padding: 20px; }
.cesta-sheet h3 { margin: 0 0 4px; font-size: 1.05rem; }
.cesta-sheet p { margin: 0 0 14px; color: var(--muted); font-size: .85rem; }
.cesta-tiendas { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cesta-tienda {
  flex: 1 1 40%; padding: 14px; border-radius: 10px; border: 2px solid #334155;
  background: #0f172a; color: var(--txt); font-size: 1rem; cursor: pointer;
}
.cesta-cancel { width: 100%; padding: 12px; border: none; border-radius: 8px; background: #334155; color: var(--txt); font-size: 1rem; cursor: pointer; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; z-index: 60;
  transform: translateX(-50%) translateY(20px);
  background: #16a34a; color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: .9rem; opacity: 0; transition: all .25s; box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Pestañas lista / calendario */
.tabs { display: flex; gap: 6px; padding: 0 16px 8px; }
.tab {
  flex: 1; padding: 9px; border: none; border-radius: 8px;
  background: #1e293b; color: var(--muted); font-size: .9rem; cursor: pointer;
}
.tab.activo { background: #334155; color: var(--txt); }
.oculto { display: none !important; }

/* Calendario */
.calendario { padding: 4px 16px 96px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav button {
  background: #334155; color: var(--txt); border: none; border-radius: 8px;
  width: 42px; height: 38px; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.cal-titulo { font-size: 1.05rem; font-weight: 600; text-transform: capitalize; }
.cal-semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-semana span { text-align: center; font-size: .7rem; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-celda {
  aspect-ratio: 1; border-radius: 8px; background: #1e293b; position: relative;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.cal-celda.vacia { background: transparent; }
.cal-celda .cal-dia { color: var(--muted); }
.cal-celda.con-productos { cursor: pointer; }
.cal-celda.con-productos .cal-dia { color: #fff; font-weight: 600; }
.cal-celda .cal-num {
  position: absolute; top: 3px; right: 4px; font-size: .6rem; color: #fff;
  background: rgba(0, 0, 0, .35); border-radius: 8px; padding: 0 4px;
}
.cal-celda.ok       { background: #14532d; }
.cal-celda.pronto   { background: #854d0e; }
.cal-celda.critico  { background: #9a3412; }
.cal-celda.caducado { background: #7f1d1d; }
.cal-celda.hoy { outline: 2px solid var(--pri); outline-offset: -2px; }

.cal-detalle { margin-top: 16px; }
.cal-detalle h3 { font-size: .95rem; text-transform: capitalize; margin: 0 0 8px; }
.cal-item { background: var(--panel); border-radius: 8px; padding: 11px 13px; margin-bottom: 6px; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 12px; }
.chip-fecha {
  background: #334155; color: var(--txt); border: none; border-radius: 999px;
  padding: 6px 12px; font-size: .85rem; cursor: pointer;
}
.chip-fecha:active { background: var(--pri); }

/* Escáner de código de barras a pantalla completa */
.scan-overlay {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.scan-overlay video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-marco {
  position: relative; width: 72%; max-width: 320px; height: 150px;
  border: 3px solid #fff; border-radius: 12px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, .45);
}
.scan-ayuda { position: absolute; bottom: 130px; color: #fff; z-index: 1; }
.scan-cancel {
  position: absolute; bottom: 44px; z-index: 1;
  background: #fff; color: #000; border: none; border-radius: 999px;
  padding: 12px 28px; font-size: 1rem; cursor: pointer;
}
.ocr-estado { font-size: .8rem; color: var(--muted); min-height: 1.2em; margin: 0 0 10px; }

form label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
form input {
  display: block; width: 100%; margin-top: 4px; padding: 10px;
  border-radius: 8px; border: 1px solid #334155;
  background: #0f172a; color: var(--txt); font-size: 1rem;
}

.acciones { display: flex; gap: 10px; margin-top: 8px; }
.btn-pri, .btn-sec {
  flex: 1; padding: 12px; border-radius: 8px; border: none;
  font-size: 1rem; cursor: pointer;
}
.btn-pri { background: var(--pri); color: #fff; }
.btn-sec { background: #334155; color: var(--txt); }
