/* ============================================================================
   RoofHawk — shared design system v2 "Zincalume"  (roofhawk.css)
   ----------------------------------------------------------------------------
   One stylesheet for all three surfaces (admin SPA, roofer PWA, marketing site).

   Direction (25 Sep 2026 overhaul): built from the trade, not a template.
     - Base  = zinc/galvanised sheet greys (light, readable in full sun on a roof)
               with an "Ironsand" dark theme for evenings.
     - Action = hi-vis yellow. It is ONLY used for things you press / the one
               thing you should do next. Never decoration.
     - Data   = roof-condition colours taken from real roofing: oxide rust,
               weathered/faded, scoria, Karaka green for sound.
     - Type   = Archivo (variable width). Wide + heavy for display, normal for
               body, tabular numerals for every figure.
     - The bold element = the aerial roof photo with a hi-vis footprint outline.
               Everything around it stays quiet.

   Theme: follows the OS; force with <html data-theme="light|dark">.
   The class API (.rh-*) is unchanged from v1 so existing markup keeps working;
   v2 adds map/split/roof-card/segmented/tab-bar/sheet/kpi primitives (bottom).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,300..900&display=swap');

/* ---------------------------------------------------------------------------
   Tokens — light (default)
   ------------------------------------------------------------------------ */
:root {
  color-scheme: light;
  /* galvanised sheet */
  --rh-bg: #e7e9e8;
  --rh-surface: #f6f7f6;
  --rh-surface-2: #dde1df;
  --rh-surface-3: #d0d5d3;
  --rh-ink: #25221e;          /* Ironsand */
  --rh-ink-2: #5a5650;
  --rh-ink-3: #7c7871;
  --rh-line: #c6cbc8;
  --rh-line-strong: #a9afab;

  /* action */
  --rh-hivis: #f4c300;
  --rh-hivis-hover: #ffd324;
  --rh-hivis-ink: #1d1a00;
  --rh-accent-text: #7a5d00;  /* hi-vis family, but legible as text on zinc */
  --rh-focus: #1f6fd1;

  /* roof condition (data only) */
  --rh-c-rust: #a8421a;
  --rh-c-rust-bg: #f3dfd4;
  --rh-c-faded: #8a7648;
  --rh-c-faded-bg: #ece5d3;
  --rh-c-scoria: #7a2c2a;
  --rh-c-scoria-bg: #eed9d7;
  --rh-c-sound: #3c6a4a;
  --rh-c-sound-bg: #d8e7dc;
  --rh-c-unknown: #6a7075;
  --rh-c-unknown-bg: #e0e3e4;
  --rh-c-warm: #9a6410;
  --rh-c-warm-bg: #f1e3c6;
  --rh-c-danger: #b3261e;
  --rh-c-danger-bg: #f5d9d6;

  --rh-shadow: 0 1px 0 rgba(37, 34, 30, .04), 0 1px 3px rgba(37, 34, 30, .08);
  --rh-shadow-lg: 0 18px 50px rgba(37, 34, 30, .22);
  --rh-scrim: rgba(30, 28, 25, .45);

  /* shape: controls tight, panels a little softer, sheets softest */
  --rh-r-ctl: 6px;
  --rh-r-panel: 10px;
  --rh-r-sheet: 16px;
  --rh-gap: 16px;

  --rh-font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --rh-chrome: #25221e;       /* sidebar: always Ironsand, both themes (its text is fixed light) */
  --rh-sidebar-w: 232px;
  --rh-tabbar-h: 64px;

  /* v1 aliases — old markup/inline styles keep resolving to sensible colours */
  --rh-bg2: var(--rh-surface);
  --rh-bg3: var(--rh-surface-2);
  --rh-text: var(--rh-ink);
  --rh-muted: var(--rh-ink-2);
  --rh-muted2: var(--rh-ink-3);
  --rh-line2: var(--rh-line);
  --rh-amber: var(--rh-accent-text);
  --rh-amber2: var(--rh-accent-text);
  --rh-gold-soft: var(--rh-accent-text);
  --rh-gold-dim: var(--rh-line-strong);
  --rh-rust: var(--rh-c-rust);
  --rh-red: var(--rh-c-danger);
  --rh-rust-soft: var(--rh-c-rust);
  --rh-panel: var(--rh-surface);
  --rh-radius: var(--rh-r-panel);
  --rh-radius-sm: var(--rh-r-ctl);
  --rh-font-head: var(--rh-font);
  --rh-font-body: var(--rh-font);
}

