/* Łowca Cen – panel PWA. Ciemny „terminal okazji”, jasny wariant automatycznie. */
:root {
  --bg: #0f1115;
  --bg-2: #161921;
  --card: #1b1f29;
  --card-2: #222736;
  --line: #2b3142;
  --text: #eceef3;
  --muted: #8e96a8;
  --faint: #5d6579;
  --accent: #ffb020;       /* bursztyn – marka */
  --accent-ink: #1a1203;
  --hot: #ff4d4f;          /* anomalia */
  --hot-bg: rgba(255, 77, 79, .12);
  --good: #2fd38a;         /* obniżka */
  --good-bg: rgba(47, 211, 138, .12);
  --info: #6aa8ff;
  --info-bg: rgba(106, 168, 255, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --tabbar-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4ef; --bg-2: #efece4; --card: #ffffff; --card-2: #f7f5f0; --line: #e4e0d6;
    --text: #17181c; --muted: #646a78; --faint: #9aa0ac; --accent: #e89200; --accent-ink: #fff;
    --hot: #e5383b; --hot-bg: rgba(229, 56, 59, .09); --good: #0f9e62; --good-bg: rgba(15, 158, 98, .1);
    --info: #2f6fd6; --info-bg: rgba(47, 111, 214, .09); --shadow: 0 10px 30px rgba(30, 25, 10, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 800; }
.top-stats { margin-left: auto; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.top-stats::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.chip b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.chip.hot b { color: var(--hot); }

/* ------------------------------------------------------------------- tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 500;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--accent); }
.tabs .dot { position: absolute; top: 10px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--hot); box-shadow: 0 0 0 2px var(--bg-2); }

@media (min-width: 900px) {
  body { padding-bottom: 24px; }
  .tabs {
    position: sticky; top: 57px; bottom: auto; height: auto; padding: 0 16px;
    display: flex; gap: 4px; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); z-index: 19;
  }
  .tabs a { flex-direction: row; gap: 8px; padding: 12px 14px; font-size: 14px; border-bottom: 2px solid transparent; }
  .tabs a.active { border-bottom-color: var(--accent); }
  .tabs .dot { top: 12px; left: auto; right: 6px; }
}

/* ------------------------------------------------------------------- view */
.view { max-width: 980px; margin: 0 auto; padding: 16px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
h1 { font-size: 26px; line-height: 1.1; letter-spacing: -.03em; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.section { margin-top: 22px; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 14px; padding-inline: 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
}
.filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ------------------------------------------------------------ deal cards */
.deals { display: grid; gap: 10px; }
@media (min-width: 700px) { .deals { grid-template-columns: 1fr 1fr; } }
.deal {
  position: relative; display: grid; grid-template-columns: 76px 1fr; gap: 12px;
  padding: 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  cursor: pointer; transition: transform .12s ease, border-color .12s ease;
}
.deal:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.deal:active { transform: scale(.99); }
.deal.k-anomaly { border-color: color-mix(in srgb, var(--hot) 55%, var(--line)); background: linear-gradient(135deg, var(--hot-bg), var(--card) 55%); }
.deal.unseen::after { content: ""; position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.thumb { width: 76px; height: 76px; border-radius: 12px; background: var(--card-2) center/cover no-repeat; border: 1px solid var(--line); overflow: hidden; }
.thumb.ph { display: grid; place-items: center; color: var(--faint); font-size: 26px; }
.deal-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.deal-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.deal-meta .shop { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.deal-name { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.price { font-family: var(--mono); font-weight: 700; font-size: 19px; letter-spacing: -.03em; }
.was { font-family: var(--mono); color: var(--faint); text-decoration: line-through; font-size: 13px; }
.pct { font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 6px; background: var(--good-bg); color: var(--good); }
.k-anomaly .pct { background: var(--hot); color: #fff; }
.deal-msg { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: var(--card-2); color: var(--muted); flex: none;
}
.badge.anomaly { background: var(--hot); color: #fff; }
.badge.drop { background: var(--good-bg); color: var(--good); }
.badge.target { background: var(--accent); color: var(--accent-ink); }
.badge.back_in_stock { background: var(--info-bg); color: var(--info); }
.badge.promo { background: var(--card-2); color: var(--muted); }
.badge.watch { background: transparent; border: 1px solid var(--line); }

/* -------------------------------------------------------------- list rows */
.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line); cursor: pointer;
}
.row .thumb { width: 52px; height: 52px; border-radius: 10px; }
.row-main { min-width: 0; }
.row-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row-side .price { font-size: 16px; }
.delta-up { color: var(--hot); } .delta-down { color: var(--good); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--hot); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 38px; padding: 0; }
.eye { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card-2); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.eye.on { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field small { color: var(--faint); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-2); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; min-width: 0; }
details.adv { border-top: 1px dashed var(--line); padding-top: 10px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
details.adv[open] summary { margin-bottom: 12px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--good); }
.switch input:checked::after { transform: translateX(18px); }
.switch .lbl b { display: block; font-size: 14px; }
.switch .lbl small { color: var(--muted); font-size: 12px; }
.range-row { display: grid; grid-template-columns: 1fr 64px; gap: 12px; align-items: center; }
.range-row output { font-family: var(--mono); font-weight: 700; text-align: right; }
input[type=range] { accent-color: var(--accent); width: 100%; }

/* ------------------------------------------------------------------ shops */
.shop { display: grid; gap: 12px; }
.shop-head { display: flex; align-items: center; gap: 10px; }
.shop-head h3 { margin: 0; font-size: 16px; }
.shop-head a { color: var(--muted); font-size: 12px; text-decoration: none; }
.status { margin-left: auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .05em; }
.status.running { background: var(--good-bg); color: var(--good); }
.status.discovering, .status.new { background: var(--info-bg); color: var(--info); }
.status.blocked, .status.error { background: var(--hot-bg); color: var(--hot); }
.status.paused { background: var(--card-2); color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi { background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }
.kpi b { display: block; font-family: var(--mono); font-size: 17px; }
.kpi span { font-size: 11px; color: var(--muted); }
.progress { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }
.shop-note { font-size: 12px; color: var(--muted); }
.shop-err { font-size: 12px; color: var(--hot); background: var(--hot-bg); padding: 8px 10px; border-radius: 8px; }
.log { font-family: var(--mono); font-size: 11.5px; color: var(--muted); max-height: 220px; overflow: auto; background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }
.log div { padding: 2px 0; border-bottom: 1px solid var(--line); }
.log .warn { color: var(--accent); } .log .error { color: var(--hot); }

/* ------------------------------------------------------------------ sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; animation: fade .15s; }
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 640px; border-radius: 22px; animation: fade .15s; max-height: 88dvh; }
}
.grabber { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet-close { position: absolute; top: 14px; right: 12px; z-index: 2; }
.sheet > .pd-head, .sheet > h2 { padding-right: 46px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.pd-head { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: start; margin-top: 8px; }
.pd-head .thumb { width: 96px; height: 96px; }
.pd-head h2 { font-size: 18px; line-height: 1.25; margin: 4px 0 6px; }
.pd-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pd-price .price { font-size: 28px; }
.stats4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
@media (min-width: 520px) { .stats4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-family: var(--mono); font-size: 15px; }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px 6px; }
.chart svg { width: 100%; height: 190px; display: block; }
.chart .axis { fill: var(--faint); font: 10px var(--mono); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.chart .median { stroke: var(--muted); stroke-dasharray: 5 5; stroke-width: 1; }
.chart .dot { fill: var(--accent); }
.chart .oos { fill: var(--hot); opacity: .5; }

/* ------------------------------------------------------------------- misc */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 0 0 6px; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--info-bg); color: var(--text); font-size: 13px; }
.callout.warn { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.callout.bad { background: var(--hot-bg); }
.callout p { margin: 0; }
.muted { color: var(--muted); }
.more { display: flex; justify-content: center; margin-top: 14px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); animation: up .2s; max-width: calc(100% - 32px);
}
.skeleton { height: 100px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 0, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login img { margin: 0 auto 14px; }
code, kbd { font-family: var(--mono); font-size: 12.5px; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; }
ol.steps { padding-left: 20px; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
ol.steps li { margin: 4px 0; }
