:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-card: rgba(26, 36, 61, 0.85);
  --bg-glass: rgba(11, 15, 25, 0.82);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --accent-primary: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;
  --tabbar-height: 68px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --safe-top: env(safe-area-inset-top, 0px);
  --drawer-peek: 180px;  /* how much of bottom drawer peeks */
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; }
input, textarea, select { user-select: text; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  position: relative;
  z-index: 60;
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}
.brand-wrapper { display: flex; align-items: center; gap: 8px; }
.brand-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(59,130,246,.35);
}
.brand-title {
  font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(135deg,#fff 40%,#94a3b8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 20px; font-size: .72rem; font-weight: 600;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border-glass);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #64748b; }
.status-dot.active { background: #10b981; box-shadow: 0 0 8px #10b981; animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%{transform:scale(.95);opacity:.8} 50%{transform:scale(1.2);opacity:1} 100%{transform:scale(.95);opacity:.8} }
.icon-btn {
  background: rgba(255,255,255,.06); border: 1px solid var(--border-glass);
  color: var(--text-main); width: 34px; height: 34px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s ease;
}
.icon-btn:active { transform: scale(.92); }

/* Tab Layout */
.tab-content {
  display: none;
  flex: 1;
  position: relative;
  overflow: hidden;
}
.tab-content.active { display: flex; flex-direction: column; }

/* Map tab: leaflet takes up full remaining height minus tab bar */
#tab-map {
  position: relative;
}
#leaflet-map {
  width: 100%;
  flex: 1;
  z-index: 1;
}

/* FAB Quick Add */
.fab-quick-add {
  position: absolute;
  right: 16px;
  bottom: calc(var(--drawer-peek) + 16px);
  z-index: 20;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(16,185,129,.45);
  transition: all .2s ease;
}
.fab-quick-add:active { transform: scale(.93); }

/* Map Bottom Drawer */
.map-bottom-drawer {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  z-index: 15;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-glass);
  border-radius: 20px 20px 0 0;
  height: var(--drawer-peek);
  transition: height .35s cubic-bezier(.16,1,.3,1);
  overflow: hidden;
}
.map-bottom-drawer.expanded { height: 65%; }
.drawer-handle {
  width: 38px; height: 5px;
  background: rgba(255,255,255,.2);
  border-radius: 10px;
  margin: 10px auto 6px auto;
  cursor: pointer;
}
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 16px 8px 16px;
  flex-shrink: 0;
}
.nearby-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0 14px 16px 14px;
  height: calc(100% - 60px);
}

/* Legend */
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-dot.blue { background: #3b82f6; }
.legend-dot.green { background: #10b981; }
.legend-label { font-size: .72rem; color: var(--text-muted); }

/* Nearby card (drawer) */
.nearby-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .2s;
}
.nearby-card:active { background: rgba(255,255,255,.09); }
.nearby-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.nearby-name {
  font-size: .88rem; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.nearby-meta { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

/* Non-map tabs scroll */
#tab-radar, #tab-locations, #tab-settings {
  overflow-y: auto;
  padding: 14px;
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 20px);
}

/* Switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top:0;left:0;right:0;bottom:0; background: #334155; transition: .3s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
input:checked + .slider { background: #10b981; }
input:checked + .slider:before { transform: translateX(20px); }

/* Section headers */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; margin-top: 6px; }
.section-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.section-badge { font-size: .75rem; padding: 2px 8px; border-radius: 12px; background: rgba(255,255,255,.07); color: var(--text-muted); }

/* Radar status */
.radar-status-bar { background: var(--bg-card); border: 1px solid var(--border-glass); border-radius: 14px; padding: 12px 16px; margin-bottom: 14px; }
.radar-info-title { font-size: .75rem; color: var(--text-muted); }
.radar-info-value { font-size: .95rem; font-weight: 600; margin-top: 2px; }

