/* ============================================================
   PreçoCerto RJ — design system
   Tema claro · verde esmeralda (economia) · azul escuro (ações)
   Mobile-first
   ============================================================ */

:root {
  --brand-900: #0a2340;
  --brand-800: #0f2f5c;
  --brand-700: #16406f;
  --brand-600: #1d5590;
  --brand-100: #e6eefb;
  --brand-50: #f2f7ff;

  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --emerald-50: #ecfdf5;

  --amber-500: #f59e0b;
  --amber-50: #fffbeb;
  --rose-600: #e11d48;
  --rose-50: #fff1f2;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5e9f0;
  --line-2: #eef2f7;
  --bg: #f5f7fa;
  --surface: #ffffff;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sh-1: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh-2: 0 4px 14px rgba(15, 23, 42, 0.07);
  --sh-3: 0 12px 34px rgba(15, 23, 42, 0.12);

  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, figure { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: var(--brand-600); text-decoration: none; }
img { max-width: 100%; display: block; }
input, select { font: inherit; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid rgba(29, 85, 144, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

.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 {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
}

.view {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  animation: fade-in 0.22s ease;
}

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

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

/* ------------------------------------------------------------
   Topbar (mobile)
   ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--emerald-500), var(--emerald-700));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.32);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: -0.3px;
  color: var(--brand-900);
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.loc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 46vw;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  color: var(--brand-700);
  font-size: 12.5px;
  font-weight: 600;
}

.loc-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-pill svg { flex: none; }

/* ------------------------------------------------------------
   Bottom nav (mobile)
   ------------------------------------------------------------ */

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  height: calc(var(--nav-h) + var(--safe-b));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  position: relative;
  transition: color 0.15s ease;
}

.nav-item svg { width: 23px; height: 23px; stroke-width: 1.9; }

.nav-item[aria-current='page'] {
  color: var(--brand-800);
}

.nav-item[aria-current='page']::before {
  content: '';
  position: absolute;
  top: 0;
  width: 34px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--emerald-500);
}

.nav-item:active { transform: scale(0.96); }

/* ------------------------------------------------------------
   Page header
   ------------------------------------------------------------ */

.page-head {
  margin-bottom: 16px;
}

.page-head h1 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--brand-900);
  line-height: 1.22;
}

.page-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ------------------------------------------------------------
   Cards
   ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

.card + .card { margin-top: 12px; }

.card-pad { padding: 16px; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.15px;
}

.card-title .ic { color: var(--brand-600); }

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label:first-child { margin-top: 4px; }

/* ------------------------------------------------------------
   Hero: melhor opção
   ------------------------------------------------------------ */

.hero {
  position: relative;
  border-radius: var(--r-xl);
  padding: 18px;
  color: #fff;
  background:
    radial-gradient(120% 120% at 100% 0%, #0b8a63 0%, rgba(11, 138, 99, 0) 58%),
    linear-gradient(150deg, #065f46 0%, #047857 46%, #0a5a43 100%);
  box-shadow: 0 14px 34px -10px rgba(4, 120, 87, 0.55);
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  right: -46px; top: -46px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-chain {
  margin-top: 12px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.7px;
  line-height: 1.1;
  position: relative;
}

.hero-store {
  margin-top: 4px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.82);
  position: relative;
}

.hero-total {
  margin-top: 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  position: relative;
}

.hero-total .amount {
  font-size: 33px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-total .unit {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.75);
  padding-bottom: 4px;
}

.hero-meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.13);
  font-size: 11.5px;
  font-weight: 600;
}

.hero-saving {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--emerald-700);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
}

.hero-saving strong { font-size: 15.5px; font-variant-numeric: tabular-nums; }
.hero-saving small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* ------------------------------------------------------------
   Ranking
   ------------------------------------------------------------ */

.rank-list { display: flex; flex-direction: column; gap: 9px; }

.rank {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-1);
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.rank.is-best {
  border-color: rgba(5, 150, 105, 0.5);
  background: linear-gradient(180deg, var(--emerald-50), #fff 70%);
  box-shadow: 0 6px 18px -8px rgba(5, 150, 105, 0.4);
}

.rank.is-out { opacity: 0.56; }

.rank-badge {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12px !important;
  font-weight: 800;
  background: var(--brand-50);
  color: var(--brand-700);
}

.rank.is-best .rank-badge {
  background: var(--emerald-600);
  color: #fff;
}

.rank-body { flex: 1; min-width: 0; }

.rank-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.2px;
}

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

.rank-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.rank-sub b { color: var(--ink-2); font-weight: 700; }

.rank-right { text-align: right; flex: none; }

