/* ================================================================
   ROOF-REPORT.CSS -- Screen + Print styles for /roof-measurement-report/
   Dashboard shell: persistent left sidebar for inputs/outputs,
   full-bleed right canvas for map + diagram.
   ================================================================ */

:root {
  --rr-blue:        #1B3A5C;
  --rr-blue-dark:   #0F2440;
  --rr-blue-deep:   #0A1628;
  --rr-gold:        #D4A843;
  --rr-gold-light:  #E8C96A;
  --rr-gold-soft:   #FEF3C7;
  --rr-white:       #FFFFFF;
  --rr-off:         #F7F8FA;
  --rr-bg:          #F2F4F7;
  --rr-ink-900:     #0F172A;
  --rr-ink-700:     #334155;
  --rr-ink-500:     #64748B;
  --rr-ink-400:     #94A3B8;
  --rr-ink-300:     #CBD5E1;
  --rr-line:        #E2E8F0;
  --rr-line-soft:   #EEF1F5;
  --rr-success:     #16A34A;
  --rr-warn:        #F59E0B;
  --rr-danger:      #DC2626;

  --rr-font-head:   'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --rr-font-body:   'Poppins', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --rr-radius-xs:   6px;
  --rr-radius-sm:   10px;
  --rr-radius:      14px;
  --rr-radius-lg:   20px;
  --rr-radius-xl:   28px;
  --rr-radius-pill: 999px;

  --rr-shadow-xs:   0 1px 2px rgba(15, 23, 42, 0.05);
  --rr-shadow-sm:   0 2px 6px rgba(15, 23, 42, 0.06);
  --rr-shadow:      0 8px 24px rgba(15, 23, 42, 0.06);
  --rr-shadow-lg:   0 20px 60px rgba(15, 23, 42, 0.15);

  --rr-ease:        cubic-bezier(0.22, 0.61, 0.36, 1);

  --rr-sidebar-w:   380px;
  --rr-app-pad:     20px;
}

html, body { height: 100%; }
body.rr-page-root {
  margin: 0;
  padding: 0;
  font-family: var(--rr-font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--rr-ink-900);
  background: var(--rr-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.rr-page-root *,
body.rr-page-root *::before,
body.rr-page-root *::after { box-sizing: border-box; }
body.rr-modal-open { overflow: hidden; }

button { font-family: inherit; }

/* ==========================================================
   APP SHELL
   ========================================================== */
.rr-app {
  display: grid;
  grid-template-columns: var(--rr-sidebar-w) minmax(0, 1fr);
  gap: var(--rr-app-pad);
  min-height: 100vh;
  padding: var(--rr-app-pad);
  background: var(--rr-bg);
}

/* ==========================================================
   SIDEBAR
   ========================================================== */
.rr-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--rr-white);
  border-radius: var(--rr-radius-xl);
  box-shadow: var(--rr-shadow);
  overflow: hidden;
  max-height: calc(100vh - 2 * var(--rr-app-pad));
}
.rr-sidebar__header {
  padding: 22px 22px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rr-line-soft);
}
.rr-sidebar__logo {
  display: inline-flex;
  align-items: center;
  color: var(--rr-blue);
  text-decoration: none;
  transition: opacity 0.2s;
}
.rr-sidebar__logo:hover { opacity: 0.85; }
.rr-sidebar__logo svg { height: 28px; width: auto; }
.rr-sidebar__lang {
  font-size: 12px;
  font-weight: 600;
  color: var(--rr-ink-500);
  background: var(--rr-off);
  border: 1px solid var(--rr-line);
  padding: 6px 12px;
  border-radius: var(--rr-radius-pill);
  text-decoration: none;
  transition: all 0.15s;
}
.rr-sidebar__lang:hover {
  color: var(--rr-blue);
  border-color: var(--rr-blue);
}

.rr-sidebar__address {
  padding: 20px 22px;
  border-bottom: 1px solid var(--rr-line-soft);
}
.rr-sidebar__address-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--rr-ink-500);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.rr-sidebar__address-label svg { width: 12px; height: 12px; color: var(--rr-gold); }
.rr-sidebar__address-input-wrap { position: relative; }
.rr-sidebar__address-input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  font-size: 14px;
  font-family: var(--rr-font-body);
  color: var(--rr-ink-900);
  background: var(--rr-off);
  border: 1.5px solid transparent;
  border-radius: var(--rr-radius);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.rr-sidebar__address-input::placeholder { color: var(--rr-ink-400); }
.rr-sidebar__address-input:focus {
  background: var(--rr-white);
  border-color: var(--rr-gold);
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15);
}
.rr-sidebar__address-icon {
  position: absolute;
  top: 50%; right: 14px;
  transform: translateY(-50%);
  color: var(--rr-ink-400);
  pointer-events: none;
}
.rr-sidebar__address-icon svg { width: 16px; height: 16px; display: block; }
.rr-pac-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--rr-white);
  border: 1px solid var(--rr-line);
  border-radius: var(--rr-radius);
  box-shadow: var(--rr-shadow-lg);
  overflow: hidden;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
}
.rr-pac-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--rr-ink-700);
  border-bottom: 1px solid var(--rr-line-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rr-pac-item:last-child { border-bottom: none; }
.rr-pac-item:hover,
.rr-pac-item.is-active {
  background: var(--rr-gold-soft);
  color: var(--rr-blue-dark);
}

.rr-sidebar__reportmeta {
  padding: 12px 22px 0;
  display: none;
}
.rr-sidebar.has-report .rr-sidebar__reportmeta { display: block; }
.rr-sidebar__reportmeta-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: var(--rr-off);
  border: 1px solid var(--rr-line-soft);
  border-radius: var(--rr-radius-sm);
  font-size: 12px;
}
.rr-sidebar__reportmeta-row strong {
  color: var(--rr-blue);
  font-weight: 700;
}
.rr-sidebar__reportmeta-id {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--rr-ink-500);
  font-size: 11px;
}

.rr-sidebar__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 22px 16px;
  min-height: 0;
}
.rr-sidebar__scroll::-webkit-scrollbar { width: 6px; }
.rr-sidebar__scroll::-webkit-scrollbar-thumb { background: var(--rr-line); border-radius: 3px; }

