/* ============================================================
   FINTRACK — Design System
   Style bancaire moderne, mode clair, accents bleus
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
  /* Palette principale */
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-900: #1e3a8a;

  /* Neutres */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Sémantiques */
  --color-income:  #059669;
  --color-income-bg: #d1fae5;
  --color-expense: #dc2626;
  --color-expense-bg: #fee2e2;
  --color-savings: #7c3aed;
  --color-savings-bg: #ede9fe;
  --color-balance: #0284c7;
  --color-balance-bg: #e0f2fe;

  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;
  --color-danger: #dc2626;

  /* Budget couleurs */
  --budget-ok:      #059669;
  --budget-warn:    #d97706;
  --budget-danger:  #dc2626;

  /* Equilibrium ratios */
  --eq-needs: #f59e0b;
  --eq-wants: #3b82f6;
  --eq-savings: #10b981;

  /* Backgrounds */
  --bg-page:    #f4f6fb;
  --bg-card:    #ffffff;
  --bg-sidebar: #1e3a8a;
  --surface:    #ffffff;
  --text-primary: #1f2937;

  /* Borders */
  --border:     #e5e7eb;
  --border-focus: #3b82f6;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.08);

  /* Toast fixed background to prevent invisibility */
  --bg-toast:   #111827;

  /* Typography */
  --font: 'Inter', -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8rem;
  --fs-base: 0.9rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;

  /* Spacing & sizing */
  --header-h: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: .2s ease;
  --transition-slow: .35s ease;
}

:root[data-theme="dark"] {
  /* Palette principale adaptée pour le mode sombre */
  --blue-50:  rgba(37, 99, 235, 0.15);
  --blue-100: rgba(37, 99, 235, 0.25);
  --blue-200: rgba(37, 99, 235, 0.35);
  --blue-900: #60a5fa;

  /* Neutres inversés */
  --gray-50:  #1e293b;
  --gray-100: #334155;
  --gray-200: #475569;
  --gray-300: #64748b;
  --gray-400: #94a3b8;
  --gray-500: #cbd5e1;
  --gray-600: #e2e8f0;
  --gray-700: #f1f5f9;
  --gray-800: #f8fafc;
  --gray-900: #ffffff;

  /* Sémantiques */
  --color-income-bg: rgba(5, 150, 105, 0.15);
  --color-expense-bg: rgba(220, 38, 38, 0.15);
  --color-savings-bg: rgba(124, 58, 237, 0.15);
  --color-balance-bg: rgba(2, 132, 199, 0.15);
  --color-warning-bg: rgba(217, 119, 6, 0.15);

  /* Backgrounds */
  --bg-page:    #0f172a;
  --bg-card:    #1e293b;
  --bg-sidebar: #0f172a;
  --surface:    #1e293b;
  --text-primary: #ffffff;

  /* Borders */
  --border:     #334155;

  /* Shadows adaptés au sombre */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,.6), 0 2px 4px rgba(0,0,0,.3);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.7), 0 4px 8px rgba(0,0,0,.4);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   DESIGN SYSTEM UTILITIES & COMPONENTS
   ============================================================ */

/* Layout & Flexbox Utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; align-items: center; }
.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* Gaps & Margins */
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-15 { gap: 15px; }
.gap-16 { gap: 16px; }

.w-100 { width: 100%; }

.mb-4 { margin-bottom: 4px; }
.mb-5 { margin-bottom: 5px; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-15 { margin-bottom: 15px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mr-8 { margin-right: 8px; }
.ml-8 { margin-left: 8px; }
.mt-15 { margin-top: 15px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.pt-8 { padding-top: 8px; }
.pt-10 { padding-top: 10px; }
.pt-16 { padding-top: 16px; }
.pb-10 { padding-bottom: 10px; }
.p-12 { padding: 12px; }
.p-20 { padding: 20px; }
.pr-4 { padding-right: 4px; }

/* SVG icons inline */
.svg-icon-inline {
  margin-right: 4px;
  vertical-align: middle;
}

/* Typography Utilities */
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.fs-xs { font-size: var(--fs-xs); }
.fs-sm { font-size: var(--fs-sm); }
.fs-base { font-size: var(--fs-base); }
.fs-md { font-size: var(--fs-md); }
.fs-lg { font-size: var(--fs-lg); }
.fs-xl { font-size: var(--fs-xl); }

/* Form Component Standardizations */
.form-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;
}

.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--gray-600);
}

body[data-theme="dark"] .form-label {
  color: var(--gray-400);
}

.form-input-large, .form-select-large {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  background: var(--bg-card);
  color: var(--gray-800);
  outline: none;
  transition: border-color var(--transition);
}

.form-input-large:focus, .form-select-large:focus {
  border-color: var(--border-focus);
}

/* Global Search Component */
#global-search-container {
  position: relative;
  display: flex;
  align-items: center;
}

#global-search {
  padding: 6px 12px 6px 32px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: var(--fs-base);
  background: var(--gray-50);
  color: var(--gray-800);
  width: 160px;
  transition: width 0.2s ease;
}

#global-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

#global-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  max-height: 400px;
  overflow-y: auto;
}

/* Recurring KPI Icon adaptives */
.rec-kpi-icon.fixed-expense {
  background: var(--color-expense-bg);
  color: var(--color-expense);
}
.rec-kpi-icon.variable-expense {
  background: var(--color-balance-bg);
  color: var(--color-balance);
}
.rec-kpi-icon.total-expense {
  background: var(--color-income-bg);
  color: var(--color-income);
}
.rec-kpi-icon.count-badge {
  background: var(--color-savings-bg);
  color: var(--color-savings);
}

/* Button & Action Extensions */
.btn-pdf {
  margin-left: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  height: 36px;
}

.mapping-choice-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--blue-50);
}

/* Advisor Card components */
.advisor-card {
  margin-bottom: 24px;
}
.advisor-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.01em;
}
.advisor-card-subtitle {
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* Empty State / Hint component */
.empty-state-hint {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

/* Rule Pattern Preview */
.rule-pattern-preview {
  color: var(--blue-600);
}

/* Category Editor components */
.editor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.editor-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
}
.mobile-only-close {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
}

/* Backup and Restore Cards */
.backup-restore-card {
  background: rgba(37, 99, 235, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Simulator elements & Collapsible Card */
.simulator-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.collapse-icon {
  font-size: 1.2rem;
  transition: transform var(--transition);
}
.collapsible-content {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.simulator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
}
body[data-theme="dark"] .form-group label {
  color: var(--gray-400);
}
.simulator-grid input,
.simulator-grid select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg-page);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.simulator-grid input:focus,
.simulator-grid select:focus {
  border-color: var(--border-focus);
}
.simulator-grid button {
  height: 38px;
}
#btn-sim-apply {
  flex: 1;
  justify-content: center;
}
.form-group-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: auto;
}
.sim-results-banner {
  display: none;
  margin-top: 16px;
  padding: 12px;
  background: var(--color-balance-bg);
  border-left: 4px solid var(--color-balance);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--gray-800);
  font-weight: 500;
}
body[data-theme="dark"] .sim-results-banner {
  color: var(--gray-100);
}

