/* ============================================================================
   Materiais Escolares — visual "caderno quadriculado" (claro) e "grafite" (escuro)
   ========================================================================== */
@font-face { font-family: 'Atkinson Next'; src: url('../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url('../fonts/atkinson-hyperlegible-next-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url('../fonts/atkinson-hyperlegible-next-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #EDF0EF;
  --bg-grad: linear-gradient(180deg, #EFF2F1 0%, #E9EDEC 100%);
  --grid: rgba(47, 106, 143, 0.055);
  --surface: #FAFBFA;
  --surface-2: #F1F4F3;
  --line: #D5DCDA;
  --line-strong: #BCC6C3;
  --text: #25302F;
  --muted: #5B6867;
  --ink: #2F6A8F;          /* caneta azul */
  --ink-text: #FFFFFF;
  --ink-soft: #DDE9F1;
  --ok: #2C7A55;
  --ok-soft: #DCEFE4;
  --warn: #85600C;
  --warn-soft: #F6ECCF;
  --bad: #A4443A;
  --bad-soft: #F6DFDA;
  --hl: rgba(236, 206, 74, 0.6);   /* marca-texto */
  --shadow: 0 1px 0 rgba(37, 48, 47, 0.04), 0 8px 24px -16px rgba(37, 48, 47, 0.25);
  --radius: 12px;
  --radius-s: 8px;
  --nav-h: 64px;
  --font: 'Atkinson Next', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
:root[data-theme='escuro'] {
  color-scheme: dark;
  --bg: #2C3136;
  --bg-grad: linear-gradient(165deg, #363C42 0%, #2D3237 45%, #272B2F 100%);
  --grid: rgba(255, 255, 255, 0.022);
  --surface: #383F45;
  --surface-2: #414950;
  --line: #4C555D;
  --line-strong: #5D6770;
  --text: #E5E3DD;
  --muted: #BEC3C7;
  --ink: #93BFDB;
  --ink-text: #1E2A33;
  --ink-soft: #3B4C59;
  --ok: #8BCBA4;
  --ok-soft: #34493F;
  --warn: #E4C47E;
  --warn-soft: #4D4634;
  --bad: #EBA197;
  --bad-soft: #55403D;
  --hl: rgba(228, 200, 96, 0.3);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.15), 0 10px 26px -18px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--bg-grad);
  background-size: 22px 22px, 22px 22px, 100% 100%;
  background-attachment: fixed;
  min-height: 100vh; min-height: 100dvh;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- estrutura ---------- */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; min-height: 100dvh; }
.top {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); display: grid; place-items: center; color: var(--ink-text); }
.brand-mark svg { width: 16px; height: 16px; }
.top select.year-select { width: auto; min-width: 96px; min-height: 40px; padding: 4px 10px; font-weight: 700; }
.kids { display: flex; gap: 6px; width: 100%; overflow-x: auto; scrollbar-width: none; }
.kids::-webkit-scrollbar { display: none; }

main { padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); width: 100%; max-width: 1080px; margin: 0 auto; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 0.74rem; font-weight: 600;
}
.nav a[aria-current='page'] { color: var(--ink); }
.nav a[aria-current='page'] svg { stroke-width: 2.3; }

@media (min-width: 900px) {
  .app { grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / -1; padding-left: 24px; padding-right: 24px; position: sticky; top: 0; }
  .kids { width: auto; }
  .nav {
    position: sticky; top: 64px; bottom: auto; height: calc(100vh - 64px); height: calc(100dvh - 64px);
    grid-template-columns: 1fr; grid-auto-rows: 48px; align-content: start; gap: 2px;
    padding: 16px 12px; background: transparent; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 10px; font-size: 0.95rem; }
  .nav a[aria-current='page'] { background: var(--ink-soft); }
  main { padding: 24px 28px 48px; }
}

/* ---------- tipografia ---------- */
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.015em; }
h2 { font-size: 1.15rem; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 0; }
.sub { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 700; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink); padding: 0 10px; }
.btn.danger { color: var(--bad); }
.btn.primary.danger { background: var(--bad); color: var(--surface); border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; border-radius: 8px; }
.btn.icon { width: 44px; padding: 0; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; font-weight: 600; font-size: 0.92rem; white-space: nowrap;
}
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); }

