:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-muted: #eef3ef;
  --ink: #1d2522;
  --muted: #63706a;
  --line: #d7ded8;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #dcefeb;
  --warn: #8a5a12;
  --shadow: 0 18px 42px rgba(29, 37, 34, 0.08);
  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;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.site-header {
  background: #20332f;
  color: #f7fbf8;
  border-bottom: 5px solid #d99b30;
}

.site-header__inner {
  width: min(1680px, calc(100% - 24px));
  margin: 0 auto;
  padding: 44px 0 36px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-header .eyebrow {
  color: #f2c870;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 820px;
  font-size: clamp(2.25rem, 5vw, 4.75rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

h3 {
  font-size: 1.05rem;
}

.intro {
  max-width: 720px;
  margin: 18px 0 0;
  color: #d7e5df;
  font-size: 1.05rem;
  line-height: 1.6;
}

.page-shell {
  width: min(1680px, calc(100% - 24px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

.calculator-panel,
.results-panel,
.disclaimer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calculator-panel,
.results-panel {
  min-width: 0;
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.section-heading--compact {
  margin-top: 26px;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input {
  min-height: 44px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.payments-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 26px 0 12px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  gap: 8px;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: var(--accent);
  color: #fff;
}

.button--primary:hover {
  background: var(--accent-strong);
}

.button--secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.button--quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.icon-button {
  width: 36px;
  height: 36px;
  background: #fff4e2;
  color: var(--warn);
  border-color: #edd2a6;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap--inputs {
  max-height: 330px;
}

.table-wrap--preview {
  max-height: 250px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.input-table {
  table-layout: fixed;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

td {
  background: #fff;
}

td.numeric {
  text-align: right;
}

th {
  background: var(--surface-muted);
  color: #41504a;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.input-table input {
  min-width: 0;
}

.input-table input[name="paymentMemo"] {
  min-width: 0;
}

.action-cell {
  width: 48px;
  text-align: center;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
}

.section-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.bulk-panel {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.file-picker {
  display: grid;
  min-width: min(100%, 240px);
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.bulk-preview {
  margin-top: 14px;
}

.preview-table {
  min-width: 0;
  table-layout: fixed;
}

.row-error td {
  background: #fff4ef;
  color: #842d18;
}

.status-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.status-message.is-error {
  color: #a23b25;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px dashed #b8c5bd;
  border-radius: 8px;
  text-align: center;
}

.results {
  display: grid;
  gap: 20px;
}

.workbook-view {
  border: 1px solid #aec2d2;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fbfe;
}

.workbook-titlebar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: #eef5fb;
  border-bottom: 1px solid #c5d5e0;
}

.workbook-titlebar h3 {
  color: #18365d;
  font-size: 1.05rem;
  text-transform: uppercase;
}

.workbook-titlebar span {
  color: #55646e;
  font-size: 0.9rem;
  font-weight: 800;
}

.workbook-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.62fr);
  gap: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.schedule-sheet,
.summary-sheet {
  min-width: 0;
  background: #fff;
}

.summary-sheet {
  border-left: 2px solid #ffffff;
}

.sheet-title {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: #2f7db7;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.sheet-scroll {
  max-height: 720px;
  overflow-x: hidden;
  overflow-y: auto;
}

.sheet-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: clamp(0.76rem, 0.82vw, 0.92rem);
}

.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1f3f70;
  color: #fff;
  border-color: #49678f;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  font-size: clamp(0.95rem, 1.18vw, 1.35rem);
  line-height: 1.05;
}

.sheet-table th,
.sheet-table td {
  padding: 6px 7px;
  line-height: 1.2;
  overflow-wrap: normal;
  white-space: nowrap;
}

.sheet-table th:nth-child(1),
.sheet-table td:nth-child(1) {
  width: 8%;
}

.sheet-table th:nth-child(2),
.sheet-table td:nth-child(2) {
  width: 9%;
}

.sheet-table th:nth-child(3),
.sheet-table td:nth-child(3) {
  width: 9%;
}

.sheet-table th:nth-child(4),
.sheet-table td:nth-child(4),
.sheet-table th:nth-child(5),
.sheet-table td:nth-child(5),
.sheet-table th:nth-child(6),
.sheet-table td:nth-child(6),
.sheet-table th:nth-child(7),
.sheet-table td:nth-child(7),
.sheet-table th:nth-child(8),
.sheet-table td:nth-child(8),
.sheet-table th:nth-child(9),
.sheet-table td:nth-child(9) {
  width: 9.2%;
}

.sheet-table th:nth-child(10),
.sheet-table td:nth-child(10) {
  width: 6%;
}

.sheet-table th:nth-child(11),
.sheet-table td:nth-child(11) {
  width: 6%;
}

.sheet-table td {
  background: #d8eaf8;
  border: 1px solid #bdd3e2;
  color: #112437;
}

.sheet-table tbody tr:nth-child(even) td {
  background: #cfe4f4;
}

.sheet-table .status-cell {
  color: #071f2e;
  font-weight: 900;
}

.summary-sections {
  max-height: 762px;
  overflow: auto;
  background: #fff;
}

.summary-section h4 {
  margin: 0;
  padding: 7px 10px;
  background: #1f3f70;
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.2;
}

.summary-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: clamp(0.72rem, 0.78vw, 0.88rem);
}

.summary-table th,
.summary-table td {
  padding: 6px 7px;
  border: 1px solid #e0e5ea;
  background: #fff;
  color: #12294b;
  vertical-align: top;
  white-space: normal;
}

.summary-table th {
  width: 58%;
  font-weight: 900;
  text-align: left;
}

.summary-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-table tr.is-emphasis th,
.summary-table tr.is-emphasis td {
  background: #dce6f2;
  font-weight: 900;
}

.summary-table tr.is-strong th,
.summary-table tr.is-strong td {
  background: #2f7db7;
  color: #fff;
  font-weight: 900;
}

.summary-table tr.is-compact th,
.summary-table tr.is-compact td {
  padding-top: 6px;
  padding-bottom: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-card,
.detail-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card {
  padding: 16px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.2;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.detail-block--wide {
  grid-column: 1 / -1;
}

.detail-block {
  min-width: 0;
  padding: 16px;
}

.detail-block h3 {
  margin-bottom: 12px;
}

dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, max-content);
  gap: 10px 14px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
  min-width: 0;
}

dd {
  min-width: 0;
  margin: 0;
  text-align: right;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result-table {
  min-width: 1360px;
}

.calculation-table th,
.calculation-table td {
  font-size: 0.86rem;
}

.disclaimer {
  width: min(1680px, calc(100% - 24px));
  margin: 0 auto 32px;
  padding: 16px 18px;
  color: #594019;
  background: #fff8eb;
  border-color: #edcf92;
  line-height: 1.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1120px) {
  .workbook-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-sheet {
    border-top: 2px solid #fff;
    border-left: 0;
  }
}

@media (max-width: 620px) {
  .site-header__inner,
  .page-shell,
  .disclaimer {
    width: min(100% - 20px, 1180px);
  }

  .site-header__inner {
    padding: 34px 0 28px;
  }

  .calculator-panel,
  .results-panel {
    padding: 18px;
  }

  .section-heading,
  .payments-header,
  .bulk-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .summary-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .workbook-titlebar {
    align-items: flex-start;
    flex-direction: column;
  }

  dl {
    grid-template-columns: 1fr;
  }

  dd {
    text-align: left;
  }
}
