/* ─────────────────────────────────────────────────────────────
   Palette — edit these to reskin the whole page.
   ───────────────────────────────────────────────────────────── */
:root {
  --bg:             #F5F3EE;
  --surface:        #FBFAF7;
  --surface-raised: #EEE9E0;

  --border:        #DED8CE;
  --border-strong: #C7BFB2;

  --text:       #34322F;
  --text-muted: #726D65;
  --text-faint: #9B948A;

  /* Brand / interaction — Slate Ink */
  --accent:        #5C7686;
  --accent-soft:   #EDF3F5;
  --accent-strong: #486170;

  /* Semantic — Moss (positive), Antique Brass (pending/review), Terracotta (risk) */
  --positive:      #6F8A73;
  --positive-soft: #EDF3EE;

  --pending:      #B39258;
  --pending-soft: #F7F2E7;

  --risk:      #A96A60;
  --risk-soft: #F8EEEB;

  --confirmed: #7F9087;

  /* Data visualization */
  --data-neutral: #A7AAA5;
  --data-focus:   #5C7686;

  /* Category-identification colors (rule 11 amendment) — light-mode static
     defaults; applyCategoryColors() overrides these for dark mode. Kept
     theme-independent on purpose, see the comment in app.js. */
  --cat-groceries: #B37B84;
  --cat-dining: #BC7A63;
  --cat-gas: #C08552;
  --cat-transport: #6E8CA0;
  --cat-subscriptions: #8C7BA6;
  --cat-health: #6FA090;
  --cat-shopping: #B08A5C;
  --cat-credit-card: #6B7A99;
  --cat-uncategorized: #8C8C86;

  --radius:    8px;
  --radius-sm: 6px;

  color-scheme: light;
}

/* Final 2026-07-09 pass: recurring/transaction grouping and compact credit
   account cards. Kept at EOF so older table/mobile rules above cannot leak
   priority fields or tall stacked metrics back into the UI. */
.viz-summary {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.bank-explorer-list {
  gap: 10px;
  border-top: 0;
}

.bank-explorer-month-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.bank-explorer-month-divider {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--surface-raised);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}

.bank-explorer-month-rows {
  display: flex;
  flex-direction: column;
}

.bank-explorer-row-card {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.bank-explorer-row-card--selected {
  background: var(--surface-raised);
  box-shadow: inset 3px 0 0 var(--accent);
}

.bank-explorer-row-card .bank-explorer-row {
  border-top: 0;
  min-height: 52px;
  padding: 10px 12px;
  cursor: pointer;
  background: transparent;
}

.bank-explorer-row-actions-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 12px 12px 52px;
}

.bank-explorer-row-hint {
  color: var(--accent);
  font-size: 11px;
}

.finance-credit-head,
.finance-credit-row {
  grid-template-columns: minmax(150px, 1.4fr) 86px 66px 58px 78px 86px 82px 86px 82px 86px;
}

.finance-credit-summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 12px;
}

.finance-credit-row {
  padding: 9px 0;
}

.finance-credit-priority,
.finance-payment-priority,
.finance-credit-input--priority {
  display: none !important;
}

@media (max-width: 760px) {
  .bank-explorer-list {
    gap: 8px;
    border: 0;
    background: transparent;
  }

  .bank-explorer-row-card .bank-explorer-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas:
      "icon desc amount"
      "icon date amount";
    gap: 5px 10px;
    min-height: 58px;
    padding: 10px 12px;
  }

  .bank-explorer-row-card .bank-explorer-row::before {
    display: none;
    content: none;
  }

  .bank-explorer-row-card .bank-explorer-date { grid-area: date; }
  .bank-explorer-row-card .bank-explorer-desc { grid-area: desc; }
  .bank-explorer-row-card .bank-explorer-amount { grid-area: amount; }

  .bank-explorer-row-actions-panel {
    padding: 0 12px 12px 56px;
  }

  .finance-credit-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .finance-credit-head {
    display: none;
  }

  .finance-credit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 12px;
    min-height: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  .finance-credit-row--selected {
    background: var(--surface-raised);
  }

  .finance-credit-row > span {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
  }

  .finance-credit-row > span::before {
    content: attr(data-label);
    color: var(--text-faint);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.45px;
    text-transform: uppercase;
  }

  .finance-credit-row > span:nth-child(1) {
    flex: 1 1 min(100%, 190px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .finance-credit-row > span:nth-child(1)::before {
    display: none;
  }

  .finance-credit-row > span:nth-child(2) {
    flex: 0 0 auto;
    margin-left: auto;
    flex-direction: column;
    align-items: flex-end;
  }

  .finance-credit-row > span:nth-child(n + 3):nth-child(-n + 10) {
    flex: 0 1 auto;
    font-size: 11.5px;
  }

  .finance-credit-card-hint {
    flex: 1 0 100%;
    padding: 0;
  }

  .finance-credit-card-hint::before {
    display: none;
  }
}

/* Clarity is light by default, deliberately, regardless of OS/browser dark
   preference — the project owner asked for this explicitly after finding
   the app rendering dark against their wishes. There is no automatic
   `@media (prefers-color-scheme: dark)` override; manual dark mode is an
   explicit, user-chosen Settings option, never something that silently kicks
   in because of an OS setting outside the app. */

/* ─────────────────────────────────────────────────────────────
   Reset & page shell
   ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  font-size: 15px;
  font-weight: 450;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Guarantee [hidden] always wins, even against later display:flex/grid rules
   on the same element (e.g. #login-view, #finance-body toggled from JS). */
[hidden] { display: none !important; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.page-header {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-header h1 { font-size: 20px; font-weight: 650; color: var(--text); }
.header-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.header-settings-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-raised);
}
.header-settings-btn svg,
.icon-btn svg {
  display: block;
}
.page-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}
.brand-home:hover .clarity-logo {
  background-color: var(--accent);
}
.clarity-logo {
  display: block;
  width: 104px;
  height: 44px;
  flex-shrink: 0;
  background-color: var(--text);
  -webkit-mask-image: url('logo-cat-glasses.png');
  mask-image: url('logo-cat-glasses.png');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: background-color 0.15s;
}
.header-toggle-all {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.header-toggle-all::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-top: -3px;
}
.header-toggle-all:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-raised);
}

#account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-menu {
  position: relative;
}
.icon-btn, .account-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover, .account-menu-trigger:hover { color: var(--text); border-color: var(--accent); }
.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.2px;
  line-height: 1;
}
.account-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 168px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}
.account-menu-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.account-menu-panel .btn { width: 100%; justify-content: flex-start; }
.account-page-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.account-page-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.account-page-row:first-child { border-top: none; padding-top: 0; }
.account-page-row--quiet {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}
.account-page-value {
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}
.account-page-muted {
  color: var(--text-faint);
  font-weight: 500;
}

#persist-status {
  margin-bottom: 14px;
  padding: 7px 11px;
  border: 1px solid color-mix(in srgb, var(--risk) 35%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--risk) 10%, transparent);
  color: var(--risk);
  font-size: 12.5px;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.app-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.app-loading-logo {
  width: 92px;
  height: 42px;
  background-color: var(--text);
  -webkit-mask-image: url('logo-cat-glasses.png');
  mask-image: url('logo-cat-glasses.png');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  animation: clarity-loading-pulse 1.2s ease-in-out infinite;
}
.app-loading-title {
  font-size: 18px;
  font-weight: 750;
  line-height: 1.1;
}
.app-loading-copy {
  font-size: 12px;
  color: var(--text-muted);
}
@keyframes clarity-loading-pulse {
  0%, 100% { opacity: 0.58; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
}

/* ── Login / signup ───────────────────────────────────────────── */
#login-view {
  display: flex;
  justify-content: center;
  padding-top: 60px;
}
.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
}
.login-card h2 { font-size: 16px; font-weight: 650; color: var(--text); }
.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-card .btn { margin-top: 4px; }
.login-error {
  font-size: 12.5px;
  color: var(--risk);
}
.login-security-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.login-switch {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.login-switch:hover { text-decoration: underline; }
.login-unlock-note {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: -6px;
}
.recovery-code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.5px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  word-break: break-all;
  user-select: all;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.settings-section:first-of-type { padding-top: 0; border-top: none; }
.settings-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.settings-section-copy {
  font-size: 12px;
  color: var(--text-muted);
}
.settings-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.settings-swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--text);
  cursor: pointer;
  padding: 0;
}
.settings-swatch:hover { border-color: var(--border-strong); }
.settings-swatch--active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.settings-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}
.settings-mode-btn {
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
}
.settings-mode-btn:hover { color: var(--text); }
.settings-mode-btn--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.admin-user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.admin-user-row span:first-child { color: var(--text); }
.admin-user-row span:last-child { color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ─────────────────────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.1px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn--primary:hover { filter: brightness(0.94); }
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  color: var(--text);
  background: var(--surface-raised);
}
.btn--sm { padding: 4px 10px; font-size: 11.5px; }