.rr-sidebar__empty {
  text-align: center;
  padding: 32px 8px;
  color: var(--rr-ink-500);
}
.rr-sidebar__empty svg {
  display: block;
  margin: 0 auto 16px;
  width: 64px; height: 64px;
  opacity: 0.55;
}
.rr-sidebar__empty h3 {
  font-family: var(--rr-font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--rr-ink-700);
  margin: 0 0 6px;
}
.rr-sidebar__empty p {
  font-size: 13px;
  margin: 0;
  line-height: 1.55;
  color: var(--rr-ink-500);
}

.rr-sidebar.has-report .rr-sidebar__empty { display: none; }
.rr-sidebar__report { display: none; }
.rr-sidebar.has-report .rr-sidebar__report { display: flex; flex-direction: column; gap: 18px; }

.rr-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rr-section__heading {
  font-family: var(--rr-font-head);
  font-size: 10px;
  font-weight: 700;
  color: var(--rr-ink-500);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0;
}

/* KPI compact grid */
.rr-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rr-kpi {
  background: var(--rr-off);
  border: 1px solid var(--rr-line-soft);
  border-radius: var(--rr-radius);
  padding: 12px 14px;
}
.rr-kpi__value {
  font-family: var(--rr-font-head);
  font-weight: 800;
  font-size: 22px;
  color: var(--rr-blue);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 2px;
}
.rr-kpi__label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--rr-ink-500);
  letter-spacing: 0.8px;
  font-weight: 600;
}
.rr-kpi--accent { background: linear-gradient(135deg, rgba(212, 168, 67, 0.12), rgba(212, 168, 67, 0.04)); border-color: rgba(212, 168, 67, 0.25); }
.rr-kpi--accent .rr-kpi__value { color: var(--rr-gold); }
.rr-kpi--wide { grid-column: span 2; }
.rr-kpi--wide .rr-kpi__value { font-size: 18px; }

