/* ============================================================
   SCCA 430 — Financial Declaration (Web Edition)
   Aesthetic: faithful to the official PDF — black on white,
   tabular, official-document. Letter-size paper feel.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@400;600;700&family=Source+Sans+3:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --paper:        #ffffff;
  --canvas:       #d8d6cf;       /* desk surface around the page */
  --ink:          #000000;
  --ink-soft:     #333333;
  --ink-mute:     #6b6b6b;
  --rule:         #000000;
  --rule-soft:    #b5b5b5;
  --shade:        #e8e8e8;       /* table header shade */
  --shade-deep:   #cfcfcf;       /* SUBTOTAL row shade */
  --black-bar:    #000000;       /* unused-cell bars from PDF */
  --highlight:    #fff8c2;       /* focused field */
  --accent:       #1f3864;       /* judicial branch navy */
  --warn:         #8b1a1a;
  --good:         #1a5a2d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.35;
  min-height: 100vh;
}

/* ---------- Toolbar (sticky, off-paper) ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #2a2a2a;
  color: #f0f0f0;
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #000;
  font-size: 15.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.toolbar .brand {
  font-family: 'Source Serif 4', serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.toolbar .group { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar button {
  font-family: inherit;
  font-size: 14.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid #5a5a5a;
  background: #3a3a3a;
  color: #f0f0f0;
  cursor: pointer;
  transition: all 0.12s;
}
.toolbar button:hover { background: #f0f0f0; color: #2a2a2a; }
.toolbar button.primary { background: var(--accent); border-color: var(--accent); }
.toolbar button.primary:hover { background: #fff; color: var(--accent); border-color: #fff; }
.toolbar .status {
  font-size: 14.5px;
  color: #c0c0c0;
  font-style: italic;
}
.toolbar .status .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--good);
  margin-right: 6px;
}

/* ---------- Paper page ---------- */
.page {
  background: var(--paper);
  width: 850px;
  max-width: 100%;
  margin: 16px auto;
  padding: 56px 60px 80px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  position: relative;
  font-size: 15px;
  line-height: 1.4;
}

/* ---------- Caption block (top of pg 1) ---------- */
.caption-block {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px 14px;
  margin-bottom: 22px;
  font-size: 15px;
}
.caption-block .left,
.caption-block .right { display: flex; flex-direction: column; gap: 6px; }
.caption-block .paren { color: var(--ink); font-family: 'Source Serif 4', serif; padding: 0 4px; align-self: stretch; }
.caption-block .right { text-align: left; }
.caption-block .right .heading {
  font-weight: 700;
  text-transform: none;
  font-size: 16px;
  margin-bottom: 4px;
}
.caption-block .line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.caption-block .line label {
  font-size: 13.5px;
  white-space: nowrap;
}
.caption-block .line input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  padding: 1px 2px;
}
.caption-block .line input:focus { outline: none; background: var(--highlight); }
.caption-block .vs {
  text-align: right;
  font-style: italic;
  padding-right: 8px;
}

/* ---------- Section heading ---------- */
.section-h {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  margin: 18px 0 6px;
}
.section-h.left { text-align: left; }
.note {
  font-size: 13.5px;
  margin: 10px 0 4px;
  line-height: 1.45;
}
.note .underline {
  border-bottom: 1px solid var(--ink);
  display: inline-block;
  min-width: 240px;
  padding: 0 4px;
  outline: none;
}
.note .underline:focus { background: var(--highlight); }

/* ---------- Form table (the main pattern) ---------- */
table.fd {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--ink);
  margin-bottom: 8px;
  font-size: 14.5px;
}
table.fd th,
table.fd td {
  border: 1px solid var(--ink);
  padding: 4px 6px;
  vertical-align: middle;
}
table.fd thead th {
  background: var(--shade);
  font-weight: 700;
  text-align: left;
  font-size: 14.5px;
}
table.fd thead th.center { text-align: center; }
table.fd td.label { width: auto; }
table.fd td.amount {
  text-align: right;
  width: 130px;
  padding: 0;
}
table.fd td.amount input {
  width: 100%;
  border: none;
  background: transparent;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14.5px;
  padding: 4px 8px;
}
table.fd td.amount input:focus {
  outline: none;
  background: var(--highlight);
}
table.fd td.amount input.readonly {
  background: #f3f3f3;
  color: var(--ink-soft);
}
table.fd td.text input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  padding: 4px 6px;
}
table.fd td.text input:focus { outline: none; background: var(--highlight); }

