/* -------------------------------------------------------------
 * CSS Custom Properties & Base Setup (Sleek Dark Finance Theme)
 * ------------------------------------------------------------- */
:root {
  /* Color Palette */
  --bg-primary: #0a0b10;
  --bg-secondary: #12131b;
  --bg-card: rgba(22, 24, 37, 0.7);
  --bg-card-hover: rgba(28, 30, 48, 0.85);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #6366f1; /* Indigo */
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #d946ef; /* Fuchsia */
  
  --income: #10b981; /* Emerald */
  --income-glow: rgba(16, 185, 129, 0.2);
  --expense: #f43f5e; /* Rose */
  --expense-glow: rgba(244, 63, 94, 0.2);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --app-height: var(--layout-viewport-height, 100vh);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
  --bottom-bar-height: 64px;
  --bottom-bar-overscan: 0px;
  --bottom-bar-drape: 0px;
  --bottom-tabbar-safe-space: clamp(0px, calc(var(--safe-area-bottom) - 14px), 16px);
  --bottom-nav-drop: clamp(0px, calc(var(--safe-area-bottom) - 20px), 10px);
  --pull-refresh-distance: 0px;
  --toast-top: max(72px, calc(var(--safe-area-top) + 44px));
}

@supports (height: 100dvh) {
  :root {
    --app-height: var(--layout-viewport-height, 100dvh);
  }
}

@media (display-mode: standalone) {
  :root {
    --safe-area-top: env(safe-area-inset-top, 60px);
    --safe-area-bottom: env(safe-area-inset-bottom, 30px);
  }
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-light: rgba(0, 0, 0, 0.06);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 35px rgba(99, 102, 241, 0.08);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  width: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(circle at 85% 0%, rgba(99, 102, 241, 0.16), transparent 300px),
    radial-gradient(circle at 15% 100%, rgba(217, 70, 239, 0.12), transparent 300px);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  overscroll-behavior: none;
  min-height: var(--app-height);
}

/* Allow text selection only in form inputs and transaction amounts in cards */
input, textarea {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.tx-amount {
  user-select: text !important;
  -webkit-user-select: text !important;
  -webkit-touch-callout: default !important;
}

.app-container {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: auto;
  left: 0;
  height: var(--app-height);
  min-height: var(--app-height);
  width: 100%;
  max-width: 480px; /* Limit width on desktop for perfect mobile mockup appearance */
  margin: 0 auto;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 85% 0%, rgba(99, 102, 241, 0.16), transparent 300px),
    radial-gradient(circle at 15% 100%, rgba(217, 70, 239, 0.12), transparent 300px);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
  transition: transform 0.45s cubic-bezier(0.32, 0.94, 0.6, 1), filter 0.45s cubic-bezier(0.32, 0.94, 0.6, 1), border-radius 0.45s cubic-bezier(0.32, 0.94, 0.6, 1);
  transform-origin: center bottom;
  overflow: hidden;
  overscroll-behavior: none;
}

.app-container::after {
  content: '';
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 0;
  background: linear-gradient(180deg, rgba(10, 11, 16, 0) 0%, rgba(8, 9, 14, 0.96) 34%, var(--bg-primary) 100%);
  pointer-events: none;
  z-index: 90;
}

body:has(.modal-overlay.active) .app-container {
  transform: scale(0.96);
  filter: brightness(0.65) blur(0.3px);
  border-radius: 24px 24px 0 0;
}

/* Header Styling */
.app-header {
  height: calc(64px + var(--safe-area-top));
  padding: calc(16px + var(--safe-area-top)) 20px 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  background: rgba(10, 11, 16, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
}

.demo-mode-banner {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 20px;
  color: #fde68a;
  background: rgba(120, 53, 15, 0.34);
  border-bottom: 1px solid rgba(245, 158, 11, 0.38);
  z-index: 110;
}

.demo-mode-banner:not([hidden]) {
  display: flex;
}

.demo-mode-banner > i {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.demo-mode-banner > span {
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
}

.demo-mode-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid rgba(253, 230, 138, 0.42);
  border-radius: 8px;
  color: #fff7d6;
  background: rgba(245, 158, 11, 0.13);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.demo-mode-exit:hover {
  background: rgba(245, 158, 11, 0.22);
}

.demo-mode-exit:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

.demo-mode-exit i {
  width: 16px;
  height: 16px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
}

.logo-icon {
  width: 20px;
  height: 20px;
  color: white;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-icon-btn,
.settings-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  transition: background-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-add-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.24);
}

.header-add-btn i {
  width: 22px;
  height: 22px;
  stroke-width: 3;
}

.header-icon-btn.active,
.header-icon-btn:active,
.settings-btn:active {
  background-color: var(--border-light);
  color: var(--text-primary);
  transform: scale(0.92);
}

.header-add-btn:active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}

.header-search-panel {
  position: absolute;
  top: calc(var(--safe-area-top) + 68px);
  left: 20px;
  right: 20px;
  z-index: 150;
}

.header-search-panel[hidden] {
  display: none;
}

.header-search-input-wrapper {
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: rgba(18, 19, 27, 0.92);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header-search-input-wrapper input {
  min-height: 50px;
  border-radius: 18px;
  background: transparent;
}

/* Pull to refresh */
.pull-refresh-indicator {
  position: absolute;
  top: calc(var(--safe-area-top) + 10px);
  left: 50%;
  transform: translate(-50%, calc(-100% + var(--pull-refresh-distance, 0px)));
  z-index: 130;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(18, 19, 27, 0.78);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34), 0 0 22px rgba(99, 102, 241, 0.16);
  color: var(--text-secondary);
  opacity: 0;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.32, 0.94, 0.6, 1), border-color 0.18s ease;
}

.pull-refresh-orb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(217, 70, 239, 0.95));
  color: white;
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.24);
}

.pull-refresh-icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.5;
  transform-origin: center;
  transition: transform 0.08s linear;
}

.pull-refresh-indicator span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.app-container.is-pulling-refresh .pull-refresh-indicator {
  opacity: 1;
}

.app-container.is-pull-refresh-ready .pull-refresh-indicator {
  border-color: rgba(99, 102, 241, 0.32);
  color: var(--text-primary);
}

.app-container.is-refreshing .pull-refresh-indicator {
  opacity: 1;
  transform: translate(-50%, calc(-100% + 86px));
  border-color: rgba(99, 102, 241, 0.36);
  color: var(--text-primary);
}

.app-container.is-refreshing .pull-refresh-icon {
  animation: pullRefreshSpin 0.78s linear infinite;
}

@keyframes pullRefreshSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pull-refresh-indicator,
  .pull-refresh-icon {
    transition: none;
  }

  .app-container.is-refreshing .pull-refresh-icon {
    animation: none;
  }
}

