/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg:        #120d0d;
  --bg-card:   #1c1416;
  --bg-input:  #241c1e;
  --surface:   #241c1e;
  --border:    #342526;
  --text:      #f5e8ea;
  --muted:     #9a7075;
  --accent:    #c8627c;
  --accent-dim:#8c3a52;
  --green:     #6ec890;
  --red:       #d06060;
  --yellow:    #d4a050;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
}

[data-theme="light"] {
  color-scheme: light;
  --bg:        #faf7f4;
  --bg-card:   #ffffff;
  --bg-input:  #f3ede8;
  --surface:   #f3ede8;
  --border:    #e8ddd6;
  --text:      #2d1f1a;
  --muted:     #9e7b6f;
  --accent:    #c4657a;
  --accent-dim:#9e3d56;
  --green:     #2d9e6d;
  --red:       #c4657a;
  --yellow:    #c9880a;
  --shadow:    0 4px 24px rgba(180,100,80,.12);
}

html { font-size: 15px; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.logo-icon { font-size: 1.3rem; color: var(--accent); }

.logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
}

.logo-img { height: 36px; width: 36px; object-fit: contain; display: block; }

.tagline {
  color: var(--muted);
  font-size: .9rem;
}

/* ── User info in header ──────────────────────────────────────────────────── */
.user-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.user-email { font-size: .8rem; color: var(--muted); }

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  padding: .3rem .75rem;
  border-radius: var(--radius-sm);
  transition: color .15s, border-color .15s;
}

.logout-btn:hover { color: var(--text); border-color: var(--muted); }

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
  flex-shrink: 0;
}

.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

/* ── Tab bar ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  padding: 0 2rem;
  gap: .25rem;
}

.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  padding: .75rem 1rem;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Feather icon sizing ──────────────────────────────────────────────────── */
svg.feather, .feather svg {
  display: inline-block;
  vertical-align: -0.125em;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.tab-icon { font-size: 1rem; line-height: 1; display: flex; align-items: center; }

.tab-badge {
  background: var(--red);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 99px;
  padding: .1rem .4rem;
  min-width: 1.2rem;
  text-align: center;
  line-height: 1.4;
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.tab-panel { display: flex; flex-direction: column; gap: 2rem; }

/* ── Add form ─────────────────────────────────────────────────────────────── */
.add-section { display: flex; flex-direction: column; gap: .5rem; }

#add-form { display: flex; gap: .75rem; }

#url-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  padding: .65rem 1rem;
  outline: none;
  transition: border-color .15s;
}

#url-input:focus { border-color: var(--accent); }
#url-input::placeholder { color: var(--muted); }

#add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  padding: .65rem 1.4rem;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .5rem;
}

#add-btn:hover { opacity: .9; }
#add-btn:active { transform: scale(.97); }
#add-btn:disabled { opacity: .5; cursor: not-allowed; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error { color: var(--red); font-size: .85rem; }

/* ── Controls: search + sort + filter ────────────────────────────────────── */
.controls-section { display: flex; flex-direction: column; gap: .6rem; }

.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.1rem;
  pointer-events: none;
  display: flex;
  align-items: center;
}

#search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  padding: .6rem 1rem .6rem 2.4rem;
  outline: none;
  transition: border-color .15s;
}

#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--muted); }

.control-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.control-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .85rem;
  padding: .4rem 1.85rem .4rem .7rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a7075'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
}

.control-select option {
  background: var(--bg-card);
  color: var(--text);
}

[data-theme="light"] .control-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239e7b6f'/%3E%3C/svg%3E");
}

.control-select:focus { border-color: var(--accent); }

/* ── Section titles ───────────────────────────────────────────────────────── */
.section-title {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .8rem;
}

/* ── Products section ─────────────────────────────────────────────────────── */
.products-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
}

.product-count {
  font-size: .8rem;
  color: var(--muted);
  background: var(--bg-input);
  border-radius: 99px;
  padding: .15rem .6rem;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
}

.empty-icon { opacity: .4; display: flex; align-items: center; justify-content: center; }
.empty-icon svg { width: 3rem; height: 3rem; }
.empty-title { color: var(--text); font-size: 1.1rem; font-weight: 700; }
.empty-hint { color: var(--muted); font-size: .9rem; max-width: 280px; line-height: 1.6; }
.empty-subhint { color: var(--muted); font-size: .85rem; }