/* Waste pills (compact for sidebar) */
.rr-waste { display: flex; flex-direction: column; gap: 8px; }
.rr-waste__sub { font-size: 12px; color: var(--rr-ink-500); margin: 0; line-height: 1.5; }
.rr-waste__pills {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rr-waste-pill {
  position: relative;
  background: var(--rr-white);
  border: 1.5px solid var(--rr-line);
  border-radius: var(--rr-radius-pill);
  padding: 6px 12px;
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 12px;
  color: var(--rr-ink-700);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.rr-waste-pill:hover { border-color: var(--rr-gold); color: var(--rr-blue); }
.rr-waste-pill.is-selected {
  background: var(--rr-blue);
  border-color: var(--rr-blue);
  color: var(--rr-white);
}
.rr-waste-pill--suggested {
  border-color: var(--rr-gold);
  background: var(--rr-gold-soft);
  color: var(--rr-blue);
}
.rr-waste-pill--suggested.is-selected {
  background: var(--rr-gold);
  border-color: var(--rr-gold);
  color: var(--rr-blue-dark);
}
.rr-waste-pill__badge {
  font-size: 8px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: var(--rr-gold);
  color: var(--rr-blue-dark);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}
.rr-waste-pill--suggested.is-selected .rr-waste-pill__badge {
  background: var(--rr-blue-dark); color: var(--rr-gold);
}

/* Materials + edges tables (sidebar compact) */
.rr-table-compact {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rr-table-compact th,
.rr-table-compact td {
  text-align: left;
  padding: 8px 0;
  border-bottom: 1px solid var(--rr-line-soft);
  color: var(--rr-ink-700);
  font-weight: 500;
}
.rr-table-compact tr:last-child th,
.rr-table-compact tr:last-child td { border-bottom: none; }
.rr-table-compact td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--rr-blue);
  font-family: var(--rr-font-head);
}
.rr-table-compact tfoot td {
  border-top: 1.5px solid var(--rr-line);
  padding-top: 10px;
  font-weight: 700;
}
.rr-edges-table__dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.rr-edges-table__dot--ridge { background: #E53935; }
.rr-edges-table__dot--hip { background: #1E88E5; }
.rr-edges-table__dot--valley { background: #43A047; }
.rr-edges-table__dot--eave { background: #212121; }
.rr-edges-table__dot--rake { background: #8E24AA; }

/* Layer toggles */
.rr-layers { display: flex; flex-direction: column; gap: 6px; }
.rr-layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--rr-line-soft);
  background: var(--rr-off);
  border-radius: var(--rr-radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--rr-ink-700);
  transition: all 0.15s;
  text-align: left;
}
.rr-layer-toggle:hover { border-color: var(--rr-gold); background: var(--rr-white); }
.rr-layer-toggle:not(.is-on) {
  opacity: 0.45;
}
.rr-layer-toggle__swatch {
  display: inline-block;
  width: 14px; height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.rr-layer-toggle__label { flex: 1; }
.rr-layer-toggle__check {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--rr-line);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--rr-white);
  transition: all 0.15s;
}
.rr-layer-toggle.is-on .rr-layer-toggle__check {
  background: var(--rr-blue);
  border-color: var(--rr-blue);
}
.rr-layer-toggle__check svg {
  width: 10px; height: 10px;
  color: var(--rr-white);
  opacity: 0;
  transition: opacity 0.15s;
}
.rr-layer-toggle.is-on .rr-layer-toggle__check svg { opacity: 1; }

/* Pitch distribution */
.rr-pitchdist { display: flex; flex-direction: column; gap: 5px; }
.rr-pitchdist__row {
  display: grid;
  grid-template-columns: 72px 1fr 36px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}
.rr-pitchdist__label {
  color: var(--rr-ink-700);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rr-pitchdist__bar {
  display: block;
  height: 6px;
  background: var(--rr-line);
  border-radius: var(--rr-radius-pill);
  overflow: hidden;
}
.rr-pitchdist__fill {
  display: block;
  height: 100%;
  border-radius: var(--rr-radius-pill);
  transition: width 0.4s var(--rr-ease);
}
.rr-pitchdist__pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--rr-ink-500);
  font-weight: 600;
}

/* Imagery meta */
.rr-imagery {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 12px;
  color: var(--rr-ink-700);
}
.rr-imagery__pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: var(--rr-radius-pill);
  background: var(--rr-off);
  border: 1px solid var(--rr-line-soft);
  font-weight: 600;
}
.rr-imagery__pill strong { color: var(--rr-blue); font-weight: 700; }

/* Sidebar banners (live alert strip near top) */
.rr-banners { display: flex; flex-direction: column; gap: 6px; }
.rr-banner {
  padding: 10px 12px;
  border-radius: var(--rr-radius-sm);
  font-size: 12px;
  line-height: 1.45;
  display: flex; align-items: flex-start; gap: 8px;
  border: 1px solid transparent;
}
.rr-banner--warn {
  background: #FEF3C7;
  color: #92400E;
  border-color: #FDE68A;
}
.rr-banner--info {
  background: #DBEAFE;
  color: #1E40AF;
  border-color: #BFDBFE;
}
.rr-banner::before {
  content: '';
  flex-shrink: 0;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.2;
  margin-top: 2px;
}

/* Source-of-truth badge — which pipeline produced the current diagram. */
.rr-source-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px; line-height: 1;
  background: #EEF2F7;
  color: #1B3A5C;
  border: 1px solid #CED7E3;
  width: fit-content;
}
.rr-source-badge__label { opacity: 0.7; }
.rr-source-badge__value { font-weight: 700; letter-spacing: 0.01em; }
.rr-source-badge--api     { background: #DCFCE7; border-color: #BBF7D0; color: #065F46; }
.rr-source-badge--ai      { background: #E0E7FF; border-color: #C7D2FE; color: #3730A3; }
.rr-source-badge--sam     { background: #FCE7F3; border-color: #FBCFE8; color: #9D174D; }
.rr-source-badge--manual  { background: #FEF3C7; border-color: #FDE68A; color: #92400E; }
.rr-source-badge--mask    { background: #EEF2F7; border-color: #CED7E3; color: #1B3A5C; }

/* Sidebar footer CTA stack */
.rr-sidebar__footer {
  padding: 16px 22px 20px;
  border-top: 1px solid var(--rr-line-soft);
  background: var(--rr-off);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rr-cta-pdf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--rr-blue);
  color: var(--rr-white);
  border: none;
  border-radius: var(--rr-radius);
  padding: 14px 18px;
  font-family: var(--rr-font-head);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-align: left;
  font-size: 14px;
}
.rr-cta-pdf:hover { background: var(--rr-blue-dark); }
.rr-cta-pdf:active { transform: scale(0.99); }
.rr-cta-pdf:disabled {
  background: var(--rr-ink-300);
  color: var(--rr-white);
  cursor: not-allowed;
  opacity: 0.8;
}
.rr-cta-pdf__icon {
  width: 32px; height: 32px;
  border-radius: var(--rr-radius-sm);
  background: var(--rr-gold);
  color: var(--rr-blue-dark);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.rr-cta-pdf__copy {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.rr-cta-pdf__label { font-size: 14px; }
.rr-cta-pdf__sub { font-size: 11px; color: rgba(255,255,255,0.7); font-weight: 500; }
.rr-cta-pdf__arrow { flex-shrink: 0; color: var(--rr-gold); }

.rr-cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.rr-cta-ghost {
  background: var(--rr-white);
  color: var(--rr-blue);
  border: 1px solid var(--rr-line);
  border-radius: var(--rr-radius-sm);
  padding: 10px 12px;
  font-family: var(--rr-font-head);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.rr-cta-ghost:hover { border-color: var(--rr-gold); color: var(--rr-blue-dark); }
.rr-cta-ghost svg { width: 13px; height: 13px; }
.rr-cta-ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.rr-cta-ghost--primary {
  background: var(--rr-blue);
  color: var(--rr-white);
  border-color: var(--rr-blue);
}
.rr-cta-ghost--primary:hover:not(:disabled) {
  background: var(--rr-blue-dark);
  border-color: var(--rr-blue-dark);
  color: var(--rr-white);
}

/* "Draw my roof manually" link-style trigger in the sidebar footer */
.rr-cta-draw {
  margin-top: 4px;
  background: transparent;
  border-style: dashed;
  color: var(--rr-ink-700);
}
.rr-cta-draw:hover {
  background: var(--rr-gold-soft);
  border-style: solid;
  color: var(--rr-blue);
}
.rr-cta-draw svg { color: var(--rr-gold); }

/* ==========================================================
   DRAW MODE (sidebar panel + canvas hint)
   ========================================================== */

/* Hide the standard sidebar sections while drawing. The panel (below)
   takes over the scroll area. */
.rr-app.is-drawing .rr-sidebar__empty,
.rr-app.is-drawing .rr-sidebar__report,
.rr-app.is-drawing .rr-sidebar__reportmeta,
.rr-app.is-drawing .rr-sidebar__footer { display: none; }
.rr-app.is-drawing .rr-draw-panel { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 24px; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.rr-draw-panel { display: none; }

.rr-draw-panel__heading h2 {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 18px;
  color: var(--rr-blue);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.rr-draw-panel__heading p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--rr-ink-500);
}

.rr-draw-panel__totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rr-draw-panel__total {
  background: var(--rr-gold-soft);
  border: 1px solid rgba(212, 168, 67, 0.4);
  border-radius: var(--rr-radius);
  padding: 10px 12px;
  text-align: left;
}
.rr-draw-panel__total-value {
  display: block;
  font-family: var(--rr-font-head);
  font-weight: 800;
  font-size: 22px;
  color: var(--rr-blue);
  letter-spacing: -0.01em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.rr-draw-panel__total-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--rr-ink-500);
  letter-spacing: 0.8px;
  font-weight: 600;
}

.rr-draw-panel__subheading {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 10px;
  color: var(--rr-ink-500);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 4px 0 2px;
}

.rr-draw-polygons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rr-draw-empty {
  font-size: 12px;
  color: var(--rr-ink-500);
  font-style: italic;
  margin: 0;
  padding: 10px 12px;
  background: var(--rr-off);
  border: 1px dashed var(--rr-line);
  border-radius: var(--rr-radius-sm);
  text-align: center;
}
.rr-draw-panel:has(.rr-draw-polygons:empty) .rr-draw-empty,
.rr-draw-panel:has(.rr-draw-polygons .rr-draw-poly) .rr-draw-empty { /* noop placeholder */ }

.rr-draw-poly {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--rr-off);
  border: 1px solid var(--rr-line-soft);
  border-radius: var(--rr-radius-sm);
}
.rr-draw-poly__idx {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--rr-blue);
  color: var(--rr-white);
  display: grid; place-items: center;
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.rr-draw-poly__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.rr-draw-poly__area {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 13px;
  color: var(--rr-blue);
  font-variant-numeric: tabular-nums;
}
.rr-draw-poly__controls {
  display: flex;
  gap: 6px;
  align-items: center;
}
.rr-draw-poly__pitch {
  border: 1px solid var(--rr-line);
  background: var(--rr-white);
  border-radius: var(--rr-radius-sm);
  font-family: var(--rr-font-body);
  font-size: 11px;
  color: var(--rr-ink-700);
  padding: 4px 6px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.rr-draw-poly__pitch:focus { border-color: var(--rr-gold); }
.rr-draw-poly__del {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--rr-ink-500);
  cursor: pointer;
  font-size: 14px;
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.rr-draw-poly__del:hover { background: #FEE2E2; color: var(--rr-danger); }
.rr-draw-poly__del svg { width: 12px; height: 12px; }

.rr-draw-panel__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.rr-draw-panel__cancel {
  background: transparent;
  border: none;
  color: var(--rr-ink-500);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 0;
  text-align: center;
  font-family: var(--rr-font-body);
}
.rr-draw-panel__cancel:hover { color: var(--rr-danger); }

/* Canvas-side floating drawing hint */
.rr-draw-hint {
  position: absolute;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  background: rgba(27, 58, 92, 0.94);
  color: var(--rr-white);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--rr-radius-pill);
  box-shadow: var(--rr-shadow);
  z-index: 12;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.rr-draw-hint svg { width: 14px; height: 14px; color: var(--rr-gold); }

/* While drawing: hide scan CTA, map hint, scan overlay; keep map visible. */
.rr-app.is-drawing .rr-scan-cta,
.rr-app.is-drawing .rr-map__hint { display: none; }
.rr-app.is-drawing .rr-canvas .rr-map { display: block; }
.rr-app.is-drawing .rr-canvas .rr-empty,
.rr-app.is-drawing .rr-canvas .rr-diagram-wrap,
.rr-app.is-drawing .rr-canvas .rr-aerial-wrap,
.rr-app.is-drawing .rr-canvas .rr-scan-overlay { display: none; }
.rr-app.is-drawing .rr-canvas__tabs { display: none; }

/* ==========================================================
   SAM REFINE MODAL
   ========================================================== */
.rr-cta-samrefine {
  margin-top: 4px;
  background: transparent;
  border-style: dashed;
  color: var(--rr-ink-700);
}
.rr-cta-samrefine:hover:not(:disabled) {
  background: var(--rr-gold-soft);
  border-style: solid;
  color: var(--rr-blue);
}
.rr-cta-samrefine svg { color: var(--rr-gold); }

.rr-sam-modal {
  position: fixed; inset: 0;
  z-index: 120;
  display: grid; place-items: center;
  padding: 16px;
}
.rr-sam-modal[hidden] { display: none; }
.rr-sam-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 22, 40, 0.78);
}
.rr-sam-modal__card {
  position: relative;
  width: 100%;
  max-width: 1000px;
  max-height: 92vh;
  background: var(--rr-white);
  border-radius: var(--rr-radius-lg);
  box-shadow: var(--rr-shadow-lg);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}
.rr-sam-modal__close {
  position: absolute;
  top: 10px; right: 12px;
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 22px; line-height: 1;
  color: var(--rr-ink-500);
  cursor: pointer;
  border-radius: 50%;
  z-index: 2;
  transition: background 0.15s;
}
.rr-sam-modal__close:hover { background: var(--rr-bg); }

.rr-sam-modal__head {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--rr-line-soft);
}
.rr-sam-modal__head h2 {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 20px;
  color: var(--rr-blue);
  margin: 0 0 4px;
}
.rr-sam-modal__head p {
  margin: 0;
  font-size: 13px;
  color: var(--rr-ink-500);
  line-height: 1.5;
}

.rr-sam-modal__stage {
  position: relative;
  background: var(--rr-bg);
  min-height: 360px;
  overflow: hidden;
}
.rr-sam-canvas {
  position: absolute;
  border-radius: var(--rr-radius-sm);
  cursor: crosshair;
  box-shadow: var(--rr-shadow);
  image-rendering: crisp-edges;
}
.rr-sam-overlay {
  position: absolute;
  pointer-events: none;
}
.rr-sam-overlay svg.rr-sam-maskpath {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.rr-sam-overlay svg.rr-sam-maskpath path {
  fill: rgba(212, 168, 67, 0.35);
  stroke: #D4A843;
  stroke-width: 2.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.rr-sam-pinmark {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.9), var(--rr-shadow-sm);
  pointer-events: none;
}
.rr-sam-pinmark--pos { background: #16A34A; }
.rr-sam-pinmark--neg {
  background: #fff;
  border: 3px solid #DC2626;
  width: 16px; height: 16px;
}

.rr-sam-progress {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: grid; place-items: center;
  backdrop-filter: blur(3px);
}
.rr-sam-progress__inner { text-align: center; max-width: 300px; padding: 20px; }
.rr-sam-progress__bar {
  height: 4px;
  background: var(--rr-line);
  border-radius: var(--rr-radius-pill);
  overflow: hidden;
  margin-bottom: 10px;
}
.rr-sam-progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--rr-gold), var(--rr-gold-light));
  border-radius: var(--rr-radius-pill);
  transition: width 0.3s var(--rr-ease);
}
.rr-sam-progress__label {
  font-size: 13px;
  color: var(--rr-ink-700);
  margin: 0;
  font-weight: 500;
}

.rr-sam-modal__tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-top: 1px solid var(--rr-line-soft);
  background: var(--rr-off);
  flex-wrap: wrap;
}
.rr-sam-modal__mode {
  display: inline-flex;
  background: var(--rr-white);
  padding: 3px;
  border-radius: var(--rr-radius-pill);
  border: 1px solid var(--rr-line);
}
.rr-sam-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--rr-radius-pill);
  border: none;
  background: transparent;
  font-family: var(--rr-font-head);
  font-weight: 600;
  font-size: 12px;
  color: var(--rr-ink-500);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rr-sam-btn svg { width: 12px; height: 12px; }
.rr-sam-btn.is-active.rr-sam-btn--pos {
  background: #16A34A; color: #fff;
}
.rr-sam-btn.is-active.rr-sam-btn--neg {
  background: #DC2626; color: #fff;
}
.rr-sam-btn--primary {
  background: var(--rr-blue);
  color: var(--rr-white);
  padding: 10px 22px;
  font-size: 14px;
}
.rr-sam-btn--primary:disabled {
  background: var(--rr-ink-300);
  cursor: not-allowed;
}
.rr-sam-btn--primary:hover:not(:disabled) { background: var(--rr-blue-dark); }
.rr-sam-btn--ghost {
  background: var(--rr-white);
  border: 1px solid var(--rr-line);
  color: var(--rr-ink-700);
  padding: 10px 18px;
  font-size: 14px;
}
.rr-sam-btn--ghost:hover { border-color: var(--rr-gold); color: var(--rr-blue); }

.rr-sam-modal__counts {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--rr-ink-500);
}
.rr-sam-pin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  color: var(--rr-ink-700);
}
.rr-sam-pin__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.rr-sam-pin--pos .rr-sam-pin__dot { background: #16A34A; }
.rr-sam-pin--neg .rr-sam-pin__dot {
  background: #fff;
  border: 2px solid #DC2626;
}
.rr-sam-link {
  background: none;
  border: none;
  color: var(--rr-ink-500);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 2px 4px;
}
.rr-sam-link:disabled { opacity: 0.4; cursor: not-allowed; }
.rr-sam-link:hover:not(:disabled) { color: var(--rr-blue); }

.rr-sam-modal__footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--rr-line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.rr-sam-modal__status {
  margin: 0;
  font-size: 13px;
  color: var(--rr-ink-700);
  flex: 1;
  min-width: 180px;
}
.rr-sam-modal__actions {
  display: inline-flex;
  gap: 8px;
}

@media (max-width: 720px) {
  .rr-sam-modal { padding: 8px; }
  .rr-sam-modal__card { max-height: 96vh; }
  .rr-sam-modal__head { padding: 16px 16px 10px; }
  .rr-sam-modal__head h2 { font-size: 17px; }
  .rr-sam-modal__head p { font-size: 12px; }
  .rr-sam-modal__tools { padding: 10px 14px; }
  .rr-sam-modal__footer { padding: 12px 14px; }
  .rr-sam-btn--primary, .rr-sam-btn--ghost { padding: 8px 14px; font-size: 13px; }
  .rr-sam-modal__status { font-size: 12px; }
}

/* ==========================================================
   AI VERIFICATION CARD
   ========================================================== */
.rr-ai-card {
  background: linear-gradient(135deg, rgba(27, 58, 92, 0.04), rgba(212, 168, 67, 0.06));
  border: 1px solid rgba(27, 58, 92, 0.12);
  border-radius: var(--rr-radius);
  padding: 14px 16px;
}
.rr-ai-card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.rr-ai-card__head h2 { margin: 0; color: var(--rr-blue); }
.rr-ai-badge {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--rr-radius-pill);
}
.rr-ai-badge--high   { background: #D1FAE5; color: #065F46; }
.rr-ai-badge--medium { background: #FEF3C7; color: #92400E; }
.rr-ai-badge--low    { background: #FEE2E2; color: #991B1B; }

.rr-ai-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0 0 10px;
  font-size: 12px;
}
.rr-ai-dl dt {
  color: var(--rr-ink-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
  align-self: center;
}
.rr-ai-dl dd {
  margin: 0;
  color: var(--rr-blue);
  font-weight: 700;
  font-family: var(--rr-font-head);
  font-size: 13px;
}

.rr-ai-penetrations {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.rr-ai-penetrations:empty { display: none; }
.rr-ai-pen {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--rr-white);
  border: 1px solid var(--rr-line);
  border-radius: var(--rr-radius-pill);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--rr-ink-700);
}
.rr-ai-pen strong { color: var(--rr-blue); }

.rr-ai-notes {
  margin: 0;
  padding: 10px 12px;
  background: rgba(27, 58, 92, 0.05);
  border-left: 3px solid var(--rr-gold);
  border-radius: var(--rr-radius-sm);
  font-size: 12px;
  line-height: 1.5;
  color: var(--rr-ink-700);
  font-style: italic;
}

/* ==========================================================
   CANVAS (right side)
   ========================================================== */
.rr-canvas {
  position: relative;
  background: var(--rr-white);
  border-radius: var(--rr-radius-xl);
  box-shadow: var(--rr-shadow);
  overflow: hidden;
  min-height: calc(100vh - 2 * var(--rr-app-pad));
}
.rr-canvas__toolbar {
  position: absolute;
  top: 20px; left: 20px;
  display: flex; gap: 8px;
  z-index: 15;
}
.rr-canvas__title {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 16px;
  border-radius: var(--rr-radius-pill);
  box-shadow: var(--rr-shadow-xs);
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 13px;
  color: var(--rr-blue);
  display: inline-flex; align-items: center; gap: 8px;
}
.rr-canvas__title svg { width: 14px; height: 14px; color: var(--rr-gold); }

.rr-canvas__tabs {
  position: absolute;
  top: 20px; right: 20px;
  display: inline-flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px;
  border-radius: var(--rr-radius-pill);
  box-shadow: var(--rr-shadow-xs);
  z-index: 15;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.rr-canvas.has-report .rr-canvas__tabs {
  opacity: 1;
  visibility: visible;
}
.rr-canvas__tab {
  padding: 6px 14px;
  border-radius: var(--rr-radius-pill);
  border: none;
  background: transparent;
  font-family: var(--rr-font-head);
  font-weight: 600;
  font-size: 12px;
  color: var(--rr-ink-500);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rr-canvas__tab.is-active {
  background: var(--rr-blue);
  color: var(--rr-white);
}

.rr-canvas__stage {
  position: absolute;
  inset: 0;
}

/* Empty state */
.rr-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(212, 168, 67, 0.04), transparent 60%),
    var(--rr-white);
}
.rr-canvas.has-located .rr-empty,
.rr-canvas.is-scanning .rr-empty,
.rr-canvas.has-report .rr-empty { display: none; }
.rr-empty__inner { max-width: 420px; }
.rr-empty__viz {
  position: relative;
  width: 220px; height: 220px;
  margin: 0 auto 28px;
}
.rr-empty__viz svg {
  width: 100%; height: 100%;
  display: block;
}
.rr-empty__viz-rings circle {
  fill: none;
  stroke: var(--rr-gold);
  stroke-width: 1.2;
  opacity: 0.3;
  transform-origin: center;
  animation: rrRing 5s var(--rr-ease) infinite;
}
.rr-empty__viz-rings circle:nth-child(2) { animation-delay: 1.2s; }
.rr-empty__viz-rings circle:nth-child(3) { animation-delay: 2.4s; }
@keyframes rrRing {
  0%   { transform: scale(0.3); opacity: 0; }
  30%  { opacity: 0.6; }
  100% { transform: scale(1); opacity: 0; }
}
.rr-empty h2 {
  font-family: var(--rr-font-head);
  font-weight: 800;
  font-size: 28px;
  color: var(--rr-blue);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.rr-empty p {
  color: var(--rr-ink-500);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 24px;
}
.rr-empty__trust {
  display: inline-flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--rr-off);
  border-radius: var(--rr-radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--rr-ink-700);
}
.rr-empty__trust-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--rr-success);
  display: inline-block;
  margin-right: 6px;
}

