:root {
    --bg: #f2f5f1;
    --surface: #ffffff;
    --surface-2: #e6ebe4;
    --border: #cdd6ca;
    --text: #121a14;
    --muted: #56655a;
    --accent: #1a5c36;
    --accent-hover: #134428;
    --danger: #b42318;
    --success: #1f7a3f;
    --shadow: rgba(18, 26, 20, 0.07);
    --radius: 12px;
    --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1410;
        --surface: #161d18;
        --surface-2: #222b24;
        --border: #2e3a32;
        --text: #e6ece7;
        --muted: #95a399;
        --accent: #3d9e62;
        --accent-hover: #4db374;
        --shadow: rgba(0, 0, 0, 0.35);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button, input, select { font: inherit; }
button {
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
@media (prefers-reduced-motion: no-preference) {
    button:hover { transform: translateY(-1px); }
}
button:active { transform: scale(0.98); }

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}
input::placeholder { color: var(--muted); opacity: 0.75; }
input:focus, select:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
    border-color: var(--accent);
}

.page { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 28px var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 100%;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}
@media (prefers-reduced-motion: no-preference) {
    .product-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 36px var(--shadow);
        color: inherit;
    }
}

.product-image {
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; }

.product-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1;
}

.meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.82rem;
}
.retailer { color: var(--accent); font-weight: 700; text-transform: capitalize; }

.product-card h2 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
}
.fact {
    background: var(--surface-2);
    border-radius: var(--radius-pill);
    color: var(--muted);
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.card-actions { padding-top: 0.15rem; }
.price { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.02em; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { border-color: var(--accent); color: #fff; background: var(--accent); }

.btn-primary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-pill);
    padding: 0.7rem 1.1rem;
    text-decoration: none;
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.65rem 0.95rem;
}

.status {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--muted);
    margin: 1rem 0;
}
.status.error { color: var(--danger); }

@media (max-width: 840px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .page { padding: 1rem 1rem 2.5rem; }
    .grid { grid-template-columns: 1fr; }
}