.quiet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  opacity: 0.5;
  transition: opacity 0.14s;
}
.quiet-actions:hover, .quiet-actions:focus-within { opacity: 1; }

/* ─────────────────────────────────────────────────────────────
   Finance — shared panel chrome
   ───────────────────────────────────────────────────────────── */
.finance-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.finance-shell--standalone {
  gap: 16px;
}

.finance-register-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 72px;
}

.full-page-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Underline tab selector (Rocket Money's mobile tab bar look) — used for the
   Activity view's Transactions/Recurring split now that recurring schedules
   moved out of Cash Flow and into this destination. */
.activity-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.activity-tab {
  flex: 1 1 0;
  padding: 10px 4px 9px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.activity-tab:hover { color: var(--text); }
.activity-tab--active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.activity-tab-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.activity-tab--active .activity-tab-count {
  background: var(--accent);
  color: #fff;
}
.finance-schedules-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.full-page-view--transactions .bank-explorer-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.full-page-view--transactions .bank-explorer-list {
  max-height: none;
  overflow: visible;
}
.full-page-view--transactions .bank-explorer-row {
  grid-template-columns: 64px minmax(0, 1fr) minmax(82px, auto) minmax(144px, auto);
}
.full-page-view--transactions .bank-explorer-desc {
  flex-direction: row;
  align-items: flex-start;
  white-space: normal;
}
.full-page-view--transactions .bank-explorer-desc-text {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}
.full-page-view--transactions .bank-explorer-desc-name {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}
.full-page-view--transactions .bank-explorer-desc-info {
  justify-content: flex-start;
  overflow: visible;
  white-space: normal;
  text-align: left;
}
.full-page-view--transactions .bank-explorer-row-actions {
  min-width: 0;
}
.full-page-view--transactions .bank-explorer-row-menu {
  max-width: 100%;
}

.more-sheet {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.more-sheet-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.more-sheet-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.more-sheet-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}
.more-sheet-action {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 9px 11px;
  cursor: pointer;
}
.more-sheet-action:hover {
  border-color: var(--border-strong);
}
.more-coming-soon {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.more-sheet-note {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
}

.finance-credit-score-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  padding: 12px;
}
.finance-credit-score-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.finance-credit-score-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.finance-credit-score-value {
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.finance-credit-score-note {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}
.finance-credit-score-projection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.finance-credit-score-projection-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.finance-credit-score-projection-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.finance-credit-score-projection-value {
  color: var(--text);
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.finance-credit-score-projection-delta {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.finance-credit-score-projection-delta--up { color: var(--positive); }
.finance-credit-score-projection-delta--down { color: var(--risk); }
.finance-credit-score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.finance-credit-score-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.finance-credit-score-breakdown-label { color: var(--text-muted); }
.finance-credit-score-breakdown-value { color: var(--text); font-variant-numeric: tabular-nums; }

/* What-if fields are always visible/editable, at the bottom of the card —
   not behind a separate edit dialog. */
.finance-credit-score-whatif {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.finance-credit-score-whatif-label {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.finance-credit-score-whatif-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 8px;
}
.finance-credit-score-whatif-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.finance-credit-score-whatif-field span {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.35px;
  line-height: 1.15;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.finance-credit-score-whatif-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.finance-credit-score-whatif-field:focus-within {
  border-color: var(--accent);
  background: var(--surface-raised);
}

.finance-planned-vs-actual-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.finance-planned-vs-actual-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  padding: 10px 12px;
}
.finance-planned-vs-actual-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.finance-planned-vs-actual-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.finance-planned-vs-actual-diff {
  font-size: 13px;
  font-weight: 600;
}
.finance-planned-vs-actual-diff--under { color: var(--positive); }
.finance-planned-vs-actual-diff--over { color: var(--risk); }
.finance-planned-vs-actual-detail {
  font-size: 12px;
  color: var(--text-muted);
}

/* A real, contained button — not the tiny 26x22px circular "⋯" icon style
   (.simplefin-overflow), which is built for a single glyph and looked
   cramped/blended-in when reused for text like "+ Add". */
.finance-add-menu {
  position: relative;
  display: inline-flex;
}
.finance-add-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.finance-add-menu > summary::-webkit-details-marker { display: none; }
.finance-add-menu > summary::after {
  content: "▾";
  font-size: 10px;
  color: var(--text-muted);
}
.finance-add-menu > summary:hover {
  border-color: var(--accent);
  color: var(--text);
}
.finance-add-menu-panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}
.finance-add-menu-panel .btn {
  justify-content: flex-start;
}
.full-page-view--insights .visualizations-block {
  margin: 0;
}

.finance-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 12px 14px;
  background: var(--surface);
  position: relative;
}

.finance-assets-block--has-corner-action {
  padding-bottom: 46px;
}

.finance-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.finance-section-toggle:hover { color: var(--text-muted); }
.finance-schedules-chevron { font-size: 8px; }

/* ── Assets ───────────────────────────────────────────────── */
.finance-assets-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.finance-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.finance-summary-item {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  min-width: 0;
}

.finance-summary-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.finance-summary-value {
  display: block;
  font-size: 18px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.finance-checking-source {
  display: block;
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.finance-summary-edit {
  font-size: 11px;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 0 0;
  font-family: inherit;
  display: block;
  text-align: left;
}
.finance-summary-edit:hover { color: var(--accent); }

.simplefin-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 6px;
}
/* Neutral, not the celebratory --positive green it used to be — connecting
   a bank is an optional convenience, not an achievement to nudge toward. */
.simplefin-sync-pill {
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  padding: 5px 10px;
  cursor: pointer;
}
.simplefin-sync-pill:hover {
  color: var(--text);
  border-color: var(--accent);
}
.simplefin-sync-pill--corner {
  position: absolute;
  right: 14px;
  bottom: 12px;
}
.simplefin-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.simplefin-primary-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.simplefin-overflow {
  position: relative;
  display: inline-flex;
}
.simplefin-overflow > summary {
  width: 26px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-faint);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.simplefin-overflow > summary::-webkit-details-marker { display: none; }
.simplefin-overflow > summary:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.simplefin-overflow .simplefin-actions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 5px);
  left: 0;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}
.simplefin-menu-note {
  display: block;
  max-width: 210px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.3;
}
.simplefin-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-faint);
  font: inherit;
  font-size: 10.5px;
  line-height: 1.2;
  cursor: pointer;
}
.simplefin-link + .simplefin-link::before {
  content: "/";
  color: var(--border-strong);
  margin-right: 7px;
}
.simplefin-overflow .simplefin-link + .simplefin-link::before,
.simplefin-primary-actions .simplefin-link + .simplefin-link::before {
  content: none;
  margin-right: 0;
}
.simplefin-link:hover { color: var(--accent); }
.simplefin-link--undo {
  color: var(--accent);
  font-weight: 650;
}
.simplefin-link--undo:hover { color: var(--risk); }
.simplefin-status {
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.25;
  max-width: 220px;
}

.finance-guidance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  padding-right: 36px;
}
.finance-guidance-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 2px;
}
.finance-guidance-copy {
  max-width: 620px;
  font-size: 12px;
  color: var(--text-muted);
}
.finance-guidance-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.finance-guidance-minimize {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.finance-guidance-minimize:hover { color: var(--text); background: rgba(0, 0, 0, 0.06); }
.finance-guidance-hide {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--text-faint);
  cursor: pointer;
}
.finance-guidance-hide:hover { color: var(--text-muted); text-decoration: underline; }
.finance-guidance-new-note {
  font-size: 10.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.finance-guidance-pill {
  align-self: flex-start;
  width: fit-content;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 11px;
  padding: 5px 12px;
  cursor: pointer;
}
.finance-guidance-pill:hover { color: var(--text); border-color: var(--accent); }


/* ── First-run setup ─────────────────────────────────────────── */
.setup-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.setup-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 18px 0 6px;
}
.setup-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 5px;
}
.setup-hero h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 7px;
}
.setup-hero p {
  max-width: 680px;
  font-size: 13px;
  color: var(--text-muted);
}
.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.setup-defer-credit {
  margin-top: -4px;
}
.setup-card-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}
.setup-card-copy {
  font-size: 12px;
  color: var(--text-muted);
}
.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.setup-meta {
  font-size: 11px;
  color: var(--text-faint);
}
.setup-review {
  gap: 8px;
}
.setup-transaction-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.setup-transaction-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 92px 82px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.setup-transaction-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.setup-transaction-row span:nth-child(3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.setup-empty {
  padding: 12px 0;
  font-size: 12px;
  color: var(--text-faint);
}

.hidden-assets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
}
.hidden-asset-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hidden-asset-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hidden-asset-bal {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.conn-row-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.hidden-asset-row:hover .conn-row-actions,
.hidden-asset-row:focus-within .conn-row-actions {
  opacity: 1;
  pointer-events: auto;
}

/* ── Forecast / cash flow ─────────────────────────────────────── */
.finance-at-a-glance {
  gap: 12px;
}
.finance-at-a-glance-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.finance-at-a-glance-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.finance-planning {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finance-planning-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.finance-planning-actions-row {
  justify-content: flex-end;
}
.finance-cashflow-controls-row {
  justify-content: space-between;
}
.finance-forecast-balance-toggles {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cashflow-filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.cashflow-filter-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cashflow-filter-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.finance-planning-subtitle {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text-muted);
}
.finance-forecast-summary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}
.finance-forecast-summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.finance-forecast-summary-top-text {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.finance-forecast-summary-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.finance-forecast-summary-kicker,
.finance-forecast-summary-label,
.finance-lowpoint-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.finance-forecast-summary-horizon {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.finance-forecast-summary-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.finance-forecast-summary-value {
  font-size: 24px;
  line-height: 1.05;
  font-weight: 750;
  color: var(--positive);
}
.finance-forecast-summary-title {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text);
}
.finance-forecast-summary-subline {
  font-size: 13px;
  color: var(--text-muted);
}
.finance-insights-trajectory--embedded {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Trajectory: a step graph of the same rows the ledger renders below it —
   never smoothed, since the balance doesn't change gradually between events.
   In the forecast panel it is clickable; in Insights it can render as a
   static summary. */
.finance-trajectory {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  padding: 10px 12px 8px;
  margin: 2px 0 4px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.finance-trajectory:hover {
  border-color: var(--border-strong);
}
.finance-trajectory--static {
  cursor: default;
}
.finance-trajectory--static:hover {
  border-color: var(--border);
}
.finance-trajectory-svg {
  display: block;
  width: 100%;
  height: 92px;
}
.finance-trajectory-line {
  stroke: var(--accent);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}
.finance-trajectory-zero {
  stroke: var(--risk);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.35;
  vector-effect: non-scaling-stroke;
}
.finance-trajectory-dot {
  fill: var(--accent);
}
.finance-trajectory-dot--neg {
  fill: var(--risk);
}
.finance-trajectory-caption {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

.finance-lowpoint-explain {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.finance-lowpoint-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.finance-lowpoint-value {
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--text);
  font-weight: 600;
}
.finance-lowpoint-note {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text-muted);
}

.finance-schedules {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.finance-schedules-count {
  font-weight: 400;
  opacity: 0.7;
  margin-left: 4px;
}

/* Each recurring schedule is its own contained card (not a table row) — no
   visible Edit button; a tap selects/highlights the card, a second tap on
   the already-selected card opens the edit dialog. See
   'select-finance-schedule' in app.js. */
.finance-schedule-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finance-schedule-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.finance-schedule-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.finance-schedule-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.finance-schedule-group-head:hover .finance-schedule-group-label {
  color: var(--text);
}

.finance-schedule-group-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.finance-schedule-group-count {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 11px;
}

.finance-schedule-group-total {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.finance-schedule-group-total--pos { color: var(--positive); }
.finance-schedule-group-total--neg { color: var(--risk); }

.finance-schedule-cards--grouped {
  gap: 0;
}

.finance-schedule-cards--grouped .finance-schedule-card {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.finance-schedule-cards--grouped .finance-schedule-card--selected {
  background: var(--surface-raised);
}

.finance-schedule-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.finance-schedule-card--selected {
  border-color: var(--accent);
  background: var(--surface-raised);
}

.finance-schedule-card-tap,
.finance-row-tap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  cursor: pointer;
}

.finance-schedule-card-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.finance-schedule-card-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.finance-schedule-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.finance-schedule-card-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.finance-schedule-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.finance-schedule-card-tag {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.finance-schedule-card--selected .finance-schedule-card-tag {
  background: var(--surface);
}

.finance-schedule-card-hint {
  font-size: 11px;
  color: var(--accent);
}

.finance-row-name {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.finance-row-subtle {
  font-size: 11px;
  color: var(--text-faint);
}

.finance-ledger {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

/* Archive rows are the one remaining consumer of the old dense grid layout
   (financeArchiveRow) — the main ledger row (financeRow) moved to the same
   tap-to-select card as Recurring, so this is scoped to archive only now. */
.finance-archive-row {
  display: grid;
  grid-template-columns: 92px minmax(170px, 1.55fr) minmax(124px, 0.9fr) minmax(96px, 0.7fr) minmax(132px, 0.82fr) 64px;
  align-items: center;
  column-gap: 10px;
}

.finance-balance-toggle {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
}
.finance-balance-toggle:hover { color: var(--text); border-color: var(--accent); }
.finance-balance-hide-toggle {
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-faint);
  font-size: 8.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
}
.finance-balance-hide-toggle:hover { color: var(--text); border-color: var(--accent); }

.finance-row {
  position: relative;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 6px;
}
.finance-row--selected {
  border-color: var(--accent);
  background: var(--surface-raised);
}
.finance-row-balance-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
}

.finance-date-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.finance-date-note {
  font-size: 11px;
  color: var(--text-faint);
}
.finance-row-paid-note {
  color: var(--confirmed);
  font-weight: 700;
}

.finance-row--matched {
  border-color: color-mix(in srgb, var(--pending) 38%, var(--border));
  background: color-mix(in srgb, var(--pending) 7%, var(--surface));
}
.finance-row--archived {
  background: color-mix(in srgb, var(--text) 3%, var(--surface));
  opacity: 0.7;
}
.finance-row-match {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 8px 14px 10px;
  border-top: 1px dashed var(--border-strong);
  border-color: color-mix(in srgb, var(--pending) 42%, var(--border));
  background: color-mix(in srgb, var(--pending) 8%, var(--surface));
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.finance-row-match-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 8px;
  min-width: 0;
  font-size: 12px;
}
.finance-row-match-label {
  color: var(--text);
  font-size: 11px;
}
.finance-row-match-desc {
  color: var(--text);
  font-weight: 600;
}
.finance-row-match-date,
.finance-row-match-amount {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.finance-row-match-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.finance-readonly--name {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.finance-balance--neg { color: var(--risk); }

.finance-empty-row { padding: 12px 0 6px; }
.finance-empty-row .quiet-actions { justify-content: flex-start; }

/* ── Collapsible month groups ────────────────────────────────── */
.finance-month-summary-totals-pos { color: var(--positive); }
.finance-month-summary-totals-neg { color: var(--risk); }

.finance-month-group {
  border-top: 1px solid var(--border);
  margin-top: 5px;
}
.finance-month-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.finance-month-group-chevron {
  font-size: 9px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.finance-month-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}
.finance-month-group-status {
  flex-shrink: 0;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.finance-month-group-head:hover .finance-month-group-label { color: var(--text); }
.finance-month-group-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
.finance-month-group-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  line-height: 1.2;
}
.finance-month-group-stat-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.finance-month-group-stat-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  /* Deliberately proportional, not tabular-nums — reads as a summary figure,
     not another column in the ledger's aligned number grid. */
}
.finance-month-group-stat--emphasize {
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.finance-month-group-stat-value--balance {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--positive);
}
.finance-month-group-stat-value--balance.finance-balance--neg { color: var(--risk); }
.finance-month-group-rows { padding-bottom: 4px; }

.finance-month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 10px;
  flex-wrap: wrap;
}
.finance-month-all--active {
  background: var(--surface-raised) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.finance-month-arrow { font-size: 14px; line-height: 1; padding: 4px 9px !important; }
.finance-month-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  transition: border-color 0.12s;
  cursor: pointer;
}
.finance-month-input:focus { border-color: var(--accent); }
.finance-month-sep { color: var(--text-faint); font-size: 13px; flex-shrink: 0; user-select: none; }

/* ── Credit accounts / payments ──────────────────────────────── */
.finance-credit-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.finance-credit-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.finance-credit-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-faint);
}
.finance-credit-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 18px;
}
.finance-credit-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.finance-credit-table {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}
.finance-credit-head,
.finance-credit-row {
  display: grid;
  grid-template-columns: 48px minmax(170px, 1.5fr) 58px 86px 86px 82px 66px 78px 86px 82px 86px;
  align-items: center;
  column-gap: 10px;
}
.finance-credit-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.finance-credit-head {
  padding: 8px 0 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface);
}
.finance-credit-row {
  min-height: 42px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.finance-credit-row:hover,
.finance-credit-row:focus-visible {
  background: var(--surface-raised);
  outline: none;
}
.finance-credit-row--selected {
  background: var(--surface-raised);
  box-shadow: inset 3px 0 0 var(--accent);
}
.finance-credit-account { color: var(--text); font-weight: 500; }
.finance-credit-account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.finance-credit-priority,
.finance-credit-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.finance-credit-money {
  text-align: right;
}
.finance-credit-card-hint {
  grid-column: 1 / -1;
  color: var(--accent);
  font-size: 11px;
  padding: 0 0 8px;
}
.finance-credit-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-bottom-color: var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 4px 1px;
  outline: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.finance-credit-input--name {
  color: var(--text);
  font-weight: 500;
}
.finance-credit-input--money { text-align: left; }
.finance-credit-input:hover,
.finance-credit-input:focus {
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  color: var(--text);
}
.finance-credit-input--linked {
  color: var(--accent);
  font-weight: 500;
}
.finance-credit-linked { color: var(--accent); font-weight: 500; }
.finance-credit-unlinked { color: var(--text-faint); }
.finance-credit-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0.75;
  transition: opacity 0.12s;
}
.finance-credit-row:hover .finance-credit-row-actions { opacity: 1; }

.credit-import-map {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.credit-import-map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr);
  align-items: center;
  gap: 10px;
}
.credit-import-source {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.credit-import-source span {
  color: var(--text);
  font-size: 13px;
}
.credit-import-source small {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.credit-import-select {
  min-height: 34px;
}
.import-review-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.import-review-summary strong {
  color: var(--text);
}
.import-review-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.import-review-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 90px;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
.import-review-row:first-child { border-top: 0; }
.import-review-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.import-review-row span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.finance-payment-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.finance-payment-group { border-top: 1px solid var(--border); padding-top: 8px; }
.finance-payment-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.finance-payment-group-head:hover .finance-payment-account { color: var(--text); }
.finance-payment-account { font-size: 12px; color: var(--text); }
.finance-payment-total { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.finance-payment-items { display: flex; flex-direction: column; gap: 2px; }
.finance-payment-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.finance-payment-item--adhoc {
  color: var(--accent);
  font-style: italic;
}
.finance-adhoc-delete {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1;
  opacity: 0.3;
  transition: opacity 0.12s;
}
.finance-payment-item:hover .finance-adhoc-delete { opacity: 1; }
.finance-payment-empty {
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}
.finance-payment-group-actions {
  margin-top: 6px;
}

/* Forecast accuracy — deliberately the same quiet weight as the payment
   list above, not a new visual register: this is a look-back, not a call
   to action. */
.finance-accuracy-list { display: flex; flex-direction: column; gap: 8px; }
.finance-accuracy-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.finance-accuracy-month {
  font-size: 12px;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 90px;
}
.finance-accuracy-figure {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.finance-accuracy-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.finance-accuracy-pending {
  color: var(--text-faint);
  font-style: italic;
}
.finance-accuracy-diff { color: var(--positive); }
.finance-accuracy-diff.finance-balance--neg { color: var(--risk); }

/* ── Dialog modal (replaces browser prompt/confirm) ──────────── */
#dlg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#dlg-overlay[hidden] { display: none; }
#dlg-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  padding: 20px 22px 16px;
  min-width: 300px;
  max-width: 440px;
  max-height: 85vh;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.dlg-close-x {
  position: sticky;
  top: 0;
  align-self: flex-end;
  z-index: 1;
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  margin: -10px -10px -28px 0;
  cursor: pointer;
}
.dlg-close-x:hover { color: var(--text); }
#dlg-box:has(.simplefin-help-dialog) {
  max-width: 760px;
}
#dlg-box:has(.bank-explorer-dialog) {
  max-width: 560px;
}
/* Purely visual reinforcement of "this is a sheet, swipe/tap away to
   cancel" — the close-x and backdrop already do the actual dismissing. */
.sheet-grabber {
  display: none;
}
@media (max-width: 640px) {
  .sheet-grabber {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: -6px auto 4px;
  }
}
.schedule-sheet-new .btn {
  width: 100%;
  justify-content: center;
}
.schedule-sheet-divider {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin: 2px 0;
}
.schedule-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 42vh;
  overflow-y: auto;
}
.schedule-sheet-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.schedule-sheet-row:hover, .schedule-sheet-row:active {
  border-color: var(--accent);
  background: var(--surface-raised);
}
.schedule-sheet-row-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.schedule-sheet-row-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}
#dlg-msg { font-size: 13px; color: var(--text); white-space: pre-line; line-height: 1.45; padding-right: 28px; }
#dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
#dlg-cancel {
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
#dlg-ok {
  padding: 5px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  font-size: 12.5px;
  color: #fff;
  cursor: pointer;
}
#dlg-replace {
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
#dlg-replace:hover { border-color: var(--accent); color: var(--text); }
.dlg-delete-btn {
  margin-right: auto;
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 12.5px;
  color: var(--risk);
  cursor: pointer;
}
.dlg-delete-btn:hover { border-color: var(--risk); background: color-mix(in srgb, var(--risk) 10%, transparent); }
/* Non-destructive extra dialog actions (Mark as paid, Convert to
   recurring) — same neutral look as Cancel. Always place before
   .dlg-delete-btn in markup so that button's margin-right:auto pushes the
   whole left-side cluster away from Cancel/OK correctly. */
.dlg-secondary-btn {
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.dlg-secondary-btn:hover { border-color: var(--accent); color: var(--text); }
.dlg-field { display: flex; flex-direction: column; gap: 3px; }
.dlg-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.dlg-field-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.dlg-field-input:focus { border-color: var(--accent); }
select.dlg-field-input, select.dlg-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
  cursor: pointer;
}

.simplefin-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.simplefin-picker-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.simplefin-picker-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.simplefin-account-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.simplefin-account-choice input {
  flex: 0 0 auto;
}
.simplefin-picker-empty {
  font-size: 12px;
  color: var(--text-faint);
}
.simplefin-help-intro {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.simplefin-billing-note {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  padding: 12px;
}
.simplefin-token-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.simplefin-open-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  padding: 8px 13px;
  text-decoration: none;
}
.simplefin-open-link:hover {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.simplefin-connect-top {
  align-self: flex-start;
}
.simplefin-help-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.simplefin-help-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.simplefin-help-copy {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.simplefin-help-number {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.simplefin-help-title {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
}
.simplefin-help-text {
  font-size: 11.5px;
  color: var(--text-muted);
}
.simplefin-help-image {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
}
.bank-explorer-intro {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.bank-explorer-empty-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 12px;
  text-align: center;
  align-items: center;
}
.bank-explorer-empty-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}
.bank-explorer-empty-copy {
  max-width: 340px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.bank-explorer-empty-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.bank-explorer-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  max-height: min(46vh, 360px);
  overflow-y: auto;
}
/* Rocket Money-style month divider between groups in the continuous feed —
   plain label + that month's total spend, not an accordion/toggle. */
.bank-explorer-month-divider {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 2px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.bank-explorer-month-divider:first-child {
  padding-top: 2px;
}
/* Same row list, sitting directly on the page instead of in a dialog — a
   taller cap since there's no modal chrome competing for vertical space,
   but still capped so 14 days of activity can't push the rest of the page
   away. */
.bank-explorer-list--inline {
  max-height: min(50vh, 480px);
  border-top: none;
}
.finance-recent-activity-footer {
  display: flex;
  justify-content: center;
  padding-top: 10px;
}
.finance-recent-activity-block .bank-explorer-row {
  grid-template-columns: 58px minmax(0, 1fr) 78px;
  grid-template-areas:
    "date desc amount"
    "actions actions actions";
  row-gap: 6px;
  padding: 5px 0 8px;
}
.finance-recent-activity-block .bank-explorer-date { grid-area: date; }
.finance-recent-activity-block .bank-explorer-desc { grid-area: desc; }
.finance-recent-activity-block .bank-explorer-amount { grid-area: amount; }
.finance-recent-activity-block .bank-explorer-row-actions {
  grid-area: actions;
  width: 100%;
  justify-content: flex-start;
  flex-wrap: nowrap;
}
.finance-recent-activity-block .bank-explorer-row-menu {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-width: 0;
}
.category-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 999px;
}

.settings-category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.settings-category-row:hover { background: var(--surface-raised); }
.settings-category-default {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
}
.category-name-input {
  margin-top: 6px;
}

.category-picker-section {
  margin-bottom: 12px;
}
.category-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.category-icon-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.category-icon-option--active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.category-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.category-swatch-option {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
}
.category-swatch-option--active {
  border-color: var(--text);
}

/* Swipe-to-reveal shell: the row (front) sits on top of its own actions
   (back) and slides left to reveal them, instead of the actions ever being
   visible by default. See the pointerdown/move/up handlers in app.js. */
.bank-explorer-row-shell {
  position: relative;
  overflow: hidden;
}
.bank-explorer-row-back {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  background: var(--surface-raised);
}
.bank-explorer-row-back-content {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 6px 6px;
}
.bank-explorer-row-back-content .btn {
  white-space: nowrap;
}
[data-swipe-front] {
  position: relative;
  touch-action: pan-y;
  transition: transform 0.18s ease;
  cursor: pointer;
}
.bank-explorer-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 78px auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  /* Explicit, not just inherited from an ancestor — an unmodified ("new")
     row otherwise had no background of its own, showing through to
     whatever the panel painted. The status-modifier rows below already
     paint their own tinted background; plain ones need the same. */
  background: var(--surface);
}
.simplefin-picker-group .bank-explorer-row:not(:has(.bank-explorer-date)) {
  grid-template-columns: minmax(0, 1fr) 88px 82px;
}
.bank-explorer-date {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.bank-explorer-desc {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  color: var(--text);
}
.bank-explorer-desc-text {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.bank-explorer-desc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.bank-explorer-desc-info {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-align: right;
}
.bank-explorer-alias {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-faint);
  font-style: italic;
}
.bank-explorer-row--scheduled {
  /* Mixed into var(--surface), not transparent — a fully opaque tint of the
     row's own surface color, not a see-through wash over whatever's behind
     it (a transparent tint let the panel's background bleed through
     inconsistently). */
  background: color-mix(in srgb, var(--positive) 7%, var(--surface));
}
.bank-explorer-row--scheduled .bank-explorer-desc {
  color: var(--text-faint);
}
.bank-explorer-row--ignored {
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
}
.bank-explorer-row--ignored .bank-explorer-desc {
  color: var(--text-faint);
}
.bank-explorer-row--discretionary {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.bank-explorer-row--discretionary .bank-explorer-desc {
  color: var(--text-faint);
}
.bank-explorer-row--accounted {
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
}
.bank-explorer-row--accounted .bank-explorer-desc {
  color: var(--text-faint);
}
.bank-explorer-scheduled-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--positive) 14%, transparent);
  color: var(--positive);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  vertical-align: middle;
}
.bank-explorer-scheduled-tag--ignored {
  background: var(--surface-raised);
  color: var(--text-faint);
}
.bank-explorer-scheduled-tag--discretionary {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.bank-explorer-scheduled-tag--accounted {
  background: var(--surface-raised);
  color: var(--text-faint);
}
.bank-explorer-scheduled-check {
  text-align: center;
  color: var(--positive);
  font-weight: 650;
}
/* Lives in the right-aligned info group next to the raw description now,
   not stacked as its own line underneath it. */
.bank-explorer-match-note {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.bank-explorer-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bank-explorer-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.bank-explorer-inline-actions {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}
.bank-explorer-inline-actions .btn {
  min-height: 28px;
  white-space: nowrap;
}
/* Solid color block per action (Rocket Money's swipe-action treatment),
   mapped onto the existing semantic hues rather than new ones — these are
   actions, not data categories, so they stay inside the 5-hue system. Icon on
   top, one word below (see btn()'s `icon` option) — every block is the same
   width and never wraps to a second row. */
.bank-row-action--accent, .bank-row-action--pending, .bank-row-action--risk, .bank-row-action--neutral {
  border: none;
  color: #fff;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  padding: 5px 1px;
}
.bank-row-action--accent .btn-icon,
.bank-row-action--pending .btn-icon,
.bank-row-action--risk .btn-icon,
.bank-row-action--neutral .btn-icon {
  display: flex;
}
.bank-row-action--accent .btn-label,
.bank-row-action--pending .btn-label,
.bank-row-action--risk .btn-label,
.bank-row-action--neutral .btn-label {
  font-size: 9.5px;
  line-height: 1.1;
  white-space: nowrap;
}
.bank-row-action--accent { background: var(--accent); }
.bank-row-action--pending { background: var(--pending); }
.bank-row-action--risk { background: var(--risk); }
.bank-row-action--neutral { background: var(--data-neutral); }
/* Replaces what used to be up to six separate icon buttons on a single
   "new" row — one compact control standing in for all of them. */
.bank-explorer-row-menu {
  max-width: 128px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
}
.bank-explorer-row-menu:hover { border-color: var(--accent); color: var(--text); }
/* Some browsers render <option> text using their own OS-level muted/disabled
   gray instead of the author color, especially for the first/placeholder
   option — invisible against a dark --surface. Force it explicitly rather
   than relying on inheritance from the <select>. */
.bank-explorer-row-menu option {
  color: var(--text);
  background: var(--surface);
}
.bank-explorer-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.bank-explorer-filter-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.bank-explorer-filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.bank-explorer-filter-chip--active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}
.bank-explorer-filter-count {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  cursor: help;
  font-style: normal;
}
.info-tip:hover, .info-tip:focus-visible { color: var(--text-muted); }
.dlg-static-value {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);
}
.dlg-checkbox-field {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.dlg-checkbox-field input { flex: 0 0 auto; width: auto; }

/* ── Navigation dock: contained mobile-style bottom bar ─────────────── */
.dock {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 600;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.dock-icons {
  width: min(100%, 560px);
  min-height: 62px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  overflow: hidden;
}
.dock-icon {
  position: relative;
  min-width: 0;
  min-height: 58px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
}
.dock-icon:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.dock-icon--active {
  color: var(--text);
}
.dock-icon--active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
}
.dock-icon-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 20px;
  font-size: 18px;
  font-weight: 750;
}
/* The magnifying glass (Activity) and pie glyph (Insights) render visually
   smaller than $ and ☰ at the same font-size — bumped up to match weight. */
.dock-icon[data-id="activity"] .dock-icon-glyph,
.dock-icon[data-id="insights"] .dock-icon-glyph {
  font-size: 22px;
}
.dock-icon-glyph svg {
  width: 20px;
  height: 20px;
}
.dock-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.1;
}
.dock-icon--active .dock-label,
.dock-icon--active .dock-icon-glyph {
  color: var(--text);
}

