/* =========================================================================
   Quanto — sistema de diseño
   Minimalista, cálido, mobile-first. CSS puro, sin dependencias.
   Temas: claro por defecto, oscuro por sistema (prefers-color-scheme)
   u override manual con [data-theme] en <body>.
   ========================================================================= */

:root {
  --bg: #f6f5f1;
  --surface: #fffefb;
  --surface-2: #edebe4;
  --sheet: #fbfaf7;

  --ink: #1b1d1a;
  --ink-2: #565b53;
  --ink-3: #6c7166;

  --line: color-mix(in oklab, #1b1d1a 9%, transparent);
  --line-strong: color-mix(in oklab, #1b1d1a 18%, transparent);

  --brand: #c41e1e;
  --brand-deep: #8b1515;
  --on-brand: #ffffff;
  --brand-soft: color-mix(in oklab, #c41e1e 8%, #fffefb);
  --brand-line: color-mix(in oklab, #c41e1e 30%, transparent);

  --info: #33618f;
  --info-soft: color-mix(in oklab, #33618f 10%, #fffefb);
  --danger: #a8352c;
  --danger-soft: color-mix(in oklab, #a8352c 9%, #fffefb);

  --radius-s: 12px;
  --radius-m: 18px;
  --radius-l: 26px;
  --radius-full: 999px;

  --shadow-1: 0 1px 2px rgba(18, 20, 18, .04), 0 6px 20px rgba(18, 20, 18, .05);
  --shadow-2: 0 2px 6px rgba(18, 20, 18, .09), 0 18px 44px rgba(18, 20, 18, .14);

  --ease: cubic-bezier(.2, 0, 0, 1);
  --dur: 260ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412;
    --surface: #1a1d1a;
    --surface-2: #252823;
    --sheet: #1e211e;

    --ink: #e7e9e3;
    --ink-2: #abb0a5;
    --ink-3: #7d8278;

    --line: color-mix(in oklab, #e7e9e3 10%, transparent);
    --line-strong: color-mix(in oklab, #e7e9e3 20%, transparent);

    --brand: #ff6b6b;
    --brand-deep: #ff9999;
    --on-brand: #ffffff;
    --brand-soft: color-mix(in oklab, #ff6b6b 12%, #1a1d1a);
    --brand-line: color-mix(in oklab, #ff6b6b 32%, transparent);

    --info: #a9c8ea;
    --info-soft: color-mix(in oklab, #a9c8ea 14%, #1a1d1a);
    --danger: #f0a9a2;
    --danger-soft: color-mix(in oklab, #f0a9a2 12%, #1a1d1a);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 44px rgba(0, 0, 0, .45);
  }
}

/* Override manual (QA o preferencia futura del usuario) */
[data-theme="light"] {
  --bg: #f6f5f1; --surface: #fffefb; --surface-2: #edebe4; --sheet: #fbfaf7;
  --ink: #1b1d1a; --ink-2: #565b53; --ink-3: #6c7166;
  --line: color-mix(in oklab, #1b1d1a 9%, transparent);
  --line-strong: color-mix(in oklab, #1b1d1a 18%, transparent);
  --brand: #c41e1e; --brand-deep: #8b1515; --on-brand: #ffffff;
  --brand-soft: color-mix(in oklab, #c41e1e 8%, #fffefb);
  --brand-line: color-mix(in oklab, #c41e1e 30%, transparent);
  --info: #33618f; --info-soft: color-mix(in oklab, #33618f 10%, #fffefb);
  --danger: #a8352c; --danger-soft: color-mix(in oklab, #a8352c 9%, #fffefb);
  --shadow-1: 0 1px 2px rgba(18, 20, 18, .04), 0 6px 20px rgba(18, 20, 18, .05);
  --shadow-2: 0 2px 6px rgba(18, 20, 18, .09), 0 18px 44px rgba(18, 20, 18, .14);
}
[data-theme="dark"] {
  --bg: #121412; --surface: #1a1d1a; --surface-2: #252823; --sheet: #1e211e;
  --ink: #e7e9e3; --ink-2: #abb0a5; --ink-3: #7d8278;
  --line: color-mix(in oklab, #e7e9e3 10%, transparent);
  --line-strong: color-mix(in oklab, #e7e9e3 20%, transparent);
  --brand: #ff6b6b; --brand-deep: #ff9999; --on-brand: #ffffff;
  --brand-soft: color-mix(in oklab, #ff6b6b 12%, #1a1d1a);
  --brand-line: color-mix(in oklab, #ff6b6b 32%, transparent);
  --info: #a9c8ea; --info-soft: color-mix(in oklab, #a9c8ea 14%, #1a1d1a);
  --danger: #f0a9a2; --danger-soft: color-mix(in oklab, #f0a9a2 12%, #1a1d1a);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 44px rgba(0, 0, 0, .45);
}

/* ============================== Base ==================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding-top: max(12px, env(safe-area-inset-top));
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

svg[hidden] { display: none; }

.tabular { font-variant-numeric: tabular-nums; }

/* ============================ Tipografía ================================ */

.kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 650; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px;
}
.kicker::before {
  content: ""; width: 8px; height: 8px; border-radius: 3px;
  background: var(--brand); flex: none;
}
.display {
  font-size: 30px; font-weight: 750; letter-spacing: -.02em;
  line-height: 1.15; margin: 0;
}
.title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.lede { font-size: 15px; color: var(--ink-2); margin: 8px 0 0; max-width: 42ch; }
.caption { font-size: 13px; color: var(--ink-2); margin: 0; }
.micro { font-size: 12px; color: var(--ink-3); }

/* ============================== Layout ================================== */

.container { max-width: 500px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 20px calc(132px + env(safe-area-inset-bottom)); }

main[data-view] > section.screen { display: none; }
main[data-view="home"] #view-home,
main[data-view="comparar"] #view-comparar,
main[data-view="escanear"] #view-escanear,
main[data-view="listas"] #view-listas,
main[data-view="historial"] #view-historial { display: block; animation: screen-in var(--dur) var(--ease); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.screen-head {
  margin: 0 0 28px;
  padding: 8px 0;
  position: sticky;
  top: max(8px, env(safe-area-inset-top));
  background: var(--bg);
  z-index: 10;
}
.screen-head.with-back {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
  background: var(--bg);
  padding: 12px 0 16px;
}

.block { margin-bottom: 28px; }
.block-label {
  font-size: 13px; font-weight: 650; color: var(--ink-3);
  letter-spacing: .04em; text-transform: uppercase; margin: 0 0 12px;
}

/* ============================== Tarjetas ================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.action-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px;
  min-height: 128px;
  box-shadow: var(--shadow-1);
  color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.action-tile:active { transform: scale(.98); }
.action-tile:hover { border-color: var(--line-strong); }
.action-tile .tile-title { display: block; font-size: 15px; font-weight: 650; }
.action-tile .tile-caption { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }

.icon-circle {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand);
  border: 1px solid var(--brand-line);
  flex: none;
}
.icon-circle svg { width: 20px; height: 20px; }

/* ============================== Botones ================================= */

button { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 22px;
  border: none; border-radius: var(--radius-full);
  background: var(--brand); color: var(--on-brand);
  font-size: 15px; font-weight: 650; letter-spacing: .01em;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn[hidden] { display: none; }
.btn svg { width: 18px; height: 18px; }

.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-tonal { background: var(--brand-soft); color: var(--brand-deep); border: 1px solid var(--brand-line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in oklab, var(--danger) 35%, transparent); }
.btn-quiet { background: transparent; color: var(--ink-2); min-height: 44px; padding: 8px 12px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer; flex: none;
  transition: transform var(--dur) var(--ease);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }

.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-col { display: flex; flex-direction: column; gap: 10px; }

/* ============================ Formularios =============================== */

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 6px;
}
.input, select.input {
  width: 100%; min-height: 52px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  padding: 0 14px; font-size: 16px;
  transition: border-color var(--dur) var(--ease);
}
.input:focus { border-color: var(--brand); outline: none; }
.input::placeholder { color: var(--ink-3); }
.input:disabled { color: var(--ink-3); background: var(--surface-2); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-grid-3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; }

/* Segmentado */
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border-radius: var(--radius-full);
}
.seg button {
  flex: 1; min-height: 44px; border: none; border-radius: var(--radius-full);
  background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1);
}

/* ============================== Badges ================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 650;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--radius-full);
  background: currentColor; opacity: .7;
}
.badge-estimado { background: var(--surface-2); color: var(--ink-2); }
.badge-verificado { background: var(--info-soft); color: var(--info); border: 1px solid color-mix(in oklab, var(--info) 25%, transparent); }
.badge-facturado { background: var(--brand-soft); color: var(--brand-deep); border: 1px solid var(--brand-line); }

.chip-mas { color: var(--danger); background: var(--danger-soft); }
.chip-menos { color: var(--brand-deep); background: var(--brand-soft); }
.chip-neutro { color: var(--ink-2); background: var(--surface-2); }
.chip { display: inline-flex; padding: 3px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }

/* ============================ Comparador ================================ */

/* Tarjeta de producto: todos los productos visibles a la vez, compactos */
.cmp-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 14px;
  margin-bottom: 12px; box-shadow: var(--shadow-1);
}

.cmp-card-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.cmp-badge {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-deep);
  font-size: 13px; font-weight: 750;
}
.cmp-name {
  flex: 1; min-width: 0; min-height: 44px;
  border: none; background: transparent; color: var(--ink);
  font-size: 16px; font-weight: 650; padding: 0 2px;
}
.cmp-name::placeholder { color: var(--ink-3); font-weight: 500; }
.cmp-name:focus { outline: none; }
.cmp-remove {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--surface-2); color: var(--ink-3);
  font-size: 14px; cursor: pointer; transition: all var(--dur) var(--ease);
}
.cmp-remove:hover { background: var(--danger-soft); color: var(--danger); }

.cmp-fields {
  display: grid; grid-template-columns: 1fr 1.3fr minmax(98px, auto); gap: 8px;
}
.cmp-fgroup { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cmp-flabel {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3); padding-left: 4px;
}
.cmp-field {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid transparent;
  border-radius: 12px; padding: 0 10px; min-height: 48px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.cmp-field:focus-within { border-color: var(--brand-line); background: var(--surface); }
.cmp-affix { color: var(--ink-3); font-size: 15px; font-weight: 600; flex: none; }
.cmp-input {
  width: 100%; min-width: 0; border: none; background: transparent;
  color: var(--ink); font-size: 15px; font-weight: 650; padding: 0;
  text-align: center;
  appearance: textfield; -moz-appearance: textfield;
}
.cmp-input::-webkit-inner-spin-button,
.cmp-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cmp-input:focus { outline: none; }
.cmp-field-price .cmp-input { text-align: left; }
.cmp-unit {
  flex: none; border: none; background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 650; cursor: pointer; padding: 0 2px;
}
.cmp-unit:focus { outline: none; }
.cmp-field-packs { padding: 0 4px; gap: 0; justify-content: space-between; }

/* Stepper de envases: tocar en vez de teclear */
.cmp-step {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--surface); color: var(--ink-2);
  font-size: 17px; font-weight: 700; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-1);
}
.cmp-step:active { background: var(--brand-soft); color: var(--brand-deep); }
.cmp-envval { min-width: 22px; text-align: center; font-size: 15px; font-weight: 650; }

/* Chips de tamaños comunes: un toque llena el contenido */
.cmp-chips {
  display: flex; gap: 6px; overflow-x: auto; margin-top: 10px;
  padding-bottom: 2px; scrollbar-width: none;
}
.cmp-chips::-webkit-scrollbar { display: none; }
.cmp-chip {
  flex: none; border: 1px solid var(--line); border-radius: var(--radius-full);
  background: var(--surface); color: var(--ink-2);
  padding: 7px 13px; font-size: 13px; font-weight: 650; cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.cmp-chip.is-sel {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep);
}

/* Stepper y chips dentro del wizard de agregar item */
.wz-step {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-1);
}
.wz-step:active { background: var(--brand-soft); color: var(--brand-deep); border-color: var(--brand-line); }
.wz-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }

.cmp-live {
  margin-top: 10px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.cmp-live.is-on { color: var(--brand-deep); }

.btn-add-product {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; margin: 4px 0 12px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m);
  background: transparent; color: var(--ink-2);
  font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.btn-add-product svg { width: 20px; height: 20px; }
.btn-add-product:hover {
  border-color: var(--brand-line); color: var(--brand-deep); background: var(--brand-soft);
}

.example-link-row { text-align: center; margin-bottom: 24px; }
.btn-link {
  border: none; background: none; cursor: pointer;
  color: var(--ink-3); font: inherit; font-size: 13px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: var(--brand-deep); }

.result-winner {
  background: linear-gradient(145deg, var(--brand-soft), color-mix(in oklab, var(--brand) 3%, var(--surface)));
  border: 1.5px solid var(--brand-line);
  border-radius: var(--radius-m);
  padding: 20px;
  box-shadow: var(--shadow-1);
  animation: winner-in 420ms var(--ease);
}
@keyframes winner-in {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: none; }
}
.winner-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: var(--on-brand);
  padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
  margin-bottom: 10px;
}
.winner-price { font-size: 28px; font-weight: 750; letter-spacing: -.02em; color: var(--brand-deep); }
.winner-price small { font-size: 14px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }

.result-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.result-row:last-child { border-bottom: none; }
.result-delta { font-size: 13px; font-weight: 650; color: var(--danger); white-space: nowrap; margin-top: 2px; }
.result-delta.is-best { color: var(--brand-deep); }

/* Barra de costo relativo: cuanto más larga, más caro sale por 100 g/ml */
.result-bar-track {
  height: 6px; margin-top: 8px; border-radius: var(--radius-full);
  background: var(--surface-2); overflow: hidden;
}
.result-bar {
  height: 100%; border-radius: var(--radius-full);
  background: var(--danger); opacity: .55;
  transition: width 400ms var(--ease);
}
.result-bar.is-best { background: var(--brand); opacity: 1; }

.trick-note {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 14px; padding: 12px 14px;
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-s); font-size: 13px; font-weight: 550;
}
.trick-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

.hint-card {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-m);
  padding: 24px 20px; text-align: center; color: var(--ink-2); font-size: 14px;
  background: transparent;
}

/* ============================== Listas ================================== */

.list-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 16px;
  margin-bottom: 10px; cursor: pointer; font: inherit;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.list-row:active { transform: scale(.99); }
.list-row:hover { border-color: var(--line-strong); }
.list-row .row-main { flex: 1; min-width: 0; }
.list-row .row-title { display: block; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .row-meta { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.list-row .row-end { text-align: right; flex: none; }
.list-row .row-end svg { width: 20px; height: 20px; display: block; }
.list-row.is-active { border-color: var(--brand-line); background: var(--brand-soft); }

.item-price { font-size: 15px; font-weight: 700; }
.item-price.estimado { color: var(--ink-2); font-weight: 550; font-style: italic; }
.item-price.verificado { color: var(--info); }
.item-price.facturado { color: var(--brand-deep); }

.totals-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 16px;
}
.totals-strip .t-label { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.totals-strip .t-value { font-size: 17px; font-weight: 700; margin-top: 2px; }
.t-estimado .t-value { color: var(--ink-2); font-weight: 550; }
.t-verificado .t-value { color: var(--info); }
.t-facturado .t-value { color: var(--brand-deep); }
.t-value.pending { color: var(--ink-3); font-weight: 400; }

.strike .row-title { text-decoration: line-through; opacity: .6; }

.empty-state {
  text-align: center; padding: 40px 24px; color: var(--ink-2);
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m);
}
.empty-state p { margin: 0 0 16px; }

/* ============================== Cámara ================================== */

.camera-stage {
  position: relative; overflow: hidden;
  background: #0c0e0c;
  border-radius: var(--radius-m);
  aspect-ratio: 4 / 3; max-height: 300px; width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.camera-stage video { width: 100%; height: 100%; object-fit: cover; }
.camera-frame {
  position: absolute; inset: 14% 10%;
  border: 2px solid rgba(255, 255, 255, .75);
  border-radius: 16px;
  pointer-events: none;
}
.camera-status {
  position: absolute; left: 0; right: 0; bottom: 14px;
  text-align: center; color: #fff; font-size: 13px; font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

.camera-problem { text-align: left; }
.camera-problem .problem-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.camera-problem .problem-body { font-size: 14px; color: var(--ink-2); margin: 0; }

.scan-result-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.scan-result-line:last-of-type { border-bottom: none; }
.scan-result-line b { font-size: 17px; }

/* ============================= Historial ================================ */

.bars {
  display: flex; align-items: flex-end; gap: 8px;
  height: 120px; padding: 4px 2px 0;
}
.bars .bar {
  flex: 1; min-width: 10px;
  background: var(--brand);
  opacity: .85;
  border-radius: 6px 6px 3px 3px;
  transition: height 500ms var(--ease);
}
.bars .bar:last-child { opacity: 1; }
.bars-labels { display: flex; gap: 8px; margin-top: 8px; }
.bars-labels span { flex: 1; text-align: center; font-size: 10.5px; color: var(--ink-3); }

/* =========================== Bottom sheet =============================== */

.sheet-scrim {
  position: fixed; inset: 0; background: rgba(10, 12, 10, .45);
  opacity: 0; transition: opacity var(--dur) var(--ease);
  pointer-events: none; z-index: 40;
  backdrop-filter: blur(2px);
}
.sheet-scrim.open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(102%);
  transition: transform var(--dur) var(--ease);
  z-index: 41;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px; border-radius: var(--radius-full);
  background: var(--line-strong); margin: 0 auto 14px;
}
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; }
.sheet-sub { font-size: 13.5px; color: var(--ink-2); margin: 0 0 18px; }

/* ======================== Wizard / Multi-paso ========================== */

.wizard-screen {
  display: none;
  animation: screen-in var(--dur) var(--ease);
}
.wizard-screen.active { display: flex; flex-direction: column; }
.wizard-screen[data-step="0"].active { display: flex; } /* primer paso siempre visible */

.wizard-container {
  display: flex; flex-direction: column; gap: 0; min-height: 100%;
}

.wizard-progress {
  display: flex; gap: 6px; margin-bottom: 32px; padding: 12px;
  background: var(--surface-2); border-radius: var(--radius-s);
}
.wizard-progress .step {
  flex: 1; height: 4px; border-radius: var(--radius-full);
  background: color-mix(in oklab, var(--surface-2) 50%, var(--ink-2));
  transition: all var(--dur) var(--ease);
  opacity: .4;
}
.wizard-progress .step.active {
  background: var(--brand); opacity: 1;
  box-shadow: 0 0 12px color-mix(in oklab, var(--brand) 30%, transparent);
}
.wizard-progress .step.done {
  background: var(--brand); opacity: .8;
}

.wizard-content {
  flex: 1; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 200px;
}

.wizard-field-hero {
  margin-bottom: 24px;
}
.wizard-field-hero .label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-3); margin-bottom: 8px; text-transform: uppercase;
  letter-spacing: .04em;
}
.wizard-field-hero .input-hero {
  width: 100%; min-height: 80px;
  font-size: 36px; font-weight: 700; letter-spacing: -.01em;
  border: 2px solid var(--line-strong); border-radius: 20px;
  background: var(--surface);
  color: var(--ink); padding: 20px 24px;
  text-align: center;
  transition: all var(--dur) var(--ease);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}
.wizard-field-hero .input-hero:focus {
  outline: none; border-color: var(--brand);
  background: color-mix(in oklab, var(--brand) 2%, var(--surface));
  box-shadow: 0 0 0 10px color-mix(in oklab, var(--brand) 12%, transparent),
              0 4px 16px color-mix(in oklab, var(--brand) 20%, rgba(0,0,0,.1));
  transform: scale(1.02);
}
.wizard-field-hero .input-hero::placeholder { color: var(--ink-3); opacity: .5; }

.wizard-hint {
  font-size: 13px; color: var(--ink-2); margin-top: 8px; text-align: center;
}

.wizard-summary {
  background: var(--surface-2); border-radius: 14px;
  padding: 16px; margin: 16px 0;
}
.wizard-summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; font-size: 14px;
}
.wizard-summary-row:not(:last-child) { border-bottom: 1px solid var(--line); }
.wizard-summary-row strong { color: var(--ink); }
.wizard-summary-row .value { color: var(--ink-2); tabular-nums; }

.wizard-actions {
  display: flex; gap: 12px; margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--line);
}
.wizard-actions .btn {
  flex: 1; padding: 14px 16px;
  font-size: 16px; font-weight: 600;
  transition: all var(--dur) var(--ease);
}
.wizard-actions .btn:not(:disabled):active {
  transform: scale(.98);
}
.wizard-actions .btn-back {
  flex: 0 1 48px; padding: 12px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line);
  transition: all var(--dur) var(--ease);
}

/* Número grande con unidad pequeña */
.wizard-big-number {
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
  font-size: 60px; font-weight: 750;
  color: var(--brand-deep);
}
.wizard-big-number .unit {
  font-size: 20px; color: var(--ink-2); margin-bottom: 8px;
}

/* ========================== Navegación inferior ========================= */

.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 64px; min-height: 48px; padding-top: 4px;
  border: none; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
  transition: color var(--dur) var(--ease);
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--brand); }