/* Main Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* Block horizontal scroll/sway */
  padding: 20px;
  padding-bottom: calc(var(--bottom-bar-height) + var(--bottom-tabbar-safe-space) + 22px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

/* Hide scrollbars for aesthetic reasons */
.app-content::-webkit-scrollbar {
  display: none;
}

/* Tab Panels */
.tab-pane {
  display: none;
  animation: tabFadeIn 0.38s cubic-bezier(0.32, 0.94, 0.6, 1) forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: scale(0.985) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Page Titles */
.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 20px;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title-row .page-title {
  margin-bottom: 0;
}

/* Section Titles */
.section-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 12px 0;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0;
}

.see-all-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 4px;
  cursor: pointer;
}

.see-all-btn i {
  width: 14px;
  height: 14px;
}

/* -------------------------------------------------------------
 * Glassmorphic Cards & UI Elements
 * ------------------------------------------------------------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}

/* Balance Card (Gradient + Glowing Effect) */
.balance-card {
  background: linear-gradient(135deg, #1d1c31 0%, #0d0f22 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 12px;
}

.balance-card[role="button"] {
  cursor: pointer;
}

.balance-card[role="button"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.balance-card[role="button"]:active {
  transform: scale(0.99);
}

.balance-glow {
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
}

.balance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 8px;
}

/* Currency Convert Button style */
.currency-convert-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  padding: 4px 10px;
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.currency-convert-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.12);
}

.currency-convert-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.convert-icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
  transition: transform 0.4s ease;
}

.currency-convert-btn:active .convert-icon {
  transform: rotate(180deg);
}

.balance-amount {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 24px;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.balance-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-item.income .stat-icon-wrapper {
  background: rgba(16, 185, 129, 0.1);
  color: var(--income);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.stat-item.expense .stat-icon-wrapper {
  background: rgba(244, 63, 94, 0.1);
  color: var(--expense);
  border: 1px solid rgba(244, 63, 94, 0.15);
}

.stat-icon-wrapper i {
  width: 18px;
  height: 18px;
}

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

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

.stat-val {
  font-size: 15px;
  font-weight: 700;
}

.stat-item.income .stat-val {
  color: var(--income);
}

.stat-item.expense .stat-val {
  color: var(--expense);
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border-light);
}

.dashboard-accounts-breakdown {
  display: none;
}

.dashboard-accounts-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-accounts-heading small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.dashboard-account-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.dashboard-account-row.is-excluded {
  opacity: 0.58;
}

.dashboard-account-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--account-color, var(--primary)) 28%, transparent);
  color: var(--account-color, var(--primary));
  background: color-mix(in srgb, var(--account-color, var(--primary)) 13%, transparent);
}

.dashboard-account-icon i {
  width: 16px;
  height: 16px;
}

.dashboard-account-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dashboard-account-copy strong,
.dashboard-account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-account-copy strong {
  font-size: 13px;
  font-weight: 800;
}

.dashboard-account-copy small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.dashboard-account-balance {
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.dashboard-account-balance.income {
  color: var(--income);
}

.dashboard-account-balance.expense {
  color: var(--expense);
}

.dashboard-account-empty {
  padding: 12px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

/* Charts Containers */
.chart-mini-card {
  padding: 16px;
}

.dashboard-chart-title {
  margin-bottom: 12px;
  font-size: 18px;
}

.dashboard-expense-overview {
  display: grid;
  grid-template-columns: minmax(174px, 1fr) minmax(128px, 0.78fr);
  align-items: center;
  gap: 12px;
}

.chart-container-mini {
  height: 200px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.dashboard-category-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.overview-breakdown-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 20px;
}

.overview-breakdown-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.overview-breakdown-name {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-breakdown-percent {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.overview-breakdown-budget {
  grid-column: 2 / 4;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.budget-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}

.budget-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.budget-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.budget-progress-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.budget-progress-caption strong {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 900;
}

.chart-container-large {
  height: 250px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-container-trend {
  height: 200px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
}

.empty-state-chart p {
  font-size: 13px;
  font-weight: 500;
}

.empty-icon {
  width: 40px;
  height: 40px;
  color: var(--border-light);
}

/* -------------------------------------------------------------
 * Transaction List UI
 * ------------------------------------------------------------- */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s, border-color 0.2s;
  cursor: pointer;
}

#history-transactions-list .transaction-item + .transaction-item {
  margin-top: 10px;
}

.transaction-item:active {
  transform: scale(0.955);
  background-color: var(--bg-card-hover);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  margin-right: 12px;
}

.tx-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.tx-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tx-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tx-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.tx-category-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.tx-account-badge {
  max-width: 104px;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.tx-amount {
  font-size: 15px;
  font-weight: 700;
}

.tx-amount.expense {
  color: var(--text-primary);
}

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

.tx-amount.transfer {
  color: #38bdf8;
}

.tx-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* History Group Headers */
.history-date-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0;
  margin: 18px 0 8px 0;
  padding-left: 4px;
}

.transaction-date-header {
  grid-column: 1 / -1;
}

#recent-transactions-list .transaction-date-header:first-child {
  margin-top: 0;
}

/* Empty State general */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state i {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 14px;
  font-weight: 500;
}

/* -------------------------------------------------------------
 * Bottom Navigation & FAB (Perfect Bottom Curve)
 * ------------------------------------------------------------- */
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(100%, 480px);
  height: calc(var(--bottom-bar-height) + var(--bottom-tabbar-safe-space));
  padding-bottom: var(--bottom-tabbar-safe-space);
  background: linear-gradient(180deg, rgba(12, 13, 21, 0.72) 0%, rgba(8, 9, 14, 0.98) 64%, var(--bg-primary) 100%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.38);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  overflow: visible;
  isolation: isolate;
  z-index: 900;
}

.app-tabbar::before {
  content: '';
  display: none;
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 13, 21, 0.86) 0%, rgba(8, 9, 14, 0.98) 58%, var(--bg-primary) 100%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  z-index: 0;
}

.tabbar-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 58px;
  height: var(--bottom-bar-height);
  cursor: pointer;
  position: relative;
  z-index: 2;
  transform: translateY(var(--bottom-nav-drop));
  transition: color 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tabbar-item i {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), stroke-width 0.25s ease;
}

.tabbar-item span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}

