/* ============================================================
   MAGENTA GROUP — Real Estate Calculator
   Charcoal Dark · Brand: #BE0055 magenta
   ============================================================ */

:root {
  --mg:          #BE0055;
  --mg-dark:     #96003F;
  --mg-bright:   #D4006A;
  --mg-glow:     rgba(190,0,85,.2);
  --mg-subtle:   rgba(190,0,85,.07);

  --bg:          #F7F7FA;
  --bg2:         #FFFFFF;
  --bg3:         #F0F1F5;
  --card:        #FFFFFF;
  --card2:       #FAFAFD;
  --border:      #E5E6ED;
  --border2:     #D5D6DF;

  --text:        #1A1B22;
  --text2:       #5A5C6B;
  --text3:       #8B8D9E;
  --label:       #6D6F7E;

  --positive:    #1FAB5E;
  --negative:    #E0415B;
  --neutral:     #BE0055;
  --nav-bg:      #13141A;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.nav-logo {
  height: 26px;
  width: auto;
  margin-right: 2rem;
  flex-shrink: 0;
  background: #fff;
  padding: 5px 9px;
  border-radius: 6px;
  box-sizing: content-box;
}
.nav-links { display: flex; gap: .1rem; }
.nav-link {
  color: var(--text3);
  text-decoration: none;
  padding: .3rem .75rem;
  border-radius: 5px;
  font-size: .78rem;
  font-weight: 500;
  transition: color .15s, background .15s;
  letter-spacing: .01em;
}
.nav-link:hover { color: var(--text); background: var(--bg3); }
.nav-link.active { color: #fff; background: var(--mg); font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.client-badge {
  background: var(--mg-subtle);
  color: var(--mg);
  border: 1px solid var(--mg);
  border-radius: 4px;
  padding: .2rem .65rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-content {
  height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: .6rem .75rem .5rem;
  gap: .5rem;
}

/* ============================================================
   PROPERTY HEADER BAR
   ============================================================ */
.property-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .5rem .9rem;
  flex-shrink: 0;
  border-left: 3px solid var(--mg);
  box-shadow: 0 1px 3px rgba(25,30,60,.06);
}
.prop-meta-line { display: flex; align-items: center; gap: .55rem; margin-top: .05rem; flex-wrap: wrap; }
.zillow-link {
  font-size: .68rem;
  color: var(--mg);
  font-weight: 700;
  text-decoration: none;
  background: var(--mg-subtle);
  padding: .1rem .45rem;
  border-radius: 4px;
  transition: background .15s;
}
.zillow-link:hover { background: rgba(190,0,85,.15); }
.prop-unit-chip {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  background: var(--mg-subtle);
  color: var(--mg);
  border: 1px solid rgba(190,0,85,.3);
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 700;
  padding: .05rem .4rem;
  letter-spacing: .02em;
  line-height: 1.4;
}
.prop-unit-chip #prop_unit_chip_count { font-size: .75rem; font-weight: 800; }
.prop-identity { flex: 1; min-width: 0; }
.prop-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}
.prop-title:hover .edit-icon { opacity: 1; }
.edit-icon { font-size: .7rem; color: var(--mg); opacity: 0; transition: opacity .15s; }
.prop-address-line {
  font-size: .72rem;
  color: var(--text3);
  cursor: pointer;
  margin-top: .05rem;
  transition: color .15s;
}
.prop-address-line:hover { color: var(--mg); }
.prop-header-actions { display: flex; gap: .4rem; align-items: center; }
/* Mobile-only buttons + labels — hidden on desktop, shown in the mobile media query. */
.mobile-actions-btn,
.prop-edit-btn-mobile,
.refi-section-heading,
.cashflow-card { display: none; }

/* Desktop column headers — labels above the Current / After Refi columns */
.col-header { display: none; }

/* Desktop-only bar + KPI head inside the Cashflow card — hidden by default
   (mobile shows the top-of-page versions), shown on desktop via media query. */
.cf-head { display: none; }

/* Unit selector inside property header */
.prop-unit-wrap {
  display: flex;
  align-items: center;
  gap: .45rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 7px;
  padding: .2rem .55rem .2rem .65rem;
  height: 32px;
}
.prop-unit-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mg);
}
.prop-unit-select {
  appearance: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: .88rem;
  font-weight: 700;
  padding: 0 .9rem 0 .15rem;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23BE0055' d='M0 3l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .05rem center;
}
.prop-unit-select option { background: var(--bg3); color: #fff; }

/* Auto badge on readonly totals */
.auto-badge {
  background: var(--mg-subtle);
  color: var(--mg);
  border-radius: 3px;
  padding: .05rem .3rem;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* Property selector */
.prop-select-wrap { position: relative; }
/* Searchable property combobox (replaces the old native <select>) */
.prop-combo-wrap {
  position: relative;
  min-width: 220px;
  max-width: 280px;
}
.prop-combo {
  width: 100%;
  height: 30px;
  padding: .3rem 1.7rem .3rem .7rem;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: #FFFFFF;
  color: var(--text);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
}
.prop-combo:focus { outline: none; border-color: var(--mg); box-shadow: 0 0 0 3px var(--mg-glow); cursor: text; }
.prop-combo::placeholder { color: var(--text3); font-weight: 500; }
.prop-combo-caret {
  position: absolute;
  right: .55rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--mg);
  font-size: .72rem;
}
.prop-combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #FFFFFF;
  border: 1px solid var(--border2);
  border-radius: 7px;
  box-shadow: 0 12px 32px rgba(25,30,60,.18);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  padding: .25rem;
}
.prop-combo-item {
  padding: .4rem .6rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: .78rem;
  line-height: 1.25;
}
.prop-combo-item:hover,
.prop-combo-item.highlight { background: var(--mg-subtle); }
.prop-combo-item.active    { background: var(--mg); color: #fff; }
.prop-combo-item.active .pci-sub { color: rgba(255,255,255,.8); }
.pci-name { font-weight: 600; }
.pci-sub  { font-size: .68rem; color: var(--text3); margin-top: 1px; }
.prop-combo-empty {
  padding: .6rem .75rem;
  font-size: .74rem;
  color: var(--text3);
  text-align: center;
}

/* ============================================================
   CALCULATOR GRID
   ============================================================ */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 300px;
  gap: .6rem;
  flex: 1;
  min-height: 0;
}

/* ============================================================
   SUMMARY SIDEBAR (desktop right column)
   ============================================================ */
.summary-card {
  padding: 1rem 1.1rem 1.1rem;
}
.summary-cf { text-align: center; margin-bottom: .75rem; }
.summary-cf .summary-kicker {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: #A89AB8;
  margin-bottom: .15rem;
}
.summary-cf .big-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.05;
}
.summary-cf .summary-sub { font-size: .72rem; color: #A89AB8; margin-top: .15rem; font-weight: 600; }

.summary-donut-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 .5rem;
}
/* No fade — segments stay fully vibrant; active segment marked by stroke-width only */

/* Segment tabs — double as a legend (shared style for desktop + mobile drawer) */
.segment-tabs {
  display: flex;
  gap: .2rem;
  margin: .35rem 0 .9rem;
  padding: .25rem;
  background: rgba(0,0,0,.2);
  border-radius: 8px;
}
.seg-tab,
.sb-seg-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  background: transparent;
  border: none;
  color: #A89AB8;
  font-size: .62rem;
  font-weight: 700;
  padding: .4rem .25rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.seg-tab .dot,
.sb-seg-tab .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.seg-tab:hover,
.sb-seg-tab:hover {
  color: #fff;
  background: rgba(255,255,255,.05);
}
.seg-tab.active,
.sb-seg-tab.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

/* Contextual detail panel */
.summary-details {
  margin-top: .2rem;
  padding-top: .75rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.details-title {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #A89AB8;
  margin-bottom: .5rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .3rem 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: .78rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .dl-label { color: #A89AB8; font-weight: 600; font-size: .72rem; }
.detail-row .dl-value { font-weight: 700; color: #F5F5FA; }
.detail-row .dl-value.accent { color: var(--mg); }

.summary-kpis {
  display: flex;
  gap: .5rem;
  margin: 0 0 .75rem;
  padding: 0;
  background: transparent;
  justify-content: stretch;
}
.summary-kpis .kpi {
  flex: 1;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
  padding: .55rem .5rem;
  text-align: center;
}
.summary-kpis .kpi-label {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #A89AB8;
  margin-bottom: .15rem;
}
.summary-kpis .kpi-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}
.summary-kpis .kpi-divider { display: none; }

.summary-card .summary-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  margin: .3rem 0 .35rem;
}

.summary-card .summary-metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .3rem 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: .78rem;
}
.summary-card .summary-metric:last-child { border-bottom: none; }
.summary-card .metric-label { color: #A89AB8; font-size: .68rem; font-weight: 600; }
.summary-card .metric-value { font-weight: 700; color: #F5F5FA; }
.calc-col {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  overflow-y: auto;
  padding-right: 2px;
}
.calc-col::-webkit-scrollbar { width: 3px; }
.calc-col::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.calc-col::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .55rem .75rem;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(25,30,60,.06), 0 4px 16px rgba(25,30,60,.04);
}
.field { margin-bottom: .45rem; }
.card-title {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text);
  margin-bottom: .55rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .45rem;
}
.card-title::before {
  content: "";
  display: inline-block;
  width: 4px; height: 14px;
  background: var(--mg);
  border-radius: 2px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.field { margin-bottom: .55rem; }
.field:last-child { margin-bottom: 0; }

label.field-label {
  display: block;
  font-size: .68rem;
  font-weight: 500;
  color: var(--label);
  margin-bottom: .2rem;
  letter-spacing: .02em;
}

.input-prefix-wrap { position: relative; display: flex; align-items: center; }
.input-prefix { position: absolute; left: 8px; color: var(--text3); font-size: .78rem; pointer-events: none; }
.input-suffix { position: absolute; right: 8px; color: var(--text3); font-size: .78rem; pointer-events: none; }

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: .28rem .65rem;
  border: 1px solid var(--border2);
  border-radius: 6px;
  font-size: .82rem;
  color: var(--text);
  background: #FFFFFF;
  transition: border-color .15s, box-shadow .15s;
  -moz-appearance: textfield;
  height: 28px;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input:focus {
  outline: none;
  border-color: var(--mg);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px var(--mg-glow);
}
input::placeholder { color: var(--text3); }
.has-prefix input { padding-left: 22px; }
.has-suffix input { padding-right: 26px; }

/* ============================================================
   SLIDERS
   ============================================================ */
.slider-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .25rem;
}
.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--border2);
  cursor: pointer;
  border: none;
  padding: 0;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--mg);
  cursor: pointer;
  border: 2px solid var(--card);
  box-shadow: 0 0 6px var(--mg-glow);
}
.slider-row input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(to right, var(--mg) var(--val, 0%), var(--border2) var(--val, 0%));
  height: 3px; border-radius: 2px;
}
.slider-pct-input { width: 52px !important; flex-shrink: 0; text-align: right; }
.slider-label { font-size: .65rem; color: var(--text3); white-space: nowrap; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .55rem;
}
.field-row:last-child { margin-bottom: 0; }

/* ============================================================
   SUMMARY CARD
   ============================================================ */