/* Goals & Forms utilities */
.goals-list-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 4px;
}
.h-42 {
  height: 42px;
}
.h-38 {
  height: 38px;
}
.mt-8 {
  margin-top: 8px;
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.empty-state-text {
  margin: 0;
  color: var(--gray-500);
  font-size: 0.85rem;
  line-height: 1.5;
}
.hue-slider-custom {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}
.color-circle-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  transition: background 0.15s;
}
.form-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.integrated-merge-panel h4 {
  margin: 0 0 4px 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-800);
}
body[data-theme="dark"] .integrated-merge-panel h4 {
  color: var(--gray-200);
}
.integrated-merge-panel p {
  font-size: 0.72rem;
  color: var(--gray-500);
  margin: 0 0 10px 0;
  line-height: 1.4;
}
body[data-theme="dark"] .integrated-merge-panel p {
  color: var(--gray-400);
}
#btn-confirm-edit-cat {
  flex: 1;
  height: 38px;
}
#btn-delete-cat {
  height: 38px;
  padding: 0 12px;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.15);
}
#btn-confirm-merge-cat {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.15);
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
}
.rules-grid-wrapper {
  margin-top: 15px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 4px;
}
.backup-restore-card label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-800);
  margin-bottom: 6px;
  display: block;
}
body[data-theme="dark"] .backup-restore-card label {
  color: var(--gray-200);
}
.backup-restore-card p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 20px;
  line-height: 1.5;
}
body[data-theme="dark"] .backup-restore-card p {
  color: var(--gray-400);
}
#btn-confirm-advisor-config {
  padding: 10px 24px;
}
.edit-tx-summary {
  margin-bottom: 15px;
  padding: 10px;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 6px;
  font-size: 13px;
}
.form-group-checkbox input {
  margin-top: 3px;
}
.form-group-checkbox label {
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
}
body[data-theme="dark"] .form-group-checkbox label {
  color: var(--gray-400);
}
.mapping-choice-box label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}
.modal-body p {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 20px;
  line-height: 1.5;
}
/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
}

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

.brand-subtitle {
  font-size: .7rem;
  color: var(--gray-500);
  font-weight: 400;
}

/* Sidebar & Navigation */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 105;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-nav .nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  width: 100%;
}

.sidebar-nav .nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-nav .nav-btn.active {
  background: var(--blue-600);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}

.sidebar-nav #nav-more {
  display: none;
}

.sidebar-nav .nav-btn svg {
  opacity: .9;
  flex-shrink: 0;
  color: inherit;
}

.budget-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--color-danger);
  color: #ffffff;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-card);
}

.app-sidebar .budget-badge {
  border-color: var(--bg-sidebar);
}

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.data-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--gray-500);
  padding: 6px 12px;
  background: var(--gray-100);
  border-radius: 20px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gray-400);
  transition: background var(--transition);
}

.status-dot.loaded { background: var(--color-income); }

.btn-import {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: var(--blue-600);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}

.btn-import:hover {
  background: var(--blue-700);
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  transform: translateY(-1px);
}

.btn-import:active { transform: translateY(0); }

/* ============================================================
   MAIN
   ============================================================ */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  gap: 16px;
}

.empty-state.hidden { display: none; }

.empty-icon {
  width: 100px;
  height: 100px;
  background: var(--blue-50);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-400);
  margin-bottom: 8px;
  animation: pulse-soft 2.5s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59,130,246,.2); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(59,130,246,0); }
}

.empty-state h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.02em;
}

.empty-state p {
  color: var(--gray-500);
  max-width: 400px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 60px;
  margin-top: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue-400);
  background: var(--blue-50);
}

.drop-zone.drag-over { border-color: var(--blue-600); }

.drop-icon {
  color: var(--blue-400);
  transition: transform var(--transition);
}

.drop-zone:hover .drop-icon { transform: translateY(-4px); }

.drop-title {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 1rem;
}

.drop-subtitle { font-size: .85rem; color: var(--gray-500); }

.empty-hint {
  font-size: .8rem;
  color: var(--gray-400);
}

.empty-hint code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: .78rem;
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  display: none;
  animation: fadeIn .25s ease;
}

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

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

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

/* Period selector */
.period-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 4px;
}

.period-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.period-btn.active {
  background: white;
  color: var(--blue-600);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.period-btn:hover:not(.active) { color: var(--gray-800); }

.period-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.period-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-family: var(--font);
  background: white;
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.period-select:focus { border-color: var(--blue-400); }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

.kpi-card.income::before  { background: var(--color-income); }
.kpi-card.expense::before { background: var(--color-expense); }
.kpi-card.balance::before { background: var(--color-balance); }
.kpi-card.savings::before { background: var(--color-savings); }

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

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

.kpi-card.income  .kpi-icon { background: var(--color-income-bg);  color: var(--color-income); }
.kpi-card.expense .kpi-icon { background: var(--color-expense-bg); color: var(--color-expense); }
.kpi-card.balance .kpi-icon { background: var(--color-balance-bg); color: var(--color-balance); }
.kpi-card.savings .kpi-icon { background: var(--color-savings-bg); color: var(--color-savings); }

.kpi-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.kpi-change {
  font-size: .75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}

.kpi-change.up    { color: var(--color-income); }
.kpi-change.down  { color: var(--color-expense); }
.kpi-change.neutral { color: var(--gray-400); }

/* ============================================================
   CHART CARDS
   ============================================================ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.chart-card.full-width {
  margin-bottom: 24px;
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -.01em;
}

.chart-subtitle {
  font-size: .8rem;
  color: var(--gray-500);
}

.chart-wrapper {
  position: relative;
  width: 100%;
}

.chart-wrapper canvas {
  max-height: 280px;
}

.tall-chart canvas {
  max-height: 340px;
}

.donut-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.donut-wrapper canvas {
  max-height: 220px;
  max-width: 220px;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  margin-top: -10px;
}

.donut-center span {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
  display: block;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.donut-center small {
  font-size: .68rem;
  color: var(--gray-400);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.chart-legend {
  display: flex;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  color: var(--gray-600);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.chart-legend-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
}

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

.legend-name {
  flex: 1;
  color: var(--gray-600);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-amount {
  font-weight: 600;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.legend-pct {
  color: var(--gray-400);
  font-size: .75rem;
  min-width: 36px;
  text-align: right;
}

/* ============================================================
   SECTION CARD (generic)
   ============================================================ */
.section-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -.01em;
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue-600);
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background var(--transition);
}

.btn-link:hover { background: var(--blue-50); }

/* ============================================================
   RECENT TRANSACTIONS LIST
   ============================================================ */
.recent-list {
  padding: 8px 0;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-50);
  transition: background var(--transition);
}

.tx-item:last-child { border-bottom: none; }
.tx-item:hover { background: var(--gray-50); }

.tx-cat-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  background: hsl(var(--cat-hue, 200), 70%, 94%);
  color: hsl(var(--cat-hue, 200), 55%, 40%);
}

:root[data-theme="dark"] .tx-cat-badge {
  background: hsla(var(--cat-hue, 200), 70%, 15%, 0.6);
  color: hsl(var(--cat-hue, 200), 75%, 70%);
}

.tx-info {
  flex: 1;
  min-width: 0;
}

.tx-note {
  font-size: .875rem;
  font-weight: 500;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-cat {
  font-size: .75rem;
  color: var(--gray-500);
}

.tx-date {
  font-size: .75rem;
  color: var(--gray-400);
  flex-shrink: 0;
}

.tx-amount {
  font-size: .9rem;
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

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

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-group { display: flex; align-items: center; }

.filter-input {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font);
  background: var(--bg-card);
  color: var(--gray-800);
  outline: none;
  width: 220px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-input:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.filter-select {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font);
  background: var(--bg-card);
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.filter-select:focus { border-color: var(--blue-400); }

.btn-secondary {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--gray-700);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  padding: 12px 16px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th.text-right { text-align: right; }

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover { color: var(--gray-700); }

.sort-icon { opacity: .5; margin-left: 4px; }

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-50);
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--gray-50); }

.text-right { text-align: right; }

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

.tx-count {
  font-size: .83rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 4px 12px;
  border-radius: 20px;
}

/* Table cells */
.cell-date { color: var(--gray-500); font-size: .82rem; white-space: nowrap; }