/* Ironsand — dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --rh-bg: #1c1a18;
    --rh-surface: #262320;
    --rh-surface-2: #312d29;
    --rh-surface-3: #3c3833;
    --rh-ink: #efebe4;
    --rh-ink-2: #b3ada4;
    --rh-ink-3: #8b857c;
    --rh-line: #3d3934;
    --rh-line-strong: #58524b;
    --rh-accent-text: #f4c300;
    --rh-focus: #7fb2ff;
    --rh-c-rust: #f0875a;   --rh-c-rust-bg: #4a2718;
    --rh-c-faded: #d6c08a;  --rh-c-faded-bg: #3e3624;
    --rh-c-scoria: #e39a93; --rh-c-scoria-bg: #47221f;
    --rh-c-sound: #8ccc9d;  --rh-c-sound-bg: #213a2a;
    --rh-c-unknown: #aab1b6; --rh-c-unknown-bg: #33373a;
    --rh-c-warm: #efb656;   --rh-c-warm-bg: #43341a;
    --rh-c-danger: #ff8a80; --rh-c-danger-bg: #4d1f1c;
    --rh-shadow: 0 1px 0 rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .25);
    --rh-shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
    --rh-scrim: rgba(0, 0, 0, .6);
    --rh-chrome: #141210;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --rh-bg: #1c1a18;
  --rh-surface: #262320;
  --rh-surface-2: #312d29;
  --rh-surface-3: #3c3833;
  --rh-ink: #efebe4;
  --rh-ink-2: #b3ada4;
  --rh-ink-3: #8b857c;
  --rh-line: #3d3934;
  --rh-line-strong: #58524b;
  --rh-accent-text: #f4c300;
  --rh-focus: #7fb2ff;
  --rh-c-rust: #f0875a;   --rh-c-rust-bg: #4a2718;
  --rh-c-faded: #d6c08a;  --rh-c-faded-bg: #3e3624;
  --rh-c-scoria: #e39a93; --rh-c-scoria-bg: #47221f;
  --rh-c-sound: #8ccc9d;  --rh-c-sound-bg: #213a2a;
  --rh-c-unknown: #aab1b6; --rh-c-unknown-bg: #33373a;
  --rh-c-warm: #efb656;   --rh-c-warm-bg: #43341a;
  --rh-c-danger: #ff8a80; --rh-c-danger-bg: #4d1f1c;
  --rh-shadow: 0 1px 0 rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .25);
  --rh-shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
  --rh-scrim: rgba(0, 0, 0, .6);
  --rh-chrome: #141210;
}

/* ---------------------------------------------------------------------------
   Base
   ------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--rh-bg);
  color: var(--rh-ink);
  font-family: var(--rh-font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 {
  font-family: var(--rh-font);
  font-stretch: 112%;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 .4em;
  color: var(--rh-ink);
}
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 .8em; max-width: 72ch; }
a { color: var(--rh-ink); text-decoration: underline; text-decoration-color: var(--rh-hivis); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--rh-ink); }
::selection { background: var(--rh-hivis); color: var(--rh-hivis-ink); }
:focus-visible { outline: 2px solid var(--rh-focus); outline-offset: 2px; }
img { max-width: 100%; }

* { scrollbar-width: thin; scrollbar-color: var(--rh-line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--rh-line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------------------
   App shell
   ------------------------------------------------------------------------ */
