/* =========================================================
   FinFlow — Design system & layout
   A light lavender + violet fintech palette with a signature
   indigo-to-violet gradient carried across the balance hero,
   the FAB, and every primary action. Numbers are always set
   with tabular figures so amounts line up like a ledger.
   ========================================================= */

:root {
  /* ---- Surfaces (light) ---- */
  --bg:            #EEF0FB;
  --bg-elev-1:     #FFFFFF;
  --bg-elev-2:     #F4F5FC;
  --bg-elev-3:     #E9EBF8;
  --border:        rgba(46, 35, 100, 0.08);
  --border-strong: rgba(46, 35, 100, 0.16);

  --text:          #1C1A33;
  --text-muted:    #8987A3;
  --text-faint:    #B7B4CC;

  /* ---- Brand — indigo/violet primary + blue secondary ---- */
  --accent:        #6C4CF5;
  --accent-2:      #8B6BFF;
  --accent-3:      #4A2FE0;
  --accent-ink:    #FFFFFF;
  --accent-soft:   rgba(108, 76, 245, 0.12);

  --teal:          #2E6EF2;
  --teal-2:        #63B4FF;
  --teal-soft:     rgba(46, 110, 242, 0.12);

  --pos:           #16A35F;
  --pos-soft:      rgba(22, 163, 95, 0.13);
  --neg:           #F1465F;
  --neg-soft:      rgba(241, 70, 95, 0.13);
  --warn:          #F2A93B;
  --warn-soft:     rgba(242, 169, 59, 0.16);

  --radius-sm:  10px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  24px;
  --radius-full: 999px;

  --shadow-sm:   0 2px 10px rgba(46,35,100,0.06);
  --shadow-md:   0 10px 28px rgba(46,35,100,0.10);
  --shadow-lg:   0 24px 56px rgba(46,35,100,0.16);
  --shadow-card: 0 8px 20px rgba(46,35,100,0.07);

  --sidebar-w: 252px;
  --bottom-nav-h: 68px;
  --topbar-h: 82px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  /* Type system: a warm geometric display face for headings, brand and
     every monetary figure (tabular figures on), and a humanist body
     face for UI text/paragraphs. */
  --font-display: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:            #131120;
  --bg-elev-1:     #1C1930;
  --bg-elev-2:     #241F38;
  --bg-elev-3:     #2C2743;
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text:          #F2F0FA;
  --text-muted:    #A29DBE;
  --text-faint:    #6E6989;

  --accent:        #8B6BFF;
  --accent-2:      #A88CFF;
  --accent-3:      #6C4CF5;
  --accent-ink:    #16132A;
  --accent-soft:   rgba(139, 107, 255, 0.18);

  --teal:          #5B9DFF;
  --teal-2:        #8FC2FF;
  --teal-soft:     rgba(91, 157, 255, 0.18);

  --pos:           #33C583;
  --pos-soft:      rgba(51, 197, 131, 0.16);
  --neg:           #FF6B81;
  --neg-soft:      rgba(255, 107, 129, 0.16);
  --warn:          #FFC069;
  --warn-soft:     rgba(255, 192, 105, 0.18);

  --shadow-sm:   0 2px 10px rgba(0,0,0,0.30);
  --shadow-md:   0 10px 28px rgba(0,0,0,0.40);
  --shadow-lg:   0 24px 56px rgba(0,0,0,0.55);
  --shadow-card: 0 8px 20px rgba(0,0,0,0.28);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg:            #131120;
    --bg-elev-1:     #1C1930;
    --bg-elev-2:     #241F38;
    --bg-elev-3:     #2C2743;
    --border:        rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text:          #F2F0FA;
    --text-muted:    #A29DBE;
    --text-faint:    #6E6989;
    --accent:        #8B6BFF;
    --accent-2:      #A88CFF;
    --accent-3:      #6C4CF5;
    --accent-ink:    #16132A;
    --accent-soft:   rgba(139, 107, 255, 0.18);
    --teal:          #5B9DFF;
    --teal-2:        #8FC2FF;
    --teal-soft:     rgba(91, 157, 255, 0.18);
    --pos:           #33C583;
    --pos-soft:      rgba(51, 197, 131, 0.16);
    --neg:           #FF6B81;
    --neg-soft:      rgba(255, 107, 129, 0.16);
    --warn:          #FFC069;
    --warn-soft:     rgba(255, 192, 105, 0.18);
    --shadow-sm:   0 2px 10px rgba(0,0,0,0.30);
    --shadow-md:   0 10px 28px rgba(0,0,0,0.40);
    --shadow-lg:   0 24px 56px rgba(0,0,0,0.55);
    --shadow-card: 0 8px 20px rgba(0,0,0,0.28);
    color-scheme: dark;
  }
}

/* An element's [hidden] attribute must always win over any component class
   that sets `display` (e.g. .bulk-bar, .more-panel) — author class rules
   otherwise silently out-rank the UA's [hidden]{display:none}. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  transition: background .2s ease, color .2s ease;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
img { max-width: 100%; }
.no-scroll { overflow: hidden; }
::selection { background: var(--accent-soft); }

h1, h2, h3, h4,
.page-title, .card-head h2, .auth-title, .sheet-title, .modal-head h3, .chat-title, .brand-name {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

/* Every monetary figure in the app shares this treatment. */
.stat-value, .num, .pos, .neg, .txn-mini-amount, .account-balance, .account-mini-balance,
.budget-nums, .budget-card-nums, .budget-card-remaining, .rec-amount, .webhook-value,
.balance-value, .activity-amount, .portfolio-card-balance, .bank-card-balance, .stat-mini-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elev-3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* =========================================================
   App shell
   ========================================================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 1.6rem 1.25rem 1.15rem; }
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; display: flex; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-name { font-weight: 800; font-size: 1.05rem; }