/* Map */
.rr-map {
  position: absolute;
  inset: 0;
  display: none;
}
.rr-canvas.has-located .rr-map { display: block; }
.rr-canvas.is-scanning .rr-map { display: block; }
.rr-canvas.has-report:not(.is-aerial):not(.is-diagram) .rr-map { display: block; }
.rr-map__container { position: absolute; inset: 0; }

.rr-map__hint {
  position: absolute;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 36, 64, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--rr-white);
  padding: 10px 18px;
  border-radius: var(--rr-radius-pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--rr-shadow-lg);
  z-index: 10;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
.rr-map__hint svg { width: 14px; height: 14px; color: var(--rr-gold); }
.rr-canvas.is-scanning .rr-map__hint,
.rr-canvas.has-report .rr-map__hint { display: none; }

.rr-scan-cta {
  position: absolute;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center; gap: 8px;
  background: var(--rr-gold);
  color: var(--rr-blue-dark);
  border: none;
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 15px;
  padding: 14px 26px;
  border-radius: var(--rr-radius-pill);
  box-shadow: var(--rr-shadow-lg);
  cursor: pointer;
  z-index: 12;
  transition: background 0.2s, transform 0.15s;
}
.rr-canvas.has-located:not(.is-scanning):not(.has-report) .rr-scan-cta { display: inline-flex; }
.rr-scan-cta:hover { background: var(--rr-gold-light); transform: translateX(-50%) translateY(-2px); }
.rr-scan-cta svg { width: 16px; height: 16px; }