.rank-total {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.rank.is-best .rank-total { color: var(--emerald-700); }

.rank-total.is-absent { color: var(--muted-2); font-size: 12px; font-weight: 700; }

.rank-dist {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 1px;
}

/* ------------------------------------------------------------
   Segmented control
   ------------------------------------------------------------ */

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #eaeff6;
  border-radius: 13px;
  margin-bottom: 14px;
}

.segmented button {
  flex: 1;
  padding: 9px 8px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.16s ease;
}

.segmented button[aria-selected='true'] {
  background: var(--surface);
  color: var(--brand-800);
  box-shadow: var(--sh-1);
}

/* ------------------------------------------------------------
   Botões
   ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 13px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height: 48px;
}

.btn:active { transform: scale(0.985); }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-700), var(--brand-800));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(15, 47, 92, 0.6);
}

.btn-primary:hover { background: linear-gradient(180deg, var(--brand-600), var(--brand-700)); }

.btn-emerald {
  background: linear-gradient(180deg, var(--emerald-500), var(--emerald-700));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(5, 150, 105, 0.6);
}

.btn-ghost {
  background: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-100);
}

.btn-quiet {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.btn-danger-quiet {
  background: var(--rose-50);
  color: var(--rose-600);
  border: 1px solid #fecdd3;
}

.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 8px 13px; font-size: 13px; border-radius: 11px; }

.btn:disabled { opacity: 0.55; pointer-events: none; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  transition: background 0.15s ease;
  flex: none;
}

.icon-btn:hover { background: var(--brand-50); }
.icon-btn.is-danger { color: var(--rose-600); }
.icon-btn.is-danger:hover { background: var(--rose-50); }

/* ------------------------------------------------------------
   Lista de compras
   ------------------------------------------------------------ */

.summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand-800), var(--brand-700));
  color: #fff;
  box-shadow: 0 10px 26px -12px rgba(15, 47, 92, 0.7);
}

.summary-bar .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
}

.summary-bar .v {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.summary-bar .split {
  text-align: right;
}

.summary-bar .split .v { font-size: 16px; color: #a7f3d0; }

.items { display: flex; flex-direction: column; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}

.item:last-child { border-bottom: 0; }
.item.is-checked { background: #fbfdfc; }
.item.is-checked .item-name { text-decoration: line-through; color: var(--muted-2); }

.item-check {
  width: 24px; height: 24px;
  flex: none;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
  color: transparent;
}

.item-check[aria-checked='true'] {
  background: var(--emerald-600);
  border-color: var(--emerald-600);
  color: #fff;
}

.item-thumb {
  width: 48px; height: 48px;
  flex: none;
  border-radius: 11px;
  background: #f1f5f9;
  border: 1px solid var(--line-2);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

.item-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }

.item-body { flex: 1; min-width: 0; }

.item-name {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
}

.item-meta .best-price {
  color: var(--emerald-700);
  font-weight: 700;
}

.item-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 2px;
}

.stepper button {
  width: 27px; height: 27px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  font-weight: 800;
  font-size: 15px;
  background: var(--surface);
  box-shadow: var(--sh-1);
}

.stepper button:disabled { opacity: 0.4; }

.stepper .qty {
  min-width: 22px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
   Empty state
   ------------------------------------------------------------ */

.empty {
  text-align: center;
  padding: 34px 22px 30px;
}

.empty-icon {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  color: var(--brand-600);
}

.empty h3 {
  font-size: 16.5px;
  font-weight: 750;
  color: var(--ink);
  letter-spacing: -0.3px;
}

.empty p {
  margin: 6px auto 18px;
  max-width: 320px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* ------------------------------------------------------------
   Scanner
   ------------------------------------------------------------ */

.scan-stage {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #08131f;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  border: 1px solid #0d1b2a;
}

.scan-stage video,
.scan-stage canvas,
.scan-stage > div { width: 100% !important; height: 100% !important; }

.scan-stage #qr-reader { border: 0 !important; }
.scan-stage #qr-reader img[alt='Info'] { display: none; }
.scan-stage #qr-reader__dashboard_section_csr span { color: #cbd5e1 !important; }
.scan-stage #qr-reader__dashboard_section_csr button {
  background: var(--brand-700) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 9px !important;
  padding: 8px 12px !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
}
.scan-stage #qr-reader__dashboard_section_csr select {
  border-radius: 9px !important;
  padding: 7px !important;
  max-width: 100%;
}
.scan-stage #qr-reader__dashboard { padding: 8px !important; background: rgba(8, 19, 31, 0.9) !important; }
.scan-stage #qr-reader__header_message { display: none !important; }

.scan-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 2;
}

.scan-window {
  width: 74%;
  max-width: 300px;
  aspect-ratio: 1.62 / 1;
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(4, 12, 22, 0.55);
  position: relative;
}

.scan-window i {
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid var(--emerald-500);
  border-radius: 4px;
}

.scan-window i:nth-child(1) { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.scan-window i:nth-child(2) { top: -3px; right: -3px; border-left: 0; border-bottom: 0; }
.scan-window i:nth-child(3) { bottom: -3px; left: -3px; border-right: 0; border-top: 0; }
.scan-window i:nth-child(4) { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }

.scan-laser {
  position: absolute;
  left: 8%; right: 8%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--emerald-500), transparent);
  box-shadow: 0 0 12px 1px rgba(16, 185, 129, 0.8);
  animation: laser 2.1s ease-in-out infinite;
}

