/* Rapid Reports — Mobile-First Full-Viewport 3D Roof Viewer (Zero Sidebar) */
:root {
  --bg-top: #dce8f5;
  --bg-bot: #eef2f6;
  --paper: rgba(255, 255, 255, 0.94);
  --paper-solid: #ffffff;
  --ink: #14181d;
  --ink-2: #525a65;
  --ink-3: #7d8794;
  --rule: rgba(20, 24, 29, 0.11);
  --amber: #e4a045;
  --amber-dk: #b4740f;
  --blue: #2580b3;
  --shadow: 0 8px 28px rgba(15, 23, 36, 0.14), 0 1px 3px rgba(15, 23, 36, 0.08);
  --shadow-sm: 0 3px 12px rgba(15, 23, 36, 0.12);
  --f-disp: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-bot);
  color: var(--ink);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
  cursor: grab;
}
#stage:active { cursor: grabbing; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* ---- Floating Top Bar ---- */
.topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 30;
}

.bar-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 7px 12px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: calc(100% - 170px);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(20, 24, 29, 0.05);
  flex-shrink: 0;
  transition: background 0.15s;
}
.back-btn:hover { background: rgba(20, 24, 29, 0.1); }
.back-btn svg { width: 18px; height: 18px; }

.brand-mini {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.title-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.title-addr {
  font-family: var(--f-disp);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.title-meta {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-meta b { color: var(--ink); font-weight: 600; }

.bar-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--paper);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.btn-top:hover { background: #fff; }
.btn-top:active { transform: scale(0.97); }
.btn-top svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-pdf {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  padding: 0 16px;
}
.btn-pdf:hover { background: #262e38; border-color: #262e38; }
.btn-pdf .pdf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

/* ---- Single Floating Overlay Box (Anchored to Clicked Facet or Edge) ---- */
.pick-box {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(20, 24, 29, 0.13);
  border-radius: 13px;
  padding: 10px 13px;
  min-width: 158px;
  max-width: 235px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -100%);
  transition: opacity 0.14s ease;
}
.pick-box[hidden] { display: none !important; }

.pick-box::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 11px;
  height: 11px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid rgba(20, 24, 29, 0.13);
  border-bottom: 1px solid rgba(20, 24, 29, 0.13);
  transform: translateX(-50%) rotate(45deg);
}
.pick-box.below {
  transform: translate(-50%, 0%);
}
.pick-box.below::after {
  bottom: auto;
  top: -6px;
  transform: translateX(-50%) rotate(-135deg);
}

.pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.pick-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.pick-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.pick-close {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 5px;
}
.pick-close:hover { background: rgba(20, 24, 29, 0.07); color: var(--ink); }

.pick-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.pick-val {
  font-family: var(--f-disp);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.pick-pill {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: #fdf5e7;
  color: var(--amber-dk);
  border: 1px solid #edd6ad;
}
.pick-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* ---- Bottom Floating Controls + Edge Legend Strip ---- */
.bottom-dock {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 25;
}

.legend-strip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  max-width: 100%;
  padding: 5px 8px;
  background: var(--paper);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  scrollbar-width: none;
}
.legend-strip::-webkit-scrollbar { display: none; }
body.lines-off .legend-strip,
body.ss-open .legend-strip { display: none; }

.leg-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.leg-chip:hover { background: rgba(20, 24, 29, 0.05); color: var(--ink); }
.leg-chip.active {
  background: var(--ink);
  color: #fff;
}
.leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leg-ft {
  font-family: var(--f-mono);
  font-size: 11px;
  opacity: 0.78;
}

.ctrl-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--paper);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.ctrl-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--f-body);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.ctrl-btn:hover { background: rgba(20, 24, 29, 0.06); color: var(--ink); }
.ctrl-btn.on { background: var(--ink); color: #fff; }

.hint-toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 24, 29, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 20;
  opacity: 1;
  transition: opacity 0.5s ease;
  white-space: nowrap;
}
.hint-toast.fade { opacity: 0; }