@media (min-width: 900px) {
  .container { max-width: 560px; padding-top: 40px; }
  .navbar {
    left: 50%; right: auto; bottom: 20px; transform: translateX(-50%);
    border: 1px solid var(--line); border-radius: var(--radius-full);
    padding: 6px 10px; gap: 4px; box-shadow: var(--shadow-2);
  }
  .nav-item { min-width: 76px; border-radius: var(--radius-full); }
}

/* =============================== Toast ================================== */

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: var(--radius-full);
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ======================= Cierre item por item =========================== */

.cierre-item-row {
  display: grid; grid-template-columns: 1fr 100px; gap: 6px 12px;
  align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cierre-item-row:last-of-type { border-bottom: none; }
.cierre-item-row .input { min-height: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.cierre-item-chip { grid-column: 1 / -1; justify-self: end; }

/* ============================ Voz (dictado) ============================= */

.voice-listening {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--brand);
}
.voice-dot {
  width: 8px; height: 8px; border-radius: var(--radius-full);
  background: var(--brand); animation: voice-pulse 900ms ease-in-out infinite;
}
@keyframes voice-pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.15); opacity: 1; } }

/* ========================= Microinteracciones =========================== */
/* Todas quedan anuladas por el bloque prefers-reduced-motion de arriba. */