.side-nav { flex: 1; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; }
.side-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .85rem .65rem calc(.85rem - 3px);
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  position: relative;
}
.side-link:hover { background: var(--bg-elev-2); color: var(--text); }
.side-link.active { background: var(--accent-soft); color: var(--accent-3); border-left-color: var(--accent); }
.side-link.active .nav-ic { color: var(--accent); }
.nav-ic { width: 20px; height: 20px; display: inline-flex; flex-shrink: 0; }
.nav-ic svg { width: 100%; height: 100%; }

.badge {
  margin-left: auto;
  background: var(--neg);
  color: #fff;
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: .85rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.user-chip { display: flex; align-items: center; gap: .6rem; overflow: hidden; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: .85rem; color: #fff; flex-shrink: 0;
}
.user-name { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.icon-btn .nav-ic { width: 18px; height: 18px; }

.icon-btn-sm {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--text-muted); font-size: .85rem;
  transition: background .15s;
}
.icon-btn-sm:hover { background: var(--bg-elev-2); color: var(--text); }

/* =========================================================
   Main content
   ========================================================= */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- Persistent branded app header (Finance / Transactions / Banks / …) ---- */
.app-header {
  min-height: var(--topbar-h);
  padding: calc(.85rem + var(--safe-top)) 1.5rem .85rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg-elev-1) 92%, transparent);
  backdrop-filter: blur(14px);
  z-index: 20;
}
.app-header-brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.app-header-mark {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius-sm);
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center;
}
.app-header-mark .brand-mark { width: 19px; height: 19px; }
.app-header-text { min-width: 0; }
.app-header-name { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; line-height: 1.15; }
.app-header-secured {
  font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.vault-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--pos-soft); color: var(--pos);
  border-radius: var(--radius-full); padding: .38rem .7rem .38rem .6rem;
  font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.vault-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); flex-shrink: 0; }

.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.topbar-actions { display: flex; gap: .6rem; }

.content { flex: 1; padding: 1.75rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 700; font-size: .875rem;
  transition: transform .1s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s;
  min-height: 40px;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(108,76,245,0.28), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 10px 26px rgba(108,76,245,0.38), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-ghost { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-elev-3); border-color: var(--border-strong); }
.btn-danger { background: var(--neg-soft); color: var(--neg); border-color: rgba(241,70,95,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(241,70,95,0.22); }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; min-height: 32px; }
.btn-block { width: 100%; }

/* =========================================================
   Cards / stats
   ========================================================= */
.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; font-weight: 800; margin: 0; }
.card-head h2 small { font-family: var(--font-body); font-weight: 500; color: var(--text-muted); font-size: .8rem; margin-left: .35rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { margin-bottom: 0; }
.stat-label {
  display: flex; align-items: center; gap: .45rem;
  color: var(--text-muted); font-family: var(--font-mono);
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: .5rem;
}
.stat-label::before { content: ''; width: 10px; height: 2px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.stat-sub { margin-top: .35rem; font-size: .8rem; color: var(--text-muted); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }

.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.dash-grid .span-2 { grid-column: 1 / -1; }
.chart-box { position: relative; height: 260px; }

.section-label {
  font-family: var(--font-mono);
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-muted);
  margin: 1.6rem 0 .75rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.section-label:first-child { margin-top: 0; }
.section-label a { font-weight: 700; color: var(--accent); text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-size: .78rem; }

/* =========================================================
   Empty states / skeletons
   ========================================================= */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); gap: .5rem; }
.empty-state span { font-size: 2rem; }
.empty-state p { margin: 0; max-width: 320px; font-size: .875rem; }
.empty-state.span-all { grid-column: 1 / -1; }

.skeleton { height: 44px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--bg-elev-2) 25%, var(--bg-elev-3) 50%, var(--bg-elev-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin-bottom: .6rem; }
.skeleton-rows { padding: .5rem 0; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =========================================================
   Budgets
   ========================================================= */
.budget-list { display: flex; flex-direction: column; gap: .9rem; }
.budget-row { display: flex; flex-direction: column; gap: .35rem; }
.budget-meta { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; }
.budget-nums.warn { color: var(--warn); }
.budget-nums.over { color: var(--neg); }
.progress { height: 8px; background: var(--bg-elev-3); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--accent); transition: width .4s ease; }
.progress-fill.warn { background: var(--warn); }
.progress-fill.over { background: var(--neg); }

.ledger-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: .9rem; }
.ledger-table th { text-align: left; padding: .5rem .6rem; color: var(--text-muted); font-family: var(--font-mono); font-weight: 700; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.ledger-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ledger-table td:first-child { font-family: var(--font-body); font-weight: 600; }
.ledger-table tbody tr:last-child td { border-bottom: none; }

.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.budget-card { margin-bottom: 0; }
.budget-card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.budget-card-name { font-family: var(--font-body); font-weight: 700; flex: 1; }
.budget-card-nums { display: flex; justify-content: space-between; font-size: .82rem; margin-top: .5rem; }
.budget-card-remaining { font-size: .8rem; margin-top: .35rem; }
.budget-card-nums .warn { color: var(--warn); }
.budget-card-nums .over { color: var(--neg); }

.cat-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }

