/* Inventario POP — diseño móvil moderno: cabecera suave, tarjetas con sombra,
   campos rellenos, navegación inferior. Un solo archivo para app y panel. */
:root {
  --ink: #0f1419; --ink-2: #536471; --ink-3: #8b98a5;
  --bg: #f2f4f6; --card: #fff; --line: #e7ebee; --fill: #f1f4f6;
  --brand: #131921; --accent: #ff9900; --cta: #ffd814; --cta-2: #f7ca00;
  --teal: #0a7c86; --teal-bg: #e3f3f4;
  --ok: #087a5b; --ok-bg: #e2f5ee; --warn: #b45309; --warn-bg: #fef3dc; --bad: #c2321b; --bad-bg: #fdebe7;
  --r: 18px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(15,20,25,.04), 0 6px 20px rgba(15,20,25,.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--teal); text-decoration: none; font-weight: 600; }
svg { flex: none; }

/* ── Cabecera ─────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 50; padding: calc(10px + env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(180deg, #b9e6ea 0%, #dcf2f4 60%, #eaf6f7 100%);
}
.top-row { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--brand); color: var(--accent);
  display: grid; place-items: center; box-shadow: 0 4px 10px rgba(19,25,33,.25);
}
.brand b { display: block; font-size: 1rem; letter-spacing: -.01em; line-height: 1.15; }
.brand small { display: block; font-size: .7rem; color: var(--ink-2); font-weight: 500; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top-actions .avatar { margin-left: 0; }
.iconbtn { width: 38px; padding: 0; display: grid; place-items: center; }
.avatar, .pill {
  margin-left: auto; height: 38px; min-width: 38px; border-radius: 19px; border: 0;
  background: #fff; color: var(--brand); font-weight: 700; font-size: .8rem; padding: 0 12px;
  box-shadow: 0 1px 3px rgba(15,20,25,.12);
}
.loc {
  margin-top: 12px; width: 100%; display: flex; align-items: center; gap: 10px; border: 0; text-align: left;
  background: #fff; border-radius: 14px; padding: 10px 14px; box-shadow: 0 2px 8px rgba(15,20,25,.08);
}
.loc svg { color: var(--teal); }
.loc span { flex: 1; min-width: 0; }
.loc small { display: block; font-size: .68rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.loc b { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#offlineBanner { display: none; background: var(--warn-bg); color: var(--warn); padding: 9px 16px; font-size: .8rem; text-align: center; font-weight: 500; }
#pendBanner { background: var(--teal-bg); color: var(--teal); padding: 9px 16px; font-size: .82rem; text-align: center; font-weight: 600; }
#pendBanner button { margin-left: 8px; border: 0; background: var(--teal); color: #fff; border-radius: 999px; padding: 5px 12px; font-size: .76rem; font-weight: 600; }

/* ── Layout ───────────────────────────────────────────────── */
.wrap { padding: 16px 16px calc(150px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.wrap.wide { max-width: 1240px; padding-bottom: 40px; }
.card { background: var(--card); border-radius: var(--r); padding: 18px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.sec { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; font-weight: 700; margin-bottom: 14px; letter-spacing: -.01em; }
.sec .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .78rem; display: grid; place-items: center; font-weight: 700; }
h1 { font-size: 1.55rem; margin: 0 0 6px; letter-spacing: -.02em; line-height: 1.15; }
.sub { color: var(--ink-2); font-size: .9rem; margin: 0 0 18px; line-height: 1.4; }

/* ── Login ────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, #b9e6ea 0%, #dcf2f4 55%, var(--bg) 100%);
  padding: calc(44px + env(safe-area-inset-top)) 24px 70px max(24px, calc(50% - 214px)); text-align: left;
}
.hero .logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 18px; }
.sheet { max-width: 460px; margin: -48px auto 0; padding: 0 16px 30px; position: relative; }
.sheet .card { padding: 22px 18px; }
.foot { text-align: center; color: var(--ink-3); font-size: .78rem; margin: 10px 0 0; }
.foot b { color: var(--ink-2); font-weight: 600; }

/* ── Campos ───────────────────────────────────────────────── */
label.lbl { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-2); margin: 0 0 6px 2px; }
label.lbl .req { color: var(--bad); }
.field { margin-bottom: 14px; }
.inp {
  width: 100%; border: 1.5px solid transparent; background: var(--fill); border-radius: var(--r-sm);
  padding: 14px; font: inherit; font-size: 16px; color: var(--ink); outline: none; appearance: none; -webkit-appearance: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.inp::placeholder { color: var(--ink-3); }
.inp:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,153,0,.16); }
.inp.up { text-transform: uppercase; }
select.inp {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b98a5' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* ── Chips ────────────────────────────────────────────────── */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 0; border: 0; background: var(--fill); border-radius: 999px; padding: 12px 10px;
  font-size: .9rem; font-weight: 600; color: var(--ink-2); transition: .15s;
}
.seg button.on { background: var(--brand); color: #fff; box-shadow: 0 4px 10px rgba(19,25,33,.2); }
.seg button.on.ok { background: var(--ok); } .seg button.on.warn { background: var(--warn); } .seg button.on.bad { background: var(--bad); }

/* ── Cantidad ─────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--fill); border-radius: 16px; padding: 6px; }
.stepper button { width: 50px; height: 50px; border-radius: 12px; border: 0; background: #fff; font-size: 1.5rem; font-weight: 500; box-shadow: 0 1px 3px rgba(15,20,25,.1); line-height: 1; }
.stepper button:active { transform: scale(.94); }
.stepper .inp { background: transparent; border: 0; text-align: center; font-weight: 700; font-size: 1.5rem; width: 90px; padding: 6px 0; box-shadow: none; }

/* ── Foto ─────────────────────────────────────────────────── */
.foto-box {
  border-radius: 16px; background: linear-gradient(160deg, #f6fbfb, var(--fill)); min-height: 190px;
  border: 2px dashed #c5d3d8; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; cursor: pointer; overflow: hidden; color: var(--ink-2); font-size: .88rem; text-align: center; line-height: 1.35;
}
.foto-box:active { background: var(--teal-bg); border-color: var(--teal); }
.foto-box .cam { width: 62px; height: 62px; border-radius: 50%; background: var(--accent); color: var(--brand); display: grid; place-items: center; box-shadow: 0 8px 18px rgba(255,153,0,.35); }
.foto-box small { color: var(--ink-3); }
.foto-box.has { border: 0; min-height: 0; background: #000; }
.foto-box img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.foto-info { display: flex; justify-content: space-between; align-items: center; font-size: .75rem; color: var(--ink-3); margin-top: 8px; min-height: 4px; }

.gps { display: flex; align-items: center; gap: 8px; font-size: .82rem; padding: 11px 14px; border-radius: var(--r-sm); background: var(--fill); color: var(--ink-2); font-weight: 500; }
.gps.ok { background: var(--ok-bg); color: var(--ok); } .gps.bad { background: var(--warn-bg); color: var(--warn); }
.gps button { margin-left: auto; background: none; border: 0; color: var(--teal); font-weight: 700; font-size: .8rem; }

/* ── Botones ──────────────────────────────────────────────── */
.btn {
  border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 1rem; background: var(--cta);
  color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 12px rgba(247,202,0,.35); transition: .15s;
}
.btn:active { background: var(--cta-2); transform: translateY(1px); }
.btn.full { width: 100%; }
.btn.sec2 { background: var(--fill); box-shadow: none; color: var(--ink); }
.btn.danger { background: var(--bad-bg); color: var(--bad); box-shadow: none; }
.btn.sm { padding: 8px 14px; font-size: .82rem; border-radius: 10px; }
.btn:disabled { opacity: .55; }
.submit-bar {
  position: fixed; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 60;
  padding: 12px 16px; background: linear-gradient(180deg, rgba(242,244,246,0), var(--bg) 40%);
}
.submit-bar .btn { max-width: 528px; margin: 0 auto; display: block; box-shadow: 0 8px 20px rgba(247,202,0,.45); }

/* ── Navegación inferior ──────────────────────────────────── */
.bnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: flex; background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.bnav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: .7rem; font-weight: 600; color: var(--ink-3); position: relative; }
.bnav button.on { color: var(--brand); }
.bnav button.on svg { color: var(--accent); }
.bnav .dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid #fff; }

/* ── Listado (Mis registros) ──────────────────────────────── */
.item { display: flex; gap: 14px; padding: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 12px; align-items: center; }
.item img { width: 84px; height: 84px; border-radius: 14px; object-fit: cover; background: var(--fill); flex: none; }
.item > div:nth-child(2) { flex: 1; min-width: 0; }
.item .t { font-weight: 700; font-size: .95rem; line-height: 1.25; letter-spacing: -.005em; }
.item .m { color: var(--ink-2); font-size: .78rem; margin-top: 3px; }
.qty { flex: none; min-width: 44px; text-align: center; font-weight: 800; font-size: 1rem; background: var(--fill); border-radius: 12px; padding: 9px 8px; }
.tag { display: inline-block; font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--teal-bg); color: var(--teal); margin-right: 4px; }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); } .tag.pend { background: var(--warn-bg); color: var(--warn); }
.empty { text-align: center; color: var(--ink-3); padding: 36px 10px; font-size: .9rem; }

