/* ==========================================================================
   LuminaFi — Modern Responsive Design System & CSS Styling
   ========================================================================== */

:root {
  /* Color Palette - Obsidian Glassmorphism */
  --bg-dark: #0b0f17;
  --bg-card: #121926;
  --bg-card-hover: #182234;
  --bg-panel: #162030;
  --bg-input: #0e1420;
  --border-line: #1e2a3c;
  --border-focus: #4f46e5;
  
  /* Text Colors */
  --text-main: #f3f6fc;
  --text-muted: #8e9bb0;
  --text-dim: #627188;
  
  /* Accent Colors */
  --accent-primary: #4f46e5;
  --accent-primary-hover: #6366f1;
  --accent-blue: #3b82f6;
  --accent-blue-soft: rgba(59, 130, 246, 0.14);
  
  --income-green: #10b981;
  --income-green-soft: rgba(16, 185, 129, 0.14);
  
  --expense-rose: #ef4444;
  --expense-rose-soft: rgba(239, 68, 68, 0.14);
  
  --amber-gold: #f59e0b;
  --amber-gold-soft: rgba(245, 158, 11, 0.14);

  /* Shadows & Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.25);
  
  /* Typography */
  --font-heading: "Plus Jakarta Sans", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, sans-serif;
}

/* Reset & Box Model */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  height: 100%;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* When custom background is active, clear the solid color so the image shows */
body.has-custom-bg {
  background-color: transparent !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #253346;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #354760;
}

/* Typography Helpers */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.eyebrow {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* SVG Icon Helper */
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
[data-icon] svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-dark);
}

/* Desktop Left Sidebar */
.sidebar {
  width: 256px;
  flex-shrink: 0;
  background-color: #0c121d;
  border-right: 1px solid var(--border-line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

/* Brand Logo */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-blue));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
  flex-shrink: 0;
}
.brand-mark.small {
  width: 32px;
  height: 32px;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.6px;
  line-height: 1.1;
}
.brand-accent {
  color: var(--accent-blue);
}
.brand-tag {
  font-size: 10px;
  color: var(--text-muted);
}

/* Sidebar User Profile Card */
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-line);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin: 20px 0 24px;
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: color 0.2s;
  display: grid;
  place-items: center;
  text-decoration: none;
}
.user-action-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

/* Sidebar Navigation Items */
.sidebar-heading {
  margin-bottom: 10px;
  padding-left: 6px;
}
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: all 0.2s ease;
  width: 100%;
}
.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}
.nav-item.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}
.nav-badge {
  margin-left: auto;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.18);
  color: var(--income-green);
  font-weight: 700;
}

/* Quick Add Banner in Sidebar */
.quick-add-card {
  background: linear-gradient(145deg, #162032, #121824);
  border: 1px solid var(--border-line);
  padding: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.quick-add-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent-blue);
  margin-bottom: 6px;
}
.quick-add-card p {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 4px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.online {
  background: var(--income-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Main Content Area */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 60px;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

/* Mobile Header & Bottom Nav (Hidden on Desktop) */
.mobile-header, .mobile-bottom-nav, .mobile-sidebar-overlay, .sidebar-close-btn {
  display: none;
}

/* View Pages */
.view-page {
  animation: fadeIn 0.3s ease both;
  width: 100%;
}
.view-page.is-hidden {
  display: none !important;
}

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

/* Page Header Layout */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}
.page-header h1 {
  font-size: clamp(22px, 3vw, 34px);
  margin-top: 4px;
  line-height: 1.2;
}
.header-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  align-items: center;
}

.account-switcher-header {
  min-width: 44px;
}

/* Buttons System */
.primary-button, .secondary-button, .danger-button, .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
  white-space: nowrap;
  min-height: 44px;
}
.full-width {
  width: 100%;
}
.primary-button {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-blue));
  color: #fff;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
}
.primary-button:hover {
  background: linear-gradient(135deg, var(--accent-primary-hover), #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

.secondary-button {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  color: var(--text-main);
}
.secondary-button:hover {
  background: var(--bg-card-hover);
  border-color: #2b3b54;
  color: #fff;
}

.danger-button {
  background: var(--expense-rose);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.danger-button:hover {
  background: #dc2626;
}

.ghost-button {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
}
.ghost-button:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.icon-only {
  padding: 10px;
  min-width: 44px;
}

.text-link-btn {
  background: transparent;
  border: none;
  color: var(--accent-blue);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.text-link-btn:hover {
  color: #60a5fa;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  width: 100%;
}
.stat-card:hover {
  border-color: #2b3c56;
  transform: translateY(-2px);
}
.stat-card-main {
  background: linear-gradient(135deg, #182338, #121926 80%);
  border-color: rgba(79, 70, 229, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-icon-wrap.blue { color: var(--accent-blue); background: var(--accent-blue-soft); }
.stat-icon-wrap.green { color: var(--income-green); background: var(--income-green-soft); }
.stat-icon-wrap.rose { color: var(--expense-rose); background: var(--expense-rose-soft); }
.stat-icon-wrap.amber { color: var(--amber-gold); background: var(--amber-gold-soft); }

.stat-value {
  font-family: var(--font-heading);
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 800;
  letter-spacing: -0.8px;
  margin: 14px 0 6px;
  display: block;
  word-break: break-word;
}
.green-text { color: var(--income-green); }
.rose-text { color: var(--expense-rose); }
.amber-text { color: var(--amber-gold); }
.blue-text { color: var(--accent-blue); }

.stat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.stat-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.18);
  color: var(--accent-blue);
}
.stat-caption {
  font-size: 11px;
  color: var(--text-muted);
}

/* Health Banner */
.health-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.03));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  width: 100%;
}
.banner-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--income-green-soft);
  color: var(--income-green);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.banner-text {
  flex: 1;
  min-width: 0;
}
.banner-text strong {
  display: block;
  font-size: 14px;
  color: var(--text-main);
}
.banner-text p {
  font-size: 12px;
  color: var(--text-muted);
}
.banner-btn {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--income-green);
  color: var(--income-green);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.banner-btn:hover {
  background: var(--income-green);
  color: #fff;
}

/* Dashboard Panels Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(400px, 1.4fr);
  gap: 20px;
  width: 100%;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.panel-tag {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-line);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Donut Chart Visual */
.category-chart-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
  width: 100%;
}
.donut-chart-container {
  width: 170px;
  height: 170px;
  position: relative;
  flex-shrink: 0;
}
.donut-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #1f2c3f;
  display: grid;
  place-items: center;
  transition: background 0.4s ease;
}
.donut-center {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}
.donut-label {
  font-size: 10px;
  color: var(--text-muted);
}
.donut-center strong {
  font-family: var(--font-heading);
  font-size: 13px;
  margin-top: 2px;
}

