/* ==========================================
   MultiToolBox - Main Stylesheet
   Dark theme with Indigo/Violet accents
   ========================================== */

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

:root {
  --bg:          #0a0e1a;
  --surface:     #111827;
  --surface2:    #1f2937;
  --surface3:    #273344;
  --border:      #374151;
  --border-light:#4b5563;
  --accent:      #6366f1;
  --accent-dark: #4f46e5;
  --accent-hover:#818cf8;
  --secondary:   #8b5cf6;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --income:      #22c55e;
  --expense:     #ef4444;
  --warning:     #f59e0b;
  --info:        #3b82f6;
  --sidebar-w:   260px;
  --sidebar-coll: 68px;
  --header-h:    64px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --transition:  0.22s cubic-bezier(.4,0,.2,1);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ---- Layout ---- */
#app { display: flex; height: 100vh; overflow: hidden; overscroll-behavior: none; }

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), min-width var(--transition);
  overflow: hidden;
  z-index: 100;
  position: relative;
}

#sidebar.collapsed {
  width: var(--sidebar-coll);
  min-width: var(--sidebar-coll);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 0 16px rgba(99,102,241,0.4);
}

.sidebar-title {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  background: linear-gradient(90deg, var(--accent-hover), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: opacity var(--transition);
}

#sidebar.collapsed .sidebar-title { opacity: 0; pointer-events: none; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 20px 4px;
  white-space: nowrap;
  transition: opacity var(--transition);
}

#sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  transition: background var(--transition), color var(--transition);
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.1));
  color: var(--accent-hover);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  margin-left: 0;
}

.nav-icon { width: 20px; height: 20px; min-width: 20px; flex-shrink: 0; }
.nav-label { font-size: 13.5px; font-weight: 500; transition: opacity var(--transition); }
#sidebar.collapsed .nav-label { opacity: 0; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ---- Main ---- */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left var(--transition);
}

/* ---- Header ---- */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

#sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

#sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

.header-page-info { flex: 1; }
#page-title { font-size: 18px; font-weight: 700; line-height: 1.2; }
#page-subtitle { font-size: 12px; color: var(--text-muted); }

.header-date {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--surface2);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ---- Content ---- */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
  overscroll-behavior-y: auto;
}

#page-content { max-width: 1400px; margin: 0 auto; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

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

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  margin-bottom: 0;
}

.stat-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.income-icon  { background: rgba(34,197,94,0.15); color: var(--income); }
.expense-icon { background: rgba(239,68,68,0.15); color: var(--expense); }
.savings-icon { background: rgba(99,102,241,0.15); color: var(--accent); }
.balance-icon { background: rgba(139,92,246,0.15); color: var(--secondary); }

.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 700; }
.income-color  { color: var(--income) !important; }
.expense-color { color: var(--expense) !important; }

