:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --border: #e3e2de;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --grid: #ebeae6;
  --good: #1a7f37;
  --bad: #cf222e;
  --bad-bg: #fdecec;
  --warn-bg: #fff6dd;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --border: #2e2e2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #3987e5;
    --series-1: #3987e5;
    --grid: #2a2a28;
    --good: #4ac26b;
    --bad: #ff7b72;
    --bad-bg: #3a1d1d;
    --warn-bg: #3a3118;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); margin: 2px 0 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.top button { white-space: nowrap; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin-bottom: 0; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

input, select, button {
  font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; background: var(--bg); }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 4px 0; }
button.danger { color: var(--bad); }
.narrow { width: 72px; }

.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form #add-url { flex: 1 1 320px; min-width: 0; }
.add-form #add-target { width: 130px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.radio { display: flex; align-items: center; gap: 8px; }

.banner { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; background: var(--warn-bg); }

.empty { color: var(--muted); padding: 8px 0; }
.product { border-top: 1px solid var(--border); padding: 14px 0; }
.product:first-child { border-top: none; padding-top: 0; }
.product-main { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: start; }
.product img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 6px; }
.title { font-weight: 550; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.meta .err { color: var(--bad); }
.price { text-align: right; white-space: nowrap; }
.price .now { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.price .range { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 0 70px; }
.controls select, .controls input, .controls button { padding: 4px 8px; font-size: 13px; }
.controls input { width: 110px; }
.controls .spacer { flex: 1; }
@media (max-width: 560px) {
  .product-main { grid-template-columns: 48px 1fr; }
  .product img { width: 48px; height: 48px; }
  .price { grid-column: 2; text-align: left; }
  .controls { margin-left: 0; }
}

.chart { margin: 12px 0 0 70px; position: relative; }
@media (max-width: 560px) { .chart { margin-left: 0; } }
.chart svg { display: block; width: 100%; height: 180px; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--surface);
  font-size: 12px; padding: 5px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%);
}
.chart details { margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.chart table { border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.chart td { padding: 2px 16px 2px 0; }

.recipients { list-style: none; margin: 0 0 10px; padding: 0; }
.recipients li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); }
.recipients li:last-child { border-bottom: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast.error { background: var(--bad); color: #fff; }

/* ---------- Login & account ---------- */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 4px; }
.login p { color: var(--text-2); margin: 0 0 16px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login input { font-size: 16px; padding: 10px 12px; }
.login input.code { letter-spacing: 8px; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.login button { padding: 10px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.danger-zone { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 32px; }
@media (max-width: 560px) { .who { display: none; } }
