@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ============================================================
   GLOBAL STYLES + ANIMATION SYSTEM
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
/* prevent horizontal scroll on all screen sizes */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}
:root {
  --accent: #0f766e;
  --accent-light: #ccfbf1;
  --accent-hover: #0d6560;

  --bg: #eef2f7;
  --surface: rgba(255, 255, 255, 0.65);
  --nav-bg: rgba(248, 250, 252, 0.85); /* Slightly off-white light color for nav */
  --surface-2: rgba(255, 255, 255, 0.95); /* Bright white for components to pop */
  --border: rgba(148, 163, 184, 0.25); /* Subtle dark border for better definition */

  --text-primary: #0f1923;
  --text-secondary: #3d526a;
  --text-muted: #6e85a0;

  --income-color: #15803d;
  --expense-color: #c81e1e;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.12), 0 8px 32px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.06);

  --font: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth:    cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:   0.18s;
  --dur-normal: 0.28s;
  --dur-slow:   0.42s;
}
body.dark {
  --surface: rgba(30, 41, 59, 0.6);
  --nav-bg: rgba(30, 41, 59, 0.6);
  --surface-2: rgba(40, 53, 72, 0.6);
  --border: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow: 0 4px 24px rgba(0,0,0,0.4), 0 8px 32px rgba(0,0,0,0.25);
  background: linear-gradient(-45deg, #0f172a, #1a0b2e, #064e3b, #1e1b4b);
  background-size: 400% 400%;
}
body {
  font-family: var(--font);
  background: linear-gradient(-45deg, #e0f2fe, #fdf4ff, #ccfbf1, #e0e7ff);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text-primary);
  min-height: 100vh;
  transition: color var(--dur-normal) var(--ease-smooth);
}
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
#root { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
}
input, select {
  font-family: var(--font);
  /* border-radius on ALL selects and inputs globally */
  border-radius: var(--radius-sm);
}
/* ---- card ---- */
.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: background var(--dur-normal) var(--ease-smooth),
              border-color var(--dur-normal) var(--ease-smooth),
              box-shadow var(--dur-normal) var(--ease-smooth);
}
/* ---- page / tab transition ---- */
.page-enter {
  animation: pageSlideIn var(--dur-slow) var(--ease-out-quart) both;
}
/* Recharts cleanup for browser focus outlines */
.recharts-wrapper *:focus {
  outline: none !important;
}
@keyframes pageSlideIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* ---- staggered card entrance ---- */
.stagger-child {
  animation: staggerIn var(--dur-slow) var(--ease-out-quart) both;
}
.stagger-child:nth-child(1) { animation-delay: 0.00s; }
.stagger-child:nth-child(2) { animation-delay: 0.07s; }
.stagger-child:nth-child(3) { animation-delay: 0.14s; }
.stagger-child:nth-child(4) { animation-delay: 0.21s; }
@keyframes staggerIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* ---- transaction row entrance ---- */
.tx-row-enter {
  animation: rowSlideIn var(--dur-normal) var(--ease-out-quart) both;
}
@keyframes rowSlideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
/* ---- empty state ---- */
.empty-enter {
  animation: emptyBounceIn 0.5s var(--ease-spring) both;
}
@keyframes emptyBounceIn {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
/* ---- modal backdrop ---- */
.backdrop-enter {
  animation: backdropIn var(--dur-normal) var(--ease-smooth) both;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* ---- modal slide down from top ---- */
.modal-enter {
  animation: modalSlideDown var(--dur-normal) var(--ease-out-quart) both;
}
@keyframes modalSlideDown {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* ============================================================
   CUSTOM MODERN SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(15, 118, 110, 0.4);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 118, 110, 0.7);
}
body.dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}
body.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}
.custom-select {
  position: relative;
  width: 100%;
}

