<style>
/* ─────────────────────────────────────────────────────────────────────────────
   READABILITY SYSTEM — matching toolkit design system
   ─ Minimum body text: 18px
   ─ Label text: 15px minimum, always font-weight 600
   ─ Number displays: DM Mono, never below 17px
   ─ Interactive targets: minimum 56px height
   ─ Contrast: all text WCAG AAA on white backgrounds
───────────────────────────────────────────────────────────────────────────── */

#amt-root *, #amt-root *::before, #amt-root *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}

#amt-root {
  --bg:             #f8fafc;
  --bg-card:        #ffffff;
  --bg-input:       #f8fafc;
  --bg-row-alt:     #f1f5f9;
  --bg-highlight:   #f1f5f9;

  --border:         #e2e8f0;
  --border-hi:      #cbd5e1;
  --border-focus:   #0891b2;

  --amber:          #d97706;
  --amber-lt:       #b45309;
  --amber-bg:       rgba(217,119,6,0.08);
  --amber-border:   rgba(217,119,6,0.25);

  --cyan:           #0891b2;
  --cyan-lt:        #0369a1;
  --cyan-bg:        rgba(8,145,178,0.08);
  --cyan-border:    rgba(8,145,178,0.25);

  --green:          #059669;
  --green-bg:       rgba(5,150,105,0.08);
  --green-border:   rgba(5,150,105,0.25);

  --red:            #ef4444;
  --red-bg:         rgba(239,68,68,0.08);
  --red-border:     rgba(239,68,68,0.25);

  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-tertiary:  #64748b;

  font-family: 'Source Sans 3', sans-serif;
  font-size: 18px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text-primary);
  padding: 60px 28px 100px;
  -webkit-font-smoothing: antialiased;
}

.amt-wrap { max-width: 1100px; margin: 0 auto; }

/* ─────────────────────────────────────────────────────────────────────────────
   HEADER
───────────────────────────────────────────────────────────────────────────── */
.amt-header { margin-bottom: 60px; }

.amt-eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  margin-bottom: 24px;
}
.amt-eyebrow-rule { width: 36px; height: 3px; background: var(--cyan); border-radius: 2px; }
.amt-eyebrow-text {
  font-family: 'DM Mono', monospace;
  font-size: 13px; font-weight: 600;
  color: var(--cyan); letter-spacing: 0.16em; text-transform: uppercase;
}
.amt-h1 {
  font-family: 'Lora', serif;
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 700; line-height: 1.15;
  color: var(--text-primary); margin-bottom: 20px; letter-spacing: -0.01em;
}
.amt-h1 em { font-style: italic; color: var(--cyan); font-weight: 700; }
.amt-lead {
  font-size: 20px; font-weight: 400;
  color: var(--text-secondary); max-width: 560px; line-height: 1.75;
}

