/* Economiza — CSS próprio, celular primeiro. Tema segue o sistema. */

:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --text: #17201a;
  --text-2: #56605a;
  --border: #d9ddd6;
  --primary: #1f7a3a;
  --primary-ink: #ffffff;
  --primary-soft: #dff1e3;
  --bought: #1e8e3e;          /* verde do "comprado" */
  --bought-soft: #d6f2dc;
  --partial: #b7791f;         /* amarelo do parcial */
  --partial-soft: #fbefd5;
  --danger: #c62828;
  --danger-soft: #fbe3e1;
  --focus: #0b57d0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  --tap: 48px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411;
    --surface: #18201b;
    --surface-2: #222b25;
    --text: #eef3ef;
    --text-2: #a8b3ab;
    --border: #2f3a33;
    --primary: #4cc26f;
    --primary-ink: #06210f;
    --primary-soft: #1d3a26;
    --bought: #4cc26f;
    --bought-soft: #1c3a25;
    --partial: #f0b44c;
    --partial-soft: #3a2e17;
    --danger: #ff6b6b;
    --danger-soft: #3d1f1f;
    --focus: #8ab4f8;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */

.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.25rem; font-weight: 700; flex: 1; }
.topbar .sub { color: var(--text-2); font-size: .875rem; }

.page { max-width: 640px; margin: 0 auto; padding: 16px; }

.stack > * + * { margin-top: 12px; }

/* ---------- Navegação inferior ---------- */

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap);
  color: var(--text-2); text-decoration: none;
  font-size: .75rem; font-weight: 600;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a[aria-current="page"] { color: var(--primary); }
.bottom-nav a.center { position: relative; color: var(--primary-ink); }
.bottom-nav a.center .bubble {
  display: grid; place-items: center;
  width: 56px; height: 56px; margin-top: -22px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 4px 14px rgb(31 122 58 / .35);
  border: 4px solid var(--surface);
}
.bottom-nav a.center span:last-child { color: var(--text-2); }
.bottom-nav a.center[aria-current="page"] span:last-child { color: var(--primary); }

/* ---------- Componentes ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 1.05rem; }
.muted { color: var(--text-2); }
.small { font-size: .875rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--primary-ink);
  font-weight: 700; font-size: 1rem;
  cursor: pointer; text-decoration: none;
  transition: transform .06s ease, filter .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn svg { width: 20px; height: 20px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text);
  cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }

.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-weight: 600; font-size: .9rem; }
.input {
  width: 100%; min-height: var(--tap);
  padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 1rem;
}
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.field.invalid .input { border-color: var(--danger); }
.field .error { display: block; margin-top: 4px; color: var(--danger); font-size: .85rem; font-weight: 600; }
.input.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; font-size: 1.25rem; text-align: center; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap);
}
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 16px;
  background: var(--border); transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgb(0 0 0 / .3);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; gap: 4px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.segmented button {
  min-height: 40px; border: 0; border-radius: 8px;
  background: transparent; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.alert {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-weight: 600;
}
.alert.info { background: var(--primary-soft); color: var(--primary); }

/* Lista de menu (tela Mais) */
.menu { list-style: none; margin: 0; padding: 0; }
.menu li + li { border-top: 1px solid var(--border); }
.menu a, .menu button {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 56px; padding: 0 4px;
  border: 0; background: transparent; text-align: left;
  color: var(--text); text-decoration: none; font-size: 1rem; cursor: pointer;
}
.menu svg { width: 22px; height: 22px; color: var(--text-2); flex: none; }
.menu .label { flex: 1; }
.menu .tag {
  font-size: .72rem; font-weight: 700; color: var(--text-2);
  background: var(--surface-2); padding: 2px 8px; border-radius: 999px;
}
.menu .danger { color: var(--danger); }
.menu .danger svg { color: var(--danger); }

/* Estado vazio */
.empty { text-align: center; padding: 40px 16px; }
.empty .art {
  display: grid; place-items: center;
  width: 88px; height: 88px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
}
.empty .art svg { width: 44px; height: 44px; }
.empty h2 { margin: 0 0 6px; font-size: 1.2rem; }
.empty p { margin: 0 auto; max-width: 34ch; color: var(--text-2); }

