/* Gerto: paleta tirada do ícone (azul, ciano, amarelo do sino) */
:root {
  --bg: #f0f4fc;
  --surface: #ffffff;
  --surface-2: #f4f7ff;
  --text: #0f1b3a;
  --muted: #5b6a8c;
  --line: #dde6f6;
  --brand: #2f5bea;
  --brand-2: #19a7f5;
  --brand-soft: #e5edff;
  --brand-ink: #1c42bd;
  --hot: #ff8a1f;
  --hot-soft: #fff1e2;
  --hot-ink: #b35400;
  --sun: #ffc93c;
  --ok: #12a150;
  --ok-soft: #e3f7ec;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --hero-1: #1f3fae;
  --hero-2: #2f6fe8;
  --shadow: 0 1px 2px rgba(20, 44, 120, .06), 0 8px 24px rgba(20, 44, 120, .07);
  --radius: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1226;
    --surface: #121c38;
    --surface-2: #19254a;
    --text: #e8eeff;
    --muted: #98a6cc;
    --line: #243158;
    --brand: #6f9bff;
    --brand-2: #35c2ff;
    --brand-soft: #1c2c5c;
    --brand-ink: #b8ceff;
    --hot: #ffa045;
    --hot-soft: #3a2614;
    --hot-ink: #ffc58a;
    --ok: #3ddc84;
    --ok-soft: #12301f;
    --danger: #ff6b6f;
    --danger-soft: #3a1618;
    --hero-1: #12245c;
    --hero-2: #1e4fa8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: pan-x pan-y; overflow-x: clip; max-width: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
a { color: var(--brand); }
code { background: var(--brand-soft); color: var(--brand-ink); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
.ico { flex: none; }

/* ---------- cabeçalho ---------- */
.hero {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 20px 40px;
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
}
.hero::after {  /* brilho decorativo */
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255, 201, 60, .35), transparent 65%);
  pointer-events: none;
}
.hero > * { max-width: 600px; margin-left: auto; margin-right: auto; position: relative; z-index: 1; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand img { border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.hero h1 { font-size: 1.9rem; line-height: 1.15; margin: 22px auto 2px; letter-spacing: -.02em; }
.hero .sub { margin: 0 auto; opacity: .8; font-size: .95rem; }
.hero + main { margin-top: -22px; position: relative; z-index: 2; }

.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600;
  padding: 6px 12px; border-radius: 99px; text-decoration: none;
  background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(6px);
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #ffb4b4; }
.status.on .dot { background: #5dff9f; box-shadow: 0 0 0 3px rgba(93, 255, 159, .25); }
.status.inline { padding: 0; background: none; color: var(--muted); font-weight: 500; backdrop-filter: none; }
.status.inline.on .dot { background: var(--ok); box-shadow: none; }
.status.inline.off .dot { background: var(--danger); }

/* ---------- navegação inferior ---------- */
.dock {
  position: fixed; z-index: 10; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  display: flex; padding: 6px; gap: 2px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
}
.dock a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; border-radius: 18px; text-decoration: none; color: var(--muted);
  font-size: .68rem; font-weight: 600; transition: background .15s, color .15s;
}
.dock a.active { background: var(--brand-soft); color: var(--brand-ink); }
.dock a:active { transform: scale(.96); }

/* ---------- cartões ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: light) { .card { border-color: transparent; } }
.card h2 { font-size: 1.15rem; margin: 0 0 4px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.item.muted { opacity: .55; }
.item.on { box-shadow: var(--shadow), inset 3px 0 0 var(--brand); }
.grow { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.grow > strong, .grow > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow > strong.kw { font-size: 1.05rem; }
small, .hint, time { color: var(--muted); font-size: .85rem; }
.hint { margin: -4px 0 10px; }

.avatar {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700;
}
.avatar.big { width: 52px; height: 52px; border-radius: 18px; font-size: 1.3rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand-ink); white-space: nowrap;
}
.chip.hot { background: var(--hot-soft); color: var(--hot-ink); }
.chip.neg, .chip.bad { background: var(--danger-soft); color: var(--danger); }

/* aviso */
.alert-card { position: relative; overflow: hidden; }
.alert-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(var(--hot), var(--sun));
}
.alert-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.alert-card .title { font-size: 1.02rem; }
.alert-card .snippet { margin: 10px 0 12px; white-space: pre-wrap; word-break: break-word; }

/* vazio */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .ico { color: var(--brand); opacity: .5; }
.empty p { margin: 10px 0 4px; font-weight: 600; color: var(--text); }

/* ---------- formulários ---------- */
.form-card summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 700; color: var(--brand-ink);
}
.form-card summary::-webkit-details-marker { display: none; }
.form-card[open] summary { margin-bottom: 8px; }
form label { display: block; margin: 12px 0; font-size: .85rem; font-weight: 600; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 13px 14px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.code-input { font-size: 1.5rem; letter-spacing: .4em; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 label { margin-bottom: 4px; }
fieldset { border: 0; padding: 0; margin: 14px 0; }
legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 8px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; font-weight: 500; }
label.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); appearance: auto; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-check { margin: 0; position: relative; }
.pill-check input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.pill-check span {
  display: inline-block; padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  color: var(--text); font-weight: 500; font-size: .9rem; cursor: pointer; transition: all .15s;
}
.pill-check input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill-check input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }
.row-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; min-height: 48px; font: inherit; font-weight: 700; border: 0; border-radius: 14px;
  text-decoration: none; cursor: pointer; transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent);
}
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn.danger-text { color: var(--danger); }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: .88rem; border-radius: 12px; }
.btn.block { width: 100%; margin-top: 8px; }
.actions { margin: 12px 0; }
.icon-btn {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 12px; background: var(--surface-2); color: var(--muted); cursor: pointer;
}
.icon-btn.danger { color: var(--danger); background: var(--danger-soft); }
.item form { margin: 0; }