/* =========================================================
   Alerts / toasts
   ========================================================= */
.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: .5rem; }
.alert-error { background: var(--neg-soft); color: #b8264a; border: 1px solid rgba(241,70,95,0.25); }
.alert-warn { background: var(--warn-soft); color: #96650f; border: 1px solid rgba(242,169,59,0.3); }
.alert-success { background: var(--pos-soft); color: #0d7a46; border: 1px solid rgba(22,163,95,0.25); }
:root[data-theme="dark"] .alert-error { color: #ffb3c0; }
:root[data-theme="dark"] .alert-warn { color: #ffdca6; }
:root[data-theme="dark"] .alert-success { color: #9df0c9; }
.alert.small { font-size: .78rem; padding: .5rem .7rem; }

.toast-container { position: fixed; bottom: calc(1.25rem + var(--safe-bottom)); right: 1.25rem; z-index: 500; display: flex; flex-direction: column; gap: .5rem; max-width: 340px; }
.toast {
  background: var(--bg-elev-1); border: 1px solid var(--border-strong); color: var(--text);
  padding: .75rem 1rem; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  font-size: .85rem; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--pos); }
.toast-error { border-left: 3px solid var(--neg); }
.toast-info { border-left: 3px solid var(--accent); }

@media (max-width: 768px) {
  .toast-container { left: 1rem; right: 1rem; max-width: none; bottom: calc(var(--bottom-nav-h) + 1rem + var(--safe-bottom)); }
}

/* =========================================================
   Forms
   ========================================================= */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; position: relative; }
.field-inline { margin-bottom: 0; }
.field-label { font-size: .78rem; font-weight: 700; color: var(--text-muted); }
.field-label small { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], input[type=search], input[type=color],
select, textarea {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  padding: .65rem .8rem;
  min-height: 42px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type=color] { padding: .25rem; height: 42px; cursor: pointer; }
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238987a3' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2.2rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.check-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); margin-bottom: 1.1rem; }
.check-row input { width: auto; min-height: auto; }

.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.type-toggle label { position: relative; }
.type-toggle input { position: absolute; opacity: 0; }
.type-toggle span {
  display: flex; align-items: center; justify-content: center;
  padding: .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev-2); font-weight: 700; font-size: .85rem; color: var(--text-muted);
  transition: all .15s;
}
.type-toggle input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-3); }

.suggest-chip {
  align-self: flex-start; margin-top: .35rem;
  background: var(--teal-soft); color: var(--teal);
  border: 1px solid rgba(46,110,242,0.3); border-radius: var(--radius-full);
  padding: .3rem .7rem; font-size: .75rem; font-weight: 700;
}

.filters-card { padding: .9rem 1.1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 0; }
.filters select, .filters input { width: auto; min-width: 130px; flex: 1 1 130px; }
.filter-search { flex: 2 1 200px; }

/* A row of small utility buttons (Filters / Select / CSV / + Add) — always
   wraps as a row, never collapses into a full-width column like .filters
   does for real filter inputs. */
.action-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.action-bar .btn { flex: 0 0 auto; }

/* Recurring-transaction form: paired fields via .form-row (2-col desktop,
   1-col mobile via the existing .form-row breakpoint), stacked vertically. */
.rec-form { display: flex; flex-direction: column; gap: .8rem; }
.rec-form .form-row { margin: 0; }

/* =========================================================
   Search bar + pill tabs (Transactions)
   ========================================================= */
.search-bar { position: relative; margin-bottom: 1rem; }
.search-bar .nav-ic { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-faint); pointer-events: none; }
.search-bar input[type=search] {
  padding-left: 2.6rem; background: var(--bg-elev-1); border-radius: var(--radius-full);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
}
.search-bar .icon-btn { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); }

