/* NPS Home Loan calculator — visual system
   Two tracks run this loan: principal first, then accumulated interest.
   Navy chrome, white cards, and one accent colour per track.

   Chrome palette (navy / primary blue / bg), type and card geometry are
   kept in step with the RKY Finance home page (site-wide style.css) so the
   move from the home page into this calculator reads as one product. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Poppins:wght@500;600;700;800&display=swap');

:root {
  --bg: #f5f8fc;
  --card: #ffffff;
  --line: #e3e8ef;
  --line-soft: #edf1f6;

  --navy: #0b2551;
  --navy-deep: #08203f;
  --navy-50: #eef3fb;

  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #6e7c91;

  --principal: #1a63cf;
  --principal-soft: #eaf1fb;
  --principal-line: #cfe0f5;
  --interest: #a2590f;
  --interest-soft: #fdf4e7;
  --interest-line: #f0dcbd;
  --ok: #067647;
  --ok-soft: #e9f6ef;
  --alert: #b42318;
  --alert-soft: #fdeceb;
  --note-soft: #fff8ec;

  --r: 20px;
  --r-sm: 14px;
  --r-xs: 10px;
  --pad: 16px;
  --shadow: 0 1px 3px rgba(16, 40, 80, .04), 0 10px 26px rgba(16, 40, 80, .05);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: 'Poppins', 'Inter', "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  overflow-wrap: break-word;
}

.wrap {
  width: 100%; max-width: 1060px; margin: 0 auto;
  padding-left: calc(14px + env(safe-area-inset-left));
  padding-right: calc(14px + env(safe-area-inset-right));
}

/* ---------- top bar — light, to match the RKY Finance home page header ---------- */
.masthead {
  background: #fff; color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
  margin-bottom: 4px;
}
.masthead .wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-id { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1 1 220px; }
.topbar-text { display: flex; flex-direction: column; min-width: 0; }

/* RKY Finance wordmark — carries the site identity in from the home page
   and is the button back to it. The arrow + pill hover make it read as a
   "back to the site" control, not just a label. */
.brand {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--head);
  font-size: 18px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
  color: var(--navy); text-decoration: none;
  margin-left: -10px; padding: 4px 10px; border-radius: 999px;
  transition: background .15s, color .15s;
}
.brand-chev { font-size: 15px; opacity: .65; }
.brand:hover { color: var(--principal); background: var(--navy-50); }
.brand:hover .brand-chev { opacity: 1; }
.brand:focus-visible { outline: 2px solid var(--principal); outline-offset: 2px; }

/* the calculator's own name, now a subtitle under the wordmark */
.masthead h1 {
  margin: 2px 0 0; font-family: var(--sans);
  font-size: 12.5px; font-weight: 500; letter-spacing: .01em; line-height: 1.3;
  color: var(--ink-3);
}
.masthead h1 em { font-style: normal; font-weight: inherit; color: inherit; }
.masthead .tools { display: flex; gap: 8px; flex: 0 0 auto; }

/* where the figures are being kept */
.save-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  background: var(--navy-50); border: 1px solid var(--principal-line);
  color: var(--ink-2); border-radius: 999px; padding: 6px 12px;
  min-height: 34px; font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
