/* =========================================================
   AutoDash — Design System
   Mobile-first · PHP/JS Vanilla
   ========================================================= */

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

:root {
  --navy:        #1a2e4a;
  --navy-dark:   #0f1e30;
  --navy-mid:    #243858;
  --accent:      #2563eb;
  --accent-soft: #eff6ff;
  --accent-mid:  #bfdbfe;

  --success:     #16a34a;
  --success-bg:  #f0fdf4;
  --success-bdr: #bbf7d0;
  --warning:     #d97706;
  --warning-bg:  #fffbeb;
  --warning-bdr: #fde68a;
  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --danger-bdr:  #fecaca;
  --info:        #0891b2;
  --info-bg:     #ecfeff;

  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --border-dark: #cbd5e1;

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08);

  --sidebar-w:   240px;
  --nav-h:       64px;  /* mobile bottom nav */
  --header-h:    56px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* --- Layout --------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar — hidden on mobile */
.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: #fff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transform: rotate(-8deg);
  padding: 4px;
}
.sidebar-logo-text {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.5px;
  line-height: 1;
}
.sidebar-logo-dot {
  color: var(--accent-mid);
}

.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* === Déclencheur d'exercice (sidebar) === */
.sidebar-year-selector { margin: 0 12px 8px; }
.year-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.9);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-align: left;
  font-family: inherit;
}
.year-trigger-btn:hover         { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.22); }
.year-trigger-btn .trigger-icon { opacity: .6; flex-shrink: 0; }
.year-trigger-btn .trigger-label { flex: 1; }
.year-trigger-btn .trigger-chevron { opacity: .4; flex-shrink: 0; }

/* Déclencheur exercice (header mobile) */
.year-trigger-mobile {
  background: transparent;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  letter-spacing: -.3px;
  transition: background .12s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.year-trigger-mobile:hover { background: var(--bg); }

/* ===== Year Picker Modal ===== */
.year-picker-modal {
  max-width: none;
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}
.year-picker-handle {
  display: none; /* visible uniquement mobile via media query */
  justify-content: center;
  padding: 10px 0 0;
  flex-shrink: 0;
}
.year-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.year-picker-title    { font-size: 16px; font-weight: 700; color: var(--text); }
.year-picker-subtitle { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.year-picker-close {
  width: 30px; height: 30px;
  border: none; background: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-3);
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.year-picker-close:hover { background: var(--bg); color: var(--text); }

.year-picker-list {
  overflow-y: auto;
  padding: 6px;
  flex: 1;
}

/* Card exercice */
.year-picker-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  padding: 12px 12px 0;
  background: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s;
  font-family: inherit;
  margin-bottom: 3px;
  overflow: hidden;
}
.ex-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
}
.year-picker-item:hover      { background: var(--bg); }
.year-picker-item.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
}

