:root {
    --bg: #f7f6f2;
    --surface: #ffffff;
    --surface-2: #fafaf6;
    --border: #e5e3dc;
    --text: #1d1d1f;
    --text-muted: #62625f;
    --accent: #0f7a4a;
    --accent-soft: #e2f3eb;
    --discount: #c2410c;
    --discount-soft: #ffedd5;
    --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    --radius: 12px;

    --continente: #d92231;
    --auchan: #f6831f;     /* orange — differentiates from Continente red */
    --pingodoce: #009646;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", sans-serif,
        "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ---------- Header / footer ---------- */
.site-header {
    padding: 28px 24px 8px;
    text-align: center;
}
.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.5rem;
}
.site-brand:hover { text-decoration: none; }
.site-brand-mark {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font-size: 1.1rem;
}
.site-brand-tagline {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.site-footer {
    padding: 32px 24px 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px;
}

/* ---------- Hero / search ---------- */
.hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 220px;
    padding: 14px 18px;
    font-size: 1.05rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface);
}
.search-button {
    padding: 14px 24px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.search-button:hover { background: #0c633c; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    align-items: center;
}
.filter-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-right: 4px;
}
.chip {
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.88rem;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.chip:hover { text-decoration: none; background: var(--surface); border-color: #d3d1c8; }
.chip-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.stats {
    margin: 16px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.stats strong { color: var(--text); }

/* ---------- Results ---------- */
.results-count {
    color: var(--text-muted);
    margin: 0 0 12px;
    font-size: 0.9rem;
}

.card-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.12s, box-shadow 0.15s;
    position: relative;
}
.card:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 12px 28px rgba(0,0,0,0.06);
}
.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}
.card-continente::before { background: var(--continente); }
.card-auchan::before     { background: var(--auchan); }
.card-pingodoce::before  { background: var(--pingodoce); }

.card-link {
    display: block;
    padding: 16px 16px 16px 22px;
    color: inherit;
    text-decoration: none;
}
.card-link:hover { text-decoration: none; }

.retailer-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: white;
    background: var(--text-muted);
}
.retailer-continente { background: var(--continente); }
.retailer-auchan     { background: var(--auchan); }
.retailer-pingodoce  { background: var(--pingodoce); }

.product-name {
    margin: 8px 0 4px;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    /* keep cards uniform: clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-meta {
    margin: 0 0 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.brand { font-weight: 600; color: var(--text); }
.cat-sep { margin: 0 6px; color: #c5c3bb; }
.category { color: var(--text-muted); }

.price-block {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}
.price-now {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}
.price-pvpr {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.discount-badge {
    background: var(--discount-soft);
    color: var(--discount);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}
.price-per-unit {
    width: 100%;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 2px;
}
.price-empty {
    color: var(--text-muted);
    font-style: italic;
}

/* ---------- Empty / 404 states ---------- */
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state code {
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}
.empty-hint { font-size: 0.9rem; margin-top: 8px; }

/* ---------- Product detail ---------- */
.back-link {
    margin: 0 0 16px;
    font-size: 0.9rem;
}

.product-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.product-header h1 {
    margin: 8px 0 4px;
    font-size: 1.6rem;
    line-height: 1.25;
}
.category-detail {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}
.ean, .sku { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; }

.price-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px 0;
}
.price-card {
    flex: 1;
    min-width: 140px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.price-card-label {
    display: block;
    font-size: 0.76rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.price-card-value {
    display: block;
    margin-top: 4px;
    font-size: 1.4rem;
    font-weight: 700;
}
.price-card-value.strike { text-decoration: line-through; color: var(--text-muted); font-weight: 500; }
.price-card-discount .price-card-value { color: var(--discount); }

/* ---------- Cross-retailer comparison ---------- */
.cross-retailer-section {
    margin-top: 8px;
}
.cross-retailer-section h2 {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 16px 0 8px;
}
.cross-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cross-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-left-width: 4px;
    flex-wrap: wrap;
}
.cross-continente { border-left-color: var(--continente); }
.cross-auchan     { border-left-color: var(--auchan); }
.cross-pingodoce  { border-left-color: var(--pingodoce); }

.cross-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}
.cross-link:hover { text-decoration: none; }
.cross-link:hover .cross-name { color: var(--accent); }

.cross-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cross-brand {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.cross-price-block {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}
.cross-price {
    font-size: 1.15rem;
    font-weight: 700;
}
.cross-diff {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}
.cross-diff-cheaper { background: var(--accent-soft); color: var(--accent); }
.cross-diff-pricier { background: var(--discount-soft); color: var(--discount); }
.cross-diff-same    { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.cross-per-unit { color: var(--text-muted); font-size: 0.82rem; width: 100%; }

.cross-disclaimer {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

/* ---------- Sparkline ---------- */
.chart-section { margin-top: 8px; }
.chart-section h2 {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 16px 0 8px;
}
.sparkline {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    width: 100%;
    height: auto;
    display: block;
}
.spark-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.spark-area  { fill: var(--accent-soft); stroke: none; opacity: 0.7; }
.spark-point { fill: var(--accent); }
.axis-line { stroke: #d3d1c8; stroke-width: 1; }
.axis-line-faint { stroke-dasharray: 2 3; opacity: 0.6; }
.axis-label { fill: var(--text-muted); font-size: 11px; font-family: inherit; }

/* ---------- History table ---------- */
.history-table-section h2 {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 24px 0 8px;
}
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.history-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.history-table tr:last-child td { border-bottom: 0; }
.cell-time { color: var(--text-muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; }
.cell-price { font-weight: 700; }
.cell-pvpr { color: var(--text-muted); }
.muted { color: var(--text-muted); font-size: 0.84rem; }

.external-link { margin-top: 24px; font-size: 0.92rem; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .container { padding: 16px; }
    .hero, .product-detail { padding: 20px; }
    .card-list { grid-template-columns: 1fr; }
    .product-detail { padding: 20px; }
    .price-summary { gap: 8px; }
    .price-card { min-width: 120px; padding: 10px 12px; }
    .price-card-value { font-size: 1.2rem; }
    .history-table { font-size: 0.82rem; }
    .history-table th, .history-table td { padding: 6px 8px; }
}
