:root {
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #ffffff;
  --green: #16a34a; --amber: #f59e0b; --red: #dc2626; --gray: #94a3b8; --blue: #2563eb;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); background: #f8fafc; }
button { font: inherit; cursor: pointer; }

.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 14px 10px; background: var(--ink); color: #fff;
}
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.brand h1 { margin: 0; font-size: 16px; }
.brand p { margin: 0; font-size: 12px; color: #cbd5e1; }
.icon-btn { background: #1e293b; color: #fff; border: 0; width: 38px; height: 38px; border-radius: 10px; font-size: 20px; }
.icon-btn.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search { position: fixed; z-index: 999; left: 10px; right: 10px; top: calc(62px + var(--safe-top)); }
.search input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); font-size: 15px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .1); background: #fff;
}
.chips {
  position: fixed; z-index: 999; left: 0; right: 0; top: calc(112px + var(--safe-top));
  display: flex; gap: 6px; overflow-x: auto; padding: 0 10px 6px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px;
  border-radius: 999px; font-size: 13px; box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

#map { position: fixed; inset: 0; z-index: 1; }

/* İşaretçiler */
.pin {
  min-width: 34px; height: 28px; padding: 0 6px; border-radius: 14px; color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.pin.green { background: var(--green); } .pin.amber { background: var(--amber); }
.pin.red { background: var(--red); } .pin.gray { background: var(--gray); }
.pin-wrap { background: none; border: 0; }
.report-pin { font-size: 22px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37,99,235,.25); }
.marker-cluster-custom {
  background: var(--ink); color: #fff; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  border: 3px solid rgba(255,255,255,.9); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.marker-cluster-custom small { display: block; font-size: 9px; font-weight: 500; opacity: .8; margin-top: -3px; }

.fabs { position: fixed; z-index: 1001; right: 12px; bottom: calc(var(--sheet-px, 40vh) + 14px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; align-items: flex-end; transition: bottom .25s; }
.fab { border: 0; background: #fff; color: var(--ink); height: 46px; min-width: 46px; border-radius: 23px; font-size: 20px; box-shadow: 0 3px 12px rgba(15,23,42,.22); padding: 0 14px; }
.fab-primary { background: var(--blue); color: #fff; font-size: 14px; font-weight: 700; }

/* Alt sayfa */
.sheet {
  position: fixed; z-index: 1002; left: 0; right: 0; bottom: 0; background: var(--bg);
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(15,23,42,.15);
  height: 40vh; max-height: 75vh; transition: height .25s; padding-bottom: var(--safe-bottom);
  display: flex; flex-direction: column;
}
.sheet.expanded { height: 62vh; }
.handle { width: 44px; height: 5px; border-radius: 3px; background: #cbd5e1; margin: 8px auto 4px; flex: none; cursor: grab; }
#sheetContent { overflow-y: auto; padding: 4px 16px 16px; flex: 1; }
.sheet h2 { font-size: 16px; margin: 4px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.sheet h2 small { font-size: 12px; color: var(--muted); font-weight: 400; }

.item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.badge { flex: none; width: 52px; text-align: center; border-radius: 10px; padding: 6px 0; color: #fff; font-weight: 800; font-size: 17px; line-height: 1.1; }
.badge small { display: block; font-size: 10px; font-weight: 500; opacity: .9; }
.badge.green { background: var(--green); } .badge.amber { background: var(--amber); } .badge.red { background: var(--red); } .badge.gray { background: var(--gray); }
.item-main { flex: 1; min-width: 0; }
.item-main b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-main span { font-size: 12px; color: var(--muted); }
.dist { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }

.detail .big { display: flex; align-items: baseline; gap: 6px; margin: 6px 0; }
.detail .big b { font-size: 34px; }
.bar { height: 10px; border-radius: 5px; background: #e2e8f0; overflow: hidden; margin: 6px 0 12px; }
.bar > i { display: block; height: 100%; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 10px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn { flex: 1; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 11px 12px; border-radius: 12px; font-weight: 600; text-align: center; text-decoration: none; font-size: 14px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-danger { background: #fff1f2; border-color: #fecdd3; color: var(--red); }
.muted { color: var(--muted); font-size: 13px; }
.back { border: 0; background: none; color: var(--blue); padding: 0; font-weight: 600; margin-bottom: 4px; }
.legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); margin: 2px 0 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.banner { background: #fef3c7; color: #92400e; border-radius: 10px; padding: 8px 10px; font-size: 12px; margin: 4px 0 8px; }

.toast {
  position: fixed; z-index: 3000; left: 50%; top: calc(160px + var(--safe-top)); transform: translateX(-50%) translateY(-10px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.dialog { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.dialog.hidden { display: none; }
.dialog-card { pointer-events: auto; width: 100%; max-width: 520px; background: #fff; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-bottom)); box-shadow: 0 -6px 24px rgba(15,23,42,.2); }
.dialog-card h2 { margin: 0 0 4px; font-size: 17px; }
.dialog-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; margin-top: 8px; }
body.reporting .sheet, body.reporting .fabs, body.reporting .chips, body.reporting .search { display: none; }

@media (min-width: 900px) {
  .sheet { left: 12px; right: auto; top: calc(160px + var(--safe-top)); bottom: 12px; width: 380px; height: auto !important; max-height: none; border-radius: 16px; }
  .handle { display: none; }
  .fabs { bottom: 24px; }
  .search { right: auto; width: 380px; left: 12px; }
  .chips { left: 400px; top: calc(66px + var(--safe-top)); }
  .dialog { align-items: center; } .dialog-card { border-radius: 16px; }
}
.leaflet-top { top: calc(58px + var(--safe-top)); }
