/* Rest Flow — plain CSS, no build step. Look follows the "Savings tool UI" canvas: off-white ground, ink-dark hero,
   one teal accent, 12–14px radii, inset borders instead of shadows. System fonts only (no external requests). */
:root {
    color-scheme: light;
    --canvas: #f5f6f3;
    --surface: #ffffff;
    --ink: #15191e;
    --ink-2: #3a4148;
    --muted: #5b636b;
    --line: #e3e5e0;
    --line-soft: #eef0ec;
    --field: #cdd1cb;
    --teal: #0b6e66;
    --teal-press: #08524c;
    --teal-ink: #0b4f49;
    --teal-soft: #e6f2f0;
    --teal-light: #9fcdc6;
    --teal-bright: #3fb5a8;
    --blue: #2b4c7e;
    --amber: #e0a458;
    --warn: #6e3a08;
    --warn-soft: #fbebd8;
    --good: #0d402b;
    --good-soft: #e9f6f0;
    --bad: #81091f;
    --bad-soft: #fbe7eb;
    --info: #164d81;
    --info-soft: #e9f2fb;
    --radius: 12px;
    --radius-l: 14px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --display: "Space Grotesk", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); font: 14px/20px var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 30px/38px var(--display); }
h2 { font: 600 20px/28px var(--display); }
h3, .h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0 0 10px; font-size: 14px; font-weight: 600; }
dl, dd { margin: 0; }
small { font-size: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 18px; }
.tiny { font-size: 12px; line-height: 16px; }
.strong { font-weight: 600; }
.medium-weight { font-weight: 500; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.big { font: 600 22px/28px var(--display); }
.link { color: var(--teal); font-weight: 500; }
.link:hover { color: var(--teal-press); text-decoration: underline; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 10px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.narrow { max-width: 640px; }
.mobile-only { display: none; }

/* Shell: side rail on desktop, top bar on phones. */
.shell { display: flex; min-height: 100vh; }
.rail { flex: none; width: 232px; background: var(--surface); box-shadow: inset -1px 0 0 var(--line); display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font: 600 18px/24px var(--display); }
.rail-label { padding: 12px 12px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.nav-groups { display: flex; flex-direction: column; gap: 2px; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 10px; font-weight: 500; color: var(--ink-2); }
.nav a:hover { background: rgba(0, 0, 0, .04); }
.nav a[aria-current] { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 16px 8px 0; box-shadow: inset 0 1px 0 var(--line); flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.me-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-button { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.link-button:hover { color: var(--ink); text-decoration: underline; }
.content { flex: 1; min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 48px; max-width: 1200px; display: flex; flex-direction: column; gap: 24px; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.back { color: var(--teal); font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.back:hover { color: var(--teal-press); }

.card { background: var(--surface); border-radius: var(--radius-l); box-shadow: inset 0 0 0 1px var(--line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; }
.card-foot { display: flex; justify-content: space-between; gap: 12px; padding: 14px 20px; box-shadow: inset 0 1px 0 var(--line-soft); font-weight: 600; }
.pad { padding: 20px; }
.pad-s { padding: 14px 16px; }
.empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; }

.pill { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; color: var(--ink-2); }
.pill strong { color: var(--ink); }

.notice { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.notice-success { background: var(--good-soft); color: var(--good); }
.notice-error { background: var(--bad-soft); color: var(--bad); }
.notice-info { background: var(--info-soft); color: var(--info); }
.link-notice { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.link-notice > div { flex: 1 1 360px; display: flex; flex-direction: column; gap: 6px; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 16px; white-space: nowrap; background: rgba(0, 0, 0, .06); color: rgba(0, 0, 0, .75); }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.cur { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--line-soft); font-size: 11px; font-weight: 600; color: var(--ink-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 0; font: 600 14px/20px var(--font); cursor: pointer; transition: background 120ms cubic-bezier(.2, 0, 0, 1); white-space: nowrap; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-press); }
.btn-secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--field); font-weight: 500; }
.btn-secondary:hover { background: rgba(0, 0, 0, .04); }
.btn-danger { background: transparent; color: var(--bad); font-weight: 500; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-light { background: var(--teal-bright); color: #0b1f1d; }
.btn-light:hover { background: #57c2b6; }
.btn-ghost-dark { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px #4a525a; font-weight: 500; }
.btn-ghost-dark:hover { background: rgba(255, 255, 255, .08); }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-large { min-height: 48px; }
.btn:focus-visible, .input:focus-visible, a:focus-visible, .choice input:focus-visible + span, input[type=range]:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input { width: 100%; min-height: 44px; border: 0; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--field); background: var(--surface); padding: 0 12px; font: 400 16px/24px var(--font); color: var(--ink); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--teal); }
.input::placeholder { color: rgba(0, 0, 0, .38); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row > div { flex: 0 1 180px; }
.form-row > .grow { flex: 1 1 260px; }
input[type=range] { width: 100%; height: 28px; margin: 0; accent-color: var(--teal); }

/* Overview */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--radius-l); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.kpi > span { font-size: 13px; line-height: 18px; color: var(--muted); }
.kpi strong { font: 600 32px/40px var(--display); }
.kpi strong small { font-size: 18px; font-weight: 500; }
.kpi-dark { background: var(--ink); color: #fff; box-shadow: none; }
.kpi-dark > span { color: #b9c0c6; }
.kpi-soft { background: var(--teal-soft); box-shadow: none; color: var(--teal-ink); }
.kpi-soft > span { color: var(--teal-ink); }
.mix { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.split-bar { display: flex; gap: 2px; height: 14px; border-radius: 999px; overflow: hidden; }
.split-bar span:first-child { flex: none; }
.split-bar span:last-child { flex: 1; }
.split-teal span:first-child { background: var(--teal); }
.split-teal span:last-child { background: var(--teal-light); }
.split-blue span:first-child { background: var(--blue); }
.split-blue span:last-child { background: var(--amber); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-teal { background: var(--teal); }
.dot-teal-light { background: var(--teal-light); }
.dot-teal-bright { background: var(--teal-bright); }
.dot-blue { background: var(--blue); }
.dot-amber { background: var(--amber); }

.split { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; }
.main-column { flex: 3 1 560px; min-width: 0; }
.side-column { flex: 2 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.lines { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.lines div { display: flex; justify-content: space-between; gap: 12px; }
.lines dd { font-weight: 600; }
.highlight { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--teal-soft); color: var(--teal-ink); font-weight: 600; }
.highlight strong { font: 600 20px/28px var(--display); }
.grow-row { flex: 1 1 280px; }
.scenarios { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.scenarios li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; box-shadow: inset 0 -1px 0 var(--line-soft); }
.scenarios li > div { display: flex; flex-direction: column; gap: 2px; }
.scenario-age { display: flex; flex-direction: column; align-items: flex-end; }
.scenario-age strong { font: 600 20px/26px var(--display); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 8px 12px; white-space: nowrap; }
td { padding: 12px; box-shadow: inset 0 -1px 0 var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
tr.group th, tr.group td { background: var(--canvas); color: var(--ink); font-size: 13px; font-weight: 600; padding-top: 10px; padding-bottom: 10px; box-shadow: none; }
tr.group th .muted { font-weight: 400; }
tfoot th { color: var(--ink); font-size: 14px; font-weight: 600; padding-top: 16px; padding-bottom: 16px; }
tfoot td { box-shadow: none; }
td.total { font: 600 18px/24px var(--display); }
table.accounts, table.balances { min-width: 600px; }
tr.is-removed td { color: var(--muted); }

/* Balances form */
.rate-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; align-self: flex-start; }
.input-rate { width: 120px; text-align: right; font-weight: 600; }
.affix { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--field); color: var(--muted); }
.affix:focus-within { box-shadow: inset 0 0 0 2px var(--teal); }
.affix-quiet { box-shadow: inset 0 0 0 1px var(--line); background: #fafaf8; }
.affix .input { min-height: 0; height: 36px; padding: 0; box-shadow: none; background: transparent; text-align: right; color: var(--ink); }
.affix .input:focus { box-shadow: none; }
.input-money { width: 110px; font-weight: 600; }
.input-small-money { width: 80px; }
.input-fee { width: 36px; }
.totals-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-radius: var(--radius-l); background: var(--ink); color: #fff; position: sticky; bottom: 12px; z-index: 1; }
.totals { gap: 32px; }
.totals div { display: flex; flex-direction: column; gap: 2px; }
.totals span { font-size: 12px; color: #b9c0c6; }
.totals strong { font-size: 18px; }

/* Every month */
.budget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.item-list { list-style: none; margin: 0; padding: 0 20px 12px; display: flex; flex-direction: column; gap: 8px; }
.item-list li { display: grid; grid-template-columns: minmax(0, 1fr) 120px 84px auto; gap: 8px; align-items: center; }
.item-list .input-money { width: 100%; text-align: right; }
.input-currency { padding: 0 8px; }

/* Planner */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--field); font-weight: 500; }
.chip-link:hover { background: rgba(0, 0, 0, .04); }
.chip-link[aria-current] { background: var(--ink); color: #fff; box-shadow: none; }
.planner-form { position: sticky; top: 16px; }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border-radius: 10px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.choice small { font-size: 12px; color: var(--muted); }
.choice input:checked + span { background: var(--teal); color: #fff; box-shadow: none; }
.choice input:checked + span small { color: rgba(255, 255, 255, .85); }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
.results-grid > div { display: flex; flex-direction: column; gap: 4px; }
.results-grid span { font-size: 13px; color: var(--muted); }
.results-grid strong { font: 600 30px/38px var(--display); }
.results-grid strong small { font-size: 16px; font-weight: 500; }
.result-warn { padding: 10px 12px; margin: -10px -12px; border-radius: 10px; background: var(--warn-soft); }
.result-warn span, .result-warn strong { color: var(--warn); }
.timeline { position: relative; height: 40px; border-radius: 10px; background: var(--line-soft); overflow: hidden; }
.timeline span { position: absolute; top: 0; bottom: 0; transition: width 200ms cubic-bezier(.2, 0, 0, 1), left 200ms cubic-bezier(.2, 0, 0, 1); }
.timeline-work { left: 0; background: var(--blue); }
.timeline-live { background: var(--teal-bright); }
.timeline-ticks { position: relative; height: 18px; font-size: 12px; color: var(--muted); }
.timeline-ticks span { position: absolute; top: 0; transform: translateX(-50%); }
.timeline-ticks span:first-child { transform: none; }
.timeline-ticks span:last-child { transform: translateX(-100%); }

.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }
.login .hint { padding: 12px; border-radius: 8px; background: var(--canvas); color: var(--muted); }
.btn-block { width: 100%; }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .rail { width: auto; height: auto; position: sticky; z-index: 2; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 8px 12px; gap: 4px; box-shadow: inset 0 -1px 0 var(--line); }
    .brand { padding: 0 8px 0 0; font-size: 16px; }
    .rail-label { display: none; }
    .nav-groups { order: 3; width: 100%; flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; }
    .nav-groups::-webkit-scrollbar { display: none; }
    .nav { flex-direction: row; }
    .nav a { border-radius: 999px; padding: 0 14px; white-space: nowrap; min-height: 40px; }
    .me { margin: 0 0 0 auto; padding: 0; box-shadow: none; }
    .me-name { display: none; }
    .content { padding: 16px 16px 32px; gap: 16px; }
    h1 { font-size: 24px; line-height: 32px; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi { padding: 14px; }
    .kpi-dark { grid-column: span 2; }
    .kpi strong { font-size: 24px; line-height: 30px; }
    .kpi strong small { font-size: 14px; }
    .kpi-dark strong { font-size: 34px; line-height: 40px; }
    .kpi-soft { grid-column: span 2; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; }
    .kpi-soft > span:last-child { display: none; }
    .page-head .row { width: 100%; }
    .page-head .row .btn-primary { flex: 1; }
    .planner-form { position: static; }
    .totals { gap: 16px; }
    .item-list li { grid-template-columns: minmax(0, 1fr) 96px 72px; }
    .item-list li .btn-danger { grid-column: 1 / -1; justify-self: start; }
    .budget-grid { grid-template-columns: minmax(0, 1fr); }
    /* Accounts become a list: name with balance and adjustment underneath, EUR value on the right. */
    table.accounts { min-width: 0; }
    table.accounts thead, table.accounts tbody tr:not(.group) td:nth-child(2), table.accounts tbody tr:not(.group) td:nth-child(3) { display: none; }
    table.accounts tr.group th { padding-left: 16px; }
    table.accounts td:first-child, table.accounts tfoot th { padding-left: 16px; }
    table.accounts td:last-child { padding-right: 16px; vertical-align: middle; }
    table.accounts .mobile-only { display: block; margin: 4px 0 0 46px; }
    table.accounts tr.group th[colspan], table.accounts tfoot th[colspan] { width: 100%; }
}