.tabbar-item.active {
  color: var(--primary);
  text-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.tabbar-item.active i {
  transform: translateY(-3px) scale(1.05);
  stroke-width: 2.5;
}

.tabbar-item:active {
  transform: translateY(var(--bottom-nav-drop)) scale(0.92);
}

/* -------------------------------------------------------------
 * Modals & Sheets (Slide up Bottom Sheet)
 * ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

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

.modal-overlay[hidden] {
  display: none;
}

.modal-sheet {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  width: 100%;
  max-width: 480px;
  padding: 16px 20px calc(28px + var(--safe-area-bottom)) 20px;
  transform: translateY(100%);
  transition: transform 0.42s cubic-bezier(0.32, 0.94, 0.6, 1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  max-height: calc(var(--app-height) - 54px - var(--safe-area-top));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-sheet.is-dragging {
  transition: none;
}

.accounts-sheet {
  max-height: calc(var(--app-height) - 80px - var(--safe-area-top));
}

.accounts-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.accounts-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.accounts-summary span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.accounts-summary strong {
  font-size: 22px;
  line-height: 1;
}

.account-card-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.account-card {
  --account-color: var(--primary);
  position: relative;
  overflow: hidden;
  min-height: 138px;
  border: 1px solid color-mix(in srgb, var(--account-color) 32%, transparent);
  border-radius: 20px;
  padding: 16px;
  background:
    radial-gradient(circle at 88% 18%, color-mix(in srgb, var(--account-color) 24%, transparent), transparent 130px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035));
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.24);
}

.account-card.is-excluded {
  opacity: 0.72;
}

.account-card::after {
  content: '';
  position: absolute;
  right: -28px;
  bottom: -34px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--account-color) 26%, transparent);
  opacity: 0.45;
}

.account-card-topline,
.account-card-main,
.account-card-actions,
.account-card-footer {
  position: relative;
  z-index: 1;
}

.account-card-topline,
.account-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.account-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-icon i {
  width: 22px;
  height: 22px;
}

.account-type-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.account-card-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 16px 0 18px;
}

.account-card-name {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.account-card-pan {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.account-card-balance {
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.account-card-balance.income {
  color: var(--income);
}

.account-card-balance.expense {
  color: var(--expense);
}

.account-card-footer {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  align-items: flex-end;
}

.account-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.account-action-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.account-action-btn i {
  width: 17px;
  height: 17px;
}

.account-action-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.account-action-btn.danger {
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.28);
  background: rgba(244, 63, 94, 0.12);
}

.account-action-btn.danger:active {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.46);
}

.account-include-toggle,
.account-form-checkbox {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.account-include-toggle {
  justify-content: flex-end;
  flex: 1;
}

.account-include-toggle input,
.account-form-checkbox input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.account-include-toggle span {
  font-size: 11px;
  font-weight: 800;
}

.account-form-checkbox {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  margin-bottom: 16px;
}

.account-form-checkbox strong {
  display: block;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.2;
  margin-bottom: 2px;
}

.account-form-checkbox small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.account-add-card {
  min-height: 68px;
  border: 1px dashed rgba(99, 102, 241, 0.42);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(217, 70, 239, 0.08));
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.account-add-card:active {
  transform: scale(0.985);
  border-color: rgba(99, 102, 241, 0.68);
}

.account-add-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary);
  flex-shrink: 0;
}

.account-add-icon i {
  width: 22px;
  height: 22px;
}

.account-add-card strong,
.account-add-card small {
  display: block;
}

.account-add-card strong {
  font-size: 14px;
  font-weight: 800;
}

.account-add-card small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.account-form-sheet {
  max-width: 480px;
}

.account-form-card {
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
}

.color-grid,
.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.account-color-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.modal-overlay.confirm-overlay {
  align-items: center;
  padding: 20px;
}

.confirm-dialog {
  width: min(100%, 360px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.96);
  transition: transform 0.24s ease;
}

.modal-overlay.active .confirm-dialog {
  transform: translateY(0) scale(1);
}

.confirm-dialog h2 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.confirm-dialog p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.category-transfer-dialog {
  width: min(100%, 390px);
}

.category-transfer-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  margin: -8px 0 14px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.12);
  color: #fecdd3;
  border: 1px solid rgba(244, 63, 94, 0.24);
  font-size: 12px;
  font-weight: 800;
}

.category-transfer-dialog .form-label {
  display: block;
  margin-bottom: 8px;
}

.category-transfer-dialog select {
  margin-bottom: 18px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
}

.modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin-bottom: 14px;
  flex-shrink: 0;
  padding-top: 2px;
}

.modal-drag-indicator {
  appearance: none;
  width: 52px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  margin-bottom: 8px;
  position: relative;
}

.modal-drag-indicator::before {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 10px;
  height: 4px;
  background-color: var(--border-light);
  border-radius: 999px;
}

.modal-drag-indicator:active {
  cursor: grabbing;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
}

.modal-close {
  position: absolute;
  right: 0;
  top: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.9);
}

.modal-delete {
  position: absolute;
  left: 0;
  top: 8px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(244, 63, 94, 0.34);
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.14);
  color: #fb7185;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.18s ease, border-color 0.2s ease;
}

.modal-delete i {
  width: 19px;
  height: 19px;
}

.modal-delete:active {
  background: rgba(244, 63, 94, 0.24);
  border-color: rgba(244, 63, 94, 0.54);
  transform: scale(0.92);
}

.modal-delete:focus-visible {
  outline: 2px solid rgba(244, 63, 94, 0.64);
  outline-offset: 3px;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 16px;
}

.modal-body::-webkit-scrollbar {
  display: none;
}

/* Large Numeric Input */
.amount-input-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 16px 0;
}

.amount-currency-symbol {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-secondary);
}

.amount-currency-select {
  width: 72px;
  min-height: 54px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  text-align-last: center;
  padding: 0 10px;
  outline: none;
  cursor: pointer;
}

.amount-currency-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.amount-input-group input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 38px;
  font-weight: 800;
  width: 200px;
  text-align: center;
  outline: none;
  font-family: var(--font-family);
}

.amount-input-group input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

/* -------------------------------------------------------------
 * Forms, Fields, & Buttons
 * ------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0;
}

.form-section {
  margin-bottom: 16px;
}

.form-section .form-label {
  margin-bottom: 10px;
  display: block;
}

/* Inputs styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 52px;
  background-color: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.25;
  outline: none;
  caret-color: var(--primary);
  box-shadow: inset 0 0 0 1px transparent;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  border-color: var(--border-light);
  -webkit-text-fill-color: var(--text-primary);
  caret-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px rgba(22, 24, 37, 0.98) inset;
  box-shadow: 0 0 0 1000px rgba(22, 24, 37, 0.98) inset;
  transition: background-color 9999s ease-in-out 0s;
}

[data-theme="light"] input:-webkit-autofill,
[data-theme="light"] input:-webkit-autofill:hover,
[data-theme="light"] input:-webkit-autofill:focus,
[data-theme="light"] input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.98) inset;
  box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.98) inset;
}

/* Custom Select Dropdown on setting */
.settings-select {
  width: auto;
  max-width: 150px;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.05);
}

.account-select {
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) 50%,
    calc(100% - 15px) 50%;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
  font-weight: 700;
}