/* ---- Dashboard Grid ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Chart compact layout */
.chart-card-inner { display: flex; align-items: center; gap: 20px; padding: 8px 0; }
.chart-side { width: 160px; min-width: 160px; height: 160px; position: relative; }
.chart-side canvas { width: 160px !important; height: 160px !important; }
.legend-side { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-label { flex: 1; color: var(--text-muted); }
.legend-value { font-weight: 600; }

/* Upcoming */
.upcoming-filter { display: flex; gap: 8px; margin-left: auto; }
.upcoming-filter-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted); font-size: 12px;
  cursor: pointer; transition: all var(--transition);
}
.upcoming-filter-btn.active { background: var(--surface3); color: var(--text); border-color: var(--accent); }
.filter-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.upcoming-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.upcoming-list-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; max-height: 235px; overflow-y: auto; }
.upcoming-item { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface2); border-radius: var(--radius-sm); transition: background var(--transition); }
.upcoming-item:hover { background: var(--surface3); }
.upcoming-dot { width: 8px; height: 8px; min-width: 8px; border-radius: 50%; }
.upcoming-info { flex: 1; min-width: 0; }
.upcoming-title { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upcoming-meta { font-size: 11px; color: var(--text-muted); }
.upcoming-badge { flex-shrink: 0; }

/* Budget table */
.budget-table-container { overflow-x: auto; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.progress-bar-container { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.progress-label { font-size: 11px; color: var(--text-muted); display: block; margin-top: 2px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text);
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover { background: var(--surface3); border-color: var(--border-light); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent)); box-shadow: 0 0 16px rgba(99,102,241,0.4); }

.btn-secondary { background: var(--surface2); color: var(--text-muted); }
.btn-secondary:hover { color: var(--text); }
.btn-secondary.active { background: var(--surface3); color: var(--accent-hover); border-color: var(--accent); }

.btn-danger { background: rgba(239,68,68,0.1); color: var(--expense); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success { background: rgba(34,197,94,0.15); color: var(--income); border-color: rgba(34,197,94,0.3); }

.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ---- Tables ---- */
.table-container { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.filter-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.row-inactive { opacity: 0.5; }
.actions-cell { display: flex; gap: 4px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted) !important; }
.opacity-50 { opacity: 0.5; }
.line-through { text-decoration: line-through; }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.tab:hover { background: var(--surface2); color: var(--text); }
.tab.active { background: var(--surface2); color: var(--accent-hover); border: 1px solid var(--border); }

.tab-content-area { /* wrapper for tab content */ }
.tab-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.tab-summary { font-size: 13px; color: var(--text-muted); }

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.form-control::placeholder { color: var(--text-dim); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 60px; }

/* ── Date input : icône blanche + calendrier modernisé ── */
input[type="date"].form-control {
  cursor: pointer;
  color-scheme: dark;
}
input[type="date"].form-control::-webkit-calendar-picker-indicator {
  filter: brightness(0) invert(1);
  opacity: 0.8;
  cursor: pointer;
  padding: 2px;
  transition: opacity 0.15s;
}
input[type="date"].form-control::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 13px; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

/* Color picker */
.color-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.color-option {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
}
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 0 2px var(--accent); }

/* Type selector */
.type-selector { display: flex; gap: 8px; flex-wrap: wrap; }
.type-option { cursor: pointer; }
.type-option input { display: none; }
.type-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  transition: all var(--transition);
  background: var(--surface2);
}
.type-option input:checked + .type-label {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: rgba(99,102,241,0.1);
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--income); }
.badge-danger  { background: rgba(239,68,68,0.15); color: var(--expense); }
.badge-muted   { background: var(--surface2); color: var(--text-dim); }
.badge-info    { background: rgba(59,130,246,0.15); color: var(--info); }
.badge-cat     { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.25s cubic-bezier(.34,1.56,.64,1);
}

.modal.modal-lg {
  max-width: 780px;
}

@keyframes modalIn {
  from { transform: scale(0.92) translateY(-10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

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

.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--border); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 2000;
  transition: bottom 0.35s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
}

.toast.show { bottom: 32px; }
.toast-success { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); color: var(--income); }
.toast-error   { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: var(--expense); }
.toast-info    { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.4); color: var(--accent-hover); }

/* ---- Calendar ---- */
.calendar-card { padding: 0; overflow: hidden; }

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.calendar-month-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--text);
  letter-spacing: -0.01em;
}

.cal-finance-toggle.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cal-finance-toggle.active:hover { background: var(--accent-hover); }