/* chave liga/desliga */
.switch {
  position: relative; flex: none; width: 52px; height: 32px; padding: 0; border: 0; border-radius: 99px;
  background: var(--line); cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .2s cubic-bezier(.3, 1.4, .6, 1);
}
.switch.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.switch.on::after { transform: translateX(20px); }
.htmx-request.switch { opacity: .6; }

/* mensagens */
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin: 12px 0;
  border-radius: 16px; background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: .92rem;
  box-shadow: var(--shadow);
}
.toast.err { background: var(--danger-soft); color: var(--danger); }
.toast a { color: inherit; }

/* ---------- login ---------- */
.login-page { padding-bottom: 0; min-height: 100vh; background: linear-gradient(160deg, var(--hero-1), var(--hero-2)) top / 100% 48vh no-repeat, var(--bg); }
.login { padding-top: calc(10vh + env(safe-area-inset-top)); text-align: center; }
.login-logo { border-radius: 28px; box-shadow: 0 12px 32px rgba(0, 0, 0, .3); }
.login h1 { color: #fff; margin: 16px 0 2px; font-size: 2rem; letter-spacing: -.02em; }
.login .tagline { color: rgba(255, 255, 255, .8); margin: 0 0 24px; }
.login .card { text-align: left; padding: 20px; }

/* ---------- produtos (fase 3) ---------- */
.hero h1 { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.back-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.product { padding: 0; overflow: hidden; }
.product.htmx-request { opacity: .6; }
.product-main { display: flex; gap: 12px; padding: 14px; color: inherit; text-decoration: none; }
.thumb {
  flex: none; width: 76px; height: 76px; border-radius: 14px; object-fit: contain;
  background: #fff; border: 1px solid var(--line);
}
.thumb.big { width: 104px; height: 104px; }
.thumb.broken { visibility: hidden; }  /* imagem da loja não carregou */
.empty-thumb { display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); border: 0; }
.pname {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: .95rem; line-height: 1.3;
}
.price-row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.price { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.price.big { font-size: 2rem; display: block; }
.product-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }
.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-head small { display: block; margin-top: 6px; }
.chart { width: 100%; height: 120px; display: block; margin-top: 16px; }
.chart-scale { display: flex; justify-content: space-between; margin-top: -2px; }
.history { list-style: none; margin: 8px 0 0; padding: 0; }
.history li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history span { color: var(--muted); font-size: .9rem; }
.row-actions form { margin: 0; }
.alert-card.price::before { background: linear-gradient(var(--ok), #6ee7a8); }

/* lojas sugeridas */
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.suggest form { margin: 0; }
.suggest-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px 9px 10px;
  border-radius: 99px; border: 1.5px dashed color-mix(in srgb, var(--brand) 45%, var(--line));
  background: var(--surface); color: var(--brand-ink); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
}
.suggest-btn:active { transform: scale(.96); background: var(--brand-soft); }
.warn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--hot); }
.suggest-btn .warn-dot { position: absolute; top: 2px; right: 4px; }
.legend { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; }