/* ── Onboarding inline form ───────────────────────────────────────────────── */
.onboarding-form {
  display: flex;
  gap: .6rem;
  width: 100%;
  max-width: 420px;
  margin-top: .5rem;
}

.onboarding-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  padding: .6rem 1rem;
  outline: none;
  transition: border-color .15s;
}

.onboarding-input:focus { border-color: var(--accent); }
.onboarding-input::placeholder { color: var(--muted); }

.onboarding-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  padding: .6rem 1.2rem;
  transition: opacity .15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

.onboarding-btn:hover { opacity: .9; }
.onboarding-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Onboarding examples ──────────────────────────────────────────────────── */
.onboarding-examples {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .65rem;
  margin-top: .5rem;
}

.onboarding-divider {
  font-size: .78rem;
  color: var(--muted);
  letter-spacing: .03em;
}

.example-links {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.example-link {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  font-size: .82rem;
  padding: .35rem .85rem;
  transition: border-color .15s, background .15s;
}

.example-link:hover {
  border-color: var(--accent);
  background: rgba(200,98,124,.08);
}



/* ── Products grid ────────────────────────────────────────────────────────── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* ── Product card ─────────────────────────────────────────────────────────── */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .2s, transform .2s;
  cursor: pointer;
}

.product-card:hover { border-color: #4a3335; transform: translateY(-2px); }

.card-image-wrap {
  height: 160px;
  background: var(--bg-input);
  position: relative;
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 8px;
}

.card-image[src=""], .card-image:not([src]) { display: none; }

.card-image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: .3;
}
.card-image-placeholder svg { width: 3rem; height: 3rem; }

.card-image[src]:not([src=""]) + .card-image-placeholder { display: none; }

.card-body { padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-retailer {
  font-size: .7rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: rgba(200, 98, 124, .1);
  padding: .15rem .5rem;
  border-radius: 4px;
}

.card-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  padding: .2rem .3rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
  position: relative;
  z-index: 1;
}

.card-delete:hover { color: var(--red); background: rgba(208,96,96,.1); }

.card-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-buy-btn {
  display: inline-block;
  background: var(--accent-dim);
  color: #fff;
  text-decoration: none;
  font-size: .82rem;
  font-weight: 600;
  padding: .4rem .9rem;
  border-radius: var(--radius-sm);
  align-self: flex-start;
  transition: opacity .15s;
  position: relative;
  z-index: 1;
}

.card-buy-btn:hover { opacity: .85; }

/* ── Prices ───────────────────────────────────────────────────────────────── */
.card-prices {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: .25rem;
}

.price-now, .price-avg { display: flex; flex-direction: column; gap: .1rem; }

.price-now-row { display: flex; align-items: center; gap: .4rem; }

.price-avg { text-align: right; }

.price-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.price-now .price-value { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.price-avg .price-value { font-size: .9rem; color: var(--muted); }

.delta-badge { font-size: .8rem; font-weight: 700; padding: .2rem .5rem; border-radius: 6px; }
.delta-badge.down { background: rgba(110,200,144,.15); color: var(--green); }
.delta-badge.up   { background: rgba(208,96,96,.1);    color: var(--red);   }
.delta-badge.same { display: none; }

/* ── Card meta ────────────────────────────────────────────────────────────── */
.card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: .1rem; }

.card-scraped { font-size: .75rem; color: var(--muted); }

.card-scrape-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: .75rem;
  padding: .25rem .6rem;
  border-radius: 6px;
  transition: color .15s, border-color .15s;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.card-scrape-btn:hover { color: var(--text); border-color: var(--accent); }
.card-scrape-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Card alerts ──────────────────────────────────────────────────────────── */
.card-alerts { display: flex; flex-direction: column; gap: .35rem; }

