:root {
  --teal-50: #e1f5ee; --teal-100: #9fe1cb; --teal-200: #5dcaa5; --teal-400: #1d9e75;
  --teal-600: #0f6e56; --teal-800: #085041; --teal-900: #04342c;
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #eef1f0;
  --text: #16201d; --text-2: #55615d; --text-3: #8a9591;
  --border: rgba(10, 30, 25, .10); --border-strong: rgba(10, 30, 25, .18);
  --accent: var(--teal-600); --accent-text: var(--teal-600); --on-accent: #ffffff;
  --hero-bg: var(--teal-50); --hero-text: var(--teal-900); --hero-sub: var(--teal-600);
  --good: #1d9e75; --bad: #d94a3d; --warn-bg: #fdf1dc; --warn-text: #7a4a06;
  --info-bg: #e9eeec; --info-text: #45524e;
  --scale-0: #1d9e75; --scale-1: #6cc49a; --scale-2: #e6b43c; --scale-3: #ec8a3a; --scale-4: #d94a3d;
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412; --surface: #161e1b; --surface-2: #1e2825;
    --text: #e8efec; --text-2: #a9b6b1; --text-3: #75827d;
    --border: rgba(220, 240, 232, .09); --border-strong: rgba(220, 240, 232, .18);
    --accent: var(--teal-200); --accent-text: var(--teal-200); --on-accent: #04342c;
    --hero-bg: #0d3b31; --hero-text: #e1f5ee; --hero-sub: #9fe1cb;
    --good: #5dcaa5; --bad: #f08074; --warn-bg: #3a2c10; --warn-text: #f5cf87;
    --info-bg: #1e2825; --info-text: #a9b6b1;
    --scale-0: #5dcaa5; --scale-1: #8fd4b3; --scale-2: #e8c15c; --scale-3: #f0a060; --scale-4: #f08074;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; }

/* viršus */
.top { display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 6px 18px; }
.place { text-align: left; display: flex; flex-direction: column; min-width: 0; }
.place-sub { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.place-sub .ico { width: 14px; height: 14px; }
.place-title { font-size: 22px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  color: var(--accent-text); }
.icon-btn:active { background: var(--surface-2); }

.fuelbar { padding: 6px 16px 4px; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 10px; font-size: 15px; color: var(--text-2);
  transition: background .2s, color .2s; }
.seg button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.banner { margin: 8px 16px 0; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  display: flex; gap: 8px; align-items: flex-start; }
.banner .ico { width: 18px; height: 18px; margin-top: 1px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.info { background: var(--info-bg); color: var(--info-text); }

main { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
#view-map { overflow: hidden; padding-bottom: 0; }
#map { z-index: 0; position: absolute; inset: 0 0 calc(var(--nav-h) + env(safe-area-inset-bottom)) 0; background: var(--surface-2); }

.fresh { margin: 10px 18px 0; font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fresh .ico { width: 14px; height: 14px; }
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--text-3); font-size: 12px;
  transition: height .2s; }

/* pagrindinė kortelė */
.hero { margin: 10px 16px 14px; padding: 16px 18px; border-radius: 18px; background: var(--hero-bg);
  color: var(--hero-text); display: block; width: calc(100% - 32px); text-align: left; }
.hero-label { font-size: 12px; color: var(--hero-sub); font-weight: 500; }
.hero-price { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.hero-price b { font-size: 40px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.hero-price span { font-size: 15px; color: var(--hero-sub); }
.hero-name { font-size: 15px; font-weight: 500; margin-top: 2px; }
.hero-addr { font-size: 13px; color: var(--hero-sub); }
.hero-note { font-size: 13px; color: var(--hero-sub); margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.hero-note .ico { width: 16px; height: 16px; }

/* sąrašas */
.list { list-style: none; margin: 0; padding: 0 0 0 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 14px; width: 100%; text-align: left;
  border-top: 1px solid var(--border); background: var(--bg); }
.row:active { background: var(--surface-2); }
.bar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.row-name .star { width: 15px; height: 15px; color: #d99a1e; fill: #d99a1e; stroke: #d99a1e; }
.row-addr { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-price { text-align: right; flex: none; }
.row-price b { font-size: 18px; font-weight: 650; display: block; }
.row-price small { font-size: 12px; color: var(--text-3); }
.up { color: var(--bad) !important; }
.down { color: var(--good) !important; }
.empty { padding: 40px 28px; text-align: center; color: var(--text-2); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty button { margin-top: 14px; }
.foot { font-size: 12px; color: var(--text-3); padding: 14px 18px 4px; margin: 0; border-top: 1px solid var(--border); }

.skel { height: 64px; margin: 0 16px; border-top: 1px solid var(--border); position: relative; overflow: hidden; }
.skel::before, .skel::after { content: ""; position: absolute; border-radius: 6px; background: var(--surface-2); }
.skel::before { left: 14px; top: 14px; width: 45%; height: 14px; box-shadow: 0 22px 0 -2px var(--surface-2); }
.skel::after { right: 4px; top: 18px; width: 56px; height: 20px; }
@media (prefers-reduced-motion: no-preference) {
  .skel { animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .5; } }
}

.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px;
  border-radius: 12px; font-weight: 600; font-size: 15px; border: 1px solid var(--border-strong); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn .ico { width: 20px; height: 20px; }
.btn .star { fill: #d99a1e; stroke: #d99a1e; }

/* apatinė navigacija */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 500; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottom-in { display: flex; max-width: 640px; margin: 0 auto; height: var(--nav-h); }
.bottom button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--text-3); }
.bottom button[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
.bottom button[aria-current="page"] .ico { stroke-width: 2.2; }

/* lapas (degalinės informacija) */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 900; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 901; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px);
  max-width: 640px; margin: 0 auto; max-height: 88dvh; overflow-y: auto; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
}
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 12px; }
.sh-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sh-name { font-size: 20px; font-weight: 650; }
.sh-addr { font-size: 14px; color: var(--text-2); }
.sh-company { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.sh-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.sh-p { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.sh-p.cur { outline: 2px solid var(--accent); outline-offset: -2px; }
.sh-p small { font-size: 12px; color: var(--text-2); display: block; }
.sh-p b { font-size: 19px; font-weight: 650; }
.sh-p i { font-style: normal; font-size: 12px; display: block; color: var(--text-3); }
.sh-actions { display: flex; gap: 8px; }
.sh-actions .primary { flex: 1; }
.sh-hist { margin-top: 18px; }
.sh-hist h3 { font-size: 13px; font-weight: 500; color: var(--text-2); margin: 0 0 6px; }

/* paieška, nustatymai */
.overlay { position: fixed; inset: 0; z-index: 950; background: var(--bg); display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto; }
.ov-head { display: flex; align-items: center; gap: 6px; padding: calc(env(safe-area-inset-top) + 10px) 10px 10px; }
.ov-head h2 { font-size: 19px; margin: 0; font-weight: 600; }
.search-in { flex: 1; height: 46px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; padding: 0 14px; outline: none; }
.search-in:focus { border-color: var(--accent); }
.ov-body { flex: 1; overflow-y: auto; padding: 0 0 24px; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 18px;
  border-top: 1px solid var(--border); }
.opt:active { background: var(--surface-2); }
.opt .ico { color: var(--accent-text); }
.opt-main { flex: 1; min-width: 0; }
.opt-main small { display: block; color: var(--text-3); font-size: 13px; }
.opt-count { color: var(--text-3); font-size: 13px; }
.set-group { margin: 8px 16px 18px; }
.set-group h3 { font-size: 13px; font-weight: 500; color: var(--text-2); margin: 0 0 8px 2px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 9px 16px; border-radius: 20px; border: 1px solid var(--border-strong); font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  font-size: 14px; color: var(--text-2); }
.card p { margin: 0 0 6px; }
.card p:last-child { margin: 0; }
.card b { color: var(--text); font-weight: 600; }

/* istorija */
.h-wrap { padding: 12px 16px; }
.h-title { font-size: 17px; font-weight: 600; margin: 4px 2px 2px; }
.h-sub { font-size: 13px; color: var(--text-3); margin: 0 2px 12px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.tile small { font-size: 12px; color: var(--text-3); display: block; }
.tile b { font-size: 18px; font-weight: 650; }
.chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 10px 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gl { stroke: var(--border); stroke-width: 1; }
.chart .ax { fill: var(--text-3); font-size: 11px; }
.chart .l1 { stroke: var(--accent); stroke-width: 2.4; fill: none; }
.chart .l2 { stroke: var(--text-3); stroke-width: 1.6; fill: none; stroke-dasharray: 4 4; }
.chart .ar { fill: var(--accent); opacity: .10; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .tip { fill: var(--text); font-size: 12px; font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin: 8px 4px 0; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 0; border-top: 2.4px solid var(--accent);
  vertical-align: middle; margin-right: 6px; }
.legend span.lt::before { border-top: 1.6px dashed var(--text-3); }
.periods { display: flex; gap: 8px; margin: 12px 0 0; }

/* žemėlapis */
.leaflet-container { font: inherit; background: var(--surface-2); }
.pin { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 3px 8px 3px; text-align: center; line-height: 1.2; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18); transform: translate(-50%, -100%); position: absolute; left: 0; top: 0; }
.pin::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px; margin-left: -4px;
  background: inherit; border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong);
  transform: rotate(45deg); }
.pin b { display: block; font-size: 14px; font-weight: 650; }
.pin span { display: block; font-size: 11px; color: var(--text-2); max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.pin.best { background: var(--hero-bg); color: var(--hero-text); border-color: var(--good); }
.pin.best span { color: var(--hero-sub); }
.pin.worst b { color: var(--bad); }
.pin.approx { opacity: .8; border-style: dashed; }
.cl { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
  border: 3px solid var(--surface); box-shadow: 0 1px 5px rgba(0, 0, 0, .25); }
.cl b { font-size: 13px; font-weight: 700; }
.cl span { font-size: 10px; opacity: .9; }
.me { width: 18px; height: 18px; border-radius: 50%; background: #2f7de1; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(47, 125, 225, .2); }
.map-btn { position: absolute; right: 12px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 450;
  width: 48px; height: 48px; border-radius: 50%; background: var(--surface); color: var(--accent-text);
  display: grid; place-items: center; box-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, .75) !important; }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: brightness(.72) contrast(1.1) saturate(.7); }
  .leaflet-control-attribution { background: rgba(20, 28, 25, .75) !important; color: #a9b6b1; }
  .leaflet-control-attribution a { color: #9fe1cb; }
}
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 999;
  max-width: 90vw; }