/* coletor de casa */
.link-like { color: var(--brand-ink); font-weight: 600; cursor: pointer; margin: 4px 0; }
.steps { padding-left: 20px; margin: 10px 0; }
.steps li { margin: 6px 0; }
.cmd {
  background: #0a1226; color: #d5e2ff; border-radius: 12px; padding: 12px; margin: 8px 0;
  font: .8rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere;
}
.cmd code { background: none; color: inherit; padding: 0; font-size: inherit; }
#coletor form { margin-top: 12px; }

.disclosure { color: var(--muted); font-size: .78rem; text-align: center; margin: 20px 8px 8px; }

/* ofertas por loja */
.offers { list-style: none; margin: 8px 0 0; padding: 0; }
.offer { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.offer:last-child { border-bottom: 0; }
.offer form { margin: 0; }
.offer small { display: block; }
.offer-price { font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.offer.is-best .offer-price { color: var(--ok); }
.offer.is-best strong::after { content: " · melhor"; color: var(--ok); font-size: .8rem; font-weight: 700; }
.add-offer { margin-top: 12px; }
.add-offer summary { display: flex; align-items: center; gap: 6px; list-style: none; }
.add-offer summary::-webkit-details-marker { display: none; }

/* sugestões da busca automática */
.suggestions { margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--hot-soft); }
.suggestion { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.suggestion form { margin: 0; }
.suggestion small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.ok { color: var(--ok); background: var(--ok-soft); }

.report ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: .85rem; }
.report li { margin: 3px 0; }
.offer .chip { vertical-align: middle; margin-left: 4px; font-size: .68rem; padding: 1px 8px; }
form.actions .btn + .btn { margin-left: 6px; }

/* contas e convites */
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 4px 4px; }
.invite-form { display: flex; gap: 8px; align-items: flex-end; }
.invite-form label { flex: 1; margin: 0; }
.invites { list-style: none; margin: 12px 0 0; padding: 0; }
.invites li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.invites li form { margin: 0; }
.invites code { font-size: .72rem; word-break: break-all; }
.icon-btn.ok { color: var(--ok); background: var(--ok-soft); }

/* canal dos avisos */
.channel-pick { display: flex; gap: 8px; margin: 8px 0 4px; }
.channel-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.channel-box p { margin: 0 0 6px; }

[hidden] { display: none !important; }  /* botões com display próprio também somem */
#update-box.htmx-request { opacity: .6; }

/* aba Ofertas */
.search-row { display: flex; gap: 8px; margin: 0 0 10px; }
.search-row input { flex: 1; min-width: 0; }
.store-filter { margin: 0 0 12px; flex-wrap: wrap; }
.store-filter .chip { text-decoration: none; }
.offer { display: flex; gap: 12px; align-items: flex-start; }
.offer-img { width: 84px; height: 84px; object-fit: cover; border-radius: 14px; flex: none; background: var(--brand-soft); }
.offer-body { min-width: 0; flex: 1; }
.offer-title { display: block; overflow-wrap: anywhere; }
.coupon {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding: 8px 12px;
  border: 2px dashed var(--hot-ink); border-radius: 12px; background: var(--hot-soft); color: var(--hot-ink);
  font: inherit; cursor: pointer; text-align: left;
}
.coupon b { letter-spacing: .04em; }
.coupon small { opacity: .75; }
.offer .row-actions { flex-wrap: wrap; margin-top: 12px; }

/* modo convidado do administrador */
.guest-bar {
  position: sticky; top: 8px; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 0 0 12px; padding: 8px 8px 8px 14px; border-radius: 14px;
  background: var(--hot-soft); color: var(--hot-ink); font-size: .85rem; font-weight: 600;
  box-shadow: 0 6px 18px rgba(15, 30, 90, .12);
}
.offer-details { margin: 4px 0 2px; color: var(--muted); font-size: .88rem; white-space: pre-line; overflow-wrap: anywhere; }