.cell-category .cat-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 500;
  background: hsl(var(--cat-hue, 200), 60%, 92%);
  color: hsl(var(--cat-hue, 200), 50%, 35%);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme="dark"] .cell-category .cat-chip {
  background: hsla(var(--cat-hue, 200), 60%, 15%, 0.6);
  color: hsl(var(--cat-hue, 200), 75%, 70%);
}

.cell-note {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gray-600);
  font-size: .83rem;
}

.cell-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

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

.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.type-badge.income  { background: var(--color-income-bg);  color: var(--color-income); }
.type-badge.expense { background: var(--color-expense-bg); color: var(--color-expense); }

/* Table footer */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

#table-info {
  font-size: .8rem;
  color: var(--gray-500);
}

.pagination {
  display: flex;
  gap: 4px;
}

.page-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  font-family: var(--font);
  transition: all var(--transition);
}

.page-btn:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.page-btn.active {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: white;
}

.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   CATEGORIES
   ============================================================ */
.categories-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
}

.categories-table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.cat-table-wrapper {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

.cat-table td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.cat-bar-cell {
  min-width: 80px;
}

.cat-bar {
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .5s ease;
}

/* Toggle group */
.toggle-group {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 5px;
  background: transparent;
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.toggle-btn.active {
  background: white;
  color: var(--blue-600);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   BUDGETS
   ============================================================ */
.budget-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.budget-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 24px;
}

.budget-kpi { display: flex; flex-direction: column; gap: 4px; }

.bkpi-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.bkpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

.bkpi-value.expense { color: var(--color-expense); }

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

.budget-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  transition: box-shadow var(--transition);
}

.budget-card:hover { box-shadow: var(--shadow-md); }

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

.budget-cat-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 6px;
}

.budget-emoji { font-size: 1rem; }

.budget-amounts {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.budget-spent-amount {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.budget-limit-input {
  width: 80px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: .8rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--gray-600);
  background: var(--gray-50);
  text-align: right;
  outline: none;
  transition: all var(--transition);
}

.budget-limit-input:focus {
  border-color: var(--blue-400);
  background: white;
  box-shadow: 0 0 0 2px rgba(59,130,246,.1);
}

.budget-slash { color: var(--gray-400); font-size: .8rem; }

.budget-progress-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.budget-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  background: var(--budget-ok);
}

.budget-progress-bar.warn   { background: var(--budget-warn); }
.budget-progress-bar.danger { background: var(--budget-danger); }

.budget-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .75rem;
}

.budget-pct-text {
  font-weight: 600;
  color: var(--budget-ok);
}

.budget-pct-text.warn   { color: var(--budget-warn); }
.budget-pct-text.danger { color: var(--budget-danger); }

.budget-remaining-text {
  color: var(--gray-500);
}

/* ============================================================
   HISTORY
   ============================================================ */
#tab-history .section-card {
  margin-top: 24px;
}

.history-summary-row td {
  font-weight: 600;
  background: var(--gray-50);
}

.balance-positive { color: var(--color-income); }
.balance-negative { color: var(--color-expense); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  animation: overlayIn .2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-600);
  transition: all var(--transition);
}

.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 24px; }

.modal-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.modal-drop-zone:hover, .modal-drop-zone.drag-over {
  border-color: var(--blue-400);
  background: var(--blue-50);
}

.modal-drop-zone .drop-icon { color: var(--blue-400); margin-bottom: 4px; }

.file-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.file-item-icon { color: var(--blue-500); }

.file-item-info {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: .875rem;
  font-weight: 500;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  font-size: .75rem;
  color: var(--gray-400);
}

.file-item-status {
  font-size: .75rem;
  font-weight: 500;
  color: var(--color-income);
}

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

.btn-primary {
  padding: 9px 20px;
  background: var(--blue-600);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-700);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-toast);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn .25s ease;
  max-width: 320px;
}

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

.toast.success { border-left: 3px solid var(--color-income); }
.toast.error   { border-left: 3px solid var(--color-expense); }
.toast.info    { border-left: 3px solid var(--blue-400); }

.toast.fade-out { animation: toastOut .25s ease forwards; }

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

/* ============================================================
   LOADING
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 400;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--blue-100);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

.loading-overlay p {
  font-size: .9rem;
  color: var(--gray-600);
  font-weight: 500;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.text-income  { color: var(--color-income); }
.text-expense { color: var(--color-expense); }
.text-muted   { color: var(--gray-500); }
.text-bold    { font-weight: 700; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .charts-row {
    grid-template-columns: 1fr;
  }

  .categories-layout {
    grid-template-columns: 1fr;
  }

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

@media (min-width: 769px) {
  body {
    padding-left: 260px;
  }

  .app-header {
    width: 100%;
  }

  .app-main {
    padding: 28px 24px 60px;
  }
}

@media (max-width: 768px) {
  /* Sidebar bottom-bar conversion */
  .app-sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60px;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 0;
    overflow: hidden;
    scrollbar-width: none; /* Hide scrollbar Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    width: 100%;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
  }

  .sidebar-nav .nav-btn {
    display: none; /* Hide all by default on mobile */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    font-size: 0.65rem;
    height: 100%;
    width: auto;
    flex: 1; /* Distribute space evenly */
    border-radius: 0;
    background: transparent;
    box-shadow: none !important;
  }

  .sidebar-nav #nav-dashboard,
  .sidebar-nav #nav-transactions,
  .sidebar-nav #nav-budgets,
  .sidebar-nav #nav-equilibrium,
  .sidebar-nav #nav-more {
    display: flex; /* Show only core buttons */
  }

  .sidebar-nav .nav-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-radius: var(--radius-sm);
    font-weight: 600;
  }

  .sidebar-nav .nav-btn svg {
    width: 18px;
    height: 18px;
  }

  .sidebar-nav .nav-btn .budget-badge {
    top: 4px;
    right: calc(50% - 16px);
  }

  /* Header adjustments for mobile */
  .brand-subtitle {
    display: none;
  }

  .header-actions .btn-text {
    display: none;
  }

  .header-actions button {
    padding: 8px !important;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important; /* Make buttons round and modern */
  }

  .header-actions button svg {
    margin-right: 0 !important;
  }

  #global-search {
    width: 110px;
  }
  #global-search:focus {
    width: 150px;
  }

  .data-status #status-text {
    display: none;
  }

  .data-status {
    padding: 8px !important;
    border-radius: 50% !important;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
  }

  .status-dot {
    width: 8px;
    height: 8px;
  }

  /* Layout adjustments */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .budget-summary {
    grid-template-columns: 1fr 1fr;
  }

  .app-main {
    padding: 16px 12px 80px; /* More padding-bottom to clear the bottom bar */
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .budget-summary { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================================
   ANIMATIONS helpers
   ============================================================ */
.animate-value {
  transition: all .4s cubic-bezier(.4,0,.2,1);
}

/* Number counter animation */
@keyframes countUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.count-anim { animation: countUp .3s ease; }

/* ============================================================
   NEW FEATURES EXTENSION (V2)
   ============================================================ */

/* ---- Sparklines ---- */
.kpi-sparkline {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 32px;
  pointer-events: none;
  opacity: 0.8;
  transition: opacity var(--transition);
}

.kpi-card:hover .kpi-sparkline {
  opacity: 1;
}

/* ---- Projection Banner ---- */
.projection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--blue-50), #edf4ff);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.6);
  position: relative;
  overflow: hidden;
}

.projection-banner::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: radial-gradient(circle at top right, rgba(59,130,246,0.06), transparent 70%);
  pointer-events: none;
}

.proj-icon {
  font-size: 1.5rem;
  background: white;
  min-width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(59,130,246,0.08);
  flex-shrink: 0;
}

.proj-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  margin-left: 12px;
}