.pill-tabs { display: flex; gap: .5rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.pill-tab {
  padding: .5rem 1.1rem; border-radius: var(--radius-full);
  background: var(--bg-elev-1); color: var(--text-muted); border: 1px solid var(--border);
  font-weight: 700; font-size: .8rem; transition: all .15s;
}
.pill-tab.active { background: linear-gradient(135deg, var(--accent-2), var(--accent-3)); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(108,76,245,.32); }

.stat-mini-row { display: flex; gap: .8rem; margin-bottom: 1.1rem; }
.stat-mini { flex: 1; border-radius: var(--radius-lg); padding: .95rem 1.1rem; }
.stat-mini.income { background: var(--pos-soft); }
.stat-mini.expense { background: var(--neg-soft); }
.stat-mini-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.stat-mini.income .stat-mini-label { color: var(--pos); }
.stat-mini.expense .stat-mini-label { color: var(--neg); }
.stat-mini-value { font-size: 1.15rem; font-weight: 800; }
.stat-mini.income .stat-mini-value { color: var(--pos); }
.stat-mini.expense .stat-mini-value { color: var(--neg); }

/* =========================================================
   Tables
   ========================================================= */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.txn-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.txn-table th { text-align: left; padding: .85rem 1rem; color: var(--text-muted); font-family: var(--font-mono); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.txn-table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.txn-table tbody tr:hover { background: var(--bg-elev-2); }
.txn-table .num { text-align: right; font-weight: 700; }
.col-check { width: 40px; }
.col-actions { width: 90px; text-align: right; white-space: nowrap; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.sort-ind { font-size: .65rem; margin-left: .2rem; color: var(--accent); }

.cat-tag { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: var(--radius-full); background: color-mix(in srgb, var(--tag-color) 18%, transparent); font-size: .78rem; font-weight: 600; }
.pill { display: inline-block; padding: .18rem .55rem; border-radius: var(--radius-full); background: var(--bg-elev-3); font-size: .72rem; font-weight: 700; color: var(--text-muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; }

.table-footer { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; border-top: 1px solid var(--border); flex-wrap: wrap; gap: .6rem; }
.pagination { display: flex; align-items: center; gap: .6rem; }
.page-info { font-size: .8rem; color: var(--text-muted); }

.bulk-bar { display: flex; align-items: center; gap: .75rem; background: var(--accent-soft); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: .7rem 1rem; margin-bottom: 1rem; font-size: .85rem; font-weight: 700; }

/* Mobile table -> card reflow (used by Reports category breakdown table) */
@media (max-width: 768px) {
  .txn-table thead { display: none; }
  .txn-table, .txn-table tbody, .txn-table tr, .txn-table td { display: block; width: 100%; }
  .txn-table tr { padding: .9rem 1rem; border-bottom: 1px solid var(--border); position: relative; }
  .txn-table td { border: none; padding: .2rem 0; display: flex; justify-content: space-between; align-items: center; }
  .txn-table td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .txn-table td.col-check { position: absolute; top: .9rem; right: 1rem; }
  .txn-table td.col-check::before { content: ''; }
  .txn-table td.col-actions { justify-content: flex-end; gap: .5rem; }
  .txn-table td.col-actions::before { content: ''; }
  .txn-table .num { justify-content: space-between; }
}

/* =========================================================
   Balance hero card (Finance / dashboard)
   ========================================================= */
.balance-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 45%, var(--accent-3) 100%);
  border-radius: var(--radius-xl);
  padding: 1.6rem 1.5rem 1.75rem;
  color: #fff;
  box-shadow: 0 20px 46px rgba(74,47,224,0.35);
  margin-bottom: 1.5rem;
}
.balance-hero::before {
  content: ''; position: absolute; top: -60px; right: -50px; width: 220px; height: 220px;
  border-radius: 50%; background: rgba(255,255,255,0.14);
}
.balance-hero::after {
  content: ''; position: absolute; bottom: -80px; left: -40px; width: 200px; height: 200px;
  border-radius: 50%; background: rgba(255,255,255,0.08);
}
.balance-label { position: relative; font-family: var(--font-mono); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; opacity: .85; }
.balance-value { position: relative; font-size: 2.15rem; font-weight: 800; letter-spacing: -0.01em; margin: .45rem 0 1.4rem; }
.balance-actions { position: relative; display: flex; gap: 1.1rem; }
.balance-action { display: flex; flex-direction: column; align-items: center; gap: .4rem; background: transparent; border: none; color: #fff; font-family: var(--font-body); font-size: .72rem; font-weight: 700; }
.balance-action-icon {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px);
  transition: background .15s, transform .1s;
}
.balance-action:active .balance-action-icon { transform: scale(.94); }
.balance-action:hover .balance-action-icon { background: rgba(255,255,255,0.26); }
.balance-action-icon .nav-ic { width: 20px; height: 20px; }
.balance-footer { position: absolute; right: 1.5rem; bottom: 1.5rem; text-align: right; z-index: 1; }
.balance-footer-label { font-family: var(--font-mono); font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .78; }
.balance-footer-value { font-weight: 700; font-size: .82rem; margin-top: .15rem; }

/* =========================================================
   Portfolio cards (accounts summary on Finance page)
   ========================================================= */
.portfolio-row { display: flex; gap: .85rem; overflow-x: auto; padding: .1rem .1rem .35rem; margin: 0 -.1rem 1.5rem; scrollbar-width: none; }
.portfolio-row::-webkit-scrollbar { display: none; }
.portfolio-card {
  flex: 0 0 auto; width: 168px; background: var(--bg-elev-1); border-radius: var(--radius-lg);
  padding: 1.05rem 1.1rem; box-shadow: var(--shadow-card); border: 1px solid var(--border);
}
.portfolio-card-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--teal-soft); color: var(--teal);
  display: flex; align-items: center; justify-content: center; margin-bottom: .8rem;
}
.portfolio-card-icon .nav-ic { width: 18px; height: 18px; }
.portfolio-card-name { font-weight: 700; font-size: .85rem; margin-bottom: .2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-card-sub { font-family: var(--font-mono); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-bottom: .6rem; }
.portfolio-card-balance { font-weight: 800; font-size: 1.05rem; color: var(--accent-3); }
:root[data-theme="dark"] .portfolio-card-balance { color: var(--accent-2); }

@media (min-width: 640px) {
  .portfolio-row { overflow-x: visible; flex-wrap: wrap; }
  .portfolio-card { width: 200px; }
}

/* =========================================================
   Recent activity list (Finance + Transactions)
   ========================================================= */
.activity-list { display: flex; flex-direction: column; gap: .65rem; }
.activity-row {
  display: flex; align-items: center; gap: .8rem;
  background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .85rem .95rem; box-shadow: var(--shadow-card); position: relative;
}
.activity-icon { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.1rem; }
.activity-icon.pos { background: var(--pos-soft); color: var(--pos); }
.activity-icon.neg { background: var(--neg-soft); color: var(--neg); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-sub { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; text-transform: uppercase; letter-spacing: .03em; }
.activity-datetime {
  margin-top: .18rem; color: var(--text-faint); font-family: var(--font-mono);
  font-size: .68rem; font-weight: 600; line-height: 1.35;
}
.activity-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex-shrink: 0; }
.activity-amount { font-weight: 800; font-size: .92rem; white-space: nowrap; }
.activity-delete { background: transparent; border: none; color: var(--neg); opacity: .55; padding: .1rem; display: flex; transition: opacity .15s; }
.activity-delete:hover { opacity: 1; }
.activity-delete .nav-ic { width: 16px; height: 16px; }
.activity-check { flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--accent); }