.category-legend-list {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  min-width: 0;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-name {
  color: var(--text-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-val {
  font-weight: 600;
  color: var(--text-main);
  flex-shrink: 0;
}

/* Empty Placeholder States */
.empty-placeholder {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.empty-placeholder [data-icon] {
  width: 36px;
  height: 36px;
  color: var(--text-dim);
}

/* Transaction List Items */
.transaction-list, .tx-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  transition: background 0.2s;
  width: 100%;
}
.tx-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.tx-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.tx-icon-badge.income { color: var(--income-green); background: var(--income-green-soft); }
.tx-icon-badge.expense { color: var(--expense-rose); background: var(--expense-rose-soft); }

.tx-details {
  min-width: 0;
  flex: 1;
}
.tx-desc {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.tx-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.tx-amount {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.tx-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  transition: color 0.2s;
}
.tx-delete-btn:hover {
  color: var(--expense-rose);
  background: rgba(239, 68, 68, 0.1);
}

/* Toolbar & Filters Card (Transactions Page) */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  width: 100%;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  flex: 1;
  max-width: 420px;
  color: var(--text-muted);
  min-height: 44px;
}
.search-input-wrap input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  width: 100%;
}
.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Debts search and filter toolbar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 18px;
}
.filter-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.filter-search-wrap:focus-within {
  border-color: var(--border-focus);
  background: #172235;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}
.filter-search-wrap .search-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--accent-blue);
}
.filter-search-wrap .search-icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
}
.filter-search-wrap input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font: 13px var(--font-body);
}
.filter-search-wrap input::placeholder {
  color: var(--text-dim);
  opacity: 1;
}
.filter-search-wrap input:focus::placeholder {
  color: var(--text-muted);
}

/* Custom Select Styling */
.custom-select-wrap select {
  background: var(--bg-input);
  border: 1px solid var(--border-line);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  min-height: 44px;
}
.custom-select-wrap select:focus {
  border-color: var(--border-focus);
}

.tx-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 0 4px;
  flex-wrap: wrap;
  gap: 8px;
}

/* Two Column Layout (Budgets & Goals) */
.two-column-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
}
.section-title-wrap {
  margin-bottom: 16px;
}
.section-title-wrap h2 {
  font-size: 18px;
}
.section-title-wrap p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Budget Card Items */
.budget-card-list, .goal-card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}
.budget-card, .goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  width: 100%;
}
.budget-card-header, .goal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.budget-category-title, .goal-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
}
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: #1e2a3c;
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease, background-color 0.4s ease;
}
.progress-bar-fill.normal { background: var(--income-green); }
.progress-bar-fill.warning { background: var(--amber-gold); }
.progress-bar-fill.exceeded { background: var(--expense-rose); }

.budget-stats-row, .goal-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  gap: 8px;
}
.budget-percent-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.budget-percent-badge.normal { background: var(--income-green-soft); color: var(--income-green); }
.budget-percent-badge.warning { background: var(--amber-gold-soft); color: var(--amber-gold); }
.budget-percent-badge.exceeded { background: var(--expense-rose-soft); color: var(--expense-rose); }

.goal-action-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* AI Chat Page Layout */
.chat-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.chat-assistant-info {
  display: flex;
  align-items: center;
  gap: 14px;
}
.assistant-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-blue));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  flex-shrink: 0;
}
.assistant-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.active-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--income-green-soft);
  color: var(--income-green);
}

.chat-main-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  height: calc(100vh - 220px);
  min-height: 520px;
  width: 100%;
}
.chat-container-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
  flex: 1;
  min-height: 400px;
  min-width: 0;
}
.chat-messages-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat-bubble-row {
  display: flex;
  gap: 12px;
  max-width: 85%;
}
.chat-bubble-row.user {
  margin-left: auto;
  flex-direction: row-reverse;
}
.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.chat-bubble-row.assistant .msg-avatar { background: var(--accent-blue-soft); color: var(--accent-blue); }
.chat-bubble-row.user .msg-avatar { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }

.msg-body {
  display: flex;
  flex-direction: column;
}
.msg-bubble {
  background: #182334;
  border: 1px solid var(--border-line);
  padding: 12px 16px;
  border-radius: 4px 14px 14px 14px;
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
  border-radius: 14px 4px 14px 14px;
  border: none;
}
.msg-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}
.chat-bubble-row.user .msg-time {
  text-align: right;
}