.proj-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.proj-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--blue-900);
  letter-spacing: -0.02em;
}

.proj-stats {
  display: flex;
  gap: 28px;
  align-items: center;
  flex-wrap: wrap;
}

.proj-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.proj-stat-label {
  font-size: 0.7rem;
  color: var(--gray-500);
  font-weight: 500;
}

.proj-stat-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
}

/* ---- Trend Badges ---- */
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all var(--transition);
}

.trend-badge.down-good {
  background: var(--color-income-bg);
  color: var(--color-income);
}

.trend-badge.up-bad {
  background: var(--color-expense-bg);
  color: var(--color-expense);
}

.trend-badge.up-good {
  background: var(--color-income-bg);
  color: var(--color-income);
}

.trend-badge.down-bad {
  background: var(--color-expense-bg);
  color: var(--color-expense);
}

.trend-badge.neutral {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* ---- Recurring Tab Layout ---- */
.recurring-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.rec-kpi {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
}

.rec-kpi:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.rec-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.rec-kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
}

.rec-kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.recurring-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.recurring-list {
  padding: 8px 0;
}

.rec-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}

.rec-item:last-child {
  border-bottom: none;
}

.rec-item:hover {
  background: var(--gray-50);
}

.rec-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: hsl(var(--cat-hue, 200), 70%, 94%);
  color: hsl(var(--cat-hue, 200), 55%, 40%);
}

:root[data-theme="dark"] .rec-item-icon {
  background: hsla(var(--cat-hue, 200), 70%, 15%, 0.6);
  color: hsl(var(--cat-hue, 200), 75%, 70%);
}

.rec-item-details {
  flex: 1;
  min-width: 0;
}

.rec-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-item-meta {
  font-size: 0.75rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.rec-item-freq {
  background: var(--blue-50);
  color: var(--blue-600);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.rec-item-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Recurring: Action Buttons ---- */
.rec-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-left: 8px;
}

.rec-item:hover .rec-item-actions {
  opacity: 1;
}

.rec-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.15s ease;
}

.rec-action-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.rec-btn-delete:hover {
  background: rgba(220,38,38,.1);
  color: #dc2626;
}

.rec-btn-edit:hover {
  background: rgba(37,99,235,.1);
  color: #2563eb;
}

/* ---- Recurring: Source Badges ---- */
.rec-source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
}

.rec-source-badge.auto {
  background: rgba(100, 116, 139, 0.1);
  color: #64748b;
}

.rec-source-badge.manual {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.rec-source-badge.overridden {
  background: rgba(217, 119, 6, 0.1);
  color: #d97706;
}

/* ---- Recurring: Add Button ---- */
.rec-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--gray-500);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rec-add-btn:hover {
  border-color: var(--blue-400);
  color: var(--blue-600);
  background: rgba(37, 99, 235, 0.04);
}

/* ---- Bottom Row Grid (Top Dépenses + Récentes) ---- */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 1024px) {
  .recurring-layout {
    grid-template-columns: 1fr;
  }
  .recurring-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .bottom-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 580px) {
  .recurring-summary {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   FINTRACK V3 — ÉQUILIBRE DE VIE (50/30/20) & CONFIGURATION
   ============================================================ */

/* Navigation mobile scrollable */
.header-nav {
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.header-nav::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Equilibrium Cards Grid */
.equilibrium-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.eq-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.eq-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.eq-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.eq-card-pct {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.eq-card.needs .eq-card-pct { color: var(--eq-needs); }
.eq-card.wants .eq-card-pct { color: var(--eq-wants); }
.eq-card.savings .eq-card-pct { color: var(--eq-savings); }

.eq-card-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
  display: block;
  margin-bottom: 8px;
}

/* Custom Progress Bar with Target Marker */
.eq-progress-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  position: relative;
  margin-bottom: 10px;
  overflow: visible; /* To let marker extend */
}

.eq-progress-fill {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width var(--transition-slow);
}

.eq-progress-fill.needs { background: var(--eq-needs); }
.eq-progress-fill.wants { background: var(--eq-wants); }
.eq-progress-fill.savings { background: var(--eq-savings); }

.eq-target-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 16px;
  background: var(--gray-900);
  border-radius: 1px;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
  z-index: 10;
  cursor: help;
}

.eq-card-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.eq-card-comparison {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.eq-comp-val {
  font-weight: 600;
}

.eq-comp-val.better {
  color: var(--color-income);
}

.eq-comp-val.worse {
  color: var(--color-expense);
}

.eq-comp-val.neutral {
  color: var(--gray-500);
}

.eq-diff {
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.eq-diff.over {
  background: var(--color-expense-bg);
  color: var(--color-expense);
}

.eq-diff.under {
  background: var(--color-income-bg);
  color: var(--color-income);
}

.eq-diff.within {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* Equilibrium, Annual & Config Layout */
.equilibrium-layout, .config-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.annual-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* Advice styling */
.eq-advice-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 5px 0;
}

.eq-advice-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  border-left: 4px solid;
}

.eq-advice-item.info {
  background: rgba(37, 99, 235, 0.05);
  border-left-color: #3b82f6;
  color: #1e40af;
}

.eq-advice-item.warning {
  background: rgba(245, 158, 11, 0.05);
  border-left-color: #f59e0b;
  color: #92400e;
}

.eq-advice-item.success {
  background: rgba(16, 185, 129, 0.05);
  border-left-color: #10b981;
  color: #065f46;
}

.eq-advice-title {
  font-weight: 700;
  display: block;
  margin-bottom: 3px;
  font-size: 0.9rem;
}

/* Configuration targets UI */
.config-targets-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

.target-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.target-control label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.target-control-inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.target-slider {
  flex: 1;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

.target-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue-600);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.1s;
}

.target-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.target-number-input {
  width: 70px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  text-align: center;
  font-size: 0.9rem;
}

.target-status {
  padding: 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  transition: all var(--transition);
}

.target-status .status-indicator.success {
  color: var(--color-income);
  background: var(--color-income-bg);
  padding: 4px 10px;
  border-radius: 4px;
  display: block;
}

.target-status .status-indicator.error {
  color: var(--color-expense);
  background: var(--color-expense-bg);
  padding: 4px 10px;
  border-radius: 4px;
  display: block;
}

/* Category mapping table */
.config-cat-wrapper {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.config-cat-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  background: white;
  width: 100%;
}

/* Automatic Rules Form */
.full-width-card {
  grid-column: 1 / -1;
}

.new-rule-form {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px dashed var(--gray-300);
}

.form-group-horizontal {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group-horizontal .form-group {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group-horizontal .form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
}

.form-group-horizontal .form-group input,
.form-group-horizontal .form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  height: 42px;
}

/* Responsive constraints */
@media (max-width: 1024px) {
  .equilibrium-layout, .config-layout {
    grid-template-columns: 1fr;
  }
  .equilibrium-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

.btn-danger-sm {
  background: transparent;
  color: var(--color-expense);
  border: 1px solid var(--color-expense);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-danger-sm:hover {
  background: var(--color-expense);
  color: white;
}

/* Modal styling overrides */
.form-input-large:focus, .form-select-large:focus {
  border-color: var(--blue-600);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* Hover style on transaction lines */
.data-table tbody tr.clickable-row {
  cursor: pointer;
}
.data-table tbody tr.clickable-row:hover {
  background-color: var(--blue-50);
}

.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
}

.form-input-large, .form-select-large {
  background: var(--bg-card) !important;
  color: var(--gray-800) !important;
  border: 1px solid var(--border) !important;
}
.form-input-large:focus, .form-select-large:focus {
  border-color: var(--blue-600) !important;
}

/* ---- Alert Banner ---- */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}
.alert-banner.error {
  background-color: var(--color-expense-bg);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: var(--color-expense);
}
.alert-banner.error .alert-title {
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}
.alert-banner.error .alert-text {
  font-size: 0.85rem;
  margin: 0;
  opacity: 0.9;
}
.alert-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   SPRINTS 3 & 4 LAYOUTS & COMPONENTS
   ============================================================ */

/* Dashboard Grid Layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: calc(var(--header-h) + 24px);
}

@media (max-width: 1100px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .dashboard-sidebar {
    position: static;
  }
}

/* Financial Health Score SVG Gauge & Details */
.score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0 8px;
}

.gauge-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
}