.rh-app { display: grid; grid-template-columns: var(--rh-sidebar-w) 1fr; min-height: 100vh; }
.rh-sidebar {
  background: var(--rh-chrome);
  color: #e9e5de;
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rh-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--rh-font); font-stretch: 125%; font-weight: 850;
  font-size: 19px; letter-spacing: -.01em; color: inherit; text-decoration: none;
}
.rh-brand__mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: var(--rh-hivis); color: var(--rh-hivis-ink);
  border-radius: 5px; font-weight: 900; font-size: 15px;
}
.rh-brand__mark svg { width: 20px; height: 20px; }
.rh-sidebar .rh-brand { padding: 4px 8px; }
.rh-nav { display: flex; flex-direction: column; gap: 2px; }
.rh-nav__heading { font-size: 12px; font-weight: 600; color: #9d978e; padding: 14px 10px 4px; }
.rh-nav__link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--rh-r-ctl);
  color: #d9d4cc; font-weight: 550; font-size: 14.5px; text-decoration: none;
  border-left: 3px solid transparent;
}
.rh-nav__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.rh-nav__link.is-active { background: rgba(244, 195, 0, .12); color: #fff; border-left-color: var(--rh-hivis); }
.rh-nav__icon { width: 18px; height: 18px; flex: none; display: grid; place-items: center; opacity: .9; }
.rh-nav__icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.rh-nav__spacer { flex: 1; }
.rh-sidebar .rh-btn--ghost { color: #e9e5de; border-color: #55504a; }
.rh-sidebar .rh-btn--ghost:hover { background: rgba(255, 255, 255, .07); }

.rh-main { min-width: 0; display: flex; flex-direction: column; }
.rh-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; min-height: 60px;
  background: color-mix(in srgb, var(--rh-bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rh-line);
}
.rh-topbar h1, .rh-topbar h2 { margin: 0; font-size: 20px; }
.rh-topbar__spacer { flex: 1; }
.rh-container { padding: 22px 24px 40px; max-width: 1320px; width: 100%; }
.rh-container--full { max-width: none; padding: 0; }

.rh-grid { display: grid; gap: var(--rh-gap); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.rh-grid--stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------------------------------------------------------------------------
   Panels & stats
   ------------------------------------------------------------------------ */
.rh-card {
  background: var(--rh-surface);
  border: 1px solid var(--rh-line);
  border-radius: var(--rh-r-panel);
  padding: 18px 20px;
  box-shadow: var(--rh-shadow);
}
.rh-card--panel { background: var(--rh-surface); }
.rh-card--flush { padding: 0; overflow: hidden; }
.rh-card__title { font-size: 16px; font-weight: 700; font-stretch: 108%; color: var(--rh-ink); margin: 0 0 12px; }
.rh-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.rh-card__head .rh-card__title { margin: 0; }
.rh-card__head > :last-child:not(:first-child) { margin-left: auto; }

.rh-stat {
  background: var(--rh-surface);
  border: 1px solid var(--rh-line);
  border-radius: var(--rh-r-panel);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.rh-stat__num { font-stretch: 118%; font-size: 30px; font-weight: 800; line-height: 1.05; color: var(--rh-ink); }
.rh-stat__label { font-size: 13.5px; font-weight: 600; color: var(--rh-ink-2); }
.rh-stat__sub { font-size: 12.5px; color: var(--rh-ink-3); }

/* KPI strip — one quiet row instead of a wall of stat cards */
.rh-kpis { display: flex; flex-wrap: wrap; background: var(--rh-surface); border: 1px solid var(--rh-line); border-radius: var(--rh-r-panel); }
.rh-kpi { flex: 1 1 130px; padding: 12px 16px; border-right: 1px solid var(--rh-line); min-width: 0; }
.rh-kpi:last-child { border-right: 0; }
.rh-kpi__num { font-stretch: 118%; font-weight: 800; font-size: 24px; line-height: 1.1; }
.rh-kpi__label { font-size: 13px; color: var(--rh-ink-2); }
.rh-kpi--hot .rh-kpi__num { color: var(--rh-c-rust); }
button.rh-kpi, a.rh-kpi { all: unset; flex: 1 1 130px; padding: 12px 16px; border-right: 1px solid var(--rh-line); cursor: pointer; }
button.rh-kpi:hover, a.rh-kpi:hover { background: var(--rh-surface-2); }

/* ---------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------ */
.rh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--rh-font); font-weight: 650; font-size: 14.5px; line-height: 1;
  min-height: 40px; padding: 10px 16px;
  border-radius: var(--rh-r-ctl);
  border: 1px solid var(--rh-line-strong);
  background: var(--rh-surface);
  color: var(--rh-ink);
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.rh-btn:hover { background: var(--rh-surface-2); }
.rh-btn:active { transform: translateY(1px); }
.rh-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.rh-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.rh-btn--primary { background: var(--rh-hivis); color: var(--rh-hivis-ink); border-color: #c99f00; }
.rh-btn--primary:hover { background: var(--rh-hivis-hover); }
.rh-btn--ghost { background: transparent; border-color: var(--rh-line-strong); color: var(--rh-ink); }
.rh-btn--ghost:hover { background: var(--rh-surface-2); }
.rh-btn--quiet { background: transparent; border-color: transparent; color: var(--rh-ink-2); }
.rh-btn--quiet:hover { background: var(--rh-surface-2); color: var(--rh-ink); }
.rh-btn--danger { background: var(--rh-c-danger); color: #fff; border-color: transparent; }
.rh-btn--danger:hover { filter: brightness(1.08); background: var(--rh-c-danger); }
.rh-btn--sm { min-height: 32px; padding: 6px 11px; font-size: 13.5px; }
.rh-btn--lg { min-height: 50px; padding: 14px 22px; font-size: 16px; }
.rh-btn--block { width: 100%; }
.rh-btn--icon { width: 40px; padding: 0; }

/* Segmented control (filters) */
.rh-seg { display: inline-flex; background: var(--rh-surface-2); border-radius: var(--rh-r-ctl); padding: 3px; gap: 2px; flex-wrap: wrap; }
.rh-seg button {
  all: unset; cursor: pointer; padding: 6px 12px; border-radius: 4px;
  font-size: 13.5px; font-weight: 600; color: var(--rh-ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.rh-seg button:hover { color: var(--rh-ink); }
.rh-seg button.is-active, .rh-seg button[aria-pressed="true"] { background: var(--rh-surface); color: var(--rh-ink); box-shadow: var(--rh-shadow); }
.rh-seg button:focus-visible { outline: 2px solid var(--rh-focus); }
.rh-seg .rh-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------ */
.rh-table-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--rh-line); border-radius: var(--rh-r-panel); background: var(--rh-surface); }
.rh-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rh-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--rh-surface-2);
  text-align: left; font-weight: 650; font-size: 13px; color: var(--rh-ink-2);
  padding: 10px 14px; border-bottom: 1px solid var(--rh-line); white-space: nowrap;
}
.rh-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--rh-line); vertical-align: middle; }
.rh-table tbody tr:hover { background: color-mix(in srgb, var(--rh-surface-2) 55%, transparent); }
.rh-table tbody tr:last-child td { border-bottom: none; }
.rh-table--clickable tbody tr { cursor: pointer; }
.rh-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Badges — condition, tier, status
   ------------------------------------------------------------------------ */
.rh-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 12.5px; font-weight: 650; line-height: 1.5;
  background: var(--rh-c-unknown-bg); color: var(--rh-c-unknown);
  white-space: nowrap; text-transform: capitalize;
}
.rh-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.rh-badge--plain::before { display: none; }
/* condition + tier HOT */
.rh-badge--rust, .rh-badge--hot, .rh-badge--severe { background: var(--rh-c-rust-bg); color: var(--rh-c-rust); }
.rh-badge--faded { background: var(--rh-c-faded-bg); color: var(--rh-c-faded); }
.rh-badge--scoria { background: var(--rh-c-scoria-bg); color: var(--rh-c-scoria); }
.rh-badge--sound { background: var(--rh-c-sound-bg); color: var(--rh-c-sound); }
.rh-badge--warm, .rh-badge--moderate, .rh-badge--early { background: var(--rh-c-warm-bg); color: var(--rh-c-warm); }
.rh-badge--watch, .rh-badge--unknown, .rh-badge--none, .rh-badge--free, .rh-badge--shared { background: var(--rh-c-unknown-bg); color: var(--rh-c-unknown); }
/* pipeline / account status */
.rh-badge--new, .rh-badge--queued, .rh-badge--listed { background: var(--rh-surface-2); color: var(--rh-ink); }
.rh-badge--contacted, .rh-badge--quoted, .rh-badge--pending, .rh-badge--invoiced, .rh-badge--scanning, .rh-badge--solo { background: var(--rh-c-warm-bg); color: var(--rh-c-warm); }
.rh-badge--won, .rh-badge--active, .rh-badge--paid, .rh-badge--done, .rh-badge--enterprise, .rh-badge--sold { background: var(--rh-c-sound-bg); color: var(--rh-c-sound); }
.rh-badge--lost, .rh-badge--dead, .rh-badge--suspended, .rh-badge--error { background: var(--rh-c-danger-bg); color: var(--rh-c-danger); }
.rh-badge--exclusive { background: var(--rh-hivis); color: var(--rh-hivis-ink); }
.rh-badge--exclusive::before { background: var(--rh-hivis-ink); }