/* Transaction Type Toggle button */
.tx-type-toggle-group {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 3px;
  margin-bottom: 16px;
}

.tx-mode-toggle-group {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 3px;
  margin-bottom: 12px;
}

.tx-type-toggle-group input[type="radio"],
.tx-mode-toggle-group input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-btn {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, transform 0.1s;
}

.tx-type-toggle-group input[type="radio"]:checked + .toggle-btn.expense {
  background: var(--expense);
  color: white;
  box-shadow: 0 4px 12px var(--expense-glow);
}

.tx-type-toggle-group input[type="radio"]:checked + .toggle-btn.income {
  background: var(--income);
  color: white;
  box-shadow: 0 4px 12px var(--income-glow);
}

.tx-mode-toggle-group input[type="radio"]:checked + .toggle-btn {
  background: rgba(99, 102, 241, 0.22);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.22);
}

.tx-mode-toggle-group input[type="radio"]:checked + .toggle-btn.transfer {
  background: rgba(14, 165, 233, 0.18);
}

.tx-type-toggle-group input[type="radio"]:focus-visible + .toggle-btn,
.tx-mode-toggle-group input[type="radio"]:focus-visible + .toggle-btn {
  outline: 3px solid rgba(129, 140, 248, 0.72);
  outline-offset: 2px;
}

.toggle-btn:active {
  transform: scale(0.97);
}

.transfer-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

#tx-operation-type-group[hidden],
#tx-category-section[hidden],
#tx-account-section[hidden],
.transfer-fields[hidden] {
  display: none !important;
}

.is-invalid,
.category-picker-button.is-invalid {
  border-color: rgba(244, 63, 94, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12);
}

.field-error {
  color: var(--expense);
  font-size: 11px;
  font-weight: 700;
  margin-top: 6px;
}

/* Modal Category Picker */
.category-picker-button {
  appearance: none;
  min-height: 50px;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text-primary);
  padding: 8px 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.category-picker-button:active {
  transform: scale(0.985);
  background: rgba(255, 255, 255, 0.08);
}

.category-picker-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-picker-icon i,
.category-picker-chevron {
  width: 20px;
  height: 20px;
}

.category-picker-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-picker-copy strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-picker-copy small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

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

.category-picker-panel {
  position: absolute;
  inset: 88px 0 0 0;
  z-index: 5;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  padding: 12px 18px calc(24px + var(--safe-area-bottom));
  flex-direction: column;
  gap: 12px;
}

.category-picker-panel[hidden] {
  display: none;
}

.category-picker-panel:not([hidden]) {
  display: flex;
}

.category-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-picker-header h3 {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  text-align: right;
  line-height: 1.2;
}

.category-select-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 2px 8px;
}

.category-select-grid::-webkit-scrollbar {
  display: none;
}

.cat-select-item {
  appearance: none;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-primary);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.2s, border-color 0.2s;
}

.cat-select-item:active {
  transform: scale(0.985);
}

.cat-select-item.selected {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
}

.cat-select-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.cat-select-item.selected .cat-select-icon {
  border-width: 2px;
}

.cat-select-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-secondary);
  text-align: left;
  max-width: none;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

.cat-select-item.selected .cat-select-label {
  color: var(--text-primary);
  font-weight: 700;
}

/* Buttons style */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 14px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.945);
}

.btn:focus {
  outline: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.32), 0 4px 12px var(--primary-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex: 2;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  flex: 1;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.16);
  color: #fecdd3;
  border: 1px solid rgba(244, 63, 94, 0.32);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.12);
  flex: 2;
}

.btn-danger:active {
  background: rgba(244, 63, 94, 0.24);
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 8px;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(18, 19, 27, 0), var(--bg-secondary) 36%);
}

/* -------------------------------------------------------------
 * Search & Filters UI
 * ------------------------------------------------------------- */
.search-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.search-input-wrapper input {
  padding-left: 44px;
  padding-right: 40px;
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.history-filter-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.history-filter-account {
  grid-column: 2 / -1;
}

.history-filter-category {
  grid-column: 2 / -1;
}

.history-filter-type {
  grid-column: 1;
}

.history-reset-filter,
.history-filter-control {
  min-width: 0;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.history-reset-filter {
  appearance: none;
  min-height: 44px;
  padding: 0 16px;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.history-reset-filter.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px var(--primary-glow);
}

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

.history-filter-control {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
  padding: 0;
}

.history-filter-control span {
  position: absolute;
  top: 7px;
  left: 12px;
  right: 28px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: none;
}

.history-filter-control::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 12px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.history-filter-select {
  appearance: none;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  padding: 16px 28px 4px 12px;
  outline: none;
  cursor: pointer;
}

.history-filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

@media (min-width: 700px) {
  .history-filter-row {
    grid-template-columns: auto repeat(3, minmax(0, 1fr));
  }

  .history-filter-account,
  .history-filter-type,
  .history-filter-category {
    grid-column: auto;
  }
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.filter-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 10px var(--primary-glow);
}

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

/* -------------------------------------------------------------
 * Category Manager View UI
 * ------------------------------------------------------------- */
.category-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 18px;
}

.category-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 0;
  min-width: 0;
}

.cat-tab-btn {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.cat-tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.categories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s, border-color 0.2s;
}

.category-card:active {
  transform: scale(0.935);
  background-color: var(--bg-card-hover);
}

.category-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-card-icon i {
  width: 20px;
  height: 20px;
}

.category-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.category-card-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-card-meta {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.category-card-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.add-cat-btn {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.15);
  color: var(--primary);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.add-cat-btn i {
  width: 16px;
  height: 16px;
}

.add-cat-btn:active {
  transform: scale(0.95);
}

/* Category Pickers in Modal */
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px 8px;
  padding: 4px;
  justify-items: center;
  align-items: center;
}

.color-option {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s;
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
}

.color-option.selected {
  transform: scale(1.15);
  border-color: white;
}

.color-option:active {
  transform: scale(0.82);
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px 8px;
  max-height: 150px;
  overflow-y: auto;
  padding: 4px;
  justify-items: center;
  align-items: center;
}

.icon-picker-grid::-webkit-scrollbar {
  display: none;
}

.icon-option {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

.icon-option i {
  width: 18px;
  height: 18px;
}

.icon-option.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.12);
}

.icon-option:active {
  transform: scale(0.82);
}

/* -------------------------------------------------------------
 * Analytics Page Components
 * ------------------------------------------------------------- */
.period-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 16px;
}

.period-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.period-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.analytics-range-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.analytics-range-panel[hidden] {
  display: none;
}