@keyframes laser {
  0%, 100% { top: 14%; opacity: 0.35; }
  50% { top: 84%; opacity: 1; }
}

.scan-overlay-msg {
  position: absolute;
  inset: auto 12px 12px;
  z-index: 3;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(8, 19, 31, 0.86);
  color: #e2e8f0;
  font-size: 12px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.scan-splash {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  gap: 10px;
  background: rgba(8, 19, 31, 0.94);
  color: #e2e8f0;
  text-align: center;
  padding: 20px;
}

.scan-splash .big-ic {
  width: 62px; height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(16, 185, 129, 0.14);
  color: var(--emerald-500);
  margin: 0 auto 4px;
}

.scan-splash p { font-size: 12.5px; color: #94a3b8; max-width: 260px; line-height: 1.45; }

.scan-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.flash-ok {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(16, 185, 129, 0.22);
  pointer-events: none;
  animation: flash 0.45s ease-out;
}

@keyframes flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

.toast-scan {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 26px);
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--emerald-600);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--sh-3);
  animation: pop 0.28s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes pop {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.94); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ------------------------------------------------------------
   Formulários
   ------------------------------------------------------------ */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: -0.1px;
}

.field .hint {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}

.input,
select.input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.input::placeholder { color: var(--muted-2); }

.input:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(29, 85, 144, 0.14);
}

.input:disabled { background: #f8fafc; color: var(--muted); }

.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.radius-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.radius-opt {
  padding: 12px 6px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
  transition: all 0.15s ease;
  text-align: center;
}

.radius-opt small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); }

.radius-opt[aria-pressed='true'] {
  border-color: var(--emerald-600);
  background: var(--emerald-50);
  color: var(--emerald-700);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.radius-opt[aria-pressed='true'] small { color: var(--emerald-600); }

.status-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.status-line.ok { background: var(--emerald-50); color: var(--emerald-700); }
.status-line.warn { background: var(--amber-50); color: #92400e; }
.status-line.err { background: var(--rose-50); color: var(--rose-600); }
.status-line.info { background: var(--brand-50); color: var(--brand-700); }
.status-line svg { flex: none; margin-top: 1px; }

/* mapa */
#map {
  height: 210px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  z-index: 0;
  background: #e8eef5;
}

.leaflet-container { font: inherit; }
.leaflet-popup-content { font-size: 12px; margin: 8px 10px; }
.leaflet-popup-content b { color: var(--brand-800); }

.map-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------
   Detalhamento / cesta mista
   ------------------------------------------------------------ */

.detail-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.detail-item + .detail-item { margin-top: 9px; }

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line-2);
}

.detail-head .item-thumb { width: 38px; height: 38px; border-radius: 9px; }

.detail-head-body { flex: 1; min-width: 0; }

.detail-head .name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.detail-head .qty-tag {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.price-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}

.price-row:last-child { border-bottom: 0; }
.price-row.is-best { background: var(--emerald-50); }
.price-row.is-absent { opacity: 0.5; }

.price-row .chain {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink-2);
}

.price-row .val {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.2px;
}

.price-row.is-best .val { color: var(--emerald-700); }
.price-row.is-absent .val { color: var(--muted-2); font-weight: 600; }

.price-row .dist {
  font-size: 10.5px;
  color: var(--muted-2);
  font-weight: 600;
  min-width: 44px;
  text-align: right;
}

.tag-best {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--emerald-600);
  color: #fff;
}

.mixed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}

.mixed-row:last-child { border-bottom: 0; }

.mixed-chain {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--emerald-50);
  color: var(--emerald-700);
  white-space: nowrap;
}

.mixed-save {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--emerald-700);
  background: var(--emerald-100);
  padding: 3px 7px;
  border-radius: 7px;
  white-space: nowrap;
}

.store-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}

.store-summary:last-child { border-bottom: 0; }

.store-summary .num {
  width: 22px; height: 22px;
  border-radius: 7px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex: none;
}