/* ---------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------ */
.rh-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.rh-label { font-size: 13.5px; font-weight: 600; color: var(--rh-ink); }
.rh-input, .rh-select, .rh-textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--rh-ink);
  background: var(--rh-surface); border: 1px solid var(--rh-line-strong);
  border-radius: var(--rh-r-ctl); padding: 10px 12px; min-height: 42px;
}
.rh-input:focus, .rh-select:focus, .rh-textarea:focus { outline: none; border-color: var(--rh-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rh-focus) 25%, transparent); }
.rh-input::placeholder, .rh-textarea::placeholder { color: var(--rh-ink-3); }
.rh-textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.rh-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--rh-ink-2) 50%), linear-gradient(135deg, var(--rh-ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.rh-hint { font-size: 13px; color: var(--rh-ink-3); }
.rh-form-error { font-size: 13.5px; color: var(--rh-c-danger); background: var(--rh-c-danger-bg); border-radius: var(--rh-r-ctl); padding: 8px 12px; }
.rh-form-error:empty { display: none; }
.rh-check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.rh-check input { width: 18px; height: 18px; accent-color: var(--rh-ink); }

/* ---------------------------------------------------------------------------
   Login
   ------------------------------------------------------------------------ */
.rh-login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.rh-login__art { position: relative; background: var(--rh-ink) center/cover no-repeat; min-height: 280px; }
.rh-login__art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(20, 18, 16, .75)); }
.rh-login__art figcaption { position: absolute; left: 24px; bottom: 20px; right: 24px; z-index: 1; color: #fff; font-size: 14px; }
.rh-login__pane { display: grid; place-items: center; padding: 32px 20px; }
.rh-login__card { width: 100%; max-width: 380px; }
.rh-login__brand { margin-bottom: 26px; }
.rh-login__sub { color: var(--rh-ink-2); margin: -4px 0 22px; }
/* single-column fallback when no art column is present */
.rh-login:not(:has(.rh-login__art)) { grid-template-columns: 1fr; place-items: center; }
.rh-login:not(:has(.rh-login__art)) .rh-login__card { background: var(--rh-surface); border: 1px solid var(--rh-line); border-radius: var(--rh-r-sheet); padding: 28px; box-shadow: var(--rh-shadow); }
@media (max-width: 820px) { .rh-login { grid-template-columns: 1fr; } .rh-login__art { min-height: 200px; } }

/* ---------------------------------------------------------------------------
   Drawer (desktop: right panel; mobile: bottom sheet) + scrim
   ------------------------------------------------------------------------ */
.rh-scrim { position: fixed; inset: 0; background: var(--rh-scrim); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1190; } /* above Leaflet panes (~1000) */
.rh-scrim.is-open, .rh-drawer.is-open ~ .rh-scrim { opacity: 1; pointer-events: auto; }
.rh-drawer { position: fixed; inset: 0; z-index: 1200; pointer-events: none; }
.rh-drawer.is-open { pointer-events: auto; }
.rh-drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--rh-surface); box-shadow: var(--rh-shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease;
}
.rh-drawer.is-open .rh-drawer__panel { transform: none; }
.rh-drawer__head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--rh-line); }
.rh-drawer__head h2, .rh-drawer__head h3 { margin: 0; font-size: 18px; }
.rh-drawer__close { margin-left: auto; }
.rh-drawer__body { padding: 18px; overflow-y: auto; flex: 1; }
.rh-drawer__foot { padding: 12px 18px; border-top: 1px solid var(--rh-line); display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .rh-drawer__panel { top: auto; left: 0; width: 100%; max-height: 92vh; border-radius: var(--rh-r-sheet) var(--rh-r-sheet) 0 0; transform: translateY(100%); }
  .rh-drawer__panel::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--rh-line-strong); margin: 8px auto 0; }
}