/* the visible trigger button */
.custom-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition:
    border-color var(--dur-fast) var(--ease-smooth),
    background   var(--dur-fast) var(--ease-smooth),
    box-shadow   var(--dur-fast) var(--ease-smooth),
    transform    var(--dur-fast) var(--ease-spring);
  user-select: none;
}

.custom-select__trigger:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.custom-select--open .custom-select__trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
  background: var(--surface);
}

.custom-select__value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select__arrow {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 6px;
  transition: transform var(--dur-normal) var(--ease-spring);
  display: inline-block;
}

.custom-select--open .custom-select__arrow {
  transform: rotate(180deg);
}

/* the dropdown list */
.custom-select__list {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 500;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.13);
  list-style: none;
  padding: 4px;
  margin: 0;
  max-height: 240px;
  overflow-y: auto;
  /* scroll inside the list, never outside */
  overscroll-behavior: contain;
  /* smooth entrance */
  animation: listOpen 0.18s var(--ease-out-quart) both;
}

/* flip upward if not enough space below */
.custom-select__list--up {
  top: auto;
  bottom: calc(100% + 5px);
  animation: listOpenUp 0.18s var(--ease-out-quart) both;
}

@keyframes listOpen {
  from { opacity: 0; transform: translateY(-6px) scaleY(0.95); }
  to   { opacity: 1; transform: translateY(0) scaleY(1); }
}

@keyframes listOpenUp {
  from { opacity: 0; transform: translateY(6px) scaleY(0.95); }
  to   { opacity: 1; transform: translateY(0) scaleY(1); }
}

.custom-select__option {
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-smooth),
              color     var(--dur-fast) var(--ease-smooth);
}

.custom-select__option:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.custom-select__option--selected {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

body.dark .custom-select__option--selected {
  background: rgba(15, 118, 110, 0.2);
}

body.dark .custom-select__list {
  background: rgba(15, 23, 42, 0.95);
}

/* inside modal - needs higher z-index because modal is z-index 200 */
.modal .custom-select__list {
  z-index: 600;
}

/* modal input height match */
.modal .custom-select__trigger {
  height: 40px;
  font-size: 14px;
  background: var(--surface-2);
}

.modal .custom-select--open .custom-select__trigger {
  background: var(--surface);
}

/* mobile: larger tap targets */
@media (max-width: 520px) {
  .custom-select__trigger { height: 42px; font-size: 14px; }
  .custom-select__option  { padding: 11px 12px; font-size: 14px; }
  .custom-select__list    { max-height: 200px; }
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  gap: 16px;
  transition: background var(--dur-normal) var(--ease-smooth),
              border-color var(--dur-normal) var(--ease-smooth);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-logo { font-size: 20px; }

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

/* ---- tab strip ---- */
.topbar-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 4px;
  border: 1px solid var(--border);
  transition: background var(--dur-normal) var(--ease-smooth);
}

.tab-btn {
  position: relative;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  /* smooth everything */
  transition:
    color      var(--dur-normal) var(--ease-smooth),
    background var(--dur-normal) var(--ease-smooth),
    transform  var(--dur-fast)   var(--ease-spring),
    box-shadow var(--dur-normal) var(--ease-smooth);
  will-change: transform;
}

.tab-btn:hover:not(.tab-btn--active) {
  color: var(--text-primary);
  background: var(--border);
  transform: translateY(-1px);
}

.tab-btn:active {
  transform: scale(0.96);
}

.tab-btn--active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.35);
  transform: translateY(0);
}

/* ---- right side controls ---- */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.role-select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease-smooth),
    background   var(--dur-fast) var(--ease-smooth),
    box-shadow   var(--dur-fast) var(--ease-smooth);
}

.role-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.dark-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 16px;
  border: 1px solid var(--border);
  transition:
    background var(--dur-fast) var(--ease-smooth),
    transform  var(--dur-fast) var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease-smooth);
}

.dark-toggle:hover {
  background: var(--border);
  transform: rotate(20deg) scale(1.08);
}

.dark-toggle:active {
  transform: scale(0.9);
}

