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

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

.borrowing-page > section,
.borrowing-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);
}

.borrowing-page h2 { margin: 0 0 16px; color: #173b66; }
.borrowing-page h3 { color: #254c78; }
.borrowing-calculator #entry { min-width: 0; }
.borrowing-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}
.borrowing-field label {
  display: block;
  margin-bottom: 7px;
  color: #263e5c;
  font-weight: 700;
}
.borrowing-input-wrap {
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid #a9bfd6;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.borrowing-input-wrap > span { padding: 0 12px; color: #526b88; font-weight: 700; }
.borrowing-field input,
.borrowing-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;
}
.borrowing-input-wrap input { min-width: 0; border: 0; border-radius: 0; }
.borrowing-field input:focus-visible,
.borrowing-field select:focus-visible,
.schedule-actions button:focus-visible,
.year-toggle:focus-visible {
  outline: 3px solid #8cc5ff;
  outline-offset: 2px;
}
.borrowing-field [aria-invalid="true"] { background: #fff6f3; }
.field-error { min-height: 20px; margin: 5px 0 0; color: #a1331f; font-size: .86rem; }

.borrowing-results { margin-top: 24px; padding: 22px; border-radius: 14px; background: #eef7ff; }
#borrowingResult { color: #075e48; font-size: clamp(1.65rem, 4vw, 2.35rem); font-weight: 800; }
#borrowingSummary {
  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; }
.cost-bar { display: flex; grid-column: 1 / -1; height: 14px; border-radius: 999px; overflow: hidden; background: #e2eaf2; }
.cost-principal { background: #2377c8; }
.cost-interest { background: #f0a33a; }

.borrowing-schedule { margin-top: 26px; }
.schedule-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.schedule-actions button,
.year-toggle {
  min-height: 44px;
  padding: 9px 14px;
  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; }
.schedule-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #d7e2ee;
  border-radius: 12px;
  background: linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
    linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(35,67,103,.18), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(35,67,103,.18), transparent) 100% 0;
  background-attachment: local, local, scroll, scroll;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
}
.borrowing-schedule table { width: 100%; min-width: 760px; border-collapse: collapse; }
.borrowing-schedule caption { padding: 12px; text-align: left; font-weight: 700; }
.borrowing-schedule th,
.borrowing-schedule td { padding: 10px 12px; border-top: 1px solid #e3eaf2; text-align: left; white-space: nowrap; }
.borrowing-schedule th { position: sticky; top: 0; z-index: 1; background: #eaf3fb; color: #274a70; }
.borrowing-schedule td.number { text-align: right; font-variant-numeric: tabular-nums; }
.borrowing-schedule tbody tr:nth-child(even) { background: #f8fbfe; }
.year-summary { background: #edf6ff !important; font-weight: 700; }
.year-month-row.is-collapsed { display: none; }
.year-month-row td:first-child { padding-left: 28px; }

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

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

@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,
  .borrowing-formula,
  .borrowing-example,
  .borrowing-faq,
  .tool-related,
  aside,
  .ad-container { display: none !important; }

  .borrowing-page { width: 100%; margin: 0; color: #111; }
  .print-report-header { display: block; margin-bottom: 18px; }
  .print-report-header h2 { margin-bottom: 6px; }
  .print-report-header p { margin: 2px 0; font-size: 9pt; }
  .borrowing-page > section,
  .borrowing-calculator { margin: 0 0 18px; padding: 0; border: 0; box-shadow: none; }
  .borrowing-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .borrowing-input-wrap,
  .borrowing-field input,
  .borrowing-field select { border-color: #777; }
  .borrowing-results { break-inside: avoid; padding: 14px; border: 1px solid #777; background: #fff; }
  .schedule-table-wrap { overflow: visible; border: 0; background: none; }
  .borrowing-schedule table { min-width: 0; font-size: 7.5pt; }
  .borrowing-schedule thead { display: table-header-group; }
  .borrowing-schedule tr { break-inside: avoid; }
  .borrowing-schedule th { position: static; background: #eee !important; }
  .borrowing-schedule th,
  .borrowing-schedule td { padding: 4px 5px; }
  .year-month-row.is-collapsed { display: table-row; }
  .borrowing-disclaimer { break-inside: avoid; border-color: #555; background: #fff; font-size: 9pt; }
}
