/* ==========================================================================
   BOOKKEEPING APP - DARK NAVY / PURPLE FINTECH THEME
   Responsive UI for Desktop and Mobile (iOS PWA)
   ========================================================================== */

:root {
  /* Color System */
  --bg-app: #090D16;
  --bg-card: #101726;
  --bg-card-elevated: #182238;
  --bg-card-hover: #202D4A;
  --bg-input: #151D2E;
  --bg-dropdown: #121A2D;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-focus: rgba(99, 102, 241, 0.5);

  --primary: #6366F1;
  --primary-light: #818CF8;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --primary-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  
  --accent-purple: #8B5CF6;
  --accent-cyan: #06B6D4;
  --accent-emerald: #10B981;
  --accent-rose: #F43F5E;
  --accent-amber: #F59E0B;
  
  --text-main: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #090D16;

  /* Spacing & Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --header-height: 64px;
  --bottom-nav-height: 56px;
  --sidebar-width: 250px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  width: 100%;
  height: 100%;
  background-color: var(--bg-app);
}

body {
  width: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ================= CUSTOM SCROLLBARS ================= */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(11, 15, 25, 0.6);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.6);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.35) rgba(11, 15, 25, 0.6);
}

/* ================= STRICT ICON SIZING & THEMED COLORING ================= */
svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

[data-icon] svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  display: block;
}

.nav-icon [data-icon] svg,
.nav-icon svg,
.sidebar .nav-item svg {
  width: 20px;
  height: 20px;
  color: var(--primary-light);
}

.sidebar .nav-item.active .nav-icon svg,
.sidebar .nav-item.active svg {
  color: #FFFFFF;
}

.brand-icon [data-icon] svg,
.brand-icon svg {
  width: 22px;
  height: 22px;
  color: #FFFFFF;
}

.stat-icon [data-icon] svg,
.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-icon.income svg { color: var(--accent-emerald); }
.stat-icon.expense svg { color: var(--accent-rose); }
.stat-icon.net svg { color: var(--primary-light); }

.account-icon-wrap [data-icon] svg,
.account-icon-wrap svg {
  width: 18px;
  height: 18px;
  color: #FFFFFF;
}

.tx-icon-wrap [data-icon] svg,
.tx-icon-wrap svg {
  width: 18px;
  height: 18px;
  color: #FFFFFF;
}

.card-title [data-icon] svg,
.card-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary-light);
}

.search-input-wrap [data-icon] svg,
.search-input-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--primary-light);
}

.btn [data-icon] svg,
.btn svg {
  width: 18px;
  height: 18px;
}

.btn-outline [data-icon] svg {
  color: var(--primary-light);
}

.btn-danger [data-icon] svg {
  color: #FDA4AF;
}

.btn-icon [data-icon] svg,
.btn-icon svg {
  width: 16px;
  height: 16px;
}

.mobile-nav-btn [data-icon] svg,
.mobile-nav-btn svg {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
}

.mobile-nav-btn.active [data-icon] svg,
.mobile-nav-btn.active svg {
  color: var(--primary-light);
}

.mobile-fab [data-icon] svg,
.mobile-fab svg {
  width: 24px;
  height: 24px;
  color: #FFFFFF;
}

/* ================= CENTERED EMPTY STATES ================= */
.chart-empty-state,
.empty-state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
  width: 100%;
  min-height: 170px;
  margin: 0 auto;
  gap: 12px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
  margin: 0 auto;
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.15);
  flex-shrink: 0;
}

.empty-icon [data-icon] svg,
.empty-icon svg {
  width: 26px;
  height: 26px;
  color: var(--primary-light);
  stroke: var(--primary-light);
}

.empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.4;
}

/* App Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 40%),
              var(--bg-app);
}

/* Sidebar (Desktop) */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  padding: 24px 16px;
  transition: transform 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--primary-glow);
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #FFF 40%, #A5B4FC 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: var(--text-main);
  background: var(--bg-card-elevated);
}

.nav-item.active {
  color: #FFFFFF;
  background: var(--primary-gradient);
  box-shadow: 0 4px 16px var(--primary-glow);
  font-weight: 600;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 40px;
}

