/* Helios — one design for every section and for the login pages.
   Rules: color carries meaning (section, person, income/expense, risk), never decoration;
   one primary action per screen; every screen answers its question in the first card. */

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1d2430;
  --muted: #5f6b7a;
  --faint: #8a95a5;
  --line: #e3e7ee;
  --line-strong: #cfd6e0;
  --primary: #2f6fde;
  --primary-strong: #2459b8;
  --primary-soft: #e9f0fd;
  --ok: #1d7f53;
  --ok-soft: #e5f4ec;
  --warn: #9a5d07;
  --warn-soft: #fdf1dc;
  --danger: #c23f37;
  --danger-soft: #fcebea;
  --income: #1d7f53;
  --expense: #c23f37;
  --m-home: #e07a1f;
  --m-calendar: #2f6fde;
  --m-finance: #1d7f53;
  --m-health: #d0476f;
  --m-family: #7a5af5;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 6px 20px rgba(20, 30, 50, .06);
  --shadow-lg: 0 18px 50px rgba(20, 30, 50, .22);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2029;
    --surface-2: #202733;
    --text: #e8ecf2;
    --muted: #a2adbb;
    --faint: #7b8696;
    --line: #2a3340;
    --line-strong: #3a4554;
    --primary: #6d9df2;
    --primary-strong: #8fb4f6;
    --primary-soft: #1f2d45;
    --ok: #4cc28c;
    --ok-soft: #173126;
    --warn: #e7a94a;
    --warn-soft: #34281a;
    --danger: #f07b72;
    --danger-soft: #3a1f1f;
    --income: #4cc28c;
    --expense: #f07b72;
    --m-home: #f0a05a;
    --m-calendar: #6d9df2;
    --m-finance: #4cc28c;
    --m-health: #ee7d9e;
    --m-family: #a28ef8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
  .btn-primary, .btn-primary:hover { color: #0f1620; }   /* light accents in dark mode need dark text */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

/* ---------------------------------------------------------------- app frame */

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 19px; letter-spacing: -.01em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: radial-gradient(circle at 50% 50%, #ffd36b 0 31%, transparent 33%), linear-gradient(135deg, #2f6fde, #7a5af5);
}
.side .brand { padding: 4px 10px 16px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  --c: var(--muted);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text); font-weight: 560;
}
.nav a .icon { color: var(--c); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.is-on { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--text); }
.nav a.is-on .icon { color: var(--c); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.me-text { min-width: 0; line-height: 1.3; }
.me-name { font-weight: 650; }
.me-role { font-size: 12.5px; color: var(--muted); }

.main { min-width: 0; padding: 28px 32px 64px; }
.page { max-width: 1060px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.topbar, .tabbar { display: none; }

/* ---------------------------------------------------------------- page header */

.page-head { display: flex; align-items: center; gap: 16px; }
.page-icon {
  --c: var(--primary);
  width: 48px; height: 48px; border-radius: 15px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  color: var(--c);
}
.page-icon .icon { width: 26px; height: 26px; }
.page-title { flex: 1; min-width: 0; }
.page-title p { color: var(--muted); margin-top: 2px; font-size: 15.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------------------------------------------------------- cards and layout */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head .icon { color: var(--muted); }
.card-sub { color: var(--muted); font-size: 13.5px; }
.card-flush { padding: 6px 0; }
.card-flush .card-head { padding: 12px 20px 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* the one-line answer to the page's question */
.answer {
  --c: var(--ok);
  display: flex; gap: 16px; align-items: flex-start;
  border-radius: var(--radius);
  padding: 18px 20px;
  background: color-mix(in srgb, var(--c) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
}
.answer .icon { width: 28px; height: 28px; color: var(--c); margin-top: 2px; }
.answer h2 { font-size: 21px; font-weight: 720; letter-spacing: -.01em; }
.answer p { margin-top: 4px; color: var(--text); opacity: .86; }
a.answer { color: var(--text); }
a.answer:hover { text-decoration: none; border-color: var(--c); }
.answer.is-warn { --c: var(--warn); }
.answer.is-danger { --c: var(--danger); }
.answer.is-info { --c: var(--primary); }

.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 22px; font-weight: 720; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.kpi-unit { white-space: nowrap; font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 5px; letter-spacing: 0; }
.is-income { color: var(--income); }
.is-expense { color: var(--expense); }
.is-negative { color: var(--danger); }

/* ---------------------------------------------------------------- list rows */

.list { display: flex; flex-direction: column; }
.item {
  --c: var(--line-strong);
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  width: 100%;
  background: none; border-left: 0; border-right: 0; border-bottom: 0;
  font: inherit;
}
.list > .item:first-child { border-top: 0; }
button.item, a.item { cursor: pointer; }
button.item:hover, a.item:hover { background: var(--surface-2); text-decoration: none; }
.item::before {
  content: ""; position: absolute; left: 8px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px;
  background: var(--c);
}
.item.no-bar::before { display: none; }
.item-lead { width: 92px; flex: none; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.item-lead b { color: var(--text); font-weight: 650; font-size: 14.5px; display: block; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 1px; }
.item-meta .icon { width: 14px; height: 14px; }
.item-meta .badge { white-space: normal; }
.item-end { flex: none; display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-weight: 650; }
.item-end .icon { color: var(--faint); }
.item.is-busy { color: var(--muted); }
.item.is-busy::before { background: repeating-linear-gradient(45deg, var(--line-strong) 0 3px, transparent 3px 6px); }
.item.is-busy .item-title { font-weight: 500; font-style: italic; }

.day-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 20px 6px;
  font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.day-head b { color: var(--text); font-size: 15px; text-transform: none; letter-spacing: 0; }
.day-head.is-today b { color: var(--primary); }
.day-free { padding: 4px 20px 12px; color: var(--faint); font-size: 13.5px; }

/* ---------------------------------------------------------------- chips, badges, avatars */

.badge {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.6;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }
.badge-ok { --c: var(--ok); }
.badge-warn { --c: var(--warn); }
.badge-danger { --c: var(--danger); }
.badge-info { --c: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  --c: var(--primary);
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 6px 14px 6px 8px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 560; cursor: pointer;
}
.chip.no-avatar { padding-left: 14px; }
.chip:hover { border-color: var(--c); }
.chip.is-on { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: var(--c); }
.chip.is-on::after { content: "✓"; color: var(--c); font-weight: 800; margin-left: -2px; }
.chip.single.is-on::after { content: none; }

.avatar {
  --c: var(--primary);
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--c); color: #fff;
  font-weight: 700; font-size: 14px;
}
.avatar-sm { width: 22px; height: 22px; font-size: 11px; }
.avatar-lg { width: 46px; height: 46px; font-size: 19px; }
.dots { display: inline-flex; align-items: center; gap: 6px; }
.dot { --c: var(--primary); width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.who { display: inline-flex; align-items: center; gap: 6px; }

.door {
  --c: var(--ok);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 650;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
}
.door .icon { width: 16px; height: 16px; }
.door-outside { --c: var(--primary); }

/* ---------------------------------------------------------------- buttons and forms */

.btn {
  --c: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--c); }
.btn-primary { background: var(--c); border-color: var(--c); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--c) 85%, #000); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { --c: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.btn[disabled] { opacity: .55; cursor: progress; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.field-hint { color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  min-height: 44px; padding: 9px 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 92px; }
.input-suffix em { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); pointer-events: none; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.toggle b { display: block; font-weight: 600; }
.toggle small { color: var(--muted); font-size: 13px; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  flex: 1 1 auto; min-height: 38px; padding: 6px 12px;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 30, 50, .14); }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border-radius: 13px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.choice .icon { color: var(--m-health); }
.choice.is-on { border-color: var(--m-health); background: color-mix(in srgb, var(--m-health) 10%, var(--surface)); }

.preview {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-size: 13.5px;
}
.preview .icon { width: 18px; height: 18px; color: var(--primary); margin-top: 1px; }
.preview b { color: var(--text); font-weight: 650; }

.form-error { color: var(--danger); font-size: 14px; font-weight: 600; }

/* ---------------------------------------------------------------- sheet (dialog) */

dialog.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.sheet::backdrop { background: rgba(15, 22, 33, .45); }
.sheet form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.sheet-head h2 { flex: 1; font-size: 19px; }
.sheet-body { padding: 10px 20px 16px; display: flex; flex-direction: column; gap: 16px; overflow: auto; }
.sheet-foot { display: flex; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.sheet-foot .grow { flex: 1; }

/* ---------------------------------------------------------------- empty, toast, misc */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 28px 16px; color: var(--muted); }
.empty .bubble { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); }
.empty .bubble .icon { width: 28px; height: 28px; }
.empty h3 { color: var(--text); }
.steps-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; text-align: left; width: 100%; margin: 6px 0 4px; }
.steps-row div { padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.steps-row b { display: block; color: var(--primary); font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  display: flex; gap: 14px; align-items: center;
  padding: 12px 16px; border-radius: 14px;
  background: #1d2430; color: #fff; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: .2s ease; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button { background: none; border: 0; color: #9cc0ff; font: inherit; font-weight: 700; cursor: pointer; }

.loading { padding: 40px; text-align: center; color: var(--muted); }
.error-box { padding: 16px 18px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tile {
  --c: var(--primary);
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--text);
}
.tile:hover { border-color: var(--c); text-decoration: none; }
.tile .page-icon { width: 40px; height: 40px; border-radius: 12px; }
.tile .page-icon .icon { width: 22px; height: 22px; }
.tile b { font-size: 16px; }
.tile span { color: var(--muted); font-size: 13.5px; line-height: 1.4; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* finance chart */
.chart { width: 100%; height: 210px; display: block; }
.chart .zero { stroke: var(--line-strong); stroke-dasharray: 4 4; }
.chart .line { fill: none; stroke: var(--m-finance); stroke-width: 2.5; }
.chart .area-pos { fill: color-mix(in srgb, var(--m-finance) 14%, transparent); }
.chart .area-neg { fill: color-mix(in srgb, var(--danger) 22%, transparent); }
.chart .today { stroke: var(--faint); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .mark { fill: var(--danger); }
.chart .mark-ok { fill: var(--m-finance); }
.chart .hover-line { stroke: var(--text); stroke-width: 1; opacity: .35; }
.chart-tip { font-size: 13px; color: var(--muted); min-height: 20px; }

.chart { height: 230px; }
.chart .free-line { fill: none; stroke: var(--m-family); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .today-line { stroke: var(--primary); stroke-width: 2; }
.chart .today-label { fill: var(--primary); font-weight: 700; }
.chart .pay-dot { fill: var(--text); opacity: .7; }
.chart .pay-label { font-size: 11px; }

/* finance: accounts, timeline, categories, goals */
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 0 20px 14px; }
.notice { background: var(--surface-2); border: 1px solid var(--line); font-weight: 500; }
.notice-danger, .notice-ok { border-color: transparent; }
.plan-pick { min-height: 42px; width: auto; font-weight: 600; }
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.acc {
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.acc:hover { border-color: var(--m-finance); }
.acc b { font-size: 18px; font-weight: 720; font-variant-numeric: tabular-nums; }
.acc-name { color: var(--muted); font-size: 12.5px; }
.acc-sub { color: var(--faint); font-size: 12px; }
.acc-sub.is-stale, .kpi-sub.is-stale { color: var(--warn); font-weight: 600; }
.acc.is-missing { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.acc.is-missing .acc-sub { color: var(--danger); font-weight: 600; }
.acc.is-total { background: color-mix(in srgb, var(--m-finance) 10%, var(--surface)); border-color: color-mix(in srgb, var(--m-finance) 30%, transparent); cursor: default; }
.acc.is-add { align-items: center; justify-content: center; flex-direction: row; gap: 6px; border-style: dashed; color: var(--primary); font-weight: 650; background: transparent; }
.fin-tabs .seg { display: inline-flex; }
button.day-head { width: 100%; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); font: inherit; cursor: pointer; text-align: left; align-items: center; padding-top: 10px; padding-bottom: 10px; font-size: 13px; }
.fin-group.is-late { background: var(--warn-soft); }
.fin-item { align-items: center; }
.fin-item.is-late { background: color-mix(in srgb, var(--warn-soft) 60%, var(--surface)); }
.fin-item .linkish { border: 0; background: none; padding: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.fin-amount { flex-direction: column; align-items: flex-end; gap: 0; }
.fin-amount small { color: var(--faint); font-weight: 500; font-size: 12px; }
.check, .check-space { width: 22px; height: 22px; flex: none; }
.check {
  display: grid; place-items: center; padding: 0; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); color: #fff;
}
.check:hover { border-color: var(--ok); }
.check .icon { width: 14px; height: 14px; }
.check.is-on { background: var(--ok); border-color: var(--ok); }
.check[disabled] { cursor: default; opacity: .7; }
.badge-person { --c: var(--m-family); }
.month-label { font-size: 16px; min-width: 150px; text-align: center; }
.fin-cats { display: flex; flex-direction: column; }
.fin-cat { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(0, 1.4fr) auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.fin-cat:first-child { border-top: 0; }
.fin-cat small { display: block; color: var(--faint); font-size: 12px; }
.fin-bar { position: relative; height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.fin-bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 99px; background: var(--m-finance); }
.fin-bar i.is-near { background: #d99a22; }
.fin-bar i.is-over { background: var(--danger); }
.fin-bar i.is-planned { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--m-finance) 35%, transparent) 0 4px, transparent 4px 8px); border-radius: 0; }
.fin-bar u { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .45; }
.fin-cat-v { border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer; text-align: right; display: flex; gap: 6px; align-items: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-cat-v b { color: var(--text); }
.fin-cat-v:hover b { text-decoration: underline; }
.fin-unsorted { flex-wrap: wrap; padding-left: 20px; }
.fin-unsorted .item-body { flex: 1 1 100%; }
.fin-table { width: calc(100% - 40px); margin: 0 20px 10px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.fin-table th, .fin-table td { text-align: left; padding: 8px 4px; border-top: 1px solid var(--line); }
.fin-table th { color: var(--muted); font-weight: 600; font-size: 12.5px; border-top: 0; }
.goals { display: flex; flex-direction: column; }
.goal { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.goal:first-child { border-top: 0; }
.goal-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: color-mix(in srgb, var(--m-family) 12%, var(--surface)); }
.goal-body { display: flex; flex-direction: column; gap: 6px; }
.goal-bar { height: 12px; }
.goal-bar i { background: var(--m-family); }
.share-list, .cat-list { display: flex; flex-direction: column; }
.share-row, .cat-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.share-row:first-child, .cat-row:first-child { border-top: 0; }
.share-row .seg { flex: none; }
.sheet-sub { font-size: 14px; font-weight: 700; margin-top: 6px; }
.welcome-acc { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; text-align: left; }

/* family tree: one row per generation, rows never wrap — the tree scrolls sideways instead */
.tree-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.tree { position: relative; display: flex; flex-direction: column; gap: 40px; padding: 18px 4px 8px; min-width: min-content; }
.tree svg.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.tree svg.links path { fill: none; stroke: var(--line-strong); stroke-width: 2; }
.tree svg.links path.partner { stroke: var(--m-family); stroke-dasharray: 2 5; }
.gen { position: relative; display: flex; flex-wrap: nowrap; justify-content: center; gap: 10px; }
.gen-label { position: absolute; left: 0; top: -20px; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.person {
  --c: var(--primary);
  position: relative; z-index: 1;
  flex: 0 1 152px; min-width: 116px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px 10px;
  border-radius: 15px; border: 1px solid var(--line); border-top: 4px solid var(--c);
  background: var(--surface); box-shadow: var(--shadow);
  font: inherit; color: var(--text); text-align: center; cursor: pointer;
}
.person:hover { border-color: var(--c); }
.person.is-me { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), var(--shadow); }
.person .avatar-lg { width: 38px; height: 38px; font-size: 16px; }
.person-text { min-width: 0; width: 100%; line-height: 1.3; }
.person-name { font-weight: 700; font-size: 14.5px; }
.person-sub { color: var(--muted); font-size: 12.5px; }
.person .badge { margin-top: 5px; white-space: normal; justify-content: center; font-size: 11.5px; }

/* ---------------------------------------------------------------- login page */

.login-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 18px; }
.login-card {
  width: min(430px, 100%);
  display: flex; flex-direction: column; gap: 16px;
  padding: 28px 28px 26px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
.login-card .door { align-self: flex-start; }
.brand-lg { font-size: 22px; }
.brand-lg .brand-mark { width: 32px; height: 32px; }
.lead { color: var(--muted); }
.notice { padding: 11px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; }
.notice-danger { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.alt { color: var(--muted); font-size: 14px; text-align: center; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.lab-note { color: var(--faint); font-size: 13px; text-align: center; }

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .app { grid-template-columns: 224px minmax(0, 1fr); }
}

@media (max-width: 1020px) {
  .tiles, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
  }
  .topbar .brand { flex: 1; font-size: 17px; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar a {
    --c: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; border-radius: 10px;
    font-size: 11.5px; font-weight: 600; color: var(--muted);
  }
  .tabbar a .icon { width: 23px; height: 23px; color: var(--muted); }
  .tabbar a.is-on { color: var(--text); }
  .tabbar a.is-on .icon { color: var(--c); }
  .tabbar a:hover { text-decoration: none; }
  .main { padding: 18px 16px 110px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; }
  .page-icon { width: 42px; height: 42px; border-radius: 13px; }
  h1 { font-size: 23px; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions .btn { flex: 1; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .item { padding: 11px 16px 11px 20px; gap: 12px; }
  .item-lead { width: 64px; }
  .day-head { padding: 14px 16px 6px; }
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .sheet form { max-height: 92vh; }
  .fields-2 { grid-template-columns: 1fr; }
  .gen { flex-wrap: wrap; }
  .person { flex: 1 1 100%; max-width: 360px; flex-direction: row; text-align: left; padding: 10px 12px; gap: 12px; }
  .person .badge { justify-content: flex-start; }
  .tree svg.links { display: none; }
  .tree { gap: 30px; min-width: 0; }
  .toast { bottom: 92px; }
  .fin-cat { grid-template-columns: minmax(0, 1fr) auto; }
  .fin-cat .fin-bar { grid-column: 1 / -1; grid-row: 2; }
  .goal { grid-template-columns: 40px minmax(0, 1fr); }
  .goal > .row-gap { grid-column: 2; }
  .share-row { flex-wrap: wrap; }
  .welcome-acc { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .tiles, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps-row { grid-template-columns: minmax(0, 1fr); }
}
