/* Plan and Track - look from Lena's style guide (shared/design/webapp). Tokens first; a dark theme only swaps variables. */
:root {
  --bg: #F4FAFA; --surface: #FFFFFF; --text: #1A2B2E; --text-muted: #4A5F63;
  --brand: #1F6F78; --brand-dark: #12474E; --brand-tint: #DDEFEF;
  --border: #748A8D; --divider: #D5E2E3;
  --ok: #1F6B40; --disabled-text: #4A5F63; --warn: #8A5A00; --warn-fill: #FFF1CC; --danger: #B3261E; --danger-fill: #FDE7E5;
  --pro: #3B3F99; --pro-fill: #E8E9F8; --focus: #0B57D0; --on-brand: #FFFFFF;
  --disabled-fill: #C7D2D4; --on-strong: #FFFFFF;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #12191B; --surface: #1B2528; --text: #E8F1F2; --text-muted: #A9BEC1;
  --brand: #5CC1CC; --brand-dark: #8EDCE4; --brand-tint: #24383B; --on-brand: #0B2A2E;
  --border: #6B8286; --divider: #2E3F42; --ok: #6FD08F; --warn: #F2B84B; --warn-fill: #3A2E10;
  --danger: #FF8A80; --danger-fill: #3D1E1C; --focus: #8AB4F8; --pro: #B9BCFF; --pro-fill: #2A2C55;
  --disabled-fill: #334447; --disabled-text: #A9BEC1; --on-strong: #0B2A2E;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/24px var(--font); color: var(--text); background: var(--bg); padding-bottom: 72px; font-variant-numeric: tabular-nums; }
h1 { font-size: 22px; line-height: 32px; font-weight: 700; color: var(--brand-dark); margin: 16px 0 4px; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; color: var(--brand-dark); margin: 0 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--brand); }
.muted, .small { color: var(--text-muted); }
.small { font-size: 14px; line-height: 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* focus: always visible for keyboard */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#import:focus-visible + #importlabel { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }

.skip { position: absolute; left: 8px; top: -60px; background: var(--brand-dark); color: var(--on-strong); padding: 10px 16px; border-radius: 8px; z-index: 30; }
.skip:focus { top: 8px; }

.top { background: var(--surface); border-bottom: 1px solid var(--divider); }
.top-in { max-width: 960px; margin: 0 auto; padding: 0 16px; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { font-size: 18px; font-weight: 700; color: var(--brand-dark); }
.tier { display: flex; gap: 8px; align-items: center; }

main, .foot { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.foot { padding-top: 16px; padding-bottom: 16px; font-size: 14px; line-height: 20px; color: var(--text-muted); }

/* tabs: bottom bar on phone, horizontal tabs under the header on wider screens */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--divider); }
.tabs button { flex: 1 1 0; min-width: 0; min-height: 56px; padding: 6px 2px; font: 600 12px/16px var(--font); color: var(--text-muted); background: transparent; border: 0; border-top: 3px solid transparent; cursor: pointer; }
.tabs button[aria-current="page"] { background: var(--brand-tint); color: var(--text); border-top-color: var(--brand); font-weight: 700; }
.tabs .chip { margin-left: 2px; }

.btn, button { font: 600 16px/24px var(--font); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 8px; border: 2px solid var(--brand); cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.secondary { background: var(--surface); color: var(--brand-dark); }
.btn.secondary:hover { background: var(--brand-tint); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-strong); }
.btn.danger-outline { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn.small-btn { min-height: 44px; padding: 0 12px; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--disabled-fill); border-color: var(--disabled-fill); color: var(--disabled-text); cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.card { background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; padding: 16px; margin: 0 0 16px; }
.chip { display: inline-block; height: 24px; line-height: 24px; padding: 0 8px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.chip.pro { background: var(--pro-fill); color: var(--pro); }
.chip.over { background: var(--danger-fill); color: var(--danger); }
.chip.ok { background: var(--brand-tint); color: var(--text); }
.banner { color: var(--text-muted); font-size: 14px; line-height: 20px; margin-bottom: 16px; }

/* inputs */
.field { display: flex; flex-direction: column; min-width: 0; margin-bottom: 8px; }
.field label { font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: 4px; }
input[type="text"], select { font: 16px/24px var(--font); color: var(--text); background: var(--surface); height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; }
input[type="text"]:focus-visible, select:focus-visible { border: 2px solid var(--brand); padding: 0 11px; }
input.num { text-align: right; }
input[aria-invalid="true"] { border: 2px solid var(--danger); padding: 0 11px; }
.inputbox { position: relative; display: block; }
.prefix { position: absolute; left: 12px; top: 10px; color: var(--text-muted); pointer-events: none; }
.inputbox .num { padding-left: 28px; }
.err { color: var(--danger); font-size: 14px; line-height: 20px; margin: 4px 0 0; }
.err:empty { display: none; }
.bang { display: inline-block; width: 18px; height: 18px; line-height: 16px; text-align: center; border: 2px solid var(--danger); border-radius: 50%; font-size: 12px; font-weight: 700; margin-right: 6px; }
.hint { color: var(--text-muted); font-size: 14px; line-height: 20px; }

/* summary */
.summary { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
.summary .card { margin: 0; }
.summary .label { font-size: 14px; font-weight: 600; color: var(--text-muted); margin: 0; }
.summary .big { font-size: 28px; line-height: 36px; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.neg { color: var(--danger); }

/* rows: category blocks (phone: stacked cards; wider: one line) */
.rows { list-style: none; padding: 0; margin: 0; }
.cat { border-top: 1px solid var(--divider); padding: 12px 0 4px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.cat:first-child { border-top: 0; }
.cat .name { grid-column: 1 / -1; }
.cat .result { grid-column: 1 / -1; margin-bottom: 8px; }
.cat.is-over { background: var(--danger-fill); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.left { font-size: 14px; line-height: 20px; margin: 0 0 4px; }
.left.neg { font-weight: 700; }
progress { display: block; width: 100%; height: 12px; border: 0; border-radius: 6px; background: var(--brand-tint); overflow: hidden; -webkit-appearance: none; appearance: none; }
progress::-webkit-progress-bar { background: var(--brand-tint); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--brand); border-radius: 6px; }
progress.over::-webkit-progress-value { background: repeating-linear-gradient(45deg, var(--danger), var(--danger) 4px, #E8928C 4px, #E8928C 8px); }
progress.over::-moz-progress-bar { background: repeating-linear-gradient(45deg, var(--danger), var(--danger) 4px, #E8928C 4px, #E8928C 8px); }
.totals { border-top: 2px solid var(--divider); margin-top: 8px; padding-top: 12px; display: grid; grid-template-columns: 1fr; gap: 4px; font-weight: 600; }
.totals p { margin: 0; display: flex; justify-content: space-between; gap: 8px; }
.inc { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; align-items: start; }
.inc .btn { grid-column: 1 / -1; margin-bottom: 8px; }

/* debts */
.debt { border-top: 1px solid var(--divider); padding-top: 12px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.debt:first-of-type { border-top: 0; padding-top: 0; }
.debt .name, .debt .rm { grid-column: 1 / -1; }
.debt .rm { justify-self: start; margin-bottom: 12px; }
.results { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 8px; }
.results .card { margin: 0; }
.results .when { font-size: 22px; line-height: 30px; font-weight: 700; margin: 0 0 4px; }
.results .warnbox { background: var(--warn-fill); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.diff { font-weight: 600; margin: 0 0 16px; }
.lockrow:hover { background: var(--brand-tint); color: var(--text); }
.lockrow { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin-bottom: 8px; padding: 8px 16px; background: var(--surface); color: var(--text-muted); border: 1px solid var(--divider); border-radius: 8px; text-align: left; cursor: pointer; }
.empty { color: var(--text-muted); }
.msg { min-height: 24px; margin: 8px 0 0; }
.msg.bad { color: var(--danger); font-weight: 600; }

/* toast and dialog */
.toast { position: fixed; left: 16px; right: 16px; bottom: 72px; z-index: 25; max-width: 420px; margin: 0 auto; padding: 8px 12px; font-size: 14px; line-height: 20px; background: var(--brand-dark); color: var(--on-strong); border-radius: 8px; }
.toast:empty { display: none; }
.toast.bad { background: var(--danger); }
dialog.dlg { width: calc(100% - 32px); max-width: 480px; padding: 16px; border: 1px solid var(--divider); border-radius: 8px; background: var(--surface); color: var(--text); }
dialog.dlg::backdrop { background: rgba(10, 25, 28, .6); }
.dlg-buttons { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 8px; }
.prosample { height: 72px; border-radius: 8px; background: repeating-linear-gradient(90deg, var(--brand-tint) 0 28px, var(--surface) 28px 36px); border: 1px solid var(--divider); margin-bottom: 16px; }

@media (min-width: 600px) {
  body { padding-bottom: 0; }
  h1 { font-size: 24px; }
  main, .foot, .top-in { padding-left: 24px; padding-right: 24px; }
  .tabs { position: static; max-width: 960px; margin: 0 auto; padding: 0 24px; background: transparent; border-top: 0; gap: 4px; }
  .tabs button { flex: 0 0 auto; padding: 8px 20px; font-size: 16px; border-radius: 8px 8px 0 0; border-top: 0; border-bottom: 3px solid transparent; }
  .tabs button[aria-current="page"] { border-bottom-color: var(--brand); }
  .toast { bottom: 16px; }
  .summary { grid-template-columns: repeat(3, 1fr); }
  .summary .big { font-size: 32px; line-height: 40px; }
  .card { padding: 24px; }
  .cat { grid-template-columns: minmax(160px, 2fr) 1fr 1fr minmax(170px, 1.5fr); column-gap: 12px; align-items: start; }
  .cat .name { grid-column: auto; }
  .cat .result { grid-column: auto; margin-top: 28px; }
  .cat.is-over { margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
  .inc { grid-template-columns: 2fr 1fr auto; }
  .inc .btn { grid-column: auto; margin-top: 24px; }
  .debt { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: start; }
  .debt .name, .debt .rm { grid-column: auto; }
  .debt .rm { margin: 24px 0 0; }
  .results { grid-template-columns: 1fr 1fr; }
  .dlg-buttons { flex-direction: row; justify-content: flex-end; }
}
/* wider currency prefixes (the "Other" option): padding grows with the number of characters */
.inputbox.p2 .num { padding-left: 38px; } .inputbox.p3 .num { padding-left: 48px; } .inputbox.p4 .num { padding-left: 58px; }
.inputbox.p5 .num { padding-left: 68px; } .inputbox.p6 .num { padding-left: 78px; } .inputbox.p7 .num { padding-left: 88px; }
.inputbox.p8 .num { padding-left: 98px; } .inputbox.p9 .num { padding-left: 108px; }
.startrow { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.chip.warn { background: var(--warn-fill); color: var(--warn); }
.chip:empty { display: none; }

/* Pro: month bar, tables, plans, goals */
.probar { margin-bottom: 8px; }
.monthbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
.monthbar .field { flex: 1 1 160px; margin-bottom: 0; }
.monthbar .btn { padding: 0 14px; }
.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--divider); border-radius: 8px; }
.tablewrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; line-height: 20px; }
table.grid caption { text-align: left; padding: 8px 12px; color: var(--text-muted); caption-side: top; }
table.grid th, table.grid td { padding: 8px 12px; border-bottom: 1px solid var(--divider); white-space: nowrap; text-align: left; background: var(--surface); }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--brand-tint); color: var(--text); font-weight: 700; }
table.grid tbody th { font-weight: 600; }
table.grid tfoot th, table.grid tfoot td { font-weight: 700; border-top: 2px solid var(--divider); }
table.sched tbody th, table.sched thead th:first-child { position: sticky; left: 0; z-index: 1; }
table.sched thead th:first-child { z-index: 3; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 44px; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; font-weight: 600; text-align: left; }
.plans { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
.plan { border: 1px solid var(--divider); border-radius: 8px; padding: 12px; background: var(--bg); }
.plan:focus { outline: none; }
.planres p { margin: 0 0 4px; font-size: 14px; line-height: 20px; }
.schedctl { display: grid; grid-template-columns: 1fr; column-gap: 12px; }
.goalgrid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.goalgrid > :first-child { grid-column: 1 / -1; }
input[type="date"] { font: 16px/24px var(--font); color: var(--text); background: var(--surface); height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; }
input[type="date"][aria-invalid="true"] { border: 2px solid var(--danger); }
.goalres { margin: 4px 0 8px; }
.goalmsg { font-weight: 700; margin: 0 0 4px; }
.goalres progress { margin: 4px 0; }
.report { display: none; }
@media (min-width: 600px) {
  .plans { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .schedctl { grid-template-columns: 1fr 1fr; }
  .goalgrid { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .goalgrid > :first-child { grid-column: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .tabs button { transition: background-color .1s, color .1s; }
}

/* print: black on white, no navigation or buttons; Pro prints the report only (year summary, then the debt plan on a new page) */
@media print {
  :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; --text: #000; --text-muted: #000; --brand-dark: #000; --brand: #000; --divider: #888; --brand-tint: #eee; --danger: #000; --warn: #000; --warn-fill: #fff; --pro: #000; --pro-fill: #fff; }
  @page { size: A4 portrait; margin: 15mm; }
  .tabs, .top, .toast, .skip, button, .btn, .lockrow, .banner, .actions, nav { display: none !important; }
  body { background: #fff; color: #000; padding: 0; font-size: 12pt; }
  body.pro main > section:not(.report) { display: none; }
  body.pro .report { display: block; }
  .report .pagebreak { break-before: page; page-break-before: always; }
  .tablewrap { overflow: visible; max-height: none; border: 0; }
  table.grid th, table.grid td { white-space: normal; padding: 4px 6px; }
  table.grid thead th { position: static; }
  .card { border: 1px solid #888; break-inside: avoid; }
}