/* Confirm dialog */
.rh-dialog { border: 0; padding: 0; border-radius: var(--rh-r-sheet); background: var(--rh-surface); color: var(--rh-ink); box-shadow: var(--rh-shadow-lg); width: min(440px, calc(100% - 32px)); }
.rh-dialog::backdrop { background: var(--rh-scrim); }
.rh-dialog__body { padding: 22px 22px 8px; }
.rh-dialog__body h3 { margin-bottom: 6px; }
.rh-dialog__body p { color: var(--rh-ink-2); }
.rh-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px 20px; }

/* ---------------------------------------------------------------------------
   Toasts
   ------------------------------------------------------------------------ */
.rh-toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.rh-toast { pointer-events: auto; background: var(--rh-ink); color: var(--rh-bg); padding: 11px 16px; border-radius: var(--rh-r-panel); font-size: 14.5px; font-weight: 550; box-shadow: var(--rh-shadow-lg); border-left: 4px solid var(--rh-ink-3); max-width: min(520px, calc(100vw - 32px)); animation: rh-toast-in .18s ease-out; }
.rh-toast--ok { border-left-color: #6fbf87; }
.rh-toast--err { border-left-color: #ff6b5e; }
.rh-toast--info { border-left-color: var(--rh-hivis); }
@keyframes rh-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------------------
   Utilities
   ------------------------------------------------------------------------ */
.rh-row { display: flex; align-items: center; gap: 10px; }
.rh-row--wrap { flex-wrap: wrap; }
.rh-row--between { justify-content: space-between; }
.rh-stack { display: flex; flex-direction: column; gap: var(--rh-gap); }
.rh-spacer { flex: 1; }
.rh-center { text-align: center; }
.rh-muted { color: var(--rh-ink-2); }
.rh-mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .92em; }
.rh-amber { color: var(--rh-accent-text); }
.rh-mt { margin-top: var(--rh-gap); }
.rh-mb { margin-bottom: var(--rh-gap); }
.rh-hidden { display: none !important; }
.rh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rh-loading { padding: 40px; text-align: center; color: var(--rh-ink-3); }
.rh-loading::before { content: ''; display: block; width: 26px; height: 26px; margin: 0 auto 10px; border-radius: 50%; border: 3px solid var(--rh-line); border-top-color: var(--rh-ink); animation: rh-spin .8s linear infinite; }
@keyframes rh-spin { to { transform: rotate(360deg); } }
.rh-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--rh-r-ctl); background: var(--rh-surface-3); display: block; }