.score-gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--gray-100);
  stroke-width: 8;
}

:root[data-theme="dark"] .gauge-bg {
  stroke: var(--gray-200);
}

.gauge-value {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 251.2; /* 2 * PI * r (r=40) = 251.2 */
  stroke-dashoffset: 251.2;
  transition: stroke-dashoffset var(--transition-slow), stroke var(--transition);
}

/* Colors based on health state */
.score-gauge.danger .gauge-value { stroke: var(--color-danger); }
.score-gauge.warning .gauge-value { stroke: var(--color-warning); }
.score-gauge.info .gauge-value { stroke: var(--color-balance); }
.score-gauge.success .gauge-value { stroke: var(--color-income); }

.gauge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

#score-number {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
}

.gauge-text small {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.score-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.score-badge.danger { background: var(--color-expense-bg); color: var(--color-expense); }
.score-badge.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.score-badge.info { background: var(--color-balance-bg); color: var(--color-balance); }
.score-badge.success { background: var(--color-income-bg); color: var(--color-income); }

.score-details {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

.score-criterion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--gray-600);
}

.score-criterion-val {
  font-weight: 600;
}

.score-criterion-val.good { color: var(--color-income); }
.score-criterion-val.warn { color: var(--color-warning); }
.score-criterion-val.bad { color: var(--color-expense); }

/* Accounts Balance list */
.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.account-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.account-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.account-item.active {
  background: var(--blue-50);
  border-color: var(--blue-600);
}

.account-item.active .account-name {
  color: var(--blue-600);
}

.account-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-800);
}

.account-balance {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* Simulator styles */
.collapsible-card {
  transition: box-shadow var(--transition);
}

.collapse-icon {
  display: inline-block;
  transform: rotate(0deg);
  font-size: 0.8rem;
  color: var(--gray-500);
}

.collapsible-card.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

/* Goals list & items styling */
.goal-item {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--gray-50);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.goal-title-group {
  display: flex;
  flex-direction: column;
}

.goal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.goal-deadline-info {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.goal-amounts {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.goal-current-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-600);
}

.goal-target-val {
  font-weight: 600;
  color: var(--gray-700);
}

.goal-progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-500), var(--blue-600));
  border-radius: 4px;
  width: 0%;
  transition: width var(--transition-slow);
}

.goal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.goal-suggestion {
  color: var(--gray-600);
}

.goal-suggestion-val {
  font-weight: 700;
  color: var(--color-savings);
}

/* Small secondary action button */
.btn-secondary-sm {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary-sm:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--text-primary);
}

/* Custom styling for hue color range input */
#edit-cat-color-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 2px solid #64748b;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#edit-cat-color-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 2px solid #64748b;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}/* ============================================================
   MON CONSEILLER QUOTIDIEN — CSS STYLES
   ============================================================ */

.advisor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px;
}

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

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

.advisor-item {
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  gap: 12px;
  position: relative;
  transition: all var(--transition);
}

.advisor-item:hover {
  border-color: var(--blue-400);
  box-shadow: var(--shadow-sm);
  background: var(--bg-card);
}

.advisor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.advisor-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-900);
}

.advisor-status {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}

.advisor-status.ok {
  background: rgba(5, 150, 105, 0.1);
  color: var(--color-income);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.advisor-status.warning {
  background: rgba(217, 119, 6, 0.1);
  color: var(--color-warning);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.advisor-status.reduced {
  background: rgba(124, 58, 237, 0.1);
  color: var(--color-savings);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.advisor-status.danger {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-expense);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.advisor-status.info {
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue-600);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.advisor-value-box {
  display: flex;
  flex-direction: column;
}

.advisor-amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.advisor-amount.negative {
  color: var(--color-expense);
}

.advisor-amount-subtitle {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.advisor-progress-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.advisor-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--gray-500);
  font-weight: 500;
}

.advisor-progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.advisor-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-slow);
}

.advisor-progress-fill.ok {
  background: var(--color-income);
}

.advisor-progress-fill.warning {
  background: var(--color-warning);
}

.advisor-progress-fill.reduced {
  background: var(--color-savings);
}

.advisor-progress-fill.danger {
  background: var(--color-expense);
}

.advisor-progress-fill.info {
  background: var(--blue-500);
}

.advisor-progress-fill.muted {
  background: var(--gray-300);
}

:root[data-theme="dark"] .advisor-progress-fill.muted {
  background: var(--gray-700);
}

/* Priority Badges in Table */
.priority-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
}

.priority-badge.p1 {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.priority-badge.p2 {
  background: rgba(217, 119, 6, 0.08);
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.15);
}

.priority-badge.p3 {
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.priority-badge.p4 {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.15);
}

.priority-badge.p5 {
  background: rgba(107, 114, 128, 0.08);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.15);
}

/* Advisor Config Modal Lists */
.advisor-checklist-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 15px;
}

@media (max-width: 768px) {
  .advisor-checklist-container {
    grid-template-columns: 1fr;
  }
}

.advisor-checklist-box {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.advisor-checklist-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-900);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.advisor-checklist-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.advisor-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--gray-700);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background var(--transition);
}

.advisor-checklist-item:hover {
  background: var(--gray-100);
}

.advisor-checklist-item input {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: var(--blue-600);
}

/* ============================================================
   SOUS-ONGLETS DE CONFIGURATION — CSS STYLES
   ============================================================ */

.config-subtabs-nav {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding-bottom: 0;
}

.config-subtab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--gray-500);
  padding: 10px 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  bottom: -1px; /* Overlap border-bottom */
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-subtab-btn:hover {
  color: var(--blue-600);
}

.config-subtab-btn.active {
  color: var(--blue-600);
  font-weight: 600;
  border-bottom-color: var(--blue-600);
}

/* Subtab content visibility */
.config-subtab-content {
  display: none;
  animation: fadeIn var(--transition) ease;
}

.config-subtab-content.active {
  display: block;
}

/* Adaptability for backup & restore container */
.backup-restore-container {
  display: flex;
  gap: 24px;
  align-items: stretch;
  margin-top: 15px;
  flex-wrap: wrap;
}

.backup-restore-card {
  flex: 1;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.backup-restore-divider {
  width: 1px;
  background: var(--border);
  margin: 0 10px;
}

@media (max-width: 768px) {
  .config-subtabs-nav {
    gap: 12px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 16px;
  }
  
  .config-subtab-btn {
    font-size: 0.85rem;
    padding: 8px 2px;
  }
  
  .backup-restore-container {
    flex-direction: column;
    gap: 16px;
  }
  
  .backup-restore-divider {
    display: none;
  }
}

/* ============================================================
   MOBILE BOTTOM SHEET & OVERLAY
   ============================================================ */
.mobile-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.mobile-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mobile-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
  z-index: 2001;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 20px 24px 40px;
  max-height: 80vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

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

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.mobile-sheet-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
}

.mobile-sheet-close {
  background: transparent;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.mobile-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--gray-700);
  width: 100%;
  height: auto;
  box-shadow: none !important;
}

.mobile-sheet-item:hover, .mobile-sheet-item:active {
  background: var(--gray-100);
  border-color: var(--blue-400);
  color: var(--blue-600);
}