input[type='text'], input[type='number'], input[type='email'], input[type='password'], input[type='search'], input[type='tel'], input[type='url'], select, textarea, .input {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 16px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
label.field { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
label.field > span { padding-left: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- blocos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.stack { display: grid; gap: 12px; }
.stack-l { display: grid; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hr { height: 1px; background: var(--line); margin: 4px 0; }

.list-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.kid-mark { width: 6px; align-self: stretch; border-radius: 4px; background: var(--c, var(--ink)); flex: none; }
.section-title { padding: 12px 16px 6px; color: var(--muted); font-size: 0.86rem; font-weight: 700; border-top: 1px dashed var(--line); }
.section-title:first-of-type { border-top: 0; }

/* item */
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start;
  padding: 10px 16px; border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  cursor: pointer;
}
.item:hover { background: color-mix(in srgb, var(--ink-soft) 35%, transparent); }
.item .desc { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: 0.86rem; color: var(--muted); align-items: center; }
.item.done .desc { text-decoration: line-through; text-decoration-color: var(--ok); text-decoration-thickness: 2px; color: var(--muted); }
.item.skip .desc { color: var(--muted); }
.qty { font-weight: 700; color: var(--text); }
.tick {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line-strong); background: transparent;
  display: grid; place-items: center; cursor: pointer; margin-top: 1px; color: transparent;
}
.tick svg { width: 16px; height: 16px; stroke-width: 3; }
.tick[data-s='comprado'] { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.tick[data-s='tenho'] { border-color: var(--ink); color: var(--ink); border-style: dashed; }
.tick[data-s='ignorar'] { border-style: dotted; }

.prices { display: grid; gap: 2px; justify-items: end; text-align: right; min-width: 92px; }
.price { font-size: 0.9rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.price .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.price.best { color: var(--text); font-weight: 700; }
/* o marca-texto: destaca o menor preço */
.hl { background: linear-gradient(100deg, transparent 2%, var(--hl) 6%, var(--hl) 94%, transparent 98%) 0 62% / 100% 58% no-repeat; padding: 0 3px; border-radius: 2px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.ink { background: var(--ink-soft); color: var(--ink); border-color: transparent; }

/* resumo */
.totals { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .totals { grid-template-columns: 1.4fr 1fr; } }
.big { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.store-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.store-line:first-child { border-top: 0; }
.store-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.store-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }

/* modo loja */
.qrow { display: grid; grid-template-columns: 1fr 118px; gap: 8px 10px; align-items: center; padding: 10px 16px; border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.qrow .desc { font-weight: 600; line-height: 1.3; }
.qrow .hint { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 0.85rem; color: var(--muted); }
.price-in { position: relative; }
.price-in input { text-align: right; padding-left: 34px; font-weight: 700; font-size: 18px; }
.price-in::before { content: 'R$'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; pointer-events: none; }
.saved { color: var(--ok); font-weight: 700; }
.sticky-tools { position: sticky; top: 0; z-index: 5; padding: 10px 0; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@media (min-width: 900px) { .sticky-tools { top: 64px; } }

/* importação */
.drop {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 28px 16px;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer;
}
.drop.over { border-color: var(--ink); background: var(--ink-soft); }
.rv { display: grid; grid-template-columns: 28px 64px 1fr; gap: 8px; align-items: start; padding: 10px 12px; border-top: 1px solid var(--line); }
.rv.low { background: color-mix(in srgb, var(--warn-soft) 70%, transparent); }
.rv.off { opacity: 0.55; }
.rv input[type='text'], .rv input[type='number'], .rv select { min-height: 38px; padding: 6px 8px; font-size: 16px; }
.rv .extra { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rq { display: grid; gap: 6px; padding: 12px; border-top: 1px solid var(--line); }
.rq.low { background: color-mix(in srgb, var(--warn-soft) 70%, transparent); }
.rq .store-desc { font-size: 0.9rem; font-weight: 600; }
.steps { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 0.88rem; }
.steps b { color: var(--text); }

/* folha (bottom sheet) */
dialog.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 1px solid var(--line); border-radius: 18px 18px 0 0; background: var(--surface); color: var(--text);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
}
dialog.sheet::backdrop { background: rgba(20, 24, 27, 0.45); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 16px; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet-body { padding: 16px; display: grid; gap: 14px; overflow-y: auto; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.sheet-foot .btn { flex: 1; }
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(24px); opacity: 0.4; } }
}
.store-price { display: grid; grid-template-columns: 1fr 120px 74px; gap: 8px; align-items: center; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 42px; border: 0; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 0.9rem; border-left: 1px solid var(--line); padding: 0 4px; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--ink-text); }

/* vazio / avisos */
.empty { text-align: center; padding: 36px 20px; display: grid; gap: 12px; justify-items: center; }
.note { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 0.92rem; }
.note.info { background: var(--ink-soft); color: var(--ink); }
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); bottom: auto; transform: translateX(-50%);
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.45); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 100; max-width: calc(100% - 32px);
}
/* avisos sempre no alto da tela (D109); no popover o navegador põe inset/margin próprios: desfaz */
.toast[popover] { inset: auto; top: calc(14px + env(safe-area-inset-top)); left: 50%; right: auto; bottom: auto; margin: 0; transform: translateX(-50%); }
.toast[popover]:not(:popover-open) { display: none; }
.toast { cursor: pointer; overflow: hidden; padding-bottom: 14px; min-width: min(360px, calc(100% - 32px)); }
.toast-foot { margin-top: 6px; font-size: 0.78rem; font-weight: 400; color: var(--muted); }
.toast-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.toast-bar i { display: block; height: 100%; width: 100%; background: var(--ink); }
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--ink); color: var(--ink-text);
  display: grid; place-items: center; box-shadow: 0 10px 24px -8px rgba(0,0,0,.45); cursor: pointer;
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }
table.simple { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.simple td, table.simple th { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; }
table.simple th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.badge svg.i { width: 14px; height: 14px; }
.netpill { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 0; font-weight: 700; font-size: 0.82rem; cursor: pointer; }
.netpill.warn { background: var(--warn-soft); color: var(--warn); }
.netpill.bad { background: var(--bad-soft); color: var(--bad); }
.netpill.ink { background: var(--ink-soft); color: var(--ink); }
@media (max-width: 899px) { .netpill { order: 10; } }
.seg-wrap button { line-height: 1.15; padding: 4px 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { position: relative; width: 38px; height: 38px; cursor: pointer; }
.sw input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sw span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); }
.sw input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.sw input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 3px; }