/* Foco de inputs con anillo suave */
.input { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-line); }

/* Hover de botones y tarjetas (solo dispositivos con puntero) */
@media (hover: hover) {
  .btn:not(.btn-ghost):not(.btn-quiet):not(.btn-tonal):not(.btn-danger):hover { background: color-mix(in oklab, var(--brand) 90%, black); }
  .btn-ghost:hover, .btn-quiet:hover { background: var(--surface-2); }
  .btn-tonal:hover { background: color-mix(in oklab, var(--brand) 14%, var(--surface)); }
  .btn-danger:hover { background: var(--danger-soft); }
  .icon-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
  .action-tile:hover .icon-circle { transform: translateY(-2px); }
  .list-row:hover .row-end svg { transform: translateX(3px); }
}
.icon-circle { transition: transform var(--dur) var(--ease); }
.list-row .row-end svg { transition: transform var(--dur) var(--ease); }

/* Indicador animado del tab activo + rebote del icono */
.nav-item { position: relative; }
.nav-item::before {
  content: ""; position: absolute; top: 0; left: 50%;
  width: 4px; height: 4px; border-radius: var(--radius-full);
  background: var(--brand);
  transform: translateX(-50%) scale(0);
  transition: transform var(--dur) var(--ease);
}
.nav-item.active::before { transform: translateX(-50%) scale(1); }
.nav-item.active svg { animation: nav-pop 340ms var(--ease); }
@keyframes nav-pop { 40% { transform: translateY(-2px) scale(1.12); } }

