:root {
  --primary: #1e3a5f;
  --primary-light: #2563eb;
  --positive: #059669;
  --negative: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--primary);
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

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

.brand-logo {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; letter-spacing: 0.5px;
}

.brand-info h1 { font-size: 16px; font-weight: 600; }
.brand-info span { font-size: 12px; color: rgba(255,255,255,0.65); }

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

/* ── Badge ── */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.badge-demo { background: rgba(245,158,11,0.25); color: #fbbf24; border: 1px solid rgba(251,191,36,0.3); }
.badge-live { background: rgba(5,150,105,0.25); color: #34d399; border: 1px solid rgba(52,211,153,0.3); }

/* ── Sync status ── */
.sync-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255,255,255,0.7); }
.sync-status::before { content: ''; width: 6px; height: 6px; background: #34d399; border-radius: 50%; }

/* ── User info ── */
.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255,255,255,0.85); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: none; cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn-primary { background: white; color: var(--primary); }
.btn-primary:hover { background: #f0f9ff; }
.btn-ghost { background: transparent; color: rgba(255,255,255,0.8); border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; line-height: 0; }

/* ── Navigation ── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;
  z-index: 90;
}
.nav-inner {
  display: flex;
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.nav-item:hover { color: var(--primary); }
.nav-item.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

/* ── Main ── */
.main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* ── Tab content ── */
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.charts-grid-wide {
  grid-template-columns: 1fr 1fr;
}
.charts-grid-wide > .card:first-child {
  grid-column: 1 / -1;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } .charts-grid-wide { grid-template-columns: 1fr; } .charts-grid-wide > .card:first-child { grid-column: 1; } }

.chart-donut-container { display: flex; align-items: center; justify-content: center; }
.chart-donut-container canvas { max-height: 260px; }

.chart-nav { display: flex; gap: 6px; align-items: center; }
.btn-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1.6;
  transition: background 0.15s;
}
.btn-nav:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-nav:disabled { opacity: 0.35; cursor: default; }

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.card-header h3 { font-size: 14px; font-weight: 600; }

