/* Market Takip - mobil web arayüzü */
:root {
  color-scheme: light;
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #f0f1ee;
  --text: #121513;
  --text-2: #4b524e;
  --muted: #666d69;   /* beyazda 5,3:1, en koyu açık zeminde (accent-weak) 4,6:1 (eski #7a817d 3,99:1) */
  --border: rgba(18, 21, 19, 0.10);
  --accent: #0e7a5a;
  --accent-ink: #ffffff;
  --accent-weak: #e3f2ec;
  --good: #006300;
  --good-weak: #e6f3e6;
  --warn-weak: #fff3d6;
  --warn-ink: #7a4b00;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  /* grafik (dataviz referans paleti) */
  --chart-surface: #fcfcfb;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --radius: 14px;
  --tabbar-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f0e;
    --surface: #171a19;
    --surface-2: #202423;
    --text: #eef0ee;
    --text-2: #c2c7c3;
    --muted: #8d948f;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #2fb487;
    --accent-ink: #06150f;
    --accent-weak: #12302a;
    --good: #2ec46a;
    --good-weak: #12301d;
    --warn-weak: #3a2c0b;
    --warn-ink: #f3c86a;
    --bad: #ff8a80;
    --shadow: none;
    --chart-surface: #1a1a19;
    --grid: #2c2c2a;
    --axis: #383835;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f0e; --surface: #171a19; --surface-2: #202423; --text: #eef0ee; --text-2: #c2c7c3;
  --muted: #8d948f; --border: rgba(255,255,255,.10); --accent: #2fb487; --accent-ink: #06150f;
  --accent-weak: #12302a; --good: #2ec46a; --good-weak: #12301d; --warn-weak: #3a2c0b;
  --warn-ink: #f3c86a; --bad: #ff8a80; --shadow: none; --chart-surface: #1a1a19; --grid: #2c2c2a;
  --axis: #383835; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --s6: #008300; --s7: #9085e9; --s8: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* üst bar */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 6px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 608px; margin: 0 auto; }
.brand { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.city {
  font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-weak);
  padding: 4px 10px; border-radius: 999px;
}
.updated { margin: 2px auto 0; max-width: 608px; font-size: 12px; color: var(--muted); min-height: 1em; }
.updated.stale { color: var(--warn-ink); background: var(--warn-weak); border-radius: 6px; padding: 2px 8px; width: fit-content; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 24px; }

/* arama */
.search {
  position: relative; margin: 6px 0 10px;
}
.search svg {
  position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
.search input {
  width: 100%; height: 48px; padding: 0 14px 0 44px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.count { font-size: 13px; color: var(--muted); }
.sort { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.sort select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 8px; font-size: 13px;
  min-height: 40px;
}

.section-title { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 18px 2px 8px; text-transform: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer; min-height: 44px;   /* parmakla dokunma: en az 44 px */
}
.chip:active { background: var(--surface-2); }
.chip small { color: var(--muted); margin-left: 4px; }

/* listeler & kartlar */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; text-align: left;
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
.card:active { transform: scale(.995); }
.card.static { cursor: default; box-shadow: none; }
.card.static:active { transform: none; }
.thumb {
  width: 64px; height: 64px; border-radius: 10px; background: var(--surface-2); overflow: hidden;
  display: grid; place-items: center; color: var(--muted); font-size: 11px;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.thumb .ph { width: 46%; height: 46%; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.card .title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.price-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; }
.price { font-size: 18px; font-weight: 750; letter-spacing: -.01em; }
.price-old { font-size: 13px; color: var(--muted); text-decoration: line-through; }
.where { font-size: 13px; color: var(--text-2); }
.range { font-size: 12px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge {
  font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2);
}
.badge.deal { background: var(--warn-weak); color: var(--warn-ink); }
.badge.disc { background: var(--good-weak); color: var(--good); }
.badge.up { background: var(--accent-weak); color: var(--accent); }
.badge.ref { background: transparent; border: 1px dashed var(--border); color: var(--muted); font-weight: 600; }
/* market rozeti (logo yerine): renkli nokta + ad; yazı her zaman metin renginde */
.mb {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 650; line-height: 1.35;
  color: var(--text); background: color-mix(in srgb, var(--mc, var(--muted)) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--mc, var(--muted)) 28%, transparent);
}
.mb::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mc, var(--muted)); flex: none; }
.mb .p { font-weight: 700; font-variant-numeric: tabular-nums; }
.mb sup { font-size: 9px; font-weight: 700; color: var(--muted); margin-left: -2px; }
.mb.ref { background: transparent; border-style: dashed; }
.mb.best { border: 1.5px solid var(--accent); }
.mb.more { --mc: transparent; color: var(--muted); }
.mb.more::before { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mb { background: color-mix(in srgb, var(--mc, var(--muted)) 22%, var(--surface)); }
  :root:not([data-theme="light"]) .mb.ref { background: transparent; }
}
:root[data-theme="dark"] .mb { background: color-mix(in srgb, var(--mc, var(--muted)) 22%, var(--surface)); }
:root[data-theme="dark"] .mb.ref { background: transparent; }
.mrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.prow .mb { font-size: 14px; padding: 4px 11px 4px 9px; }
.prow .mb::before { width: 10px; height: 10px; }
.prow .note { margin-top: 4px; }

.compare { font-size: 13px; margin-top: 8px; color: var(--text-2); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.compare-note { margin-top: 4px; font-size: 12px; color: var(--muted); }
/* "Daha ucuzu var": fiyatlar sıralı, en ucuz üstte */
.warn-line { margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--bad); }
.ladder { margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ladder .r { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; }
.ladder .r + .r { border-top: 1px solid var(--border); }
.ladder .r.best { background: var(--accent-weak); }
.ladder .v { font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.ladder small { font-size: 11.5px; color: var(--muted); margin-left: 6px; }
.ladder small.lead { margin: 0 6px 0 0; }
.save { margin-top: 8px; font-size: 13.5px; font-weight: 700; color: var(--good); }
.save span { font-weight: 600; opacity: .85; }
.save + .compare { margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.compare .worse { color: var(--bad); }

.more {
  display: block; margin: 14px auto 0; padding: 10px 18px; border-radius: 10px; cursor: pointer; min-height: 44px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; color: var(--accent);
}
.more:disabled { color: var(--muted); cursor: progress; }

/* boş / yükleniyor / hata */
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 14px; }
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }
.skel { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sh 1.2s infinite linear; border: 1px solid var(--border); }
@keyframes sh { to { background-position: -200% 0; } }

/* segment düğmeleri */
.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin: 6px 0 8px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; min-height: 44px;
  font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-sm button { padding: 6px; font-size: 13px; min-height: 40px; }
/* Etiketin tamamı dokunulabilir: yükseklik 44 px */
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin: 0 2px 6px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* alt menü */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; max-width: 214px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent); }