.mobile-sheet-item.active {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--blue-600);
  color: var(--blue-600);
  font-weight: 600;
}

.mobile-sheet-item svg {
  width: 24px;
  height: 24px;
  color: inherit;
  transition: transform 0.2s ease;
}

.mobile-sheet-item:active svg {
  transform: scale(0.9);
}

.mobile-sheet-item span {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

/* ============================================================
   RESPONSIVE TABLES & MOBILE LAYOUTS
   ============================================================ */
@media (max-width: 768px) {
  /* Global Layout spacing */
  .header-inner {
    padding: 0 12px;
  }
  .header-actions {
    gap: 8px;
  }

  /* Modals adaptation */
  .modal, .modal-content {
    width: 94%;
    margin: 10px auto;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-header {
    padding: 16px 20px;
  }

  /* Form groups adaptation */
  .form-group-horizontal {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .form-group-horizontal .form-group {
    width: 100%;
    min-width: 0;
  }
  .form-group-horizontal button {
    width: 100%;
    margin-top: 4px;
  }

  /* Period selector adaptation */
  .period-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: transparent;
    padding: 0;
    width: 100%;
    margin-top: 8px;
  }
  .period-btn, .period-select, #btn-dashboard-pdf {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .period-divider {
    display: none;
  }
  #btn-dashboard-pdf {
    padding: 8px !important;
    width: 36px;
    height: 36px;
    justify-content: center;
  }
  #btn-dashboard-pdf .btn-text {
    display: none;
  }

  /* --- Transactions Table Mobile Card Layout --- */
  #transactions-table thead {
    display: none; /* Hide headers */
  }
  #transactions-table tbody,
  #transactions-table tr {
    display: block;
    width: 100%;
  }
  #transactions-table tr.clickable-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "date type"
      "note note"
      "category amount";
    gap: 8px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  #transactions-table td {
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  #transactions-table td.cell-date {
    grid-area: date;
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
  }
  #transactions-table tr.clickable-row td:last-child {
    grid-area: type;
    justify-self: end;
  }
  #transactions-table td.cell-note {
    grid-area: note;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
  }
  #transactions-table td.cell-category {
    grid-area: category;
    justify-self: start;
  }
  #transactions-table td.cell-amount {
    grid-area: amount;
    justify-self: end;
    font-size: 1rem;
    font-weight: 700;
    text-align: right;
  }

  /* --- Categories Table Mobile Layout --- */
  #categories-table thead {
    display: none;
  }
  #categories-table tbody,
  #categories-table tr {
    display: block;
    width: 100%;
  }
  #categories-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "name total"
      "count avg"
      "pct trend";
    gap: 8px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  #categories-table td {
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    text-align: left !important;
  }
  #categories-table tr td:nth-child(1) {
    grid-area: name;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
  }
  #categories-table tr td:nth-child(2) {
    grid-area: total;
    text-align: right !important;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
  }
  #categories-table tr td:nth-child(3) {
    grid-area: pct;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  #categories-table tr td:nth-child(4) {
    grid-area: count;
    font-size: 0.8rem;
    color: var(--gray-600);
  }
  #categories-table tr td:nth-child(4)::before {
    content: "Transactions : ";
    color: var(--gray-400);
    font-weight: normal;
  }
  #categories-table tr td:nth-child(5) {
    grid-area: avg;
    text-align: right !important;
    font-size: 0.8rem;
    color: var(--gray-600);
  }
  #categories-table tr td:nth-child(5)::before {
    content: "Moy. : ";
    color: var(--gray-400);
    font-weight: normal;
  }
  #categories-table tr td:nth-child(6) {
    grid-area: trend;
    text-align: right !important;
    display: flex;
    justify-content: flex-end;
  }

  /* --- History Table Mobile Layout --- */
  #history-table thead {
    display: none;
  }
  #history-table tbody,
  #history-table tr {
    display: block;
    width: 100%;
  }
  #history-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "month balance"
      "income expense"
      "savings rate";
    gap: 8px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  #history-table td {
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    text-align: left !important;
  }
  #history-table tr td:nth-child(1) {
    grid-area: month;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
  }
  #history-table tr td:nth-child(4) {
    grid-area: balance;
    text-align: right !important;
    font-size: 1rem;
    font-weight: 700;
  }
  #history-table tr td:nth-child(2) {
    grid-area: income;
    font-size: 0.85rem;
  }
  #history-table tr td:nth-child(2)::before {
    content: "Revenus : ";
    color: var(--gray-400);
  }
  #history-table tr td:nth-child(3) {
    grid-area: expense;
    text-align: right !important;
    font-size: 0.85rem;
  }
  #history-table tr td:nth-child(3)::before {
    content: "Dépenses : ";
    color: var(--gray-400);
  }
  #history-table tr td:nth-child(5) {
    grid-area: savings;
    font-size: 0.85rem;
  }
  #history-table tr td:nth-child(5)::before {
    content: "Épargne : ";
    color: var(--gray-400);
  }
  #history-table tr td:nth-child(6) {
    grid-area: rate;
    text-align: right !important;
    font-size: 0.85rem;
  }
  #history-table tr td:nth-child(6)::before {
    content: "Taux : ";
    color: var(--gray-400);
  }
  #history-table tr.history-summary-row {
    background: rgba(37, 99, 235, 0.04) !important;
    border-top: 2px solid var(--blue-600);
    border-bottom: 2px solid var(--blue-600);
    margin-top: 10px;
    border-radius: var(--radius-md);
  }

  /* --- Config: Category type Table --- */
  #config-cat-table thead { display: none; }
  #config-cat-table tbody, #config-cat-table tr { display: block; width: 100%; }
  #config-cat-table tr {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  #config-cat-table td {
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  /* --- Config: Manage Categories Table --- */
  #manage-cat-table thead { display: none; }
  #manage-cat-table tbody, #manage-cat-table tr { display: block; width: 100%; }
  #manage-cat-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name actions"
      "priority stats";
    gap: 8px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  #manage-cat-table td {
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  #manage-cat-table td:nth-child(1) { grid-area: name; }
  #manage-cat-table td:nth-child(2) { grid-area: priority; }
  #manage-cat-table td:nth-child(3) { grid-area: stats; text-align: right !important; }
  #manage-cat-table td:nth-child(4) { grid-area: actions; justify-self: end; }

  /* --- Config: Rules Table --- */
  #rules-table thead { display: none; }
  #rules-table tbody, #rules-table tr { display: block; width: 100%; }
  #rules-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "pattern actions"
      "target target";
    gap: 8px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  #rules-table td {
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  #rules-table td:nth-child(1) { grid-area: pattern; }
  #rules-table td:nth-child(2) { grid-area: target; }
  #rules-table td:nth-child(3) { grid-area: actions; justify-self: end; }
}

/* ============================================================
   REFONTE CONFIGURATION — DOUBLE PANNEAU, KANBAN & CARTES
   ============================================================ */

.config-layout-split {
  display: grid;
  grid-template-columns: 38% 60%;
  gap: 20px;
  align-items: start;
}

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

/* --- Ratios sliders --- */
.ratio-sliders-card {
  height: 100%;
}

/* --- Kanban Allocation Board --- */
.kanban-board-card {
  height: 100%;
}

.allocation-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.allocation-col {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 350px;
}

:root[data-theme="dark"] .allocation-col {
  background: rgba(255, 255, 255, 0.02);
}

.allocation-col-header {
  font-weight: 700;
  font-size: 0.85rem;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

.allocation-col.needs .allocation-col-header { color: var(--eq-needs); border-bottom-color: var(--eq-needs); }
.allocation-col.wants .allocation-col-header { color: var(--eq-wants); border-bottom-color: var(--eq-wants); }
.allocation-col.savings .allocation-col-header { color: var(--eq-savings); border-bottom-color: var(--eq-savings); }

.allocation-col-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding-right: 2px;
}