/* ─────────────────────────────────────────────────────────────────────────────
   INPUT LAYOUT — 3 columns
───────────────────────────────────────────────────────────────────────────── */
.amt-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px; margin-bottom: 40px;
}
@media (max-width: 800px) { .amt-inputs { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .amt-inputs { grid-template-columns: 1fr; } }

/* ─────────────────────────────────────────────────────────────────────────────
   CARDS
───────────────────────────────────────────────────────────────────────────── */
.amt-card {
  background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}
.amt-card-head {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.amt-card-icon {
  width: 38px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.amt-card-title {
  font-family: 'Lora', serif;
  font-size: 20px; font-weight: 700;
  color: var(--text-primary); line-height: 1.3;
}
.amt-card-subtitle {
  font-size: 14px; color: var(--text-tertiary); font-weight: 500; margin-top: 1px;
}
.amt-card-body { padding: 26px 28px; }

/* ─────────────────────────────────────────────────────────────────────────────
   FIELDS
───────────────────────────────────────────────────────────────────────────── */
.amt-fields { display: flex; flex-direction: column; gap: 24px; }
.amt-field  { display: flex; flex-direction: column; gap: 9px; }
.amt-label {
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  letter-spacing: 0.02em;
  display: flex; justify-content: space-between; align-items: center;
}
.amt-label-value {
  font-family: 'DM Mono', monospace;
  font-size: 15px; font-weight: 600;
  color: var(--cyan); background: var(--cyan-bg);
  border: 1px solid var(--border);
  padding: 3px 12px; border-radius: 20px;
}
.amt-input-row {
  display: flex; align-items: stretch;
  background: var(--bg-input); border: 2px solid var(--border-hi);
  border-radius: 10px; overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 56px;
}
.amt-input-row:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(8,145,178,0.12);
}
.amt-adorn {
  padding: 0 16px;
  font-family: 'DM Mono', monospace;
  font-size: 18px; font-weight: 600; color: var(--text-tertiary);
  background: var(--bg-highlight); border-right: 2px solid var(--border-hi);
  display: flex; align-items: center; flex-shrink: 0; user-select: none;
}
.amt-adorn-r { border-right: none; border-left: 2px solid var(--border-hi); }
.amt-input-row input, .amt-input-row select {
  flex: 1; border: none; outline: none; background: transparent; padding: 0 18px;
  font-family: 'DM Mono', monospace;
  font-size: 20px; font-weight: 600; color: var(--text-primary); min-width: 0;
  -webkit-appearance: none; appearance: none;
}
.amt-input-row select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
  padding-right: 44px;
}
.amt-input-row input[type=number]::-webkit-inner-spin-button,
.amt-input-row input[type=number]::-webkit-outer-spin-button { opacity: 0; }

.amt-slider-wrap { padding: 6px 0 0; }
input[type=range].amt-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; background: var(--border-hi);
  border-radius: 3px; outline: none; cursor: pointer;
}
input[type=range].amt-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px; background: var(--bg-card);
  border: 3px solid var(--cyan); border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}
input[type=range].amt-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18); box-shadow: 0 0 14px rgba(8,145,178,0.25);
}
input[type=range].amt-slider::-moz-range-thumb {
  width: 26px; height: 26px; background: var(--bg-card);
  border: 3px solid var(--cyan); border-radius: 50%;
}
.amt-slider-labels {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 13px; color: var(--text-tertiary); font-weight: 600;
}
.amt-hint {
  font-size: 15px; color: var(--text-tertiary);
  font-style: italic; line-height: 1.6; padding: 8px 0 0 2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESULTS PANEL
───────────────────────────────────────────────────────────────────────────── */
.amt-results {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
}

/* ── Summary banner ─────────────────────────────────────────────────────────── */
.amt-summary {
  padding: 36px 44px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between; gap: 32px; flex-wrap: wrap;
  background: #f8fafc;
}
.amt-summary-label {
  font-family: 'DM Mono', monospace;
  font-size: 13px; font-weight: 600; color: var(--text-tertiary);
  letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 10px;
}
.amt-summary-title {
  font-family: 'Lora', serif;
  font-size: 30px; font-weight: 700;
  color: var(--text-primary); line-height: 1.2;
}
.amt-summary-sub {
  font-size: 18px; color: var(--text-secondary); margin-top: 6px; line-height: 1.6;
}
.amt-payment-badge {
  flex-shrink: 0; text-align: center;
  padding: 20px 36px; border-radius: 14px;
  background: var(--cyan-bg); border: 2px solid var(--cyan-border);
}
.amt-payment-badge-label {
  font-family: 'DM Mono', monospace;
  font-size: 12px; font-weight: 600; color: var(--cyan-lt);
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px;
}
.amt-payment-badge-amount {
  font-family: 'Lora', serif;
  font-size: clamp(36px, 5vw, 52px); font-weight: 700;
  color: var(--cyan-lt); line-height: 1; letter-spacing: -0.02em;
}
.amt-payment-badge-sub {
  font-size: 15px; font-weight: 500; color: var(--text-tertiary); margin-top: 6px;
}

/* ── Stat grid ──────────────────────────────────────────────────────────────── */
.amt-stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 700px) { .amt-stat-grid { grid-template-columns: 1fr 1fr; } }

