/* ===== Statement of Means Calculator ===== */
:root {
  --bg: #f5f4f1;          /* off-white */
  --surface: #ffffff;
  --ink: #23262b;         /* dark readable text */
  --ink-soft: #565c66;
  --accent: #2f6f6b;      /* calm teal */
  --accent-dark: #245652;
  --accent-soft: #e5efee;
  --line: #dcdad5;
  --err: #b23b3b;
  --err-soft: #f6e3e3;
  --good: #2f6f6b;
  --warn: #9a6b1e;
  --warn-soft: #f6eddb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; border-radius: 6px; }

/* Header / footer */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; }
.mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 20px;
}
.site-title { font-weight: 700; letter-spacing: .2px; }

.site-footer {
  margin-top: 48px; padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 14px;
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--accent-dark); }

/* Screens */
.screen { display: none; padding: 28px 0 8px; }
.screen.is-active { display: block; }
main { padding-top: 8px; }

h1 { font-size: 28px; line-height: 1.2; margin: 12px 0 8px; }
.lede { font-size: 19px; color: var(--ink); margin: 0 0 20px; }

.step-title { font-size: 23px; margin: 8px 0 4px; }
.step-num {
  display: block; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--accent-dark); margin-bottom: 4px;
}
.step-help { color: var(--ink-soft); margin: 0 0 20px; }
.opt { font-weight: 400; color: var(--ink-soft); font-size: .82em; }

/* Privacy note */
.privacy-note {
  background: var(--accent-soft); border: 1px solid #cfe1df;
  border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px;
  font-size: 16px;
}

/* Disclaimer panel */
.disclaimer-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin: 0 0 24px; overflow: hidden;
}
.disclaimer-panel summary {
  cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none;
}
.disclaimer-panel summary::-webkit-details-marker { display: none; }
.disclaimer-panel summary::before { content: "▸ "; color: var(--accent); }
.disclaimer-panel[open] summary::before { content: "▾ "; }
.disclaimer-body { padding: 0 18px 8px; font-size: 15px; color: var(--ink-soft); }
.disclaimer-body h4 { color: var(--ink); margin: 16px 0 4px; font-size: 15px; }
.disclaimer-body p { margin: 0 0 10px; }
.disclaimer-body a { color: var(--accent-dark); }

/* Progress */
.progress { margin: 8px 0 4px; }
.progress-steps {
  display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none;
  margin: 0 0 10px; padding: 0; font-size: 13px; color: var(--ink-soft);
}
.progress-steps li { position: relative; }
.progress-steps li.done { color: var(--accent-dark); }
.progress-steps li.current { color: var(--ink); font-weight: 700; }
.progress-bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

/* Fields */
.field { margin: 0 0 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--err); }
.hint { font-size: 14px; color: var(--ink-soft); margin: 6px 0 0; }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"], textarea {
  width: 100%; font-family: inherit; font-size: 17px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 8px; padding: 13px 14px;
}
textarea { resize: vertical; }
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.invalid, textarea.invalid { border-color: var(--err); background: var(--err-soft); }

.money .money-input { position: relative; display: flex; align-items: stretch; }
.money-input span {
  display: flex; align-items: center; padding: 0 12px 0 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-right: 0;
  border-radius: 8px 0 0 8px; color: var(--ink-soft); font-weight: 600;
}
.money-input input { border-radius: 0 8px 8px 0; }
.money-input input:focus + span { }

/* Per-person income groups */
.group-head {
  font-size: 15px; font-weight: 700; color: var(--accent-dark);
  margin: 4px 0 12px; padding-bottom: 6px; border-bottom: 1.5px solid var(--accent-soft);
}
.income-group + .income-group { margin-top: 22px; }