.calendar-legend {
  display: flex;
  gap: 16px;
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--surface);
}
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.cal-pill { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* Agenda list modal filters */
.cal-list-filters { display: flex; gap: 8px; }

.calendar-grid {
  padding: 12px 16px;
  overflow: hidden;
}

@keyframes calSlideInFromRight {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes calSlideInFromLeft {
  from { transform: translateX(-40px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.cal-anim-from-right { animation: calSlideInFromRight 0.2s ease forwards; }
.cal-anim-from-left  { animation: calSlideInFromLeft  0.2s ease forwards; }

.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.cal-day-name {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0;
}

.cal-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-cell {
  min-height: 90px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
  overflow: hidden;
}
.cal-cell:hover { border-color: var(--accent); background: var(--surface3); }
.cal-cell.cal-empty { background: transparent; cursor: default; border: none; }
.cal-cell.cal-today { border-color: var(--accent); background: rgba(99,102,241,0.07); }

.cal-day-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-align: right;
}
.cal-cell:hover .cal-day-num { color: var(--text-muted); }

.cal-today-num {
  background: var(--accent);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}
.cal-add-btn {
  display: none;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.cal-add-btn:hover { background: var(--accent-hover); transform: scale(1.1); }
.cal-cell:hover .cal-add-btn { display: flex; }

.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event-pill {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  transition: filter var(--transition);
  line-height: 1.4;
}
.cal-event-pill:hover { filter: brightness(0.85); }
.cal-more { font-size: 10px; color: var(--text-dim); text-align: right; margin-top: 2px; font-weight: 500; }
.cal-more:hover { color: var(--accent); }

.cal-day-modal-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter var(--transition);
}
.cal-day-modal-event:hover { filter: brightness(0.88); }
.cal-day-modal-title { font-size: 14px; font-weight: 500; color: var(--text); }
.cal-day-modal-amount { font-size: 13px; font-weight: 600; color: var(--text-muted); }

/* Detail modal rows */
.budget-row-clickable:hover td { background: var(--surface3); }

.budget-detail-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.budget-detail-info { display: flex; flex-direction: column; gap: 2px; }
.budget-detail-name { font-size: 14px; font-weight: 500; color: var(--text); }
.budget-detail-sub { font-size: 11px; color: var(--text-dim); }
.budget-detail-amount { font-size: 14px; font-weight: 600; white-space: nowrap; }
.budget-detail-total { display: flex; justify-content: space-between; padding-top: 10px; font-weight: 700; font-size: 14px; color: var(--text); border-top: 1px solid var(--border); margin-top: 4px; }
.budget-detail-group-header { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); padding: 6px 0 4px; border-bottom: 1px solid var(--border); margin-top: 4px; }

.detail-rows { display: flex; flex-direction: column; gap: 12px; }
.detail-row { display: flex; flex-direction: column; gap: 3px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-value-highlight { font-size: 18px; font-weight: 700; color: var(--text); }

/* ---- Credit Cards v2 ---- */
.credit-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }

.credit-card2 {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.credit-card2:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.35); }
.credit-card-inactive { opacity: 0.45; }

.sub-category-group { margin-bottom: 28px; }

/* Expenses timeline */
.exp-timeline { display: flex; flex-direction: column; gap: 20px; }
.exp-day-group { background: var(--surface2); border-radius: var(--radius); overflow: hidden; }
.exp-day-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
}
.exp-day-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.exp-day-total { font-size: 13px; font-weight: 700; color: var(--expense-color, #ef4444); }
.exp-day-rows { display: flex; flex-direction: column; }
.exp-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.exp-row:last-child { border-bottom: none; }
.exp-row:hover { background: var(--surface3); }
.exp-cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.exp-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.exp-row-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-row-desc { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-row-cat { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 99px; border: 1px solid; white-space: nowrap; flex-shrink: 0; }
.exp-row-amount { font-size: 14px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.exp-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.sub-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.sub-category-header::before {
  content: '';
  display: block;
  width: 3px;
  height: 14px;
  border-radius: 99px;
  flex-shrink: 0;
  background: currentColor;
}
.sub-category-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  opacity: 0.5;
}

.cc2-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc2-name { font-size: 15px; font-weight: 700; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc2-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.cc2-mid { display: flex; align-items: baseline; justify-content: space-between; }
.cc2-monthly { font-size: 20px; font-weight: 800; line-height: 1; }
.cc2-monthly-unit { font-size: 12px; font-weight: 500; opacity: 0.75; margin-left: 2px; }
.cc2-pct { font-size: 13px; font-weight: 700; }

.cc2-bar-wrap { background: var(--surface3); border-radius: 99px; height: 8px; overflow: hidden; }
.cc2-bar { height: 100%; border-radius: 99px; transition: width 0.6s ease; }

.cc2-stats { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 10px; gap: 8px; }
.cc2-stat { display: flex; flex-direction: column; gap: 3px; }
.cc2-stat-right { text-align: right; }
.cc2-stat-label { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.cc2-stat-value { font-size: 12px; font-weight: 600; color: var(--text); }

/* ---- Events Page ---- */
.events-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.events-form-card, .events-list-card { margin-bottom: 0; }

.filter-group { display: flex; gap: 4px; }

.event-date-group { margin-bottom: 16px; }
.event-date-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 6px;
  padding: 0 2px;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  overflow: hidden;
  transition: background var(--transition);
  border: 1px solid var(--border);
}

.event-item:hover { background: var(--surface3); }
.event-item.event-completed { opacity: 0.55; }

.event-color-bar { width: 4px; min-width: 4px; height: 100%; min-height: 52px; flex-shrink: 0; }
.event-content { flex: 1; padding: 10px 12px; min-width: 0; }
.event-header-row { display: flex; align-items: center; gap: 6px; }
.event-type-icon { flex-shrink: 0; }
.event-title { font-weight: 500; font-size: 13.5px; flex: 1; }
.event-time { font-size: 11px; color: var(--text-muted); background: var(--surface3); padding: 2px 6px; border-radius: 4px; }
.event-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.event-actions { display: flex; gap: 4px; padding: 8px; flex-shrink: 0; }

/* ---- Bank Page ---- */
.bank-layout { display: flex; flex-direction: column; gap: 20px; }

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

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}

.drop-zone-icon { color: var(--text-dim); }
.drop-zone-text { display: flex; flex-direction: column; gap: 4px; }
.drop-zone-text strong { font-size: 15px; color: var(--text); }
.drop-zone-text span { font-size: 13px; color: var(--text-muted); }
.drop-zone-hint { font-size: 12px; color: var(--text-dim); }

.parse-options { padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }
.mapping-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.recurring-item {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    var(--surface2);
  border-radius: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.recurring-info { flex: 1; min-width: 200px; }
.recurring-name { font-weight: 700; font-size: 16px; letter-spacing: 0.1px; margin-bottom: 6px; }
.recurring-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; margin-bottom: 8px; }
.recurring-amount { font-size: 24px; line-height: 1; font-weight: 800; color: var(--expense); white-space: nowrap; min-width: 110px; text-align: right; }

.recurring-confidence { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.confidence-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.confidence-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.confidence-label { font-size: 12px; color: var(--text-muted); text-align: right; }

.recurring-occurrences { display: flex; flex-wrap: wrap; gap: 8px; }
.occurrence-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.12);
  color: var(--text);
}
.occurrence-chip-more {
  background: transparent;
  color: var(--text-muted);
}
.recurring-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ---- Finance mobile list ---- */
.fin-mobile-list { display: flex; flex-direction: column; }
.fin-mobile-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.fin-mobile-item:last-child { border-bottom: none; }
.fin-mobile-item:active { background: var(--surface2); }
.fin-inactive { opacity: 0.5; }
.fin-mobile-row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; gap: 8px; }
.fin-mobile-row2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fin-mobile-name { font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-mobile-amount { font-size: 14px; font-weight: 700; flex-shrink: 0; }
.fin-mobile-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; flex: 1; min-width: 0; }
.fin-mobile-day { font-size: 11px; color: var(--text-muted); }
.fin-mobile-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .events-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #content { padding: 16px; }
  .calendar-card { font-size: 12px; }
  .cal-cell { min-height: 60px; }
  .credit-cards-grid { grid-template-columns: 1fr; }
}

/* Overlay mobile pour fermer la sidebar */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 299;
}