.chat-input-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #0e1420;
  border-top: 1px solid var(--border-line);
}
.chat-input-form input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  outline: none;
  min-height: 44px;
}
.chat-input-form input:focus {
  border-color: var(--border-focus);
}
.send-message-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.send-message-btn:hover {
  background: var(--accent-primary-hover);
}

.chat-disclaimer-text {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 0 10px;
}

/* Aliases for new class names */
.chat-messages-container {
  flex: 1;
  min-height: 0;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #0e1420;
  border-top: 1px solid var(--border-line);
  flex: 0 0 auto;
}
.chat-input-bar input {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  outline: none;
  min-height: 44px;
}
.chat-input-bar input:focus {
  border-color: var(--border-focus);
}
.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.chat-send-btn:hover {
  background: var(--accent-primary-hover);
}
.chat-input-wrapper {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-line);
}

/* Prompt Sidebar Card */
.prompt-sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.prompt-sidebar-card h3 {
  font-size: 15px;
  margin: 4px 0 16px;
}
.prompt-chips-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prompt-chip-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
  transition: all 0.2s;
}
.prompt-chip-btn:hover {
  background: var(--accent-blue-soft);
  border-color: var(--accent-blue);
  color: var(--text-main);
}
.chip-icon {
  color: var(--accent-blue);
  margin-top: 1px;
}

/* Analytics & Health Scorecard */
.health-scorecard {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 24px;
  width: 100%;
}
.score-circle-wrap {
  width: 110px;
  height: 110px;
  position: relative;
  flex-shrink: 0;
}
.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.score-bg {
  fill: none;
  stroke: #1e2a3c;
  stroke-width: 8;
}
.score-progress {
  fill: none;
  stroke: var(--income-green);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}
.score-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.score-center-text strong {
  font-family: var(--font-heading);
  font-size: 24px;
  display: block;
  line-height: 1;
}
.score-center-text span {
  font-size: 9px;
  color: var(--text-muted);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  width: 100%;
}
.cashflow-visual-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 10px;
  width: 100%;
}
.cashflow-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.cashflow-label {
  width: 100px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cashflow-bar-track {
  flex: 1;
  height: 12px;
  background: #1e2a3c;
  border-radius: 6px;
  overflow: hidden;
}
.cashflow-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}
.cashflow-bar-fill.green { background: var(--income-green); }
.cashflow-bar-fill.rose { background: var(--expense-rose); }
.cashflow-bar-fill.blue { background: var(--accent-blue); }
.cashflow-val {
  width: 110px;
  text-align: right;
  font-family: var(--font-heading);
  font-size: 13px;
  flex-shrink: 0;
}

.backup-actions-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--text-muted);
  width: 100%;
}

/* Standalone Auth Pages (`/login`, `/register`) */
.auth-page-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}
.auth-page-wrapper {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.auth-page-header {
  text-align: center;
}
.auth-page-card {
  width: 100%;
}
.auth-footer-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Bot connection center */
.bot-security-banner {
  margin: 4px 0 26px;
}
.bot-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr);
  gap: 20px;
}
.bot-list-header {
  margin-bottom: 14px;
}
.bot-session-list {
  display: grid;
  gap: 14px;
}
.bot-session-card,
.bot-guide-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.bot-session-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bot-provider-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  font-size: 10px;
  font-weight: 800;
}
.bot-provider-mark.whatsapp { background: linear-gradient(135deg, #16a085, #0b8067); }
.bot-provider-mark.telegram { background: linear-gradient(135deg, #329bd6, #1475ad); }
.bot-session-title {
  min-width: 0;
  flex: 1;
}
.bot-session-title h3 {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bot-session-title span {
  color: var(--text-muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}
.bot-session-title code,
.bot-identifiers strong {
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}
.bot-status {
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 8px;
  white-space: nowrap;
}
.bot-status i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  background: currentColor;
}
.bot-status-connected { color: #34d399; background: rgba(16,185,129,.12); }
.bot-status-pending { color: #fbbf24; background: rgba(245,158,11,.12); }
.bot-status-error { color: #fb7185; background: rgba(239,68,68,.12); }
.bot-status-stopped { color: #94a3b8; background: rgba(148,163,184,.12); }

/* Stop / Start buttons */
.btn-stop-bot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid rgba(251,191,36,.45);
  background: rgba(251,191,36,.1);
  color: #fbbf24;
  transition: all 0.2s ease;
  min-height: 44px;
  white-space: nowrap;
}
.btn-stop-bot:hover {
  background: rgba(251,191,36,.22);
  border-color: #fbbf24;
  color: #fff;
  transform: translateY(-1px);
}

.btn-start-bot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 0 18px rgba(16,185,129,.45), 0 4px 14px rgba(16,185,129,.3);
  animation: start-pulse 2s ease-in-out infinite;
  transition: all 0.2s ease;
  min-height: 44px;
  white-space: nowrap;
}
.btn-start-bot:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-2px);
  box-shadow: 0 0 28px rgba(16,185,129,.6), 0 6px 20px rgba(16,185,129,.45);
}
.btn-start-bot:disabled {
  opacity: 0.6;
  animation: none;
  cursor: not-allowed;
}
@keyframes start-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(16,185,129,.45), 0 4px 14px rgba(16,185,129,.3); }
  50% { box-shadow: 0 0 32px rgba(16,185,129,.75), 0 4px 18px rgba(16,185,129,.55); }
}
.bot-identifiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-line);
}
.bot-identifiers div {
  min-width: 0;
}
.bot-identifiers span {
  display: block;
  color: var(--text-dim);
  font-size: 10px;
  margin-bottom: 4px;
}
.bot-identifiers strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bot-qr-wrap {
  margin: 18px auto 4px;
  text-align: center;
}
.bot-qr-wrap img {
  width: 220px;
  height: 220px;
  background: white;
  border-radius: 12px;
  padding: 8px;
}
.bot-qr-wrap p,
.pairing-code-wrap p,
.form-help {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 8px;
}
.pairing-code-wrap {
  margin-top: 18px;
  padding: 16px;
  background: rgba(79,70,229,.10);
  border: 1px solid rgba(99,102,241,.32);
  border-radius: 12px;
  text-align: center;
}
.pairing-code-wrap span {
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 1.5px;
}
.pairing-code-wrap strong {
  color: #a5b4fc;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 25px;
  letter-spacing: 5px;
  margin-top: 4px;
}
.bot-error-text {
  color: #fda4af;
  background: rgba(239,68,68,.08);
  border-radius: 8px;
  font-size: 12px;
  margin-top: 14px;
  padding: 10px;
}
.bot-session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.bot-session-actions button {
  font-size: 11px;
  padding: 9px 11px;
}
.bot-guide-panel h2 {
  font-size: 18px;
  margin: 6px 0 22px;
}
.bot-guide-step {
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border-line);
  padding: 15px 0;
}
.bot-guide-step span {
  color: #818cf8;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
}
.bot-guide-step p {
  color: var(--text-muted);
  font-size: 12px;
}
.bot-form-card {
  max-width: 540px;
}
@media (max-width: 900px) {
  .bot-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .bot-session-top { align-items: flex-start; flex-wrap: wrap; }
  .bot-status { margin-left: 54px; }
  .bot-identifiers { grid-template-columns: 1fr; }
}