/* Linkable label (opens a sub-form) */
.linkable {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.linkable::after { content: " ↗"; font-size: 11.5px; }
.linkable:hover { color: #0066cc; }

/* Endnote superscript */
sup.en {
  font-size: 10.5px;
  vertical-align: super;
  margin-left: 2px;
  color: var(--ink-soft);
  cursor: help;
}

/* Subtotal and total rows */
table.fd tr.subtotal td {
  background: var(--shade-deep);
  font-weight: 700;
}
table.fd tr.subtotal td.bar {
  background: var(--black-bar);
}
table.fd tr.total td {
  background: var(--shade);
  font-weight: 700;
  font-size: 15px;
}

/* ---------- Header tables (Husband / Wife identification) ---------- */
table.parties {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--ink);
  margin-bottom: 14px;
  font-size: 14.5px;
}
table.parties th {
  background: var(--shade);
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--ink);
  padding: 4px;
}
table.parties td {
  border: 1px solid var(--ink);
  padding: 0;
  vertical-align: top;
}
table.parties td.lbl {
  width: 80px;
  background: #fafafa;
  font-weight: 600;
  padding: 4px 6px;
  vertical-align: top;
  font-size: 13.5px;
}
table.parties td.field input,
table.parties td.field textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  padding: 4px 6px;
  resize: none;
}
table.parties td.field textarea { min-height: 32px; }
table.parties td.field input:focus,
table.parties td.field textarea:focus { outline: none; background: var(--highlight); }

/* ---------- YTD Paycheck Stub bar (page 1) ---------- */
.ytd-bar {
  margin: 6px 0 14px;
  padding: 10px 14px;
  background: #f8f5e8;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  font-size: 14px;
}
.ytd-bar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  flex: 1 1 360px;
}
.ytd-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.ytd-btn:hover { background: #fff; color: var(--accent); }
.ytd-btn .icon { font-size: 15px; }
.ytd-help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: #fff;
  color: var(--accent);
  font-family: 'Source Serif 4', serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  flex-shrink: 0;
}
.ytd-help-btn:hover {
  background: var(--accent);
  color: #fff;
}
/* ---------- Working Chart (MAA-style assets/debts spreadsheet) ---------- */
/* Landscape orientation for this page on screen + print */
.page-landscape {
  max-width: 1280px;            /* wider on screen for the landscape layout */
  width: 95%;
}
.maa-subtitle {
  background: #fffbe5;
  border: 1px solid #f0d97c;
  padding: 6px 10px;
  font-size: 12.5px;
  text-align: center;
  margin: 4px 0 8px;
}

.wc-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 6px 0 8px;
}
.wc-add-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wc-add-btn:hover { background: #fff; color: var(--accent); }
.wc-add-btn .icon { font-size: 14px; line-height: 1; }
.wc-add-btn.wc-export-btn {
  background: #1d6f42;          /* Excel green */
  border-color: #1d6f42;
}
.wc-add-btn.wc-export-btn:hover {
  background: #fff;
  color: #1d6f42;
}
.wc-hint { font-size: 12px; font-style: italic; color: var(--ink-mute); }

table.wc-grid {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--ink);
  font-size: 12px;
}
table.wc-grid colgroup col.c-num    { width: 32px; }
table.wc-grid colgroup col.c-desc   { width: auto; }
table.wc-grid colgroup col.c-title  { width: 48px; }
table.wc-grid colgroup col.c-value  { width: 69px; }
table.wc-grid colgroup col.c-debt   { width: 69px; }
table.wc-grid colgroup col.c-equity { width: 69px; }
table.wc-grid colgroup col.c-anninc { width: 80px; }
table.wc-grid colgroup col.c-alloc  { width: 64px; }
table.wc-grid colgroup col.c-husband{ width: 69px; }
table.wc-grid colgroup col.c-wife   { width: 69px; }
table.wc-grid colgroup col.c-nm     { width: 69px; }
table.wc-grid colgroup col.c-notes  { width: 200px; }
table.wc-grid colgroup col.c-act    { width: 64px; }