/* ---- Optional Slide-Over Summary Sheet (Hidden Until User Taps "Summary") ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 36, 0.35);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
}
.sheet-backdrop[hidden] { display: none !important; }

.sheet {
  width: min(400px, 100vw);
  max-height: 100dvh;
  background: var(--paper-solid);
  box-shadow: -8px 0 32px rgba(15, 23, 36, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--rule);
}
.sheet-head h2 {
  font-family: var(--f-disp);
  font-size: 17px;
  font-weight: 600;
}
.sheet-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: #eef2f6;
}
.sheet-tab {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.sheet-tab:hover { color: var(--ink); }
.sheet-tab.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 36, 0.1);
}
.sheet-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sheet-pane[hidden] { display: none !important; }
.sol-tier-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.sol-tier-btn {
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-2);
  font-family: var(--f-body);
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.sol-tier-btn:hover { background: #f4f7fa; color: var(--ink); }
.sol-tier-btn.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.sol-tier-btn b { display: block; font-size: 12.5px; line-height: 1.2; }
.sol-tier-btn span { display: block; font-family: var(--f-mono); font-size: 10.5px; opacity: 0.78; margin-top: 2px; }
.sol-cmp-tbl tbody tr { cursor: pointer; }
.sol-cmp-tbl tbody tr:hover td { background: #f4f7fa; }
.sol-cmp-tbl tbody tr.on td { background: #fdf5e7; font-weight: 600; color: var(--ink); }
.sol-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.sol-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: #f1f5f9; color: var(--ink-2);
}
.sol-badge.amber { background: #fef6e7; color: #9a5b08; border: 1px solid #f4d69e; }
.sol-badge.good  { background: #ecfdf3; color: #15803d; border: 1px solid #bbf7d0; }
.sol-badge.blue  { background: #eef5fc; color: #1d5fa7; border: 1px solid #bfdbfe; }
.sol-note {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.48;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e3e9f0;
}
.sheet-body {
  padding: 16px 18px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sum-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sum-kpi {
  background: #f4f7fa;
  border: 1px solid #e3e9f0;
  border-radius: 10px;
  padding: 10px 12px;
}
.sum-kpi b { display: block; font-family: var(--f-disp); font-size: 19px; font-variant-numeric: tabular-nums; }
.sum-kpi span { font-size: 11.5px; color: var(--ink-2); }

.sum-sec h3 {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5.5px 0;
  border-bottom: 1px solid #eef2f6;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.sum-row.total { font-weight: 700; border-top: 1px solid #d7e0ea; margin-top: 3px; padding-top: 8px; }
.sum-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.sum-table th, .sum-table td {
  padding: 6px 6px;
  text-align: right;
  border-bottom: 1px solid #eef2f6;
}
.sum-table th:first-child, .sum-table td:first-child { text-align: left; }
.sum-table th { color: var(--blue); font-weight: 600; background: #f4f7fa; }

/* ---- Loading / Error Overlay ---- */
.loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(238, 242, 246, 0.92);
  z-index: 50;
  font-size: 14px;
  color: var(--ink-2);
}
.loader[hidden] { display: none !important; }
.spin {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(20, 24, 29, 0.15);
  border-top-color: var(--amber-dk);
  border-radius: 50%;
  animation: rot 0.8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---- Passive Static 3D Fallback (shown only when WebGL is unavailable, crashes, or times out) ---- */
body.static-fallback .bottom-dock,
body.static-fallback .hint-toast {
  display: none !important;
}
body.static-fallback #stage {
  cursor: default;
}
.static-fallback-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #b9d4ee 0%, #dce8f4 42%, #a7b899 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.static-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.static-badge-bar {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 7px 10px 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.static-retry-btn {
  border: 0;
  background: var(--ink);
  color: #fff;
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.static-retry-btn:hover { background: #262e38; }

@media (max-width: 640px) {
  .bar-pill { padding: 6px 10px; gap: 8px; max-width: calc(100% - 158px); }
  .title-addr { font-size: 13.5px; }
  .title-meta { font-size: 11px; }
  .btn-top { height: 38px; padding: 0 11px; font-size: 13px; }
  .btn-top .hide-xs { display: none; }
  .sheet { width: 100vw; max-height: 82dvh; margin-top: auto; border-radius: 18px 18px 0 0; }
  .sheet-backdrop { align-items: flex-end; }
}

/* ---- Top bar actions (2026-11-30): one pill = Summary + a chevron that opens the rest ---- */
.act-split {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--paper);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}
.act-main, .act-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.act-main { gap: 7px; padding: 0 13px 0 14px; border-radius: 11px 0 0 11px; }
.act-more { width: 38px; border-left: 1px solid var(--rule); border-radius: 0 11px 11px 0; color: var(--ink-2); }
.act-main:hover, .act-more:hover, .act-more.open { background: #fff; }
.act-main svg { width: 16px; height: 16px; flex-shrink: 0; }
.act-more svg { width: 15px; height: 15px; transition: transform 0.18s ease; }
.act-more.open svg { transform: rotate(180deg); }
.act-main:focus-visible, .act-more:focus-visible, .act-item:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

.act-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 244px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 44px rgba(15, 23, 36, 0.20), 0 2px 8px rgba(15, 23, 36, 0.08);
  transform-origin: top right;
  animation: actMenuIn 0.14s ease-out;
}
.act-menu[hidden] { display: none; }
@keyframes actMenuIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.act-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.act-item:hover { background: rgba(20, 24, 29, 0.055); }
.act-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-2); }
.act-sep { height: 1px; margin: 5px 8px; background: var(--rule); }
@media (max-width: 640px) {
  .act-split { height: 38px; }
  .act-main { padding: 0 10px 0 11px; font-size: 13px; }
  .act-more { width: 34px; }
  .act-menu { min-width: 232px; }
  .act-item { padding: 13px 12px; }
}
@media (prefers-reduced-motion: reduce) { .act-menu { animation: none; } .act-more svg { transition: none; } }