@media (max-width: 768px) {
  #sidebar-overlay { display: block; }

  /* Sidebar : slide depuis la gauche */
  #sidebar {
    position: fixed;
    height: 100dvh;
    z-index: 300;
    transform: translateX(0);
    transition: transform 0.25s ease;
  }
  #sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  #main { margin-left: 0 !important; width: 100%; }
  #main.sidebar-collapsed { margin-left: 0 !important; }

  /* Header */
  #header { padding: 0 12px; gap: 8px; }
  #page-subtitle { display: none; }
  .header-date { display: none; }

  /* Contenu */
  #content { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; }

  /* Tables scrollables */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Tabs */
  .tabs { flex-wrap: wrap; gap: 4px; }
  .tab { font-size: 12px; padding: 6px 10px; }
  .tab-toolbar { flex-wrap: wrap; gap: 8px; }
  .tab-summary { font-size: 12px; }

  /* Calendar */
  .calendar-nav { gap: 6px; }
  .cal-day-name { font-size: 10px; }
  .cal-cell { min-height: 50px; padding: 2px; }
  .cal-day-num { font-size: 11px; }
  .cal-event-pill { font-size: 9px; }

  /* Modal → sheet depuis le bas */
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; max-height: 90dvh; overflow-y: auto; }
  .modal-overlay { align-items: flex-end; }

  /* Forms */
  .form-row { flex-direction: column; }
  .type-selector { flex-direction: column; }

  /* Auth */
  .auth-card { padding: 24px 18px; }

  /* Calendrier accessible depuis le dashboard → onglet masqué sur mobile */
  .nav-item[data-page="calendar"] { display: none; }

  /* Bouton "+" ajout depuis cellule masqué sur mobile */
  .cal-add-btn { display: none; }

  /* Upcoming events — 1 colonne, no horizontal overflow */
  .upcoming-list-row {
    grid-template-columns: 1fr;
    max-height: none;
    overflow-x: hidden;
  }
  .upcoming-item { padding: 8px 10px; gap: 8px; }
  .upcoming-title { font-size: 12.5px; }
  .upcoming-meta { font-size: 11px; }
  .upcoming-badge .badge { font-size: 10px; padding: 2px 6px; }

  /* Header card : filtres sur nouvelle ligne si besoin */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .upcoming-filter { margin-left: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .upcoming-list-row { grid-template-columns: 1fr; }
  /* Garder le layout horizontal camembert + légende, mais compacté */
  .chart-card-inner { gap: 12px; padding: 4px 0; align-items: center; }
  .chart-side { width: 110px; min-width: 110px; height: 110px; }
  .chart-side canvas { width: 110px !important; height: 110px !important; }
  .legend-side { gap: 6px; }
  .legend-item { font-size: 11.5px; gap: 6px; }
  .legend-dot { width: 8px; height: 8px; }
  .legend-value { font-size: 11.5px; }
}


