:root {
  --navy: #0D1B2A;
  --gold: #C8913A;
  --ink: #18212C;
  --muted: #6B7280;
  --line: #E8E3DA;
  --soft: #F6F3EE;
  --card: #FFFFFF;
  --avail: #22C55E;
  --taken: #EC7B8C;
  --dim: #E7E3DB;
  --sel: #F59E0B;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(13, 27, 42, .14), 0 2px 6px rgba(13, 27, 42, .08);
}

* { box-sizing: border-box; }
/* the engine hides tabs a one-tower project does not need; author display rules must not win */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* tower labels pinned to the roofs */
.tl {
  position: absolute; left: 0; top: 0;
  pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--navy); color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  border: 0; will-change: transform;
}
.tl small { font-weight: 500; opacity: .75; }
.tl.future { background: rgba(255, 255, 255, .9); color: var(--navy); pointer-events: none; }
.tl.on { background: var(--gold); }
/* all projects of a group on one map: one label a project */
.tl.proj { background: var(--gold); font-size: 13px; padding: 7px 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(13, 27, 42, .12);
  font-size: 13px; font-weight: 500;
}

.topbar {
  position: absolute; top: 16px; left: 16px; right: 416px; display: flex; flex-wrap: wrap; gap: 8px; z-index: 2;
  pointer-events: none;   /* the bar spans the map; only its buttons take clicks */
}
.topbar > * { pointer-events: auto; }
.chip.back { color: var(--navy); text-decoration: none; font-weight: 600; }
.chip.back:hover { background: #fff; }
.mapctl { position: absolute; left: 16px; bottom: 28px; display: flex; gap: 8px; z-index: 2; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(13, 27, 42, .12);
}
.seg button {
  border: 0; background: transparent; height: 30px; padding: 0 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.seg button[aria-selected="true"] { background: var(--navy); color: #fff; }
.seg.small { box-shadow: none; background: var(--soft); }
.seg.small button { height: 28px; padding: 0 12px; }

.switch { cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob {
  width: 30px; height: 18px; border-radius: 999px; background: #CBD2DA; position: relative; transition: background .2s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.switch input:checked + .knob { background: #3B6EF5; }
.switch input:checked + .knob::after { transform: translateX(12px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--gold); outline-offset: 2px; }

#tip {
  position: absolute; z-index: 3; pointer-events: none;
  background: var(--navy); color: #fff; border-radius: 10px; padding: 7px 10px;
  font-size: 12px; line-height: 1.35; box-shadow: var(--shadow); max-width: 240px;
}
#tip b { font-weight: 600; }
#tip .st { display: inline-block; margin-left: 6px; font-weight: 600; }
#tip .st.a { color: var(--avail); }
#tip .st.u { color: var(--taken); }

/* the heading changes width while the view turns (N 5° to N 245°); keep the buttons beside it still */
#bearingTxt { display: inline-block; min-width: 3.4em; font-variant-numeric: tabular-nums; }
.chip.rot { padding: 0 4px; gap: 0; }
.chip.rot button {
  border: 0; background: transparent; height: 30px; min-width: 34px; padding: 0 8px; border-radius: 999px;
  font-size: 15px; line-height: 1; color: var(--navy);
}
.chip.rot #spin { font-size: 12px; font-weight: 600; }
.chip.rot #spin[aria-pressed="true"] { background: var(--navy); color: #fff; }
.chip.rot button:hover { background: var(--soft); }
.chip.rot #spin[aria-pressed="true"]:hover { background: var(--navy); }

.loading { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2; }
.loading[hidden] { display: none; }
.nomap .loading {
  bottom: auto; top: 50%; transform: translate(-50%, -50%); height: auto; max-width: min(420px, 86vw);
  padding: 12px 16px; border-radius: 14px; line-height: 1.45; white-space: normal; text-align: center;
}
.nomap .loading .spin, .nomap .mapctl { display: none; }
.spin {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid #CBD2DA; border-top-color: var(--navy);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* panel */
#panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px; width: 384px; z-index: 4;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 22px 18px;
}
.ph h1 {
  font: 600 25px/1.15 Lora, Georgia, serif; margin: 2px 0 6px; color: var(--navy); letter-spacing: -.01em;
}
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.live { margin: 10px 0 0; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #22B573; box-shadow: 0 0 0 0 rgba(34, 181, 115, .5); animation: pulse 2s infinite; }
.live.stale .dot { background: #D9A23B; animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(34, 181, 115, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 181, 115, 0); } }

.block { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.block h2 {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; margin: 14px 0 8px; display: flex; justify-content: space-between; align-items: baseline;
}
.block h2:first-child { margin-top: 0; }
.hint { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; margin: 8px 0 0; }
h2 .hint { margin: 0; }

.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font: 600 22px/1.1 Lora, Georgia, serif; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

.towers { display: grid; gap: 8px; margin-top: 12px; }
.tcard {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px;
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px;
}
.tcard:hover { border-color: #CFC7B9; }
.tcard.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.tcard .nm { font-weight: 600; color: var(--navy); }
.tcard .ct { font-size: 12px; color: var(--muted); }
.tcard .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: #E5E9EE; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--avail); border-radius: 999px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: #fff; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px;
}
.chips button.on { background: #3B6EF5; border-color: #3B6EF5; color: #fff; }
.toggle { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: #3B6EF5; }

.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 7px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend li .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend li .t small { color: var(--muted); }

/* storey grid */
.grid-wrap { margin-top: 10px; overflow-x: auto; }
.sgrid { display: grid; gap: 1px; font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sgrid .lv { text-align: right; padding-right: 4px; line-height: 11px; }
.sgrid .hd { text-align: center; line-height: 12px; }
.sgrid .bk { text-align: center; font-weight: 600; color: var(--navy); font-size: 10px; }
.sgrid i { display: block; height: 11px; border-radius: 2px; background: var(--dim); cursor: pointer; }
.sgrid i.x { visibility: hidden; cursor: default; }
.sgrid i.sel { outline: 2px solid var(--sel); outline-offset: 0; position: relative; z-index: 1; }
.sgrid i:hover { filter: brightness(1.12); }
.sgrid .gap { width: 6px; }
.sgrid .lv[data-lv] { cursor: pointer; }
.sgrid .lv[data-lv]:hover { color: var(--navy); }
.sgrid .lv.cur { color: var(--navy); font-weight: 700; }

/* floor list */
.floor { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.floor:empty { display: none; }
.fhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; background: var(--soft); }
.fhead div { text-align: center; line-height: 1.25; min-width: 0; }
.fhead b { display: block; font: 600 16px/1.2 Lora, Georgia, serif; color: var(--navy); }
.fhead span { font-size: 11px; color: var(--muted); }
.fhead button {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; height: 30px; min-width: 62px;
  padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--navy);
}
.fhead button:disabled { opacity: .35; cursor: default; }
.ftab { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.ftab th {
  text-align: left; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line);
}
.ftab td { padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ftab th:first-child, .ftab td:first-child { padding-left: 10px; }
.ftab th:last-child, .ftab td:last-child { padding-right: 10px; text-align: right; }
.ftab tr:last-child td { border-bottom: 0; }
.ftab tbody tr { cursor: pointer; }
.ftab tbody tr:hover { background: #FBF8F3; }
.ftab tr.sel { background: #FFF4DE; }
.ftab tr.dim { opacity: .45; }
.ftab .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.ftab tr.a .dot { background: var(--avail); }
.ftab tr.u .dot { background: var(--taken); }
.ftab td.pr { font-weight: 600; color: var(--navy); }
.ftab tr.u td { color: var(--muted); }
.ftab tr.u td.pr { color: var(--taken); font-weight: 500; }

/* selected unit */
.card.unit {
  margin-top: 16px; border-radius: 14px; padding: 14px; background: var(--navy); color: #fff; position: relative;
}
.unit .ref { font: 600 22px/1.1 Lora, Georgia, serif; margin: 0; }
.unit .pill { position: absolute; top: 14px; right: 40px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.unit .pill.a { background: var(--avail); color: #fff; }
.unit .pill.u { background: var(--taken); color: #fff; }
.unit .close { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .12); color: #fff; line-height: 1; }
.unit p { margin: 6px 0 0; font-size: 13px; color: #C9D1DB; }
.unit p b { color: #fff; font-weight: 600; }
.unit .price { margin-top: 10px; }
.unit .price b { font: 600 21px/1.2 Lora, Georgia, serif; color: #fff; }
.unit .price span { margin-left: 8px; font-size: 12px; color: #C9D1DB; }
.unit .acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.unit .acts a, .unit .acts button {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; text-decoration: none; border: 0;
}
.unit .acts .go { background: #25D366; color: #08321A; }
.unit .acts .plan { background: rgba(255, 255, 255, .12); color: #fff; }

.pf { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.cta {
  display: flex; justify-content: center; align-items: center; height: 44px; border-radius: 12px;
  background: var(--navy); color: #fff; text-decoration: none; font-weight: 600;
}
.cta:hover { background: #16293D; }
.fine { font-size: 11px; color: var(--muted); margin: 12px 0 0; }

dialog.vr {
  border: 0; padding: 0; width: min(96vw, 1200px); height: min(90vh, 820px); max-width: none; max-height: none;
  border-radius: 16px; overflow: hidden; display: none; flex-direction: column; background: var(--navy);
  box-shadow: var(--shadow);
}
dialog.vr[open] { display: flex; }
dialog.vr::backdrop { background: rgba(13, 27, 42, .7); }
.vrbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; color: #fff; }
.vrt { flex: 1; min-width: 0; font-size: 13px; color: #C9D1DB; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vrt b { font: 600 16px/1.2 Lora, Georgia, serif; color: #fff; }
.vrbar .seg.small { background: rgba(255, 255, 255, .1); border-color: transparent; }
.vrbar .seg button { color: #fff; }
.vrbar .seg button[aria-selected="true"] { background: #fff; color: var(--navy); }
.vrbar .x { width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 20px; line-height: 1; flex: none; }
#vrFrame { flex: 1; width: 100%; border: 0; background: #000; }
.vrnote { margin: 0; padding: 8px 16px 10px; font-size: 11.5px; color: #AEB7C2; }
@media (max-width: 760px) {
  dialog.vr { width: 100vw; height: 100dvh; border-radius: 0; }
  .vrt span { display: none; }
}

dialog#planDlg { border: 0; border-radius: 16px; padding: 0; max-width: min(92vw, 900px); box-shadow: var(--shadow); }
dialog#planDlg::backdrop { background: rgba(13, 27, 42, .6); }
dialog#planDlg img { display: block; width: 100%; height: auto; }
dialog#planDlg .x { position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; font-size: 20px; line-height: 1; }

.maplibregl-ctrl-attrib { font-size: 10px; }

/* phone: map on top, panel scrolls below */
@media (max-width: 760px) {
  #app { position: static; }
  body { background: var(--card); height: auto; }
  #stage { position: relative; height: 62vh; height: 62svh; }
  .nomap #stage { height: 260px; }
  #panel {
    position: relative; inset: auto; width: auto; border-radius: 20px 20px 0 0; margin-top: -18px;
    box-shadow: 0 -6px 20px rgba(13, 27, 42, .12); overflow: visible; padding: 20px 16px 28px;
  }
  .topbar { top: 12px; left: 12px; right: 12px; flex-wrap: wrap; }
  .topbar .seg { width: 100%; justify-content: space-between; }
  .topbar .seg button { padding: 0 6px; flex: 1; font-size: 12.5px; }
  .mapctl { left: 12px; right: 12px; bottom: 30px; }
  #bearingTxt { display: none; }
  .chip { padding: 0 10px; }
  .legend { grid-template-columns: 1fr; }
  .tl { font-size: 11px; padding: 5px 8px; }
  .tl small { display: none; }
  .tl.proj small { display: inline; }
  /* a page in a group: ‹ and the project switcher share one row; towers via roof labels and cards */
  .topbar.grouped { flex-wrap: nowrap; }
  .topbar.grouped .chip.back { flex: none; }
  .topbar.grouped .chip.back .nm { display: none; }
  .topbar.grouped #projSeg { flex: 1; width: auto; min-width: 0; }
  .topbar.grouped #towerSeg { display: none; }
}

/* Style button: switch the look (engine LOOKS) */
.lookctl { position: relative; }
.lookctl #lookBtn { color: var(--navy); font-weight: 600; }
.lookmenu {
  position: absolute; bottom: 42px; left: 0; z-index: 5; min-width: 160px; padding: 6px;
  display: grid; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.lookmenu button {
  display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 8px 10px;
  border-radius: 10px; font-size: 13px; text-align: left; color: var(--ink); white-space: nowrap;
}
.lookmenu button:hover { background: var(--soft); }
.lookmenu button[aria-checked="true"] { background: var(--navy); color: #fff; }
.lookmenu i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.lookmenu i + i { margin-left: -4px; }
@media (max-width: 760px) {
  .lookctl .lbl { display: none; }
  .lookmenu { left: auto; right: 0; }
}

/* the four looks as a row under the panel title */
.lookrow { margin-top: 14px; }
.lookrow h2 { margin: 0 0 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.lookrow .seg { display: flex; width: 100%; }
.lookrow .seg button { flex: 1; padding: 0 6px; }
