:root {
  --navy: #0d3b52;
  --navy-2: #164b66;
  --ink: #1d2730;
  --muted: #62707c;
  --bg: #f3f5f7;
  --card: #fff;
  --line: #e3e7ea;
  --green: #1f8a4c;
  --green-bg: #e8f6ee;
  --blue: #1f6fb2;
  --orange: #d9822b;
  --red: #c62828;
  --gold: #c9a227;
  --radius: 14px;
  --tap: 48px;
  --shadow: 0 1px 3px rgba(13, 59, 82, 0.08);
  --header-h: 52px;
  --summary-h: 64px;
  --z-chrome: 30;
  --z-wiz-footer: 15;
  --z-summary: 35;
  --z-suggest: 40;
  --z-toast: 60;
  --z-drawer-bg: 100;
  --z-drawer: 110;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { padding-bottom: calc(var(--summary-h) + 16px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.desktop-only { display: none; }

.top {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--header-h);
  padding: .35rem .85rem;
  padding-top: calc(.35rem + env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: var(--z-chrome);
}
.logo-link { display: inline-flex; align-items: center; flex-shrink: 0; line-height: 0; }
.logo-link:focus-visible { outline: 2px solid var(--gold, #c9a227); outline-offset: 2px; border-radius: 4px; }
.logo { height: 30px; width: auto; flex-shrink: 0; display: block; cursor: pointer; }
.auth-logo { cursor: pointer; }
.top-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.15;
  font-size: .95rem;
}
.top-title small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: .68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  min-width: 40px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--navy);
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.icon-btn:active { background: #e9f1f6; }

main, main.dash {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: .75rem 1rem 1.25rem;
  overflow-x: clip;
  box-sizing: border-box;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.app-shell > main.dash { flex: 1; min-width: 0; }

.dash-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.dash-col { min-width: 0; }

.panel-results { margin-bottom: .7rem; }
.panel-h {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .55rem;
  font-size: .95rem;
}
.program-card .t { line-height: 1.3; }

.sticky-summary {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-summary);
  background: var(--navy);
  color: #fff;
  min-height: var(--summary-h);
  padding: .55rem .85rem calc(.55rem + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .4rem;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0,0,0,.18);
}
.sticky-summary .cell { text-align: center; }
.sticky-summary .lbl {
  font-size: .65rem;
  opacity: .8;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sticky-summary .val {
  font-weight: 700;
  font-size: .98rem;
  font-variant-numeric: tabular-nums;
}
.sticky-summary .neg { color: #ffb4b4; }

.deal-bar {
  display: flex;
  gap: .4rem;
  align-items: center;
  margin-bottom: .65rem;
  flex-wrap: nowrap;
  min-width: 0;
}
.deal-bar select,
.deal-bar > .btn {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 .65rem;
}
.deal-bar select {
  flex: 1 1 auto;
  min-width: 0;
}
.deal-bar > .btn { flex: 0 0 auto; white-space: nowrap; }
.btn {
  min-height: var(--tap);
  border-radius: 12px;
  border: 0;
  padding: 0 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-2); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--navy); }
.btn-danger { background: #fdecea; color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; font-size: .9rem; padding: 0 .7rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .7rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-h {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  padding: .95rem 1rem;
  min-height: var(--tap);
  cursor: pointer;
  color: var(--navy);
  font-weight: 700;
  font-size: 1rem;
}
.card-h .chev {
  margin-left: auto;
  transition: transform .15s;
  color: var(--muted);
  font-weight: 400;
}
.card.open .chev { transform: rotate(90deg); }
.card-b { display: none; padding: 0 1rem 1rem; border-top: 1px solid var(--line); }
.card.open .card-b { display: block; padding-top: .85rem; }

.field { margin-bottom: .75rem; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .25rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .75rem;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(13,59,82,.25);
  border-color: var(--navy);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.hint { font-size: .8rem; color: var(--muted); margin: .15rem 0 .4rem; }
.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: #e9f1f6;
  color: var(--navy);
  vertical-align: middle;
}
.badge-gold { background: #f8efd0; color: #7a5b00; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-navy { background: var(--navy); color: #fff; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  background: var(--bg);
  padding: .3rem;
  border-radius: 12px;
  margin-bottom: .75rem;
}
.seg button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.seg button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

.cost-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .4rem;
  align-items: center;
  padding: .45rem 0;
  border-bottom: 1px solid #f0f2f4;
}
.cost-line:last-child { border-bottom: 0; }
.cost-line .name { font-size: .92rem; }
.cost-line .auto { font-size: .72rem; color: var(--muted); }
.cost-line input {
  width: 110px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .35rem .5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cost-line .lock {
  min-width: 40px; min-height: 40px;
  border: 0; background: #f3f5f7; border-radius: 8px; cursor: pointer;
  color: var(--muted);
}
.cost-line .lock.on { background: #e8f6ee; color: var(--green); }
.cost-line-comm {
  grid-template-columns: 1fr auto auto;
  align-items: start;
}
.comm-inputs {
  display: flex;
  align-items: center;
  gap: .25rem;
}
.comm-inputs input[data-comm-pct] {
  width: 64px;
}
.comm-inputs input[data-cost-input] {
  width: 110px;
}
.comm-pct-lbl {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
}
.profit-hint {
  margin: .45rem 0 .65rem;
  padding: .55rem .7rem;
  background: #f4f8fb;
  border-left: 3px solid var(--navy);
  border-radius: 0 8px 8px 0;
  font-size: .78rem;
  line-height: 1.35;
}
.strategy-section.program-section {
  margin-top: .35rem;
  padding-top: .35rem;
  border-top: 1px dashed var(--line);
}
.program-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: .35rem;
}
.program-table th,
.program-table td {
  vertical-align: top;
  white-space: nowrap;
}
.program-table td:first-child,
.program-table th:first-child {
  white-space: normal;
  min-width: 7.5rem;
}
.program-table tr.program-row {
  cursor: pointer;
}
.program-table tr.program-row.on {
  background: #eef5f9;
}
.program-table tr.program-row.on td {
  border-color: #c5d7e4;
}
.program-table .prog-extra-inp {
  width: 96px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .3rem .4rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.program-table .pos { color: var(--green); }
.program-table .neg { color: #c0392b; }

.loan-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  margin-bottom: .65rem;
  background: #fafbfc;
}
.loan-card h4 {
  margin: 0 0 .55rem;
  font-size: .95rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.loan-card h4 .rm {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: .85rem;
  cursor: pointer;
  min-height: 36px;
  padding: 0 .4rem;
}
.loan-sum {
  background: var(--green-bg);
  border-radius: 10px;
  padding: .65rem .75rem;
  font-size: .9rem;
  margin-top: .4rem;
}
.loan-sum div { display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0; }
.loan-sum strong { font-variant-numeric: tabular-nums; }

.scenario-grid {
  display: grid;
  gap: .55rem;
}
.scenario {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.scenario.on { border-color: var(--navy); background: #eef5f9; }
.scenario .t { font-weight: 700; color: var(--navy); }
.scenario .h { font-size: .8rem; color: var(--muted); margin: .15rem 0 .45rem; }
.scenario .meta { font-size: .85rem; font-variant-numeric: tabular-nums; }

.comp-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.comp-table th, .comp-table td {
  text-align: left;
  padding: .4rem .3rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.comp-table th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; }
.comp-table input[type="checkbox"] { width: 20px; height: 20px; }
.comp-table .off { opacity: .45; }
.comp-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}
.stat {
  background: #f7f9fa;
  border-radius: 12px;
  padding: .7rem .75rem;
}
.stat .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.stat .v { font-weight: 700; font-size: 1.1rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat.wide { grid-column: 1 / -1; }
.stat.big .v { font-size: 1.45rem; }
.stat.good { background: var(--green-bg); }
.stat.good .v { color: var(--green); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1d2730;
  color: #fff;
  padding: .65rem 1rem;
  border-radius: 999px;
  font-size: .9rem;
  z-index: var(--z-toast);
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* Investor report */
.report-view { background: #fff; min-height: 100vh; }
.report-view main { max-width: 720px; padding-bottom: 2rem; }
.report-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: #fff;
  padding: .6rem 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
}
.report h1 {
  color: var(--navy);
  font-size: 1.45rem;
  margin: 0 0 .25rem;
}
.report .sub { color: var(--muted); margin-bottom: 1rem; }
.report h2 {
  color: var(--navy);
  font-size: 1.05rem;
  margin: 1.25rem 0 .5rem;
  padding-bottom: .3rem;
  border-bottom: 2px solid var(--navy);
}
.report table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.report table td, .report table th {
  padding: .4rem .2rem;
  border-bottom: 1px solid var(--line);
}
.report table td:last-child, .report table th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.report .disclaimer {
  margin-top: 1.5rem;
  font-size: .78rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: .75rem;
}
.report .split-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin: .75rem 0;
}
.report .split-box > div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  text-align: center;
}
.report .split-box .who { font-size: .8rem; color: var(--muted); }
.report .split-box .amt { font-size: 1.25rem; font-weight: 700; color: var(--navy); }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: var(--z-drawer-bg);
}
.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-drawer);
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 -8px 32px rgba(0,0,0,.2);
}
.drawer h3 { margin: 0 0 .75rem; color: var(--navy); }

@media print {
  body { background: #fff; padding: 0; }
  .top, .sticky-summary, .report-actions, .no-print { display: none !important; }
  .report-view main { max-width: none; }
  .card { break-inside: avoid; }
}

/* Excel sheet match breakdown */
.sheet-match { margin-top: .25rem; }
.sheet-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.sheet-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.sheet-row.off { background: #fff4f4; margin: 0 -.4rem; padding-left: .4rem; padding-right: .4rem; border-radius: 6px; }
.match-ok { color: var(--green); margin-left: .25rem; font-weight: 700; }
.match-bad { color: var(--red); margin-left: .25rem; font-weight: 700; }

/* Address ZIP hint + autocomplete + subject card */
.address-field { position: relative; }
.addr-wrap { position: relative; }
.zip-line {
  font-size: .82rem;
  margin: .35rem 0 .15rem;
  font-weight: 600;
}
.zip-line.zip-ok { color: var(--green); }
.zip-line.zip-pending { color: var(--muted); font-weight: 500; }

.addr-suggest {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  z-index: var(--z-suggest);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(13, 59, 82, 0.16);
  max-height: 240px;
  overflow: auto;
}
.addr-suggest-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: .45rem .75rem .2rem;
  font-weight: 700;
}
.addr-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: .7rem .75rem;
  min-height: 44px;
  cursor: pointer;
  color: var(--ink);
  border-top: 1px solid #f0f2f4;
  font-size: .92rem;
}
.addr-suggest-item:first-of-type { border-top: 0; }
.addr-suggest-item.on,
.addr-suggest-item:hover,
.addr-suggest-item:focus {
  background: #eef5f9;
  color: var(--navy);
  outline: none;
}

.subject-card {
  border: 1px solid #cfe3d6;
  background: var(--green-bg);
  border-radius: 12px;
  padding: .75rem .85rem;
  margin-bottom: .85rem;
}
.subject-h {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .25rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.subject-addr { font-weight: 600; margin-bottom: .2rem; }
.subject-meta { font-size: .82rem; color: var(--muted); }
.subject-price { font-weight: 700; margin-top: .35rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.subject-links { font-size: .85rem; margin-top: .35rem; }
.subject-links a { color: var(--blue); font-weight: 600; }


/* ARV range + finish size */
.arv-range-card {
  background: #f7f9fa;
  border-radius: 12px;
  padding: .75rem;
  margin-bottom: .65rem;
}
.arv-range-card .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.arv-range-nums {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem;
  font-variant-numeric: tabular-nums;
  margin: .25rem 0;
  font-size: 1.05rem;
  color: var(--navy);
}
.arv-range-nums strong {
  font-size: 1.35rem;
  color: var(--green);
}
.arv-range-nums .sep { color: var(--muted); font-weight: 500; }
.arv-band-toggle {
  display: flex;
  gap: .35rem;
  margin-top: .55rem;
  flex-wrap: wrap;
}
.band-btn {
  flex: 1;
  min-width: 4.5rem;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .4rem .6rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}
.band-btn.on {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.arv-bands {
  margin-top: .75rem;
  background: #f7f9fa;
  border-radius: 12px;
  padding: .7rem .75rem;
}
.arv-band-h { font-size: .72rem; color: var(--muted); text-transform: uppercase; margin-bottom: .4rem; }
.arv-band-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .4rem;
  text-align: center;
}
.arv-band-row .l { display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; }
.arv-band-row strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.arv-band-row .mid { background: var(--green-bg); border-radius: 10px; padding: .35rem; }
.arv-band-row .pos { color: var(--green); }
.arv-band-row .neg { color: #c0392b; }

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .45rem;
}
.finish-list { display: grid; gap: .55rem; margin-top: .4rem; }
.finish-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  background: #fff;
  cursor: pointer;
}
.finish-card.on { border-color: var(--navy); background: #eef5f9; }
.finish-top {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .45rem;
}
.finish-top input[type="text"] {
  flex: 1;
  font-weight: 700;
  color: var(--navy);
}
.finish-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
  margin-top: .5rem;
  font-size: .88rem;
}
.finish-metrics .l { font-size: .68rem; color: var(--muted); text-transform: uppercase; }
.finish-metrics strong { font-variant-numeric: tabular-nums; color: var(--navy); }
.finish-metrics .pos { color: var(--green); }
.finish-metrics .neg { color: #c0392b; }
.sticky-summary .pos { color: #9be7b5; }

/* Comps filters */
.comps-filters {
  background: #f4f7f9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  margin: .65rem 0;
}
.comps-filters-h {
  font-weight: 700;
  color: var(--navy);
  font-size: .9rem;
  margin-bottom: .25rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .35rem;
}
.type-chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .32rem .65rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.type-chip.on {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.type-tag {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: .1rem .35rem;
  border-radius: 6px;
  background: #e8eef2;
  color: var(--navy);
}
.type-tag.type-condo,
.type-tag.type-multi { background: #fde8e8; color: #a33; }
.type-tag.type-sfr { background: #e5f6ec; color: #1a7a3c; }
.type-tag.type-unknown { background: #eee; color: #666; }
.dist-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.dist-row input[type="range"] { flex: 1; }

/* Presets drawer */
.preset-loan {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .65rem;
  margin-bottom: .45rem;
  background: #fff;
}
.preset-loan-h {
  font-weight: 700;
  font-size: .82rem;
  color: var(--navy);
  margin-bottom: .35rem;
}
.preset-loans { max-height: 40vh; overflow: auto; }


/* App password lock / setup */
.auth-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  background: linear-gradient(160deg, #0d3b52 0%, #164b66 45%, #1a5a7a 100%);
}
body:has(.auth-gate) { padding-bottom: 0; }
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  padding: 1.35rem 1.2rem 1.4rem;
}
.auth-logo {
  height: 40px;
  width: auto;
  display: block;
  margin: 0 auto .85rem;
}
.auth-card h1 {
  margin: 0 0 .35rem;
  color: var(--navy);
  font-size: 1.35rem;
  text-align: center;
}
.auth-card .hint { text-align: center; margin: 0 0 .9rem; }
.auth-card .auth-err {
  color: var(--red);
  text-align: left;
  margin: 0 0 .65rem;
}
.auth-card .field { margin-bottom: .65rem; }
.auth-card .field label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .25rem;
}
.auth-card input[type="password"],
.auth-card input[type="text"] {
  width: 100%;
  min-height: var(--tap);
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
}
.auth-card input[type="password"]:focus,
.auth-card input[type="text"]:focus {
  outline: 2px solid rgba(13, 59, 82, 0.25);
  border-color: var(--navy);
}
.auth-remember {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  color: var(--navy);
  margin: .15rem 0 .85rem;
  min-height: var(--tap);
  cursor: pointer;
  user-select: none;
}
.auth-remember input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--navy);
}
.access-list { margin-top: .35rem; }
.access-user {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .7rem;
  margin-bottom: .5rem;
  background: #fafbfc;
}
.access-user-h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}
.access-user .badge.off {
  background: #fde8e8;
  color: var(--red);
}
.access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.access-actions .btn {
  min-height: 2.2rem;
  padding: .35rem .65rem;
  font-size: .82rem;
}


/* —— Easy / Detail mode UX —— */
.mode-toggle {
  flex: 0 0 auto;
  min-width: 0;
  width: auto;
}
.mode-toggle.seg {
  margin: 0;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 132px;
  padding: .22rem;
}
.mode-toggle button {
  min-height: 34px;
  font-size: .82rem;
  padding: 0 .55rem;
  white-space: nowrap;
}

.easy-form { display: flex; flex-direction: column; gap: .15rem; }
.easy-block {
  margin: .85rem 0 .35rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
}
.easy-block-h {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .55rem;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.easy-result { margin-top: .75rem; border-color: #b7e0c6; background: var(--green-bg); }
.check-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .55rem;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
}
.check-row input { width: 1.1rem; height: 1.1rem; }
.muted { color: var(--muted); font-weight: 500; }

/* Detail wizard — mobile horizontal ribbon (one row, scroll) */
.detail-layout { display: block; min-width: 0; max-width: 100%; overflow-x: clip; }
.detail-main { min-width: 0; max-width: 100%; overflow-x: clip; }
.detail-body { min-width: 0; max-width: 100%; }
.detail-form { min-width: 0; max-width: 100%; }

.wizard-nav-h { margin-bottom: .55rem; min-width: 0; max-width: 100%; overflow: hidden; }
.wiz-steps {
  display: flex;
  flex-wrap: nowrap;
  gap: .3rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: .1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.wiz-step {
  flex: 0 0 auto;
  min-width: 4rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .32rem .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  cursor: pointer;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
}
.wiz-step .n {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #e9eef2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  flex-shrink: 0;
}
.wiz-step.on {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.wiz-step.on .n { background: rgba(255,255,255,.2); color: #fff; }
.wiz-step.done {
  border-color: #9bc4a8;
  color: var(--green);
  background: #f0faf4;
}
.wiz-step.done .n { background: #d7f0e1; color: var(--green); }
.wiz-step .lbl { white-space: nowrap; }

/* Side rail hidden on phone; laptop media query shows it */
.wiz-side { display: none; }
.wiz-side-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 0;
  background: transparent;
  text-align: left;
  padding: .48rem .55rem;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  font-size: .86rem;
  width: 100%;
}
.wiz-side-item span {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #e9eef2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .74rem;
  flex-shrink: 0;
}
.wiz-side-item.on {
  background: #eef5f9;
  color: var(--navy);
}
.wiz-side-item.on span { background: var(--navy); color: #fff; }
.wiz-side-item.done { color: var(--green); }
.wiz-side-item.done span { background: #d7f0e1; color: var(--green); }

.wiz-footer {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: .75rem 0 .35rem;
  position: sticky;
  bottom: calc(var(--summary-h) + env(safe-area-inset-bottom));
  background: rgba(243,245,247,.94);
  backdrop-filter: blur(6px);
  padding: .45rem 0;
  z-index: var(--z-wiz-footer);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.wiz-footer .btn { flex: 0 0 auto; min-width: 4.25rem; min-height: 40px; padding: 0 .7rem; }
.wiz-footer-label {
  flex: 1;
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-shell.mode-detail main.dash {
  padding-bottom: 1rem;
}

/* —— Responsive layout (must stay last among layout rules) —— */
@media (min-width: 700px) {
  main, main.dash { padding-top: 1rem; }
}

/* Narrow phones: allow deal-bar to wrap once */
@media (max-width: 420px) {
  .deal-bar { flex-wrap: wrap; }
  .mode-toggle { flex: 1 1 auto; min-width: 120px; }
  .deal-bar select { flex: 1 1 140px; }
  .wiz-footer .btn { min-width: 3.75rem; padding: 0 .55rem; font-size: .9rem; }
  .wiz-step { min-width: 3.6rem; padding: .28rem .4rem; font-size: .72rem; }
}

/* Laptop+: full-width shell, hide mobile profit bar */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  main.dash {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: .85rem 1.15rem 1.35rem;
  }
  .desktop-only { display: block !important; }
  .sticky-summary { display: none; }
  .toast { bottom: 2rem; }
  .deal-bar {
    margin-bottom: .85rem;
    flex-wrap: nowrap;
  }

  /* Easy mode: form | results */
  .dash-grid.easy-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(260px, 320px);
    gap: 1rem;
    align-items: start;
  }
  .dash-right .dash-sticky,
  .detail-results .dash-sticky {
    position: sticky;
    top: calc(var(--header-h) + 8px);
    max-height: calc(100vh - var(--header-h) - 16px);
    overflow: auto;
    padding-bottom: .5rem;
  }

  /* Detail: side rail + main only (no forced 3rd column yet) */
  .detail-layout {
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    gap: .9rem;
    align-items: start;
  }
  .wizard-nav-h { display: none; }
  .wiz-side {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    position: sticky;
    top: calc(var(--header-h) + 8px);
    max-height: calc(100vh - var(--header-h) - 16px);
    overflow: auto;
    padding: .4rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1;
  }
  .detail-body {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    min-width: 0;
  }
  .detail-form { min-width: 0; }
  .detail-results { min-width: 0; }
  .wiz-footer {
    position: static;
    background: transparent;
    backdrop-filter: none;
    padding: .65rem 0 0;
    margin-bottom: 0;
  }
}

/* Wide desktop: form | live results as third column */
@media (min-width: 1200px) {
  main.dash {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  .dash-grid.easy-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 340px);
    gap: 1.15rem;
  }
  .detail-layout {
    grid-template-columns: 156px minmax(0, 1fr);
    gap: 1rem;
  }
  .detail-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 1rem;
    align-items: start;
  }
}


/* Multi-investor split rows */
.investor-list { display: flex; flex-direction: column; gap: .45rem; }
.investor-row {
  display: flex;
  gap: .45rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.investor-row .field { margin-bottom: 0; min-width: 5.5rem; }
.hint.neg { color: var(--red, #c0392b); }

/* Auto loan principal (Easy + Detail % modes) */
input.auto-principal,
input[data-loan-field="principal"]:disabled {
  background: #f0f3f6;
  color: var(--navy);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.field .hint { margin-top: .25rem; }

/* Minimum cash to fund / investor input */
.funding-block {
  margin: .35rem 0 1rem;
  padding: .65rem .7rem .75rem;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.funding-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-top: .65rem;
  padding: .65rem .7rem;
  background: var(--navy);
  color: #fff;
  border-radius: 10px;
}
.funding-total .l {
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.funding-total .v {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.funding-compact {
  margin-top: .65rem;
}
.funding-compact .stat.big {
  margin-bottom: .35rem;
}
.funding-details {
  margin: .25rem 0 .35rem;
  font-size: .82rem;
}
.funding-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.funding-compact-row {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .28rem 0;
  border-bottom: 1px solid #eef1f4;
}
.funding-compact-row:last-child { border-bottom: 0; }

/* Investor page: highlight only Net profit + ARV / resale */
.results-grid .stat.highlight-line {
  background: linear-gradient(90deg, #fff8e1 0%, #fff3c4 100%);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.35);
}
.results-grid .stat.highlight-line .l {
  font-weight: 700;
  color: var(--navy);
}
