/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --bg:          #f9fafb;
    --surface:     #ffffff;
    --border:      #e5e7eb;
    --text:        #111827;
    --text-muted:  #6b7280;
    --primary:     #16a34a;
    --primary-h:   #15803d;
    --danger:      #dc2626;
    --danger-h:    #b91c1c;
    --wool:        #16a34a;
    --coles:       #dc2626;
    --best-bg:     #dcfce7;
    --best-text:   #166534;
    --radius:      0.5rem;
    --shadow:      0 1px 4px rgba(0,0,0,.08);
}
html.dark {
    --bg:         #0f172a;
    --surface:    #1e293b;
    --border:     #334155;
    --text:       #f1f5f9;
    --text-muted: #94a3b8;
    --best-bg:    #14532d;
    --best-text:  #bbf7d0;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { max-width: 960px; margin: 0 auto; padding: .75rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
h1 { font-size: 1.25rem; font-weight: 700; }
.header-actions { display: flex; gap: .5rem; align-items: center; }
main { max-width: 960px; margin: 1.5rem auto; padding: 0 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem 1rem; border-radius: .375rem; border: none; font-size: .875rem; font-weight: 500; cursor: pointer; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { opacity: .8; }
.btn-danger   { background: var(--danger); color: #fff; padding: .3rem .6rem; font-size: .8rem; }
.btn-danger:hover { background: var(--danger-h); }
.btn-icon     { background: transparent; border: 1px solid var(--border); font-size: 1rem; padding: .4rem .6rem; }

/* ── Add form ───────────────────────────────────────────────────────────────── */
.add-section .input-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.add-section input { flex: 1; min-width: 200px; padding: .45rem .75rem; border: 1px solid var(--border); border-radius: .375rem; background: var(--bg); color: var(--text); font-size: .9rem; }
.add-section input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.hint { margin-top: .4rem; font-size: .8rem; color: var(--text-muted); }
.msg { margin-top: .5rem; font-size: .875rem; min-height: 1.2em; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--primary); }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.legend { display: flex; gap: .5rem; align-items: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { text-align: left; padding: .6rem .75rem; border-bottom: 2px solid var(--border); font-weight: 600; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: .6rem .75rem; vertical-align: top; }
tbody tr:hover { background: var(--border); }
.price-cell { font-weight: 600; font-size: .95rem; }
.price-best { color: var(--primary); background: var(--best-bg); border-radius: .25rem; padding: .15rem .4rem; }
.price-na    { color: var(--text-muted); font-style: italic; font-size: .85rem; }
.unit-label  { font-size: .78rem; color: var(--text-muted); display: block; }
.best-badge  { display: inline-flex; align-items: center; gap: .25rem; background: var(--best-bg); color: var(--best-text); border-radius: .375rem; padding: .25rem .6rem; font-size: .8rem; font-weight: 600; }
.time-cell   { color: var(--text-muted); font-size: .8rem; white-space: nowrap; }
.item-name   { font-weight: 500; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge { font-size: .75rem; padding: .2rem .55rem; border-radius: 999px; font-weight: 500; }
.badge-best    { background: var(--best-bg); color: var(--best-text); }
.badge-special { background: #fef3c7; color: #92400e; }
html.dark .badge-special { background: #451a03; color: #fde68a; }

/* ── States ─────────────────────────────────────────────────────────────────── */
.state-msg  { text-align: center; padding: 2rem; color: var(--text-muted); }
.hidden     { display: none; }
.scrape-note { margin-top: .75rem; font-size: .8rem; color: var(--text-muted); }

/* ── Store logo ─────────────────────────────────────────────────────────────── */
.store-logo { width: 18px; height: 18px; vertical-align: middle; margin-right: .2rem; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(4rem); background: #1e293b; color: #f8fafc; padding: .6rem 1.2rem; border-radius: .5rem; font-size: .875rem; opacity: 0; transition: opacity .25s, transform .25s; z-index: 100; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── History page ───────────────────────────────────────────────────────────── */
.select-label  { font-weight: 600; display: block; margin-bottom: .5rem; }
.item-select   { width: 100%; max-width: 400px; padding: .45rem .75rem; border: 1px solid var(--border); border-radius: .375rem; background: var(--bg); color: var(--text); font-size: .9rem; }
.chart-wrap    { position: relative; height: 320px; margin-bottom: 1rem; }
.stats-row     { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-card     { flex: 1; min-width: 160px; border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.stat-store    { font-weight: 700; margin-bottom: .4rem; }
.stat-row      { display: flex; justify-content: space-between; font-size: .875rem; padding: .15rem 0; }
.green { color: var(--primary); }
.red   { color: var(--danger); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .header-inner { gap: .5rem; }
    thead th:nth-child(5) { display: none; }
    tbody td:nth-child(5) { display: none; }
}