/* ── Home page ─────────────────────────────────────────────────── */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 48px 8px;
}
.home-date {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.home-greeting {
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}
.settings-name-row {
  display: flex;
  gap: 8px;
}
.settings-name-row .dlg-field-input { flex: 1 1 auto; }

/* ── Touch devices: hover-gated affordances need to just be visible ──── */
@media (hover: none) {
  .finance-credit-row-actions,
  .conn-row-actions,
  .finance-adhoc-delete,
  .quiet-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   Mobile — this isn't the desktop layout shrunk down. Dense grids
   (ledger, schedules, credit accounts) become stacked cards; column
   headers that no longer mean anything become inline labels instead;
   dialogs become bottom sheets within thumb reach.
   ───────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }

  .page {
    padding-top: 20px;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  /* ── Header ──────────────────────────────────────────────── */
  .page-header { align-items: flex-start; }
  .header-toggle-all { width: 26px; height: 26px; }
  #account-bar { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

  /* ── Buttons: comfortable tap targets ────────────────────── */
  .btn { padding: 9px 14px; font-size: 13px; min-height: 36px; }
  .btn--sm { padding: 7px 11px; font-size: 12px; min-height: 32px; }

  /* ── Balances panel: the headline, so it leads and reads big ─ */
  .finance-summary { grid-template-columns: 1fr; gap: 14px; }
  .finance-summary-value { font-size: 21px; }

  .finance-guidance {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .finance-guidance-actions { justify-content: flex-start; }
  .setup-hero { grid-template-columns: 1fr; align-items: start; }
  .setup-grid { grid-template-columns: 1fr; }
  .setup-transaction-row { min-width: 620px; }

  /* ── Ledger: each transaction becomes a card, not a scrolling row ── */
  .finance-balance-toggle { width: 22px; height: 22px; font-size: 11px; }
  .finance-balance-hide-toggle { padding: 5px 9px; font-size: 10px; }

  .finance-month-group-head { flex-wrap: wrap; }
  .finance-month-group-stats { margin-left: 0; gap: 10px; }

  /* ── Credit accounts: column headers become inline labels ── */
  .finance-credit-head { display: none; }
  .finance-credit-table { overflow-x: visible; }
  .finance-credit-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "acct    acct    acct"
      "apr     bal     lim"
      "avail   util    plnutil"
      "pay     plnpaid plnpaid"
      "actions actions actions";
    row-gap: 10px;
    column-gap: 12px;
    padding: 14px 0;
    min-height: 0;
  }
  .finance-credit-row > span:nth-child(1) { grid-area: acct; }
  .finance-credit-row > span:nth-child(2) { grid-area: apr; }
  .finance-credit-row > span:nth-child(3) { grid-area: bal; }
  .finance-credit-row > span:nth-child(4) { grid-area: lim; }
  .finance-credit-row > span:nth-child(5) { grid-area: avail; }
  .finance-credit-row > span:nth-child(6) { grid-area: util; }
  .finance-credit-row > span:nth-child(7) { grid-area: pay; }
  .finance-credit-row > span:nth-child(8) { grid-area: plnpaid; }
  .finance-credit-row > span:nth-child(9) { grid-area: plnutil; }
  .finance-credit-row > span:nth-child(10) { grid-area: actions; }
  .finance-credit-row > span:nth-child(n + 2):nth-child(-n + 9) {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }
  .finance-credit-row > span:nth-child(n + 2):nth-child(-n + 9)::before {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .finance-credit-row > span:nth-child(2)::before { content: "APR"; }
  .finance-credit-row > span:nth-child(3)::before { content: "Balance"; }
  .finance-credit-row > span:nth-child(4)::before { content: "Limit"; }
  .finance-credit-row > span:nth-child(5)::before { content: "Avail."; }
  .finance-credit-row > span:nth-child(6)::before { content: "Util."; }
  .finance-credit-row > span:nth-child(7)::before { content: "Monthly pmt"; }
  .finance-credit-row > span:nth-child(8)::before { content: "Planned paid"; }
  .finance-credit-row > span:nth-child(9)::before { content: "Planned util."; }
  .finance-credit-row-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .finance-payment-groups { grid-template-columns: 1fr; }

  /* ── Bank transaction review: rows become cards too ─────── */
  .bank-explorer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "desc amount"
      "date amount"
      "actions actions";
    row-gap: 6px;
    column-gap: 12px;
    padding: 13px 10px;
    min-height: 64px;
    font-size: 14px;
    background: var(--surface);
  }
  .finance-recent-activity-block .bank-explorer-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "desc amount"
      "date amount"
      "actions actions";
    row-gap: 8px;
    column-gap: 12px;
    padding: 13px 10px;
    min-height: 86px;
  }
  .bank-explorer-row--scheduled {
    background: color-mix(in srgb, var(--positive) 11%, var(--surface));
  }
  .bank-explorer-row--ignored,
  .bank-explorer-row--accounted {
    background: color-mix(in srgb, var(--text) 6%, var(--surface));
  }
  .bank-explorer-row--discretionary {
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  }
  .bank-explorer-date {
    grid-area: date;
    font-size: 11.5px;
    line-height: 1.2;
  }
  .bank-explorer-amount {
    grid-area: amount;
    align-self: start;
    padding-top: 1px;
    font-size: 14px;
    font-weight: 750;
    line-height: 1.2;
    color: var(--text);
  }
  .bank-explorer-amount--credit { color: var(--positive); }
  .bank-explorer-amount--debit { color: var(--risk); }
  .bank-explorer-desc {
    grid-area: desc;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
    white-space: normal;
  }
  .bank-explorer-desc-text {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
  }
  .bank-explorer-desc-name {
    display: block;
    width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
  }
  .bank-explorer-row--scheduled .bank-explorer-desc-name,
  .bank-explorer-row--ignored .bank-explorer-desc-name,
  .bank-explorer-row--discretionary .bank-explorer-desc-name,
  .bank-explorer-row--accounted .bank-explorer-desc-name {
    color: var(--text-muted);
  }
  .bank-explorer-desc-info {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 4px 6px;
    width: 100%;
    overflow: visible;
    white-space: normal;
    text-align: left;
    font-size: 11.5px;
    line-height: 1.25;
  }
  .bank-explorer-alias,
  .bank-explorer-match-note {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .bank-explorer-alias {
    flex: 1 1 100%;
    color: var(--text-muted);
  }
  .bank-explorer-scheduled-tag {
    margin-left: 0;
    font-size: 10px;
  }
  .bank-explorer-row-actions {
    grid-area: actions;
    width: 100%;
    justify-content: flex-start;
    align-items: stretch;
    padding-top: 4px;
    border-top: 1px solid var(--border);
  }
  .finance-recent-activity-block .bank-explorer-row-actions {
    justify-content: flex-start;
    align-items: stretch;
    flex-wrap: wrap;
    padding-top: 8px;
  }
  .finance-recent-activity-block .bank-explorer-inline-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }
  .finance-recent-activity-block .bank-explorer-inline-actions .btn {
    width: 100%;
    min-height: 36px;
    padding-inline: 8px;
    justify-content: center;
  }
  .simplefin-picker-group .bank-explorer-row > .btn {
    grid-area: actions;
    justify-self: flex-start;
  }
  .bank-explorer-row-menu {
    flex: 1 1 190px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 36px;
    border-radius: var(--radius-sm);
    font-size: 12px;
  }
  .finance-recent-activity-block .bank-explorer-row-menu {
    flex: 1 1 220px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 38px;
  }
  /* ── Dialogs: bottom sheet, primary action within thumb reach ── */
  #dlg-overlay { align-items: flex-end; }
  #dlg-box {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    padding: 18px 16px 0;
  }
  #dlg-btns {
    position: sticky;
    bottom: 0;
    margin: 8px -16px 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
}