.allocation-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.allocation-badge:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.allocation-badge-content {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-badge-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.allocation-badge .btn-chevron {
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 800;
  color: var(--gray-400);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.allocation-badge .btn-chevron:hover {
  background: var(--gray-100);
  color: var(--blue-600);
}

:root[data-theme="dark"] .allocation-badge .btn-chevron:hover {
  background: rgba(255,255,255,0.08);
}

.allocation-badge .btn-chevron:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .allocation-board {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .allocation-col {
    min-height: auto;
  }
}

/* --- Dual Pane Category Config --- */
.config-dual-pane {
  display: grid;
  grid-template-columns: 42% 56%;
  gap: 20px;
  align-items: start;
}

.categories-list-card, .category-editor-card {
  height: 100%;
}

.categories-list-wrapper {
  max-height: 480px;
  overflow-y: auto;
}

#manage-cat-table tbody tr {
  cursor: pointer;
  transition: all 0.15s ease;
}

#manage-cat-table tbody tr:hover {
  background: var(--gray-50);
}

:root[data-theme="dark"] #manage-cat-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

#manage-cat-table tbody tr.active-row {
  background: rgba(37, 99, 235, 0.04);
  border-left: 3px solid var(--blue-600);
}

.category-editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease;
}

@keyframes flash-active {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); border-color: var(--blue-600); }
  50% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.4); border-color: var(--blue-600); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); border-color: var(--border); }
}

.category-editor-card.flash-active {
  animation: flash-active 0.8s ease-out;
}


.editor-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.01);
}

:root[data-theme="dark"] .editor-empty-state {
  background: rgba(255,255,255,0.005);
}

.color-circle-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  transition: background 0.15s;
}

.hue-slider-custom {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}

.hue-slider-custom::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 2px solid #64748b;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.1s;
}

.hue-slider-custom::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.integrated-merge-panel {
  background: rgba(239, 68, 68, 0.02);
  border: 1px dashed rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 15px;
}

:root[data-theme="dark"] .integrated-merge-panel {
  background: rgba(239, 68, 68, 0.04);
}

/* Category Editor Bottom Sheet on Mobile */
@media (max-width: 768px) {
  .config-dual-pane {
    grid-template-columns: 1fr;
  }
  
  .category-editor-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2005;
    background: var(--bg-card);
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px 20px 30px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-bottom: none;
    min-height: auto;
  }
  
  .category-editor-card.active {
    transform: translateY(0);
  }
  
  .category-editor-card .mobile-only-close {
    display: block !important;
  }
  
  .editor-empty-state {
    display: none !important;
  }
  
  .category-editor-card .editor-content-form {
    display: block !important;
  }
}

/* --- Rules Grid --- */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  width: 100%;
}

.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.rule-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.rule-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.rule-keyword {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
  max-width: 80%;
}

.btn-delete-rule-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-delete-rule-icon:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

.rule-target-badge {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: hsl(var(--cat-hue, 200), 60%, 92%);
  color: hsl(var(--cat-hue, 200), 50%, 35%);
}

:root[data-theme="dark"] .rule-target-badge {
  background: hsla(var(--cat-hue, 200), 60%, 15%, 0.6);
  color: hsl(var(--cat-hue, 200), 75%, 70%);
}


/* Custom additions for UI/UX standardization and inline style removal */
.form-vertical-stack {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 15px;
}

.card-description {
  font-size: var(--fs-sm);
  color: var(--gray-500);
  margin: 12px 0 20px;
  line-height: 1.5;
}

body[data-theme="dark"] .card-description {
  color: var(--gray-400);
}

.modal-md {
  max-width: 480px !important;
}

.pt-10 {
  padding-top: 10px;
}

.mapping-choice-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group-checkbox {
  margin-top: 15px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.text-accent {
  color: var(--blue-600);
}

#merge-cat-target-select {
  height: 34px;
  padding: 4px 10px;
  font-size: var(--fs-base);
}

/* ============================================================
   CLASSES DE COMPOSANTS DYNAMIQUES ET UTILITAIRES SPRINT 10
   ============================================================ */

/* Utility Classes */
.ml-auto { margin-left: auto !important; }
.ml-6 { margin-left: 6px; }
.mr-6 { margin-right: 6px; }
.cursor-pointer { cursor: pointer !important; }
.text-right { text-align: right !important; }
.font-semibold { font-weight: 600 !important; }
.inline { display: inline !important; }
.pointer-events-none { pointer-events: none !important; }
.opacity-40 { opacity: 0.4 !important; }
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-2-gap8 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Component Classes */
.badge-compact {
  font-size: 0.7rem !important;
  padding: 2px 6px !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
}

.unpaid-charges-list {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--gray-600);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  width: 100%;
}
.unpaid-charges-list.all-paid {
  color: var(--color-income);
}
.unpaid-charges-title {
  font-weight: 600;
  color: var(--gray-700);
}
.unpaid-charges-items {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.proj-wrapper-col {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 12px;
}
.proj-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}
.proj-main-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.proj-stats-container {
  display: flex;
  gap: 12px;
  margin-left: auto;
}
.proj-middle-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.proj-time-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}
.progress-track {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}
.progress-bar-fill {
  height: 100%;
  transition: width 0.5s;
}
.progress-bar-fill.success {
  background: var(--color-income);
}
.progress-bar-fill.warning {
  background: var(--color-warning);
}
.progress-bar-fill.danger {
  background: var(--color-expense);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}
.search-result-item:hover, .search-result-item.highlighted {
  background: var(--blue-50);
}
.search-result-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 70%;
}
.search-result-item-emoji {
  font-size: 16px;
}
.search-result-item-details {
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item-title {
  font-weight: 600;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item-meta {
  color: var(--gray-400);
  font-size: 11px;
}
.search-result-item-amount {
  font-weight: 600;
  text-align: right;
  min-width: 70px;
}

.cat-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0;
  flex-shrink: 0;
}
.cat-list-stats {
  font-size: 13px;
  color: var(--gray-600);
}

.savings-pool-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--blue-800);
  margin-bottom: 8px;
}
.savings-pool-value {
  font-size: 1.1rem;
  color: var(--blue-700);
}