.card-body { padding: 0; }
.card-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-pill {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 20px 14px;
  gap: 12px;
}
.modal-header-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.modal-header h3 { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-subtitle { font-size: 12px; color: var(--text-muted); }

.modal-close {
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }

.modal-body {
  overflow-y: auto;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-amounts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.modal-amount-tile {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-amount-tile.tile-credit { background: #f0fdf4; border-color: #bbf7d0; }
.modal-amount-tile.tile-debit  { background: #fff1f2; border-color: #fecdd3; }
.modal-amount-tile-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.modal-amount-tile-value { font-size: 17px; font-weight: 700; }
.modal-amount-tile.tile-credit .modal-amount-tile-value { color: #059669; }
.modal-amount-tile.tile-debit  .modal-amount-tile-value { color: #dc2626; }
.modal-amount-tile .modal-amount-tile-sub { font-size: 11px; color: var(--text-muted); }

.modal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.modal-info-cell {
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.modal-info-cell.span2 { grid-column: 1 / -1; }
.modal-info-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.modal-info-value { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-info-value.wrap { white-space: normal; }

/* TVA breakdown */
.tva-breakdown { display: flex; flex-direction: column; gap: 0; }
.tva-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 8px; border-bottom: 1px solid var(--border); gap: 12px; }
.tva-row:last-child { border-bottom: none; }
.tva-label { font-size: 13px; color: var(--text); flex: 1; }
.tva-value { font-size: 14px; font-weight: 600; white-space: nowrap; }
.tva-row-total { background: #f8fafc; border-radius: 8px; padding: 14px 12px; margin-top: 8px; }
.tva-row-total .tva-label { font-weight: 700; font-size: 14px; }
.tva-row-link { cursor: pointer; border-radius: 6px; transition: background 0.15s; }
.tva-row-link:hover { background: #f0f7ff; }
.tva-drill { font-size: 13px; color: var(--primary-light); opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.tva-row-link:hover .tva-drill { opacity: 1; }

/* Status badge banque */
.badge-banque-oui     { display:inline-flex;align-items:center;gap:4px;background:#f0fdf4;color:#059669;border:1px solid #bbf7d0;border-radius:20px;padding:2px 8px;font-size:12px;font-weight:600; }
.badge-banque-attente { display:inline-flex;align-items:center;gap:4px;background:#fffbeb;color:#d97706;border:1px solid #fde68a;border-radius:20px;padding:2px 8px;font-size:12px;font-weight:600; }
.badge-banque-na      { display:inline-flex;align-items:center;gap:4px;background:#f1f5f9;color:#94a3b8;border:1px solid var(--border);border-radius:20px;padding:2px 8px;font-size:12px;font-weight:600; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-box { border-radius: 16px; max-height: 88vh; }
  .modal-pill { display: none; }
}


.filters-wrap { flex-wrap: wrap; }
.table-hover tbody tr { cursor: pointer; }

/* ── Filters ── */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.select, .input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.select:focus, .input:focus { border-color: var(--primary-light); }
.input { min-width: 180px; }

.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checkbox-label input { cursor: pointer; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
.recent-scroll-wrap { max-height: 480px; overflow-y: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

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

/* ── Colors ── */
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.warning { color: var(--warning); }

.amount-credit { color: var(--positive); font-weight: 500; }
.amount-debit { color: var(--negative); font-weight: 500; }
.amount-neutral { color: var(--text-muted); }

/* ── Tags ── */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-recette { background: #d1fae5; color: #065f46; }
.tag-charge { background: #fee2e2; color: #7f1d1d; }
.tag-social { background: #ede9fe; color: #4c1d95; }
.tag-impot { background: #fef3c7; color: #78350f; }
.tag-divers { background: #f1f5f9; color: var(--text-muted); }

/* ── Check icon ── */
.check-yes { color: var(--positive); font-size: 16px; }
.check-no { color: var(--border); font-size: 16px; }

/* ── Scenario bar ── */
.scenario-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.scenario-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.scenario-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.scenario-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.scenario-btn.active { background: var(--primary-light); color: white; border-color: var(--primary-light); }

/* ── Totaux ── */
.totaux { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; }
.totaux-item { display: flex; flex-direction: column; gap: 2px; }
.totaux-item span:first-child { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.totaux-item span:last-child { font-weight: 600; }
.totaux-item-solde { border-left: 2px solid var(--border); padding-left: 16px; margin-left: 4px; }
.rapport-header { background: #f0f7ff; border-bottom: 2px solid rgba(37,99,235,0.15); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 999;
  transition: opacity 0.3s ease;
}
.toast.hidden { display: none; }
.toast.error { background: var(--negative); }
.toast.success { background: var(--positive); }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Écart badges ── */
.ecart-pos { color: var(--positive); font-weight: 500; }
.ecart-neg { color: var(--negative); font-weight: 500; }
.ecart-neutral { color: var(--text-muted); }

/* ── Forecast row states ── */
tr.row-forecast td { color: var(--text-muted); font-style: italic; }
tr.row-current td { background: #eff6ff !important; font-weight: 500; }

/* ── Empty state ── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.loading-overlay.hidden { display: none; }

.loading-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px 40px;
  min-width: 400px;
  max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  text-align: center;
}
.loading-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
}
.loading-steps { text-align: left; }
.loading-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  opacity: 0.3;
  transition: opacity 0.3s, color 0.3s;
}
.loading-step:last-child { border-bottom: none; }
.loading-step.active  { opacity: 1; }
.loading-step.pending { opacity: 0.7; }
.loading-step.done    { opacity: 1; color: var(--positive); }
.loading-step.error   { opacity: 1; color: var(--negative); }
.step-icon {
  font-size: 15px;
  width: 20px;
  flex-shrink: 0;
  font-weight: 700;
  line-height: 1.5;
}
.loading-step.active .step-icon { animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }
.step-label { font-size: 14px; font-weight: 500; line-height: 1.5; }
.step-detail { font-size: 11px; color: var(--text-muted); font-family: monospace; display:block; margin-top:2px; }

.loading-error {
  margin-top: 20px;
  padding: 14px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  text-align: left;
}
.error-title { font-weight: 600; color: var(--negative); margin-bottom: 6px; font-size: 14px; }
.error-msg   { font-size: 13px; color: #7f1d1d; line-height: 1.5; word-break: break-all; }

/* ── KPI grid 3 colonnes ── */
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ── Comparatif exercices — accordéon ── */
.exercices-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.exercice-accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.exercice-accordion-item.exercice-current {
  border-color: var(--primary-light);
  border-width: 2px;
}
.exercice-accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  flex-wrap: wrap;
}
.exercice-accordion-header::-webkit-details-marker { display: none; }
.exercice-accordion-item[open] .exercice-accordion-header {
  border-bottom: 1px solid var(--border);
}
.accordion-chevron {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.exercice-accordion-item[open] .accordion-chevron { transform: rotate(180deg); }
.exercice-accordion-body {
  padding: 16px 20px;
}
.exercice-title { font-size: 14px; font-weight: 600; }
.exercice-period { font-size: 12px; color: var(--text-muted); }

/* ── Trésorerie strip ── */
.tresorerie-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.tresorerie-item { display: flex; flex-direction: column; gap: 4px; }
.tresorerie-item.tresorerie-total {
  background: #eff6ff;
  border-radius: var(--radius);
  padding: 10px 18px;
  border: 1px solid #bfdbfe;
}
.tresorerie-op { font-size: 20px; color: var(--text-muted); font-weight: 300; }
.tresorerie-secondary {
  margin-left: auto;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.tresorerie-kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-clickable {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}
.kpi-clickable:hover { opacity: 0.75; }
.kpi-hint {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .exercice-accordion-body { padding: 12px 16px; }
  .tresorerie-secondary { margin-left: 0; }
}
@media (max-width: 768px) {
  .main { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .header { padding: 0 16px; }
  .nav-inner { padding: 0 16px; }
  .nav-item { padding: 12px 10px; font-size: 12px; }
  .brand-info span { display: none; }
}

/* ── Formulaire nouvelle écriture ────────────────────────── */
.modal-form { max-width: 720px; }
.modal-form-body { padding: 4px 20px 24px; max-height: 74vh; overflow-y: auto; }

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.form-row-amounts { align-items: flex-start; }
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 130px;
}
.form-group-ac { position: relative; }
.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-hint {
  font-size: 11px;
  color: var(--primary-light);
  font-style: italic;
  margin-top: 2px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.btn-main { padding: 8px 18px; font-size: 14px; }
.btn-ghost.btn-main { color: var(--text-muted); border-color: var(--border); background: var(--surface); }
.btn-ghost.btn-main:hover { background: var(--bg); color: var(--text); }

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  max-height: 210px;
  overflow-y: auto;
  list-style: none;
  padding: 4px 0;
}
.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autocomplete-item:hover { background: #f0f7ff; }
.ac-sub { font-size: 11px; color: var(--text-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ac-main { font-weight: 500; white-space: nowrap; }
.ac-amount { margin-left: auto; font-size: 11px; color: var(--text-muted); font-weight: 600; white-space: nowrap; padding-left: 8px; }

/* Bloc "Reprendre une écriture similaire" */
.form-similaire-wrap {
  background: #f0f5ff;
  border: 1px solid #c7d9ff;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.form-similaire-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* Panneau fichiers pièce comptable */
.piece-panel {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.piece-panel-item {
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.piece-panel-item:last-child { border-bottom: none; }
.piece-panel-item:hover { background: #f0f7ff; color: var(--primary-light); }
.piece-panel-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}
.btn-creer-ecriture {
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
  color: var(--primary-light);
  border-color: rgba(37,99,235,0.3);
}
.btn-creer-ecriture:hover { background: #eff6ff; }

@media (min-width: 640px) {
  .modal-form { border-radius: 16px; }
}
@media (max-width: 600px) {
  /* Header compact */
  .header { height: 52px; padding: 0 12px; gap: 8px; }
  .header-actions { gap: 6px; }
  .brand-logo { width: 30px; height: 30px; font-size: 10px; }
  .brand-info h1 { font-size: 14px; }
  .brand-info span { display: none; }
  .sync-status { font-size: 11px; gap: 4px; }

  /* Formulaires */
  .form-row { flex-direction: column; }
  .form-group { min-width: unset; width: 100%; }
  .form-group .input,
  .form-group .select { width: 100%; min-width: unset; box-sizing: border-box; }
  .modal-form-body { padding: 4px 14px 20px; }
  .modal-amounts { gap: 6px; }
  .modal-amount-tile { padding: 8px 10px; }
  .modal-amount-tile-value { font-size: 15px; }
  .modal-info-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
  .modal-body { padding: 0 12px 20px; gap: 10px; }
}

/* ── Page Pièces comptables ──────────────────────────────────── */

.pieces-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.pieces-title { font-size: 18px; font-weight: 700; color: var(--text); }
.pieces-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.pieces-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pieces-badge {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.pieces-badge-warn { background: rgba(220,38,38,.1); color: #dc2626; border: 1px solid rgba(220,38,38,.2); }
.pieces-badge-ok   { background: rgba(5,150,105,.1);  color: #059669; border: 1px solid rgba(5,150,105,.2); }

.pieces-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.pieces-filter-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.pieces-ftab {
  padding: 5px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; background: transparent; color: var(--text-muted);
  transition: all .15s;
}
.pieces-ftab.active { background: white; color: var(--primary); box-shadow: var(--shadow); }

.pieces-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.pieces-table { width: 100%; border-collapse: collapse; background: white; }
.pieces-table thead th {
  padding: 10px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted); background: #f8fafc;
  border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap;
}
.pieces-th-right { text-align: right; }
.pieces-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.pieces-table tbody tr:last-child { border-bottom: none; }
.pieces-table tbody tr:hover { background: #fafbff; }
.pieces-row-missing td { background: rgba(254,242,242,.35); }
.pieces-row-missing:hover td { background: rgba(254,242,242,.6) !important; }

.pieces-td-date  { padding: 10px 14px; font-size: 13px; white-space: nowrap; color: var(--text-muted); }
.pieces-td-tiers { padding: 10px 14px; font-size: 13px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pieces-td-objet { padding: 10px 14px; font-size: 13px; color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pieces-td-ttc   { padding: 10px 14px; font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; }
.pieces-td-piece { padding: 8px 14px; min-width: 220px; }

.pieces-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 200px;
  padding: 3px 8px; border-radius: 20px; font-size: 12px;
  background: rgba(5,150,105,.08); color: #059669; border: 1px solid rgba(5,150,105,.2);
}
.pieces-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.pieces-btn-change {
  margin-left: 6px; padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border);
  background: white; color: var(--text-muted); cursor: pointer; vertical-align: middle;
  line-height: 0; transition: all .15s;
}
.pieces-btn-change:hover { border-color: var(--primary-light); color: var(--primary-light); }
.pieces-btn-affecter {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1.5px dashed #cbd5e1; background: white; color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.pieces-btn-affecter:hover { border-color: var(--primary-light); color: var(--primary-light); background: #f0f7ff; }

.pieces-panel-row td { padding: 0 !important; border-bottom: 1px solid var(--border); }
.pieces-panel-td { padding: 0 !important; }
.pieces-inline-panel {
  border-top: 2px solid var(--primary-light);
  max-height: 220px; overflow-y: auto; background: white;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.pieces-panel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid #f1f5f9; transition: background .1s;
}
.pieces-panel-item:last-child { border-bottom: none; }
.pieces-panel-item:hover { background: #f0f7ff; color: var(--primary-light); }
.pieces-panel-loading { padding: 12px; font-size: 13px; color: var(--text-muted); text-align: center; }
.pieces-panel-empty   { padding: 10px 12px; font-size: 13px; color: var(--text-muted); }
.pieces-panel-section {
  padding: 5px 12px 3px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted); background: #f8fafc;
  border-bottom: 1px solid var(--border); sticky: top;
}
.pieces-panel-section-others { margin-top: 2px; }
.pieces-panel-item-match {
  background: #eff6ff;
  font-weight: 500;
}
.pieces-panel-item-match:hover { background: #dbeafe; color: var(--primary-light); }
.pieces-panel-upload-label {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--primary-light);
  border-top: 1px dashed var(--border); background: #f8fafc;
  transition: background .1s;
}
.pieces-panel-upload-label:hover { background: #f0f7ff; }

.pieces-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 60px 24px; color: var(--text-muted); font-size: 14px; text-align: center;
}

@media (max-width: 600px) {
  .pieces-td-objet { display: none; }
  .pieces-td-piece { min-width: 160px; }
}