.card-alert-pill {
  font-size: .75rem;
  padding: .25rem .6rem;
  border-radius: 6px;
  border: 1px solid;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.card-alert-pill.price_drop {
  color: var(--green);
  border-color: rgba(110,200,144,.3);
  background: rgba(110,200,144,.07);
}

.card-alert-pill.promotion {
  color: var(--yellow);
  border-color: rgba(212,160,80,.3);
  background: rgba(212,160,80,.07);
}

/* ── Price chart (card + drawer) ──────────────────────────────────────────── */
.price-chart-wrap {
  margin-top: .25rem;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
}

.chart-info {
  font-size: .72rem;
  color: var(--accent);
  min-height: 14px;
  margin-bottom: 4px;
  text-align: center;
  letter-spacing: .01em;
  transition: opacity .1s;
}

.price-chart { width: 100%; height: 80px; display: block; cursor: crosshair; }

/* ── Card loading & error ─────────────────────────────────────────────────── */
.product-card.loading { pointer-events: none; opacity: .6; }

/* ── Skeleton shimmer (initial product fetch) ─────────────────────────────── */
@keyframes skeleton-shine {
  0%   { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.card-skeleton { cursor: default; }
.product-card.card-skeleton:hover { transform: none; border-color: var(--border); }

/* Shimmer image area */
.card-skeleton .card-image-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-input) 0px, rgba(255,255,255,.07) 40px, var(--bg-input) 80px);
  background-size: 200px 100%;
  animation: skeleton-shine 1.4s linear infinite;
  z-index: 1;
}

/* Hide emoji placeholder under shimmer */
.card-skeleton .card-image-placeholder { opacity: 0; }

/* Shimmer text: name */
.card-skeleton .card-name {
  color: transparent;
  background: linear-gradient(90deg, var(--bg-input) 0px, rgba(255,255,255,.07) 40px, var(--bg-input) 80px);
  background-size: 200px 100%;
  animation: skeleton-shine 1.4s linear infinite;
  border-radius: 4px;
  -webkit-line-clamp: 1;
}

/* Shimmer text: prices */
.card-skeleton .price-now .price-value,
.card-skeleton .price-avg .price-value {
  color: transparent;
  background: linear-gradient(90deg, var(--bg-input) 0px, rgba(255,255,255,.07) 40px, var(--bg-input) 80px);
  background-size: 200px 100%;
  animation: skeleton-shine 1.4s linear infinite;
  border-radius: 4px;
}

/* Hide buy button and alerts */
.card-skeleton .card-buy-btn,
.card-skeleton .card-alerts { display: none; }

/* Shimmer chart area overlay */
.card-skeleton .price-chart-wrap {
  position: relative;
  overflow: hidden;
}
.card-skeleton .price-chart-wrap::before {
  content: "";
  position: absolute;
  inset: .75rem 0 0;
  background: linear-gradient(90deg, var(--bg-input) 0px, rgba(255,255,255,.07) 40px, var(--bg-input) 80px);
  background-size: 200px 100%;
  animation: skeleton-shine 1.4s linear infinite;
  border-radius: 6px;
  z-index: 1;
}

/* Scraped / scrape-btn styling during skeleton */
.card-skeleton .card-scraped { color: var(--muted); font-style: italic; }
.card-skeleton .card-scrape-btn { opacity: .4; }



.card-error {
  font-size: .75rem;
  color: var(--red);
  background: rgba(208,96,96,.08);
  border-radius: 6px;
  padding: .35rem .6rem;
}

/* ── Alerts feed (Alerts tab) ─────────────────────────────────────────────── */
.alerts-feed { display: flex; flex-direction: column; gap: .25rem; }

.alerts-date-header {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1.25rem 0 .5rem;
}

.alerts-date-header:first-child { padding-top: 0; }

.alert-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: .75rem;
}

.alert-card.price_drop { border-left: 3px solid var(--green); }
.alert-card.promotion  { border-left: 3px solid var(--yellow); }

