/* =========================================================
   QuantoTá — mobile-first design system
   ========================================================= */

:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #f0eadf;
  --surface-3: #e9e1d2;
  --ink: #1d2a24;
  --ink-soft: #35443c;
  --muted: #5f6d65;
  --line: #e2dacb;
  --line-strong: #d2c7b4;
  --brand: #1f5e46;
  --brand-strong: #174836;
  --brand-soft: #e3efe8;
  --brand-tint: #f1f7f3;
  --accent: #b45f17;
  --accent-strong: #8f4a10;
  --accent-soft: #fbefdc;
  --danger: #a33b2d;
  --danger-soft: #f8e6e2;
  --warning: #7a4c0c;
  --warning-soft: #fbf0d9;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(29, 42, 36, .05);
  --shadow: 0 1px 2px rgba(29, 42, 36, .04), 0 10px 28px rgba(29, 42, 36, .06);
  --shadow-hover: 0 2px 4px rgba(29, 42, 36, .05), 0 16px 34px rgba(29, 42, 36, .10);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 64px;
  --bottom-h: 68px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(180, 95, 23, .07), transparent 65%),
    radial-gradient(900px 500px at -10% 10%, rgba(31, 94, 70, .07), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: var(--mono); }
[hidden] { display: none !important; }

::selection { background: var(--brand-soft); color: var(--brand-strong); }

:focus-visible {
  outline: 3px solid rgba(31, 94, 70, .35);
  outline-offset: 2px;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

.main {
  min-height: calc(100vh - var(--header-h));
  padding: 26px 0 48px;
}

.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;
}

.skip-link {
  position: fixed;
  top: -60px; left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(247, 243, 234, .88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 218, 203, .8);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 4px 12px rgba(31, 94, 70, .22);
}
.brand-mark img { display: block; width: 24px; height: 24px; }

.brand-word {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -.035em;
}
.brand-accent { color: var(--accent); }

.desktop-nav {
  display: none;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(31, 94, 70, .07); color: var(--brand-strong); }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand-strong); }
.nav-admin { margin-left: 4px; }

