/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 300;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
body.sheet-open { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
strong, b { font-weight: 600; }
.display { font-family: 'Fraunces', Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }
.warn { color: var(--warn); }
.danger { color: var(--neg); }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 19px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text); font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.sm { width: 32px; height: 32px; font-size: 13px; }
.icon-btn.accent { color: var(--accent); }
#themeBtn { color: var(--accent); }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--accent-soft); padding: 0; overflow: hidden;
  background: var(--accent); color: var(--on-accent); font-weight: 600; display: grid; place-items: center;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ============ Popovers (moon menu, account menu) ============ */
.popover {
  position: fixed; top: calc(58px + env(safe-area-inset-top)); right: 12px; z-index: 50;
  width: min(320px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  padding: 14px;
}
.popover-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 4px 2px 8px;
}
.popover-label + .seg { margin-bottom: 14px; }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.swatches button {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: transparent; font-size: 13px; text-align: left;
}
.swatches button.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.swatch { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.popover-who { padding: 4px 4px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; word-break: break-all; }
.popover-link { display: flex; gap: 10px; align-items: center; padding: 10px 6px; color: var(--text); border-radius: 8px; }
.popover-link:hover { background: var(--surface-2); }
.popover-link i { width: 18px; color: var(--accent); }

/* ============ Segmented control ============ */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg button {
  border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.seg button.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ============ Layout ============ */
.page { max-width: 760px; margin: 0 auto; padding: 16px; }
.page.narrow { max-width: 560px; }
.page-title { font-size: 28px; margin: 6px 0 16px; }
.page-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.page-head .page-title { margin: 6px 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 20px; margin: 0 0 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.card.empty { text-align: center; padding: 28px 16px; }
.loading { display: grid; place-items: center; padding: 60px 0; color: var(--accent); font-size: 22px; }
.label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 6px; }
.label:first-child { margin-top: 0; }
.flash { background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.note { color: var(--muted); margin: -4px 2px 10px; }
.hint { color: var(--muted); margin: -6px 2px 0; }
.hint:empty { display: none; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 500; font-size: 14px; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-light { background: rgba(255,255,255,.92); border-color: transparent; color: #1b1d21; font-weight: 600; white-space: nowrap; }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--neg); }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .6; }
.link-btn { border: 0; background: none; padding: 4px 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.sm { padding: 4px 8px; font-size: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Forms ============ */
input[type=text], input[type=email], input[type=date], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px; font-weight: 400; outline: none;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
label > input, label > select, label > textarea, label > .prefix-input { margin-top: 5px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .label { margin: 4px 0 -6px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 4px; }
.inline-form input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.prefix-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.prefix-input span { padding-left: 12px; color: var(--muted); }
.prefix-input input { border: 0; box-shadow: none !important; }
.radio-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-weight: 400; cursor: pointer;
}
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.radio-card strong { display: block; font-weight: 600; }
.radio-card small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ============ Sign in ============ */
.signin { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 16px; }
.signin-card { text-align: center; max-width: 360px; width: 100%; }
.signin-card h1 { font-size: 40px; margin: 12px 0 4px; }
.signin-card p { margin: 0 0 28px; }
.signin-icon {
  width: 72px; height: 72px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 32px;
}

/* ============ Budgets list ============ */
.budget-card { padding: 0; overflow: hidden; }
.budget-open { display: flex; align-items: center; justify-content: space-between; padding: 16px; color: var(--text); }
.budget-name { font-family: 'Fraunces', Georgia, serif; font-size: 20px; font-weight: 600; }
.manage { border-top: 1px solid var(--border); }
.manage summary { padding: 12px 16px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); list-style: none; }
.manage summary::-webkit-details-marker { display: none; }
.manage summary i { margin-right: 6px; }
.manage-body { padding: 0 16px 16px; }
.member-list { list-style: none; padding: 0; margin: 0 0 8px; }
.member-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); word-break: break-all; }
.member-list form { margin: 0; }

/* ============ Budget screen ============ */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.month-label {
  border: 0; background: none; font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 22px;
  display: flex; align-items: center; gap: 8px;
}
.today-chip { font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.rta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-radius: 18px; padding: 16px 18px; margin-bottom: 12px; color: #fff;
}
.rta-pos { background: var(--accent); color: var(--on-accent); }
.rta-pos .btn-light { color: #1b1d21; }
.rta-zero { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.rta-neg { background: var(--neg); color: #fff; }
.rta-amt { font-family: 'Fraunces', Georgia, serif; font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rta-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.rta-icon { font-size: 26px; color: var(--pos); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stats > div { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.stats span { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stats strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; margin: 4px 0 10px; }

.cat-head, .group-row, .cat-row { display: grid; grid-template-columns: 1fr 96px 104px; gap: 8px; align-items: center; }
.cat-head {
  position: sticky; top: calc(59px + env(safe-area-inset-top)); z-index: 5; background: var(--bg);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 8px 12px 6px;
}
.cat-head span:not(:first-child) { text-align: right; }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 10px; overflow: hidden; }
.group.is-hidden, .cat-row.is-hidden { opacity: .55; }
.group-row { padding: 10px 12px; background: var(--surface-2); }
.group-name { border: 0; background: none; text-align: left; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; padding: 0; display: flex; gap: 8px; align-items: center; min-width: 0; }
.group-name i { font-size: 11px; color: var(--accent); width: 12px; }
.g-num { text-align: right; font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-row:has(.edit-actions), .cat-row:has(.edit-actions) { grid-template-columns: 1fr auto; }
.edit-actions { display: flex; gap: 2px; justify-content: flex-end; }
.cat-row { padding: 8px 12px; border-top: 1px solid var(--border); min-height: 56px; }
.cat-name { border: 0; background: none; padding: 2px 0; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cname em, .group-name em { font-style: normal; font-weight: 400; color: var(--muted); text-transform: none; }
.cstatus { font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { display: block; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 3px; max-width: 220px; }
.bar.big { height: 8px; max-width: none; margin: 8px 0; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--pos); transition: width .3s; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.neg { background: var(--neg); }
.assign-input {
  text-align: right; padding: 8px 8px !important; font-size: 15px !important; font-variant-numeric: tabular-nums;
  border-color: transparent !important; background: var(--surface-2) !important;
}
.assign-input:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
.avail {
  justify-self: end; border: 0; border-radius: 999px; padding: 6px 10px; font-size: 13.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 104px; overflow: hidden; text-overflow: ellipsis;
}
.avail.pos  { background: var(--pos-soft);  color: var(--pos); }
.avail.warn { background: var(--warn-soft); color: var(--warn); }
.avail.neg  { background: var(--neg-soft);  color: var(--neg); }
.avail.zero { background: var(--surface-2); color: var(--muted); }
/* Keep the columns in place even if a browser extension injects icons into a row */
.cat-row { position: relative; }
.cat-row > .cat-name { grid-column: 1; grid-row: 1; }
.cat-row > .assign-wrap { grid-column: 2; grid-row: 1; }
.cat-row > .avail { grid-column: 3; grid-row: 1; }
.cat-row > .edit-actions { grid-column: 2; grid-row: 1; }
.cat-row > :not(.cat-name):not(.assign-wrap):not(.avail):not(.edit-actions),
.assign-wrap > :not(.assign-input):not(.calc-btns) { position: absolute !important; }

/* Assigned box with calculator buttons */
.assign-wrap { position: relative; display: block; min-width: 0; }
.assign-wrap .assign-input { width: 100%; }
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.calc-btns {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  display: none; gap: 2px;
}
.calc-btns button {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); padding: 0;
  background: var(--surface); color: var(--accent); font-size: 14px; font-weight: 700; line-height: 1;
}
.calc-btns button:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .assign-wrap:hover .calc-btns, .assign-wrap:focus-within .calc-btns { display: flex; }
}

/* Mobile + − = bar above the number keypad */
.calc-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: var(--surface-2); border-top: 1px solid var(--border);
}
.calc-bar button {
  min-width: 52px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 22px; font-weight: 600; line-height: 1;
}
.calc-bar button:active { background: var(--accent); color: var(--on-accent); }
.calc-bar .calc-done { margin-left: auto; font-size: 15px; padding: 0 14px; background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.calc-preview { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
body.calc-open .tabbar { display: none; }

.toolbar { align-items: center; }
.toolbar-spacer { flex: 1; }
.icon-chip { padding: 6px 10px; }
.chip:disabled { opacity: .35; cursor: default; }
.cat-empty { padding: 12px; border-top: 1px solid var(--border); }

/* ============ Bottom sheet ============ */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; opacity: 0; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; background: var(--surface); padding: 8px 0; z-index: 2; }
.sheet-head h2 { font-size: 22px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 560px; bottom: auto; top: 50%; border-radius: 22px; transform: translate(-50%, -46%); opacity: 0; transition: transform .2s, opacity .2s; padding-bottom: 24px; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grip { display: none; }
}
.cat-summary { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 10px; }
.big-avail { border-radius: 16px; padding: 12px 16px; text-align: center; min-width: 130px; }
.big-avail span { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.big-avail strong { font-family: 'Fraunces', Georgia, serif; font-size: 24px; font-variant-numeric: tabular-nums; }
.big-avail.pos  { background: var(--pos-soft);  color: var(--pos); }
.big-avail.warn { background: var(--warn-soft); color: var(--warn); }
.big-avail.neg  { background: var(--neg-soft);  color: var(--neg); }
.big-avail.zero { background: var(--surface-2); color: var(--muted); }
.kv { margin: 0; display: grid; gap: 4px; }
.kv div { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.status-line { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; }
.cat-note { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; }
.panel { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel h3 { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.panel p { margin: 8px 0; }
.move-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.move-form input { grid-column: 1; }
.move-form select[name=dir] { grid-column: 2; width: auto; }
.move-form select[name=other] { grid-column: 1 / -1; }
.move-form button { grid-column: 1 / -1; }
.repeat-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.repeat-row:has(input:not([hidden])) { grid-template-columns: 1fr 70px 1fr; }
.amount-wrap { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 0 4px; }
.amount-wrap span { font-family: 'Fraunces', Georgia, serif; font-size: 34px; color: var(--muted); }
.amount-wrap input {
  border: 0 !important; box-shadow: none !important; background: transparent !important; text-align: center;
  font-family: 'Fraunces', Georgia, serif; font-size: 40px !important; font-weight: 600; max-width: 240px; padding: 0 !important;
  width: 5.2ch; field-sizing: content; min-width: 2.4ch; text-align: left !important;
}
.fix-remaining { font-weight: 600; padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.fix-remaining.neg { background: var(--neg-soft); }
.fix-remaining.pos { background: var(--pos-soft); }
.fix-remaining.warn { background: var(--warn-soft); }
.fix-list { margin: 10px 0 14px; }
.fix-row { display: grid; grid-template-columns: 1fr auto 100px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.fix-row input { text-align: right; padding: 8px !important; }

/* ============ Accounts & registers ============ */
.acct-card { padding: 0; overflow: hidden; }
.acct-section {
  display: flex; justify-content: space-between; padding: 12px 16px; background: var(--surface-2);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); cursor: pointer; list-style: none;
}
.acct-section::-webkit-details-marker { display: none; }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--border); color: var(--text); }
.acct-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; font-size: 14px; }
.acct-name { flex: 1; min-width: 0; font-weight: 500; }
.acct-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.money { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.networth { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 16px; }
.networth span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.networth strong { font-family: 'Fraunces', Georgia, serif; font-size: 22px; }
.acct-balance { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.acct-balance span { color: var(--muted); font-size: 13px; }
.acct-balance strong { font-family: 'Fraunces', Georgia, serif; font-size: 26px; font-variant-numeric: tabular-nums; }
.search { position: relative; margin-bottom: 12px; }
.search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.search input { padding-left: 38px; }
.txn-list { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.panel .txn-list { border: 0; border-radius: 0; margin: 4px -14px -12px; }
.txn-date { padding: 7px 14px; background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.txn-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border: 0; border-top: 1px solid var(--border); background: transparent; text-align: left;
}
.txn-date + .txn-row { border-top: 0; }
.txn-row:hover { background: var(--surface-2); }
.txn-main { min-width: 0; display: flex; flex-direction: column; }
.txn-payee { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-amts { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.txn-bal { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.setting-big { font-family: 'Fraunces', Georgia, serif; font-size: 20px; font-weight: 600; }
.card .btn { margin-top: 10px; }

/* ============ Bottom tab bar ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .02em; }
.tabbar a i { font-size: 18px; }
.tabbar a.active { color: var(--accent); }
.tab-add {
  justify-self: center; width: 52px; height: 52px; border-radius: 50%; border: 0; margin-top: -18px;
  background: var(--accent); color: var(--on-accent); font-size: 20px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 500; font-size: 14px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.bad { background: var(--neg); color: #fff; }

/* ============ Import page ============ */
.import-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.import-table td, .import-table th { padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.import-table select { padding: 8px 30px 8px 10px; font-size: 14px; }

/* ============ Larger screens ============ */
@media (min-width: 700px) {
  body { font-size: 15.5px; }
  .cat-head, .group-row, .cat-row { grid-template-columns: 1fr 130px 130px; }
  .avail { max-width: 130px; }
  .page-title { font-size: 32px; }
}
@media (max-width: 380px) {
  .cat-head, .group-row, .cat-row { grid-template-columns: 1fr 84px 92px; gap: 6px; }
  .rta { flex-direction: column; align-items: stretch; }
  .stats strong { font-size: 13.5px; }
}

/* ============ Payee autocomplete ============ */
.ac-field > label { margin-bottom: 5px; }
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto; padding: 4px;
}
.ac-item {
  display: flex; width: 100%; justify-content: space-between; align-items: baseline; gap: 10px;
  border: 0; background: transparent; padding: 10px 10px; border-radius: 8px; text-align: left; font-weight: 500;
}
.ac-item small { color: var(--muted); font-weight: 400; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item.active, .ac-item:hover { background: var(--accent-soft); }
.ac-add { color: var(--accent); justify-content: flex-start; }
.setting-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); }
.setting-link .label { display: block; margin: 0 0 2px; }

/* ============ Pull to refresh ============ */
.ptr {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; z-index: 35;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--accent); box-shadow: var(--shadow); border: 1px solid var(--border);
  transform: translate(-50%, -80px); opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
.ptr.show { opacity: 1; }
.ptr.ready { background: var(--accent); color: var(--on-accent); }