/* =========================================================
   Transaction mini list (legacy, still used in a couple of places)
   ========================================================= */
.txn-mini-list { display: flex; flex-direction: column; }
.txn-mini { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.txn-mini:last-child { border-bottom: none; }
.txn-mini-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.txn-mini-body { flex: 1; min-width: 0; }
.txn-mini-desc { font-family: var(--font-body); font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-mini-date { font-size: .75rem; color: var(--text-muted); }
.txn-mini-amount { font-weight: 700; font-size: .9rem; white-space: nowrap; }

/* =========================================================
   Recurring
   ========================================================= */
.recurring-list { display: flex; flex-direction: column; gap: .1rem; }
.recurring-row { display: flex; align-items: center; gap: .75rem; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.recurring-row.inactive { opacity: .5; }
.recurring-row:last-child { border-bottom: none; }
.rec-icon { font-size: 1.2rem; width: 36px; text-align: center; }
.rec-body { flex: 1; min-width: 0; }
.rec-desc { font-family: var(--font-body); font-weight: 700; font-size: .87rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.rec-meta { font-size: .75rem; }
.rec-amount { font-weight: 700; white-space: nowrap; }
.rec-actions { display: flex; gap: .4rem; }

/* =========================================================
   Accounts / Banks & Cards
   ========================================================= */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.account-card { margin-bottom: 0; border-top: 3px solid var(--acc-color, var(--accent)); }
.account-card-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .9rem; }
.account-name { font-family: var(--font-body); font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.account-balance { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: .9rem; }
.account-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.account-mini-list { display: flex; flex-direction: column; gap: .1rem; }
.account-mini-row { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.account-mini-row:last-child { border-bottom: none; }
.account-mini-name { font-family: var(--font-body); font-weight: 600; font-size: .85rem; flex: 1; }
.account-mini-balance { font-weight: 700; font-size: .88rem; white-space: nowrap; }

.bank-stack { display: flex; flex-direction: column; gap: 1.1rem; }
@media (min-width: 760px) {
  .bank-stack { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
}

/* Bank/card-type accounts render as a gradient card visual */
.bank-card {
  position: relative; overflow: hidden; border-radius: var(--radius-xl);
  padding: 1.5rem 1.4rem 1.35rem; color: #fff;
  background: linear-gradient(135deg, var(--card-1, var(--teal)) 0%, color-mix(in srgb, var(--card-1, var(--teal)) 45%, white) 100%);
  box-shadow: 0 20px 40px color-mix(in srgb, var(--card-1, var(--teal)) 45%, transparent);
}
.bank-card::before { content: ''; position: absolute; top: -50px; right: -30px; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,0.12); }
.bank-card::after { content: ''; position: absolute; bottom: -70px; left: -20px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,0.08); }
.bank-card-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; gap: .6rem; }
.bank-card-name { font-weight: 800; font-size: 1rem; letter-spacing: -0.005em; }
.bank-card-branch { font-family: var(--font-mono); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .78; margin-top: .2rem; }
.bank-card-icon-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.bank-card-icon-btn {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.18); border: none;
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.bank-card-icon-btn .nav-ic { width: 15px; height: 15px; }
.bank-card-icon-btn:hover { background: rgba(255,255,255,0.28); }
.bank-card-mid { position: relative; display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.6rem; }
.bank-card-chip { width: 40px; height: 30px; border-radius: 7px; background: linear-gradient(135deg,#F3D27A,#D8A93D); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.bank-card-wifi .nav-ic { width: 22px; height: 22px; opacity: .9; }
.bank-card-footer { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: .6rem; }
.bank-card-holder { font-weight: 700; font-size: .82rem; letter-spacing: .03em; margin-bottom: .3rem; }
.bank-card-acc { font-family: var(--font-mono); font-size: .74rem; opacity: .88; letter-spacing: .02em; }
.bank-card-tag { font-family: var(--font-mono); font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .72; margin-bottom: .35rem; text-align: right; }
.bank-card-balance { font-weight: 800; font-size: 1.35rem; text-align: right; }

/* Cash wallets use the same full-size card layout, with a distinct violet
   treatment so they cannot be mistaken for a bank/card account. */
.wallet-account-card {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--card-1, #8b5cf6) 24%, #4c1d95) 0%,
    color-mix(in srgb, var(--card-1, #8b5cf6) 28%, #a855f7) 100%);
  box-shadow: 0 20px 40px color-mix(in srgb, #7c3aed 38%, transparent);
}
.wallet-card-mid { margin-bottom: 1.35rem; }
.wallet-card-emblem {
  width: 46px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.wallet-card-emblem svg { width: 24px; height: 24px; }
.wallet-card-cash-label {
  font-family: var(--font-mono); font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; opacity: .82;
}

/* Other/custom accounts render as a lighter portfolio-style card. */
.wallet-card { display: flex; align-items: center; gap: .9rem; background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 1.1rem 1.2rem; }
.wallet-card-icon { width: 46px; height: 46px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: color-mix(in srgb, var(--acc-color, var(--accent)) 16%, transparent); color: var(--acc-color, var(--accent)); font-size: 1.3rem; }
.wallet-card-icon .nav-ic { width: 22px; height: 22px; }
.wallet-card-body { flex: 1; min-width: 0; }
.wallet-card-name { font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.wallet-card-sub { font-family: var(--font-mono); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-top: .15rem; }
.wallet-card-balance { font-weight: 800; font-size: 1.1rem; flex-shrink: 0; }
.wallet-card-actions { display: flex; gap: .3rem; flex-shrink: 0; }

/* =========================================================
   Webhook box
   ========================================================= */
.webhook-box { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.webhook-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.webhook-label { font-size: .78rem; font-weight: 700; color: var(--text-muted); min-width: 110px; }
.webhook-value { flex: 1; background: var(--bg-elev-3); padding: .45rem .7rem; border-radius: var(--radius-sm); font-size: .78rem; word-break: break-all; }
.small { font-size: .8rem; }

/* =========================================================
   Biometric login devices
   ========================================================= */
.bio-device-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.bio-device {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .55rem .75rem;
}
.bio-device > span:first-child { font-weight: 600; }
.bio-device .js-bio-remove { margin-left: auto; }

/* =========================================================
   SMS cards
   ========================================================= */
.sms-card { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; margin-bottom: 1rem; }
.sms-raw { font-family: var(--font-mono); font-size: .8rem; background: var(--bg-elev-3); padding: .7rem .8rem; border-radius: var(--radius-sm); margin-bottom: .5rem; }
.sms-meta { font-size: .75rem; margin-bottom: .5rem; }
.sms-edit-form .form-row { margin-bottom: .6rem; }
.sms-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }

/* =========================================================
   Categories grid (settings)
   ========================================================= */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.category-chip { position: relative; background: var(--bg-elev-2); border: 1px solid var(--border); border-left: 4px solid var(--chip-color, var(--accent)); border-radius: var(--radius-sm); padding: .75rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.cat-name { font-family: var(--font-body); font-weight: 700; font-size: .85rem; }
.cat-type { font-size: .7rem; text-transform: capitalize; }
.cat-actions { position: absolute; top: .4rem; right: .4rem; display: flex; gap: .1rem; opacity: 0; transition: opacity .15s; }
.category-chip:hover .cat-actions { opacity: 1; }

/* =========================================================
   Settings hub — "More tools" tiles
   ========================================================= */
.tools-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.tools-item {
  display: flex; align-items: center; gap: .7rem;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: .9rem; font-weight: 700; font-size: .85rem; min-height: 52px;
  width: 100%; text-align: left; color: var(--text); position: relative;
}
.tools-item:hover { border-color: var(--border-strong); background: var(--bg-elev-3); }
.tools-item .nav-ic { color: var(--accent); }
.tools-item .badge { position: static; margin-left: auto; }
@media (max-width: 460px) { .tools-grid { grid-template-columns: 1fr; } }

/* =========================================================
   Modal
   ========================================================= */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,15,45,0.45); backdrop-filter: blur(2px); z-index: 400; opacity: 0; transition: opacity .2s; }
.modal-backdrop.show { opacity: 1; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -48%); width: min(440px, 92vw);
  background: var(--bg-elev-1); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow-lg); z-index: 410;
  opacity: 0; transition: opacity .2s, transform .2s;
}
.modal.show { opacity: 1; transform: translate(-50%, -50%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-head h3 { margin: 0; font-size: 1rem; }
.confirm-body { font-size: .88rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }

/* =========================================================
   Auth pages
   ========================================================= */
.auth-body {
  background:
    radial-gradient(circle at 15% 15%, rgba(108,76,245,0.16), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(46,110,242,0.14), transparent 45%),
    var(--bg);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  padding: calc(1.5rem + var(--safe-top)) 1.5rem calc(1.5rem + var(--safe-bottom));
}
.auth-card { width: 100%; max-width: 400px; background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem 1.75rem; box-shadow: var(--shadow-lg); }
.device-login { margin-top: 1rem; }
.pin-login-form { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 800; margin-bottom: 1.5rem; }
.auth-title { font-size: 1.4rem; font-weight: 800; margin: 0 0 .3rem; }
.auth-sub { color: var(--text-muted); font-size: .88rem; margin: 0 0 1.5rem; }
.auth-alt { text-align: center; font-size: .85rem; color: var(--text-muted); margin-top: 1.25rem; }
.auth-alt a { color: var(--teal); font-weight: 700; }

/* =========================================================
   AI Chat
   ========================================================= */
.chat-root { display: flex; flex-direction: column; height: 100%; position: relative; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); }
.chat-title { font-weight: 800; }
.chat-header-actions { display: flex; gap: .4rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .7rem; }
.chat-empty { color: var(--text-muted); font-size: .85rem; text-align: center; margin-top: 2rem; }

.chat-bubble { max-width: 88%; }
.chat-bubble.chat-user { align-self: flex-end; }
.chat-bubble.chat-assistant { align-self: flex-start; }
.bubble-content { padding: .65rem .9rem; border-radius: var(--radius-md); font-size: .87rem; line-height: 1.55; }
.chat-user .bubble-content { background: linear-gradient(135deg, var(--accent-2), var(--accent-3)); color: #fff; font-weight: 500; border-bottom-right-radius: 4px; }
.chat-assistant .bubble-content { background: var(--bg-elev-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-content p { margin: 0 0 .5rem; }
.bubble-content p:last-child { margin-bottom: 0; }
.bubble-content ul { margin: .3rem 0; padding-left: 1.2rem; }
.bubble-content code { font-family: var(--font-mono); background: rgba(0,0,0,0.06); padding: .1rem .3rem; border-radius: 4px; font-size: .82em; }
.bubble-content pre { background: rgba(0,0,0,0.06); padding: .6rem .7rem; border-radius: var(--radius-sm); overflow-x: auto; }

.action-chips { align-self: flex-start; display: flex; flex-direction: column; gap: .4rem; max-width: 88%; }
.action-chip { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: var(--pos-soft); border: 1px solid rgba(22,163,95,0.25); border-radius: var(--radius-sm); padding: .5rem .7rem; font-size: .8rem; }
.action-chip.undone { opacity: .5; text-decoration: line-through; }
.undo-btn { background: transparent; border: 1px solid currentColor; color: var(--teal); border-radius: var(--radius-full); padding: .15rem .55rem; font-size: .72rem; font-weight: 700; }

.confirm-card { align-self: stretch; background: var(--warn-soft); border: 1px solid rgba(242,169,59,0.35); border-radius: var(--radius-md); padding: .85rem 1rem; }
.confirm-card-title { font-weight: 700; font-size: .87rem; margin-bottom: .5rem; }
.confirm-card-items { margin: 0 0 .75rem; padding-left: 1.1rem; font-size: .8rem; color: var(--text-muted); }
.confirm-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }

.chat-typing {
  align-self: flex-start; display: flex; align-items: center; gap: .5rem;
  max-width: 88%; animation: chatTypingIn .18s ease-out;
}
.chat-typing-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-2);
  border: 1px solid var(--border-strong); font-size: .58rem; font-weight: 800;
  letter-spacing: .02em;
}
.chat-typing-bubble {
  min-width: 54px; min-height: 34px; padding: .65rem .8rem;
  display: flex; align-items: center; justify-content: center; gap: .28rem;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-card);
}
.chat-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint);
  animation: bounce 1.2s infinite ease-in-out;
}
.chat-typing-dot:nth-child(2) { animation-delay: .15s; }
.chat-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes chatTypingIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.chat-input-row { display: flex; gap: .6rem; padding: .85rem 1.1rem; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }
.chat-send { flex-shrink: 0; }

/* Slide-in panel (desktop + mobile overlay) */
.chat-overlay { position: fixed; inset: 0; background: rgba(20,15,45,0.4); z-index: 300; opacity: 0; transition: opacity .25s; }
.chat-overlay.show { opacity: 1; }
.chat-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 100vw);
  background: var(--bg-elev-1); border-left: 1px solid var(--border-strong); z-index: 310;
  transform: translateX(100%); transition: transform .3s ease; box-shadow: var(--shadow-lg);
  padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
}
.chat-panel.show { transform: translateX(0); }

/* History overlay — covers the whole chat surface while browsing past threads */
.chat-history-panel {
  position: absolute; inset: 0; z-index: 20;
  background: var(--bg-elev-1);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.chat-history-panel.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.chat-history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.chat-history-list { flex: 1; overflow-y: auto; padding: .5rem; }
.chat-history-empty { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 2.5rem 1rem; }
.chat-history-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem .8rem; border-radius: var(--radius-md);
  cursor: pointer; margin-bottom: .25rem;
  border: 1px solid transparent;
}
.chat-history-item:hover { background: var(--bg-elev-2); }
.chat-history-item.active { background: var(--accent-soft); border-color: var(--border-strong); }
.chat-history-item-body { flex: 1; min-width: 0; }
.chat-history-item-title { font-family: var(--font-body); font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-history-item-date { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }
.chat-history-item-actions { display: flex; gap: .15rem; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.chat-history-item:hover .chat-history-item-actions,
.chat-history-item:focus-within .chat-history-item-actions { opacity: 1; }
@media (pointer: coarse) { .chat-history-item-actions { opacity: 1; } }

.chat-page-card { padding: 0; height: calc(100vh - var(--topbar-h) - 3.5rem); min-height: 480px; display: flex; }
.chat-page-card .chat-root { width: 100%; }
.chat-examples { margin-top: 0; }
.example-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.example-chip { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-full); padding: .5rem .9rem; font-size: .8rem; color: var(--text-muted); transition: all .15s; }
.example-chip:hover { border-color: var(--accent); color: var(--text); }

/* =========================================================
   Bottom sheets (mobile-style, also used on desktop for chat/add-txn)
   ========================================================= */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20,15,45,0.45); z-index: 350; opacity: 0; transition: opacity .25s; }
.sheet-backdrop.show { opacity: 1; }
.bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 360;
  background: var(--bg-elev-1); border-top: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0;
  padding: .6rem 1.25rem calc(1.25rem + var(--safe-bottom));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 -16px 40px rgba(46,35,100,0.18);
}
:root[data-theme="dark"] .bottom-sheet { box-shadow: 0 -16px 40px rgba(0,0,0,0.5); }
.bottom-sheet.show { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border-strong); border-radius: var(--radius-full); margin: .4rem auto 1rem; }
.sheet-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 1rem; }

