.money-page {
  box-sizing: border-box;
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 52px;
  color: #1d314d;
}

.money-page *,
.money-page *::before,
.money-page *::after { box-sizing: border-box; }

body:has(.money-page) { overflow-x: clip; }

ol.breadcrumb.money-breadcrumb {
  height: auto;
  min-height: 50px;
  flex-wrap: wrap;
}

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

.money-intro {
  max-width: 850px;
  margin: 0 0 16px;
  color: #405976;
  font-size: 1.05rem;
  line-height: 1.7;
}

.money-privacy {
  max-width: 850px;
  padding: 12px 16px;
  border-left: 4px solid #087f5b;
  border-radius: 8px;
  background: #edf8f4;
  color: #174c3c;
  line-height: 1.55;
}

.money-calculator,
.money-page > section {
  margin-bottom: 24px;
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid #d8e4f0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(28, 66, 108, .08);
}

.money-page h2 { margin: 0 0 16px; color: #173b66; }
.money-page h3 { color: #254c78; }
.money-page p,
.money-page li { line-height: 1.65; }

.money-calculator #entry {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.money-calculator #entry::before { content: none; }

.money-basic-fields,
.money-advanced-fields,
.money-row,
#moneySummary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.money-field { min-width: 0; }

.money-field label {
  display: block;
  margin-bottom: 7px;
  color: #263e5c;
  font-weight: 700;
}

.money-field input,
.money-field select,
.paste-panel textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #9eafc1;
  border-radius: 9px;
  background: #fff;
  color: #172b48;
  font: inherit;
}

.money-input-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid #9eafc1;
  border-radius: 9px;
  background: #fff;
}

.money-input-wrap > span {
  flex: 0 0 auto;
  padding: 0 11px;
  color: #526b88;
  font-weight: 700;
}

.money-input-wrap input {
  min-width: 0;
  border: 0;
  border-radius: 0;
}

