:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e7ee;
  --text: #182230;
  --muted: #69727f;
  --brand: #0a4d8c;
  --brand-dark: #073961;
  --accent: #e01a2b;
  --in-stock: #1a7f43;
  --low-stock: #b4690e;
  --out-stock: #b42318;
  --unknown: #69727f;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.12);
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--brand); }

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.site-header { background: var(--brand); color: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; gap: 1rem; }
.brand { color: #fff; font-size: 1.35rem; font-weight: 800; text-decoration: none; letter-spacing: -.01em; }
.brand-mark { font-size: 1.2rem; }
.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav a { color: #dce8f4; text-decoration: none; font-size: .95rem; }
.nav a:hover { color: #fff; }
.nav-email { color: #aac6e2; font-size: .85rem; }
.btn-outline { border: 1px solid #ffffff66; padding: .35rem .8rem; border-radius: 8px; }
.btn-outline:hover { background: #ffffff1a; }
.inline-form { display: inline; margin: 0; }
.linklike { background: none; border: none; color: #dce8f4; cursor: pointer; font-size: .95rem; padding: 0; }
.linklike:hover { color: #fff; text-decoration: underline; }
.linklike.danger { color: var(--out-stock); }

main.container { padding-top: 1.5rem; padding-bottom: 2.5rem; }
h1 { font-size: 1.7rem; margin: 0 0 1rem; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 .9rem; }
.muted { color: var(--muted); }

/* Flash messages */
.flash { margin: 1rem 0 0; padding: .7rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.flash-success { background: #e7f6ec; border-color: #b6e3c4; color: #11633a; }
.flash-error { background: #fdecea; border-color: #f5c2bd; color: var(--out-stock); }
.flash-info { background: #eef4fb; border-color: #cfe0f1; color: var(--brand-dark); }

/* Hero */
.hero { text-align: center; padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: 2.1rem; margin-bottom: .5rem; }
.hero-sub { color: var(--muted); max-width: 640px; margin: 0 auto; font-size: 1.05rem; }

/* Search panel */
.search-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-top: 1rem; }
.search-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; flex: 1 1 200px; }
.field-grow { flex: 2 1 320px; }
.field label { font-size: .8rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.field input { padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 9px; font-size: 1rem; background: #fff; }
.field input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.selected-warehouse { display: flex; flex-direction: column; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: #eef4fb; font-size: .95rem; }
.selected-warehouse span { color: var(--muted); font-size: .8rem; }
.change-link { font-size: .78rem; margin-top: .15rem; }

.btn { padding: .7rem 1.4rem; background: var(--brand); color: #fff; border: none; border-radius: 9px; font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--brand-dark); }
.alert { margin: 1rem 0 0; padding: .7rem .9rem; background: #fdecea; border: 1px solid #f5c2bd; color: var(--out-stock); border-radius: 8px; }

/* Warehouse picker */
.warehouse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; }
.warehouse-card { display: flex; flex-direction: column; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.warehouse-card:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.warehouse-card span { color: var(--muted); font-size: .85rem; }
.warehouse-card .distance { color: var(--brand); font-weight: 600; font-size: .8rem; margin-top: .2rem; }

/* Results / cards */
.results-meta { color: var(--muted); font-size: .95rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-top: .5rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .5rem; }
.card:hover { box-shadow: var(--shadow-lg); }
.card-top { display: flex; gap: .4rem; flex-wrap: wrap; }
.card-title { font-size: 1rem; margin: 0; line-height: 1.35; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--brand); }
.card-prices { display: flex; align-items: baseline; gap: .5rem; }
.price { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.price-was { color: var(--muted); text-decoration: line-through; font-size: .9rem; }
.target { color: var(--muted); font-size: .85rem; }
.promo { color: var(--accent); font-weight: 700; font-size: .9rem; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); gap: .5rem; }
.item-number { color: var(--muted); font-size: .78rem; }
.btn-alert { background: #fff4e5; color: #a85b00; border: 1px solid #f4d6a8; padding: .4rem .7rem; border-radius: 8px; font-size: .85rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn-alert:hover { background: #ffe9cc; }

.badge { display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 700; color: #fff; white-space: nowrap; }
.avail-in_stock { background: var(--in-stock); }
.avail-low_stock { background: var(--low-stock); }
.avail-out_of_stock { background: var(--out-stock); }
.avail-unknown { background: var(--unknown); }
.badge-deal { background: var(--accent); }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .76rem; background: #eef4fb; color: var(--brand-dark); border: 1px solid #cfe0f1; }
.watch-flags { margin: .1rem 0 0; display: flex; gap: .35rem; flex-wrap: wrap; }

.results-note, .empty-state p { color: var(--muted); font-size: .9rem; margin-top: 1rem; }
.empty-state { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center; box-shadow: var(--shadow); }
.empty-state h2 { margin-top: 0; }
.empty-state .btn { margin-top: .8rem; }

/* Stories */
.story-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.story { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.story-icon { font-size: 1.6rem; }
.story h3 { margin: .5rem 0 .3rem; font-size: 1.05rem; }
.story p { margin: 0; color: var(--muted); font-size: .92rem; }

/* Auth + watch forms */
.auth-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); max-width: 520px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: .5rem; font-size: .9rem; text-decoration: none; }
.stack-form { display: flex; flex-direction: column; gap: .55rem; margin-top: 1rem; }
.stack-form label { font-size: .85rem; font-weight: 600; }
.stack-form input[type=email], .stack-form input[type=text] { padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 9px; font-size: 1rem; }
.stack-form .check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.stack-form .btn { margin-top: .5rem; }
.watch-item { background: #f7f9fc; border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; }
.watch-item .item-number { display: block; margin-top: .15rem; }
.watch-current { margin-top: .5rem; display: flex; align-items: center; gap: .6rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 2rem; }
.site-footer p { color: var(--muted); font-size: .82rem; padding: 1rem 0; margin: 0; }

@media (max-width: 600px) {
  .search-form { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
  .hero h1 { font-size: 1.6rem; }
}