.summary-card {
  background: linear-gradient(160deg, #1F1F2B 0%, #2A1A30 100%);
  border: 1px solid #3A2940;
  color: #F5F5FA;
  flex: 1;
  padding: .9rem 1rem;
}
.summary-card .card-title { display: none; }
.summary-card .metric-value { color: #F5F5FA; }
.summary-card .big-value { color: #fff; }


.summary-metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .32rem 0;
  border-bottom: 1px solid #302030;
  font-size: .82rem;
}
.summary-metric:last-child { border-bottom: none; }
.summary-metric .metric-label { color: #A89AB8; font-size: .7rem; }
.summary-metric .metric-value { font-weight: 700; font-size: .85rem; }
.metric-value.positive { color: var(--positive); }
.metric-value.negative { color: var(--negative); }
.metric-value.neutral  { color: var(--mg); }

.summary-divider { border: none; border-top: 1px solid #3A2940; margin: .35rem 0; }

/* Donut chart */
.donut-wrap {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; padding: .4rem 0 .5rem;
}
.donut-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.summary-big { text-align: center; padding: .5rem 0 .4rem; }
.summary-big .big-label { font-size: .65rem; color: #A89AB8; margin-bottom: .15rem; letter-spacing: .08em; text-transform: uppercase; }
.summary-big .big-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }

/* ============================================================
   REFI — collapsible
   ============================================================ */
/* Refi new-loan bar — slim, sleek, precise */
.refi-bar {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: visible;
  cursor: ew-resize;
  user-select: none;
  margin: 1.1rem 0 1.9rem;
  touch-action: none;
  background: var(--border);
}
.refi-bar::before {
  /* Soft halo so the bar reads as clickable */
  content: "";
  position: absolute;
  inset: -12px 0;
}
.refi-zone {
  flex: 0 0 auto;
  min-width: 0;
  height: 100%;
  transition: flex-basis .2s;
  overflow: visible;
  position: relative;
}
.refi-zone:first-child { border-radius: 4px 0 0 4px; }
.refi-zone:last-child  { border-radius: 0 4px 4px 0; }
.refi-zone.balance  { background: linear-gradient(90deg, #3F57D4 0%, #5870FF 100%); }
.refi-zone.cashback { background: linear-gradient(90deg, #1FAB5E 0%, #3DD68C 100%); }
.refi-zone.extra    { background: linear-gradient(90deg, #BE0055 0%, #D4006A 100%); }

/* Tick markers at zone boundaries */
.refi-tick {
  position: absolute;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
}
.refi-tick .tick-label {
  font-size: .54rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 2px;
}
.refi-tick .tick-amt {
  font-size: .72rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.01em;
}
.refi-tick::after {
  /* thin guideline from bottom of tick content down to the bar */
  content: "";
  position: absolute;
  top: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 5px;
  background: var(--border2);
}

/* Position line — an elegant thumb */
.refi-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--mg);
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(190,0,85,.4), 0 0 0 4px rgba(190,0,85,.12);
  transition: left .05s linear;
  z-index: 3;
}
.refi-line::after {
  /* tiny vertical tick above/below for precision */
  content: "";
  position: absolute;
  left: 50%;
  top: -11px;
  bottom: -11px;
  width: 2px;
  background: var(--mg);
  transform: translateX(-50%);
  opacity: .5;
  border-radius: 1px;
}

.r-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: .4rem;
  vertical-align: middle;
}
.r-dot.balance  { background: #5870FF; }
.r-dot.cashback { background: #1FAB5E; }
.r-dot.extra    { background: #BE0055; }

/* ARV display line — flat readout, not input-looking */
.refi-arv-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}
.refi-arv-line .arv-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--label);
}
.refi-arv-line .arv-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

/* Interest-Only pill next to a term input */
.term-io-group {
  display: flex;
  gap: .3rem;
  align-items: stretch;
}
.term-io-group .input-prefix-wrap { flex: 1; min-width: 0; }
.io-toggle {
  flex-shrink: 0;
  min-width: 62px;
  height: 28px;
  padding: 0 .6rem;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  border-radius: 6px;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.io-toggle:hover { color: var(--mg); border-color: var(--mg); }
.io-toggle.active {
  background: var(--mg);
  color: #fff;
  border-color: var(--mg);
  box-shadow: 0 1px 5px rgba(190,0,85,.35);
}

/* Live LTV readout box — minimal row-based layout */
.refi-live-box {
  margin: .75rem 0 .3rem;
  padding: .65rem .85rem .75rem;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--mg);
}
.rlv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .25rem 0;
  font-size: .78rem;
}
.rlv-row-main {
  padding: .05rem 0 .45rem;
  margin-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.rlv-k {
  color: var(--text3);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.rlv-row-main .rlv-k {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.rlv-v { font-weight: 700; color: var(--text); }
.rlv-v.positive { color: var(--positive); }
.rlv-v.extra    { color: var(--mg); }
.rlv-v-big {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.02em;
}
.rlv-progress { margin-top: .55rem; }
.rlv-progress-track {
  height: 6px;
  background: rgba(190, 0, 85, .3);      /* track = still-in-deal (muted magenta) */
  border-radius: 3px;
  overflow: hidden;
}
.rlv-progress-fill {
  height: 100%;
  width: 0%;
  /* Fill grows over the magenta track as cash is recovered */
  background: var(--text2);
  border-radius: 3px;
  transition: width .3s ease;
}
.rlv-progress-fill.capped {
  /* >100% recovered (extra cash zone): fill finishes in green */
  background: linear-gradient(90deg, var(--text2) 0%, var(--text2) 70%, #3DD68C 100%);
}
.rlv-progress-caption {
  font-size: .6rem;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: .04em;
  margin-top: .35rem;
}

.rlv-short {
  margin-top: .65rem;
  padding: .5rem .7rem;
  background: rgba(224,65,91,.1);
  border: 1px solid rgba(224,65,91,.3);
  border-radius: 7px;
  font-size: .72rem;
  color: var(--negative);
  font-weight: 700;
}
.rlv-short span { font-weight: 800; }

/* Cash Recovery section — visual breakdown of what came back vs what's stuck */
.cash-recovery {
  margin-top: .75rem;
  padding: .65rem .75rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cr-title {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .5rem;
}
.cr-bar {
  height: 6px;
  background: var(--border2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .55rem;
}
.cr-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1FAB5E 0%, #3DD68C 100%);
  width: 0%;
  transition: width .3s ease;
}
.cr-rows { display: flex; flex-direction: column; gap: .15rem; }
.cr-row {
  display: flex; justify-content: space-between;
  font-size: .74rem; color: var(--text2);
}
.cr-row > :last-child { font-weight: 700; color: var(--text); }
.cr-row.cr-total {
  padding-top: .35rem; margin-top: .15rem;
  border-top: 1px solid var(--border);
  font-weight: 700;
}
.cr-row.cr-total > :first-child { color: var(--text); font-weight: 700; }
.cr-row.cr-total > :last-child  { color: var(--mg); }

/* Pre/Post Refi toggle inside summary card */
.refi-view-toggle {
  display: flex;
  gap: .2rem;
  margin: 0 0 .75rem;
  padding: .25rem;
  background: rgba(0,0,0,.25);
  border-radius: 8px;
}
.rvt-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #A89AB8;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .4rem .25rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rvt-btn:hover { color: #fff; background: rgba(255,255,255,.05); }
.rvt-btn.active {
  background: var(--mg);
  color: #fff;
  box-shadow: 0 1px 4px rgba(190,0,85,.35);
}

/* Compact interest-only checkbox */
.refi-io-check {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text2);
  user-select: none;
}
.refi-io-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border2);
  background: #fff;
  cursor: pointer;
  margin: 0;
  position: relative;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.refi-io-check input[type="checkbox"]:checked {
  background: var(--mg);
  border-color: var(--mg);
}
.refi-io-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.refi-io-check input[type="checkbox"]:checked + span { color: var(--mg); }


.refi-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: .45rem .8rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text2);
  flex-shrink: 0;
  transition: border-left-color .2s, color .2s;
  box-shadow: 0 1px 3px rgba(25,30,60,.06);
}
.refi-toggle:hover { border-left-color: var(--mg); color: var(--text); }
.refi-toggle.open { border-left-color: var(--mg); color: var(--mg); }
.refi-toggle .refi-arrow { font-size: .75rem; transition: transform .2s; }
.refi-toggle.open .refi-arrow { transform: rotate(90deg); }

/* Refi card body — always visible now (previously collapsible). The outer .card
   wrapper provides the background + border; this just spaces the contents. */
.refi-body { display: block; }
.refi-body.open { display: block; }
.refi-card { /* just a regular .card — inherits all default card styling */ }

.refi-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .25rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}
.refi-result-row:last-child { border-bottom: none; }
.refi-result-row .r-label { color: var(--text3); font-size: .7rem; }
.refi-result-row .r-value { font-weight: 700; font-size: .82rem; }

/* ============================================================
   BREAKDOWN
   ============================================================ */
.breakdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--mg);
  font-size: .66rem;
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .1rem 0;
  margin-top: .2rem;
  font-weight: 600;
  opacity: .8;
  transition: opacity .15s;
}
.breakdown-toggle:hover { opacity: 1; }

input.bd-locked {
  background: var(--mg-subtle) !important;
  color: var(--mg) !important;
  cursor: not-allowed !important;
  border-color: rgba(190,0,85,.3) !important;
  font-weight: 700;
}

.breakdown-panel {
  display: none;
  margin-top: .35rem;
  border: 1px solid var(--mg);
  border-radius: 7px;
  overflow: hidden;
}
.breakdown-panel.open { display: block; }

.bd-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(190,0,85,.12);
  padding: .3rem .6rem;
  border-bottom: 1px solid rgba(190,0,85,.25);
}
.bd-panel-header .bd-panel-title {
  font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--mg);
}
.bd-panel-header .bd-panel-actions { display: flex; gap: .3rem; }

.bd-view-list { padding: .25rem .6rem; background: var(--bg3); }
.bd-view-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .22rem 0; border-bottom: 1px solid var(--border); font-size: .8rem;
}
.bd-view-row:last-child { border-bottom: none; }
.bd-view-name { color: var(--text2); }
.bd-view-amt  { font-weight: 600; color: var(--text); }

.bd-edit-list { padding: .35rem .6rem; background: var(--bg3); }
.bd-edit-row { display: flex; gap: .3rem; align-items: center; margin-bottom: .3rem; }
.bd-edit-row input[type="text"]   { flex: 1; font-size: .78rem; }
.bd-edit-row input[type="number"] { width: 85px; font-size: .78rem; text-align: right; }
.bd-edit-row .remove-item {
  background: none; border: none; color: var(--border2);
  cursor: pointer; font-size: .9rem; line-height: 1; padding: 0; flex-shrink: 0;
}
.bd-edit-row .remove-item:hover { color: var(--negative); }

.add-breakdown-item {
  display: flex; align-items: center; justify-content: center; gap: .25rem;
  background: none; border: 1px dashed rgba(190,0,85,.35); border-radius: 5px;
  color: var(--mg); cursor: pointer; font-size: .72rem;
  padding: .2rem .6rem; width: 100%; margin-top: .15rem;
  transition: border-color .15s, background .15s;
}
.add-breakdown-item:hover { border-color: var(--mg); background: var(--mg-subtle); }

.bd-total-row {
  display: flex; justify-content: flex-end; align-items: center; gap: .35rem;
  padding: .25rem .6rem;
  background: rgba(190,0,85,.1);
  border-top: 1px solid rgba(190,0,85,.25);
  font-size: .75rem; color: var(--text3);
}
.bd-total-row strong { color: var(--mg); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .8rem; border-radius: 6px; border: none;
  font-size: .76rem; font-weight: 600; cursor: pointer;
  transition: all .15s; white-space: nowrap;
  height: 28px; letter-spacing: .01em;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--mg);
  color: #fff;
  box-shadow: 0 2px 8px var(--mg-glow);
}
.btn-primary:hover { background: var(--mg-bright); box-shadow: 0 4px 14px var(--mg-glow); }

.btn-secondary { background: #FFFFFF; color: var(--text2); border: 1px solid var(--border2); }
.btn-secondary:hover { border-color: var(--mg); color: var(--mg); }

.btn-danger    { background: rgba(224,65,91,.08); color: var(--negative); border: 1px solid rgba(224,65,91,.25); }
.btn-danger:hover { background: rgba(224,65,91,.15); }

.btn-ghost     { background: transparent; border: 1px solid var(--border2); color: var(--text2); }
.btn-ghost:hover { border-color: var(--mg); color: var(--mg); background: var(--mg-subtle); }

.btn-sm { padding: .2rem .55rem; font-size: .7rem; height: 24px; }

/* ============================================================
   VERSION HISTORY PANEL
   ============================================================ */
/* Saved Versions — dropdown anchored under the Versions button */
.versions-wrap { position: relative; }
.versions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 1rem);
  background: #FFFFFF;
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(25,30,60,.18);
  z-index: 200;
  padding: .4rem;
  max-height: 400px;
  overflow-y: auto;
}
.versions-title {
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: .35rem .55rem .5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .35rem;
}
.version-item {
  display: flex;
  align-items: center;
  padding: .45rem .55rem;
  border-radius: 6px;
  cursor: pointer;
  gap: .4rem;
  transition: background .12s;
}
.version-item:hover { background: var(--mg-subtle); }
.version-item.current { background: var(--mg-subtle); box-shadow: inset 3px 0 0 var(--mg); }
.version-item .vi-main { flex: 1; min-width: 0; }
.v-label { font-size: .82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-date  { font-size: .66rem; color: var(--text3); margin-top: 1px; }
.version-item .v-delete {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 1.05rem;
  line-height: 1;
  padding: .25rem .35rem;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s;
  flex-shrink: 0;
}
.version-item:hover .v-delete { opacity: .6; }
.version-item .v-delete:hover { opacity: 1; color: var(--negative); background: rgba(224,65,91,.1); }
.versions-empty {
  padding: 1.1rem .75rem;
  text-align: center;
  font-size: .78rem;
  color: var(--text3);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; bottom: 1rem; right: 1rem;
  background: #FFFFFF; color: var(--text);
  border: 1px solid var(--border2);
  padding: .55rem 1.1rem; border-radius: 8px; font-size: .8rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(25,30,60,.2);
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  z-index: 200; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 3px solid var(--positive); }
.toast.error   { border-left: 3px solid var(--negative); }

/* ============================================================
   MODAL / DIALOG
   ============================================================ */
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  width: 420px;
  max-width: 95vw;
  max-height: 90vh;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(25,30,60,.25), 0 0 0 1px rgba(190,0,85,.08);
  overflow: hidden;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  display: none;
  flex-direction: column;
}
dialog[open] { display: flex; }
.dialog-body-wrap { padding: 1.1rem 1.25rem .75rem; overflow-y: auto; flex: 1; }
dialog::backdrop { background: rgba(20,21,30,.45); backdrop-filter: blur(3px); }

.dialog-title {
  font-size: .9rem; font-weight: 800;
  color: #fff;
  background: var(--mg);
  padding: .8rem 1.25rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
dialog .dialog-field { margin-bottom: .75rem; }
dialog .dialog-field label {
  display: block; font-size: .72rem; font-weight: 600;
  color: var(--label); margin-bottom: .3rem;
}
dialog .dialog-field input[type="text"],
dialog .dialog-field input[type="password"],
dialog .dialog-field select { height: 36px; font-size: .88rem; width: 100%; }
dialog .dialog-field select {
  appearance: none;
  padding: 0 1.6rem 0 .65rem;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23BE0055' d='M0 3l5 5 5-5z'/%3E%3C/svg%3E") right .55rem center no-repeat;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.dialog-field-row { display: flex; gap: .75rem; }
.dialog-actions {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page-bg {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.login-card {
  width: 380px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.5), 0 0 0 1px rgba(190,0,85,.15);
}
.login-header {
  background: #fff;                /* match logo's native light background */
  border-bottom: 1px solid var(--border);
  padding: 2rem 2rem 1.5rem;
  text-align: center;
}
.login-logo-img {
  height: 44px;
  width: auto;
  margin-bottom: .75rem;
}
.login-sub {
  font-size: .72rem;
  color: var(--text3);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: .35rem;
}
.login-body { padding: 1.75rem 2rem; }
.login-field { margin-bottom: 1rem; }
.login-field label {
  display: block; font-size: .72rem; font-weight: 500;
  color: var(--label); margin-bottom: .35rem; letter-spacing: .03em;
}
.login-field input {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--border2);
  border-radius: 7px;
  font-size: .9rem;
  background: var(--bg3);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  height: 40px;
}
.login-field input::placeholder { color: var(--text3); }
.login-field input:focus {
  outline: none;
  border-color: var(--mg);
  box-shadow: 0 0 0 3px var(--mg-glow);
}
.login-btn {
  width: 100%; padding: .7rem;
  background: var(--mg);
  color: #fff; font-weight: 700; font-size: .88rem;
  border: none; border-radius: 7px; cursor: pointer;
  margin-top: .75rem;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 4px 16px var(--mg-glow);
  letter-spacing: .03em;
}
.login-btn:hover { background: var(--mg-bright); box-shadow: 0 6px 20px var(--mg-glow); }
.login-error {
  background: rgba(255,77,109,.1);
  color: var(--negative);
  border-radius: 7px;
  padding: .5rem .75rem;
  font-size: .8rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,77,109,.25);
}

/* ============================================================
   PROPERTIES LIST PAGE
   ============================================================ */
.page-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.properties-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.property-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: 8px;
  padding: .9rem 1rem;
  cursor: pointer;
  transition: border-left-color .2s, box-shadow .2s, transform .15s;
}
.property-card:hover {
  border-left-color: var(--mg);
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  transform: translateY(-1px);
}
.client-owner-badge {
  display: inline-block;
  background: var(--mg-subtle);
  color: var(--mg);
  border: 1px solid rgba(190,0,85,.25);
  border-radius: 4px;
  padding: .1rem .45rem;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}
.client-owner-badge.mine {
  background: transparent;
  color: var(--text3);
  border-color: var(--border2);
}
.prop-card-name { font-size: .88rem; font-weight: 700; margin-bottom: .15rem; color: var(--text); }
.prop-card-addr { font-size: .72rem; color: var(--text3); margin-bottom: .5rem; }
.prop-card-stats { display: flex; gap: .75rem; }
.prop-stat .stat-label { color: var(--text3); font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; }
.prop-stat .stat-value { font-weight: 700; font-size: .82rem; color: var(--mg); }
.prop-card-actions {
  display: flex; gap: .3rem; margin-top: .65rem;
  padding-top: .55rem; border-top: 1px solid var(--border);
}

/* ============================================================
   ADMIN TABLES
   ============================================================ */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 640px; }

