:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --card: #1c2029;
  --card-2: #232834;
  --border: #2b313d;
  --text: #e7ebf2;
  --text-dim: #9aa4b2;
  --accent: #ff9900;       /* Amazon-ish orange */
  --accent-2: #ffb84d;
  --primary: #4f8cff;
  --up: #ff5c5c;           /* price went up = bad */
  --down: #37d67a;         /* price went down = good */
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --radius: 14px;
  font-synthesis: none;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa; --bg-soft: #eceff5; --card: #ffffff; --card-2: #f7f9fc;
    --border: #e2e7f0; --text: #10131a; --text-dim: #5b6472;
    --shadow: 0 8px 30px rgba(20,30,50,.08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(255,153,0,.10), transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

.view { max-width: 1080px; margin: 0 auto; padding: 20px; }
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ── Logo ─────────────────────────────────────────── */
.logo { font-size: 28px; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.logo span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.sm { font-size: 20px; }

/* ── Login ────────────────────────────────────────── */
.login-card { width: 100%; max-width: 400px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.tagline { color: var(--text-dim); margin: 10px 0 22px; }
form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--text-dim); }
input[type=text], input[type=password] {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,140,255,.2); }
.hint { display: block; color: var(--text-dim); font-size: 12px; margin-top: 6px; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; text-decoration: none;
  transition: transform .05s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; margin-top: 20px; padding: 13px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #1a1200; }
.btn-accent:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--card-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.error { color: var(--up); font-size: 13px; margin-top: 12px; }

/* ── Topbar ───────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 18px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.greeting { color: var(--text-dim); font-weight: 500; }
.digest-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.digest-toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.digest-toggle:hover { color: var(--text); }

/* per-item alert editor */
.alert-summary { font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; }
.alert-summary.set { color: var(--accent-2); }
.alert-summary.hit { color: var(--down); font-weight: 700; }
.alert-editor { grid-column: 1 / -1; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.alert-editor .fld { display: flex; flex-direction: column; gap: 4px; }
.alert-editor label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); font-weight: 600; margin: 0; }
.alert-editor input { width: 130px; padding: 8px 10px; font-size: 14px; background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.alert-editor .sep { color: var(--text-dim); font-size: 12px; padding-bottom: 9px; }
.alert-editor .grow { flex: 1; }

/* ── Banner ───────────────────────────────────────── */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, rgba(255,153,0,.14), rgba(255,153,0,.04));
  border: 1px solid rgba(255,153,0,.35); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px;
}
.banner span { color: var(--text-dim); }

/* ── Content ──────────────────────────────────────── */
.content-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 18px; }
.content-head h1 { font-size: 22px; margin: 0; }

.items { display: grid; gap: 14px; }
.item {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.item-img { width: 72px; height: 72px; border-radius: 10px; object-fit: contain; background: #fff; }
.item-main { min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; line-height: 1.35; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-title a { color: var(--text); text-decoration: none; }
.item-title a:hover { color: var(--accent-2); }
.prices { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.price-block { display: flex; flex-direction: column; }
.price-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.price-val { font-size: 18px; font-weight: 700; }
.price-added .price-val { color: var(--text-dim); font-weight: 600; font-size: 15px; }

.change { font-weight: 700; font-size: 15px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.change.down { color: var(--down); background: rgba(55,214,122,.12); }
.change.up { color: var(--up); background: rgba(255,92,92,.12); }
.change.flat { color: var(--text-dim); background: var(--card-2); }
.change.na { color: var(--text-dim); background: var(--card-2); font-weight: 500; }

.item-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.link-actions { display: flex; gap: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 48px; }
.empty h2 { color: var(--text); margin: 12px 0 6px; }
.empty p { max-width: 420px; margin: 0 auto; line-height: 1.5; }

.foot { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 28px; padding-bottom: 10px; }

/* ── Modal ────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
#modal-body { padding: 16px 20px 20px; max-height: 60vh; overflow: auto; }
.hist-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.hist-row:last-child { border-bottom: none; }
.hist-src { color: var(--text-dim); font-size: 12px; }

@media (max-width: 640px) {
  .item { grid-template-columns: 56px 1fr; }
  .item-img { width: 56px; height: 56px; }
  .item-actions { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
}