/* Entrada escalonada de filas y tarjetas de lista */
.list-row, .compare-card { animation: row-in 320ms var(--ease) backwards; animation-delay: var(--stagger, 0ms); }
@keyframes row-in { from { opacity: 0; transform: translateY(5px); } }

/* Barras del historial crecen desde la base */
.bars .bar { transform-origin: bottom; animation: bar-in 560ms var(--ease) backwards; animation-delay: var(--stagger, 0ms); }
@keyframes bar-in { from { transform: scaleY(0); } }

/* Contenido del sheet entra con un leve desplazamiento */
.bottom-sheet.open #bottomSheetContent { animation: sheet-in 300ms var(--ease) 50ms backwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px); } }

/* Toast con icono y escala */
.toast { display: flex; align-items: center; gap: 8px; transform: translateX(-50%) translateY(16px) scale(.96); }
.toast.show { transform: translateX(-50%) translateY(0) scale(1); }
.toast svg { width: 15px; height: 15px; flex: none; }

/* Píldora "Mejor compra" con entrada propia; sin replay si no cambió el ganador */
.winner-pill { animation: pill-in 380ms var(--ease) 80ms backwards; }
@keyframes pill-in { from { transform: scale(.8); opacity: 0; } }
.result-winner.no-anim, .result-winner.no-anim .winner-pill { animation: none; }

