/* ============================================================================
   ATLAS REDESIGN — CMA Generator screen styles  ·  Wave-3 rebuild (2026-07-04)
   Branch: atlas-redesign-2026-06-29

   Prefix: .rd-cma. Tokens only (--r-*) — Calm (almanac) + Operator themes both
   work automatically. Two-stage screen: instant AVM estimate (range band +
   real comp table) → full CMA (ranked comps w/ expandable adjustments,
   narrative, listing history, sources). Nothing here fabricates — empty/error
   surfaces are styled to read cleanly with em-dashes.
   ========================================================================== */

.rd-cma {
  font-family: var(--r-font-body);
  color: var(--r-body);
  padding: var(--r-gutter);
  max-width: var(--r-page-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- header row ---------------------------------------------------------- */
.rd-cma-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.rd-cma-head-l { display: flex; flex-direction: column; gap: 6px; }
.rd-cma-eyebrow {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-clay);
}
.rd-cma-h1 {
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h1);
  font-weight: 600;
  line-height: 1.1;
  color: var(--r-ink);
  margin: 0;
}
.rd-cma-sub { margin: 0; font-size: 13.5px; color: var(--r-muted); }
.rd-cma-head-r { display: flex; align-items: center; gap: 10px; }

/* secondary "New CMA" button */
.rd-cma-new {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  background: var(--r-surface);
  color: var(--r-body);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-control);
  font-family: var(--r-font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--r-dur) var(--r-ease),
              border-color var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease);
}
.rd-cma-new i { font-size: 15px; color: var(--r-muted); }
.rd-cma-new:hover { background: var(--r-canvas-raised); border-color: var(--r-muted); }
.rd-cma-new:active { transform: translateY(1px); }
.rd-cma-new:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* ---- address form + quick-pick chips + status ----------------------------- */
.rd-cma-form { display: flex; gap: 10px; margin: 4px 0 0; }
.rd-cma-addr {
  flex: 1 1 auto; height: 40px; padding: 0 14px;
  border: 1px solid var(--r-border); border-radius: var(--r-radius-control);
  background: var(--r-canvas-raised); color: var(--r-ink);
  font-family: var(--r-font-body); font-size: 14px;
}
.rd-cma-addr:focus-visible { outline: var(--r-focus); outline-offset: 1px; }
.rd-cma-go { flex: 0 0 auto; margin-top: 0; }
.rd-cma-go:disabled { opacity: 0.6; cursor: wait; }
.rd-cma-quick { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.rd-cma-quick-lab { font-size: 12px; color: var(--r-muted); }
.rd-cma-chip {
  border: 1px solid var(--r-border); background: var(--r-canvas-raised);
  color: var(--r-body); border-radius: var(--r-radius-pill);
  padding: 4px 11px; font-size: 12px; cursor: pointer;
  transition: border-color var(--r-dur) var(--r-ease), color var(--r-dur) var(--r-ease);
}
.rd-cma-chip:hover { border-color: var(--r-primary); color: var(--r-primary); }
.rd-cma-chip:focus-visible { outline: var(--r-focus); outline-offset: 2px; }
.rd-cma-status {
  padding: 10px 14px;
  border: 1px solid var(--r-border); border-radius: var(--r-radius-card);
  background: var(--r-canvas-raised); font-size: 13px; color: var(--r-body);
  font-variant-numeric: tabular-nums;
}
.rd-cma-status[data-tone="good"]  { border-color: color-mix(in srgb, var(--r-good) 45%, transparent); }
.rd-cma-status[data-tone="alert"] { border-color: color-mix(in srgb, var(--r-alert) 45%, transparent); color: var(--r-alert); }

/* ---- subject bar ---------------------------------------------------------- */
.rd-cma-subject {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 14px 18px;
}
.rd-cma-subject-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-radius-control);
  background: var(--r-mint-surface);
  color: var(--r-mint-ink);
}
.rd-cma-subject-icon i { font-size: 22px; }
.rd-cma-subject-id { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rd-cma-subject-addr {
  font-size: 15px; font-weight: 600; color: var(--r-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rd-cma-subject-spec { font-size: 12.5px; color: var(--r-muted); }
.rd-cma-subject-prompt { font-size: 13.5px; color: var(--r-muted); }
.rd-cma-subject[data-empty="true"] .rd-cma-subject-icon { background: var(--r-well); color: var(--r-faint); }
.rd-cma-subject-pill {
  flex: 0 0 auto;
  font-family: var(--r-font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: .12em; line-height: 1;
  padding: 5px 10px;
  border-radius: var(--r-radius-pill);
  background: var(--r-mint-surface);
  color: var(--r-mint-ink);
}

/* ---- main grid (comps | side) --------------------------------------------- */
.rd-cma-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
  min-height: 0;
  animation: rdCmaIn .28s var(--r-ease);
}
@keyframes rdCmaIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .rd-cma-grid { animation: none; } }

/* ---- content cards -------------------------------------------------------- */
.rd-cma-comps {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 16px;
}
.rd-cma-main .rd-cma-comps:last-child { margin-bottom: 0; }
.rd-cma-comps-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rd-cma-comps-title {
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h2);
  font-weight: 600;
  color: var(--r-ink);
  margin: 0;
}
.rd-cma-comps-note { font-size: 12px; color: var(--r-muted); }
.rd-cma-comps-empty {
  font-family: var(--r-font-mono);
  font-size: 12px; line-height: 1.5;
  color: var(--r-faint);
  text-align: center;
  padding: 34px 16px; margin-top: 14px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius-control);
}
.rd-cma-comps-empty a { color: var(--r-primary); }