/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#page-content > * { animation: fadeIn 0.25s ease both; }
#page-content > *:nth-child(1) { animation-delay: 0ms; }
#page-content > *:nth-child(2) { animation-delay: 40ms; }
#page-content > *:nth-child(3) { animation-delay: 80ms; }
#page-content > *:nth-child(4) { animation-delay: 120ms; }

/* ============================================================
   AUTH PAGE
   ============================================================ */

#auth-page {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.auth-container {
  width: 100%; max-width: 420px;
}

.auth-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 32px;
  display: flex; flex-direction: column; gap: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Logo block */
.auth-logo-block { text-align: center; }
.auth-logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 14px;
  font-size: 26px; font-weight: 800; color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.auth-app-title { font-size: 22px; font-weight: 800; color: var(--text); margin: 0 0 4px; }
.auth-app-sub   { font-size: 13px; color: var(--text-dim); margin: 0; }

/* Tabs */
.auth-tabs {
  display: flex;
  background: var(--surface3);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.auth-tab.active {
  background: var(--surface2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Error */
.auth-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.35);
  color: #f87171;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

/* Form */
.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-pw-wrap { position: relative; }
.auth-pw-wrap .form-control { padding-right: 40px; }
.auth-pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); padding: 4px;
  display: flex; align-items: center;
  transition: color var(--transition);
}
.auth-pw-toggle:hover { color: var(--text); }

.auth-submit { width: 100%; padding: 11px; font-size: 14px; font-weight: 700; margin-top: 4px; }

/* ============================================================
   SIDEBAR — USER BLOCK
   ============================================================ */

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.sidebar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-user-name  { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-collapsed .sidebar-user-info { display: none; }

.sidebar-logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); padding: 6px; border-radius: 8px;
  display: flex; align-items: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.sidebar-logout-btn:hover { background: rgba(239,68,68,0.15); color: #f87171; }
.sidebar-collapsed .sidebar-logout-btn { display: none; }