/* Código de convite */
.invite-code {
  display: flex; justify-content: center; gap: 6px; margin: 12px 0;
}
.invite-code span {
  display: grid; place-items: center;
  width: 42px; height: 52px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 1.5rem; font-weight: 800; font-family: ui-monospace, Menlo, Consolas, monospace;
}

.members { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.members li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface-2);
}
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: .9rem;
}

/* Bottom sheet (base para o Modo Mercado) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgb(0 0 0 / .4);
  animation: fade .15s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 90dvh; overflow: auto;
  max-width: 640px; margin: 0 auto;
  padding: 8px 16px calc(16px + var(--safe-b));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  animation: up .2s cubic-bezier(.2,.8,.2,1);
}
.sheet::before {
  content: ""; display: block; width: 40px; height: 5px; margin: 0 auto 12px;
  border-radius: 3px; background: var(--border);
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 50;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-weight: 600;
  box-shadow: var(--shadow);
  animation: fade .2s ease;
}

/* Indicador de conexão/sincronização */
.net {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700; color: var(--text-2);
}
.net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bought); }
.net.offline::before { background: var(--partial); }

/* Tela de entrada */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  max-width: 420px; margin: 0 auto; padding: 24px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; }
.brand h1 { margin: 0; font-size: 1.6rem; }
.brand p { margin: 0; color: var(--text-2); }

.splash { min-height: 100dvh; display: grid; place-items: center; color: var(--text-2); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Itens de menu ainda indisponíveis e selo "Chega na Fase N" */
.menu .item { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 4px; }
.menu .item.off { color: var(--text-2); }
.tag-soon {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-weight: 700;
}
.topbar .grow { flex: 1; min-width: 0; }

/* ---------- Fase 1: catálogo ---------- */

.label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .9rem; }
.error { display: block; margin-top: 4px; color: var(--danger); font-size: .85rem; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.danger-text { color: var(--danger); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
ul.plain { margin: 0; padding-left: 18px; }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.search .input { padding-left: 44px; }
.create-btn { justify-content: flex-start; border-style: dashed; }

.list-card { padding: 4px 12px; }
.group-title {
  margin: 12px 4px 4px; font-size: .78rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-2);
}
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--border); }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 8px 4px;
  border: 0; background: transparent; text-align: left; color: var(--text); cursor: pointer;
}
.row.static { cursor: default; }
.row > svg { width: 20px; height: 20px; color: var(--text-2); flex: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .85rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.inactive .row-title { color: var(--text-2); text-decoration: line-through; }
.row .icon-btn:disabled { opacity: .3; }
.pos { color: var(--bought); }
.neg { color: var(--danger); }

.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.lg { width: 20px; height: 20px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--text-2);
}
.badge.new { background: var(--primary-soft); color: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--text); }

.textarea { min-height: 200px; resize: vertical; font-family: inherit; line-height: 1.5; }

