:root {
  --bg: #060606;
  --surface: rgba(24, 24, 27, 0.55);
  --surface-solid: #121214;
  --surface-hover: rgba(39, 39, 42, 0.7);
  --border: rgba(63, 63, 70, 0.6);
  --border-hover: #52525b;
  --fg: #f4f4f5;
  --fg-2: #d4d4d8;
  --fg-3: #a1a1aa;
  --fg-4: #71717a;
  --accent: #38bdf8;
  --buy: #34d399;
  --buy-bg: rgba(52, 211, 153, 0.12);
  --watch: #fbbf24;
  --watch-bg: rgba(251, 191, 36, 0.12);
  --norush: #818cf8;
  --norush-bg: rgba(129, 140, 248, 0.12);
  --danger: #fb7185;
  --radius: 16px;
  --radius-sm: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.05), transparent);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-glyph {
  font-size: 28px;
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.5));
}
.brand-text h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.brand-text p { font-size: 12px; color: var(--fg-4); letter-spacing: 0.04em; text-transform: uppercase; }
.topbar-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.as-of { font-size: 13px; color: var(--fg-3); }
.as-of strong { color: var(--fg-2); }
.disclaimer-pill {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-4);
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

/* ---------- Controls ---------- */
.controls { display: flex; flex-direction: column; gap: 16px; align-self: start; position: sticky; top: 92px; }
.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.control-card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-3); margin-bottom: 14px; }

.field { display: block; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--fg-2); font-weight: 500; margin-bottom: 8px;
}
.field-label em { font-style: normal; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.hint { display: block; font-size: 11px; color: var(--fg-4); margin-top: 6px; line-height: 1.4; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 999px;
  background: #3f3f46; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid #0a0a0a;
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid #0a0a0a;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 12px; padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--fg-3);
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.chip:hover { border-color: var(--border-hover); color: var(--fg-2); }
.chip.on { background: rgba(56, 189, 248, 0.14); border-color: var(--accent); color: var(--accent); }

.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent); background: var(--accent); color: #06121a;
  cursor: pointer; transition: all 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--fg-2); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--border-hover); color: var(--fg); }

/* ---------- Dashboard ---------- */
.dashboard { min-width: 0; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-4); margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--fg-3); margin-top: 4px; }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi.buy .kpi-value { color: var(--buy); }
.kpi.danger .kpi-value { color: var(--danger); }

/* budget bar */
.budget-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 24px;
}
.budget-bar-head, .budget-bar-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--fg-3);
}
.budget-bar-head { margin-bottom: 10px; }
.budget-bar-head span:last-child { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.budget-bar { height: 10px; border-radius: 999px; background: #27272a; overflow: hidden; }
.budget-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--watch), var(--danger));
  width: 0%; transition: width 0.35s ease;
}
.budget-bar-foot { margin-top: 10px; font-size: 12px; color: var(--fg-4); }

/* section head */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.section-head h2 { font-size: 17px; font-weight: 700; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-4); }
.sort select {
  font: inherit; font-size: 13px; color: var(--fg-2);
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px; cursor: pointer;
}

/* ---------- Item cards ---------- */
.item-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.item:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.item.verdict-buy { border-left: 3px solid var(--buy); }
.item.verdict-watch { border-left: 3px solid var(--watch); }
.item.verdict-norush { border-left: 3px solid var(--norush); }

.item-icon {
  font-size: 26px; width: 48px; height: 48px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.03); border-radius: 12px;
}
.item-main { min-width: 0; }
.item-name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.item-meta { font-size: 12px; color: var(--fg-4); display: flex; flex-wrap: wrap; gap: 6px 12px; }
.item-meta .origin::before { content: "📍 "; }
.item-meta .retailer::before { content: "🏬 "; }
.item-meta .rate::before { content: "📈 "; }
.item-note { font-size: 12px; color: var(--fg-3); margin-top: 8px; line-height: 1.45; }

.item-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 150px; }
.verdict {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}
.verdict-buy .verdict, .verdict.buy { color: var(--buy); background: var(--buy-bg); }
.verdict-watch .verdict, .verdict.watch { color: var(--watch); background: var(--watch-bg); }
.verdict-norush .verdict, .verdict.norush { color: var(--norush); background: var(--norush-bg); }

.price-now { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.price-proj { font-size: 12px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.price-proj .up { color: var(--danger); font-weight: 600; }
.countdown { font-size: 11px; color: var(--fg-4); }
.buy-link {
  font-size: 12px; font-weight: 600; color: var(--accent);
  text-decoration: none; margin-top: 2px;
}
.buy-link:hover { text-decoration: underline; }

.footnote { font-size: 11px; color: var(--fg-4); margin-top: 24px; line-height: 1.5; max-width: 70ch; }

.empty { text-align: center; color: var(--fg-4); padding: 48px 0; font-size: 14px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-solid); border: 1px solid var(--accent); color: var(--fg);
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 50;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .controls { position: static; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar { padding: 14px 16px; }
  .layout { padding: 16px 16px 48px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .item { grid-template-columns: auto 1fr; }
  .item-right { grid-column: 1 / -1; text-align: left; align-items: flex-start; flex-direction: row; flex-wrap: wrap; justify-content: space-between; min-width: 0; }
}