.clients-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.clients-table th {
  text-align: left; padding: .5rem .75rem;
  border-bottom: 1px solid var(--border2);
  font-size: .65rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--mg); font-weight: 700;
}
.clients-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text2); }
.clients-table tr:hover td { background: var(--bg3); }
.token-cell {
  font-family: monospace; font-size: .72rem; color: var(--text3);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-link-btn {
  cursor: pointer; color: var(--mg); font-size: .72rem;
  background: none; border: none; font-weight: 600;
}
.copy-link-btn:hover { text-decoration: underline; }

/* ============================================================
   MISC
   ============================================================ */
.text-muted { color: var(--text3); font-size: .75rem; }
.mt-1 { margin-top: .35rem; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: .5rem 0; }

/* Annual badge on labels */
.annual-badge {
  background: rgba(190,0,85,.15);
  color: var(--mg);
  border-radius: 3px;
  padding: .05rem .3rem;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .04em;
  vertical-align: middle;
}
.annual-hint {
  font-size: .65rem;
  color: var(--text3);
  margin-top: .15rem;
}
.annual-hint span { color: var(--text2); font-weight: 600; }

/* Unit rent rows */
.unit-rent-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .3rem;
}
.unit-rent-label {
  font-size: .68rem;
  color: var(--label);
  white-space: nowrap;
  width: 46px;
  flex-shrink: 0;
}
.unit-rent-row .input-prefix-wrap { flex: 1; }
.empty-state { text-align: center; padding: 3rem; color: var(--text3); }
.empty-state .empty-icon { margin-bottom: .75rem; }
.empty-state p { margin-bottom: 1rem; font-size: .88rem; }
.scrollable-page { height: calc(100vh - 48px); overflow-y: auto; padding: 1.25rem; }
.scrollable-page::-webkit-scrollbar { width: 4px; }
.scrollable-page::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Inline +New button next to the property selector */
.prop-select-wrap { display: flex; gap: .4rem; align-items: center; }
.prop-select-wrap #btn_new_inline { flex-shrink: 0; }

/* Calculator is disabled until a property is loaded */
body.no-property .calc-grid input,
body.no-property .calc-grid select,
body.no-property .calc-grid button,
body.no-property .calc-grid input[type="range"],
body.no-property .calc-grid .breakdown-toggle,
body.no-property .calc-grid .refi-toggle {
  pointer-events: none !important;
  opacity: .4;
}
.no-property-banner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .9rem;
  background: var(--mg-subtle);
  border: 1px dashed rgba(190,0,85,.4);
  border-radius: 8px;
  font-size: .78rem;
  color: var(--text2);
  flex-shrink: 0;
  margin-bottom: .15rem;
}
body:not(.no-property) .no-property-banner { display: none; }
.no-property-banner strong { color: var(--mg); }

/* Live collaborative session — red pulsing dot, banner, code display */
@keyframes live-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .55; transform: scale(1.15); }
}
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #E0415B;
  box-shadow: 0 0 8px rgba(224,65,91,.5);
  margin-right: .35rem;
  vertical-align: middle;
  animation: live-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: rgba(224,65,91,.1);
  color: #E0415B;
  border: 1px solid rgba(224,65,91,.35);
  border-radius: 5px;
  padding: .15rem .5rem;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.live-badge-count { letter-spacing: 0; font-weight: 700; }
.live-banner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .9rem;
  background: rgba(224,65,91,.08);
  border: 1px solid rgba(224,65,91,.3);
  border-radius: 8px;
  font-size: .74rem;
  color: var(--text);
  flex-shrink: 0;
  margin: .1rem 0;
  font-weight: 600;
}
.live-banner[hidden] { display: none; }

/* Tiny live-session chip — shown in the property header row when a
   session is active. Replaces the old full-width LIVE banner. */
