:root {
  --ink: #1d2528;
  --muted: #607075;
  --line: #d8e1df;
  --paper: #f6f3ec;
  --panel: #ffffff;
  --teal: #0f6d68;
  --teal-dark: #0a4d49;
  --coral: #c95f45;
  --gold: #aa7a18;
  --sage: #e6efea;
  --warning: #f5e8c5;
  --risk: #f7ded8;
  --shadow: 0 18px 44px rgba(24, 39, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.app-topbar a { color: var(--teal-dark); font-weight: 900; text-decoration: none; }
.app-topbar nav { display: flex; flex-wrap: wrap; gap: 14px; }
.app-home { color: var(--ink) !important; }

button, select, textarea, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 24px;
}

.control-panel, .preview-panel, .cards article, .plan-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  min-height: calc(100vh - 48px);
  padding: 22px;
}

.brand-block h1, .section-head h2, .cards h3 { margin: 0; letter-spacing: 0; }
.brand-block h1 { font-size: 28px; line-height: 1.08; }
.brand-block p:last-child { color: var(--muted); line-height: 1.45; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.upload-box {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 132px;
  margin: 20px 0;
  border: 2px dashed #9fb9b4;
  background: #f3f8f6;
  color: var(--teal-dark);
  text-align: center;
  font-weight: 900;
}
.upload-box input { display: none; }
.upload-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--teal);
  color: white;
  font-size: 28px;
  line-height: 1;
}

.field-grid { display: grid; gap: 12px; margin: 14px 0; }
.two-col { grid-template-columns: 1fr 1fr; }
.field-block { display: grid; gap: 7px; margin: 16px 0 10px; }
.custom-goal { margin-top: -6px; }
.compact-field { margin-top: -2px; }
.field-grid label { display: grid; gap: 7px; }
.field-grid span, .field-block span, .goal-control legend {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}
select, textarea, input[type="text"], input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 10px 11px;
}
textarea { resize: vertical; }

.goal-control {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 0;
  border: 0;
}
.goal-control label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: white;
  font-weight: 800;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 0;
  margin-bottom: 14px;
}
.chips span {
  padding: 5px 8px;
  background: var(--warning);
  color: #6b4b00;
  font-size: 12px;
  font-weight: 900;
}