.grid-2 > *, .grid-3 > *, .field > * { min-width: 0; }
dialog.sheet { max-width: min(560px, 100vw); overflow-x: hidden; }
.sheet-body { overflow-x: hidden; }
.stack > .btn, .stack > label.btn, .sheet-body > .btn { white-space: normal; text-align: center; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }
.stack-l > *, main > * { min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-app { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); line-height: 1.15; }
.brand-family { font-size: 0.8rem; font-weight: 600; color: var(--muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

dialog.sheet { max-height: 92vh; max-height: 92dvh; }

/* ---- v0.9: correções do QA ---- */
/* QA-07: nome da família longo não pode alargar a página */
.brand { min-width: 0; flex: 1 1 0; max-width: 100%; overflow: hidden; }
.brand-mark { flex: none; }
.brand-text, .brand > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-family { display: block; max-width: 100%; }
/* QA-11: áreas de toque de pelo menos 44px, mantendo o desenho */
.tick { position: relative; }
.tick::before { content: ''; position: absolute; inset: -8px; }
.chip { min-height: 40px; }
.btn.sm { min-height: 40px; }
.switch input { width: 50px; height: 30px; }
.switch input::after { width: 24px; height: 24px; }
details > summary { min-height: 40px; display: flex; align-items: center; }
.item:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 6px; }
/* QA-14: aviso dentro da folha fica no alto da tela, sem cobrir o botão */
dialog .toast { position: fixed; top: calc(14px + env(safe-area-inset-top)); bottom: auto; left: 50%; transform: translateX(-50%); margin: 0; z-index: 10; max-width: calc(100% - 32px); }
.btn.danger.armed { background: var(--bad); color: var(--surface); border-color: var(--bad); }
/* QA-07: o cabeçalho nunca define a largura mínima da página */
.app { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .app { grid-template-columns: 220px minmax(0, 1fr); } }
.top { min-width: 0; }
/* topo no celular: mais espaço para "Família ..." (nome com até 20 letras sem cortar em 360 px) */
@media (max-width: 420px) {
  .top { gap: 6px; padding-left: 12px; padding-right: 10px; }
  .top select.year-select { min-width: 0; padding: 4px 4px 4px 8px; }
  .top #themeBtn { width: 40px; }
  .brand { gap: 7px; }
}
.kids .badge { white-space: nowrap; }
/* "Mais dados (opcional)" nas folhas de cadastro */
details.more > summary { cursor: pointer; font-weight: 700; color: var(--ink); padding: 8px 0; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '+'; display: inline-block; width: 1.2em; }
details.more[open] > summary::before { content: '–'; }

/* ===== ajuste de cores e destaques (revisão de UI/UX, D111) ===== */
:root {
  --edge: #7F8B88;          /* P1 borda de campos e da bolinha de "comprado" (era #BCC6C3: 1,69:1 → 3,4:1) */
  --ok-soft: #E6F4EB;       /* P1 fundo dos selos verdes (texto 4,35:1 → 4,6:1) */
  --hl-text: var(--text);
  --muted: #56625F;         /* P3 mesmo cinza do site (era #5B6867) */
  --grid: rgba(47, 106, 143, 0.065); /* P3 quadriculado um pouco mais visível, como no site */
}
:root[data-theme='escuro'] {
  --edge: #858F99;                    /* P1 (era #5D6770: 1,85:1 → 3,25:1) */
  --hl: rgba(230, 198, 90, 0.9);      /* P1 marca-texto amarelo de verdade (era oliva apagado) */
  --hl-text: #1E2A33;                 /* P1 texto escuro sobre o amarelo: 4,39:1 → 7,6:1 */
  --grid: rgba(255, 255, 255, 0.032); /* P3 quadriculado igual ao do site (era 0.022, quase sumia) */
}

/* P1 — menor preço no escuro: marca-texto inteiro, com texto escuro por cima */
:root[data-theme='escuro'] .hl { background: var(--hl); color: var(--hl-text); border-radius: 4px; padding: 0 4px; }

/* P1 — campos, bolinha de marcar, chave e botões segmentados com borda visível */
input[type='text'], input[type='number'], input[type='email'], input[type='password'], input[type='search'], input[type='tel'], input[type='url'], select, textarea, .input { border-color: var(--edge); }
.tick { border-color: var(--edge); }
.switch input { background: var(--edge); }
.switch input:checked { background: var(--ok); }
.seg { border-color: var(--edge); }

/* P2 — economia em verde: "R$ 2,00 mais barato que ..." em Onde comprar */
section.card:has(> .store-head) .item .meta > span:not([class]) { color: var(--ok); font-weight: 600; }

/* P2 — resultado de "Compensa ir a mais de uma loja?" é boa notícia: verde, não amarelo de alerta */
.store-line ~ .note { background: var(--ok-soft); color: var(--ok); }

/* P2 — aviso (toast) se destaca do topo: faixa de caneta azul à esquerda; no escuro, fundo um tom acima */
.toast { border-left: 4px solid var(--ink); }
:root[data-theme='escuro'] .toast { background: var(--surface-2); box-shadow: 0 14px 36px -10px rgba(0, 0, 0, 0.7); }

/* P2 — no celular, a aba atual da barra de baixo ganha uma pílula atrás do ícone (não depende só da cor) */
@media (max-width: 899px) {
  .nav a[aria-current='page'] svg { background: var(--ink-soft); border-radius: 999px; padding: 2px 12px; box-sizing: content-box; }
}
/* (mantém a borda azul do campo em foco) */
input:focus, select:focus, textarea:focus { border-color: var(--ink); }

/* cupons em cartões (cabe no celular) */
.coupon-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.coupon-head h2 { margin: 0; }
.coupon-list { display: grid; gap: 10px; }
.coupon-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.coupon-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.coupon-lines { margin: 0; padding: 0; list-style: none; font-size: 0.92rem; color: var(--muted); display: grid; gap: 2px; overflow-wrap: anywhere; }
.coupon-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 640px) { .coupon-actions { display: flex; justify-content: flex-end; } }