/* Match cards */
.match-card {
  background: var(--bg-card); border: 1px solid var(--border-glass);
  border-radius: 16px; padding: 14px; margin-bottom: 12px;
  transition: transform .2s;
}
.match-card.manual { border-left: 4px solid #3b82f6; }
.match-card.sezgisel { border-left: 4px solid #10b981; }
.match-card.unverified { border-left: 4px solid #f59e0b; }
.match-card:active { transform: scale(.985); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card-location-name { font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.3; }
.card-status-badge { font-size: .7rem; font-weight: 700; padding: 3px 7px; border-radius: 7px; white-space: nowrap; }
.badge-verified { background: rgba(16,185,129,.15); color: #34d399; }
.badge-unverified { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-sezgisel { background: rgba(16,185,129,.15); color: #34d399; }
.card-subinfo { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; font-size: .78rem; color: var(--text-muted); }
.subinfo-tag { background: rgba(255,255,255,.05); padding: 2px 7px; border-radius: 5px; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: rgba(0,0,0,.2); border-radius: 10px; padding: 8px; margin-bottom: 10px; }
.metric-item { display: flex; flex-direction: column; align-items: center; text-align: center; }
.metric-label { font-size: .68rem; color: var(--text-sub); margin-bottom: 1px; }
.metric-val { font-size: .88rem; font-weight: 700; }
.nav-action-btn {
  width: 100%; background: var(--accent-gradient); color: #fff; border: none;
  border-radius: 10px; padding: 10px 12px; font-size: .84rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; transition: all .2s;
}
.nav-action-btn:active { transform: scale(.97); }

/* Locations list tab */
.search-wrapper { position: relative; margin-bottom: 12px; }
.search-input {
  width: 100%; background: var(--bg-card); border: 1px solid var(--border-glass);
  border-radius: 12px; padding: 11px 12px 11px 36px; color: var(--text-main);
  font-size: .9rem; outline: none;
}
.search-input:focus { border-color: var(--border-focus); }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-sub); }
.filter-pills { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filter-pills::-webkit-scrollbar { display: none; }
.pill-btn { padding: 5px 13px; border-radius: 20px; font-size: .78rem; font-weight: 600; background: rgba(255,255,255,.05); border: 1px solid var(--border-glass); color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.pill-btn.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }

/* Settings */
.settings-group { background: var(--bg-card); border: 1px solid var(--border-glass); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.settings-group-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: .88rem; font-weight: 500; }
.settings-desc { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }
.btn-secondary {
  background: rgba(255,255,255,.08); border: 1px solid var(--border-glass);
  color: var(--text-main); padding: 7px 12px; border-radius: 9px;
  font-size: .8rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-secondary:active { background: rgba(255,255,255,.15); }
.btn-primary {
  background: var(--accent-gradient); border: none; color: #fff;
  padding: 9px 16px; border-radius: 11px; font-size: .85rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:active { transform: scale(.96); }

/* Tab Bar */
.tab-bar {
  position: relative;
  z-index: 50;
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-top: 1px solid var(--border-glass);
  display: flex; align-items: center; justify-content: space-around;
  flex-shrink: 0;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-muted); font-size: .69rem; font-weight: 600; cursor: pointer;
}
.tab-item.active { color: #3b82f6; }
.tab-icon { font-size: 1.3rem; transition: transform .2s; }
.tab-item.active .tab-icon { transform: translateY(-2px); }

/* Modal / Bottom Sheet */
.modal-overlay {
  position: fixed; top:0;left:0;right:0;bottom:0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  z-index: 100; display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; animation: fadeIn .2s ease; }
.bottom-sheet {
  background: #141c30; border-top: 1px solid var(--border-glass);
  border-radius: 22px 22px 0 0; width: 100%; max-width: 600px;
  max-height: 88vh; overflow-y: auto;
  padding: 14px 18px calc(20px + var(--safe-bottom)) 18px;
  animation: slideUp .3s cubic-bezier(.16,1,.3,1);
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.sheet-handle { width: 38px; height: 5px; background: rgba(255,255,255,.2); border-radius: 10px; margin: 0 auto 14px auto; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-title { font-size: 1.1rem; font-weight: 700; }

/* Form */
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.form-control {
  width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--border-glass);
  border-radius: 10px; padding: 9px 11px; color: var(--text-main); font-size: .88rem; outline: none;
}
.form-control:focus { border-color: var(--border-focus); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper-wrapper {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.05); border: 1px solid var(--border-glass);
  border-radius: 10px; padding: 5px 10px;
}
.stepper-btn { width: 30px; height: 30px; border-radius: 7px; background: rgba(255,255,255,.1); border: none; color: white; font-size: 1.05rem; font-weight: 700; cursor: pointer; }
.stepper-val { font-size: 1rem; font-weight: 700; }
input[type="range"] { width: 100%; accent-color: #3b82f6; margin-top: 6px; }

/* Toast */
.toast-container { position: fixed; top: calc(var(--header-height) + var(--safe-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 200; width: 90%; max-width: 400px; pointer-events: none; }
.toast {
  background: rgba(15,23,42,.95); border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(16px); color: #fff; padding: 11px 14px;
  border-radius: 13px; font-size: .85rem; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); margin-bottom: 6px;
  animation: toastIn .3s ease; pointer-events: auto;
}
@keyframes toastIn { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
.empty-state { text-align: center; padding: 20px 12px; color: var(--text-muted); font-size: .88rem; }

/* Fullscreen iOS PIN Auth Screen */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(11, 15, 25, 0.96);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.auth-box {
  width: 100%;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
  margin-bottom: 16px;
}
.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.pin-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.2s ease;
}
.pin-dot.filled {
  background: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.8);
  transform: scale(1.15);
}
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 280px;
}
.numpad-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: #fff;
  font-size: 1.7rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  cursor: pointer;
  transition: all 0.15s ease;
}
.numpad-btn:active {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(0.92);
}
.numpad-empty {
  background: transparent;
  border: none;
  pointer-events: none;
}
.numpad-action {
  font-size: 1.3rem;
  background: transparent;
  border: none;
}
.auth-error {
  color: #f43f5e;
  font-size: 0.82rem;
  margin-top: 16px;
  min-height: 20px;
  font-weight: 600;
}
.shake {
  animation: shakeKeypad 0.4s ease;
}
@keyframes shakeKeypad {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-12px); }
  40%, 80% { transform: translateX(12px); }
}