/* ------------------------------------------------------------
   Modal / bottom sheet
   ------------------------------------------------------------ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 19, 31, 0.5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.18s ease;
}

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(20px + var(--safe-b));
  box-shadow: 0 -12px 40px rgba(8, 19, 31, 0.3);
  animation: slide-up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.sheet-grab {
  width: 42px; height: 4px;
  border-radius: 3px;
  background: var(--line);
  margin: 4px auto 14px;
}

.sheet h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--brand-900);
}

.sheet-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.sheet-product {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--r-md);
  background: #f8fafc;
  border: 1px solid var(--line-2);
  margin: 14px 0;
}

.sheet-product .item-thumb { width: 62px; height: 62px; border-radius: 12px; background: #fff; }

.sheet-product .pname { font-size: 14px; font-weight: 750; line-height: 1.3; color: var(--ink); }
.sheet-product .pmeta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.qty-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 4px;
}

.qty-picker button {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 21px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 1px solid var(--brand-100);
}

.qty-picker .val {
  font-size: 27px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: center;
  letter-spacing: -0.5px;
}

.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

/* ------------------------------------------------------------
   Toast
   ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px);
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 92vw;
  padding: 11px 16px;
  border-radius: 13px;
  background: var(--brand-900);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  box-shadow: var(--sh-3);
  animation: pop 0.25s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.toast.ok { background: var(--emerald-700); }
.toast.err { background: var(--rose-600); }

/* ------------------------------------------------------------
   Loader / skeleton
   ------------------------------------------------------------ */

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

.spinner.dark {
  border-color: var(--line);
  border-top-color: var(--brand-700);
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #f7f9fc 50%, #eef2f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 10px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ------------------------------------------------------------
   Conta
   ------------------------------------------------------------ */

.account-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(150deg, var(--brand-800), var(--brand-700));
  color: #fff;
  box-shadow: 0 12px 30px -14px rgba(15, 47, 92, 0.8);
}

.avatar {
  width: 54px; height: 54px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 21px;
  font-weight: 800;
  flex: none;
}

.account-hero .nm { font-size: 17px; font-weight: 800; letter-spacing: -0.4px; }
.account-hero .ad { font-size: 12px; color: rgba(255, 255, 255, 0.78); margin-top: 2px; line-height: 1.4; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat {
  padding: 12px 10px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}

.stat .n {
  font-size: 17px;
  font-weight: 800;
  color: var(--brand-800);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat .l { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.chain-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chain-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid var(--line-2);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-2);
}

.disclaimer {
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.disclaimer b { color: var(--ink-2); }

/* ------------------------------------------------------------
   Desktop (≥ 900px)
   ------------------------------------------------------------ */

@media (min-width: 900px) {
  .topbar { display: none; }
  .bottom-nav { display: none; }

  .app { padding: 0; }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 252px;
    flex: none;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 22px 16px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .sidebar .brand { padding: 0 6px 22px; }

  .side-nav { display: flex; flex-direction: column; gap: 3px; }

  .side-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: 11px;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 650;
    transition: all 0.15s ease;
  }

  .side-nav a svg { width: 19px; height: 19px; flex: none; }

  .side-nav a:hover { background: var(--brand-50); color: var(--brand-700); }

  .side-nav a[aria-current='page'] {
    background: linear-gradient(90deg, var(--brand-800), var(--brand-700));
    color: #fff;
    box-shadow: 0 6px 16px -8px rgba(15, 47, 92, 0.7);
  }

  .side-foot { margin-top: auto; }

  .side-loc {
    padding: 12px;
    border-radius: 12px;
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
  }

  .side-loc .k {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--emerald-700);
  }

  .side-loc .v { font-size: 12.5px; font-weight: 650; color: var(--brand-800); margin-top: 3px; line-height: 1.35; }

  .main { padding-bottom: 0; }

  .view { padding: 34px 32px 48px; max-width: 1080px; }

  .page-head h1 { font-size: 29px; }
  .page-head p { font-size: 14.5px; }

  .grid-2 {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 16px;
    align-items: start;
  }

  .hero { padding: 24px; }
  .hero-chain { font-size: 30px; }
  .hero-total .amount { font-size: 40px; }

  .price-grid { grid-template-columns: 1fr 1fr; }
  .price-row:nth-last-child(2) { border-bottom: 0; }

  .item:hover { background: #fbfcfe; }

  .sheet-backdrop { align-items: center; }
  .sheet {
    border-radius: 22px;
    max-width: 460px;
    padding-bottom: 20px;
    animation: fade-in 0.2s ease;
  }
}

@media (min-width: 1200px) {
  .sidebar { width: 272px; }
}
