/* Nest Egg — YNAB-style budgeting UI */
:root {
  --sb-bg: #1e2044;
  --sb-bg-2: #262955;
  --sb-hover: #2f3366;
  --sb-active: #3d4285;
  --sb-text: #e8e9f7;
  --sb-muted: #9da0c8;
  --brand: #4b55d8;
  --brand-dark: #3740b8;
  --brand-soft: #e7e9ff;
  --ink: #1c1d33;
  --ink-2: #4b4d66;
  --muted: #7a7c96;
  --line: #e4e5ef;
  --line-2: #eef0f6;
  --bg: #ffffff;
  --bg-2: #f6f7fb;
  --group-bg: #f0f1f8;
  --row-hover: #f7f8fe;
  --row-selected: #e8ebff;
  --green-bg: #c3ec9b;
  --green-ink: #1f4a0e;
  --green-strong: #3f8f1c;
  --yellow-bg: #fde59a;
  --yellow-ink: #6a4b00;
  --yellow-strong: #e2a900;
  --red-bg: #fcc8c8;
  --red-ink: #9e1219;
  --red-strong: #d6323a;
  --zero-bg: #ebecf2;
  --zero-ink: #6b6d84;
  --inspector-w: 340px;
  --sidebar-w: 268px;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(28, 29, 51, .12);
  font-size: 14px;
}

html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }
button { font: inherit; }
a { color: var(--brand); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(75, 85, 216, .18); }
.btn { border-radius: 8px; }
.btn-ghost { background: transparent; border: 0; color: var(--ink-2); padding: .3rem .55rem; border-radius: 6px; }
.btn-ghost:hover { background: var(--line-2); color: var(--ink); }
.btn-ghost:disabled { opacity: .35; }
.text-muted-2 { color: var(--muted) !important; }
.neg { color: var(--red-strong); }

.app-loading { display: flex; align-items: center; justify-content: center; height: 100vh; }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--sb-bg); color: var(--sb-text);
  display: flex; flex-direction: column; overflow: hidden; transition: width .2s, flex-basis .2s;
}
.main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.mobile-bar { display: none; }