/* Scan overlay */
.rr-scan-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 40, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  align-items: center;
  padding: 40px 20px;
  z-index: 20;
  color: var(--rr-white);
  text-align: center;
}
.rr-canvas.is-scanning .rr-scan-overlay { display: grid; }
.rr-scan-overlay__viz {
  grid-row: 2;
  width: 200px; height: 200px;
  margin-bottom: 32px;
}
.rr-scan-overlay__viz svg { width: 100%; height: 100%; }
.rr-scan-overlay__viz .sweep {
  transform-origin: center;
  animation: rrSweep 3s linear infinite;
}
@keyframes rrSweep {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}
.rr-scan-overlay__body {
  grid-row: 3;
  align-self: start;
  max-width: 420px;
  width: 100%;
}
.rr-scan-overlay__title {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 18px;
}
.rr-scan-overlay__progress {
  position: relative;
  width: 100%; height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--rr-radius-pill);
  overflow: hidden;
  margin-bottom: 18px;
}
.rr-scan-overlay__progress-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--rr-gold), var(--rr-gold-light));
  border-radius: var(--rr-radius-pill);
  transition: width 0.4s var(--rr-ease);
}
.rr-scan-overlay__steps {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
  text-align: left;
  max-width: 300px;
  margin: 0 auto;
}
.rr-scan-overlay__step {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  transition: color 0.3s;
}
.rr-scan-overlay__step::before {
  content: '';
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  transition: all 0.3s;
  flex-shrink: 0;
}
.rr-scan-overlay__step.is-active { color: var(--rr-white); }
.rr-scan-overlay__step.is-active::before {
  border-color: var(--rr-gold);
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.22);
  animation: rrPulse 1.2s var(--rr-ease) infinite;
}
.rr-scan-overlay__step.is-done { color: rgba(255,255,255,0.75); }
.rr-scan-overlay__step.is-done::before {
  background: var(--rr-gold);
  border-color: var(--rr-gold);
}
@keyframes rrPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 67, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(212, 168, 67, 0); }
}

