/* Expense family app styles. Colours come from themes/<theme>.css (same variable names). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* iOS 26 blurs about 38pt below the status bar of a Home Screen app; keep the top rows below that band. */
:root { --glass-top: 0px; }
@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) and (orientation: portrait) { :root { --glass-top: 34px; } }
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--app); color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.big { width: 24px; height: 24px; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

#app {
  max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 6px + var(--glass-top)) 18px calc(env(safe-area-inset-bottom) + 110px);
}

/* ---------- top bar ---------- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 48px; margin-bottom: 6px; }
.sync { font-size: 12.5px; line-height: 1.15; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; justify-self: start; min-height: 44px; max-width: 92px; text-align: left; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.sync.ok i { background: var(--ok); }
.sync.attn { color: var(--primary-ink); font-weight: 700; }
.sync.attn i { background: var(--primary-ink); }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav h1 { font-size: 17px; font-weight: 700; min-width: 96px; text-align: center; }
.month-btn { font: inherit; color: inherit; min-height: 44px; padding: 0 4px; white-space: nowrap; }
.month-btn.long { font-size: 15px; }
.icon-btn { width: 44px; height: 44px; margin: -5px; display: grid; place-items: center; color: var(--ink-2); border-radius: 50%; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.round-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--card); display: grid; place-items: center; color: var(--primary-ink); box-shadow: var(--shadow); }
.round-btn.soft { background: var(--app); box-shadow: none; color: var(--ink-2); justify-self: start; }
.round-btn svg { width: 18px; height: 18px; }

/* ---------- home ---------- */
.hero { background: var(--primary); color: #fff; border-radius: 22px; padding: 16px 18px; margin: 4px 0 18px; box-shadow: var(--shadow-lift); }
.hero .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero .lbl { font-size: 13px; opacity: .8; }
.hero .val { font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.hero .left { text-align: right; }
.hero .left .val { font-size: 20px; color: var(--accent); }
.hero .track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.2); margin-top: 14px; overflow: hidden; }
.hero .track i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.hero .track i.over { background: var(--over-soft); }
.hero small { display: block; margin-top: 7px; font-size: 12.5px; opacity: .85; }