/* Platform Separated Layout */
.bot-columns-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 1024px) {
  .bot-columns-grid {
    grid-template-columns: 1fr;
  }
}
.platform-column-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.platform-column-card.whatsapp-column {
  border-top: 3px solid #10b981;
}
.platform-column-card.telegram-column {
  border-top: 3px solid #3b82f6;
}
.platform-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-line);
}
.platform-column-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.platform-column-title h2 {
  font-size: 17px;
  font-weight: 700;
}
.platform-column-title p {
  font-size: 11px;
  color: var(--text-muted);
}
.platform-column-action {
  font-size: 12px;
  padding: 8px 14px;
}

/* Method selector cards in modal */
.method-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 6px;
}
@media (max-width: 500px) {
  .method-selector-grid {
    grid-template-columns: 1fr;
  }
}
.method-card-radio {
  position: relative;
  border: 1.5px solid var(--border-line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.method-card-radio:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}
.method-card-radio input[type="radio"] {
  position: absolute;
  top: 14px;
  right: 14px;
  accent-color: #10b981;
}
.method-card-radio.is-selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}
.method-card-icon {
  font-size: 20px;
  margin-bottom: 6px;
}
.method-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}
.method-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Enhanced Pairing Code Display */
.pairing-code-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.06));
  border: 1.5px dashed rgba(16, 185, 129, 0.4);
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
  text-align: center;
}
.pairing-code-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #34d399;
  text-transform: uppercase;
}
.pairing-code-flex {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.pairing-code-digits {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 5px;
  color: #6ee7b7;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 18px;
  border-radius: 10px;
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.copy-code-btn {
  background: #10b981;
  color: #022c22;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.copy-code-btn:hover {
  background: #34d399;
  transform: translateY(-1px);
}
.pairing-instructions-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
  text-align: left;
}
.pairing-instructions-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pairing-instructions-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.pairing-instructions-list li {
  margin-bottom: 4px;
}
.pairing-instructions-list li strong {
  color: #e2e8f0;
}
.text-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
}
.text-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   CUSTOM MODALS DIALOGS SYSTEM
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 14, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fadeIn 0.25s ease both;
  overflow-y: auto;
}
.modal-overlay.is-hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
  margin: auto;
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-line);
}
.modal-header h2 {
  font-size: 18px;
}
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  min-width: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
}
.modal-close-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

/* Floating background music player */
.music-player {
  position: fixed;
  right: 24px;
  bottom: 82px;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 10px;
}
.music-player-toggle {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: 999px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(30, 41, 59, 0.38);
}
.music-player-toggle:hover {
  filter: brightness(1.08);
}
.music-player-panel {
  display: none;
  width: min(360px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid rgba(99, 102, 241, 0.32);
  border-radius: 18px;
  background: rgba(14, 20, 32, 0.96);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.42);
}
.music-player.is-open .music-player-panel {
  display: block;
  animation: scaleUp 0.2s ease both;
}
.music-player-header,
.music-player-search,
.music-player-track,
.music-player-controls {
  display: flex;
  align-items: center;
}
.music-player-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.music-player-header strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}
.music-player-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.music-player-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}
.music-player-search {
  gap: 8px;
}
.music-player-search input {
  min-width: 0;
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-line);
  border-radius: 9px;
  background: var(--bg-input);
  color: var(--text-main);
  outline: none;
}
.music-player-search input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
.music-player-search .icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
}
.music-player-track {
  gap: 10px;
  min-width: 0;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--border-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}