.rr-scan-error {
  margin-top: 24px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--rr-radius);
  max-width: 380px;
}
.rr-scan-error h3 {
  font-family: var(--rr-font-head);
  font-size: 16px;
  margin: 0 0 6px;
}
.rr-scan-error p {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  margin: 0 0 14px;
}
.rr-scan-error__actions {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.rr-scan-error__actions a,
.rr-scan-error__actions button {
  font-family: var(--rr-font-head); font-weight: 600; font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--rr-radius-pill);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: var(--rr-white);
}
.rr-scan-error__actions a:hover,
.rr-scan-error__actions button:hover {
  background: var(--rr-gold);
  border-color: var(--rr-gold);
  color: var(--rr-blue-dark);
}

/* Diagram (interactive 2D SVG) */
.rr-diagram-wrap {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, var(--rr-white), var(--rr-off));
  display: none;
}
/* Manual reports keep the live map visible with the drawn polygons as the
   canvas visualization. No diagram/aerial tabs in this mode. */
.rr-canvas.is-manual .rr-canvas__tabs { display: none; }
.rr-canvas.is-manual .rr-map,
.rr-canvas.has-report.is-manual .rr-map { display: block; }
.rr-canvas.is-manual .rr-diagram-wrap,
.rr-canvas.is-manual .rr-aerial-wrap,
.rr-canvas.is-manual .rr-empty,
.rr-canvas.is-manual .rr-scan-overlay { display: none; }

.rr-canvas.has-report.is-diagram .rr-diagram-wrap { display: block; }
.rr-diagram-wrap svg.rr-diagram-svg {
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}
.rr-diagram-wrap .rr-segment {
  cursor: pointer;
  transition: fill-opacity 0.15s;
}

