/* Heading actions stay in normal flow; neither menu nor buttons cover facts. */
#buyer-main[data-page="analysis"] .buyer-property-tools {grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-items:stretch;}
.buyer-property-tools > .buyer-button {min-height:44px;box-sizing:border-box;}
#buyer-analysis-form {scroll-margin-top:100px;}
#buyer-main[data-page="analysis"] .buyer-listing-links .buyer-button {min-height:44px;box-sizing:border-box;}
.buyer-property-details {position:relative;}
.buyer-property-details>.buyer-heading-share {position:absolute;right:0;top:0;min-height:36px;padding:6px 14px;border:1px solid #294e74;background:#fff;color:#294e74;}
@media(max-width:767px){.buyer-property-tools > .buyer-button{font-size:13px;}}

#buyer-main .buyer-property-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 1px 0 6px;
}
.buyer-property-badges span {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
}
.buyer-property-badges .buyer-property-location { background: #e6eff8; color: #294967; }
.buyer-property-badges .buyer-property-type { background: #edf1f4; color: #435367; }
#buyer-main .buyer-property-heading h1 {
  color: #102f59;
  font-size: clamp(24px, 2.25vw, 32px);
  font-weight: 650;
  line-height: 1.15;
  margin: 0 0 3px;
  overflow-wrap: anywhere;
}
#buyer-main .buyer-property-heading .buyer-property-subtitle {
  color: #596d80;
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 6px;
}
#buyer-main .buyer-property-heading .buyer-property-facts { padding-block: 4px; }
#buyer-main .buyer-property-heading :is(.buyer-property-prices-primary, .buyer-property-prices-secondary) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 12px;
}
.buyer-property-prices-primary > div { grid-column: span 2; }
#buyer-main .buyer-property-heading .buyer-property-prices-primary dd {
  color: #102f59;
  font-size: clamp(20px, 2.05vw, 29px);
  line-height: 1.14;
  font-weight: 680;
  letter-spacing: -.015em;
}
.buyer-property-prices-primary .buyer-missing { font-size: inherit; }
.buyer-property-prices-secondary dt { min-height: 1.4em; }
#buyer-main .buyer-property-heading .buyer-property-prices-secondary dd { font-size: 14px; font-weight: 550; }
#buyer-main .buyer-profile-actions {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
#buyer-main .buyer-profile-actions > .buyer-profile-summary-trigger {
  anchor-name: --buyer-profile-trigger;
  min-height: 44px;
  margin-left: auto;
  padding: 4px 0 4px 6px;
  gap: 4px;
  color: #596d80;
  background: transparent;
  border-color: transparent;
  font-weight: 500;
  text-align: right;
}
#buyer-main .buyer-profile-actions > .buyer-profile-summary-trigger:hover {
  color: #183a5e;
  text-decoration: underline;
}
.buyer-profile-summary-trigger svg { width: 12px; height: 12px; flex: none; }
.buyer-profile-summary-trigger:has(+ :popover-open) svg { transform: rotate(180deg); }
.buyer-profile-summary-popover {
  width: min(320px, calc(100vw - 36px));
  max-height: calc(100dvh - 36px);
  overflow: auto;
  box-sizing: border-box;
  padding: 14px 16px;
  border: 1px solid #c9daed;
  border-radius: 10px;
  background: #fff;
  color: #203142;
  box-shadow: 0 8px 24px rgb(16 47 89 / 15%);
}
@supports (top: anchor(bottom)) {
  .buyer-profile-summary-popover {
    position: fixed;
    position-anchor: --buyer-profile-trigger;
    inset: auto;
    margin: 0;
    right: anchor(right);
    top: calc(anchor(bottom) + 6px);
    position-try-fallbacks: flip-block;
  }
}
.buyer-profile-summary-popover h2 { margin: 0 0 8px; color: #183a5e; font-size: 14px; }
.buyer-profile-summary-popover dl { margin: 0; }
.buyer-profile-summary-popover dl > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #edf1f4;
  font-size: 12px;
}
.buyer-profile-summary-popover dt { color: #596d80; }
.buyer-profile-summary-popover dd { margin: 0; font-weight: 600; }
.buyer-profile-summary-popover p { margin: 9px 0 0; color: #596d80; font-size: 11px; }
#buyer-main[data-page="analysis"] .buyer-property-tools > .buyer-button {
  background: #fff;
  border-color: #b9c9d9;
  color: #183a5e;
}
#buyer-main[data-page="analysis"] .buyer-property-tools > .buyer-button:enabled:hover,
#buyer-main[data-page="analysis"] .buyer-property-tools > [aria-pressed="true"] {
  background: #edf4fb;
  border-color: #8ca9c4;
  color: #183a5e;
}
#buyer-main[data-page="analysis"] .buyer-property-tools > .buyer-profile-attention { border-color: #b42318; }
@media (max-width: 520px) {
  #buyer-main .buyer-profile-actions { gap: 6px; }
  #buyer-main .buyer-profile-actions .buyer-listing-links { flex-wrap: nowrap; gap: 8px; }
  #buyer-main .buyer-profile-actions .buyer-listing-links > .buyer-button {
    gap: 4px;
    font-size: 11px;
    white-space: nowrap;
  }
  #buyer-main .buyer-profile-actions > .buyer-profile-summary-trigger {
    padding-left: 0;
    font-size: 11px;
    white-space: nowrap;
  }
  .buyer-profile-actions .buyer-listing-logo-frame,
  .buyer-profile-actions .buyer-listing-logo { width: 17px; height: 17px; }
  .buyer-profile-actions .buyer-listing-logo-realestate .buyer-listing-logo { width: 32.5px; height: 17px; }
  #buyer-main .buyer-property-heading .buyer-property-subtitle { font-size: 13px; }
  #buyer-main .buyer-property-heading :is(.buyer-property-prices-primary, .buyer-property-prices-secondary) { column-gap: 6px; }
  :is(.buyer-property-prices-primary, .buyer-property-prices-secondary) > div { padding-left: 5px; }
  .buyer-property-prices-secondary dt { font-size: 10px; min-height: 2.6em; }
  #buyer-main .buyer-property-heading .buyer-property-prices-secondary dd { font-size: 12px; }
  .buyer-property-prices-secondary dd small { font-size: 10px; }
}
@media (max-width: 420px) {
  #buyer-main .buyer-property-heading .buyer-property-prices-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    row-gap: 10px;
  }
  .buyer-property-prices-secondary dt { font-size: 11px; min-height: 0; }
}
@media (max-width: 375px) {
  #buyer-main .buyer-profile-actions .buyer-listing-links { gap: 5px; }
  #buyer-main .buyer-profile-actions .buyer-listing-links > .buyer-button,
  #buyer-main .buyer-profile-actions > .buyer-profile-summary-trigger { gap: 3px; font-size: 10px; }
}
@media (max-width: 345px) {
  #buyer-main .buyer-profile-actions .buyer-listing-links > .buyer-button,
  #buyer-main .buyer-profile-actions > .buyer-profile-summary-trigger { white-space: normal; }
}

