/* Kibubu design tokens
   Ink slate + jade with one gold accent (the shilling coin). IBM Plex Sans throughout, tabular figures for money. */
@font-face { font-family: Plex; src: url(/fonts/plex-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Plex; src: url(/fonts/plex-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Plex; src: url(/fonts/plex-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Plex; src: url(/fonts/plex-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --paper: #f3f5f7; --surface: #fff; --ink: #18222f; --ink-2: #485465; --muted: #7a8594; --line: #e1e6eb; --line-2: #eef1f4;
  --jade: #0e5a4b; --jade-2: #13755f; --gold: #e3a21a; --gold-ink: #3a2700;
  --good: #157a55; --warn: #a8650c; --bad: #b5402c;
  --sav: #2b65a8; --sav-bg: #e7eff8; --fix: #6a4ea6; --fix-bg: #efeaf8; --var: #13755f; --var-bg: #e2f1ec;
  --mov: #a8650c; --mov-bg: #fbf0dd; --inc: #157a55; --inc-bg: #e2f3ea; --due: #b5402c; --due-bg: #fbe9e5; --tr: #485465; --tr-bg: #ebeef2;
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --f: Plex, "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f151c; --surface: #17202a; --ink: #e6ebf0; --ink-2: #b4bfcb; --muted: #8592a0; --line: #26313d; --line-2: #1d2731;
    --jade: #3fb08f; --jade-2: #5cc4a4; --good: #4cc08d; --warn: #e0a44a; --bad: #ef8270;
    --sav: #7fb0e8; --sav-bg: #1c2b3d; --fix: #b39ae6; --fix-bg: #282340; --var: #5cc4a4; --var-bg: #17322b;
    --mov: #e5ad5a; --mov-bg: #352816; --inc: #5fcf98; --inc-bg: #173326; --due: #ef8270; --due-bg: #3a1e1a; --tr: #b4bfcb; --tr-bg: #232e3a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--f); font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; padding-bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.inline { width: 13px; height: 13px; vertical-align: -2px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
:focus-visible { outline: 2px solid var(--jade-2); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .good-t { color: var(--good); } .bad-t { color: var(--bad); } .warn-t { color: var(--warn); }
.hint { color: var(--ink-2); font-size: 13px; margin-top: 10px; } .pad { padding: 0 4px; }

/* ---------- shell: mobile ---------- */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 18px 12px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bar h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.sync.pend i, .sync.busy i { background: var(--gold); } .sync.off i { background: var(--muted); }
.sync.busy i { animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
main { max-width: 640px; margin: 0 auto; padding: 4px 14px 24px; outline: none; }

.side { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.side .brand, .side-sync { display: none; }
.nav { display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); align-items: center; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 6px 0; }
.nav a.on { color: var(--jade); }
.nav a.on .ic { stroke-width: 2.1; }
.nav .nav-log { order: 3; }
.nav .nav-log span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nav .nav-log .ic { width: 52px; height: 52px; padding: 13px; margin-top: -26px; border-radius: 16px; background: var(--gold); color: var(--gold-ink); stroke-width: 2.4; box-shadow: 0 6px 16px rgba(163, 110, 0, .28); }
.nav a[data-r=home] { order: 1; } .nav a[data-r=activity] { order: 2; } .nav a[data-r=plan] { order: 4; } .nav a[data-r=more] { order: 5; }

/* ---------- shell: desktop ---------- */
@media (min-width: 960px) {
  body { padding: 0 0 0 248px; }
  .side { top: 0; right: auto; width: 248px; border-top: 0; border-right: 1px solid var(--line); padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; }
  .side .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: -.01em; padding: 0 8px; }
  .brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); }
  .brand-mark svg { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .nav { display: flex; flex-direction: column; height: auto; align-items: stretch; gap: 2px; }
  .nav a { flex-direction: row; gap: 12px; font-size: 14.5px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); }
  .nav a:hover { background: var(--line-2); }
  .nav a.on { background: var(--var-bg); color: var(--jade); font-weight: 600; }
  .nav .nav-log { order: 0; margin-bottom: 14px; background: var(--ink); color: #fff; font-weight: 600; }
  .nav .nav-log:hover, .nav .nav-log.on { background: var(--ink); color: #fff; }
  .nav .nav-log span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .nav .nav-log .ic { width: 20px; height: 20px; padding: 0; margin: 0; background: none; box-shadow: none; color: var(--gold); border-radius: 0; }
  .side-sync { display: inline-flex; margin-top: auto; padding: 0 12px; }
  .bar { padding: 28px 40px 14px; background: transparent; backdrop-filter: none; position: static; }
  .bar h1 { font-size: 26px; }
  .bar .sync { display: none; }
  main { max-width: 1120px; margin: 0; padding: 0 40px 48px; }
  .grid-home { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }
  .grid-home > .week { grid-column: 1; }
  .grid-home > .col-side { grid-column: 2; grid-row: 1 / span 3; }
  .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
  .narrow { max-width: 560px; }
}

/* ---------- surfaces ---------- */
.panel { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; text-decoration: none; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.panel-head h2 { font-size: 15.5px; font-weight: 600; }
.panel-head p { color: var(--muted); font-size: 13px; margin-top: 1px; }
.panel-head > a, .panel-head > span, .link { font-size: 13px; color: var(--jade); font-weight: 500; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; }
.panel-head > span { color: var(--muted); font-weight: 400; }
.panel-head > b { font-size: 15px; font-weight: 600; }
.notice { display: flex; align-items: center; gap: 10px; background: var(--mov-bg); color: var(--ink); border-radius: var(--r); padding: 10px 12px; margin-bottom: 14px; font-size: 13.5px; }
.notice span { flex: 1; }

/* ---------- the week strip (signature element) ---------- */
.week { background: var(--ink); color: #eef2f6; border-radius: var(--r-lg); padding: 20px 20px 16px; margin-bottom: 14px; }
@media (prefers-color-scheme: dark) { .week { background: #1d2935; } }
.week-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.week-label { font-size: 13.5px; color: #aeb9c6; }
.week-num { font-size: 40px; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; margin: 4px 0 6px; }
.week.neg .week-num { color: #ff9b86; }
.week-sub { font-size: 14px; color: #d4dce5; max-width: 34ch; }
.week-pay { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.week-pay b { font-size: 26px; font-weight: 600; color: var(--gold); line-height: 1.1; }
.week-pay span { font-size: 12px; color: #aeb9c6; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 20px 0 10px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.day .col { position: relative; width: 100%; height: 76px; background: rgba(255,255,255,.06); border-radius: 7px; overflow: hidden; }
.day .col span { position: absolute; left: 0; right: 0; bottom: 0; background: #5fd0ad; border-radius: 7px 7px 0 0; }
.day.over .col span { background: #ff8f78; }
.day .lim { position: absolute; left: 0; right: 0; border-top: 1.5px dashed rgba(255,255,255,.5); z-index: 1; }
.day.future .col { background: transparent; border: 1px dashed rgba(255,255,255,.16); }
.day b { font-size: 12px; font-weight: 600; color: #aeb9c6; }
.day small { font-size: 11px; color: #8d99a7; min-height: 15px; }
.day.today .col { box-shadow: inset 0 0 0 2px var(--gold); }
.day.today b { color: var(--gold); }
.week-foot { font-size: 12px; color: #8d99a7; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 12px; }
.stats div { display: flex; flex-direction: column; }
.stats span { font-size: 12.5px; color: var(--muted); }
.stats b { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.stats-foot { grid-column: 1 / -1; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 8px; }

/* ---------- alerts ---------- */
.alerts { margin-bottom: 14px; display: grid; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--r); text-decoration: none; font-size: 13.5px; }
.alert .ic { width: 18px; height: 18px; margin-top: 1px; }
.alert.warn { background: var(--mov-bg); } .alert.warn .ic { color: var(--warn); }
.alert.bad { background: var(--due-bg); } .alert.bad .ic { color: var(--bad); }

/* ---------- list items ---------- */
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--line-2); background: none; text-align: left; cursor: pointer; text-decoration: none; }
.panel-head + .item, .panel > .item:first-child, .day-head + .item { border-top: 0; }
button.item:hover .item-main b { color: var(--jade); }
.tile { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex: none; background: var(--tr-bg); color: var(--tr); }
.tile .ic { width: 19px; height: 19px; }
.tile.sav { background: var(--sav-bg); color: var(--sav); } .tile.fix { background: var(--fix-bg); color: var(--fix); }
.tile.var { background: var(--var-bg); color: var(--var); } .tile.mov { background: var(--mov-bg); color: var(--mov); }
.tile.inc { background: var(--inc-bg); color: var(--inc); } .tile.due { background: var(--due-bg); color: var(--due); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-main b { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-main > span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-end { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.item-end b { font-weight: 600; font-size: 15px; }
.item-end > span { font-size: 12.5px; color: var(--muted); }
.item-end em, .env-top em { font-style: normal; color: var(--muted); font-weight: 400; }
.item-main > .status { font-size: 12.5px; white-space: normal; }
.item-main > .status.on { color: var(--jade); } .item-main > .status.paused, .item-main > .status.done { color: var(--muted); } .item-main > .status.setup { color: var(--warn); }
.item.rec.paused .item-main b, .item.rec.done .item-main b { color: var(--muted); }
.day-head { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 16px 0 2px; }
.day-head:first-child { margin-top: 2px; }
.plain { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.done { text-decoration: line-through; color: var(--muted); }

.env { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.env-main { flex: 1; min-width: 0; }
.env-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.env-top b { font-weight: 500; }
.meter { height: 6px; background: var(--line-2); border-radius: 6px; overflow: hidden; margin-top: 7px; }
.meter span { display: block; height: 100%; background: var(--jade-2); border-radius: 6px; }
.meter.warn span { background: var(--gold); } .meter.over span { background: var(--bad); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14.5px; }
.kv span { color: var(--ink-2); } .kv b { font-weight: 600; text-align: right; }
.kv.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 9px; }
.move-card .move-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 2px; }
.move-figs div { display: flex; flex-direction: column; } .move-figs span { font-size: 12.5px; color: var(--muted); } .move-figs b { font-size: 16px; font-weight: 600; }
.move-card:hover h2 { color: var(--jade); }
.goal-num { font-size: 14px; color: var(--muted); } .goal-num b { font-size: 22px; color: var(--ink); font-weight: 600; margin-right: 4px; }
.goal .btn { margin-top: 12px; }

.empty { text-align: center; padding: 22px 12px; color: var(--ink-2); }
.empty .ic { width: 28px; height: 28px; color: var(--muted); margin-bottom: 6px; }
.empty b { display: block; font-weight: 600; color: var(--ink); }
.empty p { font-size: 13.5px; margin: 4px auto 0; max-width: 34ch; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 10px 15px; font-weight: 500; font-size: 14.5px; cursor: pointer; text-decoration: none; }
.btn .ic { width: 18px; height: 18px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--jade); border-color: var(--jade); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #08251d; } }
.btn.primary:hover { background: var(--jade-2); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--jade); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.big { padding: 13px 18px; font-size: 15.5px; }
.btn.add { margin-top: 4px; padding-left: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--line-2); cursor: pointer; }
.icon-btn .ic { width: 18px; height: 18px; }
.row-btns { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; }
input, select { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: 400 16px var(--f); font-feature-settings: "tnum" 1; }
input:focus, select:focus { outline: none; border-color: var(--jade-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-2) 18%, transparent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
label.check { display: flex; gap: 11px; align-items: center; font-size: 14.5px; color: var(--ink); font-weight: 400; margin: 14px 0; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--jade); flex: none; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 13px; color: var(--ink-2); font-weight: 500; padding: 0; margin-bottom: 6px; }
.choice { display: flex; flex-wrap: wrap; gap: 6px; }
.choice label, .icon-pick label { margin: 0; cursor: pointer; }
.choice input, .icon-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { display: block; padding: 8px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; color: var(--ink); font-weight: 400; }
.choice input:checked + span { border-color: var(--jade); background: var(--var-bg); color: var(--jade); font-weight: 500; }
.choice input:focus-visible + span, .icon-pick input:focus-visible + span { outline: 2px solid var(--jade-2); outline-offset: 2px; }
.icon-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-pick span { display: grid; place-items: center; height: 38px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-2); }
.icon-pick input:checked + span { border-color: var(--jade); background: var(--var-bg); color: var(--jade); }
.field small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 5px; font-weight: 400; }
.field[hidden] { display: none; }

.income-field { font-size: 13px; }
.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; padding-left: 12px; }
.money-input:focus-within { border-color: var(--jade-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-2) 18%, transparent); }
.money-input em { font-style: normal; color: var(--muted); font-size: 15px; }
.money-input input { border: 0; margin: 0; font-size: 22px; font-weight: 600; padding: 10px 10px; box-shadow: none !important; }
.alloc { display: flex; height: 12px; gap: 3px; margin: 16px 0 12px; }
.alloc span { border-radius: 3px; min-width: 0; }
.alloc .sav, .legend .sav { background: var(--sav); } .alloc .fix, .legend .fix { background: var(--fix); }
.alloc .var, .legend .var { background: var(--var); } .alloc .left, .legend .left { background: var(--line); } .legend .neg { background: var(--bad); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 12px 0 0; }
.legend div { display: flex; flex-direction: column; }
.legend dt { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.legend dt i { width: 9px; height: 9px; border-radius: 2px; }
.legend dd { margin: 2px 0 0 16px; font-weight: 600; font-size: 16px; }
.legend dd small { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.steps { margin: 12px 0 0; padding-left: 22px; }
.steps li { padding: 4px 0 8px; } .steps li::marker { color: var(--muted); font-weight: 600; }
.steps b { display: block; font-weight: 600; font-size: 14.5px; } .steps span { font-size: 13px; color: var(--muted); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line-2); border-radius: 11px; padding: 3px; }
.seg button, .seg a { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 500; font-size: 14px; color: var(--ink-2); cursor: pointer; text-align: center; text-decoration: none; }
.seg .on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.page-seg { margin-bottom: 14px; max-width: 420px; }

/* log form */
.log { max-width: 640px; }
.amount { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 22px 0 4px; color: var(--muted); }
.amount span { font-size: 18px; font-weight: 500; }
.amount input { width: 9ch; border: 0; padding: 0; margin: 0; background: none; text-align: left; font-size: 44px; font-weight: 600; letter-spacing: -.02em; box-shadow: none !important; }
.fee { text-align: center; font-size: 13px; color: var(--muted); }
.paste { display: flex; gap: 12px; align-items: center; width: 100%; margin: 16px 0 4px; padding: 12px 14px; background: var(--line-2); border: 1px dashed var(--line); border-radius: var(--r); cursor: pointer; text-align: left; }
.paste .ic { color: var(--jade); } .paste b { display: block; font-weight: 500; font-size: 14.5px; } .paste small { color: var(--muted); font-size: 12.5px; }
.chip-group { margin-top: 16px; }
.chip-group p { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 11px; font-size: 13.5px; cursor: pointer; }
.chip .ic { width: 16px; height: 16px; color: var(--muted); }
.chip.on { background: var(--jade); border-color: var(--jade); color: #fff; } .chip.on .ic { color: #fff; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-actions .primary { flex: 1; max-width: 320px; }
@media (max-width: 959px) { .form-actions .primary { max-width: none; } }

/* more menu */
.menu { padding: 6px 18px; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 12px 0; text-decoration: none; border-top: 1px solid var(--line-2); }
.menu a:first-child { border-top: 0; }
.menu a > span { flex: 1; display: flex; flex-direction: column; } .menu b { font-weight: 500; } .menu small { color: var(--muted); font-size: 13px; }
.menu a > .ic { color: var(--muted); width: 18px; }

.pager { display: flex; justify-content: space-between; align-items: center; margin: 0 0 14px; }
.pager b { font-weight: 600; } .pager a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); }

/* move checklist */
.check-item { cursor: default; }
.tick { margin: 0; cursor: pointer; }
.tick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tick span { display: grid; place-items: center; width: 26px; height: 26px; border: 1.5px solid var(--line); border-radius: 8px; color: transparent; }
.tick input:checked + span { background: var(--jade); border-color: var(--jade); color: #fff; }
.tick input:focus-visible + span { outline: 2px solid var(--jade-2); outline-offset: 2px; }
.tick .ic { width: 16px; height: 16px; stroke-width: 2.6; }

/* ---------- sheet / dialog ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: none; }
.sheet.open { display: block; }
.sheet-bg { position: absolute; inset: 0; background: rgba(12, 18, 26, .46); }
.sheet-card { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; animation: rise .2s ease-out; }
@media (min-width: 720px) { .sheet-card { left: 50%; top: 50%; bottom: auto; width: 520px; transform: translate(-50%, -50%); border-radius: var(--r-lg); animation: fade .15s ease-out; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h3 { font-size: 18px; font-weight: 600; }
.sheet-intro { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.sheet-body { display: grid; gap: 14px; margin-top: 16px; }
.sheet-body label.check { margin: 0; }
.sheet-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 20px; }
.sheet-actions .primary { margin-left: auto; min-width: 140px; }
@media (max-width: 719px) { .sheet-actions .primary { flex: 1; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { .toast { bottom: 28px; left: calc(50% + 124px); } }

/* ---------- login ---------- */
body.login-mode { padding: 0; }
body.login-mode .side, body.login-mode .bar { display: none; }
.login { max-width: 360px; margin: 16vh auto 0; text-align: center; padding: 0 20px; }
.login-mark { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--ink); }
.login-mark .ic { width: 38px; height: 38px; color: var(--gold); stroke-width: 1.6; }
.login h1 { font-size: 28px; font-weight: 700; margin-top: 14px; letter-spacing: -.02em; }
.login > p { color: var(--muted); margin: 4px 0 26px; }
.login label { text-align: left; }
.login-err { color: var(--bad); font-size: 13.5px; margin-top: 12px; min-height: 20px; }

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

.page-actions { display: flex; justify-content: flex-end; margin: 0 0 14px; }
.chip.new { border-style: dashed; color: var(--jade); margin-top: 14px; }
.chip.new .ic { color: var(--jade); }

.item.credit { flex-wrap: wrap; cursor: default; }
.item.credit .item-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.item.credit .meter { width: calc(100% - 50px); margin: 0 0 4px 50px; }
.item.credit > .btn { margin-left: 50px; }
.meter.thin { height: 4px; }
.item.credit .item-main > span { white-space: normal; }

.fund-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 50px; }
.fund-btns .btn { margin: 0; }

/* split bills & loans */
.split-box { margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 4px; }
.split-box > label.check { margin: 10px 0; }
.split-body { display: grid; gap: 12px; padding: 12px; background: var(--line-2); border-radius: var(--r); }
.split-body[hidden], .parts-box[hidden], .payer-field[hidden], .acc-field[hidden] { display: none; }
.split-body .form-grid { margin-top: 0; }
.parts-head { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.part { display: grid; grid-template-columns: 1fr 96px auto 34px; gap: 6px; align-items: center; margin-bottom: 6px; }
.part input { margin: 0; }
label.check.mini { margin: 0; font-size: 12.5px; gap: 6px; white-space: nowrap; }
label.check.mini input { width: 18px; height: 18px; }
.split-sum { font-size: 13px; color: var(--ink-2); }
.loan-kind { margin-top: 18px; }
.row-btns.top { margin: 0 0 14px; flex-wrap: wrap; }
.person-head { display: flex; gap: 14px; align-items: center; }
.person-head > div { flex: 1; }
.person-head .tile { width: 48px; height: 48px; border-radius: 14px; }
.person-bal { font-size: 13.5px; color: var(--muted); }
.person-head b { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.move-figs.two { grid-template-columns: 1fr 1fr; margin-bottom: 6px; }
@media (max-width: 420px) { .part { grid-template-columns: 1fr 84px 34px; } .part label.check.mini { grid-column: 1 / -1; grid-row: 2; } }

input[type=date] { cursor: pointer; min-height: 44px; }
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; }
.field-hint { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 5px; }
.auto-note { margin: 2px 0 0 50px; }

/* dd-mm-yyyy date fields */
.datef { display: flex; align-items: stretch; margin-top: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.datef:focus-within { border-color: var(--jade-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-2) 18%, transparent); }
.datef .date-text { border: 0; margin: 0; flex: 1; min-width: 0; box-shadow: none !important; letter-spacing: .02em; }
.datef .date-text.bad { color: var(--bad); }
.date-btn { position: relative; display: grid; place-items: center; width: 44px; flex: none; color: var(--muted); border-left: 1px solid var(--line-2); }
.date-btn .ic { width: 18px; height: 18px; pointer-events: none; }
.date-btn:hover { color: var(--jade); }
.date-native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; border: 0; min-height: 0; }
.date-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.loan-kind .choice label { flex: 1 1 calc(50% - 6px); } .loan-kind .choice span { text-align: center; }

.fee-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 2px 0 4px; }
.fee-row[hidden] { display: none; }
.fee-row label { font-size: 13px; }
.money-input.small { margin: 0; width: 150px; padding-left: 10px; }
.money-input.small em { font-size: 13px; }
.money-input.small input { font-size: 16px; font-weight: 500; padding: 7px 8px; }
.fee-note { text-align: center; font-size: 12.5px; color: var(--muted); min-height: 0; }
.fee-note:empty { display: none; }

.top-gap { margin: 0 0 14px; }
.deposit.closed { opacity: .7; }
.deposit .row-btns { margin-top: 12px; }

/* balances glance */
.balances .panel-head { margin-bottom: 4px; }
.balances .icon-btn { width: 32px; height: 32px; }
.bal-top { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 8px; }
.bal-top div { display: flex; flex-direction: column; } .bal-top span { font-size: 12.5px; color: var(--muted); } .bal-top b { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.bal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.bal { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 0; text-decoration: none; font-size: 13.5px; min-width: 0; }
.bal span { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bal b { font-weight: 600; white-space: nowrap; }
.bal.owe b { color: var(--bad); }
@media (max-width: 360px) { .bal-grid { grid-template-columns: 1fr; } }

/* ============================================================ feel: speed, touch, motion */
button, a, .item, .chip, .btn, .tick, label.check, .seg button, .seg a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn, .chip, .seg button, .seg a, .icon-btn, .paste, .menu a, .bal, .tick span { transition: transform .09s ease, background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn:active, .chip:active, .icon-btn:active, .paste:active, .seg button:active { transform: scale(.97); }

/* Rows: a soft pressed state that reaches to the panel edge */
button.item, a.item, .menu a { border-radius: 10px; margin-left: -8px; margin-right: -8px; padding-left: 8px; padding-right: 8px; width: calc(100% + 16px); transition: background-color .12s ease; }
button.item:active, a.item:active, .menu a:active, .bal:active { background: var(--line-2); }
@media (hover: hover) { button.item:hover, a.item:hover, .menu a:hover { background: color-mix(in srgb, var(--line-2) 70%, transparent); } }
.menu a { padding-left: 8px; padding-right: 8px; }

/* Only lay out and paint sections when they're near the screen */
#view > .panel, #view .grid-2 > .panel, #view .col-side > .panel { content-visibility: auto; contain-intrinsic-size: auto 220px; }

/* Bottom bar: Material-style active pill */
@media (max-width: 959px) {
  .nav a:not(.nav-log) .ic { width: 56px; height: 30px; padding: 5px 18px; border-radius: 15px; transition: background-color .2s ease, color .2s ease; }
  .nav a.on:not(.nav-log) .ic { background: var(--var-bg); }
  .nav .nav-log:active .ic { transform: scale(.94); }
  .nav .nav-log .ic { transition: transform .1s ease; }
  .side { backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); background: color-mix(in srgb, var(--surface) 90%, transparent); }
}
.bar { transition: box-shadow .2s ease; }
.bar.scrolled { box-shadow: 0 1px 0 var(--line); }

/* Screen changes: a quick cross-fade with a small lift (View Transitions), bars stay put */
.side { view-transition-name: nav; }
.bar { view-transition-name: bar; }
::view-transition-old(root) { animation: vt-out .12s ease-in both; }
::view-transition-new(root) { animation: vt-in .18s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }

/* Week strip: bars grow in once when Overview first opens */
.week.intro .day .col span { animation: grow .55s cubic-bezier(.2, .8, .2, 1) both; transform-origin: bottom; }
.week.intro .day:nth-child(2) .col span { animation-delay: .03s; } .week.intro .day:nth-child(3) .col span { animation-delay: .06s; }
.week.intro .day:nth-child(4) .col span { animation-delay: .09s; } .week.intro .day:nth-child(5) .col span { animation-delay: .12s; }
.week.intro .day:nth-child(6) .col span { animation-delay: .15s; } .week.intro .day:nth-child(7) .col span { animation-delay: .18s; }
@keyframes grow { from { transform: scaleY(0); } }

/* Bottom sheet: grabber, drag to dismiss, smooth close, page behind stays still */
html.sheet-open, html.sheet-open body { overflow: hidden; }
.sheet-bg { transition: opacity .17s ease; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.sheet-card { max-height: 92dvh; overscroll-behavior: contain; transition: transform .2s cubic-bezier(.2, .8, .2, 1); will-change: transform; }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 10px; }
.sheet.closing .sheet-bg { opacity: 0; }
.sheet.closing .sheet-card { animation: drop .17s ease-in forwards; }
@keyframes drop { to { transform: translateY(40px); opacity: 0; } }
@media (min-width: 720px) {
  .grabber { display: none; }
  .sheet.closing .sheet-card { animation: fadeout .15s ease-in forwards; }
  @keyframes fadeout { to { opacity: 0; transform: translate(-50%, -48%); } }
}
@keyframes rise { from { transform: translateY(100%); } }
.sheet-card { animation: rise .26s cubic-bezier(.2, .8, .2, 1); }
@media (min-width: 720px) { .sheet-card { animation: pop .18s cubic-bezier(.2, .8, .2, 1); } @keyframes pop { from { opacity: 0; transform: translate(-50%, -47%) scale(.98); } } }

/* Toast and update bar */
.toast { display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); transition: opacity .2s ease, transform .25s cubic-bezier(.2, .8, .2, 1); }
.toast.ok::before { content: ""; width: 16px; height: 16px; flex: none; border-radius: 50%; background: var(--jade-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 12px no-repeat; }
.updbar { position: fixed; z-index: 45; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--paper); padding: 10px 12px 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: vt-in .25s ease both; }
@media (min-width: 960px) { .updbar { left: auto; right: 28px; bottom: 28px; max-width: 420px; } }

/* Inputs: smoother focus */
input, select, .money-input, .datef { transition: border-color .15s ease, box-shadow .15s ease; }

@media (prefers-reduced-motion: reduce) { .week.intro .day .col span { animation: none; } }

/* ============================================================ app lock */
html.app-locked, html.app-locked body { overflow: hidden; }
.lock { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: #18222f; color: #eef2f6;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); }
/* No fade-in on purpose: the cover must be fully opaque at once, so the app switcher never captures your data */
.lock .lock-inner { animation: lockin .2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes lockin { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-color-scheme: dark) { .lock { background: #0f151c; } }
.lock-inner { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.lock-mark { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,.07); margin-bottom: 18px; }
.lock-mark .ic { width: 32px; height: 32px; color: var(--gold); stroke-width: 1.6; }
.lock-title { font-size: 20px; font-weight: 600; }
.lock-sub { min-height: 40px; margin-top: 6px; font-size: 14px; color: #aeb9c6; max-width: 30ch; }
.lock-sub.bad { color: #ff9b86; }
.lock-dots { display: flex; gap: 16px; margin: 10px 0 30px; }
.lock-dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid #8d99a7; transition: background-color .1s ease, border-color .1s ease, transform .1s ease; }
.lock-dots i.on { background: var(--gold); border-color: var(--gold); transform: scale(1.08); }
.lock-dots.shake { animation: shake .4s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
.lock-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 26px; }
.lock-key { width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(255,255,255,.07); color: #fff; font: 500 28px var(--f);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; transition: background-color .1s ease, transform .08s ease; }
.lock-key:active { background: rgba(255,255,255,.18); transform: scale(.94); }
.lock-key:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.lock-key.fn { background: transparent; }
.lock-key.fn .ic { width: 28px; height: 28px; }
.lock-key[data-k=bio] .ic { color: var(--gold); width: 34px; height: 34px; }
.lock-foot { margin-top: 26px; display: flex; gap: 24px; justify-content: center; }
.lock-foot .link { color: #aeb9c6; font-size: 14px; }
@media (max-height: 640px) { .lock-key { width: 64px; height: 64px; font-size: 24px; } .lock-pad { grid-template-columns: repeat(3, 64px); gap: 10px 22px; } .lock-mark { display: none; } }
.nudge { display: flex; gap: 14px; align-items: flex-start; }
.nudge b { display: block; font-weight: 600; } .nudge p { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.nudge .row-btns { margin-top: 10px; }
.row-btns.wrap { flex-wrap: wrap; margin-top: 14px; }

/* SMS paste + receipt import side by side on wider screens */
.paste-row { display: grid; gap: 8px; margin: 16px 0 4px; }
.paste-row .paste { margin: 0; }
@media (min-width: 560px) { .paste-row:has(> .paste + .paste) { grid-template-columns: 1fr 1fr; } }

/* future-dated entries */
.sched { margin-top: 14px; padding: 12px; background: var(--sav-bg); border-radius: var(--r); display: grid; gap: 10px; }
.sched[hidden] { display: none; }
.sched p { margin: 0; font-size: 13px; color: var(--ink); }

/* receipt review */
.rc-sum { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 10px; }
.rc-sum span { display: inline-flex; gap: 8px; align-items: baseline; padding: 6px 10px; background: var(--line-2); border-radius: 999px; font-size: 13px; color: var(--ink-2); }
.rc-sum b { color: var(--ink); font-weight: 600; }
.rc-list { display: grid; border-top: 1px solid var(--line-2); }
.rc-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: center; }
.rc-row .rc-name b { display: block; font-weight: 500; font-size: 13.5px; line-height: 1.3; }
.rc-row .rc-name small { color: var(--muted); font-size: 12px; }
.rc-row .rc-name em { font-style: normal; color: var(--warn); }
.rc-row .rc-amt { font-weight: 600; font-size: 14px; }
.rc-row select { grid-column: 1 / -1; margin: 0; padding: 7px 10px; font-size: 13.5px; }
.rc-row.guess select { border-color: var(--warn); }
@media (min-width: 640px) { .rc-row { grid-template-columns: 1fr 190px 72px; } .rc-row select { grid-column: 2; grid-row: 1; } .rc-row .rc-amt { grid-column: 3; text-align: right; } }
.rc-lines { margin-top: 14px; font-size: 13.5px; }
.rc-lines summary { cursor: pointer; color: var(--jade); font-weight: 500; padding: 6px 0; }
.rc-lines .kv { font-size: 13px; padding: 3px 0; }
