:root {
  --bg: #f4f5f0;
  --surface: #ffffff;
  --surface-soft: #f7f9f7;
  --ink: #142e28;
  --muted: #526860;
  --line: #d4dfd9;
  --accent: #0f5c4d;
  --accent-hover: #0b473b;
  --accent-soft: #eaf4f1;
  --focus: #d97706;
  --shadow: 0 8px 28px rgba(20, 46, 40, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

main {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#map.dragging { cursor: grabbing; }

.lot {
  fill: transparent;
  cursor: pointer;
  pointer-events: all;
  transition: fill-opacity 0.15s ease, stroke 0.15s ease;
}
.avail:hover {
  fill: #0f5c4d;
  fill-opacity: 0.16;
}
.sold {
  fill: #aaaaaa;
  fill-opacity: 1;
}
.sold:hover {
  fill: #969696;
}
.lot:is(:hover, :focus-visible, .sel) {
  stroke: var(--accent);
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  outline: none;
}
.avail.sel, .avail:focus-visible {
  stroke: var(--focus);
  stroke-width: 3;
}

#hud {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  max-width: calc(100vw - 28px);
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.brand {
  display: flex;
  flex-direction: column;
}
.brand strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand span {
  font-size: 12.5px;
  color: var(--muted);
}
.legend {
  display: flex;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.chip i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.avail-chip i {
  background: #2f9e66;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}
.sold-chip i {
  background: #aaaaaa;
}

#tip {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 8px;
  background: #142e28;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}
#tip em {
  font-style: normal;
  opacity: 0.82;
  margin-left: 6px;
  font-weight: 400;
}

nav {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 2;
  padding: 5px;
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

button, select {
  font: inherit;
}
button {
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid transparent;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 550;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
button:hover:not(:disabled) {
  background: var(--accent-soft);
}
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Sold compact card */
#panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: min(380px, calc(100vw - 32px));
  max-height: min(82dvh, 680px);
  overflow: auto;
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-bar {
  display: flex;
  justify-content: flex-end;
}
#close {
  min-height: 40px;
  min-width: 40px;
  padding: 6px 12px;
  font-size: 20px;
  line-height: 1;
  border: 1px solid var(--line);
  background: var(--surface);
}

/* Full-screen detail view for available lots */
#panel.full {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--bg);
  overscroll-behavior: contain;
}
#panel.full .panel-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  justify-content: space-between;
  align-items: center;
  padding: 12px clamp(16px, 3vw, 48px);
  background: rgba(244, 245, 240, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#panel.full #close {
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
}
#panel.full #details {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 48px) 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr);
  gap: 22px;
  align-items: start;
}

header.lot-head {
  margin-bottom: 12px;
}
.full header.lot-head {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 2px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.is-avail {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.is-sold {
  background: #eceeed;
  color: #4b5552;
}
h2 {
  margin: 6px 0 2px;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.full h2 {
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.15;
  margin: 4px 0 0;
}
.meta-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.media, .facts {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2vw, 26px);
}
#panel:not(.full) .media {
  padding: 0;
  border: 0;
  margin-top: 10px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 14px;
}
h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.hint {
  font-size: 13px;
  color: var(--muted);
}

.plan-open {
  display: block;
  position: relative;
  width: 100%;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: zoom-in;
}
.plan-open:hover {
  background: #eff5f2;
  border-color: #b7cbc3;
}
img.plan {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}
.full img.plan {
  height: clamp(300px, 64dvh, 860px);
  object-fit: contain;
}
.plan-open span {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(20, 46, 40, 0.88);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
}
.placeholder {
  margin: 0;
  min-height: 180px;
  padding: 24px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

dl {
  margin: 14px 0 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 16px;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}
dd.list-price {
  color: var(--accent);
  font-size: 16.5px;
  font-weight: 700;
}

.quote-box {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.quote-box label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  border: 1px solid #b9c9c2;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
#quote {
  width: 100%;
  min-height: 48px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 650;
  border-radius: 10px;
}
#quote:hover:not(:disabled) {
  background: var(--accent-hover);
}
#quote:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
#result {
  display: block;
  margin-top: 14px;
  font-variant-numeric: tabular-nums;
}
#result:not(:empty) {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid #b7d8ce;
  color: var(--accent);
  font-size: 19px;
  font-weight: 750;
}

/* Floor-plan lightbox */
#viewer {
  padding: 0;
  border: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  background: #ebefec;
  color: var(--ink);
}
#viewer[open] {
  display: flex;
  flex-direction: column;
}
.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.tools strong {
  margin-right: auto;
  font-size: 15.5px;
}
.zoom-pct {
  font-size: 13.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: center;
}
.tools button {
  border-color: var(--line);
}
#dismiss {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}
#dismiss:hover {
  background: #22473e;
}
#canvas {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 16px;
  align-content: safe center;
  cursor: grab;
}
#canvas.dragging { cursor: grabbing; }
#enlarged {
  display: block;
  max-width: none;
  height: auto;
  margin: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

#error {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  background: #fff5f5;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px 16px;
}

@media (max-width: 820px) {
  #hud {
    top: 10px;
    left: 10px;
    right: 10px;
    max-width: none;
    padding: 8px 12px;
    justify-content: space-between;
  }
  .brand span {
    display: none;
  }
  #panel:not(.full) {
    inset: auto 0 0;
    width: 100%;
    max-height: 60dvh;
    border-radius: 16px 16px 0 0;
  }
  #panel.full #details {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 16px 32px;
    gap: 16px;
  }
  .full header.lot-head {
    grid-column: 1;
  }
  .full img.plan {
    height: auto;
    max-height: 54dvh;
  }
  #tip {
    display: none !important;
  }
}
