.housing-page {
  box-sizing: border-box;
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 48px;
  color: #1d314d;
}

.print-report-header,
.print-only { display: none; }

.housing-page > section,
.housing-calculator {
  box-sizing: border-box;
  margin-bottom: 24px;
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid #d8e4f0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(28, 66, 108, .07);
}

.housing-page h2 { margin: 0 0 16px; color: #173b66; }
.housing-page h3 { color: #254c78; }
.housing-intro { margin-bottom: 8px; font-size: 1.05rem; }
.housing-privacy { margin: 0 0 22px; color: #42647f; font-size: .92rem; }
.housing-calculator #entry { min-width: 0; }
.housing-basic-fields,
.housing-advanced-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}
.housing-field[hidden] { display: none; }
.housing-field label { display: block; margin-bottom: 7px; color: #263e5c; font-weight: 700; }
.housing-input-wrap {
  display: flex;
  align-items: center;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid #a9bfd6;
  border-radius: 10px;
  background: #fff;
}
.housing-input-wrap > span { padding: 0 12px; color: #526b88; font-weight: 700; }
.housing-field input,
.housing-field select {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #a9bfd6;
  border-radius: 10px;
  background: #fff;
  color: #172b48;
  font: inherit;
}
.housing-input-wrap input { min-width: 0; border: 0; border-radius: 0; }
.housing-field [aria-invalid="true"] { background: #fff6f3; }
.field-help { margin: 6px 0 0; color: #526b88; font-size: .86rem; line-height: 1.45; }
.field-error { min-height: 20px; margin: 5px 0 0; color: #a1331f; font-size: .86rem; }

.housing-advanced { margin-top: 20px; border: 1px solid #d5e1ed; border-radius: 12px; }
.housing-advanced > summary {
  min-height: 44px;
  padding: 12px 16px;
  color: #174e83;
  font-weight: 800;
  cursor: pointer;
}
#advancedSummary {
  display: block;
  margin-top: 3px;
  color: #526b88;
  font-size: .78rem;
  font-weight: 500;
}
.housing-advanced-fields { padding: 6px 16px 18px; }

.housing-results { margin-top: 24px; padding: 22px; border-radius: 14px; background: #eef7ff; }
#housingResult { color: #075e48; font-size: clamp(1.65rem, 4vw, 2.35rem); font-weight: 800; }
#housingInterpretation { margin-top: 7px; color: #315b67; }
#housingSummary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.summary-item { padding: 12px; border: 1px solid #d3e2f0; border-radius: 10px; background: #fff; }
.summary-item span,
.summary-item strong { display: block; }
.summary-item span { color: #526b88; font-size: .85rem; }
.summary-item strong { margin-top: 4px; overflow-wrap: anywhere; font-size: 1.05rem; }
#housingChart { max-width: 720px; margin-top: 20px; }
#housingChart svg { display: block; width: 100%; height: auto; font: 13px system-ui, sans-serif; }
.chart-series-0 { fill: #1768ad; }
.chart-series-1 { fill: #0b8066; }
.chart-series-2 { fill: #9a5a13; }
.chart-series-3 { fill: #6651a8; }
.chart-negative { fill: #a33d2d; }
#housingChartSummary { color: #42647f; font-size: .9rem; }

.housing-detail { margin-top: 26px; }
.schedule-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.schedule-actions button {
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid #a8bfd8;
  border-radius: 9px;
  background: #fff;
  color: #174e83;
  font: 700 .92rem system-ui, sans-serif;
  cursor: pointer;
}
.schedule-actions button[aria-pressed="true"] { border-color: #1768ad; background: #1768ad; color: #fff; }
.schedule-actions button:disabled { cursor: not-allowed; opacity: .55; }
.export-status { min-height: 24px; margin: 0 0 10px; color: #315b83; font-size: .9rem; }
.table-scroll-help { margin: 0 0 8px; color: #526b88; font-size: .85rem; }
.housing-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #d7e2ee;
  border-radius: 12px;
  background: #fff;
}
.housing-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.housing-table caption { padding: 12px; text-align: left; font-weight: 700; }
.housing-table th,
.housing-table td { padding: 10px 12px; border-top: 1px solid #e3eaf2; text-align: left; white-space: nowrap; }
.housing-table thead th { position: sticky; top: 0; z-index: 1; background: #eaf3fb; color: #274a70; }
.housing-table td.number { text-align: right; font-variant-numeric: tabular-nums; }
.housing-table tbody tr:nth-child(even) { background: #f8fbfe; }

.housing-page p,
.housing-page li { line-height: 1.65; }
.housing-faq details { padding: 13px 0; border-top: 1px solid #dfe7ef; }
.housing-faq summary { cursor: pointer; color: #244c78; font-weight: 700; }
.housing-disclaimer { padding: 15px 18px; border-left: 4px solid #6f8da9; background: #f3f7fa; }

.housing-field input:focus-visible,
.housing-field select:focus-visible,
.housing-advanced > summary:focus-visible,
.schedule-actions button:focus-visible,
.housing-table-wrap:focus-visible {
  outline: 3px solid #8cc5ff;
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .breadcrumb { flex-wrap: wrap; }
  .housing-page { width: min(100% - 20px, 1120px); margin-top: 18px; }
  .housing-page > section,
  .housing-calculator { padding: 18px; border-radius: 14px; }
  .housing-basic-fields,
  .housing-advanced-fields,
  #housingSummary { grid-template-columns: 1fr; }
  .schedule-actions button { flex: 1 1 calc(50% - 10px); }
  .table-scroll-help { display: block; }
}

@media print {
  @page { size: letter portrait; margin: .55in; }
  body { background: #fff !important; color: #111 !important; }
  body > header,
  body > footer,
  .breadcrumb,
  .heading,
  .schedule-actions,
  .export-status,
  .housing-formula,
  .housing-how-to,
  .housing-example,
  .housing-faq,
  .tool-related,
  aside,
  .ad-container { display: none !important; }
  .housing-page { width: 100%; margin: 0; color: #111; }
  .print-report-header,
  .print-only { display: block; }
  .housing-page > section,
  .housing-calculator { margin: 0 0 18px; padding: 0; border: 0; box-shadow: none; }
  .housing-results { break-inside: avoid; padding: 14px; border: 1px solid #777; background: #fff; }
  .housing-table-wrap { overflow: visible; border: 0; }
  .housing-table { min-width: 0; font-size: 7.5pt; }
  .housing-table thead { display: table-header-group; }
  .housing-table tr { break-inside: avoid; }
  .housing-table thead th { position: static; background: #eee !important; }
  .housing-table th,
  .housing-table td { padding: 4px 5px; white-space: normal; }
}
