:root {
  --navy: #14213D;
  --navy-2: #1C2E52;
  --indigo: #3D56A5;
  --sky: #1F96D4;
  --ink: #23262B;
  --gray: #4B494A;
  --muted: #6B6F76;
  --line: #E3E6EC;
  --bg: #F6F7FA;
  --occupied: #5B74C9;
  --vacant: #E9A23B;
  --available: #2FB07A;
  --vet: #D94B4B;
  --radius: 10px;
  --panel-w: 360px;
  --top-h: 68px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 1000;
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: var(--navy); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.brand img { display: block; height: 44px; width: auto; }
.title { border-left: 1px solid rgba(255,255,255,.18); padding-left: 18px; min-width: 0; }
.title h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.title p { margin: 2px 0 0; font-size: 12.5px; color: #B9C3D8; white-space: nowrap; }

.search { position: relative; margin-left: auto; width: min(460px, 42vw); }
.search input {
  width: 100%; height: 42px; padding: 0 14px 0 40px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-size: 15px; color: var(--ink); background: #fff; outline: none;
}
.search input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(31,150,212,.35); }
.search-icon { position: absolute; left: 14px; top: 11px; width: 20px; height: 20px; fill: var(--muted); pointer-events: none; }
.results {
  position: absolute; top: 48px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(20,33,61,.25);
  max-height: 60vh; overflow: auto;
}
.results li { padding: 9px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.results li[aria-selected="true"], .results li:hover { background: #EEF2FB; }
.results .r-name { font-weight: 500; }
.results .r-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.results .r-empty { color: var(--muted); cursor: default; }
.results .r-empty:hover { background: none; }
mark { background: #DCE6FF; color: inherit; border-radius: 2px; }

/* ---------- layout ---------- */
.layout { position: fixed; inset: var(--top-h) 0 0 0; }
#map { position: absolute; inset: 0 var(--panel-w) 0 0; background: #DDE2EA; }
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel-w);
  background: #fff; border-left: 1px solid var(--line); overflow-y: auto;
  display: flex; flex-direction: column;
}
.panel-handle { display: none; }

/* ---------- record card ---------- */
.card { padding: 18px 20px 20px; border-bottom: 1px solid var(--line); }
.card .photo { margin: -18px -20px 16px; background: #0E1730; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; position: relative; }
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.card .photo .nophoto { color: #8D97AD; font-size: 13px; }
.card .close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: rgba(14,23,48,.7); color: #fff; font-size: 20px; line-height: 32px; cursor: pointer; z-index: 2;
}
.card.nophoto-card { position: relative; }
.card.nophoto-card .close { background: #EEF0F4; color: var(--gray); }
.card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; line-height: 1.2; padding-right: 30px; }
.card .dates { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: #EEF0F4; color: var(--gray); }
.badge .dot { width: 9px; height: 9px; border-radius: 50%; }
.badge.vet { background: #FBEAEA; color: #A63232; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 500; }
.actions { display: flex; gap: 8px; }
.btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--indigo); background: var(--indigo); color: #fff; font: inherit; font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: #33498F; }
.btn.secondary { background: #fff; color: var(--indigo); }
.btn.secondary:hover { background: #EEF2FB; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

/* ---------- legend ---------- */
.legend { padding: 18px 20px; }
.legend h2 { margin: 0 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.chips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.chip {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left;
}
.chip .sw { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.chip .count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="false"] { opacity: .45; }
.chip[aria-pressed="false"] .sw { background: transparent !important; outline: 2px solid #C5CAD3; outline-offset: -2px; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; padding: 4px 2px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--vet); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: var(--bg); border-radius: 8px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 18px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }

.credit { margin-top: auto; padding: 14px 20px 18px; font-size: 12px; line-height: 1.5; color: var(--muted); border-top: 1px solid var(--line); }
.credit a { color: var(--indigo); font-weight: 500; }

/* ---------- map bits ---------- */
.leaflet-container { font-family: inherit; }
.section-label { background: rgba(20,33,61,.82); color: #fff; border: 0; border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 500; box-shadow: none; white-space: nowrap; }
.section-label::before { display: none; }
.leaflet-control-layers { border-radius: 8px !important; }
.leaflet-tooltip.lot-tip { font-size: 12.5px; padding: 4px 8px; }
.lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(5,10,22,.9); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 6px; }

.loading { position: fixed; inset: 0; z-index: 2000; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(246,247,250,.92); color: var(--gray); font-size: 15px; transition: opacity .3s; }
.loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #D5DBE7; border-top-color: var(--indigo); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  :root { --top-h: 112px; }
  .topbar { flex-wrap: wrap; height: var(--top-h); padding: 10px 12px; gap: 8px 12px; align-content: flex-start; }
  .brand img { height: 34px; }
  .title { padding-left: 12px; }
  .title h1 { font-size: 16px; }
  .search { width: 100%; margin-left: 0; }
  #map { inset: 0 0 0 0; }
  .panel {
    top: auto; left: 0; width: auto; max-height: 58vh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(20,33,61,.18); z-index: 900;
    transform: translateY(calc(100% - 64px)); transition: transform .25s ease;
  }
  .panel.open { transform: none; }
  .panel-handle { display: block; width: 40px; height: 5px; border-radius: 3px; background: #CDD2DB; margin: 8px auto 2px; flex: none; }
  .legend h2 { cursor: pointer; }
  .credit { display: none; }
}

.pin span { display: block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid #00E5FF; background: rgba(0,229,255,.18); box-shadow: 0 0 0 0 rgba(0,229,255,.6); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(0,229,255,.55); } 100% { box-shadow: 0 0 0 18px rgba(0,229,255,0); } }

@media (max-width: 820px) {
  .card .photo { aspect-ratio: auto; height: 170px; }
}