.analytics-range-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.analytics-range-field span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.analytics-range-field input {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
  width: 100%;
  text-align: right;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.analytics-summary-card {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: var(--bg-card);
}

.analytics-summary-card span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-summary-card strong {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.analytics-summary-card strong.income,
.analytics-summary-card .income {
  color: var(--income);
}

.analytics-summary-card strong.expense,
.analytics-summary-card .expense {
  color: var(--expense);
}

/* Plan */
.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  display: block;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.plan-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.plan-summary-card strong {
  white-space: nowrap;
}

.plan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.plan-calendar-card,
.plan-day-card {
  padding: 16px;
}

.plan-calendar-toolbar,
.plan-day-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.plan-calendar-toolbar h2,
.plan-day-card-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 800;
  text-transform: capitalize;
}

.icon-btn,
.inline-icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.icon-btn:active,
.inline-icon-btn:active {
  transform: scale(0.96);
}

.plan-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.plan-weekday {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  padding: 0 0 4px;
}

.plan-day {
  min-height: 82px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.plan-day:hover,
.plan-day.is-selected {
  border-color: rgba(99, 102, 241, 0.72);
  background: rgba(99, 102, 241, 0.12);
}

.plan-day:active {
  transform: scale(0.98);
}

.plan-day.is-outside {
  opacity: 0.42;
}

.plan-day.is-today .plan-day-number {
  color: var(--primary);
}

.plan-day-number {
  font-size: 14px;
  font-weight: 800;
}

.plan-day-dots {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.plan-day-dot {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.plan-day-dot.income,
.plan-item-side .income {
  color: var(--income);
}

.plan-day-dot.expense,
.plan-item-side .expense {
  color: var(--expense);
}

.plan-selected-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-item {
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  overflow: hidden;
}

.plan-item.status-posted,
.plan-item.status-skipped {
  opacity: 0.72;
}

.plan-item-main {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.plan-item-icon {
  width: 40px;
  height: 40px;
  border: 1px solid currentColor;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plan-item-icon i {
  width: 20px;
  height: 20px;
}

.plan-item-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-item-copy strong,
.plan-item-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-item-copy strong {
  color: var(--text-primary);
  font-size: 14px;
}

.plan-item-copy small,
.plan-item-side small {
  color: var(--text-secondary);
  font-size: 11px;
}

.plan-item-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  white-space: nowrap;
}

.plan-item-side strong {
  font-size: 14px;
}

.plan-item-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px 66px;
  flex-wrap: wrap;
}

.plan-action-btn {
  min-height: 34px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.plan-action-btn i {
  width: 15px;
  height: 15px;
}

.plan-action-btn.primary {
  color: var(--income);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.plan-action-btn.danger {
  color: var(--expense);
  border-color: rgba(244, 63, 94, 0.28);
  background: rgba(244, 63, 94, 0.07);
}

.plan-empty-state {
  min-height: 180px;
}

.plan-primary-row {
  margin-bottom: 16px;
}

.plan-amount-input-group {
  margin-bottom: 16px;
}

.analytics-work-result-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px;
  border-color: rgba(99, 102, 241, 0.2);
}

.analytics-work-result-card.empty {
  border-color: rgba(148, 163, 184, 0.18);
  gap: 10px;
  padding-block: 14px;
}

.analytics-work-result-card.empty .analytics-work-result-grid {
  display: none;
}

.analytics-work-result-card.empty .analytics-work-result-categories {
  margin-top: -4px;
}

.analytics-work-result-card.negative {
  border-color: rgba(244, 63, 94, 0.32);
}

.analytics-work-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.analytics-work-result-header h3 {
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 900;
}

.analytics-work-result-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.analytics-work-result-settings-btn {
  appearance: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 12px;
  padding: 0 10px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.analytics-work-result-settings-btn i {
  width: 15px;
  height: 15px;
}

.analytics-work-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.analytics-work-result-metric {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.analytics-work-result-metric.result {
  grid-column: 1 / -1;
}

.analytics-work-result-metric span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-work-result-metric strong {
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.analytics-work-result-metric strong.income,
.analytics-work-result-card .income {
  color: var(--income);
}

.analytics-work-result-metric strong.expense,
.analytics-work-result-card .expense {
  color: var(--expense);
}

.analytics-work-result-categories {
  margin: -2px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-main-card {
  margin-bottom: 16px;
}

.chart-header {
  margin-bottom: 12px;
}

.chart-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
}

.chart-readable-summary {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.category-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breakdown-item {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 14px 16px;
  width: 100%;
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.breakdown-item.selected {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.45);
}

.breakdown-item:active {
  transform: scale(0.985);
}

.breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.breakdown-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.breakdown-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.breakdown-name {
  font-size: 14px;
  font-weight: 700;
}

.breakdown-percent {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 4px;
}

.breakdown-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.breakdown-amount {
  font-size: 14px;
  font-weight: 700;
}

.breakdown-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  width: 0; /* Animated on load by JS setting width style */
}

.budget-progress.over-limit .budget-progress-caption strong {
  color: var(--expense);
}

.budget-progress.near-limit .budget-progress-caption strong {
  color: #facc15;
}

.budget-progress.within-limit .budget-progress-caption strong {
  color: var(--income);
}

.analytics-transactions-heading {
  margin-top: 22px;
}

.analytics-clear-category-btn {
  border: 1px solid rgba(99, 102, 241, 0.32);
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.analytics-transaction-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analytics-overview-view {
  display: contents;
}

.analytics-category-detail-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analytics-category-detail-view[hidden],
.analytics-overview-view[hidden] {
  display: none;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-back-btn {
  appearance: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 0 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.inline-back-btn:active {
  transform: scale(0.97);
  background-color: var(--bg-card-hover);
}

.inline-back-btn i {
  width: 18px;
  height: 18px;
}

.detail-period-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-category-summary-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.analytics-category-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.analytics-category-icon i {
  width: 28px;
  height: 28px;
}

.analytics-category-summary-body {
  min-width: 0;
}

.analytics-category-summary-body .eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-category-summary-body .page-title {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.analytics-category-summary-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.analytics-category-summary-values {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.analytics-category-summary-values span {
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.analytics-category-summary-values span.income {
  color: var(--income);
}

.analytics-category-summary-values span.expense {
  color: var(--expense);
}

.analytics-category-summary-values small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.analytics-category-detail-insights {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.analytics-detail-metric {
  min-width: 0;
}

.analytics-detail-metric span,
.analytics-detail-metric strong {
  display: block;
}

.analytics-detail-metric span {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-detail-metric strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.analytics-detail-metric strong.over {
  color: var(--expense);
}

.analytics-detail-metric strong.near {
  color: #facc15;
}

.analytics-detail-metric strong.ok {
  color: var(--income);
}

/* -------------------------------------------------------------
 * Settings Layout
 * ------------------------------------------------------------- */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-group h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-left: 4px;
  margin-bottom: 4px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
}

.settings-item-label {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.settings-item-label i {
  color: var(--text-secondary);
  width: 20px;
  height: 20px;
}

.settings-item-label span {
  font-size: 14px;
  font-weight: 700;
  display: block;
}

.settings-item-label p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.demo-mode-setting .settings-item-label {
  cursor: pointer;
}

.demo-mode-setting .settings-item-label div {
  min-width: 0;
}

.settings-info-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
}

.settings-info-card strong {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.work-category-settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.work-category-settings-grid[hidden] {
  display: none;
}

.work-result-settings-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.work-result-settings-toggle i {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.work-result-settings-toggle[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.work-category-settings-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: var(--bg-card);
}

.work-category-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.work-category-settings-header span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.work-category-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.work-category-toggle {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.work-category-toggle:has(input:checked) {
  border-color: rgba(99, 102, 241, 0.34);
  background: rgba(99, 102, 241, 0.1);
}

.work-category-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.work-category-icon {
  width: 30px;
  height: 30px;
  border: 1px solid;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.work-category-icon i {
  width: 16px;
  height: 16px;
}

.work-category-name {
  min-width: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-category-check {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.work-category-toggle input:checked ~ .work-category-check {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.28);
}

.work-category-toggle input:checked ~ .work-category-check::after {
  content: '';
  display: block;
  width: 8px;
  height: 4px;
  margin: 5px auto 0;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

.work-category-empty {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 0;
}

/* Toggle Switch Widget */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-light);
  transition: .25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Action button items in settings */
.settings-action-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-family);
  transition: transform 0.2s, background-color 0.2s;
}

.settings-action-btn:active {
  transform: scale(0.98);
  background-color: var(--bg-card-hover);
}

.settings-action-btn i {
  color: var(--text-secondary);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.settings-action-btn span {
  font-size: 14px;
  font-weight: 700;
  display: block;
}

.settings-action-btn p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.settings-action-btn.warning i {
  color: var(--expense);
}

.settings-action-btn.warning span {
  color: var(--expense);
}

/* About Card widget */
.about-card {
  background: linear-gradient(135deg, rgba(22, 24, 37, 0.4) 0%, rgba(14, 16, 26, 0.4) 100%);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}

.about-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.about-version {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.about-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------
 * Toast Notifications
 * ------------------------------------------------------------- */
.toast-notification {
  position: fixed;
  top: var(--toast-top);
  left: 50%;
  transform: translate(-50%, calc(-100% - var(--toast-top) - 16px));
  opacity: 0;
  visibility: hidden;
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.toast-notification.active {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.toast-message {
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.toast-action-btn {
  appearance: none;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: #c4b5fd;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 0 0 0 12px;
  cursor: pointer;
}

/* -------------------------------------------------------------
 * Small Mobile Devices Optimizations
 * ------------------------------------------------------------- */
@media (max-width: 479px) {
  .app-container {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    height: var(--app-height);
    min-height: var(--app-height);
    width: auto;
    max-width: 100%;
  }

  .demo-mode-banner {
    align-items: flex-start;
    padding: 8px 16px;
  }

  .demo-mode-banner > span {
    padding-top: 3px;
    line-height: 1.35;
  }

  .demo-mode-exit {
    flex: 0 0 auto;
    max-width: 136px;
    line-height: 1.2;
  }

  .toast-notification {
    position: absolute;
    top: auto;
    bottom: calc(var(--bottom-bar-height) + var(--bottom-tabbar-safe-space) + 12px);
    max-width: calc(100% - 32px);
    padding: 10px 14px;
    transform: translate(-50%, calc(100% + var(--bottom-bar-height) + 32px));
  }

  .balance-card {
    padding: 16px;
  }
  .balance-amount {
    font-size: 28px;
    margin-bottom: 16px;
  }
  .balance-stats {
    gap: 10px;
  }
  .dashboard-expense-overview {
    grid-template-columns: minmax(144px, 0.9fr) minmax(0, 1.1fr);
    gap: 10px;
  }
  .chart-container-mini {
    height: 180px;
  }
  .overview-breakdown-name {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.2;
  }
  .stat-item {
    gap: 8px;
  }
  .stat-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }
  .stat-icon-wrapper i {
    width: 14px;
    height: 14px;
  }
  .stat-label {
    font-size: 10px;
  }
  .stat-val {
    font-size: 13px;
    white-space: nowrap;
  }
  .app-content {
    padding: 16px;
    padding-bottom: calc(var(--bottom-bar-height) + var(--bottom-tabbar-safe-space) + 22px);
  }
  .categories-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .category-select-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .page-title {
    font-size: 22px;
    margin-bottom: 14px;
  }
  .tabbar-item {
    width: 52px;
  }
  .tabbar-item span {
    font-size: 9px;
  }
  .plan-header {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }
  .plan-add-btn {
    min-height: 38px;
    padding: 0 12px;
    flex-shrink: 0;
  }
  .plan-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }
  .plan-summary-card {
    min-height: 60px;
    padding: 10px;
    gap: 6px;
  }
  .plan-summary-card span {
    font-size: 9px;
    line-height: 1.15;
  }
  .plan-summary-card strong {
    font-size: 15px;
  }
  .plan-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .plan-calendar-card,
  .plan-day-card {
    padding: 8px;
  }
  .plan-calendar-toolbar,
  .plan-day-card-header {
    margin-bottom: 8px;
  }
  .plan-calendar-toolbar h2,
  .plan-day-card-header h2 {
    font-size: 15px;
  }
  .plan-month-btn {
    width: 34px;
    height: 34px;
  }
  .plan-weekday {
    font-size: 9px;
    padding-bottom: 2px;
  }
  .plan-calendar-grid {
    gap: 4px;
  }
  .plan-day {
    min-height: 44px;
    padding: 5px;
    gap: 4px;
  }
  .plan-day-number {
    font-size: 12px;
  }
  .plan-day-dots {
    gap: 2px;
  }
  .plan-day-dot {
    font-size: 8px;
    line-height: 1;
  }
  .plan-item-main {
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 10px;
    gap: 8px;
  }
  .plan-item-icon {
    width: 36px;
    height: 36px;
  }
  .plan-item-side {
    grid-column: 2;
    align-items: flex-start;
  }
  .plan-item-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 0 10px 10px;
  }
  .plan-action-btn {
    min-width: 0;
    padding: 0 6px;
    font-size: 10px;
    gap: 4px;
  }
  .plan-action-btn i {
    width: 13px;
    height: 13px;
  }
  .plan-primary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }
  .plan-primary-row .amount-input-group,
  .plan-primary-row .tx-type-toggle-group {
    margin: 0;
  }
  .plan-amount-input-group {
    justify-content: flex-start;
    min-width: 0;
  }
  .plan-amount-input-group .amount-currency-select {
    width: 62px;
    min-height: 50px;
    font-size: 22px;
  }
  .plan-amount-input-group input {
    min-width: 0;
    width: 100%;
    font-size: 32px;
    text-align: left;
  }
  .plan-repeat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 118px;
    gap: 10px;
  }
  .plan-repeat-row .form-group {
    min-width: 0;
  }
}

@media (max-width: 340px) {
  .history-filter-row {
    gap: 6px;
  }

  .history-reset-filter {
    padding: 0 12px;
    font-size: 12px;
  }

  .history-filter-control span {
    left: 10px;
    right: 22px;
  }

  .history-filter-control::after {
    right: 8px;
  }

  .history-filter-select {
    font-size: 12px;
    padding-right: 20px;
    padding-left: 10px;
  }

  .balance-stats {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .stat-divider {
    display: none;
  }
  .balance-amount {
    font-size: 24px;
  }
  .tabbar-item {
    width: 46px;
  }
  .tabbar-item i {
    width: 19px;
    height: 19px;
  }
  .tabbar-item span {
    font-size: 8px;
  }
  .app-header {
    padding-left: 14px;
    padding-right: 14px;
  }
  .logo-area {
    gap: 8px;
    min-width: 0;
  }
  .brand-subtitle {
    display: none;
  }
  .header-actions {
    gap: 4px;
  }
  .header-icon-btn,
  .settings-btn,
  .header-add-btn {
    width: 36px;
    height: 36px;
  }
  .header-add-btn i {
    width: 20px;
    height: 20px;
  }
  .plan-action-btn span {
    display: none;
  }
}

/* -------------------------------------------------------------
 * Desktop Responsiveness Wrapper
 * ------------------------------------------------------------- */
@media (min-width: 480px) and (max-width: 899px) {
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #050508;
    background-image: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 400px);
  }
  
  .app-container {
    height: 850px;
    border-radius: 32px;
    border: 4px solid #1e293b;
    overflow: hidden;
  }
  
  .modal-overlay {
    position: absolute;
    border-radius: 28px;
  }
  
  .toast-notification {
    position: absolute;
    top: max(96px, calc(var(--safe-area-top) + 52px));
  }

  .categories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .plan-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------
 * Desktop Workspace Layout
 * ------------------------------------------------------------- */
@media (min-width: 900px) {
  .category-select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-primary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr);
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
  }

  .plan-primary-row .amount-input-group,
  .plan-primary-row .tx-type-toggle-group {
    margin: 0;
  }

  .plan-primary-row .amount-input-group {
    justify-content: flex-start;
    min-width: 0;
  }

  .plan-primary-row .amount-input-group input {
    width: min(220px, 100%);
    text-align: left;
  }

  .plan-primary-row .tx-type-toggle-group {
    min-height: 54px;
  }

  body {
    display: block;
    background-color: var(--bg-primary);
    background-image:
      radial-gradient(circle at 90% 8%, rgba(99, 102, 241, 0.12), transparent 520px),
      radial-gradient(circle at 18% 90%, rgba(217, 70, 239, 0.08), transparent 520px);
  }

  .app-container {
    width: 100%;
    max-width: none;
    height: var(--app-height);
    min-height: var(--app-height);
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    background-image:
      radial-gradient(circle at 86% 4%, rgba(99, 102, 241, 0.12), transparent 520px),
      radial-gradient(circle at 20% 100%, rgba(217, 70, 239, 0.08), transparent 520px);
  }

  .app-container::after {
    display: none;
  }

  body:has(.modal-overlay.active) .app-container {
    transform: none;
    filter: brightness(0.72) blur(0.3px);
    border-radius: 0;
  }

  .app-header {
    height: 72px;
    padding: 18px 32px;
    position: relative;
    z-index: 120;
  }

  .demo-mode-banner {
    width: calc(100% - 248px);
    margin-left: 248px;
    padding-right: 32px;
    padding-left: 32px;
  }

  .header-search-panel {
    top: 82px;
    left: calc(248px + 32px);
    right: 32px;
  }

  .pull-refresh-indicator {
    top: 84px;
    left: calc(248px + ((100% - 248px) / 2));
  }

  .app-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .brand-title {
    font-size: 22px;
  }

  .brand-subtitle {
    font-size: 12px;
  }

  .app-content {
    width: calc(100% - 248px);
    height: calc(var(--app-height) - 72px);
    max-width: 1280px;
    margin-left: 248px;
    padding: 32px clamp(32px, 4vw, 56px) 44px;
    padding-bottom: 44px;
  }

  #history-transactions-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
  }

  #history-transactions-list .transaction-date-header {
    grid-column: 1 / -1;
    margin: 20px 0 0;
  }

  #history-transactions-list .transaction-date-header:first-child {
    margin-top: 0;
  }

  #history-transactions-list .transaction-item {
    min-width: 0;
    min-height: 92px;
  }

  #history-transactions-list .transaction-item + .transaction-item {
    margin-top: 0;
  }

  .app-tabbar {
    position: fixed;
    top: 72px;
    bottom: 0;
    left: 0;
    right: auto;
    transform: none;
    width: 248px;
    max-width: none;
    height: auto;
    padding: 20px 16px 104px;
    background: rgba(10, 11, 16, 0.58);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0;
    border-right: 1px solid var(--border-light);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 8px;
  }

  .app-tabbar::before {
    display: none;
  }

  .tabbar-item {
    width: 100%;
    height: 54px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 16px;
    border-radius: 16px;
    font-size: 13px;
    transform: none;
  }

  .tabbar-item i {
    width: 21px;
    height: 21px;
  }

  .tabbar-item span {
    font-size: 13px;
  }

  .tabbar-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
    text-shadow: none;
  }

  .tabbar-item.active i {
    transform: none;
  }

  #tab-dashboard.active {
    display: grid;
    grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr);
    grid-template-areas:
      "balance chart"
      "recent-title recent-title"
      "recent-list recent-list";
    gap: 24px;
    align-items: stretch;
  }

  #tab-dashboard.active > .balance-card {
    grid-area: balance;
    display: flex;
    flex-direction: column;
    min-height: 300px;
    margin-bottom: 0;
  }

  #tab-dashboard.active > .chart-mini-card {
    grid-area: chart;
    min-height: 300px;
    height: 100%;
  }

  #tab-dashboard.active > .section-title-wrapper {
    grid-area: recent-title;
    margin: 8px 0 -12px;
  }

  #tab-dashboard.active > .transaction-list {
    grid-area: recent-list;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
  }

  .balance-card {
    padding: 28px;
    border-radius: 24px;
  }

  .balance-amount {
    font-size: 44px;
  }

  .dashboard-accounts-breakdown {
    display: grid;
    gap: 2px;
    margin-top: auto;
    padding-top: 24px;
    max-height: 270px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
  }

  .dashboard-accounts-breakdown::-webkit-scrollbar {
    width: 6px;
  }

  .dashboard-accounts-breakdown::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.28);
    border-radius: 999px;
  }

  .dashboard-expense-overview {
    grid-template-columns: minmax(220px, .9fr) minmax(260px, 1.1fr);
    gap: 24px;
  }

  .chart-container-mini {
    height: 240px;
  }

  #tab-analytics.active {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  #tab-analytics .page-title,
  #tab-analytics .period-selector,
  #tab-analytics .analytics-range-panel,
  #tab-analytics .analytics-summary,
  #tab-analytics .analytics-work-result-card,
  #tab-analytics .section-title-wrapper,
  #tab-analytics .category-breakdown,
  #tab-analytics .analytics-category-detail-view {
    grid-column: 1 / -1;
  }

  .analytics-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .analytics-work-result-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .analytics-work-result-metric.result {
    grid-column: auto;
  }

  .analytics-category-summary-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .analytics-category-summary-values {
    grid-column: auto;
    min-width: 220px;
    align-items: flex-end;
    flex-direction: column;
    justify-content: center;
    padding-top: 0;
    border-top: 0;
  }

  .analytics-category-detail-insights {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-main-card {
    min-height: 320px;
    margin-bottom: 0;
  }

  .settings-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  .settings-group.profile-group,
  .settings-group.family-group {
    grid-column: span 1;
  }

  .settings-group.work-result-settings {
    grid-column: 1 / -1;
  }

  .work-category-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
  }

  .modal-overlay {
    position: fixed;
    border-radius: 0;
  }

  .modal-sheet {
    max-width: 720px;
    border-radius: 28px 28px 0 0;
  }

  .accounts-sheet {
    max-width: 760px;
  }

  .account-card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toast-notification {
    position: fixed;
    top: 24px;
  }
}

@media (min-width: 1180px) {
  #tab-dashboard.active {
    grid-template-columns: minmax(420px, .85fr) minmax(520px, 1.15fr);
  }
}