/* Match & archive state styling */
.finance-row-match-ambiguity {
  display: block;
  flex: 1 1 100%;
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-muted);
}

.finance-row-match--ambiguous {
  border-style: dashed;
}

.finance-archive-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.finance-archive-list {
  display: flex;
  flex-direction: column;
}
.finance-archive-row {
  color: var(--text-muted);
}
.finance-archive-date,
.finance-archive-name,
.finance-archive-category,
.finance-archive-amount,
.finance-archive-muted {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.finance-archive-date,
.finance-archive-amount {
  font-variant-numeric: tabular-nums;
}
.finance-archive-muted {
  color: var(--text-muted);
}
.finance-archive-status {
  display: flex;
  justify-content: center;
}
.finance-archive-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.finance-archive-tag--paid,
.finance-archive-tag--received {
  background: color-mix(in srgb, var(--positive) 12%, transparent);
  color: var(--positive);
}
.finance-archive-tag--skipped {
  background: color-mix(in srgb, var(--pending) 14%, transparent);
  color: var(--text-muted);
}

.finance-row-rejected-note {
  color: var(--text-muted);
  font-weight: 700;
}

.finance-match-archive-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--confirmed) 38%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--confirmed) 8%, var(--surface));
  color: var(--text);
}

.finance-match-archive-feedback__text {
  font-weight: 800;
  color: var(--confirmed);
}

