:root {
  --bg: #f7f9fc;
  --bg-gradient: radial-gradient(140% 140% at 10% 10%, #f1f5ff 0%, #f7f9fc 40%, #ffffff 100%);
  --sidebar-bg: linear-gradient(180deg, #eef2fb 0%, #f7f9ff 100%);
  --panel: #ffffff;
  --panel-strong: #f1f4fb;
  --border: #dfe5f1;
  --text: #0c1221;
  --muted: #5f6b7a;
  --accent: #2fd180;
  --accent-2: #6fe0ff;
  --warning: #ffb020;
  --danger: #ff6b6b;
  --success: #3be8b0;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --font: "Sora", "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Roboto Mono", monospace;
  --nav-hover: rgba(12, 18, 33, 0.04);
  --toast-bg: #e5f8f0;
  --toast-color: #0c1221;
  --text-on-accent: #062211;

  /* Stratégie z-index cohérente */
  --z-base: 1;
  --z-sticky: 50;
  --z-fixed: 100;
  --z-sidebar: 100;
  --z-header: 90;
  --z-dropdown: 150;
  --z-modal: 200;
  --z-toast: 250;
  --z-auth: 300;
  --z-cookie: 350;
}

:root[data-theme="dark"] {
  --bg: #0b1221;
  --bg-gradient: radial-gradient(120% 120% at 20% 20%, #142341 0%, #0b1221 40%, #090f1c 100%);
  --sidebar-bg: linear-gradient(180deg, rgba(18, 28, 47, 0.9), rgba(12, 19, 33, 0.95));
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e5ecff;
  --muted: #9fb2d4;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --nav-hover: rgba(255, 255, 255, 0.04);
  --toast-bg: rgba(47, 209, 128, 0.18);
  --toast-color: #dfffea;
  --text-on-accent: #062211;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* Requis pour le layout 4 zones fixes - pages secondaires (legal.html) font override */
}

body {
  font-family: var(--font);
  background: var(--bg-gradient);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

/* Système typographique équilibré */
h1 { font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.3px; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 17px; font-weight: 600; line-height: 1.4; }

p { margin: 0; font-size: 15px; line-height: 1.5; }

.label { font-size: 14px; font-weight: 500; }
.mini { font-size: 13px; font-weight: 400; color: var(--muted); margin: 4px 0 0; }
.eyebrow { font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; font-weight: 600; color: var(--muted); }

/* ============ LAYOUT DESKTOP - 4 ZONES FIXES ============ */
.app-shell {
  display: block;
  height: 100%;
  width: 100%;
}

/* 1. SIDEBAR - Menu de gauche fixe */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 20px 0;
  position: relative;
}

.brand::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 20px rgba(47, 209, 128, 0.5);
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--text-on-accent);
  letter-spacing: 0.5px;
  box-shadow: 0 8px 24px rgba(47, 209, 128, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.2px;
  color: var(--text);
  position: relative;
  line-height: 1;
}

.brand-name::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 85%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
}

.sidebar-summary {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(47, 209, 128, 0.08), rgba(111, 224, 255, 0.06));
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.summary-meta {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link:hover {
  border-color: var(--border);
  background: var(--nav-hover);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link.active {
  border-color: rgba(47, 209, 128, 0.45);
  background: rgba(47, 209, 128, 0.14);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(47, 209, 128, 0.18);
}

.tips {
  margin-top: auto;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(47, 209, 128, 0.18), rgba(111, 224, 255, 0.16));
  border: 1px solid var(--border);
}

.tip-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.tip-text {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  opacity: 0.86;
  line-height: 1.4;
}

/* 2. HEADER - Barre du haut fixe (titre, notifications, nouvelle transaction) */
.page-header {
  position: fixed;
  top: 0;
  left: 280px;
  right: 0;
  height: 70px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  z-index: var(--z-header);
}

.page-header h1 {
  margin: 0;
}

/* 3. MAIN - Contenu principal scrollable */
.main {
  position: fixed;
  top: 70px;
  left: 280px;
  right: 0;
  bottom: 45px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* 4. FOOTER - voir section footer plus bas */

.subtitle {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-on-accent);
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  letter-spacing: 0;
  box-sizing: border-box;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: var(--text-on-accent);
}

.btn.primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn.secondary {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--panel);
  transform: translateY(-1px);
}

.load-more-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  background: var(--panel-strong);
  border-color: rgba(47, 209, 128, 0.3);
  transform: translateY(-1px);
}