.money-field [aria-invalid="true"],
.money-input-wrap:has([aria-invalid="true"]) { border-color: #b42318; background: #fff6f4; }

.field-error {
  min-height: 1.3em;
  margin: 5px 0 0;
  padding-left: 8px;
  border-left: 3px solid transparent;
  color: #a1331f;
  font-size: .86rem;
}

.field-error:not(:empty) { border-left-color: #b42318; font-weight: 650; }
.row-error { grid-column: 1 / -1; margin-top: -8px; }

.money-editor,
.money-advanced {
  margin-top: 22px;
  padding: 17px;
  border: 1px solid #d8e4f0;
  border-radius: 13px;
}

.money-editor legend { padding: 0 7px; color: #173b66; font-weight: 800; }
.money-advanced summary { min-height: 44px; cursor: pointer; color: #173b66; font-weight: 750; }
.money-advanced-fields { margin-top: 14px; }

.money-row {
  align-items: end;
  grid-template-columns: minmax(150px, 1.35fr) repeat(3, minmax(115px, 1fr)) auto;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e3eaf2;
}

.money-editor-actions,
.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 44px;
}

.money-editor-actions button,
.paste-panel button,
.schedule-actions button,
.remove-row {
  min-width: 132px;
  padding: 10px 18px;
  border: 1px solid #1768ad;
  border-radius: 9px;
  background: #1768ad;
  color: #fff;
  font: 700 .94rem system-ui, sans-serif;
  cursor: pointer;
}

.remove-row {
  min-width: 92px;
  border-color: #d6b9b9;
  background: #fff5f5;
  color: #8b1e1e;
}

.paste-panel { margin-top: 14px; }
.paste-panel textarea { display: block; min-height: 116px; margin: 8px 0 10px; resize: vertical; }

.money-field input:focus-visible,
.money-field select:focus-visible,
.paste-panel textarea:focus-visible,
.money-page button:focus-visible,
.money-table-wrap:focus-visible,
.money-page summary:focus-visible {
  outline: 3px solid #ffb000;
  outline-offset: 3px;
}

.money-results {
  margin-top: 28px;
  padding: 24px;
  border: 1px solid #c8e0f3;
  border-radius: 16px;
  background: linear-gradient(145deg, #f5faff, #eaf5ff);
}

#moneyResult {
  margin: 6px 0 8px;
  overflow-wrap: anywhere;
  color: #075e48;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
  font-weight: 850;
}

#moneyInterpretation { max-width: 800px; color: #334f6e; }

#moneySummary { margin-top: 18px; }
.money-summary-card { min-width: 0; padding: 14px; border: 1px solid #d3e2f0; border-radius: 11px; background: #fff; }
.money-summary-card span,
.money-summary-card strong { display: block; }
.money-summary-card span { color: #526b88; font-size: .84rem; }
.money-summary-card strong { margin-top: 5px; overflow-wrap: anywhere; color: #173b66; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

#moneyChart {
  max-width: 100%;
  margin-top: 22px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid #d4e2ef;
  border-radius: 12px;
  background: #fff;
}

#moneyChart:empty { display: none; }
#moneyChart svg { display: block; width: 100%; max-width: 100%; height: auto; }
#moneyChart text { fill: #324d6b; font: 700 14px system-ui, sans-serif; }
#moneyChart rect { fill: #2377c8; }
#moneyChart .series-1 { fill: #13866d; }
#moneyChart .series-2 { fill: #7657b5; }
#moneyChart .series-3 { fill: #d28613; }
#moneyChart .series-4 { fill: #65758b; }
#moneyChart .negative { fill: #b42318; }
#moneyChartSummary { margin: 10px 0 0; color: #425d79; }

.money-detail { margin-top: 26px; }
.schedule-actions button:last-of-type { background: #fff; color: #1768ad; }
.schedule-actions button:disabled { cursor: default; opacity: .58; }
.export-status { min-height: 24px; margin: 8px 0; color: #315b83; font-size: .9rem; }
.table-scroll-help { margin: 8px 0; color: #526b88; font-size: .9rem; }

.money-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid #d7e2ee;
  border-radius: 12px;
}

.money-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.money-table caption { padding: 12px; text-align: left; font-weight: 750; }
.money-table th,
.money-table td { padding: 10px 12px; border-bottom: 1px solid #e3eaf2; text-align: right; white-space: nowrap; }
.money-table th:first-child,
.money-table td:first-child { text-align: left; }
.money-table thead th { position: sticky; top: 0; z-index: 1; background: #eaf3fb; color: #274a70; }
.money-table tbody tr:nth-child(even) { background: #f8fbfe; }

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

@media (max-width: 720px) {
  .money-page { width: min(100% - 20px, 1180px); margin-top: 18px; overflow-x: clip; }
  .money-calculator,
  .money-page > section { padding: 18px; border-radius: 14px; }
  .money-basic-fields,
  .money-advanced-fields,
  .money-row,
  #moneySummary { grid-template-columns: 1fr; }
  .money-editor { padding: 14px; }
  .money-editor-actions button,
  .schedule-actions button,
  .remove-row { width: 100%; }
  #moneyChart { padding: 5px; }
  #moneyChart text { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .money-page *,
  .money-page *::before,
  .money-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  @page { size: letter landscape; margin: .45in; }
  body { background: #fff !important; color: #111 !important; }
  body > header,
  body > footer,
  .breadcrumb,
  .heading-gradient-bar,
  #heading,
  .money-intro,
  .money-privacy,
  .schedule-actions,
  .export-status,
  .table-scroll-help,
  .money-formula,
  .money-how-to,
  .money-example,
  .money-faq,
  .tool-related,
  aside,
  .ad-container { display: none !important; }
  .money-page { width: 100%; margin: 0; color: #111; }
  .money-calculator #entry { display: none; }
  .money-page .print-only { display: block; }
  .money-page .print-report-header { display: block; margin-bottom: 16px; }
  .money-page .print-report-header h2 { margin-bottom: 5px; }
  .money-page .print-report-header p { margin: 2px 0; font-size: 8.5pt; }
  .money-calculator,
  .money-page > section { margin: 0 0 15px; padding: 0; border: 0; box-shadow: none; }
  .money-results { break-inside: avoid; padding: 12px; border: 1px solid #777; background: #fff; }
  #moneyChart,
  #moneyChartSummary { display: none; }
  #moneySummary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .money-summary-card { padding: 7px; border-color: #999; }
  #moneyPrintInputs { margin-top: 12px; }
  #moneyPrintInputs h3 { margin: 10px 0 4px; font-size: 10pt; }
  #moneyPrintInputs dl {
    display: grid;
    grid-template-columns: minmax(90px, auto) 1fr;
    gap: 3px 12px;
    margin: 0;
    font-size: 7.5pt;
  }
  #moneyPrintInputs dt { font-weight: 700; }
  #moneyPrintInputs dd { margin: 0; overflow-wrap: anywhere; }
  .money-table-wrap { overflow: visible; border: 0; }
  .money-table { min-width: 0; font-size: 7pt; }
  .money-table thead { display: table-header-group; }
  .money-table tr { break-inside: avoid; }
  .money-table thead th { position: static; background: #eee !important; }
  .money-table th,
  .money-table td { padding: 3px 4px; white-space: normal; }
  .money-assumptions { break-before: page; }
  .money-disclaimer { break-inside: avoid; border-color: #555; background: #fff; font-size: 8.5pt; }
}