.file-drop {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 96px; border: 2px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; cursor: pointer;
}
.file-drop svg { width: 28px; height: 28px; }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.import-row { padding: 10px 12px; }
.import-row.invalid { border-color: var(--danger); }
.import-top { display: flex; gap: 6px; align-items: center; }
.import-top .name { font-weight: 700; }
.import-fields { display: grid; grid-template-columns: 76px 1fr 1.4fr; gap: 6px; margin-top: 6px; }
.import-fields .input { padding: 8px 10px; }
.import-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: .8rem; color: var(--text-2); }
.price-chip { padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); font-weight: 600; }
.raw { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.store-line { display: flex; align-items: center; gap: 10px; }
.store-line input[type="checkbox"] { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }

.summary { list-style: none; margin: 0; padding: 0; }
.summary li { padding: 8px 0; font-size: 1.05rem; }
.summary li + li { border-top: 1px solid var(--border); }
.summary strong { display: inline-block; min-width: 2.5ch; color: var(--primary); font-size: 1.25rem; }

/* ---------- Fase 2: lista e preços ---------- */

.center-text { text-align: center; }
.alert.warn { background: var(--partial-soft); color: var(--partial); }
.alert.link { display: block; text-decoration: none; }

/* Lista do mês */
.with-footer { padding-bottom: 88px; }
.list-row { gap: 6px; padding-right: 0; }
.as-button { border: 0; background: transparent; text-align: left; color: inherit; padding: 6px 0; cursor: pointer; min-height: 48px; justify-content: center; }
.list-row.skipped .row-title { text-decoration: line-through; color: var(--text-2); }
.stepper { display: flex; align-items: center; flex: none; }
.stepper .icon-btn { width: 44px; height: 44px; background: var(--surface-2); }
.stepper .icon-btn svg { width: 20px; height: 20px; }
.stepper .qty { min-width: 64px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .95rem; }

.footer-bar {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: calc(var(--nav-h) + var(--safe-b));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto; padding: 10px 16px;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgb(0 0 0 / .06);
}
.footer-bar .big { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.footer-bar a { color: var(--primary); font-weight: 700; text-decoration: none; }

.picker-results { max-height: 50dvh; overflow: auto; }
.picker-results .row:disabled { opacity: .5; cursor: default; }

/* Resumo da comparação */
.totals { list-style: none; margin: 0; padding: 0; }
.totals li { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-variant-numeric: tabular-nums; }
.totals li + li { border-top: 1px solid var(--border); }
.totals li.best .common { color: var(--primary); font-weight: 800; }
.totals li.best:not(.partial) strong { color: var(--primary); }
.totals .common { display: block; font-size: .8rem; color: var(--text-2); font-weight: 600; }
.totals .grow { flex: 1; font-weight: 600; }
.totals .right { text-align: right; }

.plans { display: grid; gap: 10px; margin-top: 12px; }
@media (min-width: 520px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.plan.recommended { border-color: var(--primary); background: var(--primary-soft); }
.plan-head { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; font-weight: 700; color: var(--text-2); }
.plan-body { flex: 1; }
.savings { color: var(--bought); font-weight: 700; font-size: .9rem; }

/* Grade de preços */
.grid-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.price-grid { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
.price-grid th, .price-grid td { border-bottom: 1px solid var(--border); padding: 0; }
.price-grid thead th {
  padding: 10px 8px; font-size: .78rem; text-align: center; white-space: nowrap;
  color: var(--text-2); background: var(--surface);
}
.price-grid thead .dot { display: inline-block; width: 8px; height: 8px; }
.price-grid .sticky {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  text-align: left; padding: 8px 10px; min-width: 128px; max-width: 46vw;
  border-right: 1px solid var(--border); font-weight: 400;
}
.price-grid th.sticky .row-title, .price-grid th.sticky .row-sub { display: block; }
.price-grid td button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-width: 88px; min-height: 56px; padding: 4px 6px;
  border: 0; background: transparent; color: var(--text); font-weight: 600; cursor: pointer;
}
.price-grid td.old button { color: var(--text-2); font-weight: 500; }
.price-grid td.cheapest { background: var(--bought-soft); }
.price-grid td.cheapest button { color: var(--bought); font-weight: 800; }
.price-grid td.planned button { box-shadow: inset 0 -3px 0 var(--primary); }
.price-grid .promo, .price-grid .stale-tag { font-size: .65rem; font-weight: 700; line-height: 1.1; }
.price-grid .promo { color: var(--danger); }
.price-grid .stale-tag { color: var(--partial); }
.legend { margin: 0; }
.legend-box { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; background: var(--bought-soft); border: 1px solid var(--bought); }
.legend-text-old { color: var(--text-2); }
.price-input { font-size: 1.5rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.row-title .dot { display: inline-block; vertical-align: middle; margin-right: 4px; }
.price-grid .note-tag { font-size: .65rem; font-weight: 700; color: var(--focus); line-height: 1.1; }
.product-edit { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; }
.product-edit summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; color: var(--primary); cursor: pointer; }
.product-edit[open] { padding-bottom: 12px; }
.picker-row { display: flex; align-items: center; }
.picker-row .row { flex: 1; }
.conversion { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.conversion strong { color: var(--primary); }
.price-grid .per-unit { font-size: .68rem; font-weight: 600; color: var(--text-2); line-height: 1.1; }
.totals li.excluded { opacity: .65; }
.totals .excluded-note { display: block; font-size: .78rem; color: var(--partial); font-weight: 700; }
.compare-basis { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: .85rem; }

/* ---------- Fase 3: Modo Mercado ---------- */

.store-choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.store-choice {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); text-align: left; color: var(--text); cursor: pointer; font-size: 1.05rem;
}
.store-choice > svg { width: 22px; height: 22px; color: var(--text-2); }

.market-top { gap: 10px; }
.cart-total { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.cart-total strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.progress { position: sticky; top: 56px; z-index: 9; height: 4px; background: var(--surface-2); }
.progress span { display: block; height: 100%; background: var(--bought); transition: width .25s ease; }

/* Linha do Modo Mercado: cinza = pendente, verde = comprado, amarelo = parcial, riscado = não tinha */
.market-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 6px;
  border: 0; border-radius: 10px; background: transparent; text-align: left; color: var(--text); cursor: pointer;
  transition: background .15s ease;
}
.market-row .check {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); font-weight: 900; color: #fff; font-size: 1rem;
}
.market-row.comprado { background: var(--bought-soft); }
.market-row.comprado .check { background: var(--bought); border-color: var(--bought); }
.market-row.comprado .row-title { color: var(--bought); }
.market-row.parcial { background: var(--partial-soft); }
.market-row.parcial .check { background: var(--partial); border-color: var(--partial); }
.market-row.pulado .row-title { text-decoration: line-through; color: var(--text-2); }
.market-row.pulado .check { border-style: dashed; color: var(--text-2); }
.market-row .row-title { white-space: normal; }
.note-line { font-size: .8rem; color: var(--focus); font-weight: 600; }
.note-box { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--focus); font-weight: 600; }

.collapse-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px;
  border: 0; background: transparent; color: var(--text); font-weight: 700; cursor: pointer; padding: 0 4px;
}
.collapse-head svg { width: 20px; height: 20px; }