/* ---- comp tables ----------------------------------------------------------- */
.rd-cma-scroll { overflow-x: auto; margin-top: 12px; }
.rd-cma-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rd-cma-tbl th {
  text-align: left;
  font-family: var(--r-font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--r-faint);
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--r-hairline-2);
  white-space: nowrap;
}
.rd-cma-tbl td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--r-hairline); vertical-align: top; }
.rd-cma-row { transition: background var(--r-dur) var(--r-ease); }
.rd-cma-row:hover { background: var(--r-canvas-raised); }
.rd-cma-row-x { cursor: pointer; }
.rd-cma-row-x:focus-visible { outline: var(--r-focus); outline-offset: -2px; }
.rd-cma-cell-addr { min-width: 180px; }
.rd-cma-cell-a { display: block; font-weight: 600; color: var(--r-ink); }
.rd-cma-cell-m { display: block; font-size: 11.5px; color: var(--r-muted); margin-top: 2px; }
.rd-cma-cell-num { font-family: var(--r-font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-cma-cell-adj { color: var(--r-primary); font-weight: 600; }
.rd-cma-caret {
  font-size: 12px; color: var(--r-faint);
  margin-right: 6px;
  display: inline-block;
  transition: transform var(--r-dur) var(--r-ease);
}
.rd-cma-row-x.is-open .rd-cma-caret { transform: rotate(90deg); }

/* expandable adjustments row */
.rd-cma-xrow td {
  background: var(--r-canvas-raised);
  border-bottom: 1px solid var(--r-hairline);
  padding: 12px 14px;
}
.rd-cma-why { margin: 0 0 8px; font-size: 12.5px; line-height: 1.5; color: var(--r-body); }
.rd-cma-adjs { display: flex; flex-direction: column; gap: 4px; }
.rd-cma-adjs-lab {
  font-family: var(--r-font-mono);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--r-faint);
  margin-bottom: 2px;
}
.rd-cma-adjrow { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; }
.rd-cma-adjamt {
  font-family: var(--r-font-mono);
  font-weight: 600;
  min-width: 84px;
  color: var(--r-good);
}
.rd-cma-adjamt[data-neg="1"] { color: var(--r-alert); }
.rd-cma-adjwhy { color: var(--r-muted); }

/* ---- side column ------------------------------------------------------------ */
.rd-cma-side { display: flex; flex-direction: column; gap: 16px; }

/* estimate / valuation card */
.rd-cma-estimate {
  background: var(--r-surface);
  border: 1px solid color-mix(in srgb, var(--r-primary) 28%, var(--r-border));
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 22px;
  display: flex;
  flex-direction: column;
}
.rd-cma-estimate-eyebrow {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--r-primary);
}
.rd-cma-estimate-eyebrow i { font-size: 14px; }
.rd-cma-estimate-tag { font-size: 11.5px; color: var(--r-faint); margin-top: 4px; }
.rd-cma-estimate-value {
  font-family: var(--r-font-display);
  font-size: 38px; font-weight: 600; line-height: 1.05;
  color: var(--r-ink);
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}
.rd-cma-estimate-sub { font-size: 13px; color: var(--r-muted); margin-top: 4px; }