/* EX Badge */
.ex-badge {
  flex-shrink: 0;
  width: 46px; height: 46px;
  background: var(--navy);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.ex-badge.active  { background: var(--accent); }
.ex-badge-label   { font-size: 9px; font-weight: 700; color: rgba(255,255,255,.65); letter-spacing: .12em; text-transform: uppercase; line-height: 1; }
.ex-badge-year    { font-size: 15px; font-weight: 800; color: #fff; letter-spacing: -.5px; line-height: 1; }

/* Corps de la carte */
.ex-body        { flex: 1; min-width: 0; }
.ex-row-top     { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; flex-wrap: wrap; }
.ex-title       { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.year-picker-item.is-selected .ex-title { color: var(--accent); }

/* Status pills */
.ex-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.ex-status.encours  { background: var(--accent); color: #fff; }
.ex-status.cloture  { background: #fff7ed; color: #92400e; border: 1px solid #fde68a; }
.ex-status.partiel  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bdr); }
.ex-status.ouvert   { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.ex-status-dot      { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.ex-dates      { font-size: 11px; color: var(--text-3); margin-bottom: 5px; line-height: 1.3; }
.ex-dates-hint { color: var(--text-3); font-size: 10px; }

/* Stats sous la barre */
.ex-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px 8px;
}
.ex-bar-pct  { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.ex-meta     { font-size: 10px; color: var(--text-3); white-space: nowrap; }
/* La barre est collée en bas de la carte, bord à bord */
.ex-bar-track { width: 100%; height: 4px; background: var(--border); overflow: hidden; margin-top: 6px; border-radius: 0; }
.ex-bar-fill  { height: 100%; border-radius: 0; transition: width .3s; }
.ex-bar-fill.safe   { background: var(--success); }
.ex-bar-fill.warn   { background: var(--warning); }
.ex-bar-fill.danger { background: var(--danger); }

/* Montant CA */
.ex-right   { flex-shrink: 0; text-align: right; }
.ex-ca-val  { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; line-height: 1.2; }
.year-picker-item.is-selected .ex-ca-val { color: var(--accent); }
.ex-ca-lbl  { font-size: 10px; color: var(--text-3); white-space: nowrap; }

/* Pied de modale */
.year-picker-footer {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.year-picker-footer .btn { flex: 1; justify-content: center; }

/* === Bottom sheet sur mobile === */
@media (max-width: 640px) {
  #year-picker-modal {
    align-items: flex-end;
    padding: 0;
  }
  #year-picker-modal .year-picker-modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transform: translateY(48px); /* override scale par défaut */
  }
  #year-picker-modal.open .year-picker-modal {
    transform: translateY(0);
  }
  .year-picker-handle {
    display: flex;
  }
  .year-picker-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    background: var(--border-dark);
    border-radius: 4px;
  }
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 4px;
}

.sidebar nav { flex: 1; padding: 0 10px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  font-size: 14px;
  font-weight: 400;
  transition: background .15s, color .15s;
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 500; }
.nav-item svg    { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  line-height: 16px;
}

.sidebar-bottom {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: auto;
}
.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-plan {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent-mid);
  margin-top: 1px;
}
.sidebar-logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.sidebar-logout-btn:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}
.sidebar-logout-btn svg { width: 16px; height: 16px; }

/* Main content */
.main {
  flex: 1;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 16px); /* space for mobile nav */
}

/* Mobile top header */
.mobile-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.mobile-header-logo {
  display: flex; align-items: center; gap: 8px;
}
.mobile-header-logo-icon {
  width: 30px; height: 30px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  padding: 3px;
  flex-shrink: 0;
}
.mobile-header-logo-text {
  font-size: 17px; font-weight: 800; color: var(--navy); letter-spacing: -.4px;
}
.mobile-header-logo span {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.mobile-header-right { display: flex; align-items: center; gap: 8px; }
.mobile-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
}