@media (max-width: 540px) {
  .topbar-tabs { display: none; }
}

/* ---- mobile topbar fixes ---- */
@media (max-width: 540px) {
  .topbar {
    padding: 0 14px;
    gap: 8px;
  }

  .topbar-title { font-size: 15px; }

  .role-select {
    font-size: 12px;
    padding: 5px 7px;
    max-width: 110px;
    border-radius: var(--radius-sm);
  }

  .dark-toggle {
    width: 30px;
    height: 30px;
    font-size: 14px;
    flex-shrink: 0;
  }
}

/* custom role select sizing in topbar */
.role-select-custom {
  width: 120px;
}

.role-select-custom .custom-select__trigger {
  height: 34px;
  font-size: 13px;
  padding: 0 10px;
  background: var(--surface-2);
}

/* role select dropdown should open downward, below topbar */
.role-select-custom .custom-select__list {
  z-index: 9999;
  min-width: 130px;
}

@media (max-width: 540px) {
  .role-select-custom { width: 100px; }
  .role-select-custom .custom-select__trigger { height: 30px; font-size: 12px; }
}
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  /* rounded top corners so it sits nicely above the screen edge */
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  /* respect iPhone notch / Android nav bar */
  padding: 8px 8px env(safe-area-inset-bottom, 8px);
  transition: background var(--dur-normal) var(--ease-smooth),
              border-color var(--dur-normal) var(--ease-smooth);
}

.mobile-nav__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  transition:
    color     var(--dur-normal) var(--ease-smooth),
    transform var(--dur-normal) var(--ease-spring),
    background var(--dur-fast)  var(--ease-smooth);
}

.mobile-nav__btn:active {
  transform: scale(0.88);
  background: var(--surface-2);
}

.mobile-nav__btn--active {
  color: var(--accent);
  transform: translateY(-3px);
}

.mobile-nav__icon {
  font-size: 20px;
  transition: transform var(--dur-fast) var(--ease-spring);
}

.mobile-nav__btn--active .mobile-nav__icon {
  transform: scale(1.18);
}

.mobile-nav__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color var(--dur-normal) var(--ease-smooth);
}

@media (max-width: 540px) {
  .mobile-nav { display: flex; }
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.summary-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
  transition:
    transform    var(--dur-normal) var(--ease-spring),
    box-shadow   var(--dur-normal) var(--ease-smooth),
    border-color var(--dur-normal) var(--ease-smooth),
    background   var(--dur-normal) var(--ease-smooth);
  will-change: transform;
}

.summary-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: var(--shadow), 0 0 20px rgba(15, 118, 110, 0.15);
  border-color: var(--accent);
}

.summary-card__top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-card__icon {
  font-size: 18px;
  transition: transform var(--dur-fast) var(--ease-spring);
}

.summary-card:hover .summary-card__icon {
  transform: scale(1.2) rotate(-5deg);
}

.summary-card__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  transition: color var(--dur-normal) var(--ease-smooth);
}

.summary-card__value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  transition: color var(--dur-normal) var(--ease-smooth);
}

.summary-card__sub {
  font-size: 12px;
  color: var(--text-muted);
  transition: color var(--dur-normal) var(--ease-smooth);
}

/* accent strip */
.summary-card--balance { border-left: 4px solid var(--accent); }
.summary-card--income  { border-left: 4px solid var(--income-color); }
.summary-card--expense { border-left: 4px solid var(--expense-color); }
.summary-card--savings { border-left: 4px solid #7c3aed; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card__value { font-size: 20px; }
}
.spend-chart {
  flex: 1;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.chart-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.chart-wrapper {
  width: 100%;
}

/* shared tooltip style (used by both charts) */
.chart-tooltip {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.chart-tooltip__label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.chart-tooltip__row {
  font-weight: 500;
  line-height: 1.7;
}
.category-chart {
  flex: 1;
  min-width: 0; /* stops flex children from overflowing */
}
/* ============================================================
   FILTER BAR — single horizontal row
   search: flex:1 (stretches)
   dropdowns: fixed 128px each
   clear: auto-width, only appears when active
   ============================================================ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 16px;
}

/* --- search box --- */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 100px;
}

.search-icon {
  position: absolute;
  left: 9px;
  font-size: 12px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-smooth),
              box-shadow   var(--dur-fast) var(--ease-smooth),
              background   var(--dur-fast) var(--ease-smooth);
}

