:root {
  --red: #c8102e;
  --red-soft: #fdecee;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e6e6ea;
  --bg: #ffffff;
  --bg-alt: #f6f6f8;
  --panel-w: 380px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--red); }

#map { height: 100%; min-height: 0; }

/* Panel */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.panel-head {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; }
.brand h1 { flex: 1; }
.brand .city {
  font: inherit; font-weight: 600; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
}
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--red); color: #fff; font-weight: 800; font-size: 20px;
}

.locate {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--red); background: var(--red); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
}
.locate:disabled { opacity: .7; cursor: progress; }
/* Konum alındıktan sonra daha sakin görünür */
.locate.active { background: var(--bg); color: var(--red); }

.controls { display: flex; gap: 8px; margin-top: 8px; }
.controls select {
  flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}

.status { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.status strong { color: var(--ink); font-weight: 600; }
.status .warn, .status.warn { color: #9a5b00; }

/* Liste */
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }

.item {
  padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.item:hover, .item.selected { background: var(--bg-alt); }
.item.near { background: var(--red-soft); }
.item.near.selected, .item.near:hover { background: #fadadf; }

.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-name { font-weight: 650; flex: 1; }
.item-dist { font-weight: 650; color: var(--red); white-space: nowrap; }
.item-district { color: var(--muted); font-size: 12.5px; }
.item-addr { margin: 4px 0 0; font-size: 13px; }
.item-note { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); font-style: italic; }
.item-approx { margin: 4px 0 0; font-size: 12px; color: #9a5b00; }

.actions { display: flex; gap: 6px; margin-top: 8px; }
.actions a {
  flex: 1; min-width: 0; text-align: center; text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 6px 8px; border-radius: 7px; border: 1px solid var(--red);
}
.actions a.primary { background: var(--red); color: #fff; }

.empty { padding: 24px 16px; color: var(--muted); text-align: center; }

.panel-foot {
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.panel-foot .disclaimer { display: block; margin-top: 4px; font-size: 11px; line-height: 1.35; }

/* Harita işaretleri */
.pin {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--red); border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .35);
}
.pin span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 13px; }
.pin.near { background: #0a7d32; }
.pin.approx { opacity: .75; border-style: dashed; }

.me {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(26 115 232 / .25);
}

.leaflet-popup-content { margin: 12px 14px; font: inherit; min-width: 220px; }
.leaflet-popup-content .item-name { display: block; font-size: 15px; }
.leaflet-popup-content .actions a { color: var(--red); white-space: nowrap; }
.leaflet-popup-content .actions a.primary { color: #fff; }

.leaflet-container .leaflet-control-attribution { font-size: 10px; opacity: .7; }

/* Mobil: harita üstte sabit kalır; başlık ve liste altında sayfayla birlikte kayar */
@media (max-width: 760px) {
  html, body { height: auto; }
  body { display: flex; flex-direction: column; }
  #map {
    order: -1; position: sticky; top: 0; z-index: 10; flex: none;
    height: 38vh; height: 38svh; border-bottom: 1px solid var(--line);
  }
  .panel { border-right: 0; }
  .panel-head { padding: 10px 16px 8px; }
  .brand-mark { width: 28px; height: 28px; font-size: 16px; }
  .brand h1 { font-size: 16px; }
  .locate { margin-top: 10px; }
  .list { overflow: visible; flex: none; }
  .item { padding: 10px 16px; scroll-margin-top: 40vh; }
  .item-addr { font-size: 12.5px; }
  .actions { margin-top: 6px; }
  .actions a { padding: 7px 8px; }
  .panel-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  /* Küçük haritada popup sade: ad, mesafe, iki buton. Ayrıntılar alttaki kartta. */
  .leaflet-popup-content { margin: 8px 12px; min-width: 0; font-size: 13px; }
  .leaflet-popup-content .item-name { font-size: 14px; padding-right: 12px; }
  .leaflet-popup-content .item-district { font-size: 12px; }
  .leaflet-popup-content .item-addr,
  .leaflet-popup-content .item-note,
  .leaflet-popup-content .item-approx,
  .leaflet-popup-content .phone-num { display: none; }
  .leaflet-popup-content .actions { margin-top: 6px; gap: 6px; }
  .leaflet-popup-content .actions a { padding: 5px 12px; font-size: 12.5px; }
}