/* range band: low ——●—— high */
.rd-cma-band { margin-top: 18px; }
.rd-cma-band-track {
  position: relative;
  height: 8px;
  border-radius: var(--r-radius-pill);
  background: var(--r-hairline);
  overflow: visible;
}
.rd-cma-band-fill {
  position: absolute; inset: 0;
  width: 0;
  border-radius: var(--r-radius-pill);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--r-primary) 35%, transparent),
    var(--r-primary));
  transition: width .5s var(--r-ease);
}
.rd-cma-band-fill.is-in { width: 100%; }
.rd-cma-band-mark {
  position: absolute; top: 50%;
  width: 16px; height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--r-surface);
  border: 3px solid var(--r-primary);
  box-shadow: 0 1px 3px rgba(33, 31, 26, .25);
}
.rd-cma-band-ends {
  display: flex; justify-content: space-between;
  margin-top: 7px;
  font-family: var(--r-font-mono);
  font-size: 11.5px; font-weight: 600;
  color: var(--r-muted);
  font-variant-numeric: tabular-nums;
}

/* confidence pill + note */
.rd-cma-confrow { margin-top: 16px; }
.rd-cma-confpill {
  display: inline-flex; align-items: center;
  font-family: var(--r-font-mono);
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  line-height: 1;
  padding: 6px 11px;
  border-radius: var(--r-radius-pill);
  border: 1px solid var(--r-border);
  color: var(--r-muted);
  background: var(--r-canvas-raised);
}
.rd-cma-confpill[data-conf="high"] { color: var(--r-good); border-color: color-mix(in srgb, var(--r-good) 45%, transparent); }
.rd-cma-confpill[data-conf="med"]  { color: var(--r-amber); border-color: color-mix(in srgb, var(--r-amber) 45%, transparent); }
.rd-cma-confpill[data-conf="low"]  { color: var(--r-alert); border-color: color-mix(in srgb, var(--r-alert) 45%, transparent); }
.rd-cma-confnote { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--r-muted); }

/* $/sqft strip (AVM stage) */
.rd-cma-ppsf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.rd-cma-ppsf-tile {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--r-canvas-raised);
  border: 1px solid var(--r-hairline);
  border-radius: var(--r-radius-control);
  padding: 9px 11px;
}
.rd-cma-ppsf-lab { font-family: var(--r-font-mono); font-size: 9.5px; letter-spacing: .08em; color: var(--r-faint); }
.rd-cma-ppsf-val { font-family: var(--r-font-mono); font-size: 14px; font-weight: 600; color: var(--r-ink); }

/* recommended launch (full CMA) */
.rd-cma-launch {
  display: flex; flex-direction: column; gap: 3px;
  margin-top: 14px;
  padding: 11px 13px;
  background: var(--r-mint-surface);
  border-radius: var(--r-radius-control);
}
.rd-cma-launch-lab {
  font-family: var(--r-font-mono);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--r-mint-ink);
}
.rd-cma-launch-val { font-family: var(--r-font-mono); font-size: 17px; font-weight: 700; color: var(--r-mint-ink); }
.rd-cma-launch-val em { font-style: normal; font-size: 12px; font-weight: 600; opacity: .8; }

.rd-cma-srcline { margin-top: 12px; font-size: 12px; color: var(--r-muted); }