.music-player-art {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.7), rgba(14, 165, 233, 0.55));
  background-size: cover;
  background-position: center;
  color: #fff;
}
.music-player-art [data-icon] {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
.music-player-meta {
  min-width: 0;
  flex: 1;
}
.music-player-meta strong,
.music-player-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.music-player-meta strong {
  color: var(--text-main);
  font-size: 12px;
}
.music-player-meta span,
.music-player-status {
  color: var(--text-muted);
  font-size: 11px;
}
.music-player-track .icon-button {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}
.music-player-controls {
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
}
.music-player-controls input {
  width: 100%;
  accent-color: var(--accent-primary-hover);
}
.music-player-status {
  min-height: 16px;
  margin: 10px 2px 0;
}
.music-player-status.loading {
  color: var(--amber-gold);
}
.music-player-status.success {
  color: var(--income-green);
}
.music-player-status.error {
  color: var(--expense-rose);
}

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

.account-switcher-modal {
  max-width: 430px;
}
.account-switcher-body {
  gap: 14px;
}
.account-switcher-description {
  color: var(--text-muted);
  font-size: 12px;
}
.account-switcher-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 270px;
  overflow-y: auto;
}
.account-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.account-option:hover,
.account-option.is-active {
  border-color: rgba(99, 102, 241, 0.75);
  background: rgba(79, 70, 229, 0.13);
}
.account-option-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}
.account-option-copy {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
}
.account-option-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-option-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}
.account-option-check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--income-green);
  opacity: 0;
}
.account-option-check.is-visible {
  opacity: 1;
}
.account-switcher-empty {
  padding: 18px 12px;
  border: 1px dashed var(--border-line);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.account-add-toggle {
  justify-content: flex-start;
  width: 100%;
  border: 1px dashed var(--border-line);
}
.account-add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}
.account-add-form.is-hidden {
  display: none;
}
.account-add-form .form-group {
  gap: 6px;
}
.account-add-form label span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 400;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.form-group input, .form-group select {
  background: var(--bg-input);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  min-height: 44px;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--border-focus);
}

/* Keep native form controls visually consistent with the app.
   The browser still provides keyboard/accessibility behavior, but no
   control falls back to the bright default white select appearance. */
select,
.filter-select,
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 38px !important;
}
select:hover,
.filter-select:hover,
.form-group select:hover {
  border-color: rgba(148, 163, 184, 0.48);
}
select option {
  background: #151e2d;
  color: var(--text-main);
}

.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}
.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px 8px 14px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-main);
  font: 13px var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.custom-select-trigger:hover,
.custom-select.is-open .custom-select-trigger {
  border-color: var(--border-focus);
  background: #172235;
}
.custom-select-trigger:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.custom-select-chevron {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--text-muted);
  font-size: 15px;
  transition: transform 0.2s ease;
}
.custom-select.is-open .custom-select-chevron {
  transform: rotate(180deg);
}
.custom-select-menu {
  position: absolute;
  z-index: 120;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  display: grid;
  gap: 3px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(99, 102, 241, 0.38);
  border-radius: var(--radius-md);
  background: #151e2d;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.38);
}
.custom-select-menu[hidden] {
  display: none;
}
.custom-select-option {
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: 12px var(--font-body);
  text-align: left;
  cursor: pointer;
}
.custom-select-option:hover,
.custom-select-option:focus-visible,
.custom-select-option.is-selected {
  outline: none;
  background: rgba(99, 102, 241, 0.16);
  color: var(--text-main);
}
.filter-controls .custom-select {
  width: auto;
  min-width: 156px;
}
.filter-controls .custom-select-trigger {
  min-width: 156px;
}

/* Password show/hide toggle */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-input-wrapper input {
  flex: 1;
  padding-right: 44px;
}
.password-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s;
}
.password-toggle-btn:hover {
  color: var(--text-main);
}
.password-toggle-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.preset-chips-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.preset-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-line);
  color: var(--text-muted);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 32px;
}
.preset-chip:hover {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.type-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-line);
}
.type-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 40px;
}
.type-toggle-btn.active-expense {
  background: var(--expense-rose);
  color: #fff;
}
.type-toggle-btn.active-income {
  background: var(--income-green);
  color: #fff;
}

/* ==========================================================================
   CUSTOM TOAST NOTIFICATION SYSTEM
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-msg {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  background: #182232;
  border: 1px solid var(--border-line);
  border-left: 4px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-main);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast-msg.success { border-left-color: var(--income-green); }
.toast-msg.error { border-left-color: var(--expense-rose); }
.toast-msg.warning { border-left-color: var(--amber-gold); }

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

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS (MOBILE & TABLET OVERHAUL)
   ========================================================================== */

/* Hide Sidebar Close Button on Desktop */
.sidebar-close-btn {
  display: none;
}

/* Mobile Sidebar Overlay Backdrop */
.mobile-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 14, 0.75);
  backdrop-filter: blur(6px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.mobile-sidebar-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 1024px) {
  .music-player {
    right: 14px;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .main-content {
    padding: 32px 28px 50px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .two-column-layout {
    grid-template-columns: 1fr;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* Mobile Slide-Out Sidebar Drawer */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
    overflow-y: auto;
    background-color: #0c121d;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-close-btn {
    display: grid;
    place-items: center;
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-line);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
  }
  .sidebar-close-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
  }

  /* Main Container Padding Adjustment */
  .main-content {
    padding: 76px 14px 84px;
  }

  /* Show Mobile Header */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(12, 18, 29, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-line);
    padding: 0 14px;
    z-index: 50;
  }
  .mobile-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .mobile-actions {
    display: flex;
    gap: 8px;
  }
  .icon-button {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    color: var(--text-main);
    display: grid;
    place-items: center;
    cursor: pointer;
    text-decoration: none;
  }

  /* Show Mobile Bottom Navigation */
  .mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(12, 18, 29, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-line);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    flex: 1;
    height: 100%;
  }
  .mobile-nav-item.is-active {
    color: var(--accent-blue);
  }
  .mobile-nav-item [data-icon] {
    width: 20px;
    height: 20px;
  }

  /* Page Header Mobile Adjustments */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
  }
  .header-actions {
    width: 100%;
    flex-direction: column;
    gap: 10px;
  }
  .header-actions button, .header-actions a {
    width: 100%;
    justify-content: center;
  }

  /* Stats Grid Single / Two Column Mobile */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card-main {
    grid-column: 1 / -1;
  }
  .stat-card {
    padding: 14px;
    min-height: 110px;
  }
  .stat-value {
    font-size: 18px;
    margin: 8px 0 4px;
  }

  /* Health Banner Mobile */
  .health-banner {
    flex-direction: column;
    text-align: center;
    padding: 16px;
    gap: 12px;
  }
  .banner-btn {
    width: 100%;
    text-align: center;
  }

  /* Donut Chart Legend Mobile */
  .category-legend-list {
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
  }

  /* Toolbar Mobile */
  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }
  .search-input-wrap {
    max-width: none;
    width: 100%;
  }
  .filter-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    width: 100%;
    gap: 8px;
  }
  .custom-select-wrap select {
    width: 100%;
  }

  /* Chat View Mobile Height */
  .chat-page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .chat-main-grid {
    grid-template-columns: 1fr;
    height: calc(100vh - 210px);
    min-height: 420px;
  }
  .prompt-sidebar-card {
    display: none;
  }
  .chat-bubble-row {
    max-width: 92%;
  }

  /* Health Scorecard Mobile */
  .health-scorecard {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
    gap: 16px;
  }

  .cashflow-bar-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .cashflow-label {
    width: 100%;
  }
  .cashflow-val {
    width: 100%;
    text-align: left;
  }

  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 76px;
  }
  .toast-msg {
    max-width: none;
    width: 100%;
  }
}