.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 10px; }
.sec-head h2 { font-size: 16px; }
.sec-head span { font-size: 13px; color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { border-radius: 16px; padding: 12px 8px 11px; text-align: center; transition: transform .12s ease; }
.tile:active { transform: scale(.96); }
.tile .n { font-size: 13px; font-weight: 500; display: block; }
.tile .ic { width: 40px; height: 40px; border-radius: 50%; margin: 8px auto 7px; display: grid; place-items: center; color: #fff; }
.tile .ic svg { width: 19px; height: 19px; }
.tile .a { font-weight: 700; font-size: 15px; display: block; }
.tile .b { display: block; height: 4px; border-radius: 99px; background: var(--track); margin: 7px 6px 0; overflow: hidden; }
.tile .b i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.tile .b i.over { background: var(--over); }
.tile .b.none { visibility: hidden; }
.tile.pulse { animation: pulse .6s ease; }
@keyframes pulse { 0% { transform: scale(1); } 35% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* ---------- insights ---------- */
.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; }
.mini-ics { display: flex; gap: 6px; margin-top: 12px; }
.mini-ics span { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; }
.mini-ics svg { width: 15px; height: 15px; }
.pills { display: flex; gap: 6px; }
.pill2 { background: var(--app); border-radius: 10px; padding: 4px 9px; font-size: 11.5px; color: var(--ink-2); text-align: center; }
.pill2 b { display: block; color: var(--ink); font-size: 13px; }
.dbars { display: flex; gap: 2px; align-items: flex-end; height: 90px; }
.dbars i { flex: 1; border-radius: 3px; background: var(--chart); min-height: 3px; }
.dbars i.zero, .dbars i.future { background: var(--mist); }
.dbars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head h2 { font-size: 15px; }
.card-head span { font-size: 12.5px; color: var(--ink-2); }
.donut-row { display: flex; gap: 14px; align-items: center; }
.donut { position: relative; flex: none; width: 128px; height: 128px; }
.donut svg { transform: rotate(-90deg); display: block; }
.donut circle { cursor: pointer; transition: stroke-opacity .2s ease, stroke-width .2s ease; }
.donut-c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-c b { font-size: 16px; }
.donut-c small { font-size: 11.5px; color: var(--ink-2); max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { flex: 1; display: grid; gap: 2px; font-size: 13px; min-width: 0; }
.legend button { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; text-align: left; min-height: 40px; border-radius: 9px; padding: 2px 6px 2px 2px; }
.legend button.on { background: var(--app); font-weight: 700; }
.legend .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.legend .ic svg { width: 12px; height: 12px; }
.legend em { font-style: normal; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend em small { display: inline-block; min-width: 4ch; margin-left: 6px; text-align: right; font-size: inherit; }
.empty { text-align: center; color: var(--ink-2); padding: 36px 16px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- history ---------- */
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin: 16px 4px 6px; }
.day-head:first-child { margin-top: 4px; }
.day-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 2px 14px; }
.tx { display: grid; grid-template-columns: 36px minmax(0, 5.9em) minmax(2.5em, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; width: 100%; text-align: left; min-height: 56px; }
.tx + .tx { border-top: 1px solid var(--hair); }
.tx .ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.tx .ic svg { width: 17px; height: 17px; }
.tx b { font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .note { color: var(--ink-2); font-size: 14px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.tx .amt { font-weight: 700; }

/* ---------- tab bar ---------- */
/* Content fades out above the bar instead of scrolling behind it. */
#app::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; pointer-events: none;
  height: calc(env(safe-area-inset-bottom) + 112px);
  background: linear-gradient(to bottom, transparent, var(--app) 42%);
}
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 36px); max-width: 444px; height: 64px; z-index: 10;
  background: var(--card);
  border-radius: 32px; box-shadow: var(--shadow-bar);
  display: flex; justify-content: space-around; align-items: center; padding: 0 6px;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--tab-off); padding: 7px 12px; border-radius: 22px; min-width: 64px; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--primary-ink); background: var(--accent-soft); }

/* ---------- sheets ---------- */
/* Coloured only while shown: iPhone Safari tints the status bar from full-screen layers, even invisible ones. */
.backdrop { position: fixed; inset: 0; background: transparent; visibility: hidden; opacity: 0; pointer-events: none; transition: opacity .25s ease, background-color .25s ease, visibility 0s linear .25s; z-index: 20; }
.backdrop.show { background: var(--backdrop); visibility: visible; opacity: 1; pointer-events: auto; transition: opacity .25s ease; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 480px; z-index: 30;
  background: var(--card); border-radius: 26px 26px 0 0; display: flex; flex-direction: column;
  transform: translate(-50%, 105%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: env(safe-area-inset-bottom); visibility: hidden;
}
.sheet.open { transform: translate(-50%, 0); visibility: visible; }
.sheet.small { max-height: calc(100% - env(safe-area-inset-top) - 24px - var(--glass-top)); }
.sheet.small .sheet-body { overflow-y: auto; }
.sheet.entry { top: calc(env(safe-area-inset-top) + 44px); overflow-y: auto; overscroll-behavior: contain; }
.sheet.entry > :not(.cat-pick) { flex-shrink: 0; } /* never squash a part; scroll instead */
/* Short screens (iPhone SE and smaller): a tighter pop-up so the keypad and Save fit. */
@media (max-height: 700px) {
  .sheet.entry { top: calc(env(safe-area-inset-top) + max(10px, var(--glass-top))); }
  .sheet.entry .amount { font-size: 44px; margin-bottom: 8px; padding-top: 2px; }
  .sheet.entry .amount .cur { font-size: 24px; vertical-align: 14px; }
  .sheet.entry .sub-strip { margin-bottom: 8px; }
  .sheet.entry .note-pill, .sheet.entry .note-input { margin-bottom: 10px; }
  .sheet.entry .split { min-height: 40px; }
  .sheet.entry .keypad { margin-top: 10px; padding: 8px 10px 10px; gap: 6px; }
  .sheet.entry .keypad button { height: 46px; }
  .sheet.entry .split.none { display: none; }
}
@media (max-height: 600px) {
  .sheet.entry .amount { font-size: 38px; margin-bottom: 6px; }
  .sheet.entry .keypad button { height: 44px; }
}
.grab { width: 38px; height: 5px; border-radius: 9px; background: var(--hair); margin: 8px auto 0; flex: none; }
.sheet-head { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; padding: 10px 18px 0; }
.sheet-head h2 { font-size: 17px; text-align: center; }
.entry-title { display: flex; justify-content: center; gap: 8px; align-items: center; }
.entry-title .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.entry-title .ic svg { width: 15px; height: 15px; }
.round-btn.danger { color: var(--over-ink); justify-self: end; }
/* Changing an entry: one button for category + subcategory, opening the full list */
.cat-pick-btn { flex: none; align-self: center; display: flex; align-items: center; gap: 9px; max-width: calc(100% - 36px); margin: 14px auto 0; padding: 6px 12px 6px 6px; min-height: 48px; border-radius: 999px; background: var(--app); font-size: 15px; }
.cat-pick-btn .ic { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.cat-pick-btn .ic svg { width: 17px; height: 17px; }
.cat-pick-btn b { font-weight: 600; white-space: nowrap; }
.cat-pick-btn .cp-sub { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-pick-btn .cp-sub::before { content: "·"; margin-right: 9px; }
.cat-pick-btn > svg:last-child { width: 16px; height: 16px; color: var(--ink-2); transform: rotate(90deg); }
.sheet.entry.picking > :not(.grab):not(.sheet-head):not(.cat-pick) { display: none !important; }
.cat-pick { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 0 0; }
.cp-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 18px 8px; }
.cp-head b { font-size: 15px; }
.cp-head .link-btn { min-height: 44px; padding: 0 8px; margin-right: -8px; }
.cp-list { flex: 1; overflow-y: auto; padding: 0 18px 18px; }
.cp-group { padding: 10px 0; }
.cp-group + .cp-group { border-top: 1px solid var(--hair); }
.cp-cat { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 14px 4px 4px; border-radius: 999px; font-weight: 600; font-size: 15px; }
.cp-cat .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.cp-cat .ic svg { width: 16px; height: 16px; }
.cp-cat.on { background: var(--primary); color: #fff; }
.cp-subs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0 46px; }
.cp-subs .sub { min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--app); font-size: 14px; font-weight: 600; color: var(--ink); }
.cp-subs .sub.on { background: var(--primary); color: #fff; }

.amount { text-align: center; margin: auto 0 14px; padding-top: 8px; font-size: 56px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.amount .cur { font-size: 30px; color: var(--ink-2); vertical-align: 18px; margin-right: 2px; font-weight: 500; }
.amount .dim { color: var(--dim); }
.amount .caret { display: inline-block; width: 2px; height: .8em; background: var(--primary); vertical-align: -.05em; margin-left: 3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.note-pill { display: block; margin: 0 auto 22px; max-width: calc(100% - 36px); min-height: 40px; background: var(--app); border-radius: 999px; padding: 8px 16px; font-size: 14.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-pill b { color: var(--primary-ink); font-weight: 600; }
.note-input { display: block; margin: 0 auto 22px; width: calc(100% - 36px); border: 1.5px solid var(--primary-ink); background: var(--card); border-radius: 999px; padding: 9px 16px; font: inherit; font-size: 16px; color: var(--ink); text-align: center; }
.split { display: flex; margin: 0 18px auto; white-space: nowrap; border-radius: 12px; overflow: hidden; min-height: 46px; font-size: 12.5px; }
.split div { padding: 6px 10px; display: flex; flex-direction: column; justify-content: center; }
.split .s { background: var(--primary-2); color: #fff; }
.split .s.over { background: var(--over); }
.split .l { background: var(--ok-soft); color: var(--ink); flex: 1; text-align: right; }
.split b { font-size: 14px; }
.split.none { visibility: hidden; }

.keypad { background: var(--app); margin-top: 18px; padding: 10px 12px 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad button { height: 54px; border-radius: 13px; background: var(--card); display: grid; place-items: center; font-size: 22px; font-weight: 500; box-shadow: 0 1px 1px rgba(38,51,47,.06); position: relative; }
.keypad button:active { background: var(--mist); }
.keypad .fn { font-size: 12.5px; font-weight: 600; color: var(--primary-ink); background: var(--accent-soft); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.keypad .fn svg { width: 18px; height: 18px; }
.keypad .save { background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; }
.keypad .save:disabled { opacity: .45; cursor: default; }

.sheet.small .sheet-body { padding: 14px 20px 22px; }
.sheet-body h2 { font-size: 18px; margin-bottom: 6px; }
.sheet-body h3 { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 16px 0 8px; }
.sheet-body h3:first-child { margin-top: 4px; }
.sheet-body p { margin: 0 0 8px; line-height: 1.45; }
.themes { display: flex; gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 8px; padding: 9px 14px 9px 9px; border-radius: 999px; background: var(--app); font-weight: 600; }
.theme-opt i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(128, 128, 128, .45); }
.theme-opt[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--primary-ink); }
.row-btn { display: block; width: 100%; text-align: center; padding: 14px; border-radius: 14px; background: var(--app); font-weight: 600; color: var(--primary-ink); margin-top: 8px; }
.primary-btn { display: block; width: 100%; text-align: center; padding: 14px; min-height: 48px; border-radius: 14px; background: var(--primary); color: #fff; font-weight: 700; margin-top: 12px; }
.primary-btn:disabled, .row-btn:disabled { opacity: .55; cursor: default; }
.sheet-link { color: var(--primary-ink); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.trust { list-style: none; padding: 0; margin: 8px 0 10px; }
.trust li { display: flex; gap: 12px; padding: 10px 0; line-height: 1.45; border-top: 1px solid var(--hair); }
.trust li:first-child { border-top: 0; }
.trust .ic { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--ok-soft); color: var(--primary-ink); display: grid; place-items: center; }
.trust .ic svg { width: 17px; height: 17px; }
.danger-btn { display: block; width: 100%; text-align: center; padding: 14px; border-radius: 14px; background: var(--danger); color: var(--on-danger); font-weight: 700; margin-top: 14px; }

.blocked { position: fixed; inset: 0; z-index: 60; background: var(--app); display: grid; place-content: center; text-align: center; padding: 24px; color: var(--ink-2); line-height: 1.5; }
.blocked b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.blocked .primary-btn, .blocked .row-btn { max-width: 320px; margin-left: auto; margin-right: auto; }
.blocked small { display: block; max-width: 320px; margin: 14px auto 0; font-size: 12.5px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--toast-bg); color: var(--toast-ink); border-radius: 14px; padding: 11px 12px 11px 16px; display: flex; gap: 14px; align-items: center;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 55; max-width: calc(100% - 36px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.show button { pointer-events: auto; } /* only the action button takes taps */
.toast.top { bottom: auto; top: calc(12px + env(safe-area-inset-top) + var(--glass-top)); transform: translate(-50%, -20px); }
.toast.top.show { transform: translate(-50%, 0); }
.toast button { color: var(--toast-action); font-weight: 700; padding: 4px 6px; }

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

/* ---------- top bar actions, banners, sheet card ---------- */
.top-actions { display: flex; gap: 8px; justify-self: end; }
.round-btn { width: 40px; height: 40px; }
.demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--accent-soft); border-radius: 14px; padding: 8px 8px 8px 14px; margin: 2px 0 12px; font-size: 13.5px; }
.demo-banner button { background: var(--primary); color: #fff; font-weight: 700; border-radius: 10px; padding: 9px 12px; min-height: 40px; white-space: nowrap; }
.hero { cursor: pointer; }
.hero .set-budget { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.sheet-card { display: grid; grid-template-columns: 44px 1fr 22px; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.sheet-card .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--ok-soft); color: var(--primary-ink); display: grid; place-items: center; }
.sheet-card b { display: block; font-size: 15px; }
.sheet-card small { color: var(--ink-2); font-size: 12.5px; }
.sheet-card > svg { color: var(--ink-2); }

/* ---------- settings rows ---------- */
#settings-sheet { background: var(--app); }
#settings-sheet .grab { background: var(--dim); }
.group { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.group > * + * { border-top: 1px solid var(--hair); }
.group.pad, .group .pad { padding: 14px; }
.group .pad .primary-btn { margin-top: 0; }
.set-row { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 16px; text-align: left; font-weight: 600; }
.set-row.danger { color: var(--over-ink); }
.group.leave { margin-top: 28px; }
.caption { margin: 8px 4px 0; line-height: 1.4; }
.build { text-align: center; margin: 22px 0 4px; }
.group .themes { padding: 10px; }
.gs-status { position: relative; padding: 14px 16px; margin: 0; line-height: 1.45; }
/* The dot sits in its own space on the left, centred on the first line of text. */
.gs-status.with-dot { padding-left: 34px; }
.gs-status .dot { position: absolute; left: 16px; top: calc(14px + (1.45em - 8px) / 2); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.gs-status .dot.ok { background: var(--ok); }
.gs-status .dot.attn { background: var(--over); }
.group.pad .gs-status { padding: 0 0 4px; }
.set-row span { flex: 1; }
.set-row em { font-style: normal; font-weight: 500; color: var(--ink-2); font-size: 14px; }
.set-row > svg { color: var(--ink-2); width: 18px; height: 18px; }
.gs-status { font-size: 14px; }
.gs-status b { color: var(--ink); }
.link-btn { color: var(--primary-ink); font-weight: 600; text-align: left; padding: 6px 0; min-height: 36px; }

/* ---------- budgets ---------- */
.bud-row { display: grid; grid-template-columns: 32px 1fr 128px; gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid var(--hair); }
.bud-row:first-of-type { border-top: 0; }
.bud-row .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.bud-row .ic svg { width: 16px; height: 16px; }
.money-in { display: flex; align-items: center; gap: 2px; background: var(--app); border-radius: 10px; padding: 0 10px; border: 1px solid transparent; }
.money-in:focus-within { border-color: var(--primary-ink); }
.money-in i { font-style: normal; color: var(--ink-2); }
.money-in:has(input[placeholder="None"]:placeholder-shown) i { display: none; }
.money-in input { width: 100%; border: 0; background: none; font: inherit; font-size: 17px; color: var(--ink); padding: 11px 0; text-align: left; outline: none; }
.money-in input::placeholder { color: var(--ink-2); font-size: 14px; }
.bud-total { display: flex; justify-content: space-between; margin-top: 10px; font-weight: 700; }

/* ---------- first-run setup ---------- */
.onboard { position: fixed; inset: 0; z-index: 50; background: var(--app); overflow-y: auto; }
.ob { max-width: 480px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + max(28px, var(--glass-top) + 6px)) 24px calc(env(safe-area-inset-bottom) + 24px); }
.ob-dots { display: flex; gap: 6px; margin-bottom: 22px; }
.ob-dots i { width: 22px; height: 5px; border-radius: 9px; background: var(--hair); }
.ob-dots i.on { background: var(--primary-ink); }
.ob-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow-lift); margin: 8vh auto 22px; display: block; }
.ob h1 { font-size: 27px; line-height: 1.2; margin-bottom: 10px; }
.ob-logo.small { width: 64px; height: 64px; border-radius: 17px; margin-top: 3vh; margin-bottom: 16px; }
.ob-sub { font-size: 19px; margin: 18px 0 2px; }
@media (max-height: 700px) {
  .ob-logo.small { width: 48px; height: 48px; border-radius: 13px; margin: 0 auto 10px; }
  .ob-logo.small ~ .center h1 { font-size: 24px; margin-bottom: 6px; }
  .ob-logo.small ~ .ob-steps li { padding: 8px 0; }
  .ob-logo.small ~ .ob-note { padding: 10px 12px; }
  .ob-logo.small ~ .ob-actions { padding-top: 10px; }
  .ob-logo.small ~ .ob-actions .row-btn { padding: 12px; }
}
.ob .center { text-align: center; }
.ob p { color: var(--ink-2); line-height: 1.5; margin: 0 0 12px; font-size: 16px; }
.ob-actions { margin-top: auto; padding-top: 20px; }
.ob-steps { list-style: none; padding: 0; margin: 10px 0 14px; counter-reset: s; }
.ob-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--hair); font-size: 16px; line-height: 1.4; }
.ob-steps li:first-child { border-top: 0; }
.ob-steps li::before { counter-increment: s; content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--primary-ink); font-weight: 700; display: grid; place-items: center; }
.ob-steps svg { width: 19px; height: 19px; vertical-align: -4px; color: var(--primary-ink); }
.ob-note { background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: var(--ink-2); box-shadow: var(--shadow); }
.ob-error { background: var(--card); border-left: 4px solid var(--over); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14.5px; line-height: 1.45; }
.ob .primary-btn[aria-busy="true"]::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 10px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- insights: category detail ---------- */
.bar { height: 7px; border-radius: 99px; background: var(--mist); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.bar i.over { background: var(--over); }
.over { color: var(--over); }
.cat-detail { border-top: 1px solid var(--hair); margin-top: 14px; padding-top: 12px; }
.cd-head { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; }
.cd-head .ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.cd-head .ic svg { width: 15px; height: 15px; }
.cd-head .amt { font-weight: 700; font-size: 17px; }
.cd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.cd-stats div { background: var(--app); border-radius: 10px; padding: 6px 9px; }
.cd-stats small, .cd-bud { color: var(--ink-2); font-size: 12px; display: block; }
.cd-stats b { font-size: 14px; }
.cd-bud { margin-top: 5px; }

/* ---------- budget tab ---------- */
.bud-main { display: grid; gap: 8px; padding: 16px 18px; }
.bud-main .k { color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.money-in.total { border-radius: 14px; padding: 0 14px; gap: 4px; }
.money-in.total i { font-size: 22px; font-weight: 600; color: var(--primary-ink); }
.money-in.total input { font-size: 30px; font-weight: 700; color: var(--primary-ink); letter-spacing: -.01em; padding: 8px 0; }
.money-in.total input::placeholder { font-size: inherit; font-weight: 600; color: var(--ink-2); }
.money-in.total input[placeholder="None"]::placeholder { font-size: 20px; font-weight: 500; }
.bud-cats { padding: 4px 14px; }
.bud-cats .bud-row:first-child { border-top: 0; }
.ob .card { box-shadow: var(--shadow); }

/* ---------- expenses tab ---------- */
/* ---------- month sheet ---------- */
#month-sheet { background: var(--app); }
#month-sheet .grab { background: var(--dim); }
.year-nav { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 0 0 10px; font-size: 17px; }
.year-nav .icon-btn { width: 44px; height: 44px; }
.months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mo { display: grid; gap: 2px; justify-items: center; padding: 10px 4px; min-height: 60px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.mo b { font-size: 16px; font-weight: 600; }
.mo small { font-size: 12.5px; color: var(--ink-2); min-height: 1.2em; }
.mo.now { box-shadow: inset 0 0 0 1.5px var(--primary-ink); }
.mo.on { background: var(--primary); color: #fff; box-shadow: var(--shadow-lift); }
.mo.on small { color: rgba(255, 255, 255, .85); }
.mo:disabled { background: transparent; box-shadow: none; color: var(--dim); cursor: default; }
.set-row > svg { flex: none; }
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.range-row label { display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.range-row input { font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--hair); border-radius: 10px; padding: 9px 10px; min-height: 44px; width: 100%; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -18px 10px; padding: 2px 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600; }
.chips button i { width: 9px; height: 9px; border-radius: 50%; }
.chips button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.x-chart .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.x-chart .top small { color: var(--ink-2); font-size: 12.5px; display: block; }
.x-chart .big { font-size: 22px; }
.x-chart .top:last-child { margin-bottom: 0; }
.bud-more { margin-top: 14px; }
.bud-more summary { cursor: pointer; font-weight: 600; color: var(--primary-ink); min-height: 44px; display: flex; align-items: center; list-style: none; }
.bud-more summary::-webkit-details-marker { display: none; }
.bud-more summary::after { content: "›"; margin-left: 8px; font-size: 20px; transition: transform .2s ease; }
.bud-more[open] summary::after { transform: rotate(90deg); }

/* ---------- home: tiles read as "add" buttons ---------- */
.hero { padding: 14px 18px; margin-bottom: 20px; }
.hero .val { font-size: 27px; }
.add-head h2 { font-size: 18px; }
.add-head span { color: var(--primary-ink); font-weight: 600; }
.tile { box-shadow: var(--shadow); }
.tile .ic { position: relative; }
.tile .plus { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); color: var(--primary-ink);
  font-size: 16px; line-height: 19px; font-weight: 700; text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.tile .a { font-size: 13px; font-weight: 600; color: color-mix(in srgb, var(--ink) 50%, var(--ink-2)); } /* readable on every pastel tile */

.amt.in, .tx .amt.in { color: var(--primary-ink); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin-bottom: 10px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.seg button { min-height: 42px; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.x-catchips { margin-bottom: 12px; }
.x-catchips button { box-shadow: inset 0 0 0 1px var(--hair); background: transparent; font-weight: 500; color: var(--ink); }
.x-catchips button[aria-pressed="true"] { box-shadow: none; }
.x-catchips button { min-height: 40px; }
.io-bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 96px; }
.io-bars .m { display: flex; gap: 3px; align-items: end; justify-content: center; height: 100%; }
.io-bars i { width: 12px; border-radius: 4px 4px 2px 2px; background: var(--ok); min-height: 3px; }
.io-bars i.out { background: var(--primary); }
.io-x { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; text-align: center; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.io-key { display: flex; justify-content: center; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 10px; }
.io-key i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--ok); margin-right: 5px; }
.io-key i.out { background: var(--primary); }
.dbars i.in { background: var(--ok); }
.income-head { margin-top: 22px; }
.tiles.income { grid-template-columns: 1fr 1fr; }
.tile.wide { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; }
.tile.wide .ic { margin: 0; }
.tile.wide .n { font-size: 14px; }
.tile.wide .a { margin-top: 2px; }
/* Chart cards share one header; a tapped bar is named in it */
.card-head .pick { font-variant-numeric: tabular-nums; }
.dbars[data-pick], .io-bars { cursor: pointer; }
/* The bar being looked at is full colour, the others a little lighter: the month shown (its name in a pill), and in
   Daily only a tapped day. A dot marks today or the tapped day; axis numbers next to it step aside. */
.dbars.picked i:not(.sel):not(.future):not(.zero), .io-bars .m:not(.sel) i { opacity: .75; }
.io-bars i.one { width: 20px; }
.io-x span.on { background: var(--primary); color: #fff; font-weight: 700; border-radius: 999px; padding: 2px 0; margin: -2px 4px; }
.dbars-x.marked { position: relative; height: 15px; }
.dbars-x.marked > span { position: absolute; transform: translateX(-50%); }
.dbars-x.marked > span.first { transform: none; }
.dbars-x.marked > span.last { transform: translateX(-100%); }
.dbars-x .mark { top: -3px; display: flex; flex-direction: column; align-items: center; color: var(--primary-ink); white-space: nowrap; }
.dbars-x .mark i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-bottom: 1px; }
.dbars-x .mark b { font-size: 11px; line-height: 1; font-weight: 400; }
.dbars-x.marked > .mark.edge-l { transform: translateX(-3px); align-items: flex-start; }
.dbars-x.marked > .mark.edge-r { transform: translateX(calc(-100% + 3px)); align-items: flex-end; }

/* What Insights is narrowed to (a day, a category): tap a chip to clear it */
.focus { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -6px 0 14px; font-size: 13px; color: var(--ink-2); }
.focus button { display: inline-flex; gap: 6px; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--primary-ink); font-weight: 600; font-size: 13.5px; }
.focus button b { font-size: 16px; line-height: 1; }

/* Compared with: each category against last month or last year */
.cmp .seg { grid-template-columns: repeat(2, 1fr); margin: 0 0 6px; box-shadow: none; background: var(--app); }
.cmp .seg button { min-height: 40px; font-size: 13.5px; }
.cmp .when { font-size: 12.5px; color: var(--ink-2); margin: 0 0 6px; text-align: center; }
.cmp .rows { display: grid; }
.cmp .r { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 50px; width: 100%;
  text-align: left; padding: 0 6px 0 2px; border-radius: 10px; border-top: 1px solid var(--hair); }
.cmp .r:first-child { border-top: 0; }
.cmp .r .nm { min-width: 0; line-height: 1.25; }
.cmp .r .nm > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp .r.on { background: var(--app); font-weight: 700; }
.cmp .r.total { font-weight: 700; }
.cmp .r .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.cmp .r .ic svg { width: 13px; height: 13px; }
.cmp .r .ic.all { background: var(--primary); }
.cmp .r .nm small { display: block; color: var(--ink-2); font-size: 12.5px; font-weight: 400; font-variant-numeric: tabular-nums; }
.cmp .chg { min-width: 92px; text-align: center; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 4px 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmp .chg.up { background: var(--app); color: var(--ink); }
.cmp .chg.down { background: var(--ok-soft); color: var(--primary-ink); }
.cmp .chg.same, .cmp .chg.new { background: var(--app); color: var(--ink-2); font-weight: 600; }
.cmp .more { display: block; width: 100%; min-height: 44px; color: var(--primary-ink); font-weight: 600; font-size: 13.5px; margin-top: 4px; }

/* ---------- categories ---------- */
.side-sheet { background: var(--app); }
.side-sheet .grab { background: var(--dim); }
.add-head .link-btn { min-height: 44px; min-width: 44px; margin: -6px 0; padding: 4px 6px; font-size: 14px; text-align: center; }
.ce-top { display: flex; align-items: center; gap: 12px; }
.ce-top .ic { flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.ce-top .ic svg { width: 22px; height: 22px; }
.ce-top input { flex: 1; min-width: 0; font: inherit; font-size: 18px; font-weight: 600; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--hair); border-radius: 14px; padding: 12px 14px; }
.ce-top input:focus { border-color: var(--primary-ink); outline: none; }
.ce-top input:disabled { color: var(--ink-2); }
.ce-error { color: var(--over-ink); font-weight: 600; margin: 10px 2px 0; }
.ce-note { margin: 8px 2px 0; }
.ce-icons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ce-icons button { height: 48px; border-radius: 12px; background: var(--card); color: var(--ink-2); display: grid; place-items: center; box-shadow: var(--shadow); }
.ce-icons button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.ce-colours { display: flex; flex-wrap: wrap; gap: 10px; }
.ce-colours button { width: 40px; height: 40px; border-radius: 50%; }
.ce-colours button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--app), 0 0 0 5px var(--primary-ink); }
.cat-row .ic { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.cat-row .ic svg { width: 16px; height: 16px; }
.add-row { color: var(--primary-ink); }
.cats-intro { margin: 0 2px 4px; }
.head-links { display: flex; gap: 16px; }
.add-head .head-links .link-btn { font-weight: 500; color: var(--ink-2); }
.danger-text { color: var(--over-ink); }
.swipe { position: relative; overflow: hidden; }
.swipe-del { position: absolute; top: 0; right: 0; bottom: 0; width: 88px; z-index: 1; background: var(--danger); color: var(--on-danger); font-weight: 700;
  transform: translateX(100%); transition: transform .2s ease; }
.swipe.open .swipe-del { transform: translateX(0); }
.swipe .cat-row { touch-action: pan-y; }
/* ---------- calendar ---------- */
.calendar { background: var(--app); margin-top: 18px; padding: 8px 12px 14px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-head b { font-size: 16px; }
.cal-head .icon-btn { width: 44px; height: 44px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-week span { text-align: center; font-size: 12px; color: var(--ink-2); padding: 2px 0 4px; }
.cal-grid button { height: 40px; border-radius: 12px; background: var(--card); font-size: 16px; font-weight: 500; color: var(--ink); }
.cal-grid button.today { box-shadow: inset 0 0 0 1.5px var(--primary-ink); }
.cal-grid button.on { background: var(--primary); color: #fff; }
.cal-grid button:disabled { background: transparent; color: var(--dim); }
.cal-foot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.cal-foot button { height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--primary-ink); font-weight: 600; font-size: 14px; }
/* ---------- subcategories ---------- */
.sub-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; margin: 0 0 12px; flex: none; justify-content: center; min-height: 40px; }
.sub-strip .sub { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--app); font-size: 14px; font-weight: 600; color: var(--ink); }
.sub-strip .sub.on { background: var(--primary); color: #fff; }
.sub-strip .sub.add { background: none; color: var(--primary-ink); box-shadow: inset 0 0 0 1.5px var(--hair); }
.sub-input { flex: 1; max-width: 320px; min-height: 40px; font: inherit; font-size: 15px; color: var(--ink); background: var(--card); border: 1.5px solid var(--primary-ink); border-radius: 999px; padding: 0 16px; outline: none; }
.tx .note em { font-style: normal; font-weight: 600; color: var(--ink); }
.cd-subs { margin-top: 12px; }
.cd-subs h3 { font-size: 12.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.cd-sub { display: grid; grid-template-columns: minmax(0, 7.5em) 1fr auto; gap: 10px; align-items: center; min-height: 30px; font-size: 14px; }
.cd-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-sub i { height: 6px; border-radius: 9px; background: var(--track); overflow: hidden; }
.cd-sub i b { display: block; height: 100%; border-radius: 9px; }
.cd-sub em { font-style: normal; font-weight: 600; text-align: right; }
.cd-sub em small { color: var(--ink-2); font-weight: 400; font-size: 12.5px; margin-left: 6px; display: inline-block; min-width: 2.6em; }
.ce-subs { display: grid; gap: 8px; }
.ce-sub { display: grid; grid-template-columns: 1fr 44px; gap: 6px; align-items: center; }
.ce-sub input { min-width: 0; min-height: 46px; font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1.5px solid var(--hair); border-radius: 12px; padding: 0 12px; }
.ce-sub input:focus { border-color: var(--primary-ink); outline: none; }
.ce-sub .icon-btn { width: 44px; height: 44px; }
.ce-sub.add input { border-style: dashed; }
.ce-sub.add .icon-btn { color: var(--primary-ink); }
.sheet-body h3 .muted { font-weight: 400; margin-left: 6px; }
/* Suggestions: "+ New" in the keypad, and under "Add a subcategory" in the editor */
.sub-strip .sub.sug { background: var(--accent-soft); color: var(--primary-ink); }
.sub-strip .sub.close { width: 40px; padding: 0; display: grid; place-items: center; color: var(--ink-2); }
.sub-strip .sub.close svg { width: 16px; height: 16px; }
.ce-sug { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.ce-sug > span { width: 100%; margin: 0 2px 2px; }
.ce-sug button { min-height: 40px; padding: 0 13px; border-radius: 999px; background: var(--accent-soft); color: var(--primary-ink); font-size: 14px; font-weight: 600; }

/* ---------- subcategory visuals (only when there is subcategory data) ---------- */
.sbar { display: flex; gap: 2px; height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.sbar i { display: block; height: 100%; min-width: 3px; flex: none; }
.sbar.over { box-shadow: 0 0 0 1.5px var(--over); }
.x-subs .card-head .link-btn { font-size: 13.5px; min-height: 32px; }
.x-subs .sbar { margin: 2px 0 10px; }
.sub-rows { display: grid; gap: 2px; }
.sub-rows button { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; min-height: 40px; border-radius: 9px; padding: 2px 6px 2px 2px; font-size: 14px; }
.sub-rows button.on { background: var(--app); font-weight: 700; }
.sub-rows .dot { grid-column: 1; grid-row: 1; width: 11px; height: 11px; border-radius: 50%; justify-self: center; }
.sub-rows span { grid-column: 2; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-rows em { grid-column: 3; grid-row: 1; font-style: normal; color: var(--ink-2); white-space: nowrap; }
.sub-rows em small { display: inline-block; min-width: 4ch; margin-left: 6px; text-align: right; font-size: inherit; }
.xc-subs { margin: 4px 0 8px 30px; }
.xc-subs .sbar { height: 8px; margin: 2px 6px 6px 2px; }
.xc-subs .sub-rows button { min-height: 34px; font-size: 13.5px; }
.xc-subs .link-btn { font-size: 13px; min-height: 30px; margin-left: 2px; }

/* ---------- budgets: amounts, then boxes with Cancel + Save ---------- */
.bud-val { justify-self: end; font-weight: 600; padding-right: 4px; }
.bud-val.none { color: var(--ink-2); font-weight: 400; }
.bud-main .bud-val { justify-self: start; font-size: 30px; font-weight: 700; color: var(--primary-ink); letter-spacing: -.01em; padding: 0; }
.bud-main .bud-val.none { font-size: 22px; font-weight: 600; color: var(--ink-2); }
.bud-act p { margin: 0 0 10px; line-height: 1.4; }
.bud-check { grid-column: 1 / -1; font-size: 13px; line-height: 1.35; color: var(--over-ink); font-weight: 600; }
.bud-bar { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 92px); z-index: 11; display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
  margin-top: 14px; padding: 10px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-bar); }
.bud-bar .row-btn, .bud-bar .primary-btn { margin: 0; }

/* ---------- calendar tab ---------- */
.cal-tab { padding: 14px 12px 12px; }
.cal-sum { display: flex; gap: 24px; padding: 0 4px 12px; }
.cal-sum small { display: block; font-size: 12.5px; color: var(--ink-2); }
.cal-sum b { font-size: 20px; font-weight: 700; }
.cal-sum b.in { color: var(--primary-ink); }
.cal-month { gap: 4px; }
.cday { min-height: 58px; border-radius: 12px; background: var(--app); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 1px 4px; gap: 1px; overflow: hidden; }
.cday b { font-size: 14px; font-weight: 600; line-height: 1.2; }
.cday span { font-size: 11px; line-height: 1.25; font-weight: 600; white-space: nowrap; color: var(--ink); }
.cday span.in { color: var(--primary-ink); }
.cday.l3 span.in, .cday.l4 span.in { color: var(--ink); } /* green on the darkest shades is too faint */
.cday.l1 { background: color-mix(in srgb, var(--ok) 12%, var(--card)); }
.cday.l2 { background: color-mix(in srgb, var(--ok) 24%, var(--card)); }
.cday.l3 { background: color-mix(in srgb, var(--ok) 38%, var(--card)); }
.cday.l4 { background: color-mix(in srgb, var(--ok) 54%, var(--card)); }
.cal-month .cday.on { background: var(--primary); color: #fff; }
.cal-month .cday.on span { color: #fff; }
.cal-month .cday:disabled { background: transparent; color: var(--dim); }
.cal-day { margin-top: 6px; }
.cal-day .empty { padding: 24px 16px; }

/* Five tabs on a phone */
.tab { padding: 7px 8px; min-width: 60px; }

/* ---------- computer screens: sidebar, wider content, dialogs instead of bottom sheets ---------- */
.side-brand, .x-cats { display: none; }
@media (min-width: 960px) {
  #app { max-width: none; margin: 0 0 0 232px; padding: 18px 40px 48px; }
  #app > .topbar, #app > .view { max-width: 1040px; margin-left: auto; margin-right: auto; }
  #app::after { display: none; }
  .topbar { margin-bottom: 14px; }

  .tabbar {
    left: 0; top: 0; bottom: 0; transform: none; width: 232px; max-width: none; height: auto;
    border-radius: 0; box-shadow: none; border-right: 1px solid var(--hair);
    flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 4px; padding: 24px 14px;
  }
  .side-brand { display: block; font-size: 19px; font-weight: 700; color: var(--ink); padding: 8px 14px 22px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 14px; font-size: 15px; }
  .tab:hover:not(.on) { background: var(--app); color: var(--ink); }

  .tiles { grid-template-columns: repeat(5, 1fr); gap: 12px; }
  .tiles.income { grid-template-columns: repeat(4, 1fr); }
  .income-head { margin-top: 28px; }

  #view-insights:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr; gap: 16px; align-items: start; }
  #view-insights > * { margin: 0; }
  /* Left: budget, Daily, Income vs expenses; right: By category; then Compared with and the sheet across.
     The chips (when something is picked) go across the top. */
  #view-insights:not([hidden]) { grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas: "hero cat" "daily cat" "inout cat" "cmp cmp" "sheet sheet"; }
  #view-insights:not([hidden]):has(#in-out[hidden]) { grid-template-areas: "hero cat" "daily cat" "daily cat" "cmp cmp" "sheet sheet"; }
  #view-insights:not([hidden]):has(#focus:not([hidden])) { grid-template-rows: auto auto auto 1fr auto auto;
    grid-template-areas: "focus focus" "hero cat" "daily cat" "inout cat" "cmp cmp" "sheet sheet"; }
  #view-insights:not([hidden]):has(#focus:not([hidden])):has(#in-out[hidden]) {
    grid-template-areas: "focus focus" "hero cat" "daily cat" "daily cat" "cmp cmp" "sheet sheet"; }
  #focus { grid-area: focus; }
  #hero { grid-area: hero; }
  #daily { grid-area: daily; }
  #in-out { grid-area: inout; }
  #by-category { grid-area: cat; align-self: stretch; }
  #compare { grid-area: cmp; }
  #compare .rows { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; }
  #compare .r:nth-child(2) { border-top: 0; }
  #compare .seg { max-width: 320px; margin: 0 auto 6px; }
  #by-category .donut-row { flex-direction: column; align-items: stretch; gap: 22px; padding-top: 12px; }
  #by-category .donut { width: 184px; height: 184px; margin: 0 auto; }
  #by-category .donut svg { width: 100%; height: 100%; }
  #by-category .donut-c b { font-size: 24px; }
  #by-category .donut-c small { font-size: 13px; max-width: 120px; }
  #by-category .legend { font-size: 15px; gap: 2px; }
  #by-category .legend button { min-height: 38px; grid-template-columns: 26px 1fr auto; gap: 10px; }
  #by-category .legend .ic { width: 26px; height: 26px; }
  #by-category .legend button > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #sheet-card { grid-area: sheet; }
  /* The last card on the left grows to the height of By category; its bars grow with it. */
  #in-out, #view-insights:has(#in-out[hidden]) #daily { align-self: stretch; display: flex; flex-direction: column; }
  #in-out .io-bars { flex: 1; height: auto; min-height: 96px; max-height: 200px; margin-top: auto; }
  #in-out .io-key { margin-bottom: auto; }
  #view-insights:has(#in-out[hidden]) #daily .dbars { flex: 1; height: auto; min-height: 90px; max-height: 200px; margin-top: auto; }
  #view-insights:has(#in-out[hidden]) #daily .dbars-x { margin-bottom: auto; }

  /* Budget: the total, then every category budget in two columns. */
  #view-budget:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
  #budget-editor { display: contents; }
  #view-budget .bud-main { grid-column: 1 / -1; margin: 0 0 18px; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); align-items: center; column-gap: 24px; }
  #view-budget .bud-main .k { grid-column: 1 / -1; }
  #view-budget .bud-check { grid-column: 2; }
  #view-budget .bud-act { grid-column: 1 / -1; margin: 0 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  #view-budget .bud-act p { margin: 0; }
  #view-budget .sec-head, #view-budget .bud-cats { grid-column: 1 / -1; }
  #view-budget .bud-cats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 36px; padding: 4px 18px; }
  #view-budget .bud-cats .bud-row:nth-child(2) { border-top: 0; }

  /* Expenses: chart and totals per category stay in view beside the list. */
  #view-expenses:not([hidden]) { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; align-items: start; }
  #x-controls { grid-column: 1 / -1; }
  #x-controls .seg { width: 360px; margin: 0; }
  #x-controls .x-catchips { display: none; } /* categories: in the By category card */
  /* The first card on the left starts level with the first day's card on the right. */
  #history .day-head { line-height: 18px; }
  #history .day-head:first-child { margin-top: 0; }
  .x-side { position: sticky; top: 18px; display: grid; gap: 16px; padding-top: 24px; max-height: calc(100vh - 36px); overflow-y: auto; }
  .x-side .card { margin: 0; }
  .x-cats:not([hidden]) { display: block; }
  .x-cats .legend { font-size: 14.5px; }
  .x-cats .legend button { min-height: 36px; }
  .x-cats .legend button > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .x-subs { display: none !important; } /* the rows sit under the category in By category */

  /* Calendar: the month on the left, the chosen day beside it. */
  #view-calendar:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  #view-calendar .cal-tab { margin: 0; padding: 18px 16px 16px; }
  .cal-month { gap: 6px; }
  .cday { min-height: 76px; padding-top: 8px; }
  .cday b { font-size: 15px; }
  .cday span { font-size: 12px; }
  .cday:hover:not(:disabled):not(.on):not(.today) { box-shadow: inset 0 0 0 1.5px var(--hair); }
  .cal-day { margin-top: 0; position: sticky; top: 18px; }
  .cal-day .day-head:first-child { margin-top: 2px; }
  #view-budget .bud-bar { grid-column: 1 / -1; bottom: 18px; grid-template-columns: 160px 240px; justify-content: end; }
  .bud-act .primary-btn { width: auto; padding-left: 24px; padding-right: 24px; }

  .sheet {
    top: 50%; bottom: auto; max-width: 440px; max-height: min(760px, calc(100vh - 48px));
    border-radius: 24px; padding-bottom: 0; overflow: hidden; opacity: 0;
    transform: translate(-50%, -47%);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease, visibility 0s linear .22s;
    box-shadow: 0 24px 60px rgba(38, 51, 47, .22);
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease; }
  .sheet.entry { top: 50%; height: min(700px, calc(100vh - 48px)); }
  .grab { visibility: hidden; height: 2px; }
  .toast { bottom: 28px; }
}
/* Wide screens: a long category list (more than 8) in two columns, so both sides stay level. */
@media (min-width: 1200px) {
  #by-category .legend:has(> button:nth-child(9)) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; }
}