.search-input:hover { border-color: var(--accent); background: var(--surface-2); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
  background: var(--surface);
}

.search-clear {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 3px;
  line-height: 1;
  animation: popIn 0.16s var(--ease-spring) both;
  transition: color var(--dur-fast) var(--ease-smooth),
              transform var(--dur-fast) var(--ease-spring);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.search-clear:hover { color: var(--expense-color); transform: scale(1.2); }

/* --- each dropdown in the filter bar --- */
/* using .fb-select + specificity to win over .custom-select { width:100% } */
.filter-bar .fb-select,
.filter-bar .fb-select.custom-select {
  flex: 0 0 128px;
  width: 128px;
  min-width: 0;
}

.filter-bar .fb-select .custom-select__trigger {
  height: 38px;
  font-size: 13px;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
}

.filter-bar .fb-select .custom-select__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- clear button --- */
.filter-reset {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  animation: popIn 0.2s var(--ease-spring) both;
  transition: background  var(--dur-normal) var(--ease-smooth),
              color        var(--dur-normal) var(--ease-smooth),
              border-color var(--dur-normal) var(--ease-smooth),
              transform    var(--dur-fast)   var(--ease-spring),
              box-shadow   var(--dur-fast)   var(--ease-smooth);
}

.filter-reset:hover {
  background: var(--expense-color);
  color: #fff;
  border-color: var(--expense-color);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(200,30,30,0.28);
}

.filter-reset:active { transform: scale(0.95); }

/* ============================================================
   MOBILE: 2 rows
   Row 1: search + clear (if active)
   Row 2: three dropdowns equally spaced
   ============================================================ */
@media (max-width: 680px) {
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* row 1: search takes full width */
  .search-wrap {
    flex: 1 1 100%;
    order: 1;
  }

  /* row 2: three dropdowns share the width equally */
  .filter-bar .fb-select,
  .filter-bar .fb-select.custom-select {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    order: 2;
  }

  /* clear sits at end of row 1 */
  .filter-reset {
    order: 1;
    flex: 0 0 auto;
    height: 38px;
    align-self: center;
  }

  /* on very small screens stack dropdowns if needed */
  @media (max-width: 340px) {
    .filter-bar .fb-select,
    .filter-bar .fb-select.custom-select {
      flex: 1 1 100%;
    }
  }
}
.tx-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition:
    background    var(--dur-fast)   var(--ease-smooth),
    border-color  var(--dur-normal) var(--ease-smooth),
    padding-left  var(--dur-normal) var(--ease-out-quart);
  cursor: default;
}

.tx-row:last-child { border-bottom: none; }

.tx-row:hover {
  background: var(--surface-2);
  padding-left: 22px; /* subtle indent on hover — feels responsive */
}

.tx-row__icon {
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    transform   var(--dur-fast) var(--ease-spring),
    background  var(--dur-fast) var(--ease-smooth);
}

.tx-row:hover .tx-row__icon {
  transform: scale(1.1);
  background: var(--border);
}

.tx-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-row__desc {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--dur-fast) var(--ease-smooth);
}

.tx-row__meta {
  font-size: 12px;
  color: var(--text-muted);
  transition: color var(--dur-normal) var(--ease-smooth);
}

.tx-row__type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-spring);
}

.tx-row:hover .tx-row__type { transform: scale(1.05); }