/* Empty state — an invitation to act */
.rh-empty { text-align: center; padding: 40px 20px; color: var(--rh-ink-2); }
.rh-empty h3 { color: var(--rh-ink); }
.rh-empty .rh-btn { margin-top: 10px; }

/* ---------------------------------------------------------------------------
   v2 primitives — map-first work surfaces
   ------------------------------------------------------------------------ */

/* Split view: map on the left, list/detail on the right (stacks on mobile) */
.rh-split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: calc(100vh - 60px); }
.rh-split__map { position: relative; min-height: 320px; background: var(--rh-surface-3); }
.rh-split__side { border-left: 1px solid var(--rh-line); background: var(--rh-bg); display: flex; flex-direction: column; min-height: 0; }
.rh-split__toolbar { padding: 12px 14px; border-bottom: 1px solid var(--rh-line); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--rh-surface); }
.rh-split__list { overflow-y: auto; flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 980px) {
  .rh-split { grid-template-columns: 1fr; height: auto; }
  .rh-split__map { height: 52vh; }
  .rh-split__side { border-left: 0; border-top: 1px solid var(--rh-line); }
}
.rh-map { position: absolute; inset: 0; }
.rh-map-overlay { position: absolute; z-index: 500; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.rh-map-overlay > * { pointer-events: auto; box-shadow: var(--rh-shadow-lg); }

/* Map pins (Leaflet divIcon html) — colour = condition, ring = tier */
.rh-pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--rh-c-unknown); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.rh-pin--rust { background: #c24e1f; }
.rh-pin--faded { background: #b39857; }
.rh-pin--scoria { background: #8e3431; }
.rh-pin--sound { background: #4b8a5d; }
.rh-pin--hot { border-color: var(--rh-hivis); box-shadow: 0 0 0 3px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .45); }
.rh-pin.is-selected { width: 30px; height: 30px; border-width: 3px; border-color: var(--rh-hivis); }

/* Roof card — photo-forward list item */
.rh-roofcard {
  display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: center;
  background: var(--rh-surface); border: 1px solid var(--rh-line); border-radius: var(--rh-r-panel);
  padding: 8px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
}
.rh-roofcard:hover { border-color: var(--rh-line-strong); }
.rh-roofcard.is-selected { border-color: var(--rh-ink); box-shadow: inset 4px 0 0 var(--rh-hivis); }
.rh-roofcard__photo { width: 88px; height: 88px; border-radius: var(--rh-r-ctl); object-fit: cover; background: var(--rh-surface-3); display: block; }
.rh-roofcard__addr { font-weight: 700; font-size: 15px; line-height: 1.25; }
.rh-roofcard__sub { font-size: 13px; color: var(--rh-ink-2); }
.rh-roofcard__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.rh-roofcard--big { grid-template-columns: 1fr; padding: 0; overflow: hidden; }
.rh-roofcard--big .rh-roofcard__photo { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0; }
.rh-roofcard--big .rh-roofcard__text { padding: 10px 14px 14px; }

/* Score meter — a short filled bar, number beside it */
.rh-score { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; }
.rh-score__bar { width: 56px; height: 6px; border-radius: 3px; background: var(--rh-surface-3); overflow: hidden; }
.rh-score__bar > i { display: block; height: 100%; background: var(--rh-ink); }
.rh-score--hot .rh-score__bar > i { background: var(--rh-c-rust); }

/* Roof photo hero (lead detail) */
.rh-roofhero { position: relative; border-radius: var(--rh-r-panel); overflow: hidden; background: var(--rh-surface-3); }
.rh-roofhero img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.rh-roofhero__tag { position: absolute; left: 10px; bottom: 10px; background: rgba(20, 18, 16, .78); color: #fff; font-size: 12.5px; padding: 3px 8px; border-radius: 4px; }

/* Through-the-years strip */
.rh-years { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(110px, 1fr); gap: 8px; overflow-x: auto; }
.rh-years figure { margin: 0; }
.rh-years img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--rh-r-ctl); display: block; }
.rh-years figcaption { font-size: 13px; font-weight: 650; margin-top: 4px; }

/* Pipeline stepper (new → contacted → quoted → won/lost) */
.rh-steps { display: flex; gap: 4px; }
.rh-steps button { all: unset; cursor: pointer; flex: 1; text-align: center; padding: 10px 4px; font-size: 13.5px; font-weight: 650; background: var(--rh-surface-2); color: var(--rh-ink-2); border-radius: 4px; }
.rh-steps button:first-child { border-radius: var(--rh-r-ctl) 4px 4px var(--rh-r-ctl); }
.rh-steps button:last-child { border-radius: 4px var(--rh-r-ctl) var(--rh-r-ctl) 4px; }
.rh-steps button.is-done { background: var(--rh-surface-3); color: var(--rh-ink); }
.rh-steps button.is-current { background: var(--rh-ink); color: var(--rh-bg); }
.rh-steps button:focus-visible { outline: 2px solid var(--rh-focus); }

/* Mobile bottom tab bar (roofer PWA) */
.rh-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--rh-tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--rh-surface); border-top: 1px solid var(--rh-line); }
.rh-tabbar a, .rh-tabbar button { all: unset; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--rh-ink-3); cursor: pointer; }
.rh-tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.rh-tabbar .is-active { color: var(--rh-ink); }
.rh-tabbar .is-active svg { stroke-width: 2.3; }
.rh-tabbar .is-active::after { content: ''; width: 20px; height: 3px; border-radius: 2px; background: var(--rh-hivis); }
.rh-has-tabbar { padding-bottom: calc(var(--rh-tabbar-h) + env(safe-area-inset-bottom) + 12px); }