.rr-tooltip {
  position: absolute;
  padding: 10px 14px;
  background: var(--rr-blue-dark);
  color: var(--rr-white);
  font-size: 12px;
  line-height: 1.55;
  border-radius: var(--rr-radius-sm);
  box-shadow: var(--rr-shadow-lg);
  pointer-events: none;
  z-index: 30;
  max-width: 240px;
}

/* Aerial canvas */
.rr-aerial-wrap {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--rr-off);
}
.rr-canvas.has-report.is-aerial .rr-aerial-wrap { display: block; }
.rr-aerial-wrap canvas {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

/* ==========================================================
   MODAL (shared)
   ========================================================== */
.rr-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
}
.rr-modal[hidden] { display: none; }
.rr-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 22, 40, 0.6);
  animation: rrFadeIn 0.25s var(--rr-ease);
}
@keyframes rrFadeIn { from { opacity: 0; } to { opacity: 1; } }
.rr-modal__card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--rr-white);
  border-radius: var(--rr-radius-lg);
  padding: 32px 28px 24px;
  box-shadow: var(--rr-shadow-lg);
  animation: rrSlideUp 0.3s var(--rr-ease);
  border-top: 4px solid var(--rr-gold);
}
@keyframes rrSlideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.rr-modal__close {
  position: absolute;
  top: 12px; right: 14px;
  width: 34px; height: 34px;
  border: none; background: transparent;
  font-size: 22px; line-height: 1;
  color: var(--rr-ink-500);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.rr-modal__close:hover { background: var(--rr-bg); color: var(--rr-ink-900); }
.rr-modal__heading {
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 22px;
  color: var(--rr-blue);
  margin: 0 0 6px;
}
.rr-modal__sub {
  font-size: 14px;
  color: var(--rr-ink-500);
  margin: 0 0 22px;
}
.rr-field { display: block; margin-bottom: 16px; }
.rr-field__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--rr-ink-700);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.rr-field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--rr-line);
  border-radius: var(--rr-radius-sm);
  font-size: 15px;
  font-family: var(--rr-font-body);
  color: var(--rr-ink-900);
  background: var(--rr-white);
  outline: none;
  transition: border-color 0.15s;
}
.rr-field input:focus { border-color: var(--rr-gold); }
.rr-field input.rr-field--err,
.rr-field input[aria-invalid="true"] { border-color: var(--rr-danger); }
.rr-field__error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--rr-danger);
  font-style: normal;
}
.rr-modal__submit {
  width: 100%;
  padding: 14px;
  background: var(--rr-gold);
  color: var(--rr-blue-dark);
  font-family: var(--rr-font-head);
  font-weight: 700;
  font-size: 16px;
  border: none;
  border-radius: var(--rr-radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.rr-modal__submit:hover:not(:disabled) { background: var(--rr-gold-light); }
.rr-modal__submit:disabled { background: var(--rr-ink-300); cursor: not-allowed; }
.rr-modal__privacy { font-size: 11px; color: var(--rr-ink-500); margin: 10px 0 0; text-align: center; }
.rr-modal__err {
  margin: 10px 0 0;
  padding: 10px;
  background: #FEE2E2;
  color: var(--rr-danger);
  font-size: 13px;
  border-radius: var(--rr-radius-sm);
  text-align: center;
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */

/* Compact desktop: narrower sidebar, tighter outer padding. */
@media (max-width: 1180px) {
  :root { --rr-sidebar-w: 340px; --rr-app-pad: 16px; }
  .rr-empty h2 { font-size: 26px; }
  .rr-sidebar__scroll { padding: 18px 18px 16px; }
  .rr-sidebar__header,
  .rr-sidebar__address,
  .rr-sidebar__footer { padding-left: 18px; padding-right: 18px; }
}

/* Small tablet: further narrow the sidebar before stacking. */
@media (max-width: 960px) {
  :root { --rr-sidebar-w: 300px; }
  .rr-kpi__value { font-size: 20px; }
  .rr-empty h2 { font-size: 24px; }
}

/* Mobile + narrow tablet portrait: stacked layout.
   IMPORTANT: sidebar comes FIRST (address input at top), canvas below,
   so the primary action isn't buried under the hero illustration. */
@media (max-width: 720px) {
  .rr-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    padding: 10px;
    gap: 10px;
    min-height: 100vh;
  }
  /* Re-order so address input is at the top of the viewport. */
  .rr-sidebar { order: 1; max-height: none; overflow: visible; }
  .rr-canvas  { order: 2; min-height: 58vh; max-height: 72vh; border-radius: var(--rr-radius-lg); }

  /* Sidebar internals flow naturally (no fixed scroll container on mobile). */
  .rr-sidebar__scroll {
    overflow: visible;
    padding: 16px 18px 8px;
  }
  .rr-sidebar__header { padding: 16px 18px 12px; }
  .rr-sidebar__address { padding: 14px 18px 16px; }

  /* Before a report exists, keep the sidebar focused on the address +
     empty copy; hide the placeholder sections to avoid a tall empty card. */
  .rr-sidebar:not(.has-report) .rr-sidebar__empty { padding: 20px 8px; }

  /* Footer flows naturally at the bottom of the sidebar (below report
     sections), not sticky — sticky-inside-overflow-visible misbehaves on
     landscape phones and collides with the canvas below. */
  .rr-sidebar__footer {
    padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0));
  }

  /* Compress big empty state on small screens. */
  .rr-empty { padding: 24px 20px; }
  .rr-empty__viz { width: 160px; height: 160px; margin-bottom: 18px; }
  .rr-empty h2 { font-size: 22px; margin-bottom: 8px; }
  .rr-empty p { font-size: 14px; margin-bottom: 16px; }

  /* Trust pill wraps gracefully instead of clipping. */
  .rr-empty__trust {
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 10px 14px;
    justify-content: center;
    font-size: 11px;
  }
  .rr-empty__trust > span[style*="opacity"] { display: none; }

  /* Canvas toolbar items shrink slightly. */
  .rr-canvas__toolbar { top: 12px; left: 12px; }
  .rr-canvas__tabs    { top: 12px; right: 12px; }
  .rr-canvas__title   { padding: 8px 12px; font-size: 12px; }
  .rr-canvas__tab     { padding: 5px 10px; font-size: 11px; }

  /* Waste pills scroll horizontally if the row overflows. */
  .rr-waste__pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .rr-waste__pills::-webkit-scrollbar { display: none; }
  .rr-waste-pill { flex-shrink: 0; }

  /* Legend panel anchored over the diagram: collapse to a bottom drawer. */
  .rr-map__hint { bottom: 72px; font-size: 12px; padding: 8px 14px; }
  .rr-scan-cta  { bottom: 16px; padding: 12px 22px; font-size: 14px; }
  .rr-tooltip   { max-width: 180px; font-size: 11px; }
}