.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary-button, .secondary-button, .text-button {
  border: 0;
  font-weight: 900;
}
.primary-button { padding: 12px; background: var(--teal); color: white; }
.secondary-button { padding: 12px; background: var(--ink); color: white; }
.text-button { background: transparent; color: var(--teal-dark); text-decoration: underline; }
.remove-item { border: 0; background: var(--risk); color: #893a2b; padding: 7px 10px; font-size: 12px; font-weight: 900; }

.work-area { display: grid; gap: 18px; min-width: 0; }
.source-note {
  margin: -10px 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.source-note a {
  color: var(--teal-dark);
  font-weight: 900;
}
.preview-panel { overflow: hidden; }
.photo-frame { position: relative; min-height: 350px; background: linear-gradient(135deg, #dfe9df, #f1e8d8); }
.photo-frame img { display: none; width: 100%; height: 430px; object-fit: cover; }
.empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}
.empty-preview strong { color: var(--ink); }

.summary-grid {
  display: grid;
  grid-template-columns: 1.2fr .7fr .7fr .8fr;
  gap: 1px;
  background: var(--line);
}
.summary-grid > div { min-width: 0; padding: 15px; background: white; }
.summary-grid span, .plan-totals span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.summary-grid strong, .plan-totals strong { display: block; overflow-wrap: anywhere; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}
.section-head h2 { font-size: 24px; }
.section-head p:last-child { max-width: 560px; margin: 0; color: var(--muted); line-height: 1.45; }
.compact { align-items: center; padding: 18px 18px 0; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cards article { display: grid; gap: 13px; padding: 17px; }
.card-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.cards h3 { font-size: 18px; line-height: 1.22; }
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.badge { padding: 5px 8px; background: var(--sage); color: var(--teal-dark); font-size: 11px; font-weight: 900; white-space: nowrap; }
.badge.risk { background: var(--risk); color: #893a2b; }
.badge.match { background: var(--warning); color: #6b4b00; }
.badge.fit-strong { background: #dfeee4; color: #205b35; }
.badge.fit-moderate { background: #e7edf0; color: #415861; }
.badge.fit-risky { background: var(--risk); color: #893a2b; }
.badge.permit { background: #f0e4cb; color: #705015; }
.badge.pro { background: #e4e6ef; color: #343c61; }

.numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.numbers div { min-width: 0; padding: 9px; background: #f8f9f6; border: 1px solid var(--line); }
.numbers span { display: block; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.numbers strong { display: block; margin-top: 4px; font-size: 14px; overflow-wrap: anywhere; }

.why { margin: 0; padding-left: 18px; line-height: 1.42; }
.notes, .tier-line { margin: 0; color: var(--muted); line-height: 1.45; }
.tier-line { color: #496266; font-weight: 800; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-actions label { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.warning-line { margin: 0; color: #893a2b; font-size: 13px; font-weight: 800; line-height: 1.4; }

.plan-panel { padding-bottom: 18px; }
.plan-context {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 18px 18px 0;
  border: 1px solid var(--line);
  background: var(--line);
}
.plan-context > div { padding: 14px; background: #fbfcfa; }
.plan-context span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.plan-context strong { display: block; overflow-wrap: anywhere; }
.plan-context p { margin: 0; color: var(--ink); line-height: 1.45; overflow-wrap: anywhere; }
.plan-context .wide { grid-column: 1 / -1; }
.plan-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 18px 18px 0;
  border: 1px solid var(--line);
  background: var(--line);
}
.plan-totals > div { padding: 14px; background: #fbfcfa; }
.plan-list { display: grid; gap: 10px; padding: 18px; }
.plan-empty { color: var(--muted); margin: 0; }
.plan-item { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); background: #fbfcfa; }
.plan-item strong { display: block; }
.plan-item span { color: var(--muted); font-size: 13px; }
.plan-item p { grid-column: 1 / -1; margin: 0; color: #893a2b; font-size: 13px; font-weight: 800; }
.legal-note { margin: 0 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .control-panel { position: static; min-height: auto; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-topbar { align-items: flex-start; flex-direction: column; padding: 12px; }
  .app-shell { padding: 12px; }
  .two-col, .cards, .summary-grid, .plan-totals, .plan-context { grid-template-columns: 1fr; }
  .button-row { grid-template-columns: 1fr; }
  .section-head { align-items: stretch; flex-direction: column; }
  .photo-frame img { height: 300px; }
  .plan-item { grid-template-columns: 1fr; }
  .remove-item { justify-self: start; }
}

@media print {
  @page { size: letter; margin: 0.55in; }
  body { background: white; }
  .app-topbar, .app-shell { display: none; }
  .pdf-report { display: block; }
  .app-shell, .work-area { display: block; padding: 0; }
  .preview-panel, .plan-panel { box-shadow: none; border: 0; }
  .summary-grid, .plan-totals { grid-template-columns: repeat(3, 1fr); }
  .plan-context { grid-template-columns: repeat(2, 1fr); margin: 14px 0; }
  .plan-list { padding: 0; }
  .plan-item { break-inside: avoid; }
  .legal-note { margin: 14px 0 0; }
}


.pdf-report { display: none; }
.report-page { color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.report-cover { border-bottom: 4px solid var(--teal); padding-bottom: 18px; margin-bottom: 18px; }
.report-cover h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: 0; }
.report-cover p:last-child { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.45; }
.report-section { break-inside: avoid; margin: 18px 0; }
.report-section h2 { margin: 0 0 10px; padding: 8px 10px; background: var(--sage); border: 1px solid var(--line); font-size: 17px; letter-spacing: 0; }
.report-metrics, .report-context { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--line); gap: 1px; }
.report-metrics div, .report-context div { padding: 10px; background: white; }
.report-metrics span, .report-context span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.report-metrics strong, .report-context strong { display: block; overflow-wrap: anywhere; }
.report-context .wide { grid-column: 1 / -1; }
.report-context p { margin: 0; line-height: 1.4; }
.report-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.report-table th, .report-table td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.report-table th { background: #f3f8f6; color: var(--teal-dark); font-size: 10px; text-transform: uppercase; }
.report-table td:nth-child(3), .report-table td:nth-child(4), .report-table td:nth-child(5), .report-table td:nth-child(6), .report-table td:nth-child(7) { white-space: nowrap; }
.report-table span { color: var(--muted); }
.report-warning td { color: #893a2b; background: #fff8f6; }
.next-steps ol { margin: 0; padding-left: 22px; line-height: 1.45; }
.report-footer { margin-top: 20px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }


@media print {
  .app-topbar, .app-shell { display: none !important; }
  .pdf-report { display: block !important; }
}


.roi-calculator {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding-bottom: 16px;
}
.calculator-head { padding: 18px 18px 8px; }
.roi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 14px;
}
.roi-grid label { display: grid; gap: 7px; min-width: 0; }
.roi-grid span, .roi-result span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.roi-result {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0 18px;
  border: 1px solid var(--line);
  background: var(--line);
}
.roi-result > div { min-width: 0; padding: 12px; background: #fbfcfa; }
.roi-result strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.roi-result p { margin: 4px 0 0; line-height: 1.45; }
.roi-result .wide { grid-column: span 2; }
.calculator-note { margin: 12px 18px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.appraisal-packet {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding-bottom: 16px;
}
.packet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 14px;
}
.packet-grid label { display: grid; gap: 7px; min-width: 0; }
.packet-grid label:nth-child(n + 4) { grid-column: span 3; }
.packet-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

@media (max-width: 1120px) {
  .roi-grid, .packet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .packet-grid label:nth-child(n + 4) { grid-column: span 2; }
}

@media (max-width: 720px) {
  .roi-grid, .roi-result, .packet-grid { grid-template-columns: 1fr; }
  .roi-result .wide { grid-column: 1; }
  .packet-grid label:nth-child(n + 4) { grid-column: 1; }
}