.tx-row__type--income  { background: #dcfce7; color: #15803d; }
.tx-row__type--expense { background: #fee2e2; color: #b91c1c; }

body.dark .tx-row__type--income  { background: #14532d; color: #86efac; }
body.dark .tx-row__type--expense { background: #450a0a; color: #fca5a5; }

.tx-row__amount {
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 90px;
  text-align: right;
  transition: transform var(--dur-fast) var(--ease-spring);
}

.tx-row:hover .tx-row__amount { transform: scale(1.04); }

.tx-row__amount--income  { color: var(--income-color); }
.tx-row__amount--expense { color: var(--expense-color); }

.tx-row__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  /* slide in from right when visible */
  animation: actionsIn 0.2s var(--ease-out-quart) both;
}

@keyframes actionsIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tx-action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  transition:
    background  var(--dur-fast) var(--ease-smooth),
    transform   var(--dur-fast) var(--ease-spring);
}

.tx-action-btn:hover { background: var(--border); transform: scale(1.15); }
.tx-action-btn:active { transform: scale(0.92); }

@media (max-width: 500px) {
  .tx-row__type { display: none; }
  .tx-row__amount { font-size: 13px; min-width: 70px; }
  .tx-row:hover { padding-left: 16px; } /* disable indent on mobile */
}
/* ============================================================
   BACKDROP - fixed to viewport, never moves
   Body is position:fixed (set in JSX) so this truly locks
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ============================================================
   MODAL CARD - overflow visible so custom dropdowns show
   ============================================================ */
.modal {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 460px;
  flex-shrink: 0;
  overflow: visible;
  transition: background var(--dur-normal) var(--ease-smooth),
              border-color var(--dur-normal) var(--ease-smooth);
}

.modal-enter {
  animation: modalSlideDown var(--dur-normal) var(--ease-out-quart) both;
}

@keyframes modalSlideDown {
  from { opacity: 0; transform: translateY(-14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== MOBILE: top-aligned, full width, scrollable inside ===== */
@media (max-width: 520px) {
  .modal-backdrop {
    /* keep flex-start + top padding — same as desktop but tighter */
    align-items: flex-start;
    padding: 16px 12px 80px; /* bottom pad clears mobile nav bar */
    overflow-y: auto;
  }

  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius);
    /* scroll inside if content is taller than viewport */
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: modalSlideDown var(--dur-normal) var(--ease-out-quart) both !important;
  }
}

.modal-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title { font-size: 15px; font-weight: 650; color: var(--text-primary); }

.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast) var(--ease-smooth),
              transform  var(--dur-fast) var(--ease-spring);
}
.modal-close:hover { background: var(--border); color: var(--text-primary); transform: scale(1.1); }

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
}

.modal-row {
  display: flex;
  gap: 12px;
}
.modal-row .modal-label { flex: 1; min-width: 0; }

/* date row - day/month/year side by side */
.date-row {
  display: flex;
  gap: 8px;
}

/* day: narrow, month: wider, year: narrow */
.date-row .custom-select:nth-child(1) { flex: 1; }
.date-row .custom-select:nth-child(2) { flex: 2; }
.date-row .custom-select:nth-child(3) { flex: 1.2; }

/* make sure date dropdowns don't get cut off */
.date-row .custom-select__list { z-index: 600; }

.modal-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.modal-input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  width: 100%;
  font-family: var(--font);
  transition: border-color var(--dur-fast) var(--ease-smooth),
              box-shadow    var(--dur-fast) var(--ease-smooth),
              background    var(--dur-fast) var(--ease-smooth);
}
.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
  background: var(--surface);
}

/* match CustomSelect trigger height to modal-input */
.modal-body .custom-select__trigger {
  height: 40px;
  font-size: 14px;
  background: var(--surface-2);
}
.modal-body .custom-select--open .custom-select__trigger {
  background: var(--surface);
}

.modal-error { font-size: 13px; color: var(--expense-color); font-weight: 500; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.modal-btn {
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease-smooth),
              transform  var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-fast) var(--ease-smooth);
}
.modal-btn:active { transform: scale(0.96); }