/* Single / couple choice */
.choice-field { border: 0; margin: 0 0 18px; padding: 0; }
.field-legend { display: block; font-weight: 600; margin-bottom: 8px; padding: 0; }
.choice { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-opt {
  display: flex; align-items: center; gap: 8px; flex: 1 1 160px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 12px 14px;
  background: var(--surface); cursor: pointer; font-weight: 600;
}
.choice-opt input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent); }
.choice-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-opt:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }

.checkbox { display: flex; align-items: flex-start; gap: 10px; }
.checkbox input { width: 20px; height: 20px; margin-top: 3px; flex: 0 0 auto; }
.checkbox label { font-weight: 400; margin: 0; }

.error { color: var(--err); font-size: 14px; margin: 6px 0 0; min-height: 0; }
.error:empty { display: none; }

/* Running totals */
.running-total {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 12px 16px; margin: 4px 0 0; font-size: 16px;
}
.running-total strong { font-size: 19px; color: var(--accent-dark); }

/* Buttons */
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.btn {
  font-family: inherit; font-size: 17px; font-weight: 600;
  border-radius: 8px; padding: 14px 22px; border: 1.5px solid transparent;
  cursor: pointer; min-height: 52px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--accent-dark); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Results */
.result-grid { display: grid; gap: 14px; margin: 8px 0 22px; }
.result-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.result-label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 4px; }
.result-value { display: block; font-size: 26px; font-weight: 700; }
.person-breakdown { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
.person-breakdown li { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--ink-soft); margin: 0 0 4px; }
.person-breakdown li:last-child { margin-bottom: 0; }
.person-breakdown li span:last-child { font-weight: 600; color: var(--ink); }
.result-card.headroom { border-width: 2px; border-color: var(--accent); }
.result-card.headroom .result-value { font-size: 32px; }
.result-card.neg { border-color: var(--err); }
.result-card.neg .result-value { color: var(--err); }
.result-card.pos .result-value { color: var(--good); }

/* Risk box */
.risk-box {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 5px solid var(--accent); border-radius: var(--radius);
  padding: 18px 20px; margin: 0 0 18px;
}
.risk-box.alert { border-left-color: var(--err); }
.risk-box.caution { border-left-color: var(--warn); }
.risk-box h3 { margin: 0 0 10px; font-size: 18px; }
.risk-box ul { margin: 0; padding-left: 20px; }
.risk-box li { margin: 0 0 8px; }
.risk-box li:last-child { margin-bottom: 0; }

/* Debt-help signposting (shown only when outgoings exceed income) */
.support-box {
  background: var(--accent-soft); border: 1px solid #cfe1df;
  border-left: 5px solid var(--accent); border-radius: var(--radius);
  padding: 18px 20px; margin: 0 0 18px;
}
.support-box h3 { margin: 0 0 8px; font-size: 18px; color: var(--accent-dark); }
.support-box p { margin: 0 0 12px; }
.support-box ul { margin: 0 0 12px; padding-left: 20px; }
.support-box li { margin: 0 0 7px; }
.support-box li:last-child { margin-bottom: 0; }
.support-box a { color: var(--accent-dark); font-weight: 600; }
.support-foot { font-size: 13px; color: var(--ink-soft); margin: 0 !important; }

.snapshot-note { font-size: 14px; color: var(--ink-soft); margin: 4px 0 0; }

/* Output cards */
.output-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 0 0 18px; box-shadow: var(--shadow);
}
.output-card h3 { margin: 0 0 6px; font-size: 19px; }
.output-card p { margin: 0 0 16px; color: var(--ink-soft); font-size: 15px; }

.send-status { margin: 14px 0 0; font-size: 15px; min-height: 0; }
.send-status.ok { color: var(--good); font-weight: 600; }
.send-status.err { color: var(--err); font-weight: 600; }
.send-status.busy { color: var(--ink-soft); }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .actions { flex-direction: column-reverse; }
  .actions .btn { width: 100%; }
  h1 { font-size: 24px; }
  .result-card.headroom .result-value { font-size: 28px; }
}