/* -------------------------------------------------------------
 * AI Voice Assistant UI
 * ------------------------------------------------------------- */
/* Modal Body for AI Voice */
.ai-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 20px 0;
}

.ai-voice-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

/* Pulsing Microphone Circle */
.ai-mic-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.1);
  border: 2px solid rgba(139, 92, 246, 0.2);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
}

.ai-mic-pulse i {
  width: 36px;
  height: 36px;
  stroke-width: 2;
  z-index: 2;
}

/* Pulse Animations */
.ai-mic-pulse.pulsing::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
  animation: ai-pulse 1.4s infinite cubic-bezier(0.25, 0, 0, 1);
}

@keyframes ai-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
  }
  100% {
    box-shadow: 0 0 0 24px rgba(139, 92, 246, 0);
  }
}

.ai-mic-pulse.loading i {
  animation: ai-rotate 1.2s infinite linear;
}

@keyframes ai-rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ai-status-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  height: 20px;
}

/* Transcript Box */
.ai-transcript-box {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 20px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 24px;
  box-sizing: border-box;
}

.ai-transcript-placeholder {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.ai-transcript-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
}

.ai-manual-entry {
  width: 100%;
  display: grid;
  gap: 10px;
  margin: -6px 0 22px;
}

.ai-manual-entry[hidden] {
  display: none;
}