/* Extra Small Smartphones (<480px) */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .category-legend-list {
    grid-template-columns: 1fr;
  }
  .filter-controls {
    grid-template-columns: 1fr;
  }
  .modal-card {
    border-radius: var(--radius-lg);
  }
  .modal-body {
    padding: 16px;
  }
  .modal-header, .modal-footer {
    padding: 14px 16px;
  }
}

/* ==========================================================================
   Final responsive layout layer
   Keeps every page usable from small phones to wide desktop screens.
   ========================================================================== */

html {
  overflow-x: hidden;
}

body,
button,
input,
select,
textarea {
  max-width: 100%;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell,
.main-content,
.view-page,
.panel,
.stat-card,
.health-banner,
.toolbar-card,
.chat-main-grid,
.chat-container-card,
.analytics-grid,
.two-column-layout {
  min-width: 0;
}

.main-content {
  overflow: hidden;
}

.page-header > div:first-child,
.panel-header > div:first-child,
.chat-assistant-info > div,
.score-info-text,
.banner-text {
  min-width: 0;
}

.page-header h1,
.chat-page-header h1,
.panel h2,
.section-title-wrap h2,
.score-info-text h2 {
  overflow-wrap: anywhere;
}

.page-subtitle,
.banner-text p,
.score-info-text p,
.backup-actions-wrap p,
.empty-placeholder p {
  overflow-wrap: anywhere;
}

.stat-value {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.panel-header,
.chat-page-header,
.health-banner,
.toolbar-card,
.tx-summary-bar {
  flex-wrap: wrap;
}

.header-actions {
  flex-wrap: wrap;
}

.header-actions .primary-button,
.header-actions .secondary-button {
  min-width: 0;
}

.category-chart-wrap,
.category-legend-list,
.transaction-list,
.tx-card-list,
.budget-card-list,
.goal-card-list,
.backup-actions-wrap,
.prompt-chips-list {
  min-width: 0;
}

.donut-center strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.tx-desc {
  overflow-wrap: anywhere;
}

.tx-meta {
  overflow-wrap: anywhere;
}

.tx-right {
  max-width: 44%;
}

.tx-amount {
  overflow-wrap: anywhere;
  text-align: right;
}

.backup-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-btn-row > * {
  min-width: 0;
}

.auth-container {
  padding: 22px 24px 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 11px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border-line);
}

@media (max-width: 1200px) {
  .sidebar {
    width: 232px;
  }

  .main-content {
    padding: 32px 28px 50px;
  }

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

  .stat-card-main {
    grid-column: 1 / -1;
  }

  .dashboard-grid,
  .analytics-grid,
  .two-column-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat-main-grid {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
}

@media (max-width: 768px) {
  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .sidebar {
    width: min(86vw, 320px);
    max-width: 320px;
    min-height: 100dvh;
    height: 100dvh;
    padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
  }

  .main-content {
    width: 100%;
    max-width: none;
    padding: calc(60px + 22px) 14px calc(78px + env(safe-area-inset-bottom));
  }

  .mobile-header {
    height: 60px;
    padding: 0 14px;
    padding-top: env(safe-area-inset-top);
  }

  .mobile-header-left,
  .mobile-actions {
    min-width: 0;
  }

  .mobile-header .brand {
    min-width: 0;
  }

  .mobile-header .brand-name {
    font-size: 16px;
  }

  .mobile-actions {
    flex-shrink: 0;
  }

  .mobile-bottom-nav {
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-nav-item {
    min-width: 0;
    padding: 5px 2px 4px;
  }

  .mobile-nav-item span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-header {
    align-items: stretch;
    gap: 14px;
    margin-bottom: 22px;
  }

  .page-header h1 {
    font-size: clamp(24px, 7vw, 32px);
    line-height: 1.16;
  }

  .page-subtitle {
    font-size: 12px;
    line-height: 1.55;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .header-actions > * {
    width: 100%;
    min-width: 0;
    white-space: normal;
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    min-height: 122px;
    padding: 15px;
    border-radius: var(--radius-md);
  }

  .stat-card-main {
    grid-column: 1 / -1;
  }

  .stat-label {
    font-size: 11px;
    line-height: 1.35;
  }

  .stat-value {
    font-size: clamp(17px, 5vw, 23px);
    letter-spacing: -0.6px;
    margin: 12px 0 6px;
  }

  .stat-caption {
    font-size: 10px;
    line-height: 1.35;
  }

  .stat-badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .health-banner {
    align-items: flex-start;
    padding: 15px;
    gap: 12px;
    margin-bottom: 16px;
  }

  .banner-icon {
    width: 36px;
    height: 36px;
  }

  .banner-text {
    flex: 1 1 calc(100% - 48px);
  }

  .banner-text strong {
    font-size: 13px;
  }

  .banner-text p {
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.45;
  }

  .banner-btn {
    width: 100%;
    margin-top: 2px;
    text-align: center;
  }

  .panel {
    padding: 17px 15px;
    border-radius: var(--radius-md);
  }

  .panel-header {
    align-items: flex-start;
    margin-bottom: 16px;
  }

  .panel-header h2,
  .section-title-wrap h2 {
    font-size: 16px;
    line-height: 1.3;
  }

  .panel-tag {
    font-size: 10px;
    padding: 4px 8px;
  }

  .donut-chart-container {
    width: min(46vw, 170px);
    height: min(46vw, 170px);
  }

  .donut-center {
    width: 68%;
    height: 68%;
    padding: 8px;
  }

  .donut-center strong {
    font-size: clamp(11px, 3.2vw, 14px);
  }

  .category-legend-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
  }

  .legend-item {
    font-size: 11px;
  }

  .tx-item {
    align-items: flex-start;
    padding: 11px 10px;
    gap: 8px;
  }

  .tx-left {
    gap: 9px;
  }

  .tx-icon-badge {
    width: 32px;
    height: 32px;
  }

  .tx-desc {
    font-size: 12px;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .tx-meta {
    font-size: 10px;
    line-height: 1.35;
  }

  .tx-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    max-width: 38%;
  }

  .tx-amount {
    font-size: 11px;
    line-height: 1.3;
  }

  .tx-delete-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 6px;
  }

  .toolbar-card {
    align-items: stretch;
    padding: 12px;
    gap: 10px;
  }

  .search-input-wrap {
    width: 100%;
    max-width: none;
  }

  .filter-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    width: 100%;
    gap: 8px;
  }

  .custom-select-wrap,
  .custom-select-wrap select,
  .filter-controls .icon-only {
    width: 100%;
    min-width: 0;
  }

  .custom-select-wrap select {
    padding-left: 10px;
    padding-right: 28px;
    font-size: 11px;
  }

  .tx-summary-bar {
    align-items: flex-start;
    flex-direction: column;
    padding: 0 2px;
    font-size: 11px;
  }

  .two-column-layout {
    gap: 24px;
  }

  .section-title-wrap {
    margin-bottom: 12px;
  }

  .budget-card,
  .goal-card {
    padding: 15px;
    border-radius: var(--radius-md);
  }

  .budget-card-header,
  .goal-card-header,
  .budget-stats-row,
  .goal-stats-row,
  .goal-action-row {
    flex-wrap: wrap;
  }

  .budget-card-header,
  .goal-card-header {
    align-items: flex-start;
  }

  .budget-stats-row,
  .goal-stats-row {
    font-size: 11px;
  }

  .goal-action-row {
    align-items: flex-start;
  }

  .goal-action-row .secondary-button {
    width: 100%;
  }

  .chat-page-header {
    align-items: stretch;
    gap: 14px;
    margin-bottom: 16px;
  }

  .chat-assistant-info {
    align-items: flex-start;
    gap: 10px;
  }

  .assistant-avatar {
    width: 40px;
    height: 40px;
  }

  .assistant-status-row {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 5px;
  }

  .chat-page-header h1 {
    font-size: clamp(22px, 7vw, 30px);
    line-height: 1.15;
    margin-top: 4px;
  }

  .chat-page-header .ghost-button {
    align-self: flex-start;
  }

  .chat-main-grid {
    display: block;
    height: auto;
    min-height: 0;
  }

  .chat-container-card {
    min-height: calc(100dvh - 174px - env(safe-area-inset-bottom));
    height: calc(100dvh - 174px - env(safe-area-inset-bottom));
    border-radius: var(--radius-md);
  }

  .chat-messages-area {
    min-height: 0;
    padding: 16px 12px;
    gap: 14px;
  }

  .chat-bubble-row {
    max-width: 92%;
    gap: 8px;
  }

  .msg-avatar {
    width: 28px;
    height: 28px;
  }

  .msg-bubble {
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.55;
  }

  .chat-input-form {
    padding: 10px;
    gap: 8px;
  }

  .chat-input-form input {
    min-width: 0;
    padding: 10px 12px;
    font-size: 12px;
  }

  .send-message-btn {
    width: 42px;
    height: 42px;
  }

  .chat-disclaimer-text {
    padding: 3px 10px 9px;
    font-size: 9px;
    line-height: 1.35;
  }

  .prompt-sidebar-card {
    display: none;
  }

  .health-scorecard {
    align-items: flex-start;
    padding: 18px 15px;
    gap: 14px;
    margin-bottom: 16px;
  }

  .score-circle-wrap {
    align-self: center;
    width: 96px;
    height: 96px;
  }

  .score-info-text h2 {
    font-size: 17px;
    line-height: 1.3;
    margin: 5px 0;
  }

  .score-info-text p {
    font-size: 11px;
    line-height: 1.5;
  }

  .cashflow-bar-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 7px 10px;
  }

  .cashflow-label,
  .cashflow-val {
    width: auto;
  }

  .cashflow-val {
    grid-column: 2;
    text-align: right;
    font-size: 11px;
  }

  .cashflow-bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .backup-actions-wrap > div[style*="display: flex"] {
    flex-wrap: wrap;
  }

  .backup-actions-wrap > div[style*="display: flex"] > * {
    flex: 1 1 180px;
    min-width: 0;
  }

  .auth-page-body {
    display: block;
    min-height: 100dvh;
    padding: 24px 14px calc(24px + env(safe-area-inset-bottom));
  }

  .auth-page-wrapper {
    max-width: 100%;
    gap: 18px;
  }

  .auth-page-card {
    border-radius: var(--radius-lg);
  }

  .auth-page-card .modal-header {
    padding: 16px;
  }

  .auth-page-card .modal-header h2 {
    font-size: 16px;
  }

  .auth-container {
    padding: 18px 16px 20px;
  }

  .modal-overlay {
    align-items: flex-start;
    padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  }

  .modal-card {
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    border-radius: var(--radius-lg);
  }

  .modal-header,
  .modal-footer {
    padding: 14px 16px;
  }

  .modal-header h2 {
    max-width: calc(100% - 42px);
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  .modal-body {
    padding: 16px;
    gap: 14px;
  }

  .modal-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-footer > * {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .toast-msg {
    min-width: 0;
    width: 100%;
    max-width: none;
    font-size: 12px;
  }
}

.confirm-dialog-card {
  max-width: 440px;
}
.confirm-dialog-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.confirm-dialog-heading h2 {
  margin: 0;
}
.confirm-dialog-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  color: var(--amber-gold);
  background: var(--amber-gold-soft);
}
.confirm-dialog-icon svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 420px) {
  .main-content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .mobile-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .mobile-header .brand-tag {
    display: none;
  }

  .mobile-actions {
    gap: 5px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .header-actions,
  .stats-grid,
  .category-legend-list {
    grid-template-columns: 1fr;
  }

  .stat-card-main {
    grid-column: auto;
  }

  .stat-card {
    min-height: 108px;
  }

  .header-actions > * {
    min-height: 42px;
  }

  .filter-controls {
    grid-template-columns: 1fr;
  }

  .filter-controls .icon-only {
    width: 100%;
  }

  .panel-header {
    flex-direction: column;
  }

  .panel-tag {
    align-self: flex-start;
  }

  .chat-container-card {
    min-height: calc(100dvh - 174px - env(safe-area-inset-bottom));
    height: calc(100dvh - 174px - env(safe-area-inset-bottom));
  }

  .cashflow-bar-row {
    grid-template-columns: 1fr auto;
  }
}

/* ==========================================================================
   Custom Background UI & Overlay System
   ========================================================================== */
body.has-custom-bg {
  background-image: var(--custom-bg-url) !important;
  background-size: cover !important;
  background-position: center !important;
  background-attachment: fixed !important;
  background-repeat: no-repeat !important;
  position: relative;
}

/* Semi-transparent dark overlay — lets photo show through while keeping text readable */
body.has-custom-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.18);
  z-index: 0;
  pointer-events: none;
}