.amt-stat {
  padding: 28px 28px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.amt-stat:nth-child(4n) { border-right: none; }
@media (max-width: 700px) {
  .amt-stat:nth-child(2n) { border-right: none; }
}
.amt-stat-last-row { border-bottom: none; }

.amt-stat-label {
  font-size: 13px; font-weight: 700; color: var(--text-tertiary);
  letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 10px; line-height: 1.4;
}
.amt-stat-value {
  font-family: 'DM Mono', monospace;
  font-size: 26px; font-weight: 600; color: var(--text-primary);
  letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 4px;
  transition: all 0.25s ease;
}
.amt-stat-sub { font-size: 13px; color: var(--text-tertiary); line-height: 1.5; font-weight: 500; }

/* ── Split visual bar ───────────────────────────────────────────────────────── */
.amt-split-section {
  padding: 28px 40px 32px;
  border-bottom: 1px solid var(--border);
}
.amt-split-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.amt-split-title {
  font-size: 15px; font-weight: 700; color: var(--text-secondary);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.amt-split-pcts {
  display: flex; gap: 20px;
}
.amt-split-pct-item {
  display: flex; align-items: center; gap: 7px;
  font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 600;
}
.amt-split-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.amt-split-track {
  height: 14px; background: var(--border-hi);
  border-radius: 7px; overflow: hidden; display: flex;
}
.amt-split-principal {
  background: linear-gradient(90deg, var(--cyan-lt), var(--cyan));
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  height: 100%; border-radius: 7px 0 0 7px;
}
.amt-split-interest {
  background: linear-gradient(90deg, var(--amber), var(--amber-lt));
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  height: 100%; border-radius: 0 7px 7px 0;
}
.amt-crossover-note {
  margin-top: 12px; font-size: 15px; font-weight: 500;
  color: var(--text-tertiary); font-style: italic;
}
.amt-crossover-note span { color: var(--green); font-weight: 600; font-style: normal; }

/* ─────────────────────────────────────────────────────────────────────────────
   VIEW TOGGLE — Year summary / Full table
───────────────────────────────────────────────────────────────────────────── */
.amt-view-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; border-bottom: 1px solid var(--border);
  background: var(--bg-highlight); flex-wrap: wrap; gap: 14px;
}
.amt-view-label {
  font-size: 15px; font-weight: 700; color: var(--text-secondary);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.amt-view-toggle {
  display: flex; gap: 8px;
}
.amt-view-btn {
  padding: 9px 20px; border: 2px solid var(--border-hi);
  border-radius: 8px; background: var(--bg-card); cursor: pointer;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 15px; font-weight: 600; color: var(--text-secondary);
  transition: all 0.18s ease;
}
.amt-view-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.amt-view-btn.active {
  background: var(--cyan-bg); border-color: var(--cyan); color: var(--cyan-lt);
}

/* ─────────────────────────────────────────────────────────────────────────────
   YEAR ACCORDION
───────────────────────────────────────────────────────────────────────────── */
.amt-year-block {}
.amt-year-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 1fr 1fr 1fr 44px;
  align-items: center;
  padding: 0 16px 0 32px;
  min-height: 60px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg-card);
  transition: background 0.15s;
  gap: 0;
}
.amt-year-row:hover { background: var(--bg-row-alt); }
.amt-year-row.open  { background: var(--cyan-bg); border-bottom-color: var(--cyan-border); }