/* Extra-small phones (360px and narrower): tighten further. */
@media (max-width: 380px) {
  .rr-empty__viz { width: 140px; height: 140px; }
  .rr-empty h2 { font-size: 20px; }
  .rr-sidebar__empty svg { width: 54px; height: 54px; }
  .rr-sidebar__empty h3 { font-size: 14px; }
  .rr-sidebar__empty p  { font-size: 12px; }
  .rr-kpi__value { font-size: 18px; }
}

/* Landscape phones: keep stacked but constrain canvas height so the hero
   pill and trust row don't crowd the small strip. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 900px) {
  .rr-app { min-height: auto; }
  .rr-canvas { min-height: 70vh; max-height: none; }
  .rr-empty__viz { width: 110px; height: 110px; margin-bottom: 12px; }
  .rr-empty h2 { font-size: 18px; }
  .rr-empty p { font-size: 12px; margin-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .rr-empty__viz-rings circle,
  .rr-scan-overlay__viz .sweep,
  .rr-scan-overlay__step.is-active::before {
    animation: none !important;
  }
  * { transition-duration: 0.01ms !important; }
}

/* ==========================================================
   PRINT LAYOUT (unchanged from prior version)
   ========================================================== */
.rr-print-layout { display: none; }

@media print {
  @page { size: Letter; margin: 0.75in 0.5in; }
  @page :first { margin: 0; }

  html, body { background: #fff !important; }
  body > *:not(.rr-print-layout) { display: none !important; }
  .rr-print-layout { display: block !important; }
  body.rr-is-printing .rr-print-layout { display: block !important; }

  * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }

  .rr-print { font-family: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: #0F172A; }
  .rr-page {
    page-break-after: always;
    page-break-inside: avoid;
    break-after: page;
    padding: 0.3in 0.25in 0.3in;
    position: relative;
    min-height: 9.5in;
  }
  .rr-page:last-child { page-break-after: auto; }

  .rr-page__header {
    margin-bottom: 0.2in;
    border-bottom: 2px solid var(--rr-blue);
    padding-bottom: 0.1in;
  }
  .rr-page__header h2 {
    font-size: 22px;
    color: var(--rr-blue);
    margin: 0 0 2px;
  }
  .rr-page__header p {
    margin: 0; font-size: 12px; color: var(--rr-ink-500);
  }
  .rr-page__footer {
    position: absolute;
    bottom: 0.25in; left: 0.25in; right: 0.25in;
    text-align: center;
    font-size: 10px;
    color: var(--rr-ink-500);
    border-top: 1px solid var(--rr-line);
    padding-top: 6px;
  }

  .rr-page--cover {
    padding: 0; margin: 0;
    background: var(--rr-blue-dark);
    color: #fff;
    min-height: 11in;
    display: grid;
    grid-template-rows: auto 1fr auto;
  }
  .rr-page__cover-band {
    padding: 0.8in 0.6in 0.4in;
    background: linear-gradient(180deg, var(--rr-blue-deep), var(--rr-blue-dark));
  }
  .rr-page__cover-body {
    padding: 0.4in 0.8in;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    color: #fff;
  }
  .rr-page__cover-title {
    font-size: 44px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.4in;
    color: var(--rr-gold);
  }
  .rr-page__cover-card {
    display: inline-block;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 24px 32px;
    margin: 0 auto;
    text-align: left;
  }
  .rr-page__cover-card dl {
    display: grid;
    grid-template-columns: 1fr 2fr;
    row-gap: 10px; column-gap: 24px;
    margin: 0;
  }
  .rr-page__cover-card dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.55);
    font-weight: 600;
  }
  .rr-page__cover-card dd {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
  }
  .rr-page__cover-powered {
    margin-top: 0.5in;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--rr-gold);
  }
  .rr-page__cover-foot {
    background: var(--rr-blue-deep);
    padding: 0.3in 0.6in;
    text-align: center;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
  }

  .rr-page__aerial {
    margin: 0 -0.25in;
    height: 8in;
  }
  .rr-page__aerial img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .rr-page__diagram {
    height: 7.5in;
  }
  .rr-page__diagram svg {
    width: 100%;
    height: 100%;
  }
  .rr-page__legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    font-size: 11px;
    color: var(--rr-ink-700);
    padding: 10px 0;
  }
  .rr-page__legend i {
    display: inline-block;
    width: 14px; height: 4px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
  }

  .rr-page__kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 0.3in;
  }
  .rr-page__kpis .rr-kpi {
    background: var(--rr-gold-soft);
    border: 1px solid var(--rr-gold);
    padding: 12px;
    text-align: left;
  }

  .rr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 0.2in;
  }
  .rr-table thead th {
    background: var(--rr-blue);
    color: #fff;
    padding: 8px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .rr-table tbody td {
    padding: 8px;
    border-bottom: 1px solid var(--rr-line);
  }
  .rr-table__total td {
    font-weight: 700;
    border-top: 2px solid var(--rr-blue);
  }
  .rr-table--materials th.rr-col-suggest,
  .rr-table--materials td.rr-col-suggest {
    background: var(--rr-gold-soft);
    color: var(--rr-blue);
    font-weight: 700;
  }
  .rr-table--materials th small {
    display: block;
    font-weight: 400;
    letter-spacing: 0;
    font-size: 10px;
    opacity: 0.8;
    text-transform: none;
  }

  .rr-page__notes p {
    margin: 0 0 0.15in;
    font-size: 12px;
    line-height: 1.55;
  }
  .rr-page__meta {
    margin-top: 0.3in;
    padding-top: 0.15in;
    border-top: 1px solid var(--rr-line);
    font-size: 11px;
  }
  .rr-page__meta dt {
    display: inline-block;
    font-weight: 700;
    color: var(--rr-blue);
    margin-right: 8px;
  }
  .rr-page__meta dd { display: inline; margin: 0 16px 0 0; }
}
