/* Fix & Flip Calculator — page-specific styles */

.ff-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 980px) {
  .ff-layout { grid-template-columns: 1fr; gap: 24px; }
  .ff-layout .results-panel { position: static !important; }
}

/* ===== Top bar: actions (Save as PDF · Start over) ===== */
.ff-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: calc(24px * var(--density));
  flex-wrap: wrap;
}
.ff-topbar .calc-toolbar { margin-bottom: 0; }

/* ===== Section heads ===== */
.ff-layout .section-head h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--color-text-heading);
}
.ff-layout .field > label {
  display: block;
  font-size: 13px;
  color: var(--color-text-body);
  margin-bottom: 8px;
  font-weight: 500;
}
.field-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Derived read-only row (Total project cost) */
.ff-derived {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 14px;
  background: var(--color-cream);
  border: 1px dashed var(--color-border-hairline);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.ff-derived .d-label { color: var(--color-text-muted); font-weight: 500; }
.ff-derived .d-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-text-heading); }

/* ===== Hero — dual stat receipt ===== */
.ff-hero {
  background: var(--color-answer-wash);
  border: 1px solid var(--color-answer-edge);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-answer);
  position: relative;
  overflow: hidden;
}
.ff-hero::before {
  content: '';
  position: absolute;
  top: -44px;
  right: -44px;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(0, 97, 153, 0.18) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.ff-hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.ff-stat .s-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.ff-stat.primary .s-label {
  color: var(--color-brand-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ff-stat.primary .s-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-accent);
  flex-shrink: 0;
}
.ff-stat .s-value {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--color-text-heading);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ff-stat.primary .s-value { color: var(--color-text-heading); }
.ff-stat:not(.primary) .s-value { font-size: 30px; }
.ff-stat .s-sub { font-size: 12.5px; color: var(--color-text-muted); margin-top: 6px; line-height: 1.4; }
.ff-hero-divider { grid-column: 1 / -1; height: 1px; background: var(--color-border-hairline); margin: 14px 0; }

@media (max-width: 460px) {
  .ff-stat .s-value { font-size: 34px; }
  .ff-stat:not(.primary) .s-value { font-size: 26px; }
}

/* ===== Binding cap badge ===== */
.ff-binding {
  margin-top: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-hairline);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.ff-binding-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}
.ff-binding-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--color-brand);
  color: white;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.ff-binding-badge .bb-mark {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ff-binding-text { font-size: 13px; color: var(--color-text-body); line-height: 1.45; }
.ff-binding-text strong { color: var(--color-text-heading); font-weight: 600; }
.ff-binding-hint {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-hairline);
  background: var(--color-surface);
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.5;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.ff-binding-hint svg { flex-shrink: 0; color: var(--color-brand); margin-top: 1px; }
.ff-binding-hint strong { color: var(--color-text-heading); font-weight: 600; }

/* Cap calculations — explicit formula lines (no bars) */
.ff-caps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--color-border-hairline);
}
.ff-cap-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ff-cap-line .cap-name { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.ff-cap-line .cap-formula { display: block; font-size: 11.5px; font-weight: 400; color: var(--color-text-muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ff-cap-line .cap-val { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-text-heading); white-space: nowrap; }
.ff-cap-line.is-binding .cap-name { color: var(--color-brand-deep); }
.ff-cap-line.is-binding .cap-val { color: var(--color-brand); }

/* Two-up field rows (compact experiment) */
.ff-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
.ff-2col > .field { min-width: 0; }
@media (max-width: 560px) { .ff-2col { grid-template-columns: 1fr; gap: 0; } }

/* Contingency add-on row under rehab budget */
.ff-addon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--color-cream);
  border: 1px dashed var(--color-border-hairline);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.ff-addon .a-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--color-text-muted); }
.ff-addon .a-input { display: flex; align-items: center; gap: 5px; }
.ff-addon .a-input input {
  width: 64px;
  height: 34px;
  background: var(--color-input-bg);
  border: 1px solid var(--color-field-edge);
  border-radius: 6px;
  padding: 0 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-heading);
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.ff-addon .a-input input:focus { border-color: var(--color-brand); background: white; }
.ff-addon .a-input .a-suffix { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.ff-addon .a-derived { font-size: 12px; color: var(--color-text-body); font-variant-numeric: tabular-nums; }
.ff-addon .a-derived strong { color: var(--color-text-heading); font-weight: 600; }

/* Term / months dropdown */
.ff-select {
  width: 100%;
  height: var(--control-height);
  padding: 0 40px 0 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-heading);
  background: var(--color-input-bg);
  border: 1px solid var(--color-field-edge);
  border-radius: var(--radius-sm);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23776d66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.ff-select:hover { border-color: var(--color-field-edge-hover); }
.ff-select:focus { border-color: var(--color-brand); outline: none; }

/* ===== Funding split bar ===== */
.ff-card {
  margin-top: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
}
.ff-card-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}
.ff-split-bar {
  height: 30px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  background: var(--color-surface-alt);
}
.ff-split-seg {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
}
.ff-split-seg.advance { background: var(--color-brand); }
.ff-split-seg.holdback { background: var(--color-brand-soft); color: var(--color-brand-deep); }
.ff-split-legend {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.ff-split-legend .l-item { display: flex; flex-direction: column; gap: 2px; }
.ff-split-legend .l-key { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-muted); font-weight: 500; }
.ff-split-legend .l-dot { width: 9px; height: 9px; border-radius: 3px; }
.ff-split-legend .l-dot.advance { background: var(--color-brand); }
.ff-split-legend .l-dot.holdback { background: var(--color-brand-soft); }
.ff-split-legend .l-val { font-size: 16px; font-weight: 600; color: var(--color-text-heading); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Key-value rows (cash to close detail) */
.ff-kv { display: flex; flex-direction: column; }
.ff-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border-hairline);
  font-size: 13.5px;
}
.ff-kv-row:last-child { border-bottom: none; }
.ff-kv-row .kv-label { color: var(--color-text-muted); font-weight: 500; }
.ff-kv-row .kv-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-text-heading); }
.ff-kv-row.total {
  border-top: 2px solid var(--color-border-subtle);
  border-bottom: none;
  margin-top: 4px;
  padding-top: 12px;
  font-size: 15px;
}
.ff-kv-row.total .kv-label { color: var(--color-text-heading); font-weight: 700; }
.ff-kv-row.total .kv-val { color: var(--color-brand); font-weight: 700; }