/* Header */
.top-header {
  height: var(--header-height);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(16, 23, 38, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Content Area */
.content-area {
  padding: 24px 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #FFFFFF;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-card-elevated);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.btn-outline:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary-light);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #FDA4AF;
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
  color: #FFE4E6;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Cards & Containers */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--border-medium);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Overview Summary Card (Hero) */
.hero-card {
  background: linear-gradient(135deg, rgba(30, 41, 68, 0.8) 0%, rgba(16, 23, 38, 0.95) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.hero-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.hero-balance {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #FFFFFF 60%, #C7D2FE 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.period-pills {
  display: inline-flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.period-pill {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.period-pill.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.stat-box {
  background: rgba(16, 23, 38, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.income {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}

.stat-icon.expense {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.stat-icon.net {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

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

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

/* Accounts Carousel / Cards */
.accounts-section {
  margin-bottom: 24px;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
}

.account-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border-color: var(--border-medium);
}

.account-card-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.account-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.account-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF;
  flex-shrink: 0;
}

.account-name {
  font-weight: 600;
  font-size: 15px;
}

.account-currency {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.account-balance-amount {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 16px;
}

.add-account-card {
  border: 2px dashed var(--border-medium);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--primary-light);
  min-height: 130px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-account-card:hover {
  border-color: var(--primary);
  color: #FFFFFF;
  background: rgba(99, 102, 241, 0.08);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Donut Chart Styling */
.donut-chart-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
}

.donut-svg {
  transform: rotate(-90deg);
  transform-origin: center;
}

.donut-segment {
  transition: stroke-width 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
}

.donut-segment:hover,
.donut-segment.segment-active {
  stroke-width: 38px;
  opacity: 0.95;
}

.donut-center-content {
  position: absolute;
  text-align: center;
  pointer-events: none;
}

.donut-center-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.donut-center-value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Category List Breakdown */
.category-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.cat-breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.cat-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cat-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Bar Chart Styling */
.barchart-wrapper {
  width: 100%;
  display: flex;
  align-items: flex-end;
  padding: 10px 0;
}

.barchart-bars {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  gap: 8px;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 8px;
}

.bar-pillars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  width: 100%;
  justify-content: center;
}

.bar-pillar {
  width: 12px;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.bar-income {
  background: var(--accent-emerald);
}

.bar-expense {
  background: var(--accent-rose);
}

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

/* Transactions List */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transaction-group-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 4px 4px 4px;
}

.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
}

.transaction-item:hover {
  background: var(--bg-card-elevated);
  border-color: var(--border-medium);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tx-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.tx-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-category {
  font-weight: 600;
  font-size: 14px;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.tx-account-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 11px;
}

.tx-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.tx-amount {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.tx-amount.expense {
  color: var(--accent-rose);
}

.tx-amount.income {
  color: var(--accent-emerald);
}

.tx-amount.transfer {
  color: var(--accent-purple);
}

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

/* ================= SLEEK CUSTOM DROPDOWN COMPONENT ================= */
.custom-select-wrapper {
  position: relative;
  display: inline-block;
  min-width: 180px;
  user-select: none;
  font-family: inherit;
}

.form-group .custom-select-wrapper {
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.custom-select-trigger:hover {
  background: var(--bg-card-elevated);
  border-color: var(--border-medium);
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: var(--bg-card-elevated);
}

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

.custom-select-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
  transition: transform 0.2s ease;
}

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

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-dropdown);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  z-index: 999;
  max-height: 240px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-select-wrapper.open .custom-select-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.custom-select-option {
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-select-option:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #FFFFFF;
}

.custom-select-option.selected {
  background: var(--primary-gradient);
  color: #FFFFFF;
  font-weight: 600;
}

/* Filters bar */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.search-input-wrap {
  flex: 1;
  min-width: 220px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrap span[data-icon] {
  position: absolute;
  left: 12px;
  color: var(--primary-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 38px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: var(--bg-card-elevated);
}

/* Modals & Drawers */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-backdrop.modal-active {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.modal-active .modal-sheet {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: var(--bg-card-elevated);
}

.type-segmented {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.type-tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.type-tab.active-expense {
  background: rgba(244, 63, 94, 0.2);
  color: #FDA4AF;
}

.type-tab.active-income {
  background: rgba(16, 185, 129, 0.2);
  color: #6EE7B7;
}

.type-tab.active-transfer {
  background: rgba(139, 92, 246, 0.2);
  color: #C4B5FD;
}

/* Color and Icon Picker */
.palette-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.palette-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.palette-swatch:hover {
  transform: scale(1.15);
}

.palette-swatch.active {
  border-color: #FFFFFF;
  transform: scale(1.15);
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.icon-option {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary-light);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.icon-option svg {
  width: 20px;
  height: 20px;
}

.icon-option:hover {
  background: var(--bg-card-hover);
  color: #FFFFFF;
}

.icon-option.active {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
}

/* ================= FINANCIAL NOTES & DEBTS ================= */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.note-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.note-card.note-completed {
  opacity: 0.6;
  background: rgba(16, 23, 38, 0.4);
}

.note-card-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.note-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.note-header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.custom-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border-medium);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
  margin-top: 2px;
  flex-shrink: 0;
}

.custom-checkbox.checked {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.custom-checkbox svg {
  width: 14px;
  height: 14px;
}

.note-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.note-completed .note-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.note-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-planned {
  background: rgba(244, 63, 94, 0.15);
  color: #FDA4AF;
}

.badge-debt-to-me {
  background: rgba(16, 185, 129, 0.15);
  color: #6EE7B7;
}

.badge-debt-i-owe {
  background: rgba(245, 158, 11, 0.15);
  color: #FDE68A;
}

.badge-note {
  background: rgba(99, 102, 241, 0.15);
  color: #C7D2FE;
}

.note-amount {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.note-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: pre-wrap;
}

.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.note-due-date {
  display: flex;
  align-items: center;
  gap: 6px;
}

.note-due-date span[data-icon] {
  color: var(--primary-light);
}

.note-due-date.overdue {
  color: var(--accent-rose);
  font-weight: 600;
}

.note-due-date.overdue span[data-icon] {
  color: var(--accent-rose);
}

.note-actions {
  display: flex;
  gap: 6px;
}

/* iOS Add to Home Screen Banner & Modal */
.ios-banner {
  display: none;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
  border-bottom: 1px solid rgba(139, 92, 246, 0.3);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #E0E7FF;
}

.ios-step-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.ios-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ================= MOBILE & iOS FIXED NAVIGATION ================= */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
  }

  .top-header {
    position: sticky;
    top: 0;
    z-index: 80;
    padding: 0 16px;
    height: calc(56px + var(--safe-top));
    padding-top: var(--safe-top);
  }

  .content-area {
    padding: 16px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .header-actions .btn {
    flex: 1 1 50%;
    min-width: 0;
    padding: 10px 12px;
    font-size: 13px;
    justify-content: center;
  }

  .accounts-grid {
    grid-template-columns: 1fr;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .filters-bar .search-input-wrap,
  .filters-bar .custom-select-wrapper {
    width: 100%;
    min-width: 0;
  }

  .filters-bar .custom-select-trigger {
    width: 100%;
  }

  .hero-card {
    padding: 18px;
    border-radius: var(--radius-lg);
  }

  .hero-balance {
    font-size: 28px;
  }

  /* Rigidly fixed mobile bottom bar flush to absolute bottom edge */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-top: 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #101726;
    background: rgba(16, 23, 38, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    z-index: 9999;
    justify-content: space-around;
    align-items: center;
    box-sizing: border-box;
    margin: 0 !important;
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.2s ease;
  }

  .mobile-nav-btn.active {
    color: var(--primary-light);
    font-weight: 600;
  }

  .mobile-fab {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--primary-glow);
    cursor: pointer;
    transform: translateY(-10px);
    border: 3px solid var(--bg-app);
    flex-shrink: 0;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-sheet {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
    transform: translateY(100%);
    padding-bottom: calc(var(--safe-bottom) + 16px);
  }

  .modal-active .modal-sheet {
    transform: translateY(0);
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .toast-container {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
  }
}

.toast {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-main);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.toast.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.toast-error {
  border-color: rgba(244, 63, 94, 0.4);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