.sb-budget {
  display: flex; align-items: center; gap: .6rem; padding: .9rem .9rem .7rem; cursor: pointer; border-radius: 10px; margin: .4rem;
}
.sb-budget:hover { background: var(--sb-hover); }
.sb-budget img { width: 32px; height: 32px; border-radius: 8px; }
.sb-budget .name { font-weight: 700; font-size: 15px; line-height: 1.15; }
.sb-budget .email { color: var(--sb-muted); font-size: 12px; }
.sb-nav { padding: .25rem .5rem; }
.sb-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px; color: var(--sb-text);
  text-decoration: none; font-weight: 600; font-size: 14.5px;
}
.sb-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; color: var(--sb-muted); }
.sb-link:hover { background: var(--sb-hover); color: #fff; }
.sb-link.active { background: var(--sb-active); color: #fff; }
.sb-link.active i { color: #fff; }
.sb-accounts { flex: 1 1 auto; overflow-y: auto; padding: .5rem .5rem 1rem; scrollbar-width: thin; scrollbar-color: var(--sb-hover) transparent; }
.sb-section { margin-top: .6rem; }
.sb-section-head {
  display: flex; justify-content: space-between; align-items: center; padding: .35rem .75rem; color: var(--sb-muted);
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; user-select: none; border-radius: 6px;
}
.sb-section-head:hover { color: var(--sb-text); }
.sb-section-head .caret { transition: transform .15s; display: inline-block; margin-right: .3rem; }
.sb-section.collapsed .caret { transform: rotate(-90deg); }
.sb-section.collapsed .sb-account { display: none; }
.sb-account {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .38rem .75rem .38rem 1.65rem;
  color: var(--sb-text); text-decoration: none; border-radius: 6px; font-size: 13.5px;
}
.sb-account:hover { background: var(--sb-hover); color: #fff; }
.sb-account.active { background: var(--sb-active); color: #fff; }
.sb-account .acct-name { overflow: hidden; white-space: nowrap; display: flex; align-items: center; gap: .35rem; flex: 1 1 auto; min-width: 0; }
.sb-account .bal { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-account .bal.neg, .sb-section-head .neg { color: #ff9aa0; }
.sb-badge { background: var(--brand); color: #fff; border-radius: 10px; font-size: 10.5px; padding: 0 .4rem; font-weight: 700; }
.sb-link-icon { color: var(--sb-muted); font-size: 11px; }
.sb-link-icon.warn { color: #ffcf5c; }
.sb-footer { padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .07); display: flex; gap: .5rem; }
.sb-add {
  flex: 1; background: transparent; color: var(--sb-text); border: 1px solid rgba(255, 255, 255, .22); border-radius: 8px; padding: .45rem .6rem; font-weight: 600;
}
.sb-add:hover { background: var(--sb-hover); }
.sb-icon-btn { background: transparent; color: var(--sb-muted); border: 0; border-radius: 8px; padding: .45rem .6rem; }
.sb-icon-btn:hover { background: var(--sb-hover); color: #fff; }
.sb-sync { font-size: 11.5px; color: var(--sb-muted); padding: 0 1rem .5rem; }

/* ---------------------------------------------------------------- plan (budget) */
.plan { display: flex; flex: 1 1 auto; min-height: 0; }
.plan-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.plan-header {
  display: flex; align-items: center; gap: 1.25rem; padding: 1rem 1.5rem .8rem; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.month-nav { display: flex; align-items: center; gap: .25rem; }
.month-nav .month-label { font-size: 22px; font-weight: 800; letter-spacing: -.01em; padding: .1rem .5rem; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.month-nav .month-label:hover { background: var(--line-2); }
.month-nav .arrow { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; }
.month-nav .arrow:hover:not(:disabled) { background: var(--line-2); }
.month-nav .arrow:disabled { opacity: .35; }
.month-note { color: var(--muted); font-size: 13px; cursor: pointer; padding-left: .55rem; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-note:hover { color: var(--brand); }
.rta {
  display: flex; align-items: center; gap: 1rem; padding: .55rem .6rem .55rem 1.1rem; border-radius: 12px; margin: 0 auto;
  background: var(--green-bg); color: var(--green-ink); min-width: 290px; cursor: pointer;
}
.rta .amount { font-size: 24px; font-weight: 800; line-height: 1.05; letter-spacing: -.01em; }
.rta .label { font-size: 12.5px; font-weight: 600; opacity: .85; }
.rta .rta-btn { margin-left: auto; background: var(--green-ink); color: #fff; border: 0; border-radius: 8px; padding: .5rem .9rem; font-weight: 700; }
.rta .rta-btn:hover { background: #163a08; }
.rta.zero { background: var(--zero-bg); color: var(--zero-ink); }
.rta.zero .rta-btn { background: #5b5d75; }
.rta.negative { background: var(--red-bg); color: var(--red-ink); }
.rta.negative .rta-btn { background: var(--red-ink); }
.aom { text-align: right; line-height: 1.1; }
.aom .v { font-size: 18px; font-weight: 800; }
.aom .l { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.plan-toolbar { display: flex; align-items: center; gap: .5rem; padding: .55rem 1.5rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filter-pills { display: flex; gap: .25rem; flex-wrap: wrap; }
.filter-pill { border: 0; background: transparent; color: var(--ink-2); padding: .3rem .75rem; border-radius: 999px; font-weight: 600; font-size: 13px; }
.filter-pill:hover { background: var(--line-2); }
.filter-pill.active { background: var(--brand-soft); color: var(--brand-dark); }
.toolbar-spacer { flex: 1; }
.toolbar-btn { border: 0; background: transparent; color: var(--brand); font-weight: 600; padding: .3rem .55rem; border-radius: 6px; font-size: 13px; display: inline-flex; gap: .35rem; align-items: center; }
.toolbar-btn:hover:not(:disabled) { background: var(--brand-soft); }
.toolbar-btn:disabled { color: var(--muted); opacity: .5; }

.alert-strip { display: flex; align-items: center; gap: .6rem; padding: .5rem 1.5rem; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); }
.alert-strip.warn { background: #fff7dc; color: #6a4b00; }
.alert-strip.danger { background: #fff0f0; color: var(--red-ink); }
.alert-strip.info { background: #eef0ff; color: var(--brand-dark); }
.alert-strip a, .alert-strip button.link { color: inherit; text-decoration: underline; background: none; border: 0; padding: 0; font-weight: 700; }

.budget-table-wrap { flex: 1 1 auto; overflow-y: auto; }
.budget-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.budget-table th {
  position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .55rem .75rem;
}
.budget-table th.amt, .budget-table td.amt { text-align: right; width: 150px; }
.budget-table th.chk, .budget-table td.chk { width: 44px; text-align: center; padding-left: 1rem; padding-right: 0; }
.budget-table td { padding: 0 .75rem; height: 46px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.budget-table tr.group td { background: var(--group-bg); height: 38px; font-weight: 700; border-bottom: 1px solid var(--line); }
.budget-table tr.group td.amt { color: var(--ink-2); font-size: 13px; }
.budget-table tr.group .group-name { display: flex; align-items: center; gap: .35rem; }
.budget-table tr.group .caret { border: 0; background: none; padding: 0 .2rem; color: var(--ink-2); transition: transform .15s; }
.budget-table tr.group.collapsed .caret { transform: rotate(-90deg); }
.budget-table tr.group .add-cat { opacity: 0; border: 0; background: var(--brand); color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.budget-table tr.group:hover .add-cat { opacity: 1; }
.budget-table tr.group .name-btn, .budget-table tr.cat .name-btn { border: 0; background: none; padding: .1rem .3rem; margin-left: -.3rem; border-radius: 5px; font-weight: inherit; color: inherit; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-table tr.group .name-btn:hover, .budget-table tr.cat.selected .name-btn:hover { background: rgba(75, 85, 216, .1); }
.budget-table tr.cat { cursor: default; }
.budget-table tr.cat:hover td { background: var(--row-hover); }
.budget-table tr.cat.selected td { background: var(--row-selected); }
.budget-table tr.cat.hidden-cat { opacity: .55; }
.budget-table tr.cat.drag-over td { box-shadow: inset 0 2px 0 var(--brand); }
.budget-table tr.group.drag-over td { box-shadow: inset 0 -2px 0 var(--brand); }
.cat-name-cell { padding-top: .35rem !important; padding-bottom: .35rem !important; }
.cat-name { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.cat-name .note-dot { color: var(--muted); font-size: 11px; }
.target-bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 5px; overflow: hidden; position: relative; max-width: 420px; }
.target-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--green-strong); border-radius: 3px; }
.target-bar.under .fill { background: var(--yellow-strong); }
.target-bar.over .fill { background: var(--red-strong); }
.target-bar .spent { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(135deg, rgba(0,0,0,.28) 0 3px, transparent 3px 6px); border-radius: 3px; }
.target-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target-label.under { color: #8a6400; }
.assigned-cell { cursor: text; }
.assigned-cell .assigned-val { display: inline-block; min-width: 100px; padding: .3rem .5rem; border-radius: 6px; border: 1px solid transparent; }
.budget-table tr.cat:hover .assigned-val, .budget-table tr.cat.selected .assigned-val { border-color: #cfd2ea; background: #fff; }
.assigned-input { width: 120px; text-align: right; padding: .28rem .5rem; border: 2px solid var(--brand); border-radius: 6px; font-variant-numeric: tabular-nums; outline: none; }
.activity-cell button { border: 0; background: none; padding: .1rem .3rem; border-radius: 5px; color: inherit; font-variant-numeric: tabular-nums; }
.activity-cell button:hover { background: var(--line-2); text-decoration: underline; }

.pill {
  display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums; border: 0; min-width: 72px; text-align: right; cursor: pointer;
}
.pill.green { background: var(--green-bg); color: var(--green-ink); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow-ink); }
.pill.red { background: var(--red-bg); color: var(--red-ink); }
.pill.zero { background: var(--zero-bg); color: var(--zero-ink); }
.pill:hover { filter: brightness(.96); }
.pill.big { font-size: 20px; padding: .35rem 1rem; }
.pill i { font-size: 11px; margin-right: .2rem; }

.empty-plan { text-align: center; padding: 4rem 1rem; color: var(--muted); }

/* ---------------------------------------------------------------- inspector */
.inspector {
  width: var(--inspector-w); flex: 0 0 var(--inspector-w); border-left: 1px solid var(--line); background: var(--bg-2);
  overflow-y: auto; padding: 1rem;
}
.insp-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: .85rem; }
.insp-card h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: .75rem; display: flex; justify-content: space-between; align-items: center; }
.insp-title { font-size: 18px; font-weight: 800; margin-bottom: .1rem; word-break: break-word; }
.insp-row { display: flex; justify-content: space-between; align-items: baseline; padding: .25rem 0; font-size: 13.5px; }
.insp-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.insp-row.total { border-top: 1px solid var(--line); margin-top: .35rem; padding-top: .55rem; font-weight: 800; }
.auto-btn {
  display: flex; justify-content: space-between; width: 100%; border: 0; background: var(--bg-2); padding: .5rem .7rem; border-radius: 8px; margin-bottom: .35rem; color: var(--ink); font-size: 13.5px; text-align: left;
}
.auto-btn:hover { background: var(--brand-soft); color: var(--brand-dark); }
.auto-btn .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.target-ring { width: 74px; height: 74px; flex: 0 0 74px; }
.target-summary { display: flex; gap: 1rem; align-items: center; }
.target-summary .desc { font-size: 13px; color: var(--ink-2); }
.seg { display: flex; background: var(--bg-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: .3rem .2rem; border-radius: 6px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.seg button.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.insp-note { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .5rem; font-size: 13px; resize: vertical; min-height: 70px; }

/* ---------------------------------------------------------------- popovers & menus */
.np-pop {
  position: fixed; z-index: 1080; background: #fff; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: .9rem; min-width: 260px; max-width: 360px;
}
.np-pop h6 { font-weight: 800; font-size: 14px; margin-bottom: .6rem; }
.np-pop .pop-actions { display: flex; justify-content: flex-end; gap: .4rem; margin-top: .75rem; }
.np-menu { padding: .35rem; min-width: 220px; }
.np-menu .menu-item {
  display: flex; align-items: center; gap: .55rem; width: 100%; border: 0; background: none; text-align: left; padding: .45rem .6rem; border-radius: 7px; color: var(--ink); font-size: 13.5px;
}
.np-menu .menu-item:hover, .np-menu .menu-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.np-menu .menu-item.danger { color: var(--red-strong); }
.np-menu .menu-item .v { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.np-menu .menu-sep { height: 1px; background: var(--line); margin: .3rem 0; }
.np-menu .menu-head { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: .45rem .6rem .2rem; }

/* combobox (payee / category pickers) */
.combo { position: relative; }
.combo-list {
  position: fixed; z-index: 1090; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto; min-width: 260px; padding: .3rem;
}
.combo-item { display: flex; justify-content: space-between; gap: .75rem; padding: .38rem .6rem; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.combo-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.combo-item .v { font-variant-numeric: tabular-nums; font-size: 12.5px; }
.combo-item .v.neg { color: var(--red-strong); }
.combo-item .v.pos { color: var(--green-strong); }
.combo-head { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: .5rem .6rem .2rem; }
.combo-item .lbl { display: flex; flex-direction: column; min-width: 0; }
.combo-item .lbl .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.combo-item.suggested .bi-stars { color: var(--brand); }
.combo-item.suggested .lbl { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: .25rem; }
.combo-item.suggested .lbl .hint { flex-basis: 100%; padding-left: 1.2rem; }
.auto-tag { display: inline-flex; align-items: center; gap: .2rem; margin-left: .35rem; padding: 0 .4rem; border-radius: 999px;
  font-size: 11px; line-height: 1.6; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap; vertical-align: middle; }
.combo-empty { padding: .5rem .6rem; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- accounts / register */
.register { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.reg-header { display: flex; align-items: flex-start; gap: 1.5rem; padding: 1rem 1.5rem .9rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.reg-title { font-size: 22px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.reg-title .edit-icon { font-size: 14px; color: var(--muted); opacity: 0; }
.reg-title:hover .edit-icon { opacity: 1; }
.reg-sub { color: var(--muted); font-size: 12.5px; display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .15rem; }
.balances { display: flex; align-items: center; gap: .9rem; margin-left: auto; }
.balance-box { text-align: center; }
.balance-box .v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.balance-box .l { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.balance-op { color: var(--muted); font-size: 18px; font-weight: 300; }
.reconcile-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .45rem .75rem; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: .4rem; }
.reconcile-btn:hover { background: var(--line-2); }
.reg-toolbar { display: flex; align-items: center; gap: .35rem; padding: .5rem 1.5rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.reg-search { position: relative; }
.reg-search input { padding-left: 2rem; width: 220px; border-radius: 8px; }
.reg-search i { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.reg-table-wrap { flex: 1 1 auto; overflow: auto; }
.reg-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 860px; table-layout: fixed; }
.reg-table th {
  position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .55rem .5rem; white-space: nowrap; user-select: none;
}
.reg-table th.sortable { cursor: pointer; }
.reg-table th.sortable:hover { color: var(--ink); }
.reg-table td { padding: .5rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
.reg-table .c-chk { width: 38px; text-align: center; padding-left: 1rem; }
.reg-table .c-flag { width: 30px; text-align: center; }
.reg-table .c-acct { width: 13%; }
.reg-table .c-date { width: 128px; }
.reg-table .c-payee { width: 20%; }
.reg-table .c-cat { width: 22%; }
.reg-table .c-memo { width: auto; }
.reg-table .c-amt { width: 112px; text-align: right; font-variant-numeric: tabular-nums; }
.reg-table .c-clr { width: 52px; text-align: center; padding-right: 1rem; overflow: visible; text-overflow: clip; }
.reg-table tbody tr.txn { cursor: pointer; }
.reg-table tbody tr.txn:hover td { background: var(--row-hover); }
.reg-table tbody tr.txn.selected td { background: var(--row-selected); }
.reg-table tbody tr.txn.unapproved td { background: #fbfbf2; }
.reg-table tbody tr.txn.unapproved td.c-payee { font-weight: 700; }
.reg-table tbody tr.txn.unapproved.selected td { background: var(--row-selected); }
.reg-table tbody tr.sub td { color: var(--ink-2); font-size: 13px; border-bottom-style: dashed; }
.reg-table tbody tr.sub td.c-payee { padding-left: 1.5rem; }
.reg-table tbody tr.scheduled td { color: var(--muted); font-style: italic; background: #fcfcfe; }
.reg-table tbody tr.scheduled-head td, .reg-table tbody tr.section-head td { background: var(--group-bg); font-weight: 700; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: .35rem 1rem; }
.cat-transfer { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: .35rem; }
.cat-chip-missing { color: #8a6400; background: #fff4cc; border-radius: 6px; padding: .1rem .45rem; font-weight: 600; font-size: 12.5px; }
.cleared-btn { border: 0; background: none; padding: 0; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #b6b8cc; border: 1.5px solid #c9cbdc; }
.cleared-btn.cleared { background: var(--green-strong); border-color: var(--green-strong); color: #fff; }
.cleared-btn.reconciled { background: none; border: 0; color: var(--green-strong); font-size: 14px; }
.flag-btn { border: 0; background: none; padding: 0; color: #d0d2e2; font-size: 14px; }
.flag-btn:hover { color: var(--muted); }
.flag-red { color: #e5484d !important; } .flag-orange { color: #f2841f !important; } .flag-yellow { color: #f0c000 !important; }
.flag-green { color: #46a758 !important; } .flag-blue { color: #3e7bfa !important; } .flag-purple { color: #8e4ec6 !important; }
.payee-wrap { display: flex; align-items: center; min-width: 0; }
.payee-wrap .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.payee-wrap .auto-tag, .payee-wrap .approve-btn { flex-shrink: 0; }
.auto-tag.compact { padding: 0 .3rem; }
.approve-btn.blocked { background: #e6e7ef; color: var(--muted); display: inline-flex; align-items: center; gap: .25rem; }
.approve-btn.blocked:hover { background: #dcdde8; color: var(--ink-2); }
.approve-btn { border: 0; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; padding: .12rem .5rem; border-radius: 6px; margin-left: .35rem; }
.seg-toggle { display: inline-flex; background: var(--line-2); border-radius: 8px; padding: 2px; gap: 2px; }
.seg-toggle button { border: 0; background: none; padding: .2rem .65rem; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: .35rem; }
.seg-toggle button.on { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 2px rgba(20, 24, 60, .12); }
.seg-toggle .seg-count { background: #fff4cc; color: #8a6400; border-radius: 999px; padding: 0 .4rem; font-size: 11.5px; }
.badge-soft { background: var(--brand-soft); color: var(--brand-dark); border-radius: 6px; padding: .05rem .4rem; font-size: 11px; font-weight: 700; }

/* inline editor */
.reg-table tr.editing td { background: #f3f5ff !important; overflow: visible; white-space: normal; padding: .35rem .3rem; border-bottom: 0; }
.reg-table tr.editing.first td { border-top: 2px solid var(--brand); }
.reg-table tr.editing input, .reg-table tr.editing select { width: 100%; font-size: 13.5px; padding: .3rem .45rem; border: 1px solid #c9cce6; border-radius: 6px; background: #fff; }
.reg-table tr.editing input:focus, .reg-table tr.editing select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(75, 85, 216, .15); }
.reg-table tr.editing input.amt { text-align: right; }
.reg-table tr.edit-actions td { background: #f3f5ff !important; border-bottom: 2px solid var(--brand); padding: .4rem 1rem .6rem; overflow: visible; }
.edit-actions-inner { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.split-remaining { margin-right: auto; font-size: 12.5px; font-weight: 700; }
.split-remaining.bad { color: var(--red-strong); }
.split-remaining.ok { color: var(--green-strong); }
.empty-register { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* ---------------------------------------------------------------- reflect */
.reflect { flex: 1 1 auto; overflow-y: auto; }
.reflect-head { padding: 1rem 1.5rem 0; border-bottom: 1px solid var(--line); }
.reflect-tabs { display: flex; gap: .25rem; margin-top: .6rem; overflow-x: auto; }
.reflect-tab { border: 0; background: none; padding: .55rem .9rem; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; text-decoration: none; }
.reflect-tab:hover { color: var(--ink); }
.reflect-tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.reflect-filters { display: flex; gap: .5rem; align-items: center; padding: .75rem 1.5rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.reflect-body { padding: 1.25rem 1.5rem 2rem; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.5rem; }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; }
.chart-card h5 { font-weight: 800; font-size: 15px; }
.big-stat { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.legend-list .row-item { display: flex; align-items: center; gap: .55rem; padding: .45rem .25rem; border-bottom: 1px solid var(--line-2); font-size: 13.5px; cursor: pointer; }
.legend-list .row-item:hover { background: var(--row-hover); }
.legend-list .sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.legend-list .v { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.legend-list .p { width: 52px; text-align: right; color: var(--muted); font-size: 12.5px; }
.ie-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.ie-table th, .ie-table td { padding: .4rem .6rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line-2); }
.ie-table th:first-child, .ie-table td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.ie-table thead th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.ie-table tr.grp td { font-weight: 800; background: var(--group-bg); }
.ie-table tr.grp td:first-child { background: var(--group-bg); }
.ie-table tr.tot td { font-weight: 800; border-top: 2px solid var(--line); }
.ie-table tr.net td { font-weight: 800; font-size: 14px; }

/* ---------------------------------------------------------------- settings / auth / misc */
.page { flex: 1 1 auto; overflow-y: auto; }
.page-inner { max-width: 900px; padding: 1.5rem; }
.page h2 { font-weight: 800; font-size: 22px; }
.settings-nav { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.settings-card { border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; margin-bottom: 1rem; }
.settings-card h5 { font-weight: 800; font-size: 15px; }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--sb-bg) 0%, #343a8a 100%); padding: 1rem; }
.auth-card { background: #fff; border-radius: 18px; padding: 2rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.auth-card .logo { width: 48px; height: 48px; border-radius: 12px; }
.auth-brand { display: flex; align-items: center; gap: .65rem; }
.auth-step { display: inline-block; margin-top: 1rem; padding: .2rem .65rem; border-radius: 999px; background: #eef0ff; color: #4b55d8; font-size: 12.5px; font-weight: 700; }
.verify-card .auth-brand { justify-content: center; }
.verify-card .auth-step { display: table; margin: 1rem auto 0; }
.verify-icon { width: 68px; height: 68px; margin: 1.1rem auto .25rem; border-radius: 50%; background: #eef0ff; color: #4b55d8; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.verify-email { display: flex; align-items: center; justify-content: center; gap: .45rem; margin: 0 auto 1.1rem; padding: .45rem .8rem; border-radius: 10px; background: #f5f6fb; font-weight: 700; word-break: break-all; }
.verify-email i { color: #4b55d8; }
.verify-code { font-size: 30px; font-weight: 800; letter-spacing: .45em; text-align: center; padding: .55rem 0 .55rem .45em; margin-bottom: .9rem; border-width: 2px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.verify-code::placeholder { color: #c9cce0; letter-spacing: .45em; }
.verify-code:focus { border-color: #4b55d8; box-shadow: 0 0 0 .2rem rgba(75, 85, 216, .15); }
.verify-code.is-invalid { animation: shake .3s; background-image: none; padding-right: 0; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.verify-status { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .85rem; border-radius: 12px; margin-bottom: .9rem; font-size: 14px; line-height: 1.45; border: 1px solid transparent; }
.verify-status i { font-size: 17px; line-height: 1.2; }
.verify-status.success { background: #e9f8ef; border-color: #bfe8cf; color: #17663a; }
.verify-status.info { background: #eef0ff; border-color: #d3d7fb; color: #343a8a; }
.verify-status.error { background: #fdecef; border-color: #f6c4cd; color: #9b1c33; }
.verify-hint { margin: 1rem 0 .6rem; text-align: center; font-size: 13px; color: #6b6e8a; }
.auth-brand span { font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--sb-bg); }
.auth-card h1 { font-size: 24px; font-weight: 800; margin: .75rem 0 .25rem; }

.toast-stack { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.np-toast { background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; display: flex; gap: .75rem; align-items: center; animation: toastIn .18s ease-out; }
.np-toast.error { background: var(--red-ink); }
.np-toast button { background: none; border: 0; color: #c3c8ff; font-weight: 700; padding: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-content { border-radius: 16px; border: 0; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 800; }
.acct-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.choice-card { border: 1.5px solid var(--line); border-radius: 12px; padding: 1rem; cursor: pointer; background: #fff; text-align: left; width: 100%; }
.choice-card:hover { border-color: var(--brand); background: var(--brand-soft); }
.choice-card .t { font-weight: 800; }
.choice-card .d { color: var(--muted); font-size: 13px; }
.plaid-acct-row { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; margin-bottom: .5rem; }

/* ---------------------------------------------------------------- responsive */
.inspector-toggle { display: none; }
@media (max-width: 1280px) {
  :root { --inspector-w: 300px; }
}
@media (max-width: 1100px) {
  .inspector { position: fixed; right: 0; top: 0; bottom: 0; z-index: 1040; box-shadow: var(--shadow); transform: translateX(100%); transition: transform .2s; }
  .inspector.open { transform: none; }
  .inspector-toggle { display: inline-flex; }
  .budget-table th.amt, .budget-table td.amt { width: 120px; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 1050; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .mobile-bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--sb-bg); color: #fff; }
  .mobile-bar button { background: none; border: 0; color: #fff; font-size: 1.4rem; }
  .mobile-bar .title { font-weight: 800; }
  .backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1045; }
  .plan-header { padding: .75rem 1rem; gap: .75rem; }
  .rta { min-width: 0; width: 100%; order: 3; }
  .plan-toolbar, .reg-toolbar, .reg-header, .reflect-filters { padding-left: 1rem; padding-right: 1rem; }
  .budget-table th.col-activity, .budget-table td.col-activity { display: none; }
  .budget-table th.amt, .budget-table td.amt { width: 104px; }
  .budget-table th.chk, .budget-table td.chk { display: none; }
  .assigned-cell .assigned-val { min-width: 0; }
  .balances { margin-left: 0; }
  .report-grid { grid-template-columns: 1fr; }
  .reg-search input { width: 150px; }
}
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.bi-blank::before { content: ""; width: 1em; display: inline-block; }

/* Greyed-out category of a transfer between budget accounts */
tr.editing input.cat-transfer-input { color: var(--brand-dark); font-weight: 600; background: var(--line-2); cursor: not-allowed; }

/* Register: category filter chip */
.cat-chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--brand-50, #eef0ff); color: var(--brand-dark); border-radius: 8px; padding: .15rem .3rem .15rem .2rem; font-size: 13px; font-weight: 600; }
.cat-chip button { border: 0; background: none; color: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .35rem; border-radius: 6px; }
.cat-chip button:hover { background: rgba(255, 255, 255, .7); }
.cat-chip .cat-chip-total { color: var(--ink-2); font-weight: 600; }
.cat-chip a { color: inherit; display: inline-flex; }

/* Reflect: step the report period back and forth */
.range-nav { display: inline-flex; align-items: center; gap: .25rem; }
.range-nav .btn-ghost:disabled { opacity: .35; }
.range-nav #range-label { min-width: 120px; text-align: center; }

/* Register: drag a header's edge to resize the column */
.reg-table th { position: sticky; }
.reg-table th .col-resize { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 3; }
.reg-table th .col-resize::after { content: ''; position: absolute; top: 25%; bottom: 25%; right: 0; width: 1px; background: var(--line); }
.reg-table th:hover .col-resize::after, .reg-table th .col-resize.active::after { background: var(--brand); width: 2px; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ---------------------------------------------------------------- phones and small tablets */
@media (max-width: 860px) {
  /* Popups and dropdowns never run off the screen */
  .np-pop, .combo-list { max-width: calc(100vw - 16px); }
  .np-menu { min-width: min(220px, calc(100vw - 16px)); }

  /* Plan: filter tabs scroll sideways instead of stacking */
  .filter-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; }
  .filter-pills::-webkit-scrollbar { display: none; }
  .filter-pill { white-space: nowrap; }
  .assigned-input { font-size: 16px; } /* no iOS zoom while typing */

  /* Register header: balances wrap, Reconcile stays on screen */
  .reg-header { gap: .6rem; padding-top: .75rem; padding-bottom: .75rem; }
  .balances { flex-wrap: wrap; gap: .4rem .9rem; width: 100%; }
  .balance-op { display: none; }
  .balance-box { text-align: left; }
  .balance-box .v { font-size: 15px; }
  .balance-box .l { font-size: 11px; }
  .reg-toolbar { gap: .25rem; }
  .reg-search { flex: 1 1 100%; order: 10; }
  .reg-search input { width: 100%; font-size: 16px; }

  /* Register rows become two-line cards */
  .reg-table { min-width: 0 !important; width: 100% !important; table-layout: auto; font-size: 14px; }
  .reg-table colgroup, .reg-table thead { display: none; }
  .reg-table, .reg-table tbody { display: block; }
  .reg-table tbody tr { display: block; }
  .reg-table tbody tr td { display: block; border: 0; padding: 0; max-width: none; width: auto !important; min-width: 0; }
  .reg-table tbody tr.txn, .reg-table tbody tr.sub {
    display: grid; grid-template-columns: 26px auto minmax(0, 1fr) auto; column-gap: .5rem; row-gap: .1rem; align-items: center;
    grid-template-areas: "chk payee payee amt" "chk date cat clr" "chk acct memo memo";
    padding: .6rem .9rem; border-bottom: 1px solid var(--line-2);
  }
  .reg-table tbody tr.txn td { background: transparent !important; }
  .reg-table tbody tr.txn.selected { background: var(--row-selected); }
  .reg-table tbody tr.txn.unapproved { background: #fbfbf2; }
  .reg-table tbody tr.txn td.c-chk { grid-area: chk; padding: 0; width: auto; }
  .reg-table tbody tr.txn td.c-flag, .reg-table tbody tr.sub td.c-flag, .reg-table tbody tr.txn td:not([class]), .reg-table tbody tr.sub td:not([class]) { display: none; }
  .reg-table tbody tr td.c-payee { grid-area: payee; font-weight: 600; }
  .reg-table tbody tr td.c-amt { grid-area: amt; width: auto; font-weight: 700; }
  .reg-table tbody tr td.c-amt:empty { display: none; }
  .reg-table tbody tr.txn td.c-amt + td.c-amt, .reg-table tbody tr.sub td.c-amt + td.c-amt { color: var(--green-ink, #2f7d12); }
  .reg-table tbody tr.txn td.c-amt + td.c-amt::before, .reg-table tbody tr.sub td.c-amt + td.c-amt::before { content: '+'; }
  .reg-table tbody tr td.c-date { grid-area: date; width: auto; color: var(--muted); font-size: 12.5px; }
  .reg-table tbody tr td.c-cat { grid-area: cat; width: auto; font-size: 12.5px; color: var(--ink-2); }
  .reg-table tbody tr td.c-clr { grid-area: clr; width: auto; padding: 0; }
  .reg-table tbody tr td.c-acct { grid-area: acct; width: auto; font-size: 12px; color: var(--muted); }
  .reg-table tbody tr td.c-memo { grid-area: memo; font-size: 12px; color: var(--muted); }
  .reg-table tbody tr td.c-memo:empty, .reg-table tbody tr td.c-acct:empty { display: none; }
  .reg-table tbody tr.sub { padding-left: 2.6rem; background: #fcfcfe; }
  .reg-table tbody tr.sub td.c-payee { padding-left: 0; font-weight: 500; }
  .reg-table tbody tr.scheduled-head td, .reg-table tbody tr.section-head td { padding: .35rem .9rem; }
  .reg-table .cleared-btn { width: 26px; height: 26px; }

  /* The editor becomes a stacked form */
  .reg-table tr.editing.first {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: .45rem; padding: .7rem .9rem .3rem;
    grid-template-areas: "acct acct acct" "date date clr" "payee payee payee" "cat cat cat" "memo memo memo" "out in in";
    background: #f3f5ff; border-top: 2px solid var(--brand);
  }
  .reg-table tr.editing.first td { border-top: 0 !important; padding: 0 !important; width: auto !important; }
  .reg-table tr.editing.first td.c-chk, .reg-table tr.editing.first td.c-flag { display: none; }
  .reg-table tr.editing.first td.c-acct { grid-area: acct; }
  .reg-table tr.editing.first td.c-date { grid-area: date; }
  .reg-table tr.editing.first td.c-clr { grid-area: clr; display: flex; align-items: center; }
  .reg-table tr.editing.first td.c-payee { grid-area: payee; }
  .reg-table tr.editing.first td.c-cat { grid-area: cat; }
  .reg-table tr.editing.first td.c-memo { grid-area: memo; }
  .reg-table tr.editing.first td.c-amt { grid-area: out; }
  .reg-table tr.editing.first td.c-amt + td.c-amt { grid-area: in; }
  .reg-table tr.editing[data-split] {
    display: grid; grid-template-columns: auto 1fr 1fr; gap: .35rem; padding: .45rem .9rem .45rem .6rem; background: #f3f5ff;
    grid-template-areas: "del payee payee" "del cat cat" "del memo memo" "del out in";
  }
  .reg-table tr.editing[data-split] td { padding: 0 !important; }
  .reg-table tr.editing[data-split] td.c-flag { display: block; grid-area: del; align-self: center; }
  .reg-table tr.editing[data-split] td.c-payee { grid-area: payee; }
  .reg-table tr.editing[data-split] td.c-cat { grid-area: cat; }
  .reg-table tr.editing[data-split] td.c-memo { grid-area: memo; }
  .reg-table tr.editing[data-split] td.c-amt { grid-area: out; }
  .reg-table tr.editing[data-split] td.c-amt + td.c-amt { grid-area: in; }
  .reg-table tr.editing input, .reg-table tr.editing select { font-size: 16px; padding: .45rem .55rem; }
  .reg-table tr.edit-actions td { padding: .5rem .9rem .7rem; }
  .edit-actions-inner { flex-wrap: wrap; row-gap: .4rem; }
}