/* Progress (scan jobs) */
.rh-progress { height: 8px; border-radius: 4px; background: var(--rh-surface-3); overflow: hidden; }
.rh-progress > i { display: block; height: 100%; background: var(--rh-ink); transition: width .4s; }
.rh-progress--busy > i { width: 35% !important; animation: rh-busy 1.2s ease-in-out infinite; }
@keyframes rh-busy { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* Theme toggle */
.rh-theme-toggle { all: unset; cursor: pointer; width: 36px; height: 36px; border-radius: var(--rh-r-ctl); display: grid; place-items: center; color: inherit; }
.rh-theme-toggle:hover { background: rgba(127, 127, 127, .15); }
.rh-theme-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ---------------------------------------------------------------------------
   Responsive — admin shell collapses to a top bar + slide-out nav
   ------------------------------------------------------------------------ */
.rh-menu-btn { display: none; }
@media (max-width: 860px) {
  .rh-app { grid-template-columns: 1fr; }
  .rh-sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 80; transform: translateX(-100%); transition: transform .2s ease; }
  .rh-sidebar.is-open { transform: none; box-shadow: var(--rh-shadow-lg); }
  .rh-menu-btn { display: inline-flex; }
  .rh-topbar { padding: 10px 14px; }
  .rh-container { padding: 16px 14px 32px; }
  .rh-kpi { flex-basis: 45%; border-bottom: 1px solid var(--rh-line); }
}

/* Live scan: new pins drop in + a pulsing "scan running" chip in the top bar */
@keyframes rh-pin-pop { 0% { transform: rotate(-45deg) scale(0) translateY(-30px); opacity: 0; }
  70% { transform: rotate(-45deg) scale(1.35); opacity: 1; } 100% { transform: rotate(-45deg) scale(1); } }
.rh-pin--pop { animation: rh-pin-pop .6s cubic-bezier(.2,.9,.3,1.3) both; }
.rh-live { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; padding: 6px 12px;
  border-radius: 999px; background: var(--rh-c-warm-bg); color: var(--rh-c-warm); white-space: nowrap; }
.rh-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: rh-live 1.4s ease-in-out infinite; }
@keyframes rh-live { 50% { opacity: .25; transform: scale(.7); } }
@media (max-width: 720px) { .rh-live { font-size: 12px; padding: 4px 9px; } }