/* action row: open report + copy link */
.rd-cma-actions { display: flex; gap: 10px; align-items: stretch; }
.rd-cma-actions .rd-cma-generate { flex: 1 1 auto; }
.rd-cma-copybtn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 20px;
  padding: 0 14px;
  background: var(--r-surface);
  color: var(--r-body);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-control);
  font-family: var(--r-font-body);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: border-color var(--r-dur) var(--r-ease), color var(--r-dur) var(--r-ease);
}
.rd-cma-copybtn:hover { border-color: var(--r-primary); color: var(--r-primary); }
.rd-cma-copybtn:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* primary generate button */
.rd-cma-generate {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px;
  margin-top: 20px;
  padding: 0 16px;
  background: var(--r-primary);
  color: var(--r-primary-ink);
  border: none;
  border-radius: var(--r-radius-control);
  font-family: var(--r-font-body);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: filter var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease),
              box-shadow var(--r-dur) var(--r-ease);
}
.rd-cma-generate i { font-size: 15px; }
.rd-cma-generate:hover { filter: brightness(1.06); box-shadow: var(--r-shadow-hover); transform: translateY(-1px); }
.rd-cma-generate:active { transform: translateY(0); }
.rd-cma-generate:focus-visible { outline: var(--r-focus); outline-offset: 2px; }
.rd-cma-generate:disabled {
  cursor: not-allowed; opacity: .5;
  filter: none; box-shadow: none; transform: none;
}
.rd-cma-open { text-decoration: none; }

.rd-cma-fineprint { margin: 12px 0 0; font-size: 11px; line-height: 1.5; color: var(--r-faint); }

/* fallback CTA (AVM failed → offer the full pipeline) */
.rd-cma-fallback { display: flex; justify-content: center; padding: 8px 0; }
.rd-cma-fallback .rd-cma-generate { margin-top: 4px; }

/* ---- narrative ("Pricing story") -------------------------------------------- */
.rd-cma-points { margin: 14px 0 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.rd-cma-points li { font-size: 13.5px; line-height: 1.55; color: var(--r-body); }
.rd-cma-bottom {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--r-primary);
  background: var(--r-canvas-raised);
  border-radius: 0 var(--r-radius-control) var(--r-radius-control) 0;
  font-size: 14px; line-height: 1.55; font-weight: 600;
  color: var(--r-ink);
}
.rd-cma-read { margin: 14px 0 0; font-size: 13px; line-height: 1.6; color: var(--r-muted); }
.rd-cma-script { margin-top: 14px; }
.rd-cma-script summary {
  cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--r-primary);
}
.rd-cma-script summary:focus-visible { outline: var(--r-focus); outline-offset: 2px; }
.rd-cma-script p { margin: 10px 0 0; font-size: 13px; line-height: 1.6; color: var(--r-body); }

/* ---- note / external AVMs / sources ------------------------------------------ */
.rd-cma-note {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--r-well);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  padding: 13px 15px;
}
.rd-cma-note i { color: var(--r-primary); font-size: 16px; flex: 0 0 auto; margin-top: 1px; }
.rd-cma-note p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--r-muted); }
.rd-cma-extavms-lab { font-weight: 600; color: var(--r-body); margin-bottom: 6px; }
.rd-cma-extavm {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12.5px; color: var(--r-muted);
  padding: 3px 0;
}
.rd-cma-extavm b { font-family: var(--r-font-mono); color: var(--r-ink); }
.rd-cma-sources {
  margin: 0; padding: 0 4px;
  font-family: var(--r-font-mono);
  font-size: 10.5px; line-height: 1.6;
  color: var(--r-faint);
}

/* ---- responsive ---------------------------------------------------------------- */
@media (max-width: 980px) {
  .rd-cma-grid { grid-template-columns: 1fr; }
  .rd-cma-estimate-value { font-size: 32px; }
}
@media (max-width: 480px) {
  .rd-cma { padding: 14px; }
  .rd-cma-form { flex-direction: column; }
  .rd-cma-go { width: 100%; }
  .rd-cma-actions { flex-direction: column; }
  .rd-cma-copybtn { margin-top: 10px; height: 40px; }
  .rd-cma-ppsf { grid-template-columns: 1fr 1fr; }
  .rd-cma-cell-addr { min-width: 140px; }
}