.btn.full {
  width: 100%;
}

.btn:active {
  transform: translateY(1px);
}

.panel {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.panel.visible {
  display: flex;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

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

.card-head .label {
  margin: 0;
}

.stat .label {
  margin: 0;
  color: var(--muted);
}

.value {
  margin: 8px 0 2px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.trend {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.trend.positive {
  color: var(--success);
}

.trend.negative {
  color: var(--danger);
}

/* .mini défini dans le système typographique ligne 68 */

.highlight {
  border: 1px solid rgba(47, 209, 128, 0.4);
}

.progress {
  height: 10px;
  background: var(--panel-strong);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.progress-section .progress {
  flex: 1;
}

.progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  min-width: 45px;
  text-align: right;
}

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

.flow {
  display: grid;
  gap: 8px;
}

.flow-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel-strong);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.flow-item p:first-child {
  font-weight: 400;
}

.flow-item.total {
  border-style: dashed;
  font-weight: 500;
}

.flow-value {
  font-size: 15px;
  font-weight: 600;
}

.flow-value.positive {
  color: var(--success);
}

.flow-value.negative {
  color: var(--danger);
}

.alerts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.alert {
  background: var(--panel-strong);
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-on-accent);
  font-weight: 600;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
}

.pill.neutral {
  background: rgba(111, 224, 255, 0.85);
}

.pill.warning {
  background: rgba(255, 176, 32, 0.9);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.account-card {
  display: grid;
  gap: 6px;
}

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

.account-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #ffffff;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.account-icon svg {
  width: 100%;
  height: 100%;
  max-width: 38px;
  max-height: 38px;
}

.account-icon svg[viewBox="0 0 24 24"] {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.account-icon .fill {
  fill: currentColor;
  stroke: none;
}

.account-info {
  display: grid;
  gap: 2px;
  flex: 1;
}

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

.account-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.institution-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  opacity: 0.9;
}

.institution-logo svg {
  width: 40px;
  height: 40px;
}

.account-balance {
  font-size: 22px;
  font-weight: 600;
  margin: 8px 0 0;
}

/* Sections de comptes */
.account-section-header {
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.account-section-header:first-child {
  margin-top: 0;
}

.account-section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.account-section-list {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}

/* Items de compte dans les sections */
.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.account-item:last-of-type {
  border-bottom: none;
}

.account-item:hover {
  background: var(--panel-strong);
}

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

.account-icon-small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  flex-shrink: 0;
}

.account-icon-small svg {
  width: 100%;
  height: 100%;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
}

/* Icônes génériques (type stroke) */
.account-icon-small svg[viewBox="0 0 24 24"] {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Logos de marques (ne pas modifier le fill ni le stroke) */
.account-icon-small svg:not([viewBox="0 0 24 24"]) {
  width: 100%;
  height: auto;
  max-width: 26px;
}

.account-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.account-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-item-bank {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.account-item-balance {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  min-width: 80px;
}

.account-item-more {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1;
}

.account-item-more:hover {
  background: var(--panel);
  color: var(--text);
}

.account-item-more.active {
  background: var(--panel);
  color: var(--text);
}

/* Menu contextuel des comptes */
.account-context-menu {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  min-width: 240px;
  z-index: var(--z-dropdown);
  display: none;
}

.account-context-menu.show {
  display: block;
}

.account-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background 0.15s ease;
}

.account-context-menu-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.account-context-menu-item:hover {
  background: var(--panel-strong);
}

.account-context-menu-item.danger {
  color: var(--danger);
}

.account-context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.account-context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Footer de section */
.account-section-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.account-add-button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.account-add-button:hover {
  background: var(--panel-strong);
}

.account-add-button svg {
  flex-shrink: 0;
}

.account-section-total {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-section-total-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.account-section-total-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.account-empty-state {
  padding: 16px;
}

.account-empty-state .empty-state {
  text-align: left;
  padding: 0;
}

.budget-card {
  display: grid;
  gap: 6px;
}

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

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

.budget-values {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-head, .table-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr 1fr 1fr;
  gap: 8px;
  padding: 12px 14px;
}

.table-head {
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.table-row {
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.amount {
  font-weight: 600;
}

.amount.positive {
  color: var(--success);
}

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

.form-card {
  display: grid;
  gap: 16px;
}

.form-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}

.form-row {
  display: grid;
  gap: 6px;
  margin: 0;
}

.form-row.dual {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.form-row.dual .form-field label {
  margin: 0 0 4px;
}

.form-row.dual .form-field {
  display: grid;
  gap: 4px;
}

.form-row label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.form-card .form-row + .form-row {
  margin-top: 8px;
}

.form-card .btn.full,
.form-card button.full {
  margin-top: 10px;
}

input, select {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px; /* 16px minimum pour éviter le zoom iOS */
  font-weight: 400;
  height: 44px;
  line-height: 22px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(47, 209, 128, 0.4);
  outline-offset: 1px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Textarea */
textarea {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  box-sizing: border-box;
  resize: vertical;
  min-height: 100px;
  width: 100%;
}

/* Placeholder */
input::placeholder, textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* États disabled */
input:disabled, select:disabled, textarea:disabled {
  background: var(--panel);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/* États de validation */
input.error, select.error, textarea.error {
  border-color: var(--danger);
}

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

/* Checkbox inline avec label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
}

/* Mini text avec margin-top */
.mini.mt {
  margin-top: 10px;
}

.mini.mb {
  margin-bottom: 16px;
}

/* Range slider custom */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
  padding: 0;
  border: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Range value display */
.range-with-value {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-with-value input[type="range"] {
  flex: 1;
}

.range-value {
  min-width: 40px;
  text-align: center;
  font-weight: 600;
  color: var(--accent);
  background: var(--panel-strong);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Grille des paramètres d'affichage - uniformisée */
.settings-grid {
  grid-template-columns: repeat(3, 1fr);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 80px;
  padding: 18px;
}

.setting > div {
  flex: 1;
  min-width: 0;
}

.setting .label {
  margin: 0 0 4px;
}

.setting .mini {
  margin: 0;
  line-height: 1.4;
}

.setting select {
  min-width: 120px;
  flex-shrink: 0;
}

.setting .switch {
  flex-shrink: 0;
}

.settings-sections {
  display: grid;
  gap: 28px;
}

.settings-title {
  margin: 12px 0 12px;
  font-size: 18px;
}

.settings-tabs {
  display: grid;
  gap: 14px;
}

.settings-tablist {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-tab {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.settings-tab.active {
  border-color: rgba(47, 209, 128, 0.5);
  background: rgba(47, 209, 128, 0.12);
}

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

.settings-tabpanels {
  position: relative;
}

.settings-panel {
  display: none;
}

.settings-panel.visible {
  display: grid;
  gap: 16px;
  align-items: start;
}

.settings-columns.two {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  align-items: stretch;
}

/* Uniformisation de toutes les cards dans les settings */
.settings-panel .card {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.settings-panel .card h3 {
  margin: 0 0 20px;
  font-size: 17px;
  font-weight: 600;
}

.settings-panel .card .form-row {
  margin-bottom: 16px;
}

.settings-panel .card .form-row label {
  margin-bottom: 6px;
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.settings-panel .card .mini {
  margin: 0 0 16px;
  line-height: 1.5;
}

.settings-panel .card .modal-error {
  margin: 8px 0;
}

.settings-panel .card .btn.full {
  margin-top: auto;
}

/* État vide pour listes */
.settings-panel .card .empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 16px;
  text-align: center;
  background: var(--panel-strong);
  border-radius: 10px;
}

/* Exports - taille réduite */
#tab-exports .form-card {
  max-width: 500px;
}

#tab-exports .btn.primary {
  width: auto;
  max-width: 320px;
  padding: 11px 24px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-list,
.accounts-settings-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 10px;
}

.category-item,
.account-settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.category-label,
.account-settings-name {
  margin: 0;
  font-weight: 600;
}

.category-meta,
.account-settings-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.account-settings-item-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.account-settings-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch {
  position: relative;
  width: 52px;
  height: 28px;
  cursor: pointer;
  display: inline-block;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  margin: 0;
  padding: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  background: var(--panel-strong);
  border-radius: 999px;
  border: 1.5px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  will-change: transform;
}

.switch input:checked + span {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  border-color: var(--accent) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 10px rgba(47, 209, 128, 0.4) !important;
}

.switch input:checked + span::after {
  transform: translateX(23px) translateY(-50%);
  background: #ffffff !important;
}

.switch:hover span::after {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.toast {
  position: fixed;
  bottom: 26px;
  right: 26px;
  background: var(--toast-bg);
  color: var(--toast-color);
  border: 1px solid rgba(47, 209, 128, 0.4);
  padding: 12px 16px;
  border-radius: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.section-head h2 {
  margin: 2px 0 0;
}

.pill.note {
  background: var(--panel-strong);
  color: var(--text);
}

.table-body {
  max-height: 360px;
  overflow: auto;
}

.focus-mode .panel:not(#dashboard):not(#budgets) {
  opacity: 0.2;
  pointer-events: none;
  filter: blur(1px);
}

.focus-mode .nav-link:not([data-link="dashboard"]):not([data-link="budgets"]) {
  opacity: 0.5;
}

.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-auth);
  padding: 20px;
}

/* Masquer complètement le contenu de l'app quand auth est visible */
.auth-screen:not(.hidden) ~ .app-shell,
.auth-screen:not(.hidden) ~ .mobile-menu,
body:has(.auth-screen:not(.hidden)) .sidebar,
body:has(.auth-screen:not(.hidden)) .mobile-header,
body:has(.auth-screen:not(.hidden)) .app-shell {
  display: none !important;
}

/* Logo sur la page d'auth */
.auth-logo {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 32px;
  position: relative;
  display: inline-block;
}

.auth-logo::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 85%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 6px;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.auth-error {
  display: none;
  color: #ff4444;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 68, 68, 0.1);
}

.auth-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: var(--z-modal);
  padding: 20px;
}

.modal.visible {
  display: grid;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  box-shadow: var(--shadow);
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  transition: color 0.2s ease;
}

.close-modal:hover {
  color: var(--text);
}

.modal-form {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.modal-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions .btn {
  flex: 1;
}

/* ============ 4. FOOTER LÉGAL - Barre du bas fixe ============ */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 280px;
  right: 0;
  height: 45px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  z-index: var(--z-base);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-copyright {
  color: var(--muted);
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.footer-links a,
.footer-link-btn {
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color 0.2s;
}

.footer-links a:hover,
.footer-link-btn:hover {
  color: var(--accent);
}

.footer-version {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ============ BANNIÈRE COOKIES / LOI 25 ============ */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  z-index: var(--z-cookie);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.cookie-banner.visible {
  transform: translateY(0);
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.cookie-text {
  flex: 1;
}

.cookie-text strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.cookie-text p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.cookie-text a {
  color: var(--accent);
}

.cookie-actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* ============ MODAL À PROPOS ============ */
.modal-sm {
  width: min(420px, 90vw);
}

.about-content {
  text-align: center;
  padding: 1rem 0;
}

.about-logo {
  margin-bottom: 1.5rem;
}

.about-app-name {
  display: block;
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.about-version {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
}

.about-description {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.about-links {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.about-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.about-footer p {
  margin: 0.25rem 0;
}

.about-made {
  font-size: 0.75rem;
}

/* ============ SECTION AIDE ============ */
.help-section {
  margin-bottom: 1.5rem;
}

.help-section h4 {
  margin-bottom: 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
}

.help-faq {
  background: var(--panel-strong);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.help-faq summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.help-faq summary::-webkit-details-marker {
  display: none;
}

.help-faq summary::after {
  content: "+";
  font-size: 1.2rem;
  color: var(--muted);
  transition: transform 0.2s;
}

.help-faq[open] summary::after {
  content: "−";
}

.help-faq p {
  padding: 0 1rem 1rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-shortcuts {
  list-style: none;
  padding: 0;
  margin: 0;
}

.help-shortcuts li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.help-shortcuts kbd {
  background: var(--panel-strong);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 50px;
  text-align: center;
}

.help-contact {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.help-contact-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.help-contact-item strong {
  font-size: 0.85rem;
  color: var(--text);
}

.help-contact-item a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.help-contact-item a:hover {
  text-decoration: underline;
}

.help-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.help-about {
  text-align: center;
}

/* ============ FORMULAIRE FEEDBACK ============ */
.modal-md {
  width: min(600px, 95vw);
}

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

.char-count {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.file-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.file-upload-zone:hover,
.file-upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(47, 209, 128, 0.05);
}

.file-upload-zone.has-file {
  border-color: var(--accent);
  border-style: solid;
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  pointer-events: none;
}

.file-upload-content svg {
  color: var(--muted);
}

.file-upload-zone.has-file .file-upload-content svg {
  color: var(--accent);
}

.file-name {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

.modal-success {
  color: var(--success);
  font-size: 0.9rem;
  text-align: center;
  padding: 0.75rem;
  background: rgba(59, 232, 176, 0.1);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============ RESPONSIVE TABLETTE PAYSAGE (1024px) ============ */
@media (max-width: 1024px) {
  /* Sidebar plus étroite */
  .sidebar {
    width: 220px;
  }

  /* Ajuster les 3 autres zones */
  .page-header {
    left: 220px;
  }

  .main {
    left: 220px;
  }

  .app-footer {
    left: 220px;
  }

  /* Grilles */
  .settings-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .settings-tablist {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .settings-tab {
    font-size: 13px;
    padding: 8px 12px;
    white-space: nowrap;
  }
}

/* ============ RESPONSIVE TABLETTE PORTRAIT (900px) ============ */
@media (max-width: 900px) {
  /* Sidebar encore plus étroite */
  .sidebar {
    width: 200px;
  }

  .page-header {
    left: 200px;
    padding: 0 24px;
  }

  .main {
    left: 200px;
    padding: 24px;
  }

  .app-footer {
    left: 200px;
    padding: 0 1.5rem;
  }

  /* Grilles réduites */
  .settings-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-columns.two {
    grid-template-columns: 1fr;
  }

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

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

  /* Header ajustements */
  .page-header h1 {
    font-size: 24px;
  }

  .subtitle {
    display: none;
  }

  /* Prévisions - layout en colonne */
  .forecast-container {
    grid-template-columns: 1fr;
  }

  .forecast-input-card {
    grid-row: auto;
  }

  .forecast-results-card,
  .forecast-timeline-card {
    grid-column: 1;
  }
}

/* Header mobile - caché par défaut */
.mobile-header {
  display: none;
}

/* Menu mobile dropdown */
.mobile-menu {
  position: fixed;
  top: 60px;
  right: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: var(--z-dropdown);
  min-width: 200px;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: all 0.2s ease;
}

.mobile-menu.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.mobile-menu-item:hover {
  background: var(--panel-strong);
}

.mobile-menu-item.danger {
  color: var(--danger);
}

.mobile-menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.mobile-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============ RESPONSIVE MOBILE (< 720px) ============ */
@media (max-width: 720px) {
  /* Header mobile visible et sticky */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin: 0 0 12px 0;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    backdrop-filter: blur(20px);
  }

  .mobile-logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.8px;
    color: var(--text);
    position: relative;
  }

  /* Ligne verte sous le logo mobile */
  .mobile-logo::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 85%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    border-radius: 2px;
  }

  /* Actions dans le header mobile */
  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-notification-btn {
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    color: var(--text);
    position: relative;
  }

  .mobile-notification-btn svg {
    width: 20px;
    height: 20px;
    display: block;
  }

  .mobile-notification-btn .notification-badge {
    top: -4px;
    right: -4px;
  }

  .mobile-menu-btn {
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    color: var(--text);
  }

  .mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    display: block;
  }

  /* ====== RESET LAYOUT MOBILE ====== */
  /* Réactiver le scroll sur body pour mobile */
  html, body {
    overflow: auto;
    height: auto;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* ====== SIDEBAR devient BOTTOM NAV ====== */
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 4px;
    border-right: none;
    border-top: 1px solid var(--border);
    background: var(--panel);
    backdrop-filter: blur(20px);
    z-index: var(--z-sidebar);
  }

  /* Masquer éléments non essentiels sur mobile */
  .brand,
  .sidebar-summary,
  .tips,
  #logout-btn,
  .nav-link[data-link="parametres"] {
    display: none;
  }

  /* Navigation horizontale */
  .nav {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
    gap: 2px;
  }

  .nav-link {
    flex-direction: column;
    padding: 8px 6px;
    font-size: 10px;
    gap: 4px;
    flex: 1;
    border-radius: 10px;
    text-align: center;
    min-width: 0;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
  }

  /* ====== HEADER DESKTOP CACHÉ ====== */
  .page-header {
    display: none;
  }

  /* ====== MAIN - Contenu scrollable ====== */
  .main {
    position: static;
    top: auto;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    padding: 16px;
    padding-bottom: 100px; /* Espace pour bottom nav */
    gap: 16px;
    overflow: visible;
  }

  /* ====== FOOTER CACHÉ sur mobile ====== */
  .app-footer {
    display: none;
  }

  /* ====== MOBILE HEADER VISIBLE ====== */
  .mobile-header {
    display: flex;
  }

  /* Masquer le bouton notification desktop */
  .btn-notification {
    display: none !important;
  }

  /* Cartes et stats en 2 colonnes sur mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Réorganisation: Solde/Revenus en haut, Objectif/Dépenses en bas */
  .stats-grid .card.stat:nth-child(1) { order: 1; } /* Solde total */
  .stats-grid .card.stat:nth-child(2) { order: 2; } /* Revenus */
  .stats-grid .card.stat:nth-child(3) { order: 4; } /* Dépenses */
  .stats-grid .card.stat:nth-child(4) { order: 3; } /* Objectif mensuel */

  .card {
    padding: 14px;
    border-radius: 14px;
  }

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

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Valeurs et texte */
  .value {
    font-size: 22px;
  }

  .stat .label {
    font-size: 13px;
  }

  /* Tableau responsive */
  .table-card {
    overflow-x: auto;
  }

  .table-head, .table-row {
    grid-template-columns: 1.5fr 1fr 1fr;
    font-size: 12px;
    padding: 10px 12px;
    min-width: auto;
  }

  /* Masquer colonnes moins importantes */
  .table-head span:nth-child(4),
  .table-head span:nth-child(5),
  .table-row span:nth-child(4),
  .table-row span:nth-child(5) {
    display: none;
  }

  /* Settings mobile */
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .setting {
    min-height: 70px;
    padding: 14px;
    gap: 12px;
  }

  .setting .label {
    font-size: 13px;
  }

  .setting .mini {
    font-size: 11px;
  }

  .settings-columns.two {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Onglets paramètres - scroll horizontal */
  .settings-tablist {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 6px;
    margin: 0 -16px;
    padding: 0 16px 8px;
  }

  .settings-tab {
    flex-shrink: 0;
    font-size: 13px;
    padding: 8px 14px;
  }

  /* Form cards mobile */
  .settings-panel .form-card {
    padding: 16px;
  }

  .settings-panel .form-card h3 {
    font-size: 16px;
  }

  /* Champ date normalisé sur mobile */
  input[type="date"] {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Prévisions mobile */
  .forecast-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .forecast-input-card {
    grid-row: auto;
  }

  .forecast-results-card,
  .forecast-timeline-card {
    grid-column: 1;
  }

  .forecast-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .forecast-stat {
    padding: 12px;
  }

  .forecast-value {
    font-size: 18px;
  }

  /* Comptes mobile */
  .account-item {
    padding: 10px 12px;
  }

  .account-item-balance {
    font-size: 13px;
  }

  .account-item-right {
    gap: 8px;
    padding-right: 4px;
  }

  .account-item-more {
    padding: 6px 10px;
  }

  /* Notifications panel mobile */
  .notifications-panel {
    top: auto;
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 60vh;
  }

  /* Modals mobile - plein écran */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-content.modal-large {
    width: 100%;
    max-height: 90vh;
  }

  .modal-header {
    padding: 16px 20px;
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: var(--z-base);
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .modal-form,
  .modal-body {
    padding: 16px 20px;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--panel);
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    margin: 0 -20px;
    width: calc(100% + 40px);
  }

  /* Toast mobile */
  .toast {
    bottom: 100px;
    right: 16px;
    left: 16px;
    text-align: center;
  }

  /* Footer mobile - déjà géré plus haut */

  /* Cookie banner mobile */
  .cookie-banner {
    padding: 1rem;
  }

  .cookie-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .cookie-actions {
    width: 100%;
    justify-content: center;
  }

  /* Flow items */
  .flow-item {
    padding: 10px 12px;
    font-size: 13px;
  }

  .flow-value {
    font-size: 14px;
  }

  /* Alerts */
  .alert {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Budgets */
  .budget-card {
    padding: 14px;
  }

  .budget-top .label {
    font-size: 13px;
  }

  /* Section heads */
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-head h2 {
    font-size: 18px;
  }

  /* Bouton export */
  #tab-exports .form-card {
    max-width: 100%;
  }

  #tab-exports .btn.primary {
    width: 100%;
    max-width: 100%;
  }

  /* Centrage texte boutons sur mobile */
  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .btn.full {
    justify-content: center;
  }

  .settings-panel .form-card .btn.full {
    padding: 14px 20px;
  }
}

/* Boutons d'action sur les cartes */
.card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-icon, .btn-icon-small {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-small {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-icon:hover, .btn-icon-small:hover {
  background: var(--panel);
  transform: translateY(-1px);
}

.btn-icon.active {
  background: var(--panel);
  color: var(--text);
}

.btn-icon.danger:hover, .btn-icon-small.danger:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--danger);
}

.transaction-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* Modal large pour vues détaillées */
.modal-large {
  width: min(700px, 100%);
  max-height: 85vh;
}

.modal-body {
  padding: 24px;
  display: grid;
  gap: 20px;
}

/* Section dans modal */
.modal-section {
  display: grid;
  gap: 12px;
}

.modal-section h3 {
  margin: 0 0 4px;
}

/* Stats de détail */
.account-details-stats,
.budget-details-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.detail-stat {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.detail-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.detail-value {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.detail-value-small {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--font-mono);
}

.detail-value-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* Liste de transactions dans modal */
.transactions-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.transaction-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: center;
  transition: all 0.2s ease;
}

.transaction-detail-row:hover {
  background: var(--panel);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.transaction-detail-info {
  display: grid;
  gap: 4px;
}

.transaction-detail-label {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}

.transaction-detail-meta {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.transaction-detail-amount {
  font-weight: 600;
  font-size: 17px;
}

/* Actions en bas de modal */
.modal-actions-bottom {
  display: flex;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.modal-actions-bottom .btn {
  flex: 1;
}

.btn.danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.btn.danger:hover {
  background: rgba(255, 107, 107, 0.25);
  border-color: var(--danger);
}

/* État vide */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 20px;
  font-size: 14px;
  font-weight: 400;
}

/* Amélioration de la sous-info des comptes */
.account-details-bank {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.budget-details-period {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

/* Séparateur horizontal */
.divider {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* Cartes cliquables */
.account-card,
.budget-card {
  cursor: pointer;
  transition: all 0.2s ease;
}

.account-card:hover,
.budget-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  border-color: rgba(47, 209, 128, 0.3);
}

/* Table rows cliquables */
.table-row {
  cursor: pointer;
  transition: all 0.15s ease;
}

.table-row:hover {
  background: var(--panel-strong);
}

.table-row:last-child {
  border-bottom: none;
}

/* Police monospace pour les montants */
.value,
.account-balance,
.flow-value,
.amount,
.detail-value,
.transaction-detail-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Masquer les montants pendant le chargement de la devise */
body.currency-loading .value,
body.currency-loading .account-balance,
body.currency-loading .flow-value,
body.currency-loading .amount,
body.currency-loading .detail-value,
body.currency-loading .transaction-detail-amount,
body.currency-loading .summary-value,
body.currency-loading #sidebar-total-balance {
  color: transparent;
  background: var(--border);
  border-radius: 4px;
  animation: pulse-loading 1.5s ease-in-out infinite;
}

@keyframes pulse-loading {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.3; }
}

/* Bouton de notification avec cloche */
.btn-notification {
  position: relative;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-notification:hover {
  background: var(--panel);
  transform: translateY(-1px);
}

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

.bell-icon {
  width: 20px;
  height: 20px;
  display: block;
  color: var(--text);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-badge.active {
  opacity: 1;
  transform: scale(1);
  animation: notification-pulse 2s ease-in-out infinite;
}

@keyframes notification-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 8px rgba(255, 107, 107, 0);
  }
}

@keyframes notification-bell-ring {
  0%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(12deg); }
  20%, 40% { transform: rotate(-12deg); }
  50% { transform: rotate(0); }
}

.btn-notification.has-notifications .bell-icon {
  animation: notification-bell-ring 1s ease-in-out;
  animation-iteration-count: 3;
}

/* Panneau de notifications */
.notifications-panel {
  position: fixed;
  top: 80px;
  right: 32px;
  width: min(420px, calc(100vw - 64px));
  max-height: 600px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
}

.notifications-panel.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

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

.notifications-header h3 {
  margin: 0;
}

.btn-text {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-text:hover {
  background: var(--panel);
  border-color: var(--accent);
  color: var(--accent);
}

.notifications-list {
  overflow-y: auto;
  max-height: 520px;
  padding: 8px;
}

.notification-item {
  padding: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.notification-item:last-child {
  margin-bottom: 0;
}

.notification-item:hover {
  background: var(--panel);
  transform: translateX(2px);
}

.notification-item.unread {
  border-left: 3px solid var(--warning);
  background: rgba(255, 176, 32, 0.08);
}

.notification-item.danger {
  border-left: 3px solid var(--danger);
  background: rgba(255, 107, 107, 0.08);
}

.notification-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--panel-strong);
  color: var(--text);
  border: 2px solid var(--border);
}

.notification-item.unread .notification-icon {
  background: rgba(255, 176, 32, 0.2);
  color: var(--warning);
  border-color: var(--warning);
}

.notification-item.danger .notification-icon {
  background: rgba(255, 107, 107, 0.2);
  color: var(--danger);
  border-color: var(--danger);
}

.notification-content {
  display: flex;
  align-items: start;
  gap: 10px;
}

.notification-text {
  flex: 1;
}

.notification-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.notification-message {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 4px;
  line-height: 1.4;
}

.notification-time {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.notification-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
}

.notification-item:hover .notification-close {
  opacity: 1;
}

.notification-close:hover {
  background: var(--panel-strong);
  color: var(--text);
}

/* Retirer les flèches des champs de montant */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

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

/* Style pour les champs de montant avec masque */
input.currency-input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============ SECTION PRÉVISIONS ============ */

.forecast-container {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 320px) 1fr;
}

.forecast-input-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  grid-row: 1 / 3;
}

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

.forecast-card-header h3 {
  margin: 0;
}

.forecast-collapse-btn {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s ease;
}

.forecast-collapse-btn:hover {
  background: var(--panel);
  transform: scale(1.05);
}

.forecast-collapse-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  transition: transform 0.3s ease;
}

.forecast-input-card.collapsed .forecast-collapse-btn svg {
  transform: rotate(180deg);
}

.forecast-input-card.collapsed .forecast-form {
  display: none;
}

.forecast-results-card {
  grid-column: 2;
}

.forecast-timeline-card {
  grid-column: 2;
}

.forecast-form {
  display: grid;
  gap: 16px;
}

.forecast-form input[type="text"],
.forecast-form input[type="number"],
.forecast-form select {
  text-align: right;
  font-family: var(--font-mono);
}

.forecast-results-card,
.forecast-timeline-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.forecast-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.forecast-stat {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.forecast-stat .label {
  margin: 0;
  color: var(--muted);
}

.forecast-value {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 600;
}

.forecast-chart-container {
  margin-top: 12px;
  padding: 18px;
  background: var(--panel-strong);
  border-radius: 14px;
  border: 1px solid var(--border);
}

.forecast-chart {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forecast-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.forecast-month-label {
  width: 80px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex-shrink: 0;
}

.forecast-bar-container {
  flex: 1;
  height: 32px;
  background: var(--bg);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.forecast-bar {
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  min-width: 0;
}

.forecast-bar.negative {
  background: linear-gradient(135deg, var(--danger), #ff9a9a);
}

.forecast-bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-on-accent);
  white-space: nowrap;
  font-family: var(--font-mono);
}

.forecast-timeline {
  display: grid;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.forecast-month-item {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.forecast-month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.forecast-month-name {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.forecast-month-balance {
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.forecast-month-balance.positive {
  color: var(--success);
}

.forecast-month-balance.negative {
  color: var(--danger);
}

.forecast-month-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.forecast-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}

.forecast-detail-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.forecast-detail-value {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-align: right;
}

/* Responsive prévisions - tablette/mobile (inclus dans le breakpoint 900px principal) */