/* tabela larga (Indicadores) rola de lado dentro do cartão, sem alargar a página */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-scroll table { min-width: 100%; white-space: nowrap; }
section.card { min-width: 0; }

/* confirmação de cupom sem limite (D121): sobe por cima do rodapé da folha, sem perder o que foi preenchido */
.nolimit-confirm { position: sticky; bottom: 0; z-index: 2; margin: 8px 0 0; padding: 14px; display: grid; gap: 8px;
  background: var(--surface); border: 2px solid var(--warn, #d9a55b); border-radius: 12px; box-shadow: 0 -6px 18px rgba(0,0,0,.18); }
.nolimit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- painel do dono (D137) ---------- */
.nav.six { grid-template-columns: repeat(6, 1fr); }
.nav.six a span { font-size: 0.68rem; text-align: center; line-height: 1.1; }
@media (min-width: 900px) { .nav.six { grid-template-columns: 1fr; } .nav.six a span { font-size: inherit; text-align: left; } }
.pn h2 { display: flex; align-items: center; gap: 8px; font-size: 1.08rem; margin: 0 0 10px; }
.pn h2 .btn { margin-left: auto; }
.pn .card { margin-bottom: 16px; }
.pn-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.pn-todo { list-style: none; margin: 0; padding: 0; }
.pn-todo li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.pn-todo li:first-child { border-top: 0; padding-top: 2px; }
.pn-todo li > div { flex: 1; min-width: 0; }
.pn-todo small { display: block; color: var(--muted); font-size: 0.84rem; }
.pn-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pn-dot.bad { background: var(--bad); } .pn-dot.warn { background: #D9A54A; } .pn-dot.ok { background: var(--ok); }
.pn-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (min-width: 1100px) { .pn-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.pn-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.pn-tile span { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.pn-tile b { font-size: 1.55rem; line-height: 1.15; margin: 2px 0; font-variant-numeric: tabular-nums; }
.pn-tile small { font-size: 0.8rem; color: var(--muted); }
.pn-tile small.up { color: var(--ok); } .pn-tile small.alert { color: var(--bad); font-weight: 700; }
.pn-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 560px; }
.pn-table th, .pn-table td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.pn-table th { font-size: 0.78rem; color: var(--muted); border-top: 0; }
.pn-table .n { text-align: right; font-variant-numeric: tabular-nums; }
.pn-two { display: grid; gap: 16px; }
@media (min-width: 900px) { .pn-two { grid-template-columns: 1fr 1fr; } }
.pn-funnel { display: grid; gap: 8px; }
.pn-frow { display: grid; grid-template-columns: 140px 1fr 48px; gap: 10px; align-items: center; font-size: 0.9rem; }
.pn-frow b { text-align: right; }
.pn-bar { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.pn-bar i { display: block; height: 100%; background: var(--ink); border-radius: 6px; }

.pn-cities > td { padding: 0 0 8px 18px; border-top: 0; }
.pn-table.pn-sub { min-width: 0; background: var(--surface-2); border-radius: 8px; }
.pn-table.pn-sub th, .pn-table.pn-sub td { padding: 6px 10px; }