/* Flash al capturar con la cámara */
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.zap { animation: flash 380ms ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }

/* Punto que "vuela" hacia la pestaña Listas al agregar un item */
.fly-dot {
  position: fixed; width: 12px; height: 12px; border-radius: var(--radius-full);
  background: var(--brand); z-index: 100; pointer-events: none;
  transition: transform 620ms var(--ease), opacity 620ms var(--ease);
}

/* ================== Escáner: sesión multi-captura ======================= */

.auto-chip {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: var(--radius-full);
  background: rgba(0, 0, 0, .35); color: #fff;
  font-size: 12.5px; font-weight: 650; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.auto-chip::before {
  content: ""; width: 7px; height: 7px; border-radius: var(--radius-full);
  background: rgba(255, 255, 255, .45);
}
.auto-chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.auto-chip.on::before { background: currentColor; animation: voice-pulse 1.1s ease-in-out infinite; }

.scan-tray {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 2px 2px 10px; scroll-snap-type: x proximity;
}
.scan-card {
  flex: 0 0 152px; scroll-snap-align: start; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 10px;
  position: relative; cursor: pointer; font: inherit; color: inherit;
  animation: row-in 320ms var(--ease) backwards; animation-delay: var(--stagger, 0ms);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.scan-card:active { transform: scale(.97); }
.scan-card.is-best { border-color: var(--brand-line); background: var(--brand-soft); }
.scan-card img { display: block; width: 100%; height: 62px; object-fit: cover; border-radius: 9px; background: #0c0e0c; }
.scan-card .sc-precio { font-size: 16px; font-weight: 700; margin-top: 8px; }
.scan-card .sc-meta { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.sc-flag { position: absolute; top: 16px; left: 16px; z-index: 1; box-shadow: var(--shadow-1); }