/* ── Éxito ────────────────────────────────────────────────── */
.success {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 28px; text-align: center; background: linear-gradient(180deg, #dcf2f4 0%, #fff 45%);
}
.success .check { width: 96px; height: 96px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 14px var(--ok-bg); animation: pop .45s cubic-bezier(.2,1.4,.4,1); margin-bottom: 18px; }
.success .check svg { width: 46px; height: 46px; }
.success .code { font-size: 1.1rem; font-weight: 800; letter-spacing: .04em; background: var(--brand); color: #fff; padding: 8px 16px; border-radius: 999px; }
.success .sub { max-width: 320px; margin-bottom: 14px; }
.success .btn { width: 100%; max-width: 360px; }
.success.pend .check { background: #f59e0b; box-shadow: 0 0 0 14px var(--warn-bg); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Toast ────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%) translateY(16px); background: var(--brand); color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: .86rem; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s;
  z-index: 300; max-width: 90vw; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); } #toast.ok { background: var(--ok); }

/* ── Panel admin ──────────────────────────────────────────── */
.top.admin { padding-bottom: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; background: #fff; padding: 5px; border-radius: 999px; box-shadow: var(--shadow); align-items: center; }
.tabs button { border: 0; background: none; border-radius: 999px; padding: 10px 16px; font-size: .86rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tabs button.on { background: var(--brand); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.stat:nth-child(2)::before { background: var(--teal); } .stat:nth-child(3)::before { background: #6d4aff; }
.stat:nth-child(4)::before { background: #e0457b; } .stat:nth-child(5)::before { background: var(--ok); }
.stat b { font-size: 1.8rem; display: block; letter-spacing: -.02em; line-height: 1.1; }
.stat span { color: var(--ink-2); font-size: .76rem; font-weight: 500; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.filters .inp { background: #fff; box-shadow: var(--shadow); }
.tbl-wrap { overflow-x: auto; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; background: #fafbfc; position: sticky; top: 0; }
tbody tr { cursor: pointer; transition: background .1s; } tbody tr:hover { background: #f7fbfb; }
tbody tr:last-child td { border-bottom: 0; }
td img { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; display: block; }
#map { height: 62vh; min-height: 360px; border-radius: var(--r); box-shadow: var(--shadow); }
.modal { position: fixed; inset: 0; background: rgba(15,20,25,.55); backdrop-filter: blur(3px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { background: #fff; border-radius: 22px; max-width: 520px; width: 100%; max-height: 92vh; overflow: auto; padding: 14px 14px 18px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal img.big { width: 100%; border-radius: 16px; max-height: 46vh; object-fit: cover; background: #000; display: block; }
.modal h2 { margin: 14px 0 2px; font-size: 1.2rem; letter-spacing: -.01em; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.modal h2 .qty { font-size: .95rem; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px 10px; font-size: .86rem; margin: 14px 0; padding: 14px; background: var(--fill); border-radius: 14px; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; font-weight: 600; }
.hint { font-size: .76rem; color: var(--ink-3); margin-top: 4px; }

@media (max-width: 600px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal .box { border-radius: 24px 24px 0 0; max-width: none; }
}
@media (min-width: 900px) {
  .wrap:not(.wide) { padding-top: 28px; }
}

/* ── Logo "E + caja" ──────────────────────────────────────── */
.logo { width: auto; min-width: 38px; padding: 0 9px; gap: 2px; display: flex; align-items: center; justify-content: center; }
.logo b { font-weight: 800; font-size: 1.25rem; line-height: 1; letter-spacing: -.02em; color: var(--accent); }
.hero .logo { height: 64px; padding: 0 16px; gap: 4px; width: auto; display: inline-flex; }
.hero .logo b { font-size: 2.2rem; }
.hero .logo svg { width: 34px; height: 34px; }
.eyebrow { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--teal); margin: 0 0 8px; line-height: 1.35; }

/* ── Controles nuevos ─────────────────────────────────────── */
.top-actions { gap: 6px; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--fill); border-radius: 12px; padding: 12px 14px; font-weight: 600; font-size: .9rem; }
.sw input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: #cfd6db; position: relative; transition: .2s; flex: none; margin: 0; cursor: pointer; }
.sw input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.sw input:checked { background: var(--ok); } .sw input:checked::after { left: 21px; }
.sw input:disabled { opacity: .45; }
.iw { position: relative; }
.iw .inp { padding-right: 52px; }
.mic { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); display: grid; place-items: center; }
.mic.rec { background: var(--bad); color: #fff; animation: pulso 1s infinite; }
@keyframes pulso { 50% { box-shadow: 0 0 0 8px rgba(194,50,27,.18); } }
.seg.tres button { padding: 12px 4px; font-size: .8rem; }
.hint2 { font-size: .74rem; color: var(--ink-3); margin: 8px 2px 0; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--teal); }

/* Tarjeta de estado de la bodega (Mis registros) */
.bodega { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.bodega .info { flex: 1; min-width: 0; }
.bodega b { display: block; font-size: .95rem; }
.bodega span { font-size: .78rem; color: var(--ink-2); }
.bodega.cerrada { background: var(--ok-bg); }
.bodega.cerrada b { color: var(--ok); }

/* Hoja de detalle / edición */
.sheet-modal { align-items: flex-end; padding: 0; }
.sheet-modal .box { max-width: 560px; border-radius: 24px 24px 0 0; max-height: 94vh; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet-modal { align-items: center; padding: 16px; } .sheet-modal .box { border-radius: 22px; } }
.box .tl { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 2px; }
.box .tl h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.01em; }
.nota-ed { background: var(--warn-bg); color: var(--warn); font-size: .78rem; font-weight: 600; padding: 9px 12px; border-radius: 10px; margin: 10px 0; }

/* Tarjeta instalar */
.instalar { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 14px; margin-top: 14px; font-size: .82rem; color: var(--ink-2); }
.instalar .btn { margin-left: auto; padding: 9px 14px; font-size: .82rem; }

/* Tags de destino */
.tag.rep { background: var(--warn-bg); color: var(--warn); } .tag.baj { background: var(--bad-bg); color: var(--bad); }

/* ── Panel: avance, gráficos, catálogo ────────────────────── */
.progreso { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.progreso .pct { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; }
.barra-p { height: 12px; background: var(--fill); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.barra-p i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #ffc766); border-radius: 6px; transition: width .5s; }
.grid-av { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.av { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.av h3 { margin: 0 0 4px; font-size: .98rem; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.av .nums { display: flex; gap: 14px; margin: 10px 0; font-size: .78rem; color: var(--ink-2); }
.av .nums b { display: block; font-size: 1.15rem; color: var(--ink); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.chart h4 { margin: 0 0 10px; font-size: .9rem; }
.chart canvas { max-height: 260px; }
.dos-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.acciones .btn { padding: 10px 14px; font-size: .84rem; }
.filters label.lbl { margin-bottom: 4px; }