.amt-year-num {
  font-family: 'DM Mono', monospace;
  font-size: 14px; font-weight: 600; color: var(--text-tertiary);
  padding-right: 12px;
}
.amt-year-cell {
  font-family: 'DM Mono', monospace;
  font-size: 17px; font-weight: 600; color: var(--text-primary);
  text-align: right; padding: 0 14px;
}
.amt-year-cell.col-principal { color: var(--cyan-lt); }
.amt-year-cell.col-interest  { color: var(--amber);   }
.amt-year-cell.col-balance   { color: var(--text-primary); }

/* Mini split bar inside year row */
.amt-year-bar-cell { padding: 0 14px; }
.amt-year-bar-track {
  height: 8px; background: var(--border-hi);
  border-radius: 4px; overflow: hidden; display: flex; width: 100%; min-width: 80px;
}
.amt-year-bar-p { background: var(--cyan); height: 100%; border-radius: 4px 0 0 4px; }
.amt-year-bar-i { background: var(--amber); height: 100%; border-radius: 0 4px 4px 0; }

.amt-year-chevron {
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-tertiary);
  transition: transform 0.2s ease;
  width: 28px; height: 28px;
}
.amt-year-row.open .amt-year-chevron { transform: rotate(180deg); }

/* Month rows inside accordion */
.amt-month-rows { display: none; }
.amt-month-rows.open { display: block; }

.amt-month-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 1fr 1fr 1fr 44px;
  align-items: center;
  padding: 0 16px 0 32px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  transition: background 0.12s;
  gap: 0;
}
.amt-month-row:last-child { border-bottom: 2px solid var(--border-hi); }
.amt-month-row:hover { background: var(--bg-row-alt); }
.amt-month-row.milestone-crossover {
  background: var(--green-bg);
  border-top: 2px solid var(--green-border);
  border-bottom: 2px solid var(--green-border);
}
.amt-month-row.milestone-half {
  background: var(--amber-bg);
  border-top: 2px solid var(--amber-border);
  border-bottom: 2px solid var(--amber-border);
}

.amt-month-num {
  font-family: 'DM Mono', monospace;
  font-size: 13px; font-weight: 500; color: var(--text-tertiary);
  padding-right: 12px;
}
.amt-month-cell {
  font-family: 'DM Mono', monospace;
  font-size: 16px; font-weight: 500; color: var(--text-secondary);
  text-align: right; padding: 0 14px;
}
.amt-month-cell.col-principal { color: var(--cyan-lt); font-weight: 600; }
.amt-month-cell.col-interest  { color: var(--amber);   font-weight: 600; }
.amt-month-cell.col-balance   { color: var(--text-primary); font-weight: 600; }

/* Milestone pill */
.amt-milestone-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; white-space: nowrap;
}
.amt-milestone-col { display: flex; justify-content: flex-end; padding-right: 6px; }

/* ── Table header ────────────────────────────────────────────────────────────── */
.amt-table-header {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 1fr 1fr 1fr 44px;
  padding: 0 16px 0 32px; gap: 0;
  background: var(--bg-highlight); border-bottom: 2px solid var(--border-hi);
}
.amt-th {
  padding: 16px 14px;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  letter-spacing: 0.08em; text-transform: uppercase;
  text-align: right; line-height: 1.3;
}
.amt-th:first-child { text-align: left; padding-left: 0; }
.amt-th:last-child  { padding-right: 0; }

/* ─────────────────────────────────────────────────────────────────────────────
   FULL TABLE view (flat, paginated)
───────────────────────────────────────────────────────────────────────────── */
#amt-flat-view { display: none; }
#amt-flat-view.visible { display: block; }