.alert-type-badge {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-top: .1rem;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

.alert-card.price_drop .alert-type-badge { color: var(--green); }
.alert-card.promotion  .alert-type-badge { color: var(--yellow); }

.alert-body { min-width: 0; }
.alert-product-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-detail { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.alert-time { color: var(--muted); font-size: .78rem; white-space: nowrap; padding-top: .15rem; }

/* ── Detail drawer ────────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 100;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn { from { opacity: 0; } }

.detail-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 100vw);
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 101;
  overflow-y: auto;
  animation: slideIn .25s ease;
}

@keyframes slideIn { from { transform: translateX(100%); } }

.drawer-inner { display: flex; flex-direction: column; }

.drawer-close {
  position: absolute;
  top: 1rem; right: 1rem;
  z-index: 1;
  background: rgba(0,0,0,.4);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: .9rem;
  width: 2rem; height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.drawer-close:hover { background: rgba(208,96,96,.2); color: var(--red); }

.drawer-hero-wrap {
  width: 100%;
  height: 220px;
  background: var(--bg-input);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.drawer-hero { width: 100%; height: 100%; object-fit: contain; display: block; padding: 12px; }
.drawer-hero[src=""], .drawer-hero:not([src]) { display: none; }

.drawer-hero-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .2;
}
.drawer-hero-placeholder svg { width: 5rem; height: 5rem; }

.drawer-hero[src]:not([src=""]) + .drawer-hero-placeholder { display: none; }

.drawer-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.drawer-top-row { display: flex; align-items: center; justify-content: space-between; }

.drawer-retailer {
  font-size: .72rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(200,98,124,.1);
  padding: .2rem .6rem;
  border-radius: 4px;
}

.drawer-open-link { color: var(--muted); font-size: .82rem; text-decoration: none; transition: color .15s; }
.drawer-open-link:hover { color: var(--accent); }

.drawer-name { font-size: 1.15rem; font-weight: 700; line-height: 1.3; color: var(--text); }

.drawer-prices { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.drawer-price-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.drawer-was { font-size: .95rem; color: var(--muted); }
.drawer-avg { font-size: .95rem; color: var(--muted); }

.drawer-scraped { font-size: .78rem; color: var(--muted); }

.drawer-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.drawer-section-head { display: flex; align-items: center; justify-content: space-between; }

.drawer-section-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Range toggle buttons ─────────────────────────────────────────────────── */
.range-btns { display: flex; gap: .25rem; }

.range-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: 5px;
  transition: color .15s, border-color .15s, background .15s;
}

.range-btn:hover { color: var(--text); border-color: var(--accent); }
.range-btn.active { background: rgba(200,98,124,.15); border-color: var(--accent); color: var(--accent); }

/* ── Drawer chart ─────────────────────────────────────────────────────────── */
.drawer-chart-wrap { width: 100%; }
#drawer-chart { width: 100%; display: block; cursor: crosshair; }

/* ── Drawer alerts list ───────────────────────────────────────────────────── */
.drawer-alerts-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; }

.drawer-alert-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .6rem .75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: .82rem;
}

.drawer-alert-type { font-weight: 700; flex-shrink: 0; display: flex; align-items: center; }
.drawer-alert-type.drop  { color: var(--green); }
.drawer-alert-type.promo { color: var(--yellow); }
.drawer-alert-detail { flex: 1; color: var(--text); }
.drawer-alert-time { color: var(--muted); font-size: .75rem; white-space: nowrap; }

/* ── Drawer compare prices ────────────────────────────────────────────────── */
.drawer-compare-spinner { display: flex; align-items: center; color: var(--muted); }
.drawer-compare-subtitle { color: var(--muted); font-size: .78rem; margin: 0 0 .5rem; }

.drawer-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.drawer-compare-table td {
  padding: .45rem .5rem;
  border-bottom: 1px solid var(--border2, var(--border));
  vertical-align: middle;
}
.drawer-compare-table tr:last-child td { border-bottom: none; }
.drawer-compare-table tr.best td { background: rgba(200,98,124,.07); }

.compare-retailer { color: var(--text); flex: 1; }
.compare-price    { color: var(--text); font-weight: 600; white-space: nowrap; text-align: right; }
.compare-link     { text-align: right; white-space: nowrap; }
.compare-buy-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.compare-buy-link:hover { text-decoration: underline; }

.compare-best-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  margin-right: .35rem;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Drawer correction section ────────────────────────────────────────────── */

/* The section container reuses .drawer-section for the top border + spacing.
   When empty (before JS populates it) it renders with zero height. */
.drawer-correction-section:empty { padding-top: 0; border-top: none; }

.correction-trigger {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: .8rem;
  color: var(--muted);
  transition: color .15s;
  text-align: left;
}
.correction-trigger:hover,
.correction-trigger.active { color: var(--yellow); }

.correction-form {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-top: .75rem;
  background: rgba(212,160,80,.07);
  border: 1px solid rgba(212,160,80,.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.correction-label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.correction-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  padding: .45rem .65rem;
  transition: border-color .15s;
  width: 100%;
}
.correction-input:focus {
  outline: none;
  border-color: var(--yellow);
}

.correction-textarea {
  resize: vertical;
  min-height: 3.5rem;
}

.correction-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .15rem;
}

.correction-submit-btn {
  background: var(--yellow);
  border: none;
  border-radius: var(--radius-sm);
  color: #1a1008;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  padding: .45rem 1rem;
  transition: opacity .15s;
}
.correction-submit-btn:hover    { opacity: .88; }
.correction-submit-btn:disabled { opacity: .5; cursor: not-allowed; }