.btn-delete-goal {
  color: var(--color-danger);
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.btn-delete-goal:hover {
  opacity: 0.8;
}

.empty-list-text {
  padding: 12px 20px;
  color: var(--gray-400);
  font-size: 0.85rem;
}

.page-btn-disabled {
  pointer-events: none;
  opacity: 0.4;
}

.app-sidebar .account-item {
  margin-bottom: 4px;
  background: var(--bg-card);
  border-left: 3px solid transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.app-sidebar .account-item.active {
  border-left-color: var(--blue-500);
  background: var(--blue-50);
}
.app-sidebar .account-item-name {
  font-size: 0.85rem;
  color: var(--gray-800);
  font-weight: 600;
}
.app-sidebar .account-item.active .account-item-name {
  font-weight: 700;
}
.app-sidebar .account-item-details {
  font-size: 0.7rem;
  color: var(--gray-500);
}
.app-sidebar .account-item-balance {
  font-size: 0.9rem;
  font-weight: 700;
}
.app-sidebar .account-item-balance.positive {
  color: var(--color-income);
}
.app-sidebar .account-item-balance.negative {
  color: var(--color-expense);
}

/* Legend dots */
.legend-dot.income {
  background: var(--color-income);
}
.legend-dot.expense {
  background: var(--color-expense);
}

/* Category HSL-based styles */
.cat-color-dot {
  background: hsl(var(--cat-hue, 200), 65%, 60%);
}
.cat-color-dot.color-dot-autres {
  background: rgba(148, 163, 184, 0.5) !important;
}

.legend-color-dot {
  background: hsl(var(--cat-hue, 200), 65%, 60%);
}
.legend-color-dot.color-dot-autres {
  background: rgba(148, 163, 184, 0.5) !important;
}

.cat-bar-fill {
  background: hsl(var(--cat-hue, 200), 65%, 60%);
}
.cat-bar-fill.bar-fill-autres {
  background: rgba(148, 163, 184, 0.5) !important;
}

/* Configuration Empty States */
.empty-rules-hint {
  grid-column: 1 / -1;
  padding: 30px;
  font-size: 0.85rem;
}

.empty-advisor-categories {
  font-size: 12px;
  padding: 10px 0;
}

/* Tags styling */
.tx-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue-600);
  border: 1px solid rgba(37, 99, 235, 0.12);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-pill:hover {
  background: var(--blue-600);
  color: white;
  border-color: var(--blue-600);
  transform: translateY(-0.5px);
}

:root[data-theme="dark"] .tag-pill {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border-color: rgba(37, 99, 235, 0.25);
}

:root[data-theme="dark"] .tag-pill:hover {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

/* Comparative Report Custom Styles */
.compare-period-card {
  background: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.compare-period-title {
  margin-bottom: 8px;
  display: block;
  font-size: var(--fs-xs);
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.label-compact {
  font-size: 0.7rem;
  color: var(--gray-500);
}

.align-end {
  align-items: flex-end;
}

.btn-height-36 {
  height: 36px;
}

.no-border {
  border: none !important;
}

.pb-0 {
  padding-bottom: 0 !important;
}

.mb-20 {
  margin-bottom: 20px !important;
}

.kpi-sublabel {
  font-size: 0.7rem;
  margin-top: 2px;
  color: var(--gray-500);
}

.kpi-pct-value {
  font-weight: 600;
  margin-top: 2px;
  font-size: 0.78rem;
}

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

/* ============================================================
   SYNCHRONISATION DOSSIER LOCAL
   ============================================================ */

.dir-banner-key-icon {
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dir-banner-desc {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

.btn-dir-auth {
  margin-left: 15px;
  white-space: nowrap;
}

.dir-status-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.dir-status-label {
  font-weight: 600;
  color: var(--gray-700);
}

.dir-status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.dir-status-badge.status-disconnected {
  background: var(--color-expense-bg);
  color: var(--color-expense);
}

.dir-status-badge.status-auth-needed {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.dir-status-badge.status-connected {
  background: var(--color-income-bg);
  color: var(--color-income);
}

.dir-info-text {
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--gray-50);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
}

:root[data-theme="dark"] .dir-info-text {
  background: rgba(255, 255, 255, 0.02);
}

.btn-danger-outline {
  background: transparent;
  color: var(--color-expense);
  border: 1px solid var(--color-expense);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-danger-outline:hover {
  background: var(--color-expense);
  color: white;
}

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

/* ============================================================
   ECRAN DE VERROUILLAGE PIN & MODE CONFIDENTIEL (SPRINT 1)
   ============================================================ */

/* Privacy Mode */
.privacy-active .kpi-value,
.privacy-active .monetary-value,
.privacy-active .amount-val,
.privacy-active .proj-value,
.privacy-active .proj-stat-val,
.privacy-active .bkpi-value,
.privacy-active .donut-center span,
.privacy-active canvas,
.privacy-active .kpi-sparkline {
  filter: blur(8px) !important;
  user-select: none !important;
  pointer-events: none !important;
}

#btn-privacy-toggle .privacy-on-icon {
  display: none;
}
.privacy-active #btn-privacy-toggle .privacy-off-icon {
  display: none;
}
.privacy-active #btn-privacy-toggle .privacy-on-icon {
  display: inline-block;
}

/* PIN Lock Screen Overlay */
.pin-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.pin-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.pin-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 30px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-header {
  text-align: center;
  margin-bottom: 24px;
}

.pin-logo {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.pin-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.pin-header p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.pin-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 30px;
}

.pin-dots .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  background: transparent;
  transition: all 0.15s ease;
}

.pin-dots .dot.filled {
  background: var(--blue-600);
  border-color: var(--blue-600);
  transform: scale(1.15);
}

.pin-keyboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.pin-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
  justify-self: center;
}

.pin-btn:hover {
  background: var(--gray-50);
  transform: scale(1.05);
}

:root[data-theme="dark"] .pin-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.pin-btn.action {
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  background: transparent;
}

.pin-btn.action:hover {
  background: transparent;
  color: var(--blue-600);
  transform: none;
}

.pin-btn.action.delete {
  font-size: 1.25rem;
}

.pin-btn.action.cancel {
  color: var(--gray-500);
}

/* Shake Animation for incorrect PIN */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

.pin-dots.shake .dot {
  border-color: var(--color-expense) !important;
  background: var(--color-expense-bg) !important;
}

/* ============================================================
   FORECAST & WEALTH GAUGES STYLES
   ============================================================ */
.wealth-container {
  padding: 8px 0;
}

.wealth-gauge-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.wealth-gauge-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.wealth-gauge-wrapper {
  position: relative;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
}

.wealth-gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.wealth-gauge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
}

/* Event List Styles */
.forecast-event-card {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.forecast-event-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.forecast-event-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
}

.forecast-event-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.forecast-event-amt {
  font-weight: 700;
  font-size: 13px;
}
.forecast-event-amt.income {
  color: var(--color-income);
}
.forecast-event-amt.expense {
  color: var(--color-expense);
}

.btn-delete-event {
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-delete-event:hover {
  color: var(--color-expense);
  background: var(--color-expense-bg);
}

/* Blurring for Privacy Mode on wealth metrics */
.privacy-active .wealth-gauge-text,
.privacy-active #emergency-current-val,
.privacy-active #fire-current-val {
  filter: blur(8px) !important;
  user-select: none !important;
  pointer-events: none !important;
}

/* --- Debts & Loan Management --- */
.debt-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.debt-item:hover {
  background: var(--gray-50);
  border-color: var(--blue-600);
}
:root[data-theme="dark"] .debt-item:hover {
  background: rgba(255, 255, 255, 0.02);
}
.debt-item.active {
  border-color: var(--blue-600);
  background: rgba(37, 99, 235, 0.04);
}
.debt-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.debt-item-name {
  font-weight: 600;
  color: var(--text-main);
}
.debt-item-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.debt-item-payment {
  font-weight: 700;
  color: var(--color-expense);
}

/* --- Receipt Upload Drag & Drop Zone --- */
.receipt-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  background: var(--gray-50);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
:root[data-theme="dark"] .receipt-dropzone {
  background: rgba(255, 255, 255, 0.01);
}
.receipt-dropzone.drag-over {
  border-color: var(--blue-600);
  background: rgba(37, 99, 235, 0.05);
}
.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.dropzone-info {
  font-size: var(--fs-xs);
  opacity: 0.8;
}
.hidden-file-input {
  display: none !important;
}
.receipt-preview-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}
.receipt-filename {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--blue-600);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}
.btn-delete-receipt {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-md);
  padding: 4px;
  border-radius: 40%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.btn-delete-receipt:hover {
  color: var(--color-danger);
  background: var(--color-expense-bg);
}

/* Receipt Indicator in tables */
.has-receipt-indicator {
  cursor: pointer;
  color: var(--blue-600);
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.has-receipt-indicator:hover {
  opacity: 1;
}

/* Modal Large override */
@media (min-width: 769px) {
  .modal-large {
    width: 60% !important;
    max-width: 800px;
  }
}
.receipt-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  transition: transform 0.3s ease;
}
.receipt-pdf-frame {
  width: 100%;
  height: 60vh;
  border: none;
}