/* alttan açılan detay paneli */
.sheet {
  padding: 0; border: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  max-height: 92vh; max-height: 92dvh; background: transparent; color: var(--text);
}
@media (min-width: 680px) { .sheet { margin: auto; max-width: 640px; } .sheet-inner { border-radius: 18px !important; } }
.sheet::backdrop { background: rgba(0,0,0,.45); }
.sheet[open] .sheet-inner { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-inner {
  position: relative; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto;
  overscroll-behavior: contain;
}
.grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 8px; }
.close {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center;
}
.close svg { width: 18px; height: 18px; stroke: var(--text-2); stroke-width: 2.2; fill: none; stroke-linecap: round; }
.detail-head { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding-right: 48px; margin-top: 4px; }
.detail-head .thumb { width: 96px; height: 96px; }
.detail-head h2 { font-size: 18px; margin: 0; line-height: 1.25; }
.detail-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.h3 { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 20px 0 8px; }
.prices { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.prow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 11px 12px; border-top: 1px solid var(--border); }
.prow:first-child { border-top: 0; }
.prow.best { background: var(--accent-weak); }
.prow .m { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.prow .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.prow .note { font-size: 12px; color: var(--muted); font-weight: 500; }
.prow .v { text-align: right; font-variant-numeric: tabular-nums; }
.prow .v b { font-size: 16px; }
.prow .v small { display: block; font-size: 12px; color: var(--muted); }
.prow .diff { color: var(--muted); font-size: 12px; }
.fine { font-size: 12px; color: var(--muted); margin-top: 8px; }
/* grafik */
.chart { position: relative; background: var(--chart-surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 8px 4px; }
/* Yükseklik viewBox oranından: çizim her genişlikte eşit ölçeklenir (yazılar ezilmez) */
.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .gridl { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .pt { stroke: var(--chart-surface); stroke-width: 2; }
.chart .xhair { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 4px 2px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,.12); border-radius: 10px; padding: 8px 10px; font-size: 12px; min-width: 130px;
}
.tip .d { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; }
.tip .r i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.tip .r b { font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  max-width: 600px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 10px;
  padding: 10px 14px; font-size: 14px; z-index: 20;
}