/* Mobile bottom nav */
.mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s;
  padding: 6px 0;
}
.mobile-nav-item svg { width: 22px; height: 22px; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item.active svg { stroke: var(--accent); }

/* Page content wrapper */
.page { padding: 16px 16px 8px; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-title   { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* --- Desktop breakpoint ---------------------------------- */
@media (min-width: 768px) {
  .sidebar        { display: flex; }
  .mobile-header  { display: none; }
  .mobile-nav     { display: none; }
  .main           { margin-left: var(--sidebar-w); padding-bottom: 24px; }
  .page           { padding: 28px 32px; }
  .page-title     { font-size: 24px; }
}

/* --- Cards ---------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 12px;
}

/* Metric cards grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -.5px;
}
.metric-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.metric-sub.up   { color: var(--success); }
.metric-sub.down { color: var(--danger); }
.metric-sub.warn { color: var(--warning); }

@media (min-width: 768px) {
  .metrics-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
  .metric-value { font-size: 26px; }
}

/* --- Progress bar --------------------------------------- */
.progress-wrap { margin-bottom: 16px; }
.progress-bar-bg {
  background: var(--border);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .6s ease;
}
.progress-bar-fill.safe   { background: var(--success); }
.progress-bar-fill.warn   { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}
.progress-pct {
  font-size: 13px;
  font-weight: 700;
}
.progress-pct.safe   { color: var(--success); }
.progress-pct.warn   { color: var(--warning); }
.progress-pct.danger { color: var(--danger); }

/* --- Badges / Status ------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  line-height: 1;
}
.badge::before { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bdr); }
.badge-success::before { background: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bdr); }
.badge-warning::before { background: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bdr); }
.badge-danger::before  { background: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: #f1f5f9; color: var(--text-2); border: 1px solid var(--border); }
.badge-neutral::before { background: var(--text-3); }

/* --- Table ---------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 12px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* --- Mobile list (replaces table on small screens) ------ */
.item-list { display: flex; flex-direction: column; gap: 0; }
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: #f8fafc; }
.item-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.item-icon-blue   { background: var(--accent-soft); color: var(--accent); }
.item-icon-green  { background: var(--success-bg);  color: var(--success); }
.item-icon-orange { background: var(--warning-bg);  color: var(--warning); }
.item-icon-red    { background: var(--danger-bg);   color: var(--danger); }
.item-body  { flex: 1; min-width: 0; }
.item-name  { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta  { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.item-right { text-align: right; flex-shrink: 0; }
.item-amount { font-size: 14px; font-weight: 600; color: var(--text); }
.item-date   { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.item-chevron { color: var(--text-3); margin-left: 4px; }

/* --- Buttons -------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  border: none; cursor: pointer;
  transition: opacity .15s, transform .1s;
  line-height: 1;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { opacity: .9; }
.btn-outline  { background: transparent; border: 1px solid var(--border-dark); color: var(--text); }
.btn-outline:hover  { background: var(--bg); }
.btn-danger   { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bdr); }
.btn-sm       { padding: 6px 12px; font-size: 13px; }
.btn-lg       { padding: 13px 24px; font-size: 15px; width: 100%; }
.btn svg      { width: 16px; height: 16px; }
.btn-icon     { padding: 8px; border-radius: var(--radius-sm); }

.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  transition: transform .15s, box-shadow .15s;
}
.btn-fab:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(37,99,235,.45); }
.btn-fab svg   { width: 22px; height: 22px; }

@media (min-width: 768px) {
  .btn-fab { display: none; }
}

/* --- Forms ---------------------------------------------- */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-label span { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--text-3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-control.is-invalid { border-color: var(--danger); }

.form-row { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 500px) {
  .form-row { grid-template-columns: 1fr 1fr; gap: 12px; }
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}
.form-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Input with prefix (€, FA-) */
.input-group { display: flex; }
.input-prefix, .input-suffix {
  display: flex; align-items: center;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border-dark);
  font-size: 14px; color: var(--text-2);
  white-space: nowrap;
}
.input-prefix { border-right: none; border-radius: var(--radius) 0 0 var(--radius); }
.input-suffix { border-left: none; border-radius: 0 var(--radius) var(--radius) 0; }
.input-group .form-control {
  border-radius: 0;
  flex: 1;
}
.input-group .form-control:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .form-control:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }

/* --- Filter/Search bar ---------------------------------- */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .form-control { flex: 1; min-width: 160px; font-size: 14px; padding: 9px 12px; }
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
  border: none;
  background: transparent;
}
.filter-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* --- Flash messages ------------------------------------- */
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bdr); }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bdr); }
.flash-info    { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-mid); }

/* --- Empty state ---------------------------------------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }
.empty-state h3   { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p    { font-size: 14px; color: var(--text-2); margin-bottom: 16px; }

/* --- Chart container ------------------------------------ */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 200px;
}
@media (min-width: 768px) { .chart-wrap { height: 240px; } }

/* --- Deadline items ------------------------------------- */
.deadline-list { display: flex; flex-direction: column; }
.deadline-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.deadline-item:last-child { border-bottom: none; }
.deadline-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.deadline-dot.urgent { background: var(--danger); }
.deadline-dot.soon   { background: var(--warning); }
.deadline-dot.ok     { background: var(--success); }
.deadline-label { flex: 1; font-size: 14px; color: var(--text); }
.deadline-date  { font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; }