.correction-cancel {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .82rem;
  padding: 0;
  transition: color .15s;
}
.correction-cancel:hover { color: var(--text); }

.correction-feedback {
  font-size: .82rem;
  margin: 0;
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
}
.correction-feedback--ok  { color: var(--green);  background: rgba(110,200,144,.1); }
.correction-feedback--err { color: var(--red);    background: rgba(208,96,96,.1);  }

/* ── Drawer actions ───────────────────────────────────────────────────────── */
.drawer-actions { border-top: 1px solid var(--border); padding-top: 1rem; }

.drawer-refresh-btn {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  padding: .7rem;
  transition: border-color .15s, background .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}

.drawer-refresh-btn:hover { border-color: var(--accent); background: rgba(200,98,124,.08); }
.drawer-refresh-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Auth overlay ─────────────────────────────────────────────────────────── */
.auth-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: var(--shadow);
}

.auth-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: .25rem; }

.auth-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  padding: .65rem 1rem;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--muted); }

.auth-submit {
  background: var(--accent-dim);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  padding: .7rem;
  width: 100%;
  margin-top: .25rem;
  transition: opacity .15s;
}

.auth-submit:hover   { opacity: .9; }
.auth-submit:disabled { opacity: .5; cursor: not-allowed; }

.auth-toggle {
  background: none;
  border: none;
  color: var(--accent-dim);
  cursor: pointer;
  font-size: .85rem;
  text-align: center;
  padding: .25rem 0;
}

.auth-toggle:hover { text-decoration: underline; }

/* ── Unsupported sites log ────────────────────────────────────────────────── */
.misses-section { border-top: 1px solid var(--border); padding-top: 1.5rem; }

.misses-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  user-select: none;
}

.misses-summary::-webkit-details-marker { display: none; }

.misses-summary .section-title::before {
  content: "▶ ";
  font-size: .7em;
  opacity: .5;
}

details[open] .misses-summary .section-title::before { content: "▼ "; }

.misses-count {
  font-size: .75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: .1rem .5rem;
  border-radius: 99px;
}

.misses-hint { color: var(--muted); font-size: .8rem; margin: .75rem 0; }

.misses-table { width: 100%; border-collapse: collapse; font-size: .8rem; }

.misses-table th {
  text-align: left;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .05em;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
}

.misses-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: top;
}

.misses-table tr:hover td { background: var(--surface); }
.miss-domain { color: var(--text); font-weight: 600; white-space: nowrap; }
.miss-hits   { color: var(--red); font-weight: 700; text-align: center; }
.miss-date   { color: var(--muted); white-space: nowrap; }
.miss-error  { color: var(--muted); max-width: 280px; word-break: break-word; }
.miss-url a  { color: var(--accent); text-decoration: none; word-break: break-all; }
.miss-url a:hover { text-decoration: underline; }

/* ── Home dashboard ───────────────────────────────────────────────────────── */

.home-greeting {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem 0.25rem;
}
.home-greeting-icon { display: flex; align-items: center; color: var(--accent); }
.home-greeting-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.home-section { display: flex; flex-direction: column; gap: .75rem; }

.home-section-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .4rem;
}

.home-deals { display: flex; flex-direction: column; gap: .6rem; }

.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.deal-card:hover { border-color: rgba(200,98,124,.5); }

.deal-card-inner { display: flex; align-items: center; gap: 12px; }

.deal-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--surface);
  flex-shrink: 0;
}

.deal-thumb-placeholder {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  flex-shrink: 0;
}

.deal-body { flex: 1; min-width: 0; }

.deal-retailer {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.deal-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin: .2rem 0 .35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-price-row { display: flex; align-items: center; gap: .5rem; }

.deal-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.deal-was {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .2rem;
}

/* Recently Checked horizontal scroll */
.home-recent-scroll {
  display: flex;
  gap: .65rem;
  overflow-x: auto;
  padding-bottom: .35rem;
  scrollbar-width: none;          /* Firefox */
}
.home-recent-scroll::-webkit-scrollbar { display: none; }

.recent-card {
  flex-shrink: 0;
  width: 130px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: border-color .15s;
}
.recent-card:hover { border-color: rgba(200,98,124,.5); }

.recent-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--surface);
  margin-bottom: .5rem;
}

.recent-thumb-placeholder {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: .5rem;
}

.recent-name {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-bottom: .25rem;
}