body.has-custom-bg .app-shell {
  position: relative;
  z-index: 1;
  background-color: transparent !important;
  background: transparent !important;
}

/* Let the photo remain visible behind the glass UI on every page. */
body.has-custom-bg .sidebar,
body.has-custom-bg .main-content,
body.has-custom-bg .mobile-header {
  background: rgba(17, 24, 39, 0.64) !important;
}

body.has-custom-bg .main-content {
  background-color: transparent !important;
  background: transparent !important;
}

body.has-custom-bg .stat-card,
body.has-custom-bg .panel,
body.has-custom-bg .health-banner,
body.has-custom-bg .toolbar-card,
body.has-custom-bg .chat-container-card,
body.has-custom-bg .analytics-card,
body.has-custom-bg .two-column-layout > *,
body.has-custom-bg .bot-guide-panel,
body.has-custom-bg .quick-add-card {
  background: rgba(17, 24, 39, 0.58) !important;
}

.bg-preview-box {
  width: 100%;
  height: 140px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-line);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 10px;
  overflow: hidden;
  position: relative;
}

.bg-preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 23, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}

/* ==========================================================================
   Debts & Bills Page Component Styling
   ========================================================================== */
.debt-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  transition: all 0.2s ease;
}

.debt-item-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(79, 70, 229, 0.3);
}