/* =========================================================
   Mobile bottom nav (+ its centered FAB and "More" slide-in panel)
   ========================================================= */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 250;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--bg-elev-1) 94%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(46,35,100,0.08);
  align-items: center;
  justify-content: space-around;
}
:root[data-theme="dark"] .bottom-nav { box-shadow: 0 -6px 24px rgba(0,0,0,0.35); }
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  color: var(--text-faint); font-size: .64rem; font-weight: 700;
  min-width: 48px; min-height: 48px; position: relative;
  background: transparent; border: none;
}
.bn-item-ic { width: 34px; height: 34px; border-radius: 12px; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.bn-item .nav-ic { width: 20px; height: 20px; }
.bn-item.active { color: var(--accent-3); }
:root[data-theme="dark"] .bn-item.active { color: var(--accent-2); }
.bn-item.active .bn-item-ic { background: var(--accent-soft); color: var(--accent); }
.bn-label { line-height: 1; }
.bn-dot { position: absolute; top: 2px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--neg); border: 2px solid var(--bg-elev-1); }

/* FAB, centered inline within the bottom nav bar itself */
.bn-fab {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  color: #fff; border: 4px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(74,47,224,0.45);
  transform: translateY(-14px);
  transition: transform .15s;
}
.bn-fab:active { transform: translateY(-14px) scale(0.92); }
.bn-fab .nav-ic { width: 24px; height: 24px; }