.big-stepper { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; align-items: center; }
.big-stepper .icon-btn { width: 56px; height: 56px; background: var(--surface-2); border-radius: 14px; }
.big-stepper .input { text-align: center; font-size: 1.5rem; font-weight: 800; min-height: 56px; }
.confirm-btn { min-height: 56px; font-size: 1.1rem; background: var(--bought); }

.sync-chip {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  top: calc(env(safe-area-inset-top, 0px) + 62px);
  padding: 6px 14px; border-radius: 999px; background: var(--partial-soft); color: var(--partial);
  font-size: .8rem; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap;
}
.list-row.bought .row-title, .list-row.bought .row-sub { color: var(--bought); }
.list-row.partial .row-sub { color: var(--partial); font-weight: 600; }

/* ---------- Comparar na prateleira e calculadora ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-3 .btn { padding: 0 8px; font-size: .9rem; }
.basis-chips { align-items: center; margin-top: 8px; }
.basis-chips .chip { min-height: 36px; padding: 0 12px; font-size: .9rem; }

.compare-box { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid; }
.compare-box.good { background: var(--bought-soft); border-color: var(--bought); color: var(--bought); }
.compare-box.bad { background: var(--partial-soft); border-color: var(--partial); color: var(--partial); }
.compare-box span { color: var(--text); font-size: .9rem; }
.compare-box .defer-btn { margin-top: 6px; background: var(--partial); color: #fff; }
.other-prices { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid currentColor; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--text-2); }
.other-prices .dot { display: inline-block; width: 8px; height: 8px; }

.market-row.adiado .row-title { color: var(--text-2); }
.market-row.adiado .check { border-color: var(--focus); color: var(--focus); }

.calc-row { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.calc-row.best { border-color: var(--bought); background: var(--bought-soft); }
.calc-head { display: flex; align-items: center; gap: 6px; }
.calc-label { min-height: 40px; padding: 6px 10px; font-weight: 600; }
.calc-fields { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 6px; }
.calc-fields .input { padding: 8px 10px; }
.calc-result { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-variant-numeric: tabular-nums; }
.calc-result .small-btn { min-height: 36px; padding: 0 10px; margin-left: auto; }

/* ---------- Modo Mercado em tabela ---------- */
.mk-wrap { margin: 0 -4px; }
.mk-grid .sticky { min-width: 150px; max-width: 48vw; padding: 4px 6px; }
.mk-item { display: flex; align-items: center; gap: 6px; }
.mk-check {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--surface); color: #fff; font-weight: 900; font-size: 1.1rem; cursor: pointer;
}
.mk-name {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-height: 48px; justify-content: center; padding: 2px 0; border: 0; background: transparent; color: var(--text);
  text-align: left; cursor: pointer;
}
.mk-name .row-title { white-space: normal; line-height: 1.2; }
.mk-name .row-sub { white-space: normal; font-size: .78rem; }