.live-mini {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .45rem;
  background: rgba(224,65,91,.12);
  color: #E0415B;
  border: 1px solid rgba(224,65,91,.4);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  flex-shrink: 0;
  cursor: pointer;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
.live-mini:hover { background: rgba(224,65,91,.18); }
.live-mini[hidden] { display: none; }
.live-mini .live-eye { font-size: .85rem; line-height: 1; }
.live-mini .live-mini-count {
  font-family: "Courier New", monospace;
  font-weight: 700;
  min-width: .8em;
  text-align: center;
}


/* Zillow-style horizontal breakdown bar. Hidden on desktop; shown on
   mobile above the cards. Segments flex proportionally to their share
   of monthly cash (mortgage + opex + cf). */
.top-breakdown-bar { display: none; }
.top-breakdown-bar .tbb-seg {
  height: 100%;
  transition: flex .3s ease;
}
.tbb-mortgage { background: #BE0055; }
.tbb-opex     { background: #7B4FA0; }
.tbb-cf       { background: #3DD68C; }

/* Inline results strip (Cash Flow / CoC / Cap Rate) — hidden on desktop */
.results-strip,
.equity-strip { display: none; }
.live-banner strong {
  font-family: "Courier New", monospace;
  letter-spacing: .1em;
  color: #E0415B;
}

.live-code-display {
  text-align: center;
  font-family: "Courier New", monospace;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: .4em;
  padding: 1rem .5rem;
  margin: .5rem 0;
  background: var(--bg3);
  border: 2px dashed var(--mg);
  border-radius: 10px;
  color: var(--mg);
  text-transform: uppercase;
  user-select: all;
}

.live-participants-wrap {
  margin-top: .9rem;
  padding-top: .6rem;
  border-top: 1px solid var(--border);
}
.live-participants-title {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .5rem;
}
.live-participants-list {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  max-height: 180px;
  overflow-y: auto;
}
.lp-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .45rem;
  border-radius: 5px;
  font-size: .78rem;
  background: var(--bg3);
}
.lp-item .lp-name { flex: 1; font-weight: 600; }
.lp-item .lp-host { font-size: .6rem; color: var(--mg); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

/* Presence tag — floating name above a field someone else is editing */
.presence-tag {
  position: absolute;
  z-index: 9999;
  padding: 1px 6px;
  font-size: .65rem;
  font-weight: 700;
  color: #fff;
  border-radius: 3px 3px 3px 0;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  letter-spacing: .02em;
}

/* View-only banner for shared links — visible only when IS_SHARED */
.view-only-banner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .9rem;
  background: rgba(190,0,85,.08);
  border: 1px solid rgba(190,0,85,.3);
  border-radius: 8px;
  font-size: .75rem;
  color: var(--text2);
  flex-shrink: 0;
  margin-bottom: .1rem;
}
.view-only-banner .vob-icon { font-size: .95rem; }
.view-only-banner strong { color: var(--mg); font-weight: 700; }

/* Shared (view-only) mode: disable all calculator inputs until user logs in */
body.view-only .main-content input:not([id^="login_"]):not([id^="reg_"]),
body.view-only .main-content select,
body.view-only .main-content button:not(#btn_shared_login):not(#btn_shared_signup):not(#btn_shared_save_account):not(.seg-tab):not(.sb-seg-tab):not(.rvt-btn):not(#refi_toggle):not(.refi-toggle),
body.view-only .main-content input[type="range"] {
  pointer-events: none !important;
  opacity: .75;
}
body.view-only .main-content input[type="text"]:not([id^="login_"]):not([id^="reg_"]),
body.view-only .main-content input[type="number"]:not([id^="login_"]):not([id^="reg_"]) {
  cursor: not-allowed !important;
}

/* Live-guest mode: hide the no-property banner & keep the property header
   compact — the live-banner already tells you you're connected */
body.is-live-guest .no-property-banner { display: none; }

/* ============================================================
   STICKY MOBILE BANNER — key metrics visible at all times
   ============================================================ */
.sticky-banner-wrap {
  display: none;
  /* On mobile we switch to position: fixed so the banner stays pinned even
     when the mobile keyboard opens (iOS Safari loses sticky positioning
     during visual-viewport reshuffles from keyboard open/close). */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 110;
  background: linear-gradient(180deg, #2A1A30 0%, #1F1F2B 100%);
  border-bottom: 1px solid #3A2940;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.sticky-banner {
  display: flex;
  width: 100%;
  padding: .5rem .75rem;
  gap: .75rem;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  align-items: center;
}
.sb-mini-pie { flex-shrink: 0; display: block; }
.sb-chev {
  color: #A89AB8;
  font-size: .9rem;
  font-weight: 700;
  padding: 0 .3rem;
  transition: transform .2s;
  flex-shrink: 0;
}
.sticky-banner-wrap.open .sb-chev { transform: rotate(180deg); }
.sticky-banner-drawer {
  padding: .8rem 1rem 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
  color: #EEEEF2;
  max-height: 70vh;
  overflow-y: auto;
}
.drawer-top {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: .5rem;
}
.sticky-banner .sb-item {
  flex: 1;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,.08);
  padding: 0 .4rem;
}
.sticky-banner .sb-item:last-child { border-right: none; }
.sticky-banner .sb-label {
  font-size: .55rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #A89AB8;
  margin-bottom: .1rem;
}
.sticky-banner .sb-val {
  font-size: .95rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
}
.sticky-banner .sb-val.positive { color: #3DD68C; }
.sticky-banner .sb-val.negative { color: #FF4D6D; }
.sticky-banner .sb-sub {
  font-size: .58rem;
  font-weight: 600;
  color: #A89AB8;
  margin-top: 1px;
}
.sticky-banner .sb-item-cf { flex: 1.4; }

/* ============================================================
   MOBILE — hamburger + responsive layout
   ============================================================ */
.nav-hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: .3rem; color: var(--text2);
  flex-direction: column; gap: 4px; margin-left: auto;
}
.nav-hamburger span {
  display: block; width: 20px; height: 2px;
  background: currentColor; border-radius: 2px; transition: all .2s;
}

/* Unified layout: the styles below used to be mobile-only. We now apply
   them at ALL widths so desktop mirrors the cleaner mobile design (top
   breakdown bar + KPI strip + accordion cards + cashflow card + collapsible
   Refinance Analysis). The sidebar summary pie is retired. On wide screens
   .main-content is capped by a max-width so content reads as a centered
   column instead of stretching edge-to-edge. */
@media (min-width: 0) {
  /* Cap width & center so the page doesn't sprawl on wide monitors. */
  .main-content {
    max-width: 1400px;
    margin: 0 auto;
  }
  .calc-grid { max-width: none; }

  /* Navbar — fixed at top; hamburger menu drops as absolute overlay
     so nav keeps a predictable height at all times */
  .navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 120;
    height: 52px;
    padding: .5rem .75rem;
    flex-wrap: nowrap;
  }
  .nav-hamburger { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: .5rem .75rem .75rem;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 16px rgba(0,0,0,.3);
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: .55rem .5rem; font-size: .85rem; border-radius: 6px; }
  .nav-right { margin-left: auto; gap: .5rem; }

  /* Calculator: stack columns */
  html, body { overflow: auto; }
  .main-content {
    height: auto; overflow: visible;
    padding: .8rem .75rem 1rem;
  }
  /* Make sure the property header sits below the fixed nav with breathing room */
  .property-header { margin-top: .25rem; }
  .calc-grid {
    grid-template-columns: 1fr !important;
    overflow: visible; height: auto;
  }
  .calc-col { overflow-y: visible; padding-right: 0; }

  /* Property header: compact single row — just selector + a ⋮ overflow
     button that pops all actions into a dropdown. Header stays short. */
  .property-header {
    flex-wrap: nowrap;
    gap: .35rem;
    padding: .3rem .45rem;
    border-left-width: 2px;
    border-radius: 8px;
    align-items: center;
    position: relative;
  }
  .prop-select-wrap { order: 0; flex: 1 1 0; min-width: 60px; }
  /* Hide the entire property identity (title, address, meta chips, inline
     Zillow icon) on mobile — the Zillow link lives in the ⋮ menu instead. */
  .prop-identity { display: none !important; }
  .prop-title { font-size: .78rem; max-width: 100%; }
  .prop-combo {
    font-size: .78rem; padding: .3rem .5rem;
    min-width: 0; width: 100%; height: 32px;
  }
  .prop-select-wrap #btn_new_inline {
    padding: 0 .45rem; font-size: .7rem; height: 32px; flex-shrink: 0;
  }

  /* ⋮ overflow button — solid visible pill so it's not mistaken for blank */
  .mobile-actions-btn {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    min-width: 32px; width: 32px; height: 32px;
    padding: 0 !important;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
    background: var(--card);
    color: var(--text1);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
  }
  /* ✎ edit property — similar sized pill, magenta accent */
  .prop-edit-btn-mobile {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 26px; height: 26px;
    padding: 0;
    font-size: .78rem;
    line-height: 1;
    flex-shrink: 0;
    background: transparent;
    color: var(--mg);
    border: 1px solid rgba(190,0,85,.3);
    border-radius: 6px;
    cursor: pointer;
  }

  /* Hide the normal action buttons by default on mobile; show them as a
     fly-out dropdown only when the body has .mobile-actions-open class. */
  .prop-header-actions {
    position: absolute;
    top: calc(100% + 4px);
    right: .45rem;
    z-index: 150;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: .25rem;
    padding: .45rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(25,30,60,.18);
    min-width: 160px;
  }
  body.mobile-actions-open .prop-header-actions {
    display: flex;
  }
  .prop-header-actions .btn,
  .prop-header-actions .btn-sm {
    font-size: .78rem;
    padding: .4rem .55rem;
    text-align: left;
    white-space: nowrap;
    width: 100%;
    justify-content: flex-start;
  }
  .prop-header-actions .versions-wrap { width: 100%; }
  .prop-header-actions .versions-dropdown {
    right: auto; left: 0; top: calc(100% + 4px); max-width: 90vw;
  }
  .prop-header-actions .live-badge { align-self: flex-start; }

  /* Properties / admin pages */
  .properties-grid { grid-template-columns: 1fr; }
  .settings-grid   { grid-template-columns: 1fr; }
  .scrollable-page { height: auto; min-height: calc(100vh - 48px); padding: .75rem; }

  /* Tables: horizontal scroll */
  .card { overflow-x: auto; }
  .clients-table { min-width: 520px; }

  /* Login */
  .login-card { width: 95vw; max-width: 380px; }

  /* Kill the fixed-position bottom summary on mobile — the pie is now
     shown inline (flex order puts it between Expenses and Refi). */
  .sticky-banner-wrap { display: none !important; }
  body { padding-top: 52px; padding-bottom: 0; }

  /* Reorder cards via flex + display:contents on the column wrappers.
     DOM already puts Income before Financing; explicit `order` also
     positions the summary card (inside .summary-col) between Expenses
     and Refi on mobile. */
  .calc-grid { display: flex; flex-direction: column; gap: 0; }
  .calc-col, .summary-col { display: contents; }
  #card_purchase         { order: 5; }
  #card_income           { order: 10; }
  #card_financing        { order: 20; }
  #card_expenses         { order: 30; }
  #card_cashflow         { order: 32; }
  .refi-section-heading  { order: 36; }
  .refi-breakdown-bar    { order: 37; }
  .refi-results-strip    { order: 38; }
  .refi-equity-strip     { order: 38; }  /* sits right under the refi results strip */
  #card_refi_closing     { order: 39; }
  #card_refi_income      { order: 40; }
  #card_refi             { order: 41; }
  #card_refi_expenses    { order: 42; }
  #card_refi_cashflow    { order: 43; }
  /* Summary card is replaced on mobile by the top-breakdown bar + the
     results strip inside the Expenses card. */
  .summary-card     { display: none !important; }
  /* Tappable heading that toggles the whole refi group (bar + strip + cards) */
  .refi-section-heading {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: .75rem 0 .3rem;
    padding: .55rem .7rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text1);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .refi-section-heading .refi-heading-chev {
    color: var(--mg);
    font-size: 1rem;
    transition: transform .2s;
  }
  body:not(.refi-section-open) .refi-heading-chev { transform: rotate(0deg); }
  body.refi-section-open       .refi-heading-chev { transform: rotate(180deg); }

  /* Collapsed: hide the whole Refi group except the heading toggle */
  body:not(.refi-section-open) .refi-breakdown-bar,
  body:not(.refi-section-open) .refi-results-strip,
  body:not(.refi-section-open) .refi-equity-strip,
  body:not(.refi-section-open) #card_refi_closing,
  body:not(.refi-section-open) #card_refi,
  body:not(.refi-section-open) #card_refi_income,
  body:not(.refi-section-open) #card_refi_expenses,
  body:not(.refi-section-open) #card_refi_cashflow {
    display: none !important;
  }
  .refi-breakdown-bar { margin-top: 0; }

  /* Top breakdown bar — pinned directly above the cards. */
  .top-breakdown-bar {
    display: flex;
    height: 6px;
    width: 100%;
    border-radius: 3px;
    overflow: hidden;
    margin: .25rem 0 .25rem;
    background: var(--border);
  }

  /* Results strip — compact 3 KPI cells directly under the breakdown bar */
  .results-strip {
    display: flex;
    gap: .25rem;
    margin: 0 0 .45rem;
    padding: 0;
    border-top: none;
  }
  .results-strip .result-cell {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: .2rem .15rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
  }
  .results-strip .result-label {
    font-size: .48rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text3);
    margin-bottom: 1px;
    line-height: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .results-strip .result-value {
    font-size: .75rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.15;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .results-strip { gap: .2rem; }
  .results-strip .result-value.positive { color: #1BA967; }
  .results-strip .result-value.negative { color: #D42050; }
  .results-strip .result-sub {
    font-size: .55rem;
    color: var(--text3);
    margin-top: 0;
    line-height: 1;
  }

  /* Equity strip — same look as the results strip, two 50/50 cells for
     Cash in Deal + Equity%. One sits under the top results strip (current
     scenario), the other sits under the refi results strip. */
  .equity-strip {
    display: flex;
    gap: .25rem;
    margin: 0 0 .5rem;
  }
  .equity-strip .result-cell {
    flex: 1 1 0;
  }

  /* Cashflow summary card — readonly waterfall with Monthly + Annual cols */
  .cashflow-card {
    display: block;
    margin: 0 0 .3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    padding: .4rem .6rem .55rem;
  }
  .cashflow-card > .card-title {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem 0 .3rem;
    margin: 0 0 .3rem;
    border-bottom: 1px solid var(--border);
    font-size: .72rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text1);
  }
  .cashflow-card > .card-title::before { display: none; }
  .cashflow-card .card-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  }
  .cashflow-card .card-title-val {
    margin-left: auto;
    font-weight: 700;
    font-size: .78rem;
    color: var(--text1);
  }
  .cashflow-card .cf-grid {
    display: block;
  }
  .cashflow-card .cf-row {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: .4rem;
    align-items: baseline;
    padding: .22rem 0;
    font-size: .78rem;
    line-height: 1.15;
  }
  .cashflow-card .cf-row + .cf-row { border-top: 1px solid var(--border); }
  .cashflow-card .cf-row-head {
    padding: 0 0 .15rem;
    border-bottom: 1px solid var(--border);
  }
  .cashflow-card .cf-row-head + .cf-row { border-top: none; }
  .cashflow-card .cf-row-head > div {
    font-size: .5rem;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: right;
  }
  .cashflow-card .cf-row-head > div:first-child { text-align: left; }
  .cashflow-card .cf-label {
    font-size: .7rem;
    color: var(--text2);
    font-weight: 600;
  }
  .cashflow-card .cf-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: .4rem;
    vertical-align: middle;
    flex-shrink: 0;
  }
  .cashflow-card .cf-minus .cf-label::before {
    content: "− "; color: var(--text3); font-weight: 700;
  }
  .cashflow-card .cf-val {
    font-size: .8rem;
    font-weight: 700;
    color: var(--text1);
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .cashflow-card .cf-total .cf-label,
  .cashflow-card .cf-total .cf-val {
    font-weight: 800;
    color: var(--text1);
  }
  .cashflow-card .cf-total .cf-label::before { display: none; }
  .cashflow-card .cf-final .cf-val {
    color: #1BA967;  /* green — the "profit" line */
  }
  .cashflow-card .cf-final .cf-val.negative { color: #D42050; }

  /* Per-card collapse (Zillow-style): every card has a tappable title
     with a chevron. Default = expanded (editable inputs). Collapsed =
     values still visible but styled as read-only plain text. */
  .mob-accordion > .card-title {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  /* Chevron is hidden — the whole title row is tappable to toggle. */
  .mob-accordion > .card-title .card-chev { display: none !important; }

  /* ---- Collapsed card body: inputs visible but styled as text ---- */
  .mob-accordion.card-collapsed .field-row {
    gap: .5rem;
    margin-bottom: .2rem;
  }
  .mob-accordion.card-collapsed .field {
    position: relative;
    margin: 0 0 .3rem !important;
    padding: 0;
  }
  .mob-accordion.card-collapsed .field-label {
    position: static !important;
    top: auto !important;
    left: auto !important;
    font-size: .5rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    color: var(--text3) !important;
    margin: 0 0 1px !important;
    padding: 0 !important;
    letter-spacing: .04em !important;
    text-transform: uppercase !important;
    max-width: 100% !important;
    pointer-events: auto !important;
  }
  .mob-accordion.card-collapsed input[type="text"],
  .mob-accordion.card-collapsed input[type="number"],
  .mob-accordion.card-collapsed input[type="date"],
  .mob-accordion.card-collapsed .input-prefix-wrap input {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    height: auto !important;
    line-height: 1.15 !important;
    font-size: .85rem !important;
    font-weight: 600 !important;
    color: var(--text2) !important;
    pointer-events: none;
    box-shadow: none !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 1 auto !important;
    text-align: left !important;
    /* Modern browsers (Chrome 123+, Safari 17+): auto-shrink to value width */
    field-sizing: content;
  }
  .mob-accordion.card-collapsed .input-prefix-wrap {
    position: static;
    display: inline-flex;
    align-items: baseline;
    width: auto;
    gap: 1px;
  }
  .mob-accordion.card-collapsed .input-prefix {
    position: static !important;
    bottom: auto !important;
    left: auto !important;
    font-size: .82rem !important;
    color: var(--text3) !important;
    font-weight: 600 !important;
  }
  .mob-accordion.card-collapsed .input-suffix {
    position: static !important;
    bottom: auto !important;
    right: auto !important;
    font-size: .78rem !important;
    color: var(--text3) !important;
    font-weight: 600 !important;
  }
  /* Field-pair ($ amount + % value): show side by side with a bullet,
     inputs auto-sized to their content. */
  .mob-accordion.card-collapsed .field-pair .field-pair-inputs {
    display: inline-flex;
    gap: .35rem;
    width: auto;
    align-items: baseline;
  }
  .mob-accordion.card-collapsed .field-pair .field-pair-inputs > .input-prefix-wrap {
    flex: 0 0 auto;
    position: static;
  }
  .mob-accordion.card-collapsed .field-pair .field-pair-inputs > .input-prefix-wrap:last-child::before {
    content: "\00B7"; /* · middle dot separator */
    color: var(--text3);
    margin-right: .3rem;
    font-size: .85rem;
    position: static !important;
    transform: none !important;
    width: auto; height: auto;
    border: none; background: transparent;
    border-radius: 0;
    display: inline;
    line-height: 1;
  }
  /* In collapsed mode, inputs inside field-pair shouldn't stretch */
  .mob-accordion.card-collapsed .field-pair input { flex: 0 1 auto !important; }

  /* Fallback width caps for browsers without field-sizing: content.
     Keeps the collapsed read-only text from defaulting to the native
     20-char input width (~170px). */
  @supports not (field-sizing: content) {
    .mob-accordion.card-collapsed .has-prefix input,
    .mob-accordion.card-collapsed .has-suffix input {
      width: 100px !important;
      max-width: 100%;
    }
    .mob-accordion.card-collapsed .field-pair .input-prefix-wrap:last-child input {
      width: 50px !important;
    }
    .mob-accordion.card-collapsed input[type="date"] {
      width: 110px !important;
    }
  }
  /* Drop decorations + interactive bits — just keep the values */
  .mob-accordion.card-collapsed .breakdown-toggle,
  .mob-accordion.card-collapsed .breakdown-panel,
  .mob-accordion.card-collapsed .io-toggle,
  .mob-accordion.card-collapsed .slider-row,
  .mob-accordion.card-collapsed .text-muted,
  .mob-accordion.card-collapsed .annual-hint {
    display: none !important;
  }
  /* Term + IO group: stay inline, drop the IO button */
  .mob-accordion.card-collapsed .term-io-group {
    display: flex;
    gap: .25rem;
  }
  /* Refi live box — hide the whole box in collapsed since it's summary-like */
  .mob-accordion.card-collapsed .refi-live-box,
  .mob-accordion.card-collapsed .refi-arv-line {
    display: none !important;
  }
  /* Whole collapsed card feels tappable */
  .mob-accordion.card-collapsed { cursor: pointer; }

  /* Per-card collapsed visibility rules — each card chooses what to show
     when collapsed, since the right "glance summary" differs by section. */

  /* Income collapsed (regular + refi): show only Monthly Rent + Vacancy $.
     Hide per-unit breakdown, effective-income line, and the vacancy %. */
  .mob-accordion.card-collapsed#card_income #unit_rents_panel,
  .mob-accordion.card-collapsed#card_income #effective_rent_display,
  .mob-accordion.card-collapsed#card_income .field-pair .input-prefix-wrap:has(#vacancy_pct),
  .mob-accordion.card-collapsed#card_refi_income #refi_unit_rents_panel,
  .mob-accordion.card-collapsed#card_refi_income .field-pair .input-prefix-wrap:has(#refi_vacancy_pct) {
    display: none !important;
  }
  .mob-accordion.card-collapsed#card_income .field-pair .field-pair-inputs > .input-prefix-wrap:last-child::before,
  .mob-accordion.card-collapsed#card_refi_income .field-pair .field-pair-inputs > .input-prefix-wrap:last-child::before {
    display: none !important;
  }

  /* Financing collapsed: keep ONLY Loan Amount + Interest Rate, side by side. */
  .mob-accordion.card-collapsed#card_financing .field:has(#down_payment_amt),
  .mob-accordion.card-collapsed#card_financing .field:has(#loan_term),
  .mob-accordion.card-collapsed#card_financing .field-loan-origination {
    display: none !important;
  }
  /* Flatten the field-rows so the two remaining fields share a single row. */
  .mob-accordion.card-collapsed#card_financing .field-row { display: contents; }
  .mob-accordion.card-collapsed#card_financing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: .5rem;
    row-gap: .3rem;
  }
  .mob-accordion.card-collapsed#card_financing > .card-title { grid-column: 1 / -1; }

  /* Expenses collapsed: show all six fields ($ only), hide the % side of
     paired fields (Management %, Maintenance %) and the · separator. */
  .mob-accordion.card-collapsed#card_expenses .field-pair .input-prefix-wrap:has(#management_pct),
  .mob-accordion.card-collapsed#card_expenses .field-pair .input-prefix-wrap:has(#maintenance_pct) {
    display: none !important;
  }
  .mob-accordion.card-collapsed#card_expenses .field-pair .field-pair-inputs > .input-prefix-wrap:last-child::before {
    display: none !important;
  }

  /* Refi Financing (card_refi) collapsed: keep ONLY New Loan + Refi Rate,
     side by side. Hide Refi Term, LTV, and the computed ARV readout /
     refi-live-box (those are already hidden by earlier collapsed rules). */
  .mob-accordion.card-collapsed#card_refi .field:has(#refi_term),
  .mob-accordion.card-collapsed#card_refi .field:has(#refi_ltv) {
    display: none !important;
  }
  .mob-accordion.card-collapsed#card_refi .field-row,
  .mob-accordion.card-collapsed#card_refi .refi-body {
    display: contents;
  }
  .mob-accordion.card-collapsed#card_refi {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: .5rem;
    row-gap: .3rem;
  }
  .mob-accordion.card-collapsed#card_refi > .card-title { grid-column: 1 / -1; }
  /* Tighten card title spacing when collapsed too */
  .mob-accordion.card-collapsed > .card-title {
    margin-bottom: .25rem;
  }

  /* ---- Inline summary card on mobile ---- */
  .summary-card {
    background: linear-gradient(180deg, #2A1A30 0%, #1F1F2B 100%);
    color: #EEEEF2;
    border: 1px solid #3A2940;
    border-radius: 10px;
    padding: .7rem .7rem .75rem;
    margin-bottom: .3rem;
  }
  .summary-card .card-title,
  .summary-card .card-title-text,
  .summary-card .details-title { color: #EEEEF2; }
  .summary-card .kpi-label { color: #A89AB8; font-size: .62rem; }
  .summary-card .kpi-value { font-size: 1.05rem; }
  .summary-card .summary-kpis { gap: .6rem; margin-bottom: .4rem; }
  .summary-card .summary-donut-wrap { padding: .2rem 0 .3rem; }
  .summary-card .summary-donut-wrap svg { width: 140px; height: 140px; }
  .summary-card .segment-tabs { gap: .3rem; }
  .summary-card .seg-tab {
    font-size: .68rem; padding: .3rem .45rem;
  }
  .summary-card .summary-details { margin-top: .4rem; }
  .summary-card .details-title { font-size: .72rem; }
  .summary-card .refi-view-toggle { margin-bottom: .4rem; }
  .summary-card .rvt-btn { font-size: .68rem; padding: .25rem .5rem; }

  /* ---------- Flat single-form layout on mobile (no dropdowns) ---------- */
  .mob-accordion {
    margin-bottom: .3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 0 .5rem .4rem;
    overflow: visible;
  }
  /* Section header becomes a thin divider row — no tap/toggle behavior */
  .mob-accordion > .card-title {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem 0 .25rem;
    margin: 0 0 .3rem;
    border-bottom: 1px solid var(--border);
    user-select: none;
    cursor: default;
    font-size: .72rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text1);
  }
  .mob-accordion > .card-title::before { display: none; }
  .mob-accordion > .card-title .card-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  }
  .mob-accordion > .card-title .card-title-text {
    font-weight: 700; font-size: .78rem;
  }
  .mob-accordion > .card-title .card-title-val {
    margin-left: auto;
    font-weight: 700; font-size: .78rem; color: var(--text1);
    white-space: nowrap;
  }
  /* All card content is visible by default (expanded). Per-card collapse
     is handled by the .card-collapsed class above, wired by the title
     click handler in calculator.js. */
  .mob-accordion > * { display: block; }
  .mob-accordion > .field-row { display: flex; gap: .3rem; flex-wrap: wrap; }
  .mob-accordion > .field-row > .field { flex: 1 1 0; min-width: 0; }
  .mob-accordion > .refi-body { display: block; }
  /* Reset any leftover per-child padding from the old accordion layout */
  .mob-accordion > .field,
  .mob-accordion > .field-row { padding: 0; }
  .mob-accordion .refi-body { padding: 0; }

  /* Drop UI that crowds the mobile form */
  .mob-accordion .slider-row,
  .mob-accordion .breakdown-toggle,
  .mob-accordion .annual-hint,
  .mob-accordion .text-muted.mt-1 {
    display: none !important;
  }
  /* Keep "/yr" hints — just compact them so they stay inside the floating label */
  .mob-accordion .annual-badge {
    font-size: .6rem;
    font-weight: 600;
    color: var(--text3);
    letter-spacing: 0;
  }
  /* Hide verbose help text under fields (e.g. the "used on portfolio
     dashboard" note under the loan origination date) — keeps forms tight.
     Keep the ARV auto-hint though — it's a 1-line preview of the value. */
  .mob-accordion .field > .text-muted:not(.arv-hint) { display: none !important; }
  .mob-accordion .arv-hint {
    font-size: .6rem;
    margin-top: 2px;
    color: var(--text3);
    line-height: 1.1;
  }
  /* Loan origination date — kept compact; fits as 3rd column of Interest row */
  .mob-accordion .field-loan-origination input[type="date"] {
    font-size: .7rem;
    padding: 13px 4px 2px;
  }

  /* ---------- Paired $ / % field (linked visual) ----------
     Two inputs linked by an "=" sign make it unmistakable that the $ amount
     and the % are two views of the same number (Down Payment / Vacancy /
     Management / Maintenance). */
  .mob-accordion .field-pair .field-pair-inputs {
    display: flex;
    align-items: stretch;
    background: transparent;
    width: 100%;
    gap: 18px;
    position: relative;
  }
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap {
    min-width: 0;
    position: relative;
  }
  /* $ side wider than % side (value like $1,234,000 vs 20) */
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap:first-child  { flex: 3 1 0; }
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap:last-child   { flex: 2 1 0; }
  /* "=" between the two inputs — floats in the gap */
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap:last-child::before {
    content: "=";
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .9rem;
    font-weight: 700;
    color: var(--text3);
    line-height: 1;
    pointer-events: none;
    z-index: 3;
  }

  /* Compact refi-live-box — tight rows, smaller progress bar */
  .mob-accordion .refi-live-box { padding: .4rem .5rem; margin-top: .25rem; }
  .mob-accordion .refi-live-box .rlv-row {
    padding: .1rem 0; font-size: .72rem;
  }
  .mob-accordion .refi-live-box .rlv-row-main .rlv-k,
  .mob-accordion .refi-live-box .rlv-v-big { font-size: .82rem; }
  .mob-accordion .rlv-progress { margin-top: .3rem; }
  .mob-accordion .rlv-progress-caption { font-size: .62rem; margin-top: .15rem; }
  .mob-accordion .refi-arv-line { padding: .3rem 0; }
  .mob-accordion .refi-arv-line .arv-label,
  .mob-accordion .refi-arv-line .arv-value { font-size: .74rem; }
  /* Keep the field-row fields equal width */
  .mob-accordion .field-row > .field { flex: 1; min-width: 0; }

  /* ---------- Compact floating-label inputs ---------- */
  .mob-accordion .field { position: relative; margin-bottom: .3rem; }
  .mob-accordion .field:last-child { margin-bottom: 0; }
  .mob-accordion .field-label {
    position: absolute;
    top: 3px;
    left: 7px;
    z-index: 1;
    font-size: .58rem;
    font-weight: 600;
    color: var(--text3);
    margin: 0;
    padding: 0;
    letter-spacing: 0;
    pointer-events: none;
    background: transparent;
    max-width: calc(100% - 14px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
  }
  .mob-accordion .input-prefix-wrap { width: 100%; }
  .mob-accordion .input-prefix-wrap input,
  .mob-accordion .field > input[type="text"],
  .mob-accordion .field > input[type="number"],
  .mob-accordion .field > input[type="date"] {
    height: 36px;
    width: 100%;
    padding: 12px 8px 2px;
    border: 1px solid var(--border2);
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
  }
  .mob-accordion .has-prefix input { padding-left: 16px; }
  .mob-accordion .has-suffix input { padding-right: 20px; }
  .mob-accordion .input-prefix {
    top: auto; left: 8px; bottom: 7px;
    font-size: .82rem; font-weight: 600; color: var(--text);
  }
  .mob-accordion .has-prefix .field-label { left: 15px; }
  .mob-accordion .input-suffix {
    top: auto; right: 8px; bottom: 9px;
    font-size: .72rem; color: var(--text3);
  }
  .mob-accordion .field > input[type="date"] {
    padding-top: 12px; font-size: .78rem;
  }
  .mob-accordion .field-row { margin-bottom: .3rem; }
  .mob-accordion .field-row .field { margin-bottom: 0; }

  /* Term + Int-only toggle: keep side by side, toggle smaller */
  .mob-accordion .term-io-group { display: flex; gap: .25rem; align-items: stretch; }
  .mob-accordion .term-io-group .input-prefix-wrap { flex: 1; }
  .mob-accordion .io-toggle {
    height: 36px; padding: 0 .4rem;
    font-size: .6rem; white-space: nowrap;
  }

  /* Per-unit rent inputs on mobile: 3-per-row grid of compact
     floating-label boxes, matching the rest of the inputs. Applies to
     BOTH the regular and the refi unit-rents panels. */
  .mob-accordion #unit_rents_panel,
  .mob-accordion #refi_unit_rents_panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .3rem;
    margin: .35rem 0 0;
  }
  .mob-accordion .unit-rent-row {
    display: block;
    position: relative;
    padding: 0;
    margin: 0;
    gap: 0;
  }
  .mob-accordion .unit-rent-row .unit-rent-label {
    position: absolute;
    top: 3px;
    left: 15px;
    z-index: 1;
    font-size: .54rem;
    font-weight: 600;
    color: var(--text3);
    pointer-events: none;
    line-height: 1;
    width: auto;
    margin: 0;
  }
  .mob-accordion .unit-rent-row .input-prefix-wrap { flex: none; width: 100%; }
  /* Hide the "/mo" suffix on mobile — the label "Unit N" implies /mo. */
  .mob-accordion .unit-rent-row > span:last-child { display: none; }

  /* Refi live box fits the card — tighten padding */
  .mob-accordion .refi-live-box { padding: .75rem; }
  .mob-accordion .refi-arv-line { padding: .5rem .25rem; }

  /* Breakdown panel — keep visible but tighter */
  .mob-accordion .breakdown-panel { margin-top: .4rem; }

  /* Version panel: full screen overlay on mobile */
  .version-panel { width: 100%; }
}