.ai-manual-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-manual-entry textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  padding: 12px;
  box-sizing: border-box;
  outline: none;
}

.ai-manual-entry textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.ai-review-card {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
  box-sizing: border-box;
  margin-bottom: 18px;
}

.ai-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ai-review-kicker {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
}

.ai-review-pill {
  color: var(--primary);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-review-warning {
  border: 1px solid rgba(234, 179, 8, 0.3);
  background: rgba(234, 179, 8, 0.1);
  color: #facc15;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 12px;
}

.ai-review-summary-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.ai-review-summary-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-glow);
}

.ai-review-summary-icon i {
  width: 22px;
  height: 22px;
  stroke-width: 2.4;
}

.ai-review-summary-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-review-summary-main strong,
.ai-review-summary-main span,
.ai-review-summary-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-review-summary-main strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
}

.ai-review-summary-main span,
.ai-review-summary-main small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.ai-review-summary-amount {
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

.ai-review-summary-amount.expense {
  color: var(--expense);
}

.ai-review-summary-amount.income {
  color: var(--income);
}

.ai-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ai-review-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ai-review-field-wide {
  grid-column: 1 / -1;
}

.ai-review-field span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ai-review-field input,
.ai-review-field select,
.ai-review-field textarea {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  padding: 0 12px;
  box-sizing: border-box;
  outline: none;
}

.ai-review-field select {
  color-scheme: dark;
}

body[data-theme="light"] .ai-review-field select {
  color-scheme: light;
}

.ai-review-field input:focus,
.ai-review-field select:focus,
.ai-review-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.ai-review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.ai-review-actions .btn {
  min-height: 46px;
  padding-left: 10px;
  padding-right: 10px;
}

/* Actions Row */
.ai-actions {
  width: 100%;
  display: grid;
  gap: 10px;
}

.ai-actions .btn {
  width: 100%;
}

/* -------------------------------------------------------------
 * Authentication Screen & Profiles Styling
 * ------------------------------------------------------------- */

/* Auth Screen Overlay */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: var(--app-height);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 85% 0%, rgba(99, 102, 241, 0.18), transparent 350px),
    radial-gradient(circle at 15% 100%, rgba(217, 70, 239, 0.15), transparent 350px);
  z-index: 2500;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.auth-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

/* Auth Card */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: 28px;
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: authScaleIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes authScaleIn {
  from {
    transform: scale(0.92) translateY(12px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
  margin-bottom: 12px;
}

.auth-logo i {
  width: 24px;
  height: 24px;
  color: white;
}

.auth-brand h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.auth-brand p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Auth Forms */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.auth-form .form-group {
  gap: 10px;
  margin-bottom: 0;
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  min-height: 54px;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.065);
  font-size: 16px;
}

.auth-form .btn-block {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 12px;
  margin-top: 8px;
}

/* Settings Profiles: Profile Card */
.profile-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  position: relative;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.profile-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-grow: 1;
}

.profile-info h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-info p {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.logout-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  background: rgba(244, 63, 94, 0.1);
  color: var(--expense);
  border: 1px solid rgba(244, 63, 94, 0.15);
}

.logout-btn:active {
  background: rgba(244, 63, 94, 0.2);
  transform: scale(0.95);
}

/* Family Members List */
.family-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.family-member-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.family-member-avatar {
  font-size: 20px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
}

.family-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Transaction List Item: User Avatar Badge */
.tx-author-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1.5px solid var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}

/* Position relative for wrapper to let avatar badge sit in corner */
.tx-icon-wrapper {
  position: relative;
}