.nav-count,
.icon-count {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
  line-height: 1;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.user-menu form { margin: 0; }
.user-name {
  display: none;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.mobile-admin {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  color: var(--brand-strong);
  text-decoration: none;
}
.mobile-admin:hover { background: var(--brand-soft); }
.icon-count {
  position: absolute;
  top: 1px; right: 0;
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  min-height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, .95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.bottom-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  border-radius: 12px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
}
.bottom-link .icon { width: 21px; height: 21px; }
.bottom-link.is-active { color: var(--brand-strong); }
.bottom-link.is-active .icon { stroke-width: 2.1; }

.bottom-add .bottom-add-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  margin-top: -16px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  color: #fff;
  box-shadow: 0 6px 16px rgba(31, 94, 70, .28);
}
.bottom-add.is-active .bottom-add-mark { background: var(--accent); box-shadow: 0 6px 16px rgba(180, 95, 23, .28); }

/* ---------- Type & common ---------- */

h1 {
  font-size: clamp(1.75rem, 4.4vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: -.035em;
  font-weight: 800;
}
h2 { font-size: 1.22rem; line-height: 1.25; letter-spacing: -.02em; font-weight: 750; }
h3 { font-size: 1.02rem; line-height: 1.3; letter-spacing: -.01em; font-weight: 700; }

.eyebrow {
  margin-bottom: 6px;
  color: var(--brand);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.page-sub {
  max-width: 62ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: .98rem;
}

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.optional { color: var(--muted); font-weight: 400; font-size: .78em; }
.footnote { margin-top: 12px; color: var(--muted); font-size: .78rem; }
.result-count { margin: 14px 0 12px; color: var(--muted); font-size: .82rem; font-weight: 600; }

.text-link {
  color: var(--brand-strong);
  font-size: .88rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.text-link:hover { color: var(--accent-strong); }

.breadcrumb { margin-bottom: 18px; }
.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 600;
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--brand-strong); }

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.title-row h1 { margin: 0; }

.icon { flex: 0 0 auto; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: #fff;
  box-shadow: 0 6px 16px rgba(31, 94, 70, .18);
}
.btn-primary:hover { background: var(--brand-strong); box-shadow: 0 8px 20px rgba(31, 94, 70, .24); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(29, 42, 36, .06); }

.btn-danger {
  background: var(--surface);
  border-color: #e7c5be;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { min-height: 38px; padding: 7px 12px; font-size: .82rem; border-radius: 10px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-dim { background: var(--surface-2); color: var(--ink-soft); }
.badge-best { background: var(--brand); color: #fff; }
.badge-approved { background: var(--brand-soft); color: var(--brand-strong); }
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-rejected { background: var(--danger-soft); color: var(--danger); }
.badge-stale { background: var(--surface-2); color: var(--muted); }

/* ---------- Flash & callouts ---------- */

.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }

.flash {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: .88rem;
  font-weight: 500;
}
.flash .icon { margin-top: 1px; }
.flash-success { border-color: #c9e0d3; background: var(--brand-tint); color: var(--brand-strong); }
.flash-error { border-color: #eccbc4; background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--surface-2); color: var(--ink-soft); }

.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.callout-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--brand-strong);
}
.callout-body { flex: 1; min-width: 0; }
.callout-body strong { display: block; margin-bottom: 2px; }
.callout-admin { border-color: #ecd3ad; background: linear-gradient(120deg, #fffaf0, var(--accent-soft)); }
.callout-admin .callout-icon { background: #f6e3c5; color: var(--accent-strong); }
.callout-warning { border-color: #ecd3ad; background: var(--warning-soft); }
.callout-warning .callout-icon { background: #f4e2c4; color: var(--warning); }
.callout-danger { border-color: #eccbc4; background: var(--danger-soft); }
.callout-danger .callout-icon { background: #f1d5cf; color: var(--danger); }

/* ---------- Page structure ---------- */

.page-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head .btn { flex-shrink: 0; }
.page-head-copy { min-width: 0; }

.section { margin-top: 38px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.section-sub { margin-top: 3px; color: var(--muted); font-size: .84rem; }

/* ---------- Dashboard ---------- */

.dashboard-head { margin-bottom: 22px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, .72);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-size: .74rem; font-weight: 600; line-height: 1.3; }

.savings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.saving-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.saving-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.saving-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.saving-product { font-weight: 700; font-size: .95rem; }
.saving-percent {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.saving-line { color: var(--ink-soft); font-size: .84rem; }
.saving-price { color: var(--brand-strong); font-size: 1.16rem; font-weight: 800; letter-spacing: -.02em; }

.recent-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.recent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.recent-row:last-child { border-bottom: 0; }
.recent-product { font-weight: 700; text-decoration: none; }
.recent-product:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
.recent-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; color: var(--muted); font-size: .8rem; }
.recent-price { display: flex; align-items: baseline; gap: 8px; }
.recent-price strong { color: var(--brand-strong); font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.recent-price span { font-size: .76rem; }
.recent-when { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--ink-soft); }

/* ---------- Search ---------- */

.search-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.search-form .search-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  margin-right: -42px;
  margin-left: 4px;
  color: var(--muted);
  pointer-events: none;
}
.search-form input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px 9px 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: .95rem;
}
.search-form input:focus { outline: none; background: var(--surface-2); }
.search-form .btn { flex: 0 0 auto; }

/* ---------- Product cards ---------- */

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

.product-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.product-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.product-card h3 { margin-bottom: 2px; }
.product-card h3 a { text-decoration: none; }
.product-card h3 a:hover { color: var(--brand-strong); }
.product-sub { color: var(--muted); font-size: .78rem; }
.product-best {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--brand-tint);
  border: 1px solid #dbe9e1;
}
.product-best-label { color: var(--brand); font-size: .63rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.product-best-value { color: var(--brand-strong); font-size: 1.3rem; font-weight: 800; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.product-best-store { color: var(--muted); font-size: .76rem; }
.product-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; color: var(--ink-soft); font-size: .74rem; }
.product-empty { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- Product detail ---------- */

.best-deal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid #cfe3d7;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(500px 180px at 100% 0%, rgba(31, 94, 70, .10), transparent 70%),
    linear-gradient(145deg, #f7fbf8, var(--brand-soft));
  box-shadow: var(--shadow-sm);
}
.best-deal-price {
  display: block;
  margin: 2px 0;
  color: var(--brand-strong);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.best-deal-store { color: var(--ink-soft); font-size: .9rem; }
.best-deal-store a { font-weight: 700; text-decoration: none; }
.best-deal-store a:hover { text-decoration: underline; text-underline-offset: 3px; }
.best-deal-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(31, 94, 70, .22);
}

.price-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.price-row:last-child { border-bottom: 0; }
.price-row.is-best {
  background: linear-gradient(90deg, var(--brand-tint), var(--surface) 70%);
  box-shadow: inset 4px 0 0 var(--brand);
}
.price-row:target { animation: row-highlight 1.6s ease; }
@keyframes row-highlight {
  0%, 35% { background: var(--accent-soft); }
  100% { background: var(--surface); }
}
.price-row-main { min-width: 0; }
.price-row-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.price-store { font-weight: 700; font-size: .95rem; text-decoration: none; }
.price-store:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
.price-row-pack { margin-top: 2px; color: var(--ink-soft); font-size: .82rem; }
.price-row-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 3px; color: var(--muted); font-size: .74rem; }
.price-note { font-style: italic; }
.price-row-unit { text-align: right; }
.price-row > form { justify-self: end; align-self: center; }
.price-row-unit strong {
  display: block;
  color: var(--brand-strong);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.price-row-unit span { font-size: .7rem; }
.price-row form { margin: 0; }
.pending-list { border-style: dashed; box-shadow: none; background: rgba(255, 253, 248, .6); }

/* ---------- Forms ---------- */

.price-form { display: grid; gap: 14px; }

.form-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.form-card.standalone { max-width: 640px; }
.form-card-head { display: flex; align-items: flex-start; gap: 12px; }
.form-card-head h2 { font-size: 1.1rem; }
.step {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: .86rem;
  font-weight: 800;
}

.field { display: flex; flex-direction: column; margin-top: 16px; min-width: 0; }
.field:first-of-type { margin-top: 14px; }
.field > label { margin-bottom: 6px; font-size: .84rem; font-weight: 700; color: var(--ink-soft); }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #fff;
  font-size: .95rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input::placeholder,
.field textarea::placeholder { color: #9aa39d; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(31, 94, 70, .13);
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: #cf8378; }
.field select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.field-hint { margin-top: 5px; color: var(--muted); font-size: .74rem; }
.field-error { margin-top: 5px; color: var(--danger); font-size: .78rem; font-weight: 600; }

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

.input-affix { position: relative; }
.input-affix .affix {
  position: absolute;
  top: 50%; left: 13px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
  pointer-events: none;
}
.input-affix input { padding-left: 42px; }

.unit-preview {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #cfe3d7;
  border-radius: 12px;
  background: var(--brand-tint);
}
.unit-preview-label { color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.unit-preview-value { color: var(--brand-strong); font-size: 1.3rem; font-weight: 800; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.unit-preview-total { color: var(--muted); font-size: .78rem; }

.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---------- Stores ---------- */

.store-grid { grid-template-columns: 1fr; }
.store-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.store-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.store-card-head { display: flex; align-items: flex-start; gap: 10px; }
.store-card-head > div { min-width: 0; flex: 1; }
.store-card-head h3 { margin-bottom: 1px; overflow-wrap: anywhere; }
.store-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.store-card-pending { border-style: dashed; background: rgba(255, 253, 248, .7); }
.store-card-rejected { background: rgba(255, 253, 248, .55); border-style: dashed; }
.store-card-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .74rem; }

.store-groups { display: grid; grid-template-columns: 1fr; gap: 12px; }
.store-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.store-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.store-group-head a { font-weight: 700; text-decoration: none; }
.store-group-head a:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
.store-price-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 15px; border-bottom: 1px solid var(--line); }
.store-price-list li:last-child { border-bottom: 0; }
.store-price-main { display: flex; flex-direction: column; min-width: 0; }
.store-price-pack { font-size: .85rem; font-weight: 600; }
.store-price-unit { text-align: right; }
.store-price-unit strong { display: block; color: var(--brand-strong); font-size: .98rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Admin ---------- */

.admin-queue { display: grid; grid-template-columns: 1fr; gap: 12px; }
.review-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.review-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.review-card-head h3 { overflow-wrap: anywhere; }
.review-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; padding: 10px 12px; border-radius: 11px; background: var(--surface-2); }
.review-meta dt { color: var(--muted); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.review-meta dd { font-size: .8rem; font-weight: 600; }
.review-note { margin: 10px 0; padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--ink-soft); font-size: .84rem; font-style: italic; }
.review-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 12px 0; }
.review-form { display: flex; flex-direction: column; gap: 6px; }
.review-form label { color: var(--muted); font-size: .72rem; font-weight: 700; }
.review-form input { min-height: 42px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font-size: .85rem; }
.review-form .btn { align-self: flex-start; }
.review-history { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.review-history li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.review-history li:last-child { border-bottom: 0; }
.review-history li > div { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.review-history a { font-weight: 700; text-decoration: none; }
.review-history a:hover { text-decoration: underline; text-underline-offset: 3px; }

.admin-panels { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 38px; }
.admin-panel { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.admin-panel-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.invite-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.invite-box code { font-size: 1.2rem; font-weight: 800; letter-spacing: .09em; color: var(--brand-strong); }
.backup-list { display: grid; gap: 8px; }
.backup-list > div { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.backup-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.backup-list dt { color: var(--muted); font-size: .76rem; }
.backup-list dd { font-size: .78rem; font-weight: 600; text-align: right; }

/* ---------- Auth ---------- */

.auth-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: center;
  min-height: calc(100vh - var(--header-h) - 80px);
  padding: 12px 0 40px;
}
.auth-card {
  width: 100%;
  max-width: 480px;
  margin-inline: auto;
  padding: 26px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 2px; font-size: clamp(1.7rem, 4vw, 2.05rem); }
.auth-card > .muted { margin-top: 8px; font-size: .9rem; }
.auth-form { margin-top: 22px; display: grid; gap: 2px; }
.auth-form .field { margin-top: 12px; }
.auth-form .btn { margin-top: 18px; }
.auth-alt { margin-top: 20px; color: var(--muted); font-size: .84rem; text-align: center; }
.auth-alt a { color: var(--brand-strong); font-weight: 700; text-underline-offset: 3px; }

.auth-pitch {
  display: none;
  position: relative;
  overflow: hidden;
  padding: 36px;
  border-radius: 28px;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(255, 255, 255, .12), transparent 60%),
    linear-gradient(150deg, var(--brand), var(--brand-strong));
  color: #f6f1e5;
  box-shadow: 0 20px 50px rgba(23, 72, 54, .24);
}
.auth-pitch::after {
  content: "";
  position: absolute;
  right: -80px; bottom: -110px;
  width: 280px; height: 280px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
}
.pitch-mark {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  margin-bottom: 24px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .14);
}
.pitch-mark img { display: block; width: 30px; height: 30px; }
.auth-pitch h2 { margin-bottom: 12px; color: #fffdf6; font-size: clamp(1.7rem, 3vw, 2.25rem); line-height: 1.12; letter-spacing: -.03em; }
.auth-pitch p { max-width: 42ch; color: rgba(246, 241, 229, .82); font-size: .92rem; }
.pitch-list { display: grid; gap: 8px; margin-top: 22px; }
.pitch-list li { position: relative; padding-left: 24px; color: rgba(246, 241, 229, .92); font-size: .86rem; }
.pitch-list li::before {
  content: "";
  position: absolute;
  left: 0; top: .35em;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #e8b25e;
  box-shadow: 0 0 0 4px rgba(232, 178, 94, .15);
}

/* ---------- Empty / error ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 34px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, .55);
  text-align: center;
}
.empty-state.compact { padding: 22px 18px; }
.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  margin-bottom: 2px;
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--brand-strong);
}
.empty-state p { max-width: 52ch; color: var(--muted); font-size: .88rem; }
.empty-state .btn { margin-top: 6px; }

.error-page { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 16px; text-align: center; }
.error-code { color: var(--brand-soft); font-size: clamp(4rem, 16vw, 7rem); font-weight: 800; letter-spacing: -.06em; line-height: 1; text-shadow: 0 1px 0 #cfe3d7; }
.error-page h1 { margin-top: -10px; }
.error-page .btn { margin-top: 10px; }

/* ---------- Responsive ---------- */

@media (min-width: 560px) {
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .price-grid { grid-template-columns: 1.1fr .9fr .8fr; }
  .savings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid, .store-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .store-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-row { grid-template-columns: minmax(0, 1fr) auto; }
  .recent-when { grid-column: 1 / -1; }
  .review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 720px) {
  .main { padding-top: 34px; }
  .page-head { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 24px; }
  .page-head .btn { margin-bottom: 2px; }
  .field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-card { padding: 16px 18px; }
  .stat-label { font-size: .78rem; }
  .form-card { padding: 22px 24px; }
  .auth-card { padding: 34px 32px; }
  .recent-row { grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; }
  .recent-when { grid-column: auto; flex-direction: column; align-items: flex-end; gap: 0; text-align: right; }
  .price-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 18px; padding: 16px 18px; }
  .price-row-unit { min-width: 140px; }
}

@media (min-width: 900px) {
  .desktop-nav { display: flex; }
  .user-name { display: inline; }
  .mobile-admin { display: none; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 64px; }
  .auth-wrap { grid-template-columns: minmax(0, 1fr) minmax(360px, .95fr); gap: 44px; padding: 30px 0 60px; }
  .auth-pitch { display: block; }
  .auth-card { margin-inline: 0; }
  .admin-queue { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-row { padding: 15px 18px; }
}

@media (min-width: 1024px) {
  .card-grid, .store-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .store-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .savings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .savings-grid .saving-card:nth-child(4),
  .savings-grid .saving-card:nth-child(5) { grid-column: auto; }
}

@media (max-width: 899px) {
  .main { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 24px); }
  .site-header { background: rgba(247, 243, 234, .94); }
}

@media (max-width: 380px) {
  .shell { width: calc(100% - 22px); }
  .stat-card { padding: 11px 10px; }
  .stat-icon { width: 30px; height: 30px; margin-bottom: 4px; }
  .stat-value { font-size: 1.25rem; }
  .stat-label { font-size: .68rem; }
  .brand-word { font-size: 1.1rem; }
  .search-form .btn { flex: 1; }
}

@media (max-width: 480px) {
  .review-meta { grid-template-columns: 1fr; }
  .review-meta > div { display: flex; justify-content: space-between; gap: 10px; }
  .review-meta dd { text-align: right; }
}

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