/* --- Auth pages ----------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px;
}
.auth-logo-icon {
  width: 40px; height: 40px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  display: flex; align-items: center; justify-content: center;
  padding: 5px; overflow: hidden; flex-shrink: 0;
  transform: rotate(-8deg);
}
.auth-logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo-text {
  font-size: 22px; font-weight: 800; color: var(--navy); letter-spacing: -.5px;
}
.auth-logo-dot { color: var(--accent); }
.auth-title    { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 24px; }
.auth-divider  { text-align: center; color: var(--text-3); font-size: 13px; margin: 16px 0; position: relative; }
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute; top: 50%;
  width: calc(50% - 24px);
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-link { text-align: center; font-size: 14px; color: var(--text-2); margin-top: 16px; }
.auth-link a { color: var(--accent); font-weight: 500; }

/* --- Onboarding steps ----------------------------------- */
.steps-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}
.step-item {
  display: flex; align-items: center; flex: 1;
  font-size: 12px; color: var(--text-3);
}
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
  color: var(--text-3);
}
.step-item.active .step-num  { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-item.done .step-num    { background: var(--success); border-color: var(--success); color: #fff; }
.step-line {
  flex: 1; height: 1px;
  background: var(--border);
  margin: 0 6px;
}
.step-item.done + .step-item .step-line { background: var(--success); }

/* --- Stat comparison row -------------------------------- */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label { color: var(--text-2); }
.stat-row-value { font-weight: 600; color: var(--text); }

/* --- Toggle / Switch ------------------------------------ */
.toggle-group {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}
.toggle-opt {
  flex: 1; text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-size: 14px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.toggle-opt.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* --- Utilities ------------------------------------------ */
.mt-1  { margin-top:  4px; }
.mt-2  { margin-top:  8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mb-1  { margin-bottom:  4px; }
.mb-2  { margin-bottom:  8px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-2); }
.text-small  { font-size: 13px; }
.fw-600      { font-weight: 600; }
.d-flex      { display: flex; align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.flex-1      { flex: 1; }
.grid-2      { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .grid-2 { grid-template-columns: 1fr; } }

/* Montant coloré */
.amount-positive { color: var(--success); font-weight: 600; }
.amount-negative { color: var(--danger);  font-weight: 600; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Smooth page transitions */
.page { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* --- Import / Export ------------------------------------ */
.upload-drop-zone {
  position: relative;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  background: var(--bg);
  transition: border-color .2s, background .2s;
  cursor: default;
}
.upload-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-drop-zone.has-file {
  border-color: var(--success);
  background: var(--success-bg);
}
.upload-drop-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-3);
}
.upload-drop-zone.drag-over .upload-drop-icon { color: var(--accent); }
.upload-drop-zone.has-file  .upload-drop-icon { color: var(--success); }
.upload-drop-text {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.8;
}

/* Cartes de format */
.format-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.format-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.format-card-title {
  font-weight: 600;
  font-size: 14px;
}
.format-card-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 10px;
}
.format-card-ext {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface);
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.format-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 22px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.format-badge-pdf { background: #fef2f2; color: #dc2626; }
.format-badge-xml { background: #eff6ff; color: #2563eb; }
.format-badge-csv { background: #f0fdf4; color: #16a34a; }

/* Badge warning (manquant) */
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bdr); }

/* Ligne grisée (doublon) */
.row-muted td { opacity: .5; }

/* --- Confirm Modal --------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  padding: 16px;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.08);
  padding: 28px 24px 20px;
  width: 100%;
  max-width: 400px;
  transform: translateY(10px) scale(.97);
  transition: transform .2s ease;
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--warning-bg);
  border: 1px solid var(--warning-bdr);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--warning);
  flex-shrink: 0;
}
.modal-icon.modal-icon-danger {
  background: var(--danger-bg);
  border-color: var(--danger-bdr);
  color: var(--danger);
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.modal-message {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 22px;
  padding-left: 52px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .modal-overlay.open .modal {
    transform: translateY(0);
  }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
}

/* Print styles */
@media print {
  .sidebar, .mobile-nav, .mobile-header, .btn-fab, .filter-bar { display: none !important; }
  .main { margin-left: 0 !important; }
  .card { border: 1px solid #ddd !important; box-shadow: none !important; }
}