.debt-item-card.is-paid {
  opacity: 0.65;
  background: rgba(18, 25, 38, 0.5);
}

.debt-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.debt-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.debt-icon-badge.payable {
  background: var(--expense-rose-soft);
  color: var(--expense-rose);
}

.debt-icon-badge.receivable {
  background: var(--income-green-soft);
  color: var(--income-green);
}

.debt-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.debt-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.debt-badge {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.debt-badge.payable {
  background: var(--expense-rose-soft);
  color: var(--expense-rose);
}

.debt-badge.receivable {
  background: var(--income-green-soft);
  color: var(--income-green);
}

.debt-badge.status-unpaid {
  background: var(--amber-gold-soft);
  color: var(--amber-gold);
}

.debt-badge.status-paid {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.debt-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.debt-amount-wrap {
  text-align: right;
}

.debt-amount {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-heading);
}

.debt-amount.payable {
  color: var(--expense-rose);
}

.debt-amount.receivable {
  color: var(--income-green);
}

.debt-due-tag {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.debt-due-tag.overdue {
  color: var(--expense-rose);
  font-weight: 700;
}

.debt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  .debt-item-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .debt-right {
    width: 100%;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px dashed var(--border-line);
  }

  .debt-amount-wrap {
    text-align: left;
  }
}