table.wc-grid thead.maa-superhead th {
  background: var(--shade);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 4px;
  border: 1px solid var(--ink);
  text-align: center;
}
table.wc-grid thead.maa-superhead th.maa-mar { background: #f9c8d6; color: #4d1c2c; }
table.wc-grid thead.maa-superhead th.maa-nm  { background: #ffd99c; color: #5a3700; }
table.wc-grid thead th {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 4px 5px;
  border: 1px solid var(--ink);
  background: var(--shade);
  vertical-align: middle;
}
table.wc-grid thead th.maa-h { background: #b6e8e8; }   /* cyan for husband */
table.wc-grid thead th.maa-w { background: #f5cce8; }   /* pink for wife */

table.wc-grid td {
  padding: 0;
  border: 1px solid var(--rule);
  vertical-align: middle;
}
table.wc-grid td.c-num {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--ink-mute);
  padding: 0 4px;
}

table.wc-grid input,
table.wc-grid select,
table.wc-grid textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  padding: 3px 6px;
  box-sizing: border-box;
}
table.wc-grid input:focus,
table.wc-grid select:focus,
table.wc-grid textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--highlight); }
table.wc-grid input.wc-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  text-align: right;
}
table.wc-grid textarea.wc-textarea {
  resize: vertical;          /* user can drag the corner to resize manually */
  overflow: hidden;          /* hide scrollbar; auto-grow JS keeps it visible */
  min-height: 22px;
  line-height: 1.3;
  white-space: pre-wrap;     /* honor newlines and wrap long text */
  word-wrap: break-word;
  vertical-align: top;
  display: block;
}
table.wc-grid td:has(textarea.wc-textarea) {
  vertical-align: top;
  padding: 0;
}
table.wc-grid select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-mute) 50%),
                    linear-gradient(135deg, var(--ink-mute) 50%, transparent 50%);
  background-position: calc(100% - 10px) center, calc(100% - 6px) center;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 16px;
  cursor: pointer;
  text-align: center;
}