.amt-flat-table { width: 100%; border-collapse: collapse; }
.amt-flat-table thead th {
  padding: 16px 24px;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  letter-spacing: 0.08em; text-transform: uppercase; text-align: right;
  background: var(--bg-highlight); border-bottom: 2px solid var(--border-hi);
  white-space: nowrap;
}
.amt-flat-table thead th:first-child { text-align: left; }
.amt-flat-table tbody td {
  padding: 16px 24px;
  font-family: 'DM Mono', monospace;
  font-size: 16px; font-weight: 500; color: var(--text-secondary);
  text-align: right; border-bottom: 1px solid var(--border);
  line-height: 1.3;
}
.amt-flat-table tbody tr:last-child td { border-bottom: none; }
.amt-flat-table tbody td:first-child { text-align: left; color: var(--text-tertiary); font-weight: 600; }
.amt-flat-table tbody tr:hover td { background: var(--bg-row-alt); }
.amt-flat-table .col-principal { color: var(--cyan-lt); font-weight: 600; }
.amt-flat-table .col-interest  { color: var(--amber);   font-weight: 600; }
.amt-flat-table .col-balance   { color: var(--text-primary); font-weight: 600; }
.amt-flat-table .col-pct td    { font-size: 14px; }

/* Milestone rows in flat table */
.amt-flat-table tbody tr.row-crossover td {
  background: var(--green-bg); border-top: 2px solid var(--green-border);
  border-bottom: 2px solid var(--green-border);
}
.amt-flat-table tbody tr.row-half td {
  background: var(--amber-bg); border-top: 2px solid var(--amber-border);
  border-bottom: 2px solid var(--amber-border);
}

/* Pagination */
.amt-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; border-top: 1px solid var(--border);
  background: var(--bg-highlight); flex-wrap: wrap; gap: 12px;
}
.amt-page-info {
  font-family: 'DM Mono', monospace;
  font-size: 14px; font-weight: 600; color: var(--text-tertiary);
}
.amt-page-btns { display: flex; gap: 8px; }
.amt-page-btn {
  padding: 9px 20px; border: 2px solid var(--border-hi);
  border-radius: 8px; background: var(--bg-card); cursor: pointer;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 15px; font-weight: 600; color: var(--text-secondary);
  transition: all 0.18s;
}
.amt-page-btn:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.amt-page-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Takeaway ────────────────────────────────────────────────────────────────── */
.amt-takeaway {
  display: grid; grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
}
@media (max-width: 640px) { .amt-takeaway { grid-template-columns: 1fr; } }
.amt-take-col { padding: 36px 40px; border-right: 1px solid var(--border); }
.amt-take-col:last-child { border-right: none; }
.amt-take-heading {
  font-family: 'Lora', serif;
  font-size: 20px; font-weight: 700; margin-bottom: 20px; line-height: 1.3;
}
.amt-take-item { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.amt-take-arrow { font-size: 20px; font-weight: 700; line-height: 1.6; flex-shrink: 0; }
.amt-take-text  { font-size: 17px; color: var(--text-secondary); line-height: 1.7; font-weight: 500; }

/* ── Footnote ────────────────────────────────────────────────────────────────── */
.amt-footnote {
  padding: 28px 40px; border-top: 1px solid var(--border);
  font-size: 15px; color: var(--text-tertiary);
  line-height: 1.7; font-style: italic; background: var(--bg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────────────────────────────────────────── */
@keyframes amt-up { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.amt-header  { animation: amt-up 0.5s ease both 0.05s; }
.amt-inputs  { animation: amt-up 0.5s ease both 0.15s; }
.amt-results { animation: amt-up 0.5s ease both 0.25s; }
.amt-stat-value, .amt-payment-badge-amount { transition: all 0.25s ease; }

/* ─────────────────────────────────────────────────────────────────────────────
   PRINT STYLES
───────────────────────────────────────────────────────────────────────────── */
@media print {
  #amt-root { padding: 20px; background: white; }
  .amt-inputs, .amt-summary, .amt-split-section { page-break-inside: avoid; }
  .amt-month-rows { display: block !important; }
  .amt-year-chevron { display: none; }
  .amt-view-bar, .amt-pagination { display: none; }
  #amt-flat-view { display: block !important; }
  #amt-year-view { display: none; }
}
</style>