:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1c2430;
    --muted: #66707d;
    --accent: #0a7d4d;
    --accent-dark: #07603b;
    --amber: #b35c00;
    --border: #e3e8ee;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

a { color: inherit; text-decoration: none; }

/* ── Topo ─────────────────────────────────────────── */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-top: 14px;
    padding-bottom: 14px;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; white-space: nowrap; }
.brand-logo { height: 44px; width: auto; display: block; transition: opacity .15s; }
.brand:hover .brand-logo { opacity: .85; }

.search { display: flex; flex: 1; min-width: 260px; gap: 8px; }

.search input {
    flex: 1;
    padding: 10px 16px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 999px;
    outline: none;
    background: var(--bg);
}

.search input:focus { border-color: var(--accent); background: #fff; }

.search button {
    padding: 10px 22px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.search button:hover { background: var(--accent-dark); }

/* ── Hero / vazio ─────────────────────────────────── */
.hero { text-align: center; padding: 90px 0 60px; }
.hero h1 { font-size: 34px; margin: 0 0 12px; }
.hero p { color: var(--muted); font-size: 17px; margin: 0 0 28px; }

.chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.chip {
    padding: 8px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 14px;
    box-shadow: var(--shadow);
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

.empty { text-align: center; padding: 80px 0; color: var(--muted); }
.empty h2 { color: var(--text); }

/* ── Cabeçalho dos resultados ─────────────────────── */
.results-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 28px 0 18px;
}

.results-head h1 { font-size: 20px; margin: 0; }

.sources {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    color: var(--muted);
    font-size: 13px;
    margin: 4px 0 0;
}

.sources span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.sources img { width: 16px; height: 16px; border-radius: 4px; }

.sources .off { opacity: .45; }
.sources .off::after { content: " ✕"; color: #c0392b; }
.sources .cached::after { content: none; }

.sort { display: flex; gap: 6px; }

.sort a {
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--muted);
}

.sort a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* No celular as pílulas não quebram linha: rolam de lado se faltar espaço. */
@media (max-width: 640px) {
    .results-head { flex-direction: column; align-items: stretch; }

    .sort {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0 -20px;
        padding: 2px 20px;
    }

    .sort::-webkit-scrollbar { display: none; }
}

/* ── Cards ────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
    gap: 16px;
    margin-bottom: 48px;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card:hover { border-color: #c9d2dc; }

.badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #fff;
    border-radius: 6px;
}

.badge-price { background: var(--accent); }
.badge-unit { background: var(--amber); }

.thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 150px;
    margin-bottom: 12px;
}

.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.noimg { font-size: 48px; }

.card h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3.2em;
}

.card h3 a:hover { color: var(--accent); }

.meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 10px;
}

.meta .store {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: var(--text);
}

.meta .store img { width: 14px; height: 14px; border-radius: 3px; }

.price { font-size: 22px; font-weight: 800; margin: 0; }

.ppu {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin: 2px 0 0;
}

.btn {
    margin-top: auto;
    padding: 9px 0;
    margin-top: 14px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
}

.btn:hover { background: var(--accent); color: #fff; }

/* ── Rodapé ───────────────────────────────────────── */
.footer {
    padding-top: 16px;
    padding-bottom: 32px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}