table.wc-grid .wc-calc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  text-align: right;
  padding: 3px 8px;
  display: block;
}
table.wc-grid td.cell-husband { background: #e3f3f3; }
table.wc-grid td.cell-wife    { background: #fbe9f2; }
table.wc-grid td.cell-nm      { background: #fff4dd; }
table.wc-grid td.cell-equity  { background: #fafafa; }
table.wc-grid td.cell-anninc  { background: #f4f9f4; }
table.wc-grid td.cell-anninc-na { background: #f4f4f4; text-align: center; }
table.wc-grid td.cell-anninc input.wc-amount { background: transparent; }
table.wc-grid .wc-calc-na { color: var(--ink-mute); font-size: 11px; }
table.wc-grid td.cell-alloc   { background: #fffbe5; text-align: center; padding: 2px 0; }
table.wc-grid td.cell-husband input.wc-amount,
table.wc-grid td.cell-wife    input.wc-amount,
table.wc-grid td.cell-nm      input.wc-amount { background: transparent; }

/* Imbalance indicator — small warning marker beside row number when
   Husband + Wife + Nonmarital does not equal Equity. */
table.wc-grid .wc-imbalance {
  display: inline-block;
  margin-left: 3px;
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
}
table.wc-grid tr.wc-row-imbalanced td.c-num {
  background: #fff2e5;
  font-weight: 700;
  color: var(--warn);
}

/* Allocate radios — compact H/W pair */
table.wc-grid .wc-alloc-radios {
  display: flex;
  justify-content: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
}
table.wc-grid .wc-alloc-radios label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 2px;
  transition: all 0.1s;
  user-select: none;
  -webkit-user-select: none;
}
table.wc-grid .wc-alloc-radios label:hover { background: rgba(0,0,0,0.04); }
table.wc-grid .wc-alloc-radios input[type="radio"] {
  margin: 0;
  cursor: pointer;
  width: auto;
}
table.wc-grid .wc-alloc-radios label:has(input:checked) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

table.wc-grid td.c-act { text-align: center; }
table.wc-grid .wc-row-actions {
  display: flex;
  justify-content: center;
  gap: 3px;
  padding: 1px 0;
}
table.wc-grid .wc-row-btn {
  background: transparent;
  border: 1px solid var(--rule);
  font-family: inherit;
  font-size: 10px;
  padding: 1px 5px;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.12s;
}
table.wc-grid .wc-row-btn:hover { background: var(--shade); border-color: var(--ink); }
table.wc-grid .wc-row-btn.wc-row-del:hover { background: var(--warn); color: #fff; border-color: var(--warn); }

table.wc-grid tr.maa-section-h td {
  background: #2c4869;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border: 1px solid #1a2e44;
}
table.wc-grid tr.maa-section-h .wc-section-add {
  float: right;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
table.wc-grid tr.maa-section-h .wc-section-add:hover { background: rgba(255,255,255,0.32); }

table.wc-grid tbody tr.wc-debt-row { background: #fff8f4; }

table.wc-grid tr.maa-subtotal td {
  background: #e8eef5;
  font-weight: 700;
  font-size: 11.5px;
  padding: 3px 6px;
  border: 1px solid var(--ink);
  border-top: 2px solid var(--ink);
}
table.wc-grid tr.maa-subtotal td.label { text-align: right; text-transform: uppercase; letter-spacing: 0.03em; }
table.wc-grid tr.maa-subtotal td .wc-calc { font-weight: 700; }

.wc-summary {
  margin-top: 12px;
  border: 2px solid var(--ink);
  background: #fff;
}
.wc-summary table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.wc-summary table th {
  background: #2c4869;
  color: #fff;
  text-align: center;
  padding: 4px 8px;
  border: 1px solid var(--ink);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wc-summary table th.maa-h { background: #5b9b9b; }
.wc-summary table th.maa-w { background: #b974a3; }
.wc-summary table td {
  padding: 3px 8px;
  border: 1px solid var(--rule);
  font-size: 11.5px;
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}
.wc-summary table td.label {
  text-align: left;
  font-family: inherit;
  font-weight: 600;
}
.wc-summary table tr.maa-grand td {
  background: var(--shade);
  font-weight: 800;
  font-size: 13px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
.wc-summary .maa-distrib {
  background: #fffbe5;
  padding: 8px 14px;
  border-top: 2px solid var(--ink);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  font-size: 13px;
}
.wc-summary .maa-distrib .lbl { font-weight: 600; }
.wc-summary .maa-distrib .val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  text-align: right;
}

/* Working Chart edit popup */
.modal.wc-edit-modal { max-width: 560px; }
.wc-edit-modal h2 { text-align: center; margin-bottom: 12px; }
.wc-edit-modal .wc-edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.wc-edit-modal .wc-edit-form .field { display: flex; flex-direction: column; gap: 4px; }
.wc-edit-modal .wc-edit-form .field.full { grid-column: 1 / -1; }
.wc-edit-modal .wc-edit-form label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.wc-edit-modal .wc-edit-form input,
.wc-edit-modal .wc-edit-form select,
.wc-edit-modal .wc-edit-form textarea {
  border: 1px solid var(--ink);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  padding: 6px 8px;
}
.wc-edit-modal .wc-edit-form input:focus,
.wc-edit-modal .wc-edit-form select:focus,
.wc-edit-modal .wc-edit-form textarea:focus { outline: none; background: var(--highlight); }
.wc-edit-modal .wc-edit-form textarea {
  min-height: 60px;
  resize: vertical;
}
.wc-edit-modal .wc-edit-form input.amount {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}
.wc-edit-modal .wc-radio-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.wc-edit-modal .wc-radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--ink);
  cursor: pointer;
  font-size: 13px;
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
}
.wc-edit-modal .wc-radio-group input[type="radio"] {
  margin: 0;
  cursor: pointer;
}
.wc-edit-modal .wc-radio-group label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}


/* Compact help popup */
.modal.ytd-help-modal { max-width: 460px; }
.modal.ytd-help-modal h2 { text-align: center; }

/* FICA cap warning — used both inside YTD popup and on page 1 */
.ytd-fica-warn,
.ytd-fica-alert {
  margin: 10px 0;
  padding: 10px 14px;
  background: #ffe8e0;
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  position: relative;
}
.ytd-fica-warn strong,
.ytd-fica-alert strong { color: var(--warn); }
.ytd-alert-dismiss {
  position: absolute;
  right: 6px;
  top: 6px;
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 2px 8px;
}
.ytd-alert-dismiss:hover { color: var(--warn); }
.ytd-stub-notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.ytd-note {
  background: #fffaef;
  border: 1px dashed var(--accent);
  padding: 4px 30px 4px 10px;
  position: relative;
}
.ytd-note .ytd-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 2px 6px;
}
.ytd-note .ytd-clear:hover { color: var(--warn); }

/* YTD modal — wider than mortgage so the two columns of inputs fit comfortably */
.modal.ytd-modal { max-width: 720px; }
.ytd-modal h2 { margin-bottom: 8px; }
.ytd-modal .ytd-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px 16px;
  margin: 12px 0 16px;
  padding: 10px 12px;
  background: var(--shade);
  border: 1px solid var(--ink);
}
.ytd-modal .ytd-meta .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ytd-modal .ytd-meta label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ytd-modal .ytd-meta input,
.ytd-modal .ytd-meta select {
  border: 1px solid var(--ink);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  padding: 6px 8px;
}
.ytd-modal .ytd-meta input:focus,
.ytd-modal .ytd-meta select:focus { outline: none; background: var(--highlight); }
.ytd-modal .ytd-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.ytd-modal .ytd-cols .col h3 {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 6px;
  padding: 4px 8px;
  background: var(--shade);
  border: 1px solid var(--ink);
}
.ytd-modal table.ytd-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ytd-modal table.ytd-tbl td {
  border: 1px solid var(--rule-soft);
  padding: 0;
  vertical-align: middle;
}
.ytd-modal table.ytd-tbl td.lbl {
  padding: 4px 8px;
  background: #fafafa;
}
.ytd-modal table.ytd-tbl td.amount { width: 120px; }
.ytd-modal table.ytd-tbl input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 5px 8px;
  text-align: right;
}
.ytd-modal table.ytd-tbl input:focus { outline: none; background: var(--highlight); }
.ytd-modal table.ytd-tbl tr.total td {
  background: var(--shade);
  font-weight: 700;
  border-top: 2px solid var(--ink);
  padding: 5px 8px;
}
.ytd-modal table.ytd-tbl tr.total td.amount {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}
.ytd-modal table.ytd-tbl tr.eq td {
  background: #fffaef;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 4px 8px;
}
.ytd-modal table.ytd-tbl tr.eq td.amount {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  font-weight: 700;
  color: var(--accent);
}
@media (max-width: 720px) {
  .ytd-modal .ytd-meta { grid-template-columns: 1fr; }
  .ytd-modal .ytd-cols { grid-template-columns: 1fr; }
}

/* ---------- Yes/No question rows ---------- */
.yn-row {
  margin: 8px 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.yn-row label.opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  font-weight: 600;
}
.yn-row input.text-rest {
  flex: 1 1 280px;
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  padding: 2px 4px;
}
.yn-row input.text-rest:focus { outline: none; background: var(--highlight); }

/* ---------- Italic instructions ---------- */
.threshold {
  font-style: italic;
  font-weight: 700;
  margin: 14px 0 4px;
  font-size: 14.5px;
}

/* ---------- Notary block ---------- */
.notary {
  margin-top: 32px;
  font-size: 15px;
}
.notary .sigline {
  border-top: 1px solid var(--ink);
  text-align: center;
  width: 320px;
  margin-left: auto;
  padding-top: 2px;
  font-weight: 700;
}
.notary .sworn { margin-top: 24px; }
.notary input.inline {
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  padding: 1px 4px;
  margin: 0 2px;
}
.notary input.inline:focus { outline: none; background: var(--highlight); }
.notary .nblock {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 4px 12px;
  align-items: baseline;
}
.notary .nblock .seal-line {
  border-top: 1px solid var(--ink);
  padding-top: 2px;
  font-weight: 700;
}
.notary .nblock .lbl-pair {
  display: contents;
}
.notary .nblock .right-pair {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: baseline;
}
.notary .nblock .right-pair label { font-weight: 600; white-space: nowrap; }

/* ---------- Page footer (mimics SCCA 430 footer) ---------- */
.page-foot {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 30px;
  border-top: 1px solid var(--rule-soft);
  padding-top: 4px;
}

/* ---------- Summary banner (web-only addition) ---------- */
.summary-banner {
  position: sticky;
  bottom: 0;
  background: #fffbe8;
  border-top: 2px solid var(--ink);
  padding: 10px 18px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  font-size: 14.5px;
  z-index: 40;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.summary-banner .stat {
  text-align: center;
  border-right: 1px solid var(--rule-soft);
  padding: 0 4px;
}
.summary-banner .stat:last-child { border-right: none; }
.summary-banner .stat .lbl {
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 2px;
}
.summary-banner .stat .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}
.summary-banner .stat .val.warn { color: var(--warn); }
.summary-banner .stat .val.good { color: var(--good); }

/* ---------- Threshold notice (assets > $300k) ---------- */
.threshold-notice {
  margin: 6px 0 14px;
  padding: 8px 12px;
  font-size: 14.5px;
  background: #fff4e0;
  border: 1px solid #c79a4d;
  border-left: 4px solid #c79a4d;
}
.threshold-notice.over {
  background: #ffe9e0;
  border-color: var(--warn);
  border-left-color: var(--warn);
}
.itemization,
.itemization-cont {
  display: block;
}
.itemization.show,
.itemization-cont.show { display: block; }

/* ---------- Modal (sub-forms) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  max-width: 880px;
  width: 100%;
  padding: 24px 32px 24px;
  position: relative;
  font-size: 15px;
}
.modal h2 {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 4px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
  text-align: center;
}
.modal .modal-sub {
  font-size: 13.5px;
  color: var(--ink-mute);
  font-style: italic;
  margin: 6px 0 14px;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
}
.modal-actions button {
  font-family: inherit;
  font-size: 14.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid var(--ink);
  background: #fff;
  cursor: pointer;
}
.modal-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-actions button:hover { background: #000; color: #fff; }
.modal-actions button.primary:hover { background: #fff; color: var(--accent); }

/* Mortgage modal — narrow stacked layout */
.modal.mort-modal { max-width: 260px; padding: 22px 26px 20px; }
.mort-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mort-grid .field { display: flex; flex-direction: column; gap: 3px; }
.mort-grid label {
  font-size: 13.5px;
  font-weight: 600;
}
.mort-grid input {
  border: 1px solid var(--ink);
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  padding: 6px 10px;
  text-align: right;
}
.mort-grid input:focus { outline: none; background: var(--highlight); }
.mort-grid .mort-calc-btn {
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
}
.mort-grid .mort-calc-btn:hover { background: #fff; color: var(--accent); }
.mort-result {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--shade);
  border: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.mort-result .lbl { font-weight: 700; font-size: 14.5px; letter-spacing: 0.04em; }
.mort-result .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28.5px;
  font-weight: 700;
}
/* In the narrow modal, stack action buttons vertically and full-width */
.modal.mort-modal .modal-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.modal.mort-modal .modal-actions button {
  width: 100%;
  padding: 8px 10px;
}

/* Food modal */
.food-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}
.food-cols .col h3 {
  font-size: 15.5px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink);
}
.food-cols .row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 4px;
  margin-bottom: 3px;
}
.food-cols input {
  border: none;
  border-bottom: 1px dotted var(--rule-soft);
  background: transparent;
  font-size: 14.5px;
  padding: 2px 2px;
}
.food-cols input.amount {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  border: 1px solid var(--rule-soft);
  padding: 2px 6px;
}
.food-cols input:focus { outline: none; background: var(--highlight); }
.food-cols .col-total {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 4px;
  margin-top: 8px;
  padding-top: 4px;
  border-top: 2px solid var(--ink);
  font-weight: 700;
  font-size: 14.5px;
  align-items: baseline;
}
.food-cols .col-total .v {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}
.food-equiv {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 8px 0;
  margin-top: 4px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 13.5px;
  color: var(--ink-mute);
}
.food-equiv .item { display: flex; justify-content: space-between; }
.food-equiv .item .v {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--ink);
}
.food-grand {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}
.food-grand .v { font-family: 'JetBrains Mono', monospace; font-size: 18px; }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .toolbar, .summary-banner, .modal-backdrop, .linkable::after { display: none !important; }
  /* Hide the YTD button & helper text on print, but keep the "figures from..." source notes */
  .ytd-btn, .ytd-help-btn, .ytd-clear, .ytd-alert-dismiss { display: none !important; }
  .ytd-bar {
    background: #fff;
    border: none;
    border-left: 2px solid #000;
    padding: 4px 10px;
    margin-bottom: 8px;
  }
  /* If neither party has a YTD note nor a FICA alert, hide the bar entirely on print */
  .ytd-bar:not(:has(.ytd-note:not([style*="display: none"]))):not(:has(.ytd-fica-alert:not([style*="display: none"]))) { display: none; }
  .ytd-note {
    background: #fff;
    border: 1px solid #000;
    padding: 4px 8px;
  }
  .ytd-fica-alert {
    background: #fff;
    border: 1.5px solid #000;
    padding: 6px 10px;
    color: #000;
  }
  .ytd-fica-alert strong { color: #000; }
  .page {
    box-shadow: none;
    margin: 0 auto;
    padding: 28px 36px;
    width: 100%;
    page-break-after: always;
  }
  .page:last-of-type { page-break-after: auto; }
  table.fd, table.parties { font-size: 12px; }
  .linkable { color: var(--ink); text-decoration: none; }
  input { color: var(--ink); }
  input:focus { background: transparent !important; }

  /* ---------- Page 1 compression: keep all sections on one printed page ---------- */
  /* Tighter page margins on page 1 only */
  #page-1 { padding: 18px 32px 8px; }

  /* Caption block — tighter spacing */
  #page-1 .sc-header { margin-bottom: 8px; }
  #page-1 .sc-header .seal { width: 28px; height: 28px; font-size: 13px; }
  #page-1 .sc-header .titles .top { font-size: 11px; }
  #page-1 .sc-header .titles .bottom { font-size: 14px; }
  #page-1 .caption-block { margin-bottom: 8px; gap: 2px 14px; font-size: 12px; }
  #page-1 .caption-block .left, #page-1 .caption-block .right { gap: 2px; }

  /* Parties identification table — much tighter rows.
     Target: ~18px per row instead of ~32px. */
  #page-1 table.parties { margin-bottom: 6px; font-size: 11.5px; }
  #page-1 table.parties th { padding: 2px 4px; font-size: 11.5px; }
  #page-1 table.parties td { padding: 0; }
  #page-1 table.parties td.lbl { padding: 1px 5px; font-size: 11px; }
  #page-1 table.parties td.field input,
  #page-1 table.parties td.field textarea {
    padding: 1px 5px;
    font-size: 11.5px;
    min-height: 0;
    line-height: 1.2;
  }
  /* Address & Employer Address — collapse to single-line height */
  #page-1 table.parties td.field textarea {
    min-height: 14px;
    height: 16px;
    overflow: hidden;
    white-space: nowrap;
  }

  /* Income & Deductions tables — compact rows */
  #page-1 table.fd th { padding: 2px 5px; font-size: 11.5px; }
  #page-1 table.fd td { padding: 1px 5px; }
  #page-1 table.fd td.amount { padding: 0; }
  #page-1 table.fd td.amount input { padding: 1px 6px; font-size: 11px; line-height: 1.2; }
  #page-1 table.fd td.label { font-size: 11.5px; line-height: 1.25; }
  #page-1 table.fd tr.total td { padding: 2px 5px; font-size: 11.5px; }

  /* YTD bar — minimal footprint when source notes are visible */
  #page-1 .ytd-bar { margin: 4px 0; padding: 2px 8px; }
  #page-1 .ytd-note { padding: 2px 8px; font-size: 11px; }
  #page-1 .ytd-fica-alert { padding: 3px 8px; font-size: 11px; line-height: 1.35; }

  /* Smaller endnote superscripts on print */
  #page-1 sup.en { font-size: 8px; }

  /* Page footer — minimal */
  #page-1 .page-foot { margin-top: 4px; padding-top: 2px; font-size: 10px; }

  /* ---------- Page 2 compression: keep all expenses + installments on one printed page ---------- */
  #page-2 { padding: 18px 32px 8px; }

  /* Custodial-parent note — tighter */
  #page-2 .note { margin: 4px 0 6px; font-size: 11.5px; line-height: 1.3; }

  /* Expense tables (top + bottom) and installment table — compact rows */
  #page-2 table.fd { margin-bottom: 6px; }
  #page-2 table.fd th { padding: 2px 5px; font-size: 11px; }
  #page-2 table.fd td { padding: 1px 5px; font-size: 11px; line-height: 1.2; }
  #page-2 table.fd td.amount { padding: 0; }
  #page-2 table.fd td.amount input { padding: 1px 5px; font-size: 10.5px; line-height: 1.2; }
  #page-2 table.fd td input,
  #page-2 table.fd td textarea {
    padding: 1px 5px;
    font-size: 10.5px;
    min-height: 0;
    line-height: 1.2;
  }
  #page-2 table.fd tr.subtotal td,
  #page-2 table.fd tr.total td { padding: 2px 5px; font-size: 11px; }

  /* Linkable expense rows — keep readable but no underline arrow on print */
  #page-2 .linkable { color: #000; text-decoration: none; }
  #page-2 sup.en { font-size: 8px; }

  /* Installment Loan section header — tighter */
  #page-2 .section-h {
    margin: 4px 0 2px;
    padding: 2px 0;
    font-size: 12px;
    font-weight: 700;
  }

  /* Page footer */
  #page-2 .page-foot { margin-top: 4px; padding-top: 2px; font-size: 10px; }

  /* ---------- Page 2b — Working Chart prints LANDSCAPE on its own page #3 ---------- */
  /* The @page rule with the page-2b page-break sets letter landscape */
  @page page-2b-landscape { size: letter landscape; margin: 0.4in 0.4in; }
  #page-2b { page: page-2b-landscape; page-break-after: always; padding: 18px 24px 8px; max-width: none; width: 100%; }
  #page-2b .page-foot { margin-top: 4px; padding-top: 2px; font-size: 10px; }
  #page-2b .section-h { margin: 4px 0 4px; font-size: 14px; }
  #page-2b .maa-subtitle { margin: 4px 0 6px; font-size: 10.5px; padding: 4px 8px; }
  /* Hide the toolbar & per-row buttons on print */
  #page-2b .wc-toolbar, #page-2b .wc-row-actions, #page-2b .wc-section-add { display: none !important; }
  #page-2b table.wc-grid .c-act { display: none; }
  /* Compact rows on print */
  #page-2b table.wc-grid { font-size: 10px; }
  #page-2b table.wc-grid thead th { padding: 2px 3px; font-size: 9.5px; }
  #page-2b table.wc-grid td { padding: 0; font-size: 10px; line-height: 1.2; }
  #page-2b table.wc-grid input,
  #page-2b table.wc-grid select { padding: 1px 3px; font-size: 10px; }
  #page-2b table.wc-grid input.wc-amount { font-size: 9.5px; }
  #page-2b table.wc-grid select { background-image: none; padding-right: 3px; appearance: none; }
  #page-2b table.wc-grid .wc-calc { font-size: 9.5px; padding: 1px 4px; }
  #page-2b table.wc-grid tr.maa-section-h td { padding: 2px 6px; font-size: 10px; }
  #page-2b table.wc-grid tr.maa-subtotal td { padding: 1px 4px; font-size: 10px; }

  /* Summary block also tighter */
  #page-2b .wc-summary table { font-size: 10px; }
  #page-2b .wc-summary table th { padding: 2px 6px; font-size: 9.5px; }
  #page-2b .wc-summary table td { padding: 1px 6px; font-size: 9.5px; }
  #page-2b .wc-summary .maa-distrib { padding: 4px 8px; font-size: 10px; }

  /* ---------- Pages 3 & 4 collapse into a single printed page #3 ----------
     Logical pages 3 and 4 flow together. The MAA Working Chart (page-2b)
     prints AFTER page 4 as printed page #4 (landscape). Endnotes (page 5)
     print as printed page #5. */
  #page-3 { page-break-after: avoid !important; padding: 18px 32px 4px; }
  #page-4 { padding: 4px 32px 8px; page-break-after: always; }
  #page-5 { padding: 18px 32px 8px; page-break-after: auto; page-break-before: always; }

  /* Hide page 3's footer; only keep page 4's footer on the merged page,
     and page 5 keeps its own footer. */
  #page-3 .page-foot { display: none !important; }
  #page-4 .page-foot { margin-top: 4px; padding-top: 2px; font-size: 10px; }
  #page-5 .page-foot { margin-top: 4px; padding-top: 2px; font-size: 10px; }

  /* Section headers on pages 3, 4 — tighter */
  #page-3 .section-h, #page-4 .section-h {
    margin: 4px 0 2px;
    padding: 1px 0;
    font-size: 11.5px;
    font-weight: 700;
  }

  /* All tables on pages 3 & 4 — very compact rows */
  #page-3 table.fd, #page-4 table.fd { margin-bottom: 4px; }
  #page-3 table.fd th, #page-4 table.fd th { padding: 2px 5px; font-size: 10.5px; line-height: 1.2; }
  #page-3 table.fd td, #page-4 table.fd td { padding: 1px 5px; font-size: 10.5px; line-height: 1.2; }
  #page-3 table.fd td.amount, #page-4 table.fd td.amount { padding: 0; }
  #page-3 table.fd td input, #page-4 table.fd td input,
  #page-3 table.fd td textarea, #page-4 table.fd td textarea {
    padding: 1px 4px;
    font-size: 10px;
    min-height: 0;
    line-height: 1.2;
  }
  #page-3 table.fd tr.total td, #page-4 table.fd tr.total td { padding: 2px 5px; font-size: 10.5px; }

  /* Yes/No question rows on page 3 — tighter */
  #page-3 .yn-row { margin: 2px 0; font-size: 11px; gap: 6px; }
  #page-3 .yn-row label.opt { font-size: 11px; }
  #page-3 .yn-row input.text-rest { font-size: 11px; padding: 1px 4px; }

  /* Threshold notice — slim */
  #page-3 .threshold-notice {
    margin: 4px 0;
    padding: 4px 8px;
    font-size: 10.5px;
    line-height: 1.3;
  }

  /* Notary block on page 4 — compress vertical spacing */
  #page-4 .notary { margin-top: 8px; font-size: 11px; }
  #page-4 .notary > div[style*="height:48px"] { height: 18px !important; }
  #page-4 .notary .sigline { padding-top: 1px; font-size: 11px; }
  #page-4 .notary .sworn { margin-top: 8px; font-size: 11px; }
  #page-4 .notary input.inline { font-size: 11px; padding: 0 3px; }
  #page-4 .notary .nblock { margin-top: 8px; gap: 2px 10px; font-size: 11px; }
  #page-4 .notary .nblock .seal-line { padding-top: 1px; font-size: 11px; }
  #page-4 .notary .nblock .right-pair { gap: 2px 6px; }
  #page-4 .notary .nblock .right-pair input { padding: 0 3px; font-size: 11px; }
  #page-4 .notary > div:last-child { margin-top: 6px !important; font-size: 11px; }
  #page-4 .notary > div:last-child input { font-size: 11px; padding: 0 3px; }

  /* Endnotes on page 5 — keep readable, single column on its own printed page */
  #page-5 .section-h { margin-top: 4px; }
  #page-5 ol {
    font-size: 13px !important;
    line-height: 1.45 !important;
    padding-left: 22px !important;
    margin: 4px 0;
  }
  #page-5 ol li { margin-bottom: 3px; }

  /* Endnote superscripts on these pages */
  #page-3 sup.en, #page-4 sup.en { font-size: 7.5px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .page { padding: 30px 22px 50px; }
  .summary-banner { grid-template-columns: repeat(3, 1fr); }
  .food-cols { grid-template-columns: 1fr; }
  .mort-grid { grid-template-columns: 1fr; }
}