/* grey = this device only. green is reserved for a cloud copy. */
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: #9fb0c4; flex: none; }
.save-pill[data-save="saving"] { color: #8a6116; }
.save-pill[data-save="saving"] .save-dot { background: #d9a441; }
.save-pill[data-save="cloud"] { color: var(--ok); }
.save-pill[data-save="cloud"] .save-dot { background: #45c286; }
.save-pill[data-save="off"] { color: var(--alert); }
.save-pill[data-save="off"] .save-dot { background: #e0776c; }
.save-pill[data-save="failed"], .save-pill[data-save="conflict"], .save-pill[data-save="signin"] { color: var(--alert); }
.save-pill[data-save="failed"] .save-dot,
.save-pill[data-save="conflict"] .save-dot,
.save-pill[data-save="signin"] .save-dot { background: #e0776c; }

.save-note {
  margin: 12px 0 0; padding: 12px 13px; border-radius: var(--r-sm);
  background: var(--navy-50); border: 1px solid var(--principal-line);
  font-size: 12.5px; line-height: 1.5; color: var(--ink-2);
  display: flex; flex-direction: column; gap: 8px;
}
.save-note[hidden] { display: none; }
.save-note-who { font-size: 11.5px; color: var(--ink-3); }
.save-note-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.btn-danger { color: var(--alert); border-color: #f0cfcc; background: var(--alert-soft); }

/* ---------- sticky summary, shown once the hero scrolls out of view ---------- */
.sticky-summary {
  /* fixed, not sticky: it must sit fully outside the document flow, so
     showing/hiding it never shifts the layout underneath — including the
     hero section that decides its own visibility, which otherwise causes
     a shift → re-trigger → flicker loop. */
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255, 255, 255, .94); color: var(--ink);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(16, 40, 80, .1);
}
.sticky-summary[hidden] { display: none; }
.sticky-summary-inner {
  display: flex; gap: 14px; padding: 9px 0;
}
.sticky-item { display: flex; flex-direction: column; gap: 0; min-width: 0; flex: 1 1 0; }
.sticky-label {
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sticky-value {
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em; overflow-wrap: anywhere;
}

/* ---------- section rules ---------- */
.section-rule {
  display: flex; align-items: center; gap: 12px;
  margin: 26px 2px 2px; color: var(--ink-3);
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
}
.section-rule::before, .section-rule::after { content: ""; height: 1px; background: var(--line); flex: 1 1 auto; }
.section-rule::before { flex: 0 0 14px; }

/* ---------- generic chrome ---------- */
.eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--principal);
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); margin-top: 12px; overflow: hidden;
}
.card > summary, .card-head {
  list-style: none; padding: 15px var(--pad); display: flex; align-items: center;
  gap: 11px; cursor: pointer; background: var(--card);
  border-bottom: 1px solid transparent;
}
.card[open] > summary { border-bottom-color: var(--line); }
.card > summary::-webkit-details-marker { display: none; }
.card h2 {
  margin: 0; font-family: var(--head); font-size: 15.5px; font-weight: 700;
  letter-spacing: -.015em; flex: 1 1 auto; min-width: 0;
}
.card .hint { font-size: 12px; color: var(--ink-3); font-weight: 500; flex: 0 0 auto; }
.step-warn {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--alert); background: var(--alert-soft); border: 1px solid #f0cfcc;
  border-radius: 999px; padding: 4px 9px;
}
.step-warn[hidden] { display: none; }
.chev {
  width: 9px; height: 9px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg); transition: transform .18s ease; flex: none; margin-right: 3px;
}
.card[open] > summary .chev { transform: rotate(-135deg); }
.card-body { padding: var(--pad); }

.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--principal-soft); color: var(--principal);
  font-size: 11.5px; font-weight: 700; flex: none;
}