/* Floating AI Chat trigger — bottom-right, above the bottom nav (same
   positioning the "+" FAB used before it moved inline into the nav bar). */
.chat-fab {
  position: fixed; right: 1.15rem; bottom: calc(var(--bottom-nav-h) + .9rem + var(--safe-bottom));
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(74,47,224,0.4);
  z-index: 259; transition: transform .15s;
}
.chat-fab:active { transform: scale(0.93); }
.chat-fab .nav-ic { width: 22px; height: 22px; }
@media (min-width: 769px) { .chat-fab { bottom: 1.5rem; right: 1.75rem; } }

/* "More" slide-in panel, from the right (mobile bottom-nav overflow menu) */
.more-panel-overlay { position: fixed; inset: 0; background: rgba(20,15,45,0.45); z-index: 300; opacity: 0; transition: opacity .25s; }
.more-panel-overlay.show { opacity: 1; }
.more-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: min(300px, 78vw);
  background: var(--bg-elev-1); border-left: 1px solid var(--border-strong); z-index: 310;
  transform: translateX(100%); transition: transform .3s ease; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
}
.more-panel.show { transform: translateX(0); }
.more-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.1rem .9rem; font-weight: 800; font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
}
.more-panel-list { flex: 1; overflow-y: auto; padding: .6rem; display: flex; flex-direction: column; gap: .15rem; }
.more-panel-item {
  display: flex; align-items: center; gap: .8rem;
  padding: .75rem .7rem; border-radius: var(--radius-md);
  color: var(--text); font-weight: 600; font-size: .9rem;
  background: transparent; border: none; width: 100%; text-align: left;
}
.more-panel-item .nav-ic { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.more-panel-item:hover { background: var(--bg-elev-2); }
.more-panel-item.active { background: var(--accent-soft); color: var(--accent-3); }
:root[data-theme="dark"] .more-panel-item.active { color: var(--accent-2); }
.more-panel-item.active .nav-ic { color: var(--accent); }
.more-panel-item.danger { color: var(--neg); }
.more-panel-item.danger .nav-ic { color: var(--neg); }
.more-panel-item .badge { margin-left: auto; }
.more-panel-list form { margin: 1rem 0 0; padding-top: .6rem; border-top: 1px solid var(--border); }
@media (min-width: 769px) { .more-panel, .more-panel-overlay { display: none; } }

/* =========================================================
   Responsive breakpoints
   ========================================================= */
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .content { padding: 1rem 1rem calc(var(--bottom-nav-h) + 1.5rem + var(--safe-bottom)); }
  .app-header { padding: calc(.75rem + var(--safe-top)) 1rem .75rem; }
  .hide-mobile { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .stat-value { font-size: 1.2rem; }
  .form-row { grid-template-columns: 1fr; }
  .chat-page-card { height: calc(100vh - var(--topbar-h) - var(--bottom-nav-h) - 2rem - var(--safe-bottom)); }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input { width: 100%; flex: none; }
}

@media (max-width: 460px) {
  .stat-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr 1fr; }
}

/* Touch target sizing on mobile */
@media (pointer: coarse) {
  .icon-btn-sm { width: 36px; height: 36px; }
  .btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.muted { color: var(--text-muted); }