.recent-price {
  font-size: .88rem;
  font-weight: 700;
  color: var(--accent);
}

.recent-time {
  font-size: .72rem;
  color: var(--muted);
  margin-top: .15rem;
}

/* Section header row (title + see-all link) */
.home-section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-see-all-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: .82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .15rem;
  padding: 0;
  flex-shrink: 0;
}
.home-see-all-btn:hover { text-decoration: underline; }
.home-see-all-btn svg { vertical-align: middle; }

.home-alerts-list { display: flex; flex-direction: column; gap: .5rem; }

.home-alert-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s;
}
.home-alert-row:hover { border-color: var(--muted); }

.home-alert-icon { display: flex; align-items: center; flex-shrink: 0; }
.home-alert-icon.drop  { color: var(--green); }
.home-alert-icon.promo { color: var(--yellow); }

.home-alert-body { flex: 1; min-width: 0; }

.home-alert-name   { color: var(--text); font-size: .9rem; font-weight: 600; }
.home-alert-detail { color: var(--muted); font-size: .8rem; margin-top: .1rem; }

.home-alert-time {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Settings tab ─────────────────────────────────────────────────────────── */

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-group-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }

.settings-row-label { display: flex; flex-direction: column; gap: .2rem; }

.settings-label { font-size: .9rem; color: var(--text); font-weight: 500; }
.settings-hint  { font-size: .78rem; color: var(--muted); }

.settings-action-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
  padding: .4rem .9rem;
  transition: border-color .15s;
  white-space: nowrap;
}
.settings-action-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Admin tab ────────────────────────────────────────────────────────────── */

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.corrections-loading {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--muted);
  font-size: .9rem;
  padding: 1rem 0;
}

.corrections-empty {
  color: var(--muted);
  font-size: .9rem;
  padding: 1.5rem 0;
}

.corrections-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.correction-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  transition: opacity .25s ease, transform .25s ease;
}

.correction-card--removing {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.correction-card-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.correction-product-name {
  font-weight: 600;
  font-size: .95rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.correction-retailer-badge {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .55rem;
  text-transform: capitalize;
  flex-shrink: 0;
}

.correction-proposed {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.correction-field {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .875rem;
}

.correction-field-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  min-width: 3.5rem;
  flex-shrink: 0;
}

.correction-field-value {
  color: var(--text);
  font-weight: 500;
}

.correction-notes {
  color: var(--muted);
  font-size: .85rem;
  border-left: 2px solid var(--border);
  padding-left: .75rem;
  margin: 0;
  font-style: italic;
}

.correction-card-actions {
  display: flex;
  gap: .5rem;
  margin-top: .15rem;
}

.correction-action-btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  padding: .4rem .9rem;
  transition: opacity .15s, filter .15s;
}

.correction-action-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.correction-action-btn--approve {
  background: var(--green);
  color: #0f1a12;
}
.correction-action-btn--approve:hover:not(:disabled) { filter: brightness(1.1); }

.correction-action-btn--reject {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--muted);
}
.correction-action-btn--reject:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.admin-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .875rem;
  font-weight: 500;
  padding: .65rem 1rem;
  box-shadow: var(--shadow);
  max-width: 320px;
  opacity: 0;
  transform: translateY(.5rem);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

.admin-toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.admin-toast--success { border-left: 3px solid var(--green); }
.admin-toast--error   { border-left: 3px solid var(--red); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: .75rem 1rem; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: .3rem; }
  .user-info { margin-left: 0; }
  .tab-bar { padding: 0 1rem; }
  main { padding: 1rem; }
  #add-form { flex-direction: column; }
  .onboarding-form { flex-direction: column; }
  .products-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-row { flex-direction: column; align-items: flex-start; gap: .5rem; }

  .detail-drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 92vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    animation: slideUp .25s ease;
  }

  @keyframes slideUp { from { transform: translateY(100%); } }
}

/* ── Auth card social login ─────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0 1rem;
  color: var(--muted);
  font-size: .8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.social-btn-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: .75rem;
}

/* Shared social button shell (used for Apple + fallback Google) */
.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .625rem;
  width: 100%;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity .15s, border-color .15s;
}

.social-btn:hover { opacity: .85; border-color: var(--muted); }

.google-btn {
  background: #fff;
  color: #3c4043;
}

.apple-btn {
  background: #000;
  color: #fff;
  border-color: #333;
  margin-bottom: .5rem;
}

.social-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  fill: currentColor;
}