/* ============================================================
   DESKTOP RESTORES — keep the navbar + select-wrap usable on wide
   screens even though the rest of the layout mirrors mobile.
   ============================================================ */
@media (min-width: 769px) {
  /* Restore inline nav links; hide the hamburger */
  .nav-hamburger { display: none !important; }
  .nav-links {
    display: flex !important;
    position: static !important;
    flex-direction: row !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-bottom: none !important;
  }
  /* Show the property title + meta line in the header again on desktop
     (hidden on mobile due to space constraints) */
  .prop-identity { display: flex !important; }
  .prop-identity .prop-title { display: inline-flex !important; }
  /* JS sets this when name duplicates the address, so the title hides
     and the address line carries the property's identity alone. */
  .prop-identity .prop-title.is-hidden { display: none !important; }
  .prop-meta-line { display: flex !important; }
  .prop-meta-line .prop-address-line,
  .prop-meta-line .prop-unit-chip { display: inline-flex !important; }
  /* Restore normal Zillow link text on desktop (hides icon-only override) */
  .prop-meta-line #prop_zillow_link {
    font-size: .68rem !important;
    padding: .1rem .45rem !important;
    width: auto !important;
    height: auto !important;
    line-height: normal !important;
  }
  .prop-meta-line #prop_zillow_link::before { content: none !important; }
  /* Hide the mobile-only ✎ and ⋮ header buttons on desktop */
  .mobile-actions-btn,
  .prop-edit-btn-mobile { display: none !important; }
  /* Show the normal inline action buttons on desktop */
  .prop-header-actions {
    position: static !important;
    display: flex !important;
    flex-direction: row !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    gap: .4rem !important;
    min-width: 0 !important;
    overflow: visible !important;
    align-items: center;
  }
  .prop-header-actions .btn,
  .prop-header-actions .btn-sm {
    width: auto !important;
    text-align: center !important;
    justify-content: center !important;
  }
  /* Property header uses its full-width desktop layout again */
  .property-header {
    flex-wrap: wrap !important;
    gap: .75rem !important;
    padding: .5rem .9rem !important;
    align-items: center !important;
  }
  .prop-title { font-size: .92rem !important; max-width: 400px !important; }

  /* ---- 2-column grid for cards on desktop ----
     Same design language (colored dots, accordion, cashflow waterfall) but
     cards are laid out side-by-side and typography is scaled up so it
     feels like a proper desktop site, not stretched mobile. */
  .calc-grid {
    display: grid !important;
    /* 2 cols: regular scenario | refi scenario */
    grid-template-columns: 1fr 1fr !important;
    column-gap: 1.25rem !important;
    row-gap: .35rem !important;
    align-items: start;
    flex-direction: unset !important;
    gap: initial;
  }
  .calc-col, .summary-col { display: contents; }

  /* The top breakdown bar + KPI strip move INSIDE the Cashflow card on
     desktop (via .cf-head). Hide the page-level ones. */
  #top_breakdown_bar,
  #results_strip { display: none !important; }

  /* Refi page-level bar+strip likewise move into the refi cashflow card. */
  .refi-breakdown-bar,
  .refi-results-strip { display: none !important; }

  /* Refi section heading is redundant on desktop — refi sits side-by-side
     with the regular section, no need for a separator/toggle. */
  .refi-section-heading { display: none !important; }
  /* Refi cards always visible on desktop regardless of body class state */
  body #card_refi_closing,
  body #card_refi,
  body #card_refi_income,
  body #card_refi_expenses,
  body #card_refi_cashflow { display: block !important; }

  /* --- 2-column layout: regular scenario stacked | refi scenario stacked ---
     Each column gets a small header label, then mirrored card order:
     Purchase|Closing → Income → Financing → Expenses → Cashflow. */

  /* Top of each column: bar + KPI strip (cf-head) — emphasized visually
     with a colored background panel so the two scenarios are clearly
     distinct top blocks. */
  #cf_head_top  {
    grid-column: 1; grid-row: 1; display: block;
    background: linear-gradient(180deg, rgba(190,0,85,.08) 0%, rgba(190,0,85,.02) 100%);
    border: 1px solid rgba(190,0,85,.18);
    border-radius: 12px;
    padding: .85rem 1rem .9rem;
    margin-bottom: .35rem;
  }
  #rcf_head_top {
    grid-column: 2; grid-row: 1; display: block;
    background: linear-gradient(180deg, rgba(88,112,255,.08) 0%, rgba(88,112,255,.02) 100%);
    border: 1px solid rgba(88,112,255,.22);
    border-radius: 12px;
    padding: .85rem 1rem .9rem;
    margin-bottom: .35rem;
  }
  /* No column header chips and no collapse toggle anymore — blue accent
     border on refi cards stays as the visual differentiator. */
  .current-col-header,
  .refi-col-header { display: none !important; }

  /* LEFT — regular */
  #card_purchase  { grid-column: 1; grid-row: 2; }
  #card_income    { grid-column: 1; grid-row: 3; }
  #card_financing { grid-column: 1; grid-row: 4; }
  #card_expenses  { grid-column: 1; grid-row: 5; }
  #card_cashflow  { grid-column: 1; grid-row: 6; }

  /* RIGHT — refi (mirrored order) */
  #card_refi_closing  { grid-column: 2; grid-row: 2; }
  #card_refi_income   { grid-column: 2; grid-row: 3; }
  #card_refi          { grid-column: 2; grid-row: 4; }
  #card_refi_expenses { grid-column: 2; grid-row: 5; }
  #card_refi_cashflow { grid-column: 2; grid-row: 6; }

  /* Subtle visual differentiation — regular cards get a magenta accent,
     refi cards get a blue accent. Each column reads as a distinct scenario. */
  #card_purchase,
  #card_income,
  #card_financing,
  #card_expenses,
  #card_cashflow {
    border-left: 3px solid rgba(190,0,85,.5);
  }
  #card_refi_closing,
  #card_refi,
  #card_refi_income,
  #card_refi_expenses,
  #card_refi_cashflow {
    border-left: 3px solid rgba(88,112,255,.5);
  }

  /* Column header labels styled as section banners */
  .col-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .5rem .75rem;
    margin: .15rem 0 .35rem;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    border-radius: 8px;
  }
  .current-col-header {
    background: rgba(190,0,85,.06);
    color: var(--mg);
    border: 1px solid rgba(190,0,85,.18);
  }
  .refi-col-header {
    background: rgba(88,112,255,.08);
    color: #4760E0;
    border: 1px solid rgba(88,112,255,.22);
    gap: .5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .col-header .ch-chev {
    margin-left: auto;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .35rem;
    border-radius: 4px;
  }
  .refi-col-header:hover .ch-chev { background: rgba(88,112,255,.15); }

  /* When user collapses the refi side: hide all refi cards, stretch the
     current column to full width, and shrink the refi header into a small
     "Show After Refi" pill at the top. */
  body.refi-col-hidden .calc-grid {
    grid-template-columns: 1fr !important;
  }
  body.refi-col-hidden #card_refi_closing,
  body.refi-col-hidden #card_refi,
  body.refi-col-hidden #card_refi_income,
  body.refi-col-hidden #card_refi_expenses,
  body.refi-col-hidden #card_refi_cashflow {
    display: none !important;
  }
  body.refi-col-hidden .current-col-header { display: none; }
  body.refi-col-hidden .refi-col-header {
    grid-column: 1;
    grid-row: 1;
    padding: .35rem .65rem;
    font-size: .68rem;
  }
  body.refi-col-hidden .refi-col-header .ch-text::before { content: "Show "; }
  body.refi-col-hidden .refi-col-header .ch-chev { display: none; }

  /* ---- Typography + spacing upsize for desktop ---- */
  .mob-accordion {
    margin-bottom: 0;       /* gap is handled by grid row-gap */
    border-radius: 10px;
    padding: 0 .9rem .85rem;
  }
  .mob-accordion > .card-title {
    gap: .6rem;
    padding: .7rem 0 .55rem;
    margin: 0 0 .5rem;
    font-size: .95rem;
  }
  .mob-accordion > .card-title .card-dot {
    width: 10px; height: 10px;
  }
  .mob-accordion > .card-title .card-title-text { font-size: .95rem; }
  .mob-accordion > .card-title .card-title-val  { font-size: 1rem; }

  /* Fields */
  .mob-accordion .field { margin-bottom: .5rem; }
  .mob-accordion .field-label {
    top: 6px;
    left: 11px;
    font-size: .68rem;
  }
  .mob-accordion .input-prefix-wrap input,
  .mob-accordion .field > input[type="text"],
  .mob-accordion .field > input[type="number"],
  .mob-accordion .field > input[type="date"] {
    height: 44px;
    padding: 18px 10px 4px;
    font-size: .98rem;
    border-radius: 8px;
  }
  .mob-accordion .has-prefix .field-label { left: 20px; }
  .mob-accordion .has-prefix input { padding-left: 22px; }
  .mob-accordion .has-suffix input { padding-right: 28px; }
  .mob-accordion .input-prefix {
    left: 11px; bottom: 11px;
    font-size: .95rem;
  }
  .mob-accordion .input-suffix {
    right: 11px; bottom: 13px;
    font-size: .82rem;
  }
  .mob-accordion .field-row { gap: .6rem; margin-bottom: .5rem; }
  /* Term + Int-only toggle: compact IO button + wider Loan Term input */
  .mob-accordion .term-io-group {
    gap: .35rem;
    align-items: stretch;
  }
  .mob-accordion .term-io-group .input-prefix-wrap { flex: 1 1 auto; min-width: 0; }
  .mob-accordion .io-toggle {
    height: 44px;
    padding: 0 .55rem;
    font-size: .64rem;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* On narrow desktop columns the 3-per-row field-rows squish paired
     inputs. Give each field a sensible min-width so field-rows wrap to
     a second line when the column is narrow — never cramping inputs.
     Standalone fields can pack 3 per row; paired ($ = %) fields wrap
     to their own line if they can't fit at their natural width. */
  .mob-accordion .field-row > .field {
    flex: 1 1 120px;
    min-width: 120px;
  }
  .mob-accordion .field-row > .field.field-pair {
    flex: 1.8 1 185px;
    min-width: 185px;
  }

  /* Field-pair ($ amount = %) — give the % side enough room so values like
     "6.9%" or "12.5%" never get clipped. 3:2 ratio with a hard min on the
     % half stops Management/Maintenance/Vacancy from cutting off. */
  .mob-accordion .field-pair .field-pair-inputs { gap: 18px; }
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap:first-child {
    flex: 3 1 0;
    min-width: 0;
  }
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap:last-child {
    flex: 0 0 64px;
    min-width: 64px;
  }
  .mob-accordion .field-pair .field-pair-inputs > .input-prefix-wrap:last-child::before {
    left: -13px;
  }

  /* Top breakdown bar + KPI strip + cashflow card — bigger on desktop */
  .top-breakdown-bar { height: 8px; border-radius: 4px; margin: .35rem 0 .45rem; }
  .results-strip { gap: .45rem; margin-bottom: .65rem; }
  .results-strip .result-cell { padding: .5rem .55rem; border-radius: 8px; }
  .results-strip .result-label { font-size: .6rem; margin-bottom: 3px; }
  .results-strip .result-value { font-size: 1.1rem; line-height: 1.25; }
  .results-strip .result-sub   { font-size: .7rem; margin-top: 2px; }

  /* Cashflow waterfall card — bigger and more readable */
  .cashflow-card { padding: .6rem 1rem .85rem; border-radius: 10px; }
  .cashflow-card > .card-title {
    padding: .45rem 0 .5rem;
    margin: 0 0 .45rem;
    font-size: .95rem;
  }
  .cashflow-card .card-title-val { font-size: 1rem; }
  .cashflow-card .cf-row {
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: .8rem;
    padding: .42rem 0;
    font-size: .92rem;
  }
  .cashflow-card .cf-row-head > div { font-size: .6rem; }
  .cashflow-card .cf-label { font-size: .88rem; }
  .cashflow-card .cf-val   { font-size: .98rem; }
  .cashflow-card .cf-dot   { width: 9px; height: 9px; margin-right: .5rem; }

  /* Refi section heading — more prominent on desktop */
  .refi-section-heading {
    padding: .75rem 1rem;
    font-size: .95rem;
    border-radius: 10px;
    margin: .4rem 0;
  }
  .refi-section-heading .refi-heading-chev { font-size: 1.25rem; }

  /* Cashflow-card embedded head: bar + 3 KPI pills stacked at the top */
  .cf-head { display: block; margin-bottom: .6rem; }
  .cf-head .cf-head-bar {
    display: flex;
    height: 8px;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: .5rem;
    background: var(--border);
  }
  .cf-head .cf-head-strip {
    display: flex;
    gap: .4rem;
    margin: 0;
  }
  .cf-head .cf-head-strip .result-cell {
    flex: 1 1 0;
    text-align: center;
    padding: .4rem .35rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 7px;
  }
  .cf-head .cf-head-strip .result-label {
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text3);
    line-height: 1;
    margin-bottom: 2px;
  }
  .cf-head .cf-head-strip .result-value {
    font-size: .95rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
  }

  /* ---- Calc shell + right strategy rail ----
     Shell is flex: calc-grid on the left grows to fill, rail sits on the
     right at fixed width. */
  .calc-shell {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
  }
  .calc-shell > .calc-grid { flex: 1 1 auto; min-width: 0; }
  .strategy-rail {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: .85rem .6rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: sticky;
    top: 1rem;
  }
  .srail-title {
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text3);
    padding: .15rem .4rem .35rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .25rem;
  }
  .srail-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .55rem .55rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text1);
    font-size: .82rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background .12s, border-color .12s;
  }
  .srail-item:hover:not(:disabled) { background: var(--bg3); }
  .srail-item.is-active {
    background: var(--mg-subtle);
    border-color: rgba(190,0,85,.25);
    color: var(--mg);
  }
  .srail-item.is-active .srail-label { font-weight: 800; }
  .srail-item:disabled,
  .srail-item.is-soon { cursor: not-allowed; opacity: .55; }
  .srail-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .srail-label { flex: 1 1 auto; }
  .srail-soon {
    font-size: .55rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: var(--border);
    color: var(--text2);
    padding: 2px 5px;
    border-radius: 4px;
  }

  /* ---- Strategy: Buy & Hold (default) ----
     Hide everything refi-related, collapse the grid to a single column,
     and cap the calc-grid width so the regular calculator stays centered
     and readable instead of stretching across the page. */
  body.strategy-buy-hold .calc-grid {
    grid-template-columns: minmax(0, 720px) !important;
    justify-content: center;
  }
  body.strategy-buy-hold #rcf_head_top,
  body.strategy-buy-hold #card_refi_closing,
  body.strategy-buy-hold #card_refi,
  body.strategy-buy-hold #card_refi_income,
  body.strategy-buy-hold #card_refi_expenses,
  body.strategy-buy-hold #card_refi_cashflow {
    display: none !important;
  }
  /* In buy-hold the regular column slides to col 1 (only column). */
  body.strategy-buy-hold #cf_head_top,
  body.strategy-buy-hold #card_purchase,
  body.strategy-buy-hold #card_income,
  body.strategy-buy-hold #card_financing,
  body.strategy-buy-hold #card_expenses,
  body.strategy-buy-hold #card_cashflow { grid-column: 1 !important; }

  /* ---- Strategy: BRRRR (refi 2-col, default visibility) ----
     Hide flip-only cards. Refi cards already visible by default. */
  body.strategy-brrrr .flip-card { display: none !important; }

  /* ---- Strategy: Fix & Flip ----
     Show flip cards in the right column. Hide rental income, refi cards,
     the buy-hold cashflow (rental cashflow is meaningless on a flip), and
     both KPI heads (KPIs are rental-specific; flip has its own profit
     summary card). */
  body.strategy-flip #cf_head_top,
  body.strategy-flip #rcf_head_top,
  body.strategy-flip #card_income,
  body.strategy-flip #card_cashflow,
  body.strategy-flip #card_refi_closing,
  body.strategy-flip #card_refi,
  body.strategy-flip #card_refi_income,
  body.strategy-flip #card_refi_expenses,
  body.strategy-flip #card_refi_cashflow {
    display: none !important;
  }
  /* Flip cards on right; purchase/financing/expenses on left */
  body.strategy-flip #card_purchase   { grid-column: 1 !important; grid-row: 1 !important; }
  body.strategy-flip #card_financing  { grid-column: 1 !important; grid-row: 2 !important; }
  body.strategy-flip #card_expenses   { grid-column: 1 !important; grid-row: 3 !important; }
  body.strategy-flip #card_flip_sale     { grid-column: 2 !important; grid-row: 1 !important; }
  body.strategy-flip #card_flip_holding  { grid-column: 2 !important; grid-row: 2 !important; }
  body.strategy-flip #card_flip_summary  { grid-column: 2 !important; grid-row: 3 !important; }
  /* Flip cards inherit the orange accent from the sale card's color */
  body.strategy-flip #card_flip_sale,
  body.strategy-flip #card_flip_holding,
  body.strategy-flip #card_flip_summary {
    border-left: 3px solid rgba(245,124,0,.5);
  }
}