.modal-btn--cancel {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
}
.modal-btn--cancel:hover { background: var(--border); }

.modal-btn--submit { background: var(--accent); color: white; border: none; }
.modal-btn--submit:hover { background: var(--accent-hover); box-shadow: 0 3px 10px rgba(15,118,110,0.3); }

@media (max-width: 520px) {
  /* buttons stay in a row on mobile — no reverse stacking needed */
  .modal-footer { padding: 12px 14px 14px; gap: 8px; }
  .modal-btn    { height: 44px; font-size: 14px; flex: 1; }
  .modal-body   { padding: 14px; }
  .modal-row    { flex-direction: column; gap: 10px; }
}
.tx-list {
  display: flex;
  flex-direction: column;
}

.tx-list__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.tx-list__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.tx-list__count {
  font-size: 13px;
  color: var(--text-muted);
}

.tx-list__actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tx-header-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.tx-header-btn--export {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.tx-header-btn--export:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.tx-header-btn--add {
  background: var(--accent);
  color: white;
  border: none;
}

.tx-header-btn--add:hover {
  background: var(--accent-hover);
}

.tx-list__table {
  padding: 0;
  overflow: hidden;
}

/* empty state */
.tx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 8px;
  text-align: center;
}

.tx-empty__icon {
  font-size: 36px;
  margin-bottom: 4px;
}

.tx-empty__text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.tx-empty__sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- mobile fixes ---- */
@media (max-width: 600px) {
  .tx-list__header { flex-direction: column; align-items: stretch; gap: 10px; }
  .tx-list__actions { justify-content: flex-end; }

  .tx-header-btn {
    height: 40px;
    font-size: 13px;
    padding: 0 14px;
  }

  .tx-list__table {
    border-radius: var(--radius);
    overflow: hidden;
  }
}
.insight-panel {
  display: flex;
  flex-direction: column;
}

.insight-panel__header {
  margin-bottom: 24px;
}

.insight-panel__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.insight-panel__sub {
  font-size: 13px;
  color: var(--text-muted);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.insight-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.insight-card__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.insight-card__main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.insight-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.insight-card__value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.insight-card__detail {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* progress bar */
.insight-bar-track {
  height: 7px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.insight-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

.insight-bar-fill--accent  { background: var(--accent); }
.insight-bar-fill--muted   { background: var(--text-muted); }
.insight-bar-fill--purple  { background: #7c3aed; }

/* mom badge */
.insight-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.insight-badge--up   { background: #fee2e2; color: var(--expense-color); }
.insight-badge--down { background: #dcfce7; color: var(--income-color); }
.insight-badge--same { background: var(--surface-2); color: var(--text-muted); }

body.dark .insight-badge--up   { background: #450a0a; color: #fca5a5; }
body.dark .insight-badge--down { background: #14532d; color: #86efac; }

/* mom mini bar chart */
.mom-bars {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  height: 48px;
}

.mom-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.mom-bar-track {
  width: 100%;
  height: 36px;
  background: var(--surface-2);
  border-radius: 4px 4px 0 0;
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.mom-bar-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.5s ease;
}

.mom-bar-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* compare bars */
.insight-compare {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-compare__item {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 8px;
}

.insight-compare__label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.insight-compare__val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* tip text at bottom of card */
.insight-tip {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

@media (max-width: 700px) {
  .insight-grid {
    grid-template-columns: 1fr;
  }
}
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
  /* prevent children from breaking out of the viewport */
  min-width: 0;
  overflow-x: hidden;
}

.charts-row {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  min-width: 0;
}

@media (max-width: 800px) {
  .charts-row { flex-direction: column; }
}

@media (max-width: 600px) {
  .app-main { padding: 16px 12px; }
}

/* mobile: push content above the fixed bottom nav */
@media (max-width: 540px) {
  .app-main { padding-bottom: 84px; }
}