/* ---------- form controls ---------- */
.grid { display: grid; gap: 14px 16px; grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.field .note { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }

input, select {
  font: inherit; font-size: 16px;          /* 16px stops iOS Safari zooming on focus */
  color: var(--ink); background: #fff;
  border: 1px solid #d8e0ea; border-radius: var(--r-sm);
  padding: 11px 12px; width: 100%; min-width: 0; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
input[type=date] { -webkit-appearance: none; }
input::placeholder { color: #9aa6b8; }
input:focus, select:focus, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--principal); outline-offset: 1px; border-color: var(--principal);
}
.num { font-variant-numeric: tabular-nums; }

/* ---------- invalid / missing required fields ---------- */
input.is-invalid {
  border-color: var(--alert); background: var(--alert-soft);
}
input.is-invalid:focus { outline-color: var(--alert); }

/* ---------- inline applied / not-applied note under a modified EMI field ---------- */
.applied-note { font-size: 11.5px; font-weight: 650; margin-top: -2px; }
.applied-note.is-applied { color: var(--ok); }
.applied-note.is-notapplied { color: var(--ink-3); font-weight: 500; }

button {
  font: inherit; font-size: 13.5px; font-weight: 650;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  padding: 9px 14px; min-height: 42px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
button:active { transform: translateY(1px); }
.btn-primary { background: var(--principal); border-color: var(--principal); color: #fff; }
.btn-ghost-dark {
  background: #fff; border-color: var(--line); color: var(--ink-2);
  min-height: 38px; padding: 7px 12px; font-size: 12.5px;
}
.btn-ghost-dark:hover { border-color: var(--principal-line); color: var(--navy); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 12.5px; }

/* ---------- the hero result panel — the headline answer, kept light but
   tinted blue so it still reads as the primary card above the stat tiles ---------- */
.hero {
  margin-top: 12px;
  background: linear-gradient(180deg, #dbe8f8, #c1d6f0);
  color: var(--ink);
  border: 1px solid #acc8e6;
  border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.hero-main { display: flex; flex-direction: column; }
.hero-label { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.hero-split {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px;
}
.hero-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hero-value {
  font-size: 20px; font-weight: 700; letter-spacing: -.015em;
  color: var(--navy); font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.hero-value.is-warn { color: var(--interest); }
.hero-item-note { font-size: 10.5px; color: var(--ink-3); }
.hero-item-note.is-warn { color: var(--interest); font-weight: 650; }

/* ---------- stat tiles ---------- */
.stat-grid { display: grid; gap: 10px; margin-top: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 13px; display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.stat-label { font-size: 11px; color: var(--ink-3); font-weight: 650; }
.stat-value {
  font-size: 16px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat-note { font-size: 11px; color: var(--ink-3); }
.stat.is-principal { border-color: var(--principal-line); background: linear-gradient(#fff, var(--principal-soft)); }
.stat.is-principal .stat-value { color: var(--principal); }
.stat.is-interest { border-color: var(--interest-line); background: linear-gradient(#fff, var(--interest-soft)); }
.stat.is-interest .stat-value { color: var(--interest); }
/* past an instalment ceiling — needs the interest EMI raised */
.stat.is-over { border-color: #f0cfcc; background: linear-gradient(#fff, var(--alert-soft)); }
.stat.is-over .stat-value, .stat.is-over .stat-note { color: var(--alert); }
.stat.is-over .stat-note { font-weight: 650; }

/* ---------- inline advice under a field ---------- */
.inline-warn {
  margin-top: 6px; font-size: 12px; line-height: 1.5;
  background: var(--note-soft); border: 1px solid #f0d9a8; border-left: 3px solid #d9a441;
  color: #74501a; border-radius: var(--r-sm); padding: 10px 11px;
}
.inline-warn b { font-weight: 700; }
.btn-inline { min-height: 32px; padding: 5px 10px; margin-top: 8px; font-size: 12px; }

/* ---------- collapsible facts strip inside a card ---------- */
.facts {
  margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fbfcfe; overflow: hidden;
}
.facts > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center;
  gap: 10px; padding: 11px 12px; min-height: 46px;
}
.facts > summary::-webkit-details-marker { display: none; }
.facts-title { font-size: 12.5px; font-weight: 650; color: var(--ink-2); flex: 0 0 auto; }
.facts-peek {
  flex: 1 1 auto; min-width: 0; text-align: right;
  font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.facts[open] > summary { border-bottom: 1px solid var(--line); }
.facts[open] > summary .chev { transform: rotate(-135deg); }
.facts[open] .facts-peek { visibility: hidden; }
.facts .dl { padding: 2px 12px 8px; }

/* ---------- figures (repayment benefit) ---------- */
.figures { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.figure {
  padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: #fff; min-width: 0;
}
.figure .k { font-size: 11px; font-weight: 650; color: var(--ink-3); }
.figure .v {
  font-size: 19px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin-top: 3px; overflow-wrap: anywhere;
}
.figure .m { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.figure.is-good { background: var(--ok-soft); border-color: #c6e6d5; }
.figure.is-good .v { color: var(--ok); }

/* ---------- the recovery ribbon ---------- */
.ribbon-track {
  display: flex; height: 34px; border-radius: var(--r-xs); overflow: hidden;
  border: 1px solid var(--line); background: #f1f4f9;
}
.ribbon-seg { display: flex; align-items: center; justify-content: center; min-width: 0; }
.ribbon-seg span {
  font-size: 11px; font-weight: 650; color: #fff; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px;
}
.seg-principal { background: var(--principal); }
.seg-interest { background: var(--interest); }
.ribbon-scale { display: flex; justify-content: space-between; margin-top: 7px; gap: 8px; }
.ribbon-scale div { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 0; }
.ribbon-scale div:last-child { text-align: right; }
.ribbon-legend { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; }
.ribbon-legend b { font-weight: 700; color: var(--ink); }
.ribbon-legend > div { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dot.p { background: var(--principal); }
.dot.i { background: var(--interest); }

/* ---------- definition rows ---------- */
.dl { display: flex; flex-direction: column; }
.dl > div {
  display: flex; justify-content: space-between; gap: 10px 18px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.dl > div:last-child { border-bottom: 0; }
.dl dt { font-size: 13px; color: var(--ink-2); margin: 0; flex: 1 1 auto; min-width: 0; }
.dl dd {
  margin: 0; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums;
  text-align: right; flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere;
}
.dl dd.blank { color: var(--ink-3); font-weight: 400; }

/* ---------- messages ---------- */
.msg { border-radius: var(--r-sm); padding: 12px 14px; font-size: 13px; margin-top: 12px; }
.msg ul { margin: 6px 0 0; padding-left: 18px; }
.msg li + li { margin-top: 4px; }
.msg-error { background: var(--alert-soft); color: #7d1f1f; border: 1px solid #f4d3d0; border-left: 3px solid var(--alert); }
.msg-note { background: var(--note-soft); color: #74501a; border: 1px solid #f0d9a8; border-left: 3px solid #d9a441; }

/* "Worth knowing" folds away — it never blocks the result, so it opens on demand */
.msg-fold { padding: 0; }
.msg-fold > summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; align-items: center; gap: 8px;
}
.msg-fold > summary::-webkit-details-marker { display: none; }
.msg-fold > summary::after {
  content: "\25B8"; margin-left: auto; font-size: 12px; opacity: .65;
  transition: transform .15s ease;
}
.msg-fold[open] > summary::after { transform: rotate(90deg); }
.msg-fold-body { padding-top: 2px; }
.msg-fold ul { margin: 0; padding: 0 14px 12px 32px; }
.msg-pill {
  background: rgba(217, 164, 65, .25); border-radius: 999px;
  padding: 1px 7px; font-size: 11px; font-weight: 600;
}
/* The one-click fix, once folded in, drops its own card frame — it reads as
   the first section of "Worth knowing", with a rule between it and the list. */
.msg-fold .fix-needed { margin: 0 14px 10px; padding: 0; background: none; border: 0; }
.msg-fold .fix-needed + ul { border-top: 1px solid #f0d9a8; padding-top: 10px; }

/* ---------- "here's exactly what to do" — the actionable counterpart to
   the plain-text warnings above, when there's a single concrete fix ---------- */
.fix-needed {
  margin-top: 12px; padding: 14px 15px; border-radius: var(--r-sm);
  background: var(--note-soft); border: 1px solid #f0d9a8; border-left: 3px solid #d9a441;
}
.fix-needed-title { margin: 0 0 4px; font-size: 13.5px; font-weight: 700; color: #74501a; }
.fix-needed-body { margin: 0; font-size: 13px; line-height: 1.5; color: #74501a; }
.fix-needed-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; align-items: center; }
.fix-needed-link {
  background: none; border: 0; padding: 4px 2px; min-height: 0;
  font-size: 12.5px; font-weight: 650; color: #8a6116; text-decoration: underline;
}

/* Draws the eye to a field that was just jumped to from elsewhere on the
   page, so the scroll doesn't dump the borrower somewhere unexplained. */
@keyframes field-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
  30% { box-shadow: 0 0 0 4px rgba(37, 99, 235, .28); }
}
.is-highlighted { animation: field-pulse 1.1s ease-out 2; }

/* ---------- tables ---------- */
.table-scroll {
  overflow: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff;
  max-height: 70vh; overscroll-behavior: contain;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { padding: 9px 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
th {
  position: sticky; top: 0; z-index: 3;
  background: #f7f9fc; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-2); text-align: right;
  border-bottom: 1px solid var(--line);
}
th:first-child, td:first-child {
  position: sticky; left: 0; z-index: 2; text-align: left;
  background: #fff; border-right: 1px solid var(--line);
}
th:first-child { z-index: 4; background: #f7f9fc; }
td { font-variant-numeric: tabular-nums; }
tbody tr:hover td, tbody tr:hover td:first-child { background: #f7f9fd; }
tr.is-event td:first-child { box-shadow: inset 3px 0 0 var(--interest); }
tr.is-final td { font-weight: 700; }
td.zero { color: #9aa6b8; }
tbody tr { cursor: pointer; }
tr.is-now td, tr.is-now td:first-child { background: #fff6e4; }
tr.is-now td:first-child { box-shadow: inset 3px 0 0 var(--interest); }
tr.is-picked td, tr.is-picked td:first-child { background: var(--principal-soft); }
tr.is-picked td:first-child { box-shadow: inset 3px 0 0 var(--principal); }
.tbl-note { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; }
.tbl-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 11px; }
.tbl-tools .count { font-size: 11.5px; color: var(--ink-3); }

/* Below 560px, the secondary columns of each schedule table are hidden by
   default — same data, just fewer columns to scroll through on a phone.
   "Show all columns" (a body class) brings them back at any width. */
@media (max-width: 559px) {
  #prin-table:not(.show-cols) th:nth-child(5),
  #prin-table:not(.show-cols) td:nth-child(5),
  #prin-table:not(.show-cols) th:nth-child(6),
  #prin-table:not(.show-cols) td:nth-child(6),
  #prin-table:not(.show-cols) th:nth-child(10),
  #prin-table:not(.show-cols) td:nth-child(10) { display: none; }
  #int-table:not(.show-cols) th:nth-child(5),
  #int-table:not(.show-cols) td:nth-child(5) { display: none; }

  /* Interest recovery panel: several labels here are long enough to fill a
     narrow line, so the value wraps beneath — and a lone wrapped item under
     "space-between" lands hard against the left edge, making some rows read
     left-aligned and some right. Stack every row in this panel instead:
     label above, value below, both left. Other .dl panels are unaffected. */
  #interest-panel > div { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px; }
  #interest-panel dd { text-align: left; }
}

/* ---------- step 2: pill tabs + list editor ---------- */
.step-sub { margin: 0; padding: 0 var(--pad) 2px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.ptabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px var(--pad) 2px; }
.ptab {
  flex: 0 1 auto; font-size: 12.5px; font-weight: 650; color: var(--ink-2);
  background: #eef1f6; border: 1px solid transparent; border-radius: 999px;
  padding: 8px 13px; min-height: 38px; white-space: nowrap;
}
.ptab-on { background: var(--navy); border-color: var(--navy); color: #fff; }
.ptab .pip { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; opacity: .75; }

.list-editor { padding: 14px var(--pad) var(--pad); }
.list-editor .note { display: block; margin: 0 0 12px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.empty {
  margin: 0; padding: 16px; text-align: center; font-size: 13px; color: var(--ink-3);
  background: #f8fafc; border: 1px dashed var(--line); border-radius: var(--r-sm);
}

.entries { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line-soft);
}
.entry:first-child { border-top: 0; padding-top: 2px; }
.entry-editing { background: var(--principal-soft); border-radius: var(--r-xs); padding-left: 8px; padding-right: 8px; }
.entry-no { font-size: 11.5px; color: var(--ink-3); font-weight: 700; }
.entry-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.entry-date { font-size: 12.5px; color: var(--ink-3); }
.entry-val {
  font-size: 15px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.entry-acts { display: flex; gap: 6px; flex: none; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; min-height: 38px; padding: 0;
  background: #eef1f6; border: 0; border-radius: var(--r-xs); color: var(--ink-2);
}
.icon-btn:hover { background: #e2e8f1; }
.icon-del:hover { background: var(--alert-soft); color: var(--alert); }

.entry-form { margin-top: 14px; padding: 13px; border-radius: 14px; background: #f8fafc; border: 1px solid var(--line); }
.entry-form-title {
  margin: 0 0 11px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
}
.entry-form-full { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.entry-form-grid { display: grid; gap: 12px; }
.entry-error { margin: 10px 0 0; font-size: 12.5px; color: var(--alert); font-weight: 650; }
.entry-form-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.input-wrap { position: relative; display: block; }
.input-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--ink-3); pointer-events: none; font-weight: 650;
}
input.has-prefix { padding-left: 32px; }

.list-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 13px; flex-wrap: wrap;
}
.list-total { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.list-foot .cap { font-size: 11.5px; color: var(--ink-3); }

/* ---------- underline tabs ---------- */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line); margin-bottom: 14px; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; border-radius: 0; min-height: 42px; flex: 0 0 auto;
  padding: 8px 12px; white-space: nowrap; color: var(--ink-3); font-weight: 650; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.is-on { color: var(--principal); border-bottom-color: var(--principal); }
.panel { display: none; }
.panel.is-on { display: block; }

/* ---------- before / after comparison ---------- */
.cmp { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.cmp-head, .cmp-row {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px; padding: 10px 12px; align-items: baseline;
}
.cmp-head {
  background: #f7f9fc; font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-2);
}
.cmp-head span:not(:first-child), .cmp-row span:not(:first-child) { text-align: right; }
.cmp-row { border-top: 1px solid var(--line-soft); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cmp-row span { min-width: 0; overflow-wrap: anywhere; }
.cmp-row .was { color: var(--ink-3); }
.cmp-row .now { font-weight: 700; color: var(--ink); }

/* ---------- a tick beside a field ---------- */
.tick {
  display: flex; align-items: flex-start; gap: 8px; cursor: pointer;
  font-size: 12px; line-height: 1.4; color: var(--ink-2); padding: 2px 0;
  min-height: 26px;
}
.tick input[type=checkbox] {
  width: 18px; height: 18px; min-height: 18px; margin: 1px 0 0; padding: 0; flex: none;
  -webkit-appearance: auto; appearance: auto; accent-color: var(--principal); cursor: pointer;
}
.tick input:checked ~ span { color: var(--alert); font-weight: 650; }

/* ---------- floating quick guide, and the confirm dialog ---------- */
.sheet-panel.is-narrow { width: min(480px, calc(100vw - 20px)); }
.eyebrow.is-alert { color: var(--alert); }
.warn-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; margin-right: 6px;
  background: var(--alert); color: #fff; font-size: 13px; font-weight: 700; line-height: 1;
}

.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgba(16, 24, 40, .55); }
.sheet-panel {
  position: relative; z-index: 1; background: var(--card);
  width: min(720px, calc(100vw - 20px)); max-height: min(88vh, 900px);
  border-radius: var(--r); box-shadow: 0 24px 60px -20px rgba(16, 24, 40, .6);
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px var(--pad); border-bottom: 1px solid var(--line); background: var(--card);
}
.sheet-head h2 { margin: 3px 0 0; font-family: var(--head); font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.sheet-head > div { flex: 1 1 auto; min-width: 0; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px var(--pad) var(--pad); overscroll-behavior: contain; }
.g-lede {
  font-size: 13.5px; line-height: 1.55; color: var(--ink-2);
  background: var(--principal-soft); border: 1px solid var(--principal-line);
  border-radius: var(--r-sm); padding: 12px 13px; margin: 12px 0 4px;
}
.g-h {
  margin: 20px 0 8px; font-size: 10px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--principal); padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.g-p { margin: 0 0 10px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.g-note { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.g-dl { margin: 0; }
.g-dl dt { font-size: 12.5px; font-weight: 650; color: var(--ink); padding: 9px 0 0; border-top: 1px solid var(--line-soft); }
.g-dl dt:first-child { border-top: 0; padding-top: 0; }
.g-dl dd { margin: 1px 0 9px; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.g-list { margin: 0; padding-left: 20px; }
.g-list li { font-size: 13px; line-height: 1.55; color: var(--ink-2); margin-bottom: 7px; }
.g-list b { color: var(--ink); font-weight: 650; }


/* =====================================================================
   BREAKPOINTS — mobile is the base above; everything below widens it.
   ===================================================================== */
@media (min-width: 420px) {
  .entry-form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .entry-main { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 14px; }
  .entry-date { flex: 0 0 auto; }
  .entry-val { text-align: right; }
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 18px 20px; }
  .hero-split { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .g-dl { display: grid; grid-template-columns: 190px minmax(0, 1fr); align-items: baseline; }
  .g-dl dt { padding: 10px 14px 10px 0; }
  .g-dl dd { margin: 0; padding: 10px 0; border-top: 1px solid var(--line-soft); }
  .g-dl dt:first-of-type, .g-dl dt:first-of-type + dd { border-top: 0; padding-top: 0; }
}

@media (min-width: 760px) {
  :root { --pad: 22px; }
  .wrap { padding-left: calc(20px + env(safe-area-inset-left)); padding-right: calc(20px + env(safe-area-inset-right)); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .figures { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .brand { font-size: 19px; }
  .masthead h1 { font-size: 13px; }
  table { font-size: 13.5px; }
}

/* Phones: keep the header compact — small save chip, short tool buttons,
   tighter padding — so it doesn't eat a third of the first screen. */
@media (max-width: 559px) {
  .masthead { padding: calc(9px + env(safe-area-inset-top)) 0 9px; }
  .masthead .wrap { gap: 8px 10px; align-items: flex-start; }
  .topbar-id { flex: 1 1 auto; }
  .masthead h1 { font-size: 11.5px; margin-top: 1px; }
  .save-pill { min-height: 28px; padding: 4px 10px; font-size: 10.5px; gap: 6px; }
  .masthead .tools { width: 100%; gap: 6px; }
  .masthead .tools button { flex: 1 1 0; min-height: 32px; padding: 6px 4px; font-size: 12px; }
}

/* Very narrow phones: stop the three-column comparison from crushing. */
@media (max-width: 400px) {
  .cmp-head, .cmp-row { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr); padding: 9px 10px; gap: 6px; font-size: 12px; }
  .cmp-head { font-size: 9.5px; letter-spacing: .04em; }
  th, td { padding: 8px 9px; font-size: 12.5px; }
  .hero-value { font-size: 17px; }
  .masthead .tools { width: 100%; }
  .masthead .tools button { flex: 1 1 0; padding: 7px 6px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- print / save as PDF ---------- */
@media print {
  body { background: #fff; padding: 0; font-size: 11px; }
  .masthead .tools, .sheet, .sticky-summary { display: none !important; }
  .masthead { background: #fff; color: var(--ink); border-bottom: 2px solid var(--ink); padding: 0 0 10px; }
  .masthead .brand { color: var(--ink); }
  .masthead h1, .masthead h1 em { color: var(--ink-3); }
  .hero { background: #fff; color: var(--ink); box-shadow: none; border: 1px solid #ccc; }
  .hero-label { color: var(--ink-3); }
  .hero-item-note { color: var(--ink-3); }
  .hero-split { border-color: #ddd; }
  .hero-value.is-warn { color: var(--interest); }
  .save-pill { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .stat { box-shadow: none; break-inside: avoid; }
  details:not([open]) > summary ~ * { display: none; }
  .table-scroll { max-height: none; overflow: visible; border: 0; }
  th, th:first-child, td:first-child { position: static; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
