/* Sistema de diseño: blanco con acento rojo del logo. Sin degradados. */
:root {
  --brand: #d7202a;
  --brand-700: #b0151e;
  --tint: #fdecec;
  --bg: #f6f6f7;
  --field: #f1f1f3;
  --card: #ffffff;
  --text: #1b1b1f;
  --muted: #5f6368;
  --line: #e7e7ea;
  --sale: #c92a2a;
  --red: #c92a2a;
  --red-bg: #fcebeb;
  --amber: #9a5b00;
  --amber-bg: #fff3d9;
  --green: #0b7a4b;
  --green-bg: #e6f6ef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 27, 31, 0.06), 0 8px 20px -14px rgba(27, 27, 31, 0.25);
  --tabs-h: 64px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Figtree, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin-top: -4px; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ---------- botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text); font-weight: 700; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { background: var(--line); border-color: var(--line); color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover, .btn.primary:active { background: var(--brand-700); border-color: var(--brand-700); }
.btn.soft { background: var(--tint); border-color: transparent; color: var(--brand-700); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--tint); }
.btn.wa { background: var(--green); border-color: var(--green); color: #fff; }
.btn.in { background: var(--green-bg); border-color: transparent; color: var(--green); }
.btn.out { background: var(--red-bg); border-color: transparent; color: var(--red); }
.btn.danger-text { border-color: transparent; background: transparent; color: var(--red); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); font-size: 16px;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.on { color: var(--brand); }
.icon-btn.on svg { fill: currentColor; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
form input:not([type=checkbox]):not([type=file]), form select, form textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); font-weight: 400; font-size: 16px;
}
textarea { resize: vertical; }
form input:focus, form select:focus, form textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.btn:focus-visible, .card:focus-visible, .tab:focus-visible, .chip:focus-visible, .stat:focus-visible, .icon-btn:focus-visible, .cat-tile:focus-visible, .fav:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px;
}
form { display: grid; gap: 14px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.form-error { color: var(--red); background: var(--red-bg); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* ---------- acceso ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; padding: 8px 4px; }
.auth-logo { width: 190px; max-width: 60%; margin: 0 auto 4px; display: block; }
.auth-card h1 { text-align: center; font-size: 22px; font-weight: 800; }
.auth-card .muted { text-align: center; }

/* ---------- cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1180px; margin: 0 auto; }
.top-logo { width: 40px; height: 40px; border-radius: 10px; }
.top-title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; margin-right: auto; }
.top-title strong { font-size: 16px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.top-title span { font-size: 12px; color: var(--muted); }
.top-avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
  background: var(--tint); color: var(--brand-700); font-weight: 800;
}
.net { padding: 5px 10px; border-radius: 99px; background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 700; white-space: nowrap; }
.top-search {
  display: flex; align-items: center; gap: 10px; max-width: 1180px; margin: 12px auto 0; padding: 0 14px; height: 46px;
  background: var(--field); border-radius: 12px; color: var(--brand); border: 2px solid transparent;
}
.top-search svg { width: 20px; height: 20px; flex: none; }
.top-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; font-weight: 400; }
.top-search:focus-within { background: #fff; border-color: var(--brand); }

/* ---------- navegación ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; height: calc(var(--tabs-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tab {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tab i { width: 44px; height: 28px; border-radius: 99px; display: grid; place-items: center; }
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--brand-700); font-weight: 800; }
.tab.active i { background: var(--tint); }

main { padding: 16px 16px calc(var(--tabs-h) + var(--safe-b) + 28px); max-width: 1212px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-title { font-size: 22px; font-weight: 800; line-height: 1.25; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar .page-title { flex: 1; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel h3 { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.panel .muted { margin-bottom: 12px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section-head h2 { font-size: 17px; font-weight: 800; }
.section-head span { font-size: 13px; color: var(--muted); }
.link { border: 0; background: none; padding: 8px 0; color: var(--brand); font-size: 13px; font-weight: 700; }

/* ---------- inicio ---------- */
.mode { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pill { padding: 4px 10px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-weight: 600; white-space: nowrap; }
.promo {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 18px; border-radius: 16px; background: var(--text); color: #fff;
}
.promo::after { content: ""; position: absolute; right: -34px; top: -34px; width: 150px; height: 150px; border-radius: 50%; background: var(--brand); opacity: 0.9; }
.promo > * { position: relative; z-index: 1; }
.promo small { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ffb3b6; }
.promo h2 { font-size: 22px; line-height: 1.2; font-weight: 800; max-width: 240px; }
.promo .btn { margin-top: 8px; border-color: #fff; }

.stats { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.stats::-webkit-scrollbar { display: none; }
.stat {
  flex: 1 0 auto; min-width: 128px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat strong { font-size: 20px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.stat.alert strong { color: var(--red); }
.stat.warn strong { color: var(--amber); }
.stat.on { border-color: var(--brand); background: var(--tint); }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 13px; color: var(--text); }
.chip.on { background: var(--tint); border-color: var(--brand-700); color: var(--brand-700); font-weight: 700; }

.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cat-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
}
.cat-tile i { width: 44px; height: 44px; border-radius: 12px; background: var(--tint); color: var(--brand); display: grid; place-items: center; flex: none; font-style: normal; font-weight: 800; font-size: 18px; }
.cat-tile b { display: block; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.cat-tile span span { font-size: 12px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden; cursor: pointer;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-img { position: relative; flex: none; display: grid; place-items: center; width: 100%; height: 132px; background: var(--field); }
.card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph { width: 38px; height: 38px; color: #b9bcc4; }
.tag { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 99px; background: var(--sale); color: #fff; font-size: 12px; font-weight: 800; }
.tag.big { top: 12px; left: 12px; font-size: 13px; padding: 4px 10px; }
.fav {
  position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: #fff; color: var(--muted); display: grid; place-items: center;
}
.fav svg { width: 17px; height: 17px; }
.fav.on { color: var(--brand); }
.fav.on svg { fill: currentColor; }
.card-info { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; min-width: 0; }
.card-meta { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 15px; }
.card-name { font-size: 14px; font-weight: 600; line-height: 1.3; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; min-height: 24px; }
.card-price b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-price b.sale { color: var(--sale); }
.card-price s { color: var(--muted); font-size: 12px; }
.avail { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.avail::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.avail.ok { color: var(--green); }
.avail.low { color: var(--amber); }
.avail.out { color: var(--red); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badges:empty { display: none; }
.badge { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge.out { background: var(--red-bg); color: var(--red); }
.badge.low, .badge.warn { background: var(--amber-bg); color: var(--amber); }
.empty { grid-column: 1 / -1; padding: 48px 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

.advisor { display: flex; align-items: center; gap: 12px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.advisor i { width: 44px; height: 44px; border-radius: 12px; background: var(--green-bg); color: var(--green); display: grid; place-items: center; flex: none; }
.advisor i svg { width: 22px; height: 22px; }
.advisor div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.advisor b { font-size: 14px; }
.advisor span { font-size: 13px; color: var(--muted); }

/* ---------- hoja / diálogo ---------- */
dialog#sheet {
  width: 100%; max-width: 620px; max-height: 94dvh; margin: auto auto 0; padding: var(--pad) var(--pad) calc(22px + var(--safe-b));
  border: 0; border-radius: 20px 20px 0 0; background: #fff; color: var(--text); overflow-y: auto;
}
dialog#sheet::backdrop { background: rgba(27, 27, 31, 0.55); }
dialog#sheet > * + * { margin-top: 18px; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; }
.sheet-head h2 { flex: 1; font-size: 20px; font-weight: 800; overflow-wrap: anywhere; padding-top: 8px; }
.sheet-head .icon-btn, .hero .icon-btn { background: var(--field); border-radius: 50%; }
dialog h3 { font-size: 16px; font-weight: 800; }

.hero { position: relative; overflow: hidden; display: grid; place-items: center; height: min(280px, 40dvh); border-radius: 18px; background: var(--field); }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.hero .ph { width: 64px; height: 64px; }
.hero-btns { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; }
.hero .icon-btn { background: #fff; }
.detail-head { display: flex; flex-direction: column; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.07em; }
.detail-head h2 { font-size: 22px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.price-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.price-big strong { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.price-big.sale strong { color: var(--sale); }
.price-big s { color: var(--muted); font-size: 15px; }
.price-big em { font-style: normal; font-weight: 700; font-size: 12px; color: #a61e1e; background: var(--red-bg); padding: 3px 9px; border-radius: 99px; }
.detail-avail { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.detail-avail .avail { font-size: 14px; }
.detail-avail .avail::before { width: 8px; height: 8px; }

.qty-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.qty-box > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qty-box b { font-size: 15px; }
.qty-total { padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.qty-total strong { font-size: 18px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.qty { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 2px; }
.qty button { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: var(--field); font-size: 20px; font-weight: 700; }
.qty button:last-child { background: var(--tint); color: var(--brand-700); }
.qty output { min-width: 36px; text-align: center; font-size: 16px; font-weight: 800; }

.sheet-bar {
  position: sticky; bottom: calc(-22px - var(--safe-b)); z-index: 2; display: flex; gap: 10px;
  margin: 18px calc(var(--pad) * -1) calc(-22px - var(--safe-b)); padding: 12px var(--pad) calc(14px + var(--safe-b));
  background: #fff; border-top: 1px solid var(--line);
}
.sheet-bar .btn { min-height: 50px; }
.sheet-bar .btn.primary { flex: 1; min-width: 0; }
.sheet-bar .btn.sq { width: 50px; padding: 0; color: var(--green); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1; }
.actions.end { justify-content: flex-end; }
.actions.end .btn { flex: none; }
.fields { margin: 0; padding: 4px 14px; border-radius: 12px; background: var(--bg); font-size: 14px; }
.fields:not(:has(div)) { display: none; }
.fields div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fields div:last-child { border-bottom: 0; }
.fields dt { color: var(--muted); flex: none; }
.fields dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.desc { font-size: 14px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.pricing > div { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.pricing span { font-size: 12px; font-weight: 600; color: var(--muted); }
.pricing strong { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pricing .pos { color: var(--green); }
.pricing .neg { color: var(--red); }

.photo-zone { display: flex; align-items: center; gap: 14px; }
.photo-frame {
  flex: none; width: 132px; height: 132px; border-radius: 18px; overflow: hidden; cursor: pointer;
  display: grid; place-items: center; background: var(--field); border: 2px dashed #c9cbd1;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-frame:has(img:not([hidden])) { border: 1px solid var(--line); }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--brand); font-size: 13px; }
.photo-empty svg { width: 34px; height: 34px; }
.photo-btns { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.photo-btns label { color: var(--text); }

/* ---------- listas ---------- */
.moves, .people { list-style: none; margin: 0; padding: 0; }
.moves li, .people li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.moves li:last-child, .people li:last-child { border-bottom: 0; }
.mv { flex: none; min-width: 64px; padding: 6px 8px; border-radius: 10px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.mv.entrada { background: var(--green-bg); color: var(--green); }
.mv.salida { background: var(--red-bg); color: var(--red); }
.mv.ajuste { background: var(--field); color: var(--text); }
.mv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; overflow-wrap: anywhere; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--brand-700); font-weight: 800; }
.people li.off { opacity: 0.55; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); z-index: 99;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: var(--text); color: #fff; font-weight: 600; font-size: 14px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); }

/* ---------- tablet y escritorio ---------- */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
}
@media (min-width: 700px) {
  :root { --pad: 24px; }
  .top { padding-left: 24px; padding-right: 24px; }
  main { padding-left: 24px; padding-right: 24px; }
  .stats, .chips { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .grid { gap: 16px; }
  .card-img { height: 160px; }
  dialog#sheet { margin: auto; border-radius: 20px; }
}
@media (min-width: 1000px) {
  .shell { padding-left: 92px; }
  .tabs {
    top: 0; right: auto; width: 92px; height: auto; flex-direction: column; justify-content: center; gap: 8px;
    padding: 16px 8px; border-top: 0; border-right: 1px solid var(--line);
  }
  .tab { flex: none; height: 64px; }
  main { padding-top: 24px; padding-bottom: 40px; }
  #toast { bottom: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