.finance-match-archive-feedback__detail {
  color: var(--text-muted);
  font-size: 12px;
}

/* Credit account table — sorting & priority order */
.finance-credit-head,
.finance-credit-row {
  grid-template-columns: 48px minmax(160px, 1.5fr) 58px 80px 80px 74px 66px 78px 82px 78px 80px;
  column-gap: 8px;
}

.finance-credit-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
}

.finance-credit-sort:hover,
.finance-credit-sort--active {
  color: var(--text);
}

.finance-credit-sort-arrow {
  color: var(--accent);
  font-size: 9px;
}

.finance-credit-account {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.finance-credit-input--priority {
  text-align: center;
}

.finance-payment-account {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.finance-payment-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.finance-credit-minimum-note {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .finance-credit-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "prio   acct    acct"
      "apr    bal     lim"
      "avail  util    plnutil"
      "minpay planpay plnpaid"
      "actions actions actions";
  }

  .finance-credit-row > span:nth-child(1) { grid-area: prio; }
  .finance-credit-row > span:nth-child(2) { grid-area: acct; }
  .finance-credit-row > span:nth-child(3) { grid-area: apr; }
  .finance-credit-row > span:nth-child(4) { grid-area: bal; }
  .finance-credit-row > span:nth-child(5) { grid-area: lim; }
  .finance-credit-row > span:nth-child(6) { grid-area: avail; }
  .finance-credit-row > span:nth-child(7) { grid-area: util; }
  .finance-credit-row > span:nth-child(8) { grid-area: minpay; }
  .finance-credit-row > span:nth-child(9) { grid-area: planpay; }
  .finance-credit-row > span:nth-child(10) { grid-area: plnpaid; }
  .finance-credit-row > span:nth-child(11) { grid-area: plnutil; }
  .finance-credit-row > span:nth-child(12) { grid-area: actions; }

  .finance-credit-row > span:nth-child(n + 1):nth-child(-n + 11) {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .finance-credit-row > span:nth-child(n + 1):nth-child(-n + 11)::before {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-faint);
  }

  .finance-credit-row > span:nth-child(1)::before { content: "Priority"; }
  .finance-credit-row > span:nth-child(2)::before { content: "Account"; }
  .finance-credit-row > span:nth-child(3)::before { content: "APR"; }
  .finance-credit-row > span:nth-child(4)::before { content: "Balance"; }
  .finance-credit-row > span:nth-child(5)::before { content: "Limit"; }
  .finance-credit-row > span:nth-child(6)::before { content: "Avail."; }
  .finance-credit-row > span:nth-child(7)::before { content: "Util."; }
  .finance-credit-row > span:nth-child(8)::before { content: "Min due"; }
  .finance-credit-row > span:nth-child(9)::before { content: "Planned pmt"; }
  .finance-credit-row > span:nth-child(10)::before { content: "Planned paid"; }
  .finance-credit-row > span:nth-child(11)::before { content: "Planned util."; }
}

@media (prefers-reduced-motion: reduce) {
  .app-loading-logo { animation: none; }
}

@media (max-width: 760px) {
  .page {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .page-header {
    position: sticky;
    top: 0;
    z-index: 520;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) minmax(42px, auto);
    align-items: center;
    gap: 8px;
    margin: calc(-10px - env(safe-area-inset-top)) calc(-14px - env(safe-area-inset-left)) 14px calc(-14px - env(safe-area-inset-right));
    padding: calc(8px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 94%, var(--surface));
  }

  .header-settings-btn {
    grid-column: 1;
    justify-self: start;
    width: 28px;
    height: 28px;
  }

  .page-title {
    grid-column: 2;
    justify-content: center;
    min-width: 0;
  }

  .brand-home {
    justify-content: center;
    min-width: 0;
  }

  .clarity-logo {
    width: 42px;
    height: 28px;
  }

  .page-header h1 {
    font-size: 17px;
    line-height: 1;
  }

  .header-toggle-all {
    display: none;
  }

  #account-bar {
    grid-column: 3;
    justify-content: flex-end;
    flex-wrap: nowrap;
    min-width: 0;
  }

  #account-bar > .btn {
    display: none;
  }

  .account-menu-trigger,
  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .account-menu-panel {
    right: 0;
    min-width: min(220px, calc(100vw - 28px));
  }

  .finance-shell,
  .finance-register-group,
  .finance-credit-section {
    gap: 12px;
  }

  .home-page {
    padding: 24px 2px 4px;
    scroll-margin-top: 72px;
  }

  .home-greeting {
    font-size: 28px;
  }

  .finance-panel {
    border-radius: 8px;
    padding: 14px;
    scroll-margin-top: 72px;
  }

  .finance-section-toggle {
    min-height: 32px;
    font-size: 11px;
  }

  .finance-transactions-entry {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-raised);
    color: var(--text-muted);
    font: inherit;
    cursor: text;
  }

  .finance-transactions-entry:focus-within {
    color: var(--text);
    border-color: var(--border-strong);
  }

  .finance-transactions-entry-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
  }

  .finance-transactions-entry-input {
    min-width: 0;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--text);
  }
  .finance-transactions-entry-input::placeholder { color: var(--text-muted); }

  .full-page-view--transactions .bank-explorer-dialog {
    gap: 14px;
  }

  .full-page-view--transactions #dlg-msg {
    font-size: 22px;
    font-weight: 750;
    padding-right: 0;
  }

  .full-page-view--transactions .bank-explorer-search-field {
    position: relative;
  }

  .full-page-view--transactions .bank-explorer-search-field .dlg-label {
    display: none;
  }

  .full-page-view--transactions [data-bank-explorer-search] {
    min-height: 52px;
    border-radius: 14px;
    padding-left: 42px;
    padding-right: 42px;
    font-size: 16px;
    background: var(--surface-raised);
  }

  .full-page-view--transactions .bank-explorer-search-field::before {
    content: "⌕";
    position: absolute;
    left: 14px;
    top: 50%;
    z-index: 1;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
  }

  .full-page-view--transactions .bank-explorer-search-field::after {
    content: "≡";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
  }

  .bank-explorer-list,
  .finance-credit-table,
  .finance-payment-groups,
  .finance-month-group,
  .finance-archive-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
  }

  .bank-explorer-list {
    border-top: 1px solid var(--border);
  }

  .bank-explorer-row,
  .finance-recent-activity-block .bank-explorer-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    border-top: 1px solid var(--border);
    border-radius: 0;
    padding: 13px 12px;
  }

  .bank-explorer-row {
    grid-template-areas:
      "icon desc amount"
      "icon date amount"
      "actions actions actions";
  }

  .full-page-view--transactions .bank-explorer-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas:
      "icon desc amount"
      "icon date amount"
      "actions actions actions";
    row-gap: 8px;
    min-height: 0;
  }

  .full-page-view--transactions .bank-explorer-row-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
  }

  .full-page-view--transactions .bank-explorer-row-menu {
    width: 100%;
    min-width: 0;
  }

  .full-page-view--transactions .bank-explorer-row-actions .btn {
    min-width: 38px;
    min-height: 36px;
    justify-content: center;
  }

  .bank-explorer-row::before {
    content: "$";
    grid-area: icon;
    align-self: start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 13%, var(--surface));
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
  }

  .bank-explorer-row--scheduled::before,
  .bank-explorer-row--accounted::before {
    content: "✓";
    background: color-mix(in srgb, var(--positive) 13%, var(--surface));
    color: var(--positive);
  }

  .bank-explorer-row--ignored::before {
    content: "–";
    background: var(--surface-raised);
    color: var(--text-muted);
  }

  .bank-explorer-row--discretionary::before {
    content: "•";
    background: color-mix(in srgb, var(--pending) 15%, var(--surface));
    color: var(--pending);
  }

  .bank-explorer-row:first-child,
  .finance-recent-activity-block .bank-explorer-row:first-child {
    border-top: 0;
  }

  .finance-credit-row,
  .finance-payment-group,
  .finance-archive-row {
    border-top: 1px solid var(--border);
    padding-left: 12px;
    padding-right: 12px;
  }

  .finance-credit-row:first-of-type,
  .finance-payment-group:first-child,
  .finance-archive-row:first-child {
    border-top: 0;
  }

  .finance-ledger {
    border-top: 0;
  }

  .finance-month-group {
    margin-top: 8px;
  }

  .finance-month-group-head {
    padding: 12px;
  }

  .finance-month-group-rows {
    padding-bottom: 0;
  }

  .finance-archive-amount,
  .bank-explorer-amount,
  .finance-payment-total,
  .finance-payment-item span:nth-child(2),
  .hidden-asset-bal {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .finance-payment-groups {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .finance-payment-group {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .finance-credit-table {
    border-top: 1px solid var(--border);
  }

  .finance-credit-summary {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

  .dock {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    justify-content: center;
  }

  .dock-icons {
    width: min(100%, 430px);
    min-height: 66px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 22px;
  }
}

/* Authoritative fix for the transaction-name-unreadable bug: three earlier
   mobile media-query passes (~2873, ~2932, ~3477) left the description
   column narrow enough, combined with overflow-wrap:anywhere, that names
   were breaking every 3-4 characters instead of being readable. Rather than
   untangle which of those three wins in which combination, this is placed
   last and matches their same specificity, so it always wins outright:
   single-line ellipsis truncation, the same reliable pattern already used
   successfully on desktop, guarantees a readable name regardless of exactly
   how narrow the column ends up being. */
@media (max-width: 760px) {
  .bank-explorer-desc-name {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
  }
}

/* Authoritative mobile treatment for Credit Accounts after the row surface
   moved from inline table inputs to tap-to-edit cards. Earlier mobile
   table-grid rules are left in place for history but intentionally lose to
   this final block. */
@media (max-width: 760px) {
  .finance-credit-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .finance-credit-summary {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px 12px;
  }

  .finance-credit-head {
    display: none;
  }

  .finance-credit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "acct bal"
      "prio util"
      "apr minpay"
      "limit avail"
      "plan paid"
      "planutil planutil"
      "hint hint";
    gap: 8px 12px;
    min-height: 0;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  .finance-credit-row--selected {
    border-color: var(--accent);
    box-shadow: none;
    background: var(--surface-raised);
  }

  .finance-credit-row > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .finance-credit-row > span::before {
    content: attr(data-label);
    color: var(--text-faint);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
  }

  .finance-credit-row > span:nth-child(1) { grid-area: prio; }
  .finance-credit-row > span:nth-child(2) { grid-area: acct; }
  .finance-credit-row > span:nth-child(3) { grid-area: apr; }
  .finance-credit-row > span:nth-child(4) { grid-area: bal; }
  .finance-credit-row > span:nth-child(5) { grid-area: limit; }
  .finance-credit-row > span:nth-child(6) { grid-area: avail; }
  .finance-credit-row > span:nth-child(7) { grid-area: util; }
  .finance-credit-row > span:nth-child(8) { grid-area: minpay; }
  .finance-credit-row > span:nth-child(9) { grid-area: plan; }
  .finance-credit-row > span:nth-child(10) { grid-area: paid; }
  .finance-credit-row > span:nth-child(11) { grid-area: planutil; }

  .finance-credit-row > span:nth-child(2)::before {
    display: none;
  }

  .finance-credit-account-name {
    font-size: 13px;
    font-weight: 750;
    color: var(--text);
  }

  .finance-credit-money {
    align-items: flex-end;
    text-align: right;
  }

  .finance-credit-card-hint {
    grid-area: hint;
    padding: 0;
  }

  .finance-credit-card-hint::before {
    display: none;
  }

  .finance-credit-footer-actions {
    margin-top: 2px;
    justify-content: flex-end;
  }
}

/* EOF override: the credit/transaction surfaces above have several historical
   mobile passes. This block is last on purpose. */
.viz-summary {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.finance-credit-head,
.finance-credit-row {
  grid-template-columns: minmax(150px, 1.4fr) 86px 66px 58px 78px 86px 82px 86px 82px 86px;
}

.finance-credit-priority,
.finance-payment-priority,
.finance-credit-input--priority {
  display: none !important;
}

.bank-explorer-list {
  gap: 10px;
  border-top: 0;
}

.bank-explorer-month-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.bank-explorer-month-divider {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--surface-raised);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}

.bank-explorer-month-rows {
  display: flex;
  flex-direction: column;
}

.bank-explorer-row-card {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.bank-explorer-row-card--selected {
  background: var(--surface-raised);
  box-shadow: inset 3px 0 0 var(--accent);
}

.bank-explorer-row-card .bank-explorer-row {
  border-top: 0;
  min-height: 52px;
  padding: 10px 12px;
  cursor: pointer;
  background: transparent;
}

.bank-explorer-row-actions-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 12px 12px 52px;
}

.bank-explorer-row-hint {
  color: var(--accent);
  font-size: 11px;
}

@media (max-width: 760px) {
  .finance-credit-score-whatif-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bank-explorer-row-card .bank-explorer-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas:
      "icon desc amount"
      "icon date amount";
    gap: 5px 10px;
    min-height: 58px;
    padding: 10px 12px;
  }

  .bank-explorer-row-card .bank-explorer-row::before {
    display: none;
    content: none;
  }

  .bank-explorer-row-card .bank-explorer-date { grid-area: date; }
  .bank-explorer-row-card .bank-explorer-desc { grid-area: desc; }
  .bank-explorer-row-card .bank-explorer-amount { grid-area: amount; }

  .bank-explorer-row-actions-panel {
    padding: 0 12px 12px 56px;
  }

  .finance-credit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 12px;
    min-height: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  .finance-credit-row > span {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
  }

  .finance-credit-row > span::before {
    content: attr(data-label);
    color: var(--text-faint);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.45px;
    text-transform: uppercase;
  }

  .finance-credit-row > span:nth-child(1) {
    flex: 1 1 min(100%, 190px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .finance-credit-row > span:nth-child(1)::before {
    display: none;
  }

  .finance-credit-row > span:nth-child(2) {
    flex: 0 0 auto;
    margin-left: auto;
    flex-direction: column;
    align-items: flex-end;
  }

  .finance-credit-row > span:nth-child(n + 3):nth-child(-n + 10) {
    flex: 0 1 auto;
    font-size: 11.5px;
  }

  .finance-credit-card-hint {
    flex: 1 0 100%;
    padding: 0;
  }

  .finance-credit-card-hint::before {
    display: none;
  }
}

@media (max-width: 380px) {
  .finance-credit-score-whatif-fields {
    grid-template-columns: 1fr;
  }
}