/* Hide flip cards by default everywhere — only shown when strategy-flip
   class is set (also forces them into the right column on desktop above). */
.flip-card { display: none; }
body.strategy-flip .flip-card { display: block; }

/* Read-only computed-value display inputs (Monthly Carry, Total Holding) */
.input-prefix-wrap.readonly-display input {
  background: var(--mg-subtle);
  color: var(--mg);
  font-weight: 700;
  cursor: default;
  border-color: rgba(190,0,85,.3);
}

.flip-holding-note {
  font-size: .65rem;
  color: var(--text3);
  margin-top: .35rem;
  padding: .35rem .5rem;
  background: var(--bg3);
  border-radius: 6px;
  line-height: 1.4;
}

/* Profit summary card layout */
.flip-summary-grid {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .25rem 0;
}
.flip-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .3rem .15rem;
  font-size: .82rem;
  color: var(--text1);
}
.flip-row-sub { padding-left: 1rem; color: var(--text2); font-size: .76rem; }
.flip-row-total {
  font-weight: 800;
  color: var(--text);
  border-top: 1px dashed var(--border);
  padding-top: .45rem;
  margin-top: .15rem;
}
.flip-row-divider { height: 1px; background: var(--border); margin: .35rem 0; }
.flip-row-profit {
  font-size: 1.05rem;
  font-weight: 800;
}
.flip-row-profit .flip-row-val { color: var(--positive); }
.flip-row-profit.is-loss .flip-row-val { color: var(--negative); }
.flip-row-val { font-variant-numeric: tabular-nums; }

/* Mobile: rail collapses into a small chip row at the top of the calc
   so the user can still pick a strategy. Buy & Hold default still hides
   the refi section unless explicitly switched on. */
@media (max-width: 768px) {
  /* Stack the rail above the calc-grid */
  .calc-shell { display: flex; flex-direction: column; }
  .calc-shell > .strategy-rail { order: -1; }

  .strategy-rail {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: .35rem;
    padding: .5rem .65rem;
    margin: 0 .25rem .5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    top: auto;
    -webkit-overflow-scrolling: touch;
  }
  .srail-title { display: none; }
  .srail-item {
    flex: 0 0 auto;
    padding: .35rem .55rem;
    border: 1px solid var(--border);
    background: var(--bg3);
    border-radius: 999px;
    font-size: .72rem;
    white-space: nowrap;
  }
  .srail-item.is-active {
    background: var(--mg);
    border-color: var(--mg);
    color: #fff;
  }
  .srail-soon { font-size: .5rem; }

  /* Mobile buy-hold: hide the entire Refinance Analysis section heading +
     all refi cards + the refi top breakdown bar/strip. */
  body.strategy-buy-hold .refi-section-heading,
  body.strategy-buy-hold .refi-breakdown-bar,
  body.strategy-buy-hold .refi-results-strip,
  body.strategy-buy-hold #card_refi_closing,
  body.strategy-buy-hold #card_refi,
  body.strategy-buy-hold #card_refi_income,
  body.strategy-buy-hold #card_refi_expenses,
  body.strategy-buy-hold #card_refi_cashflow {
    display: none !important;
  }

  /* Mobile fix-and-flip: hide rental-only sections, show flip cards inline. */
  body.strategy-flip #cf_head_top,
  body.strategy-flip .refi-section-heading,
  body.strategy-flip .refi-breakdown-bar,
  body.strategy-flip .refi-results-strip,
  body.strategy-flip #card_income,
  body.strategy-flip #card_cashflow,
  body.strategy-flip #card_refi_closing,
  body.strategy-flip #card_refi,
  body.strategy-flip #card_refi_income,
  body.strategy-flip #card_refi_expenses,
  body.strategy-flip #card_refi_cashflow {
    display: none !important;
  }
}




/* ============================================================
   PORTFOLIO v2 — Stessa-style overview + property detail
   ============================================================ */
.portfolio-page { padding: 0; max-width: 100%; min-width: 0; }
.portfolio-page #detail_body, .portfolio-page #pf_body { min-width: 0; }
.portfolio-page .detail-split { min-width: 0; }
.portfolio-page .scrollable-page-header,
.portfolio-page .page-header { display: none; }

/* ---------- Header ---------- */
.pf-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.pf-back {
  display: inline-block;
  font-size: .8rem;
  color: var(--text3);
  text-decoration: none;
  margin-bottom: .25rem;
}
.pf-back:hover { color: var(--text); }
.pf-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.pf-title    { font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; }
.pf-subtitle { font-size: .78rem; color: var(--text3); margin-top: .15rem; }
.pf-actions  { display: flex; gap: .4rem; align-items: center; }