/* ===== Fee editor (Pro) ===== */
.ff-fee-row {
  display: grid;
  grid-template-columns: 1fr 96px 64px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-hairline);
}
.ff-fee-row:last-child { border-bottom: none; }
.ff-fee-name { font-size: 13px; color: var(--color-text-body); font-weight: 500; }
.ff-fee-name .ff-fee-amt { display: block; font-size: 11px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; margin-top: 1px; }
.ff-fee-input {
  width: 100%;
  height: 38px;
  background: var(--color-input-bg);
  border: 1px solid var(--color-field-edge);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-heading);
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.ff-fee-input:focus { border-color: var(--color-brand); background: white; }
.ff-fee-unit {
  display: inline-flex;
  background: var(--color-input-bg-solid);
  border-radius: 6px;
  padding: 2px;
  height: 38px;
}
.ff-fee-unit button {
  border: none; background: transparent;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--color-text-muted);
  padding: 0 8px; border-radius: 5px; cursor: pointer;
  min-width: 26px;
}
.ff-fee-unit button.active { background: white; color: var(--color-text-heading); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.ff-fee-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--color-border-subtle);
  font-size: 14px;
}
.ff-fee-total .t-label { font-weight: 700; color: var(--color-text-heading); }
.ff-fee-total .t-val { font-weight: 700; color: var(--color-text-heading); font-variant-numeric: tabular-nums; }

/* ===== Quick mode collapsed closing costs ===== */
.ff-quick-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.ff-quick-line .ql-label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--color-text-muted); font-weight: 500; }

/* ===== Optional reserves (Pro) ===== */
.ff-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
}
.ff-toggle-row input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--color-brand);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}
.ff-toggle-row .tr-body { flex: 1; }
.ff-toggle-row .tr-title { font-size: 13.5px; font-weight: 600; color: var(--color-text-heading); }
.ff-toggle-row .tr-hint { font-size: 12px; color: var(--color-text-muted); line-height: 1.5; margin-top: 1px; }

.ff-total-funds {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-hairline);
}
.ff-total-funds .tf-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); font-weight: 600; }
.ff-total-funds .tf-value { font-size: 26px; font-weight: 600; color: var(--color-text-heading); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin-top: 4px; }
.ff-total-funds .tf-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* ===== Closing-date field ===== */
.ff-date-input {
  width: 100%;
  height: var(--control-height);
  background: var(--color-input-bg);
  border: 1px solid var(--color-field-edge);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-heading);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.ff-date-input:focus { border-color: var(--color-brand); background: white; }
.alta-calc .alta-cal__field .ff-date-input { padding-right: 48px; }
.alta-calc .alta-cal__field .alta-cal__toggle { top: 1px; bottom: 1px; height: auto; }

/* text input matching .input-base for metadata */
.ff-text-input {
  width: 100%;
  height: var(--control-height-sm);
  background: var(--color-input-bg);
  border: 1px solid var(--color-field-edge);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-heading);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.ff-text-input:focus { border-color: var(--color-brand); background: white; }

/* LTC base toggle inline */
.ff-inline-toggle {
  display: inline-flex;
  background: var(--color-input-bg-solid);
  border-radius: 6px;
  padding: 2px;
}
.ff-inline-toggle button {
  border: none; background: transparent;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--color-text-muted);
  padding: 5px 10px; border-radius: 5px; cursor: pointer;
}
.ff-inline-toggle button.active { background: var(--color-surface); color: var(--color-brand-deep); box-shadow: 0 0 0 1px rgba(0, 97, 153, 0.22), 0 1px 3px rgba(15, 37, 47, 0.12); }

/* CTA block: buttons side by side left-to-right, no trust strip, no caution hint (fix-flip only) */
.cta-pair-buttons { flex-direction: row; }
.cta-pair .trust-strip { display: none; }
.cta-pair .cta-pair-hint { display: none; }

/* Estimate ribbon for quick-mode print */
.ff-estimate-note {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  line-height: 1.5;
}

@media (max-width: 480px) {
  .ff-fee-row { grid-template-columns: 1fr 80px 58px; }
}

/* ===== Print: fix-flip carries the most rows (14 inputs + 6 metrics) of any
   calculator, which spilled the footer onto a second, near-empty page. These
   overrides tighten only the fix-flip print document (this file is injected
   after the shared print CSS and only on this page) so the full termsheet —
   hero, deal numbers, metrics, and compliance footer — lands on one page. ===== */
@media print {
  .pv-head { margin-bottom: 16pt; }
  .pv-title { margin-bottom: 12pt; }
  .pv-hero { margin-bottom: 16pt; padding-bottom: 12pt; }
  .pv-section { margin-bottom: 14pt; }
  .pv-kv th, .pv-kv td { padding: 3.5pt 0; }
  .pv-metrics { margin-bottom: 14pt; padding-top: 12pt; gap: 12pt 22pt; }
  .pv-foot { margin-top: 14pt; padding-top: 12pt; }
}