/* Core assumptions need room for the number, unit and action on a phone. */
@media (max-width: 767px) {
  #buyer-main[data-page="analysis"] .buyer-summary-editable { grid-column: 1 / -1; }
  #buyer-main[data-page="analysis"] .buyer-inline-update {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  #buyer-main[data-page="analysis"] .buyer-inline-update .buyer-field-unit { min-width: 0; min-height: 46px; height: auto; }
  #buyer-main[data-page="analysis"] .buyer-inline-update input { height: 44px; min-height: 44px; font-size: 16px; }
  #buyer-main[data-page="analysis"] .buyer-inline-update button { min-height: 44px; }
}

/* Analysis-only typography: keep the blue/green surfaces and their hierarchy. */
#buyer-main[data-page="analysis"] :is(.buyer-summary-card-costs, #buyer-editor-costs) {
  --buyer-muted: #41586c;
}
#buyer-main[data-page="analysis"] :is(.buyer-summary-card-rental, #buyer-editor-rental) {
  --buyer-muted: #3d5745;
}
#buyer-main[data-page="analysis"] :is(.buyer-summary-card-costs, .buyer-summary-card-rental) .buyer-field-unit span {
  color: var(--buyer-muted);
  font-size: 12px;
  line-height: 1.4;
  padding-inline: 8px;
}
#buyer-main[data-page="analysis"] .buyer-inline-update {
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 8px;
}
#buyer-main[data-page="analysis"] .buyer-inline-update > .buyer-button {
  min-height: 46px;
  height: auto;
  padding: 7px 8px;
  font-size: 13px;
  line-height: 1.35;
}
#buyer-main[data-page="analysis"] :is(.buyer-summary-card-costs, .buyer-summary-card-rental) .buyer-summary-caption {
  margin: 10px 0;
  color: var(--buyer-muted);
  font-size: 12px;
  line-height: 1.55;
}
#buyer-main[data-page="analysis"] :is(.buyer-summary-card-costs, .buyer-summary-card-rental) :is(.buyer-summary-main dt, .buyer-summary-metrics dt) {
  color: var(--buyer-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Read-only values need less vertical space than editable, touch-sized fields. */
#buyer-main[data-page="analysis"] #buyer-basic-analysis .buyer-summary-metrics {
  row-gap: 12px;
}
#buyer-main[data-page="analysis"] #buyer-basic-analysis .buyer-summary-metrics > div:not(.buyer-summary-editable) > dd {
  min-height: 24px;
  margin-top: 2px;
  line-height: 1.5;
}
#buyer-main[data-page="analysis"] #buyer-basic-analysis .buyer-basic-fields {
  padding-bottom: 12px;
}

/* Detailed editors retain desktop geometry; only their small-screen fields stack. */
#buyer-main[data-page="analysis"] .buyer-analysis-editor :is(.buyer-form-field, .buyer-form-footnote, .buyer-field-unit span, .buyer-result-row > span:first-child) {
  color: var(--buyer-muted);
}
#buyer-main[data-page="analysis"] .buyer-analysis-editor :is(.buyer-field-unit span, .buyer-form-footnote, .buyer-form-field small) {
  font-size: 12px;
  line-height: 1.55;
}
@media (max-width: 767px) {
  #buyer-main[data-page="analysis"] .buyer-analysis-editor .buyer-form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  #buyer-main[data-page="analysis"] .buyer-analysis-editor :is(.buyer-input, .buyer-select, .buyer-field-unit input) {
    box-sizing: border-box;
    min-height: 44px;
    font-size: 16px;
    line-height: 1.5;
  }
  #buyer-main[data-page="analysis"] .buyer-analysis-editor .buyer-field-unit {
    min-height: 46px;
  }
  #buyer-main[data-page="analysis"] .buyer-analysis-editor .buyer-field-unit input {
    flex: 1 1 0;
    width: 0;
    padding: 10px;
  }
  #buyer-main[data-page="analysis"] .buyer-analysis-editor .buyer-field-unit span {
    flex: 0 1 auto;
    max-width: 48%;
    padding-inline: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #buyer-main[data-page="analysis"] .buyer-analysis-editor .buyer-form-field {
    font-size: 13px;
  }
  #buyer-main[data-page="analysis"] .buyer-analysis-editor .buyer-button {
    min-height: 44px;
    white-space: normal;
  }
}
