:root {
  --bg: #eef3ef;
  --surface: #fff;
  --text: #102116;
  --muted: #5d6d60;
  --line: #e2ebe4;
  --brand: #178a3f;
  --brand-dark: #0f4d28;
  --brand-mid: #146c32;
  --brand-soft: #e7f6ec;
  --sale: #c2410c;
  --sale-badge: #ea580c;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(15, 40, 22, 0.12);
  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-display: "Plus Jakarta Sans", "Manrope", system-ui, sans-serif;
  --header-h: 58px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
body {
  display: flex; flex-direction: column; min-height: 100vh; height: 100vh;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(23, 138, 63, .18), transparent 50%),
    radial-gradient(900px 360px at 110% 0%, rgba(14, 77, 40, .12), transparent 45%),
    var(--bg);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 var(--header-h); height: var(--header-h);
  padding: 10px 18px;
  background: linear-gradient(90deg, #0c3b1f 0%, #146c32 55%, #1b8a44 100%);
  color: #fff;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(12, 50, 28, .28);
}
.brand { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand strong {
  display: block; font-family: var(--font-display);
  font-size: 16px; font-weight: 800; letter-spacing: -.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand span { font-size: 12px; opacity: .82; font-weight: 500; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-ghost, .btn-back, .btn-more, .seg-btn { border: 0; cursor: pointer; font: inherit; }
.btn-ghost {
  background: rgba(255,255,255,.14); color: #fff;
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  backdrop-filter: blur(6px);
}
.btn-ghost:hover { background: rgba(255,255,255,.24); }

.toast {
  position: fixed; top: calc(var(--header-h) + 10px); left: 16px; right: 16px;
  z-index: 40; margin: 0 auto; max-width: 520px;
  background: #111827; color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; box-shadow: var(--shadow);
}
.toast[hidden] { display: none !important; }

.layout {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.map-pane {
  position: relative; flex: 1 1 auto; min-height: 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
#map {
  position: absolute; inset: 0;
  height: 100%; width: 100%;
  min-height: 220px;
}
.map-status {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  background: rgba(255,255,255,.94); padding: 6px 10px; border-radius: 999px;
  font-size: 12px; box-shadow: var(--shadow); font-weight: 600;
}
.catalog-pane {
  display: none;
  flex-direction: column;
  min-height: 0;
  padding: 0 14px;
}
body.store-open .catalog-pane {
  display: flex;
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.store-head { display: flex; gap: 10px; align-items: flex-start; padding: 14px 0 8px; }
.btn-back {
  width: 42px; height: 42px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line); font-size: 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.store-meta h1 {
  margin: 0; font-family: var(--font-display);
  font-size: 22px; font-weight: 800; letter-spacing: -.04em;
}
.store-meta p { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 500; }

.filters {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg), var(--bg) 88%, transparent);
  padding-bottom: 8px;
}
#q {
  width: 100%; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); font-size: 16px; background: #fff;
  box-shadow: 0 6px 18px rgba(16, 40, 22, .05);
}
.seg { display: flex; gap: 8px; margin: 10px 0; }
.seg-btn {
  flex: 1; padding: 9px 10px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.seg-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.kat-bar { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.kat-chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.kat-chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }

.list-status { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.card {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 12px; align-items: start;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
  box-shadow: 0 8px 22px rgba(16, 40, 22, .05);
}
.card.sale { border-color: #fed7aa; border-left: 4px solid var(--sale-badge); }
.thumb {
  position: relative; width: 92px; height: 92px;
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
  overflow: hidden; flex-shrink: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.badge-akcija {
  display: inline-block;
  background: var(--sale-badge); color: #fff; font-weight: 800;
  font-family: var(--font-display); font-size: 10px;
  border-radius: 999px; padding: 2px 7px;
  letter-spacing: .02em; margin-bottom: 5px;
}
.card h2 {
  margin: 0 0 4px; font-family: var(--font-display);
  font-size: 15px; font-weight: 700; line-height: 1.35; letter-spacing: -.02em;
}
.card .meta { font-size: 12px; color: var(--muted); font-weight: 500; }
.price {
  text-align: right; min-width: 108px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.badge-pct {
  display: inline-block;
  background: var(--sale-badge); color: #fff; font-weight: 800;
  font-family: var(--font-display); font-size: 12px;
  border-radius: 999px; padding: 3px 8px; margin-bottom: 4px;
  letter-spacing: -.02em;
}
.price .now {
  display: block; font-family: var(--font-display);
  font-size: 20px; font-weight: 800; color: var(--brand-dark);
  line-height: 1.15; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.card.sale .price .now { color: var(--sale); }
.price .old { color: var(--muted); text-decoration: line-through; font-size: 13px; }
.price .unit { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.period { margin-top: 6px; font-size: 12px; color: var(--sale); font-weight: 600; }
.btn-more {
  display: block; width: 100%; margin: 16px 0 8px; padding: 12px;
  border-radius: 14px; background: #fff; border: 1px solid var(--line); font-weight: 600;
}
.legal { padding: 10px 0 22px; font-size: 11px; color: var(--muted); }
.leaflet-container, .leaflet-popup-content { font-family: var(--font); }
.leaflet-tooltip.store-tip {
  background: #0c3b1f; color: #fff; border: 0;
  border-radius: 12px; padding: 8px 12px;
  box-shadow: var(--shadow); font-family: var(--font);
}
.leaflet-tooltip.store-tip::before { border-top-color: #0c3b1f; }
.store-tip strong {
  display: block; font-family: var(--font-display);
  font-size: 13px; font-weight: 800; letter-spacing: -.02em;
}
.store-tip span { display: block; font-size: 11px; opacity: .85; font-weight: 500; margin-top: 2px; }
.mp-cluster {
  background: #1b7a3a;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(12, 50, 28, .35);
}
.popup-btn {
  margin-top: 8px; width: 100%; background: var(--brand); color: #fff;
  border: 0; border-radius: 8px; padding: 8px; cursor: pointer; font-weight: 600;
}

body.store-open .map-pane {
  flex: 0 0 148px;
}
body.store-open.map-wide .map-pane {
  flex: 0 0 42vh;
}

@media (min-width: 960px) {
  .layout { flex-direction: row; }
  .map-pane { flex: 1 1 auto; width: 100%; height: auto !important; }
  body.store-open .map-pane {
    flex: 0 0 26%;
    width: 26%;
    height: auto !important;
  }
  body.store-open.map-wide .map-pane {
    flex: 0 0 40%;
    width: 40%;
  }
  body.store-open .catalog-pane {
    flex: 1 1 auto;
    width: auto;
    padding: 8px 20px 0;
  }
  .btn-back { display: none; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 8px; padding: 10px;
  }
  .thumb { width: 72px; height: 72px; }
  .price { min-width: 96px; }
  .price .now { font-size: 17px; }
  .filters { top: 0; }
  .brand strong { font-size: 18px; }
}