.mk-row.comprado th, .mk-row.comprado td { background: var(--bought-soft); }
.mk-row.comprado .mk-check { background: var(--bought); border-color: var(--bought); }
.mk-row.comprado .row-title, .mk-row.comprado .row-sub { color: var(--bought); }
.mk-row.parcial th, .mk-row.parcial td { background: var(--partial-soft); }
.mk-row.parcial .mk-check { background: var(--partial); border-color: var(--partial); }
.mk-row.pulado .row-title { text-decoration: line-through; color: var(--text-2); }
.mk-row.pulado .mk-check { border-style: dashed; color: var(--text-2); }
.mk-row.adiado .row-title { color: var(--text-2); }
.mk-row.adiado .mk-check { border-color: var(--focus); color: var(--focus); }

.mk-grid .here-col { color: var(--text); font-weight: 800; }
.mk-grid td.here { background: var(--surface-2); min-width: 104px; }
.mk-grid td.here button { font-weight: 800; font-size: 1rem; }
.mk-grid td.here.expected button { color: var(--text-2); font-weight: 600; }
.mk-grid td.here.good button { color: var(--bought); }
.mk-grid td.here.bad button { color: var(--partial); }
.mk-grid td.here.editing { padding: 4px; }
.mk-grid td.here.editing .input { min-height: 44px; padding: 6px; text-align: center; font-weight: 800; font-size: 1rem; min-width: 104px; }
.mk-add { color: var(--primary); font-weight: 700; font-size: .85rem; }
.mk-other { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 80px; min-height: 52px; padding: 2px 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-grid td.cheapest .mk-other { color: var(--bought); font-weight: 800; }
.mk-other small { font-size: .62rem; font-weight: 700; }
.mk-other .promo { color: var(--danger); }
.mk-other .stale-tag { color: var(--partial); }

.cat-row th {
  padding: 8px 10px 4px; text-align: left; font-size: .72rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-2); background: var(--bg);
}
.cat-row th span { position: sticky; left: 10px; }
.bought-list .row-sub .dot { display: inline-block; vertical-align: middle; }

/* ---------- Fase 4: estoque ---------- */
.stock-row { gap: 8px; }
.stock-qty { flex: none; min-width: 64px; text-align: right; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stock-row.acabou .stock-qty { color: var(--danger); }
.stock-row.acabando .stock-qty { color: var(--partial); }
.stock-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.stock-actions .icon-btn { width: 44px; height: 44px; background: var(--surface-2); }
.stock-actions .icon-btn svg { width: 20px; height: 20px; }
.btn.mini { min-height: 40px; padding: 0 10px; font-size: .85rem; }
.stock-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.stock-chip.ok { background: var(--bought-soft); color: var(--bought); }
.stock-chip.acabando { background: var(--partial-soft); color: var(--partial); }
.stock-chip.acabou { background: var(--danger-soft); color: var(--danger); }
.center-badge { align-self: center; justify-self: center; }
.btn.mini.in-list { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary); }