/* ---------- Property picker (replaces the old title) ---------- */
.pf-title-wrap { display: flex; flex-direction: column; min-width: 0; }
.property-picker {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 0 1.6rem 0 0;
  appearance: none;
  cursor: pointer;
  line-height: 1.25;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23777' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  max-width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.property-picker:hover { color: var(--mg, #c80e3a); }
.property-picker:focus { outline: none; color: var(--mg, #c80e3a); }

.invest-readout-agg .invest-total { margin-top: .5rem; }

/* ---------- Period chips (reuse existing .chip styles from v1) ---------- */
.period-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  margin-top: .75rem;
}
.period-bar .chip {
  padding: .35rem .7rem;
  font-size: .72rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
}
.period-bar .chip:hover { background: var(--surface); }
.period-bar .chip.active {
  background: var(--text);
  color: var(--card);
  border-color: var(--text);
}
.custom-range {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-left: .5rem;
}
.custom-range input[type="date"] {
  font-size: .72rem;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: .3rem;
}
.period-label {
  margin-left: auto;
  font-size: .72rem;
  color: var(--text3);
  font-weight: 500;
}

/* ---------- Empty state ---------- */
.empty-wrap {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.empty-card {
  max-width: 420px;
  text-align: center;
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: .5rem;
  background: var(--card);
}
.empty-card h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.empty-card p  { color: var(--text3); font-size: .85rem; margin-bottom: 1.1rem; }
.empty-card.small { padding: 1.25rem; }

/* ---------- Body shell ---------- */
#pf_body, #detail_body { padding: 1.25rem 1.5rem 2.5rem; }

/* ---------- Summary tiles ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.summary-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding: 1.1rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-height: 180px;
  box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.st-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.st-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--text);
}
.summary-tile.pos .st-value { color: #15854a; }
.summary-tile.neg .st-value { color: #c23030; }
.st-sub {
  font-size: .72rem;
  color: var(--text3);
  margin-bottom: .4rem;
}
.st-breakdown {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding-top: .6rem;
  border-top: 1px solid rgba(0,0,0,.05);
}
.st-row {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text2);
}
.st-row span:first-child { color: var(--text3); }
.st-row .neg { color: #c23030; }
.st-row.sub  { font-size: .72rem; color: var(--text3); }
.st-hint {
  font-size: .68rem;
  color: var(--text3);
  font-style: italic;
  margin-top: .35rem;
}

/* ---------- Section shell ---------- */
.pf-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding: 1rem 1.25rem 1.15rem;
  margin-bottom: 1.25rem;
}
.pf-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: .75rem;
  gap: 1rem;
}
.pf-section-title { font-weight: 650; font-size: .95rem; color: var(--text); }
.pf-section-sub   { font-size: .73rem; color: var(--text3); }

/* ---------- Property list (overview) ---------- */
.prop-list {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: .45rem;
  text-decoration: none;
  color: inherit;
  transition: all .12s;
  background: var(--card);
}
.prop-row:hover {
  border-color: var(--primary, #5a34d1);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transform: translateY(-1px);
}
.prop-row.empty {
  color: var(--text3);
  font-style: italic;
  justify-content: center;
  cursor: default;
}
.prop-main { flex: 1; min-width: 0; }
.prop-name { font-weight: 600; font-size: .92rem; color: var(--text); }
.prop-meta { font-size: .72rem; color: var(--text3); margin-top: .15rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.prop-tag  {
  display: inline-block;
  padding: .1rem .45rem;
  background: rgba(90,52,209,.1);
  color: #5a34d1;
  border-radius: 99px;
  font-size: .64rem;
  font-weight: 500;
}
.prop-tag.muted { background: rgba(0,0,0,.05); color: var(--text3); }
.prop-metrics {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.pm { text-align: right; min-width: 90px; }
.pm-label { font-size: .65rem; color: var(--text3); text-transform: uppercase; letter-spacing: .03em; }
.pm-value { font-size: .88rem; font-weight: 600; margin-top: .1rem; }
.pm-value.pos { color: #15854a; }
.pm-value.neg { color: #c23030; }
.pm-chev { font-size: 1.4rem; color: var(--text3); font-weight: 300; padding-left: .5rem; }

/* ---------- Uploads strip ---------- */
.uploads-strip { display: flex; flex-wrap: wrap; gap: .4rem; }
.upload-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .7rem;
  color: var(--text2);
}
.uc-type { font-weight: 600; text-transform: capitalize; color: var(--text); }
.uc-file { color: var(--text3); max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-rows { color: var(--text3); }
.uc-when { color: var(--text3); }

/* ---------- Cashflow trend (v2: stacked carrying + expected-rent frame) ---------- */
.trend-chart { min-height: 220px; min-width: 0; }
.tc-plot {
  position: relative;
  height: 200px;
  min-width: 0;        /* let the flex/grid parent shrink us down */
  max-width: 100%;
}
.tc-bars {
  display: flex;
  gap: .5rem;
  padding: .5rem .25rem 0;
  height: 100%;
  align-items: stretch;
}
.tc-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  cursor: pointer;
  padding: .2rem .1rem;
  border-radius: .3rem;
  transition: background .12s;
  justify-content: flex-end;
  position: relative;
  z-index: 2;
}
.tc-col:hover { background: rgba(0,0,0,.035); }
.tc-col.sel {
  background: rgba(90,52,209,.08);
  outline: 1px solid rgba(90,52,209,.3);
}
.tc-stack {
  display: flex;
  gap: 3px;
  align-items: stretch;        /* tc-inc and tc-exp fill full stack height */
  height: 150px;
  width: 100%;
  max-width: 46px;
}
.tc-inc, .tc-exp {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;   /* content grows up from the bottom */
  height: 100%;
}
.tc-exp {
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}
/* Income side: expected-rent outlined frame with fills inside it */
.tc-exp-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border: 1.5px solid #2f9d5b;
  border-radius: 3px;
  background: rgba(47,157,91,.06);
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}
.tc-exp-fill-op {
  width: 100%;
  background: repeating-linear-gradient(
    -45deg,
    #8fd6aa 0 4px,
    #b6e5c3 4px 8px
  );
}
.tc-exp-fill-bm {
  width: 100%;
  background: #2f9d5b;
}
/* Income above / instead of the expected-rent frame */
.tc-inc-over {
  width: 100%;
  background: #9bddb4;
  border-radius: 3px 3px 0 0;
}
.tc-inc-unframed {
  width: 100%;
  background: #2f9d5b;
  border-radius: 3px 3px 0 0;
}
/* Expense side: stacked segments (source order top→bottom;
   justify-content:flex-end packs them at the bottom of the bar) */
.tc-seg { width: 100%; min-height: 1px; }
.tc-seg-op   { background: #d04848; }
.tc-seg-opop {
  background: repeating-linear-gradient(
    -45deg,
    #d04848 0 4px,
    #eb9c9c 4px 8px
  );
}
.tc-seg-mort { background: #8e6ee0; }
.tc-seg-tax  { background: #e89b3c; }
.tc-seg-ins  { background: #2fa6b9; }

.tc-label { font-size: .62rem; color: var(--text3); text-transform: uppercase; letter-spacing: .02em; }
.tc-net   { font-size: .68rem; font-weight: 600; }
.tc-net.pos { color: #15854a; }
.tc-net.neg { color: #c23030; }

/* Net-line overlay SVG — sits on top of the bars */
.tc-netline {
  position: absolute;
  top: .5rem; left: .25rem; right: .25rem;
  height: calc(100% - .5rem - 2.2rem); /* leave room for labels */
  pointer-events: none;
  z-index: 1;
}
.tc-netline polyline {
  fill: none;
  stroke: #1f2a44;
  stroke-width: .6;
  stroke-dasharray: 2 2;
  vector-effect: non-scaling-stroke;
  opacity: .55;
}
/* Net-line dots — positioned via absolute HTML so they render as true
   circles regardless of the chart's aspect ratio */
.tc-netdots {
  position: absolute;
  top: .5rem; left: .25rem; right: .25rem;
  height: calc(100% - .5rem - 2.2rem);
  pointer-events: none;
  z-index: 2;
}
.tc-netdot {
  position: absolute;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;  /* center on (left%, top%) */
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.tc-netdot.pos { background: #15854a; }
.tc-netdot.neg { background: #c23030; }

/* Hover tooltip */
.tc-tooltip {
  position: absolute;
  background: #1f2a44;
  color: #f4f5f7;
  padding: .55rem .7rem;
  border-radius: .4rem;
  font-size: .7rem;
  pointer-events: none;
  box-shadow: 0 6px 22px rgba(0,0,0,.25);
  z-index: 10;
  min-width: 220px;
  line-height: 1.35;
}
.tcc-title { font-weight: 700; font-size: .78rem; margin-bottom: .2rem; }
.tcc-sec {
  font-size: .55rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #8a93ae;
  margin: .35rem 0 .15rem;
}
.tcc-row {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  padding: .05rem 0;
}
.tcc-row span { color: #c9cfe1; }
.tcc-row strong { font-weight: 600; }
.tcc-row.neg strong { color: #ff9898; }
.tcc-row.good strong { color: #7ce2a4; }
.tcc-row.warn strong { color: #f4c678; }
.tcc-row.bad  strong { color: #ff9898; }
.tcc-net {
  display: flex;
  justify-content: space-between;
  margin-top: .4rem;
  padding-top: .3rem;
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: .78rem;
  font-weight: 700;
}
.tcc-net.pos strong { color: #7ce2a4; }
.tcc-net.neg strong { color: #ff9898; }

/* ---------- Chart income view toggle (cash vs accrual) ---------- */
.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.vt-btn {
  padding: .25rem .7rem;
  font-size: .68rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: 99px;
  color: var(--text3);
  cursor: pointer;
  transition: background .12s, color .12s;
  line-height: 1.2;
  white-space: nowrap;
}
.vt-btn:hover { color: var(--text2); }
.vt-btn.active {
  background: var(--text);
  color: var(--card);
}

/* ---------- Chart KPI strip (Collection Rate + legend) ---------- */
.chart-kpis {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: .75rem;
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid rgba(0,0,0,.06);
}
.ck-collect {
  background: var(--surface);
  border-radius: .5rem;
  padding: .85rem 1rem;
  border-left: 3px solid #9aa5c1;
}
.ck-collect.good { border-left-color: #15854a; background: rgba(47,157,91,.06); }
.ck-collect.warn { border-left-color: #e89b3c; background: rgba(232,155,60,.06); }
.ck-collect.bad  { border-left-color: #c23030; background: rgba(194,48,48,.06); }
.ck-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text3); font-weight: 600; }
.ck-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; margin: .1rem 0; color: var(--text); }
.ck-collect.good .ck-value { color: #15854a; }
.ck-collect.warn .ck-value { color: #c37a1e; }
.ck-collect.bad  .ck-value { color: #c23030; }
.ck-sub { font-size: .72rem; color: var(--text2); margin-bottom: .5rem; }
.ck-bar {
  height: 6px;
  background: rgba(0,0,0,.07);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .35rem;
}
.ck-bar-fill {
  height: 100%;
  background: currentColor;
  transition: width .4s ease;
}
.ck-collect.good .ck-bar-fill { background: #15854a; }
.ck-collect.warn .ck-bar-fill { background: #e89b3c; }
.ck-collect.bad  .ck-bar-fill { background: #c23030; }
.ck-period { font-size: .62rem; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; }

.ck-legend {
  background: var(--surface);
  border-radius: .5rem;
  padding: .75rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .28rem;
  font-size: .7rem;
  color: var(--text2);
}
.ck-leg-row { display: flex; align-items: center; gap: .4rem; }
.ck-leg-desc { color: var(--text3); font-size: .64rem; font-style: italic; margin-left: .25rem; }
.ck-sw {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}
.ck-sw.bm     { background: #2f9d5b; }
.ck-sw.op     { background: repeating-linear-gradient(-45deg, #8fd6aa 0 3px, #b6e5c3 3px 6px); }
.ck-sw.frame  { border: 1.5px solid #2f9d5b; background: rgba(47,157,91,.06); }
.ck-sw.red    { background: #d04848; }
.ck-sw.purple { background: #8e6ee0; }
.ck-sw.amber  { background: #e89b3c; }
.ck-sw.teal   { background: #2fa6b9; }
.ck-sw.dot    { width: 12px; height: 2px; background: #1f2a44; border-radius: 1px; }

/* ---------- Rent ledger ---------- */
.ledger-block {
  border: 1px solid var(--border);
  border-radius: .45rem;
  padding: .9rem 1rem;
  margin-bottom: .75rem;
  background: var(--card);
}
.ledger-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.ledger-unit { font-weight: 600; font-size: .9rem; }
.ledger-sub  { font-size: .72rem; color: var(--text3); margin-top: .15rem; display: flex; gap: .5rem; align-items: center; }
.ledger-rent { color: var(--text2); }
.ledger-rent.muted em { color: var(--text3); font-style: italic; }
.ledger-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.badge-evict {
  background: #fdecec;
  color: #b22;
  padding: .05rem .45rem;
  border-radius: 99px;
  font-size: .62rem;
  font-weight: 600;
}
.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}
.ledger-table thead th {
  text-align: left;
  font-size: .66rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--border);
}
.ledger-table td {
  padding: .4rem .5rem;
  border-bottom: 1px solid rgba(0,0,0,.04);
  color: var(--text2);
}
.ledger-table td.pos { color: #15854a; }
.ledger-table td.neg { color: #c23030; }
.ledger-table .muted { color: var(--text3); }
.ledger-table tfoot td {
  font-weight: 600;
  color: var(--text);
  padding-top: .5rem;
  border-top: 1px solid var(--border);
  border-bottom: none;
  background: rgba(0,0,0,.02);
}
.op-tag {
  display: inline-block;
  background: rgba(90,52,209,.1);
  color: #5a34d1;
  padding: .05rem .4rem;
  border-radius: 3px;
  font-size: .72rem;
}

/* ---------- Income & Expenses accordion ---------- */
.ie-section {
  border-bottom: 1px solid var(--border);
  padding: .65rem 0;
}
.ie-section:last-child { border-bottom: none; }
.ie-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 650;
  font-size: .9rem;
  color: var(--text);
  margin-bottom: .4rem;
  gap: 1rem;
}
.ie-title { display: flex; align-items: center; gap: .5rem; }
.ie-source { font-weight: 400; font-size: .68rem; color: var(--text3); font-style: italic; }
.ie-items  { display: flex; flex-direction: column; gap: .1rem; }
.ie-item {
  display: flex;
  justify-content: space-between;
  padding: .35rem .6rem;
  font-size: .82rem;
  border-radius: .3rem;
  color: var(--text2);
}
.ie-item.openable { cursor: pointer; }
.ie-item.openable:hover { background: rgba(0,0,0,.035); }
.ie-amt { font-weight: 500; }
.ie-amt.neg { color: #c23030; }
.ie-empty { font-size: .75rem; color: var(--text3); font-style: italic; padding: .25rem .5rem; }
.ie-empty.small { font-size: .7rem; }
.ie-loading { font-size: .75rem; color: var(--text3); padding: .5rem; }
.ie-txns { display: none; padding: 0 0 .5rem 1rem; }
.ie-txns.open { display: block; }
.op-tag-note {
  display: inline-block;
  font-weight: 400;
  font-size: .68rem;
  background: rgba(0,0,0,.04);
  color: var(--text3);
  padding: .05rem .35rem;
  border-radius: 3px;
  margin-left: .35rem;
}
.delete-op {
  margin-left: .4rem;
  padding: 0 .35rem;
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: .7rem;
}
.delete-op:hover { color: #c23030; }

/* ---------- Transaction table (in-accordion drill) ---------- */
.txn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .74rem;
  margin-top: .35rem;
}
.txn-table th {
  text-align: left;
  font-size: .62rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
  padding: .3rem .5rem;
  border-bottom: 1px solid var(--border);
}
.txn-table td {
  padding: .3rem .5rem;
  border-bottom: 1px solid rgba(0,0,0,.035);
  color: var(--text2);
}
.txn-table td.right, .txn-table th.right { text-align: right; }

/* ---------- Investment section ---------- */
.invest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.invest-col { display: flex; flex-direction: column; gap: .75rem; }
.invest-section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text3);
  font-weight: 600;
  margin-top: .25rem;
}
.invest-toggle {
  display: flex;
  gap: 1rem;
  font-size: .82rem;
  color: var(--text2);
}
.invest-toggle label { display: flex; align-items: center; gap: .3rem; cursor: pointer; }
.invest-block {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .75rem .85rem;
  background: var(--surface);
  border-radius: .4rem;
  border: 1px solid var(--border);
}
.invest-block label {
  font-size: .72rem;
  color: var(--text3);
  font-weight: 500;
}
.invest-block input,
.invest-block select {
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: .3rem;
  font-size: .82rem;
  background: var(--card);
}
.invest-inline { display: flex; gap: .35rem; align-items: center; }
.invest-inline input { flex: 1; }
.invest-hint { font-size: .7rem; color: var(--text3); font-style: italic; }
.invest-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem .9rem;
  padding-top: .4rem;
  border-top: 1px solid rgba(0,0,0,.06);
}
.invest-readout > div {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text2);
}
.invest-readout > div span { color: var(--text3); }
.invest-readout .invest-total {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(0,0,0,.07);
  padding-top: .35rem;
  margin-top: .25rem;
  font-weight: 650;
  color: var(--text);
}

/* ---------- Modal shell ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 32, .55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}
.modal-body {
  background: var(--card);
  border-radius: .6rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 1.5rem;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.modal-body h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.btn-xs {
  padding: .1rem .45rem;
  font-size: .66rem;
  height: auto;
  line-height: 1.4;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: .3rem;
  color: var(--text3);
  cursor: pointer;
}
.btn-xs:hover { color: var(--text); border-color: var(--text3); }
.mb-md { margin-bottom: 1rem; }
.text-muted { color: var(--text3); }

/* ---------- Upload modal fields ---------- */
.upload-field {
  margin-bottom: .85rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.upload-field label {
  font-weight: 600;
  font-size: .8rem;
  color: var(--text);
}
.upload-field input[type="file"],
.upload-field input[type="text"],
.upload-field input[type="number"],
.upload-field input[type="date"],
.upload-field input[type="month"],
.upload-field select {
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: .3rem;
  font-size: .82rem;
  background: var(--card);
}
.field-hint {
  font-weight: 400;
  font-size: .7rem;
  color: var(--text3);
  margin-left: .35rem;
}
.field-help {
  font-size: .72rem;
  color: var(--text3);
  margin-top: .1rem;
}
.upload-status {
  font-size: .78rem;
  color: var(--text3);
  min-height: 1.2em;
  margin: .5rem 0;
}
.upload-status.err { color: #c23030; font-weight: 600; }
.upload-status.ok  { color: #15854a; font-weight: 600; }

/* ---------- Slim summary tiles on property detail ---------- */
.summary-grid--slim { gap: .6rem; margin-bottom: 1rem; }
.summary-grid--slim .summary-tile {
  min-height: 0;
  padding: .65rem .85rem .7rem;
  gap: .15rem;
  border-radius: .5rem;
  box-shadow: none;
}
.summary-grid--slim .st-label { font-size: .6rem; }
.summary-grid--slim .st-value { font-size: 1.1rem; }
.summary-grid--slim .st-sub   { font-size: .62rem; margin-bottom: .2rem; }
.summary-grid--slim .st-breakdown { padding-top: .35rem; gap: .1rem; }
.summary-grid--slim .st-row       { font-size: .7rem; }
.summary-grid--slim .st-row.sub   { font-size: .65rem; }
.summary-grid--slim .st-hint      { font-size: .62rem; }

/* ---------- Detail split: chart | IE side panel ---------- */
.detail-split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: stretch;
}
.detail-split-chart, .detail-split-ie { margin-bottom: 0; }
.detail-split-ie  { display: flex; flex-direction: column; }
.detail-split-ie #ie_body { flex: 1; }
.detail-split-ie .pf-section-head { margin-bottom: .4rem; }
.detail-split-ie .pf-section-head #ie_clear_btn { align-self: flex-start; }

/* NET chip sits inline with the section subtitle */
.ie-sub-net {
  display: inline-flex;
  align-items: baseline;
  gap: .25rem;
  font-weight: 700;
  font-size: .78rem;
  margin-left: .5rem;
  padding: .05rem .4rem;
  border-radius: .25rem;
}
.ie-sub-net.pos { background: rgba(47,157,91,.1);  color: #15854a; }
.ie-sub-net.neg { background: rgba(194,48,48,.1); color: #c23030; }

/* Compact rows so every group fits without scrolling */
.detail-split-ie .ie-section { padding: .42rem 0; }
.detail-split-ie .ie-head    { margin-bottom: .2rem; font-size: .82rem; }
.detail-split-ie .ie-item    { padding: .22rem .5rem; font-size: .76rem; }
.detail-split-ie .ie-empty   { padding: .2rem .5rem; font-size: .7rem; }
.detail-split-ie .ie-total   { font-size: .84rem; }

.ie-op-row { background: rgba(47,157,91,.06); border-radius: .25rem; }
.ie-op-row .ie-name { color: #0f5b32; font-weight: 500; }

/* When the ledger's Expected column shows the Buildium tenant-portion
   charge (because the owner hasn't entered the full rent yet), render it
   slightly muted + italic so it's clear it's a Buildium fallback, not the
   owner's authoritative number. */
.exp-from-buildium {
  color: var(--text2);
  font-style: italic;
  cursor: help;
  border-bottom: 1px dotted var(--text3);
}

/* "Refund" tag next to an expense line when the posted net is negative
   (money came back). Renders alongside the account name, with the amount
   green + a + sign so the user reads it as a credit, not another expense. */
.ie-credit-tag {
  display: inline-block;
  font-style: normal;
  font-size: .62rem;
  font-weight: 600;
  padding: .05rem .4rem;
  background: rgba(47,157,91,.12);
  color: #0f5b32;
  border-radius: 99px;
  margin-left: .4rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ---------- Color-coded IE sidebar (matches chart palette) ---------- */
.ie-section {
  border-left: 3px solid transparent;
  padding-left: .6rem !important;   /* override default .65rem 0 in detail-split-ie */
  margin-left: 0;
}
.ie-section.s-income   { border-left-color: #2f9d5b; }
.ie-section.s-expense  { border-left-color: #d04848; }
.ie-section.s-carrying {
  border-left: 3px solid transparent;
  border-image: linear-gradient(to bottom, #8e6ee0, #e89b3c, #2fa6b9) 1 100%;
}
.s-income  .ie-title { color: #0f5b32; }
.s-expense .ie-title { color: #8a2222; }
.s-carrying .ie-title { color: #463982; }

/* Colored dot prefixing each item row — mirrors chart color */
.ie-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: .45rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.ie-dot-bm     { background: #2f9d5b; }
.ie-dot-op     { background: repeating-linear-gradient(-45deg, #8fd6aa 0 3px, #b6e5c3 3px 6px); }
.ie-dot-red    { background: #d04848; }
.ie-dot-purple { background: #8e6ee0; }
.ie-dot-amber  { background: #e89b3c; }
.ie-dot-teal   { background: #2fa6b9; }
.ie-dot-gray   { background: #a9b0c2; }

.ie-name { display: flex; align-items: center; min-width: 0; }
.ie-name > span.ie-dot + * { /* guard in case wrapper adds extra */ }

/* Subtle hover of a row tints the background to match its dot color */
.detail-split-ie .ie-item.openable:hover { background: rgba(0,0,0,.04); }

/* ---------- Buildium Delinquent strip in the ledger ---------- */
.ledger-buildium {
  background: var(--surface);
  border-left: 3px solid #9aa5c1;
  border-radius: .35rem;
  padding: .55rem .75rem;
  margin-bottom: .6rem;
  font-size: .76rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.ledger-buildium.ok   { border-left-color: #15854a; background: rgba(47,157,91,.05); }
.ledger-buildium.warn { border-left-color: #e89b3c; background: rgba(232,155,60,.05); }
.lb-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.lb-tag {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: .62rem;
  color: var(--text3);
}
.lb-balance.neg { color: #c23030; font-weight: 700; }
.lb-balance.pos { color: #15854a; font-weight: 700; }
.lb-aging, .lb-last { color: var(--text3); font-size: .7rem; }
.lb-cmp { font-size: .7rem; }
.lb-match    { color: #0f5b32; font-weight: 600; }
.lb-mismatch { color: #8a4a14; }
.lb-mismatch em { font-style: normal; font-weight: 600; color: var(--text); }

/* ---------- "Detect from Buildium GL" panel ---------- */
.rh-detect {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .75rem; margin-bottom: .75rem;
  background: rgba(90,52,209,.05);
  border-radius: .35rem;
  flex-wrap: wrap;
}
.rh-detect-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .4rem;
  padding: .8rem .9rem;
  margin-bottom: .9rem;
}
.rh-detect-title {
  font-weight: 650;
  font-size: .85rem;
  margin-bottom: .5rem;
  color: var(--text);
}
.rh-detect-sub { font-size: .76rem; color: var(--text2); line-height: 1.4; }
.rh-detect-bd {
  font-size: .74rem;
  color: var(--text2);
  margin-top: .55rem;
  padding-top: .45rem;
  border-top: 1px dashed var(--border);
}
.rh-detect-actions {
  display: flex; gap: .4rem; justify-content: flex-end;
  margin-top: .7rem;
}

/* ---------- Rent history modal ---------- */
.rh-subhead {
  font-size: .78rem;
  font-weight: 650;
  color: var(--text2);
  margin: 1.1rem 0 .4rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.rh-empty {
  padding: .75rem;
  background: var(--surface);
  border-radius: .3rem;
  font-size: .78rem;
  color: var(--text3);
  font-style: italic;
}
.rh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}
.rh-table thead th {
  text-align: left;
  font-size: .65rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--border);
}
.rh-table td {
  padding: .4rem .5rem;
  border-bottom: 1px solid rgba(0,0,0,.04);
}
.rh-table .muted { color: var(--text3); font-style: italic; }
.rh-del { color: #c23030; }
.rh-form { display: flex; flex-direction: column; gap: .25rem; }
.rh-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
}

/* ---------- Responsive: tablet ≤1100px ---------- */
@media (max-width: 1100px) {
  .detail-split { grid-template-columns: 1fr; }
  .chart-kpis   { grid-template-columns: 1fr; }
}

/* ---------- Responsive: mobile ≤900px ---------- */
@media (max-width: 900px) {
  /* ── Body padding — tighter overall ── */
  #pf_body, #detail_body { padding: .4rem; }
  .prop-row { flex-direction: column; align-items: stretch; gap: .5rem; }
  .prop-metrics { justify-content: space-between; }
  .summary-grid { grid-template-columns: 1fr; }
  .invest-grid  { grid-template-columns: 1fr; }
  .invest-readout { grid-template-columns: 1fr; }
  .rh-form-row  { grid-template-columns: 1fr; }

  /* ── HEADER: single row, tight padding ── */
  .pf-header { padding: .4rem .5rem .35rem; }
  .pf-back   { font-size: .7rem; margin-bottom: 0; }
  .pf-header-row {
    display: flex; align-items: center; gap: .35rem;
    flex-wrap: nowrap; margin: 0;
  }
  .pf-title-wrap { flex: 1; min-width: 0; }
  .property-picker {
    font-size: .95rem; font-weight: 650; padding: 0 1.2rem 0 0;
    max-width: 100%; line-height: 1.2;
  }
  .pf-subtitle { display: none; }           /* address/subtitle lives in picker */
  .pf-actions .btn-primary {
    font-size: .65rem; padding: .3rem .6rem; height: auto;
    white-space: nowrap;
  }

  /* ── PERIOD CHIPS: single horizontal scrolling row ── */
  .period-bar {
    display: flex; flex-wrap: nowrap; gap: .25rem;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; margin-top: .4rem;
    scrollbar-width: none;
  }
  .period-bar::-webkit-scrollbar { display: none; }
  .period-bar .chip {
    flex-shrink: 0; padding: .2rem .5rem; font-size: .62rem;
  }
  .period-label { display: none; }          /* the active chip IS the label */
  .custom-range { flex-wrap: wrap; margin-left: 0; }

  /* ── SECTION PADDING: very tight on mobile ── */
  .pf-section { padding: .5rem .5rem .6rem; margin-bottom: .6rem; }
  .pf-section-head { margin-bottom: .3rem; }
  .pf-section-title { font-size: .85rem; }
  .pf-section-sub   { font-size: .62rem; }

  /* ── CHART CARD LAYOUT: Balance card goes ABOVE the chart so it's
        always in view when the user taps a month to rescope the panel. ── */
  .detail-split-chart { display: flex; flex-direction: column; overflow: hidden; padding: .4rem .4rem .5rem; }
  .detail-split-chart .pf-section-head { order: 0; }
  .detail-split-chart .chart-kpis      { order: 1; margin-top: 0; padding-top: 0; padding-bottom: .4rem; border-top: none; border-bottom: 1px solid rgba(0,0,0,.08); margin-bottom: .5rem; }
  .detail-split-chart .trend-chart     { order: 2; }

  /* ── KPIs compacted, legend hidden (colors are explanatory on their own) ── */
  .chart-kpis  { grid-template-columns: 1fr; gap: 0; }
  .ck-collect  { padding: .4rem .6rem; border-left-width: 3px; border-radius: .35rem; }
  .ck-label    { font-size: .58rem; }
  .ck-value    { font-size: 1rem; margin: 0; }
  .ck-sub      { font-size: .64rem; margin-bottom: 0; }
  .ck-period   { display: none; }
  .ck-bar      { display: none; }
  .ck-legend   { display: none; }          /* save vertical space on mobile */

  /* ── CHART: short + horizontally scrollable inside its card ── */
  .trend-chart { width: 100%; min-width: 0; }
  .tc-plot {
    height: 150px; width: 100%; max-width: 100%;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }
  .tc-plot::-webkit-scrollbar { height: 4px; }
  .tc-plot::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 2px; }
  .tc-bars  { min-width: 480px; padding: .4rem .25rem .2rem; gap: .3rem; box-sizing: border-box; }
  .tc-col   { min-width: 0; padding: .1rem 1px; scroll-snap-align: start; }
  .tc-stack { max-width: 36px; width: 100%; height: 105px; gap: 2px; }
  .tc-inc, .tc-exp { min-width: 0; }
  .tc-label { font-size: .58rem; letter-spacing: 0; white-space: nowrap; }
  .tc-net   { font-size: .6rem; white-space: nowrap; }
  .view-toggle { padding: 1px; }
  .vt-btn   { padding: .18rem .55rem; font-size: .62rem; }

  /* Tooltip pinned to top-right */
  .tc-tooltip { position: absolute; top: .4rem; right: .4rem; left: auto !important; min-width: 0; max-width: 78vw; font-size: .62rem; padding: .4rem .5rem; }

  /* ── INCOME & EXPENSES PANEL — compact ── */
  .detail-split-ie { padding: .5rem .5rem .6rem; }
  .detail-split-ie .ie-section { padding: .3rem 0; }
  .detail-split-ie .ie-head    { font-size: .78rem; margin-bottom: .15rem; }
  .detail-split-ie .ie-item    { padding: .18rem .4rem; font-size: .72rem; }
  .ie-sub-net { font-size: .72rem; padding: 0 .35rem; }

  /* ── RENT COLLECTION LEDGER: table scrolls horizontally inside card ── */
  .ledger-block    { padding: .55rem .6rem; }
  .ledger-head     { flex-direction: column; align-items: stretch; gap: .3rem; }
  .ledger-unit     { font-size: .82rem; }
  .ledger-actions  { flex-wrap: wrap; gap: .25rem; }
  .ledger-actions .btn { flex: 1; min-width: 45%; font-size: .68rem; padding: .3rem .5rem; }
  .ledger-table    { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .ledger-table thead, .ledger-table tbody, .ledger-table tfoot { display: table; width: 100%; min-width: 420px; }
  .ledger-table thead th, .ledger-table td, .ledger-table tfoot td { padding: .3rem .4rem; font-size: .68rem; }
  .ledger-summary .lb-row { flex-wrap: wrap; gap: .3rem; }
  .lb-last, .lb-aging    { font-size: .62rem; }
  .lb-tag { font-size: .56rem; }

  /* ── MODALS & MISC ── */
  .modal-body { max-width: 95vw; padding: 1rem; }
  .txn-table  { display: block; overflow-x: auto; white-space: nowrap; }
  .rh-table   { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- Responsive: narrow phones ≤480px ---------- */
@media (max-width: 480px) {
  .property-picker { font-size: .9rem; }
  .period-bar .chip { padding: .18rem .45rem; font-size: .6rem; }
  .tc-stack { max-width: 32px; height: 100px; }
  .tc-label { font-size: .55rem; }
  .tc-net   { font-size: .58rem; }
  .ck-value { font-size: .95rem; }
  .summary-grid--slim .st-value { font-size: .95rem; }
  .summary-tile { padding: .5rem .65rem; }
}
