/* Garante que o atributo "hidden" sempre esconda o elemento, mesmo quando a classe define display explicitamente (ex: .modal, .topbar, .results). Sem isso, [hidden] perde para regras de autor que fixam display. */
[hidden] { display: none !important; }

:root {
  --ink: #12130f;
  --ink-soft: #4c4f45;
  --paper: #f6f4ee;
  --card: #fffdf8;
  --line: #e4e0d5;
  --emerald: #0f7b5a;
  --emerald-bright: #12b981;
  --amber: #c9861f;
  --danger: #b23b2e;
  --shadow: 0 1px 2px rgba(18, 19, 15, .04), 0 8px 24px rgba(18, 19, 15, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, .brand, .plan-price { font-family: "Space Grotesk", sans-serif; }

.muted { color: var(--ink-soft); }
.fineprint { font-size: .78rem; color: var(--ink-soft); margin: 12px 0 0; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--emerald); color: #fff; }
.btn-primary:hover { background: #0c6549; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #efece3; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
}
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--emerald-bright), var(--emerald));
  box-shadow: 0 0 0 4px rgba(18, 185, 129, .15);
}

/* ---------- Gate ---------- */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.gate-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px;
  max-width: 460px; width: 100%;
}
.gate-card h1 {
  font-size: 1.9rem; line-height: 1.12; margin: 20px 0 12px; letter-spacing: -.02em;
}
.gate-card h1 em { font-style: normal; color: var(--emerald); }
.field { display: block; margin: 24px 0 14px; }
.field span { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.field input, .search-row input, #keyword {
  width: 100%; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff;
}
.field input:focus, #keyword:focus { outline: 2px solid var(--emerald-bright); outline-offset: 1px; border-color: transparent; }
.gate-card .btn-primary { width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: 0; z-index: 5;
}
.account { display: flex; align-items: center; gap: 14px; font-size: .88rem; }
.pill {
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .8rem;
  background: #e9f6f0; color: var(--emerald); border: 1px solid #cdeadd;
}
.pill.low { background: #fbeede; color: var(--amber); border-color: #f0d9b5; }
.pill.empty { background: #f8e3df; color: var(--danger); border-color: #eec7c0; }

/* ---------- App ---------- */
.app { max-width: 1120px; margin: 0 auto; padding: 28px; }
.search-row { display: flex; gap: 10px; }
.search-row #keyword { flex: 1; }
.search-row .btn { white-space: nowrap; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 999px; font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip:hover { border-color: #cdc8b9; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-note {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 6px; background: #efece3; color: var(--ink-soft);
}
.chip.active .chip-note { background: rgba(255,255,255,.16); color: #e9e6dd; }
.filters-hint { font-size: .8rem; margin-left: 4px; }

/* ---------- Results ---------- */
.results {
  margin-top: 26px;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.card-img { aspect-ratio: 1; background: #eceadf center/cover no-repeat; position: relative; }
.card-score {
  position: absolute; top: 8px; left: 8px;
  background: rgba(18,19,15,.82); color: #fff; font-size: .7rem; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-name {
  font-size: .9rem; line-height: 1.3; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.3em;
}
.commission {
  display: flex; align-items: baseline; gap: 6px;
  background: #e9f6f0; border: 1px solid #cdeadd; border-radius: 10px; padding: 8px 10px;
}
.commission b { font-family: "Space Grotesk"; font-size: 1.35rem; color: var(--emerald); }
.commission small { color: var(--ink-soft); font-size: .74rem; }
.meta { display: flex; justify-content: space-between; font-size: .78rem; color: var(--ink-soft); }
.meta .price { font-weight: 600; color: var(--ink); }
.card-actions { display: flex; gap: 8px; margin-top: auto; }
.card-actions .btn { flex: 1; padding: 9px; font-size: .82rem; text-align: center; text-decoration: none; }
.card-actions a.btn-ghost { display: grid; place-items: center; }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--ink-soft);
}
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(18,19,15,.5); display: grid; place-items: center; padding: 24px; z-index: 20; }
.modal-card { background: var(--card); border-radius: 18px; padding: 32px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 8px; }
.plan { border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 20px 0; text-align: left; }
.plan-price { font-size: 2.2rem; color: var(--emerald); }
.plan-price span { font-size: 1rem; color: var(--ink-soft); font-family: "Inter"; }
.plan ul { margin: 12px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: .9rem; line-height: 1.7; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: .88rem; z-index: 30; box-shadow: var(--shadow);
}

@media (max-width: 520px) {
  .gate-card, .modal-card { padding: 26px; }
  .search-row { flex-direction: column; }
  .search-row .btn { width: 100%; }
}

/* ================= v2: auth, settings, admin ================= */
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.error { color: var(--danger); font-size: .85rem; margin-top: 12px; }
.switch { margin-top: 16px; font-size: .9rem; }
.switch a { color: var(--emerald); font-weight: 600; text-decoration: none; margin-left: 4px; }

.gate-card .field:first-of-type { margin-top: 22px; }
.gate-card .btn-primary { width: 100%; margin-top: 8px; }

.banner {
  background: #fbeede; border: 1px solid #f0d9b5; color: #8a5a12;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: .9rem;
}
.banner a { color: var(--emerald); font-weight: 600; }
.link-btn { background: none; border: none; color: var(--emerald); font: inherit; font-weight: 600; cursor: pointer; padding: 0 4px; text-decoration: underline; }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }
.modal-card .field { text-align: left; margin: 16px 0 0; }

/* Admin */
.admin-controls { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; box-shadow: var(--shadow); }
.admin-controls h2 { margin: 0 0 14px; font-size: 1.15rem; }
.admin-form { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-form input[type=email] { flex: 1; min-width: 220px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.admin-form input[type=number] { width: 90px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }

table.users { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.users th, table.users td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: .9rem; }
table.users th { background: #f0ede4; font-weight: 600; }
table.users tr:last-child td { border-bottom: none; }
.tag { padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #efece3; color: var(--ink-soft); }
.tag-pro { background: #e9f6f0; color: var(--emerald); }

/* ================= v3: abas, salvar, historico ================= */
.tabs { display: flex; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--line); }
.tab {
  border: none; background: none; font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: 10px 16px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--emerald); border-bottom-color: var(--emerald); }

.card-img { position: relative; }
.bookmark {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.9); color: var(--ink-soft); font-size: 1rem; line-height: 1;
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.bookmark:hover { background: #fff; }
.bookmark.on { color: var(--emerald); }

.history { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; flex-direction: column; gap: 3px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; font: inherit;
}
.history-item:hover { border-color: var(--emerald); }
.hi-kw { font-weight: 600; }
.hi-meta { font-size: .8rem; color: var(--ink-soft); }
