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

:root {
  /* ── Thème actif (modifié par le sélecteur) ── */
  --theme-accent:       #1a7a72;
  --theme-accent-light: #e0f5f3;
  --theme-accent-dark:  #124f4a;
  --theme-sidebar:      #24292e;
  --theme-paper:        #f7f6f2;

  /* ── Couleurs fixes ── */
  --ink:        #0d0f1a;
  --ink2:       #3a3d52;
  --ink3:       #7c8098;
  --paper:      var(--theme-paper);
  --white:      #ffffff;
  --border:     #e4e2db;
  --border2:    #ccc9be;
  --gold:       #c9a84c;
  --gold-light: #fdf6e3;
  --gold-dark:  #8a6a1e;
  --teal:       var(--theme-accent);
  --teal-light: var(--theme-accent-light);
  --red:        #c0392b;
  --red-light:  #fdecea;
  --amber:      #d97706;
  --amber-light:#fef3c7;
  --green:      #16a34a;
  --green-light:#dcfce7;
  --violet:     #6d28d9;
  --violet-light:#ede9fe;
  --r: 10px;
  --r-sm: 6px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

/* ══ LOGIN ══════════════════════════════════════════════════ */
#login-overlay {
  position: fixed; inset: 0;
  background: var(--sidebar-bg, var(--ink));
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.login-box {
  width: 100%; max-width: 400px;
  padding: 2.5rem;
}
.login-logo {
  margin-bottom: 2rem;
}
.login-logo-mark {
  width: 48px; height: 48px;
  background: var(--gold);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.login-logo-mark svg { width: 24px; height: 24px; stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-logo h1 { font-family: 'Inter', sans-serif; font-size: 1.5rem; font-weight: 800; color: #fff; letter-spacing: -0.03em; }
.login-logo p  { font-size: 0.8rem; color: var(--ink3); margin-top: 3px; }

.login-field { margin-bottom: 1rem; }
.login-field label { display: block; font-size: 0.72rem; font-weight: 500; color: var(--ink3); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 10px 14px;
  font-family: 'Inter', sans-serif; font-size: 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-sm);
  color: #fff; outline: none;
  transition: border-color 0.2s;
}
.login-field input::placeholder { color: rgba(255,255,255,0.2); }
.login-field input:focus { border-color: var(--theme-accent); }

.login-submit {
  width: 100%; padding: 11px;
  background: var(--gold); color: var(--ink);
  border: none; border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; margin-top: 0.5rem;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.15s; letter-spacing: 0.01em;
}
.login-submit:hover { opacity: 0.88; }
.login-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.login-err {
  margin-top: 1rem; font-size: 0.78rem; color: #ff8080;
  background: rgba(192,57,43,0.15);
  padding: 8px 12px; border-radius: var(--r-sm);
  border-left: 2px solid var(--red); display: none;
}
.spin { width: 15px; height: 15px; border: 2px solid rgba(0,0,0,0.2); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ LAYOUT ═════════════════════════════════════════════════ */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--sidebar-bg, var(--ink));
  display: flex; flex-direction: column;
  padding: 1.5rem 0;
  /* Reste visible sur toute la hauteur pendant le scroll de la page */
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  align-self: flex-start;
  transition: width 0.25s ease;
  overflow-x: hidden;
}
.sidebar.collapsed {
  width: 18px;
  padding: 0;
  min-width: 18px;
}
/* Tout masquer sauf le bouton toggle */
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-footer {
  display: none;
}
/* Toggle centré vertical */
.sidebar.collapsed #sidebar-toggle {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  height: 100%;
  width: 18px;
  justify-content: center;
  align-items: center;
  padding: 0;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  opacity: 0.5;
}
.sidebar.collapsed #sidebar-toggle:hover {
  opacity: 1;
  background: rgba(255,255,255,0.05);
}
.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 1.5rem;
}
.sidebar-mark {
  width: 36px; height: 36px;
  background: var(--gold); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.sidebar-mark svg { width: 18px; height: 18px; stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-brand h2 { font-family: 'Inter', sans-serif; font-size: 0.95rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.sidebar-brand p  { font-size: 0.7rem; color: var(--ink3); margin-top: 2px; }

.sidebar-section { padding: 0 1rem; margin-bottom: 1.5rem; }
.sidebar-label { font-size: 0.63rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink3); padding: 0 0.5rem; margin-bottom: 6px; }

.nav-btn {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 0.83rem; font-weight: 500;
  color: rgba(255,255,255,0.5); background: none; border: none;
  cursor: pointer; transition: all 0.15s;
}
.nav-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-btn:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-btn.active { background: color-mix(in srgb, var(--sidebar-text, var(--gold)) 15%, transparent); color: var(--sidebar-text, var(--gold)); }

.sidebar-footer {
  margin-top: auto; padding: 1rem 1.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.user-info { display: flex; align-items: center; gap: 9px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif; font-size: 0.72rem; font-weight: 800;
  flex-shrink: 0;
}
.user-name { font-size: 0.78rem; color: rgba(255,255,255,0.7); font-weight: 500; flex: 1; }
.logout-btn {
  font-family: inherit; font-size: 0.7rem; color: var(--ink3);
  background: none; border: none; cursor: pointer;
  padding: 3px; transition: color 0.15s;
}
.logout-btn:hover { color: #ff8080; }
.logout-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Main ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }

/* ── Topbar ── */
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-family: 'Inter', sans-serif; font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }
.topbar-sub { font-size: 0.75rem; color: var(--ink3); margin-top: 1px; }

/* ── Vues ── */
.view { display: none; padding: 2rem; flex: 1; }
.view.active { display: block; }

/* ══ STATS BAR ══════════════════════════════════════════════ */
.stats-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 2rem; }
.stat {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px;
  position: relative; overflow: hidden;
}
.stat::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; }
.stat.s-total::after   { background: var(--ink); }
.stat.s-asaisir::after { background: var(--amber); }
.stat.s-saisie::after  { background: var(--violet); }
.stat.s-apayer::after  { background: var(--teal); }
.stat.s-payee::after   { background: var(--green); }
.stat.s-litige::after  { background: var(--red); }
.stat-val { font-family: 'Inter', sans-serif; font-size: 1.8rem; font-weight: 800; letter-spacing: -0.04em; }
.stat.s-asaisir .stat-val { color: var(--amber); }
.stat.s-saisie  .stat-val { color: var(--violet); }
.stat.s-apayer  .stat-val { color: var(--teal); }
.stat.s-payee   .stat-val { color: var(--green); }
.stat.s-litige  .stat-val { color: var(--red); }
.stat-label { font-size: 0.7rem; font-weight: 500; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px; }

/* ══ DASHBOARD COMPTAVIEW ═══════════════════════════════════ */
#view-dashboard { padding: 1.25rem 1.5rem 2rem; }
.cv-dashboard .cv-info { background: var(--white); border: 1px solid var(--border); padding: 10px 14px; margin-bottom: 1rem; border-radius: var(--r-sm); display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.85rem; }
.cv-dashboard .cv-reload { background: var(--theme-accent); color: white; padding: 8px 15px; border: none; border-radius: var(--r-sm); cursor: pointer; font-size: 0.85rem; font-family: inherit; }
.cv-dashboard .cv-reload:hover { background: var(--theme-accent-dark); }
.cv-dashboard .cv-stats { display: flex; gap: 16px; margin: 1rem 0; flex-wrap: wrap; }
.cv-dashboard .cv-stat-card { background: var(--white); border: 1px solid var(--border); padding: 14px 16px; border-radius: var(--r-sm); flex: 1; min-width: 160px; box-shadow: 0 2px 4px rgba(0,0,0,.06); }
.cv-dashboard .cv-stat-card h3 { margin: 0 0 4px; color: var(--ink3); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.cv-dashboard .cv-stat-card .value { font-family: 'Inter', sans-serif; font-size: 1.6rem; font-weight: 800; color: var(--theme-accent); }
.cv-dashboard .cv-stat-card .value.filtered-value { color: var(--amber); }
.cv-dashboard .cv-stat-card .sub-label { font-size: 0.68rem; color: var(--ink3); margin-top: 2px; }
.cv-kpi-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 16px; flex: 1; min-width: 140px; cursor: pointer; transition: all 0.15s; box-shadow: 0 2px 4px rgba(0,0,0,.06); }
.cv-kpi-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-1px); }
.cv-kpi-card.active { background: var(--theme-accent-light); border-color: var(--theme-accent); }
.cv-kpi-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink3); margin-bottom: 6px; }
.cv-kpi-count { font-size: 1.4rem; font-weight: 800; color: var(--ink); font-family: 'Inter', sans-serif; }
.cv-kpi-ttc { font-size: 0.78rem; font-weight: 600; color: var(--ink3); margin-top: 2px; }
.cv-dashboard { overflow-x: auto; }
.cv-dashboard .dataTables_wrapper { background: var(--white); padding: 16px; border: 1px solid var(--border); border-radius: var(--r); overflow-x: auto; }
.cv-dashboard table.dataTable thead th { background: var(--theme-accent); color: white; padding: 10px 12px; border-bottom: none; font-size: 0.78rem; }
.cv-dashboard table.dataTable thead tr.filters th { background: var(--paper); padding: 6px; }
.cv-dashboard table.dataTable thead tr.filters input { width: 100%; padding: 5px; border: 1px solid var(--border); border-radius: var(--r-sm); box-sizing: border-box; font-size: 0.8rem; }
.cv-dashboard .text-right { text-align: right; }
.cv-dashboard .dt-buttons { margin-bottom: 10px; }
.cv-dashboard .dt-button { background: #4caf50 !important; color: white !important; border: none !important; padding: 7px 14px !important; border-radius: var(--r-sm) !important; margin-right: 5px !important; cursor: pointer !important; font-size: 0.8rem !important; }
.cv-dashboard .dt-button.export-selected { background: #ff9800 !important; }
.cv-dashboard .dt-button.export-comptable { background: #2196f3 !important; }
.cv-dashboard .dt-button:disabled { background: #ccc !important; cursor: not-allowed !important; }
.cv-dashboard table.dataTable tbody tr.selected { background-color: #b3d9ff !important; }
.cv-dashboard .badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.cv-dashboard .badge-apayer  { background: #fff8e1; color: var(--amber); border: 1px solid #ffcc80; }
.cv-dashboard .badge-asaisir { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.cv-dashboard .badge-litige  { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.cv-dashboard .badge-payee   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.cv-dashboard .badge-saisie  { background: #f3e5f5; color: #6a1b9a; border: 1px solid #ce93d8; }
.cv-dashboard .badge-default { background: #f5f5f5; color: #555; border: 1px solid #ddd; }
.cv-dashboard tr.echeance-depassee td { background: #fff3e0 !important; }
.cv-dashboard .filtres-rapides { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; align-items: center; }
.cv-dashboard .filtres-rapides span { font-size: 0.8rem; color: var(--ink3); font-weight: 600; }
.cv-dashboard .btn-filtre, .cv-dashboard .btn-filtre-type { padding: 5px 14px; border-radius: 20px; border: 2px solid var(--border); background: white; cursor: pointer; font-size: 0.8rem; font-weight: 500; font-family: inherit; transition: all 0.15s; }
.cv-dashboard .btn-filtre.actif, .cv-dashboard .btn-filtre-type.actif { border-color: var(--theme-accent); background: var(--theme-accent); color: white; }
.cv-dashboard .btn-filtre.btn-apayer.actif  { border-color: var(--amber); background: var(--amber); }
.cv-dashboard .btn-filtre.btn-asaisir.actif { border-color: #1565c0; background: #1565c0; }
.cv-dashboard .btn-filtre.btn-litige.actif  { border-color: #c62828; background: #c62828; }
.cv-dashboard .btn-filtre.btn-payee.actif   { border-color: #2e7d32; background: #2e7d32; }
.cv-dashboard .btn-filtre.btn-saisie.actif  { border-color: #6a1b9a; background: #6a1b9a; }
.cv-dashboard .btn-filtre-type.btn-facture.actif { border-color: #00796b; background: #00796b; }
.cv-dashboard .btn-filtre-type.btn-avoir.actif   { border-color: #7b1fa2; background: #7b1fa2; }
.cv-dashboard .btn-clear-filters { padding: 5px 14px; border-radius: 20px; border: 2px solid #ef5350; background: white; color: #ef5350; cursor: pointer; font-size: 0.8rem; margin-left: auto; font-family: inherit; }
.cv-dashboard .btn-clear-filters:hover { background: #ef5350; color: white; }
.cv-dashboard #cv-retry-banner { display: none; background: #fff8e1; border: 1px solid #ffcc02; border-radius: var(--r-sm); padding: 10px 16px; margin: 8px 0; font-size: 0.85rem; }
.cv-dashboard #cv-selection-recap { display: none; background: white; border: 2px solid var(--theme-accent); border-radius: var(--r-sm); padding: 14px; margin: 10px 0; }
.cv-dashboard .cv-dash-link { color: var(--theme-accent); font-weight: 600; text-decoration: none; cursor: pointer; }
.cv-dashboard .cv-dash-link:hover { text-decoration: underline; }
.cv-dashboard .cv-error { background: var(--red-light); border: 1px solid var(--red); padding: 12px; color: var(--red); border-radius: var(--r-sm); margin-bottom: 1rem; }

/* ══ SEARCH PANEL ════════════════════════════════════════════ */
.search-panel {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1.5rem; margin-bottom: 1.5rem;
}
.search-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.search-field label { display: block; font-size: 0.68rem; font-weight: 600; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 5px; }
.search-field input,
.search-field select {
  width: 100%; padding: 8px 11px;
  font-family: 'Inter', sans-serif; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink); outline: none;
  transition: border-color 0.15s;
}
.search-field input:focus, .search-field select:focus { border-color: var(--gold); background: var(--white); }

.search-actions { display: flex; align-items: center; gap: 10px; margin-top: 1rem; flex-wrap: wrap; }
.btn-search {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 700;
  padding: 9px 20px; background: var(--ink); color: #fff;
  border: none; border-radius: var(--r-sm); cursor: pointer;
  transition: opacity 0.15s; letter-spacing: 0.01em;
}
.btn-search:hover { opacity: 0.82; }
.btn-search:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-search svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.btn-reset-search {
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 500;
  padding: 9px 16px; background: transparent; color: var(--ink2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: all 0.15s;
}
.btn-reset-search:hover { border-color: var(--border2); }

.result-info { font-size: 0.78rem; color: var(--ink3); margin-left: auto; }

/* ══ RÉSULTATS TABLE ════════════════════════════════════════ */
.results-wrap {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
}
.results-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: var(--paper);
}
.results-title { font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em; }
.results-count {
  font-size: 0.7rem; font-weight: 600;
  background: var(--ink); color: #fff;
  padding: 2px 8px; border-radius: 99px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.81rem; }
thead tr { background: var(--paper); border-bottom: 1px solid var(--border); }
th {
  padding: 10px 12px; text-align: left;
  font-size: 0.65rem; font-weight: 700; color: var(--ink3);
  text-transform: uppercase; letter-spacing: 0.07em;
  white-space: nowrap; cursor: pointer; user-select: none;
}
th:hover { color: var(--ink2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--ink2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gold-light); }
tr.loading-row td { color: var(--ink3); font-style: italic; }

.td-nom { font-family: 'JetBrains Mono', monospace; font-size: 0.73rem; color: var(--ink); max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.td-montant { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; font-weight: 500; color: var(--ink); white-space: nowrap; }
.td-date { font-size: 0.78rem; white-space: nowrap; }

/* Badges statut */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.67rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; white-space: nowrap; letter-spacing: 0.03em; }
.b-asaisir  { background: var(--amber-light);  color: #92400e; border: 1px solid #fcd34d; }
.b-saisie   { background: var(--violet-light); color: #4c1d95; border: 1px solid #c4b5fd; }
.b-apayer   { background: var(--teal-light);   color: #134e4a; border: 1px solid #5eead4; }
.b-payee    { background: var(--green-light);  color: #14532d; border: 1px solid #86efac; }
.b-litige   { background: var(--red-light);    color: #7f1d1d; border: 1px solid #fca5a5; }
.b-default  { background: var(--border); color: var(--ink3); }

.btn-edit {
  font-family: 'Inter', sans-serif; font-size: 0.72rem; font-weight: 600;
  padding: 4px 11px; background: transparent;
  color: var(--teal); border: 1px solid var(--teal);
  border-radius: var(--r-sm); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-edit:hover { background: var(--teal); color: #fff; }

/* ══ PAGINATION ══════════════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 1rem; border-top: 1px solid var(--border);
}
.page-btn {
  font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 500;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--ink2); cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { border-color: var(--gold); color: var(--gold-dark); }
.page-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ══ FORMULAIRE FICHE ════════════════════════════════════════ */
.fiche-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif; font-size: 0.8rem; font-weight: 500;
  padding: 7px 14px; background: transparent;
  color: var(--ink2); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; transition: all 0.15s;
}
.btn-back:hover { border-color: var(--border2); }
.btn-back svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fiche-title { font-family: 'Inter', sans-serif; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; }
.fiche-nodeid { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--ink3); margin-top: 2px; }

.fiche-grid { display: flex; flex-direction: column; gap: 10px; }

/* ── Totaux barre ── */
.fiche-totaux {
  display: flex; gap: 0; background: var(--white);
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; flex-shrink: 0;
}
.fiche-total-item { flex: 1; padding: 10px 14px; text-align: center; border-right: 1px solid var(--border); }
.fiche-total-item:last-child { border-right: none; }
.fiche-total-label { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink3); margin-bottom: 3px; }
.fiche-total-val { font-size: 1.1rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fiche-total-val.ttc { color: var(--theme-accent); }

/* ── Cards ── */
.fiche-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); overflow: visible; }
.fiche-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 0.63rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--white); border-bottom: none; background: var(--theme-accent);
  font-family: 'Inter', sans-serif;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.fiche-card-head svg { width: 13px; height: 13px; stroke: var(--white); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fiche-card-body { padding: 14px 16px; }

/* ── Champs style "ligne du bas" ── */
.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 0.62rem; font-weight: 700; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px; }
.field input[type=text],
.field input[type=date],
.field input[type=number],
.field textarea,
.field select {
  width: 100%; padding: 6px 10px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--white); font-family: 'Inter', sans-serif;
  font-size: 0.85rem; font-weight: 400; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 3px var(--teal-light);
}
.field input[readonly] { background: var(--paper); color: var(--ink3); cursor: default; }
.field textarea { resize: vertical; min-height: 64px; }
.field select { cursor: pointer; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.field-row4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } .field-row3 { grid-template-columns: 1fr 1fr; } }

/* ── Status pills ── */
.status-pills { display: flex; gap: 5px; flex-wrap: wrap; padding-top: 2px; }
.status-pill { padding: 3px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; border: 1.5px solid var(--border); background: var(--white); color: var(--ink3); cursor: pointer; transition: all 0.12s; font-family: 'Inter', sans-serif; }
.status-pill:hover { border-color: var(--border2); color: var(--ink2); }
.status-pill.p-asaisir { background: var(--amber-light); border-color: var(--amber); color: var(--amber); }
.status-pill.p-saisie  { background: var(--violet-light); border-color: var(--violet); color: var(--violet); }
.status-pill.p-apayer  { background: var(--teal-light); border-color: var(--teal); color: var(--teal); }
.status-pill.p-payee   { background: var(--green-light); border-color: var(--green); color: var(--green); }
.status-pill.p-litige  { background: var(--red-light); border-color: var(--red); color: var(--red); }

.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check-row input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--theme-accent); cursor: pointer; }
.check-row label { font-size: 0.82rem; color: var(--ink2); cursor: pointer; font-weight: 400; }

/* ── Lignes analytiques modernes ── */
.analytic-modern-head {
  display: grid; gap: 8px; padding: 7px 14px;
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--ink3);
  border-bottom: 1px solid var(--border); background: var(--paper);
}
.ht-head  { grid-template-columns: 22px 2fr 120px 1fr 26px; }
.tva-head { grid-template-columns: 22px 2fr 120px 1fr 26px; }
.analytic-line {
  display: grid; gap: 8px; align-items: center;
  padding: 5px 14px; border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.analytic-line:last-of-type { border-bottom: none; }
.analytic-line:hover { background: var(--paper); }
.ht-line  { grid-template-columns: 22px 2fr 120px 1fr 26px; }
.tva-line { grid-template-columns: 22px 2fr 120px 1fr 26px; }
.analytic-num { font-size: 0.62rem; color: var(--ink3); text-align: center; font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.analytic-input, .analytic-select {
  width: 100%; font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 500;
  color: var(--ink); background: var(--white);
  border: 1.5px solid var(--border); border-radius: var(--r-sm); outline: none;
  padding: 4px 8px; transition: border-color 0.15s;
}
.analytic-input:focus, .analytic-select:focus { 
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 3px var(--teal-light);
}
.analytic-input::placeholder { color: var(--ink3); font-weight: 400; }
.analytic-select { appearance: none; cursor: pointer; }
.analytic-del {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid var(--theme-accent); background: var(--theme-accent);
  color: var(--white); cursor: pointer; font-size: 0.65rem; transition: all 0.12s;
}
.analytic-del:hover { background: var(--red); border-color: var(--red); }
.analytic-footer { padding: 8px 14px; }
.btn-add-line {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 6px;
  font-family: 'Inter', sans-serif; font-size: 0.75rem; font-weight: 600;
  border: 1.5px solid var(--theme-accent); background: var(--theme-accent);
  color: var(--white); cursor: pointer; transition: all 0.15s;
}
.btn-add-line:hover { opacity: 0.85; }

/* ── Autocomplete ── */
.ac-wrap { position: relative; width: 100%; }
.ac-input {
  width: 100%; font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 500;
  color: var(--ink); background: transparent; border: none;
  border-bottom: 1.5px solid transparent; outline: none;
  padding-bottom: 2px; transition: border-color 0.15s;
}
.ac-input:focus { border-bottom-color: var(--theme-accent); }
.ac-input::placeholder { color: var(--ink3); font-weight: 400; }
.ac-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-sm); box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  z-index: 500; max-height: 400px; overflow-y: auto;
  min-width: 260px;
}
.ac-dropdown.open { display: block; }
.ac-item {
  padding: 7px 12px; font-size: 0.8rem; cursor: pointer;
  color: var(--ink2); border-bottom: 1px solid var(--border);
  transition: background 0.1s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active { background: var(--teal-light); color: var(--theme-accent); }
.ac-item mark { background: none; color: var(--theme-accent); font-weight: 700; }
.ac-empty { padding: 10px 12px; font-size: 0.78rem; color: var(--ink3); font-style: italic; }


@media (max-width: 700px) { .aspects-row { grid-template-columns: 1fr; } }

/* Boutons sauvegarde */
.fiche-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.btn-save {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 700;
  padding: 10px 24px; background: var(--ink); color: #fff;
  border: none; border-radius: var(--r-sm); cursor: pointer;
  transition: opacity 0.15s; letter-spacing: 0.01em;
}
.btn-save:hover { opacity: 0.82; }
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-save svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.btn-cancel {
  font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 500;
  padding: 10px 18px; background: transparent; color: var(--ink2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: all 0.15s;
}
.btn-cancel:hover { border-color: var(--border2); }

/* ══ BOUTON GEMINI ══════════════════════════════════════════ */
.btn-gemini {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 700;
  padding: 9px 18px;
  background: linear-gradient(135deg, #4285f4 0%, #34a853 50%, #ea4335 100%);
  color: #fff; border: none; border-radius: var(--r-sm);
  cursor: pointer; transition: opacity 0.15s; letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn-gemini:hover { opacity: 0.88; }
.btn-gemini:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-gemini svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ══ PANNEAU CONFIRMATION GEMINI ════════════════════════════ */
#gemini-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: transparent;
  display: none;
  z-index: 250;
  pointer-events: none; /* fond totalement transparent, ne bloque rien */
}
#gemini-panel.visible { display: block; }
.gemini-box {
  background: var(--white);
  border-radius: 14px;
  width: calc(50vw - 2rem); max-width: 600px;
  max-height: calc(100vh - 2rem); overflow-y: auto;
  pointer-events: all;
  position: fixed; /* pour le drag */
  top: 1rem; right: 1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  cursor: default;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.gemini-head {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.gemini-head-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, #4285f4, #34a853);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.gemini-head-icon svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gemini-head h3 { font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 800; letter-spacing: -0.02em; }
.gemini-head p  { font-size: 0.75rem; color: var(--ink3); margin-top: 2px; }
.gemini-body { padding: 1.25rem 1.5rem; }
.gemini-field-row {
  display: flex; align-items: center;
  padding: 8px 10px; border-radius: var(--r-sm);
  margin-bottom: 6px; gap: 10px;
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.gemini-field-row:hover { background: var(--paper); }
.gemini-field-row.accepted { background: var(--green-light); border-color: #86efac; }
.gemini-field-row.rejected { background: var(--paper); opacity: 0.5; }
.gemini-field-label { font-size: 0.72rem; font-weight: 600; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.06em; width: 130px; flex-shrink: 0; }
.gemini-field-val { flex: 1; font-size: 0.85rem; color: var(--ink); font-weight: 500; }
.gemini-field-val.empty { color: var(--ink3); font-style: italic; }
.gemini-field-actions { display: flex; gap: 5px; flex-shrink: 0; }
.gemini-accept, .gemini-reject {
  font-size: 0.7rem; font-weight: 600; padding: 3px 9px;
  border-radius: var(--r-sm); cursor: pointer; border: 1px solid; transition: all 0.12s;
}
.gemini-accept { color: var(--green); border-color: #86efac; background: transparent; }
.gemini-accept:hover { background: var(--green); color: #fff; border-color: var(--green); }
.gemini-reject { color: var(--ink3); border-color: var(--border); background: transparent; }
.gemini-reject:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
.gemini-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
}
.btn-apply-all {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 700;
  padding: 9px 20px;
  background: var(--ink); color: #fff;
  border: none; border-radius: var(--r-sm); cursor: pointer; transition: opacity 0.15s;
}
.btn-apply-all:hover { opacity: 0.82; }
.btn-close-gemini {
  font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 500;
  padding: 9px 16px; background: transparent; color: var(--ink2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: all 0.15s;
}
.btn-close-gemini:hover { border-color: var(--border2); }
.gemini-loading {
  padding: 2rem; text-align: center; color: var(--ink3);
}
.gemini-confidence {
  font-size: 0.68rem; padding: 2px 7px; border-radius: 99px;
  font-weight: 600; flex-shrink: 0;
}
.conf-high { background: var(--green-light); color: #14532d; }
.conf-med  { background: var(--amber-light); color: #78350f; }
.conf-low  { background: var(--red-light);   color: #7f1d1d; }



/* ══ EMPTY / LOADING ════════════════════════════════════════ */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ink3); }
.empty-state strong { display: block; font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 700; color: var(--ink2); margin-bottom: 6px; }

.loading-dots span {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); margin: 0 2px;
  animation: dot 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%,80%,100% { opacity: 0.2; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* ══ SITE PICKER ═══════════════════════════════════════════ */
#site-overlay {
  position: fixed; inset: 0; background: var(--ink);
  display: none; align-items: center; justify-content: center; z-index: 190;
}
#site-overlay.visible { display: flex; }
.site-box { width: 100%; max-width: 460px; padding: 2.5rem; }
.site-box h2 { font-family: 'Inter', sans-serif; font-size: 1.3rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; margin-bottom: 4px; }
.site-box p  { font-size: 0.8rem; color: var(--ink3); margin-bottom: 1.5rem; }
.site-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; margin-bottom: 1rem; }
.site-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--r-sm); cursor: pointer; transition: all 0.15s;
  color: rgba(255,255,255,0.75); font-size: 0.88rem;
}
.site-item:hover  { background: rgba(201,168,76,0.12); border-color: rgba(201,168,76,0.3); color: var(--gold); }
.site-item.sel    { background: rgba(201,168,76,0.18); border-color: var(--gold); color: var(--gold); }
.site-item svg    { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.site-item-name   { flex: 1; font-weight: 500; }
.site-item-id     { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--ink3); }
.btn-site-ok {
  width: 100%; padding: 11px; background: var(--gold); color: var(--ink);
  border: none; border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.15s;
}
.btn-site-ok:hover { opacity: 0.88; }
.btn-site-ok:disabled { opacity: 0.35; cursor: not-allowed; }
.site-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(201,168,76,0.1); color: var(--gold-dark);
  border: 1px solid rgba(201,168,76,0.3); border-radius: 99px;
  padding: 4px 12px 4px 8px; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.site-badge:hover { background: rgba(201,168,76,0.2); }
.site-badge svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ══ MODAL DOSSIER (dashboard) ══════════════════════════════ */
#folder-modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 9999; align-items: center; justify-content: center;
}
#folder-modal-overlay.visible { display: flex; }
.folder-modal-box {
  background: var(--white); border-radius: var(--r); width: 480px; max-width: 95vw;
  max-height: 70vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.folder-modal-head {
  background: var(--theme-accent); color: white; padding: 14px 18px;
  border-radius: var(--r) var(--r) 0 0; display: flex;
  justify-content: space-between; align-items: center;
}
.folder-modal-head button { background: none; border: none; color: white; font-size: 20px; cursor: pointer; }
#folder-breadcrumb { padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--border); font-size: 12px; min-height: 32px; }
#folder-breadcrumb span { cursor: pointer; color: var(--theme-accent); }
#folder-search { padding: 10px 16px; background: #f9f9f9; border-bottom: 1px solid var(--border); }
#folder-search input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 0.95rem; }
#folder-search input:focus { outline: none; border-color: var(--theme-accent); box-shadow: 0 0 0 2px rgba(0, 115, 207, 0.12); }
#folder-search-hint { margin-top: 8px; color: #666; font-size: 12px; }
#folder-list { overflow-y: auto; flex: 1; padding: 6px 0; min-height: 120px; max-height: 45vh; }
.folder-row { display: flex; align-items: center; border-bottom: 1px solid #f5f5f5; }
.folder-row-sel { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 14px; cursor: pointer; }
.folder-row-sel:hover { background: rgba(0, 115, 207, 0.04); }
.folder-row-title { display: flex; align-items: center; gap: 10px; width: 100%; }
.folder-row-info { display: block; font-size: 0.82rem; color: #666; word-break: break-word; }
.folder-row-arrow { padding: 10px 16px; cursor: pointer; color: var(--theme-accent); font-size: 18px; font-weight: bold; border-left: 1px solid #f0f0f0; }
.folder-row-sel { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; }
.folder-row-arrow { padding: 10px 16px; cursor: pointer; color: var(--theme-accent); font-size: 18px; font-weight: bold; border-left: 1px solid #f0f0f0; }
.folder-modal-foot {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
}
#folder-selected-label { font-size: 13px; color: var(--ink2); font-style: italic; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-foot-btns { display: flex; gap: 8px; }
.folder-foot-btns button {
  padding: 6px 12px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer; font-family: inherit;
}
#folder-btn-reset { border: 1px solid var(--border); background: white; }
#folder-btn-validate { border: none; background: #4caf50; color: white; }
#folder-btn-validate:disabled { opacity: 0.45; cursor: not-allowed; }
.cv-folder-btn {
  padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: white; cursor: pointer; font-size: 0.85rem; font-family: inherit;
}
.cv-folder-btn:hover { border-color: var(--theme-accent); color: var(--theme-accent); }

/* ══ DOUBLE ÉCRAN FICHE ═════════════════════════════════════ */
#view-fiche { padding: 0; display: none; flex-direction: column; height: calc(100vh - 57px); overflow: hidden; }
#view-fiche.active { display: flex; }

.fiche-topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 0.75rem 1.5rem;
  background: var(--white); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.fiche-subbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  padding: 8px 0 12px 0;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  margin-bottom: 4px;
}
.fiche-subbar-field {
  display: flex; align-items: center; gap: 6px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px 10px;
  transition: border-color 0.15s;
  min-width: 0;
}
.fiche-subbar-field:focus-within { border-color: var(--theme-accent); box-shadow: 0 0 0 2px var(--teal-light); }
.fiche-subbar-label {
  font-size: 0.6rem; font-weight: 700; color: var(--ink3);
  text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; flex-shrink: 0;
}
.fiche-subbar-input, .fiche-subbar-select {
  border: none; outline: none; background: transparent;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 500;
  color: var(--ink); min-width: 60px; width: auto;
}
.fiche-subbar-select { cursor: pointer; appearance: none; padding-right: 4px; }
.fiche-subbar-sep { width: 1px; background: var(--border); align-self: stretch; margin: 0 2px; flex-shrink: 0; }
.fiche-split { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.pdf-panel.fullscreen {
  position: fixed !important; inset: 0 !important; z-index: 800 !important;
  width: 100% !important; max-width: none !important; border-radius: 0 !important;
}
.pdf-panel {
  width: 50%; flex-shrink: 0; display: flex; flex-direction: column;
  border-right: 2px solid var(--border); background: #2a2a2a;
  transition: width 0.1s; overflow: hidden;
  max-height: 100vh;
}
.pdf-panel-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--sidebar-bg, var(--ink)); color: rgba(255,255,255,0.7);
  font-size: 0.72rem; font-weight: 600; flex-shrink: 0;
}
.pdf-panel-head svg { width: 13px; height: 13px; stroke: var(--sidebar-text, var(--gold)); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pdf-open-link {
  margin-left: auto; font-size: 0.7rem; color: var(--sidebar-text, var(--gold));
  text-decoration: none; display: flex; align-items: center; gap: 4px;
}
.pdf-open-link:hover { text-decoration: underline; }
#pdf-iframe { display: none; }
#pdf-viewer-container { overflow-y: auto !important; background: #525659; flex-shrink: 0; }
.pdf-page-wrapper { position: relative; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.pdf-page-wrapper canvas { display: block; }
.textLayer {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden; opacity: 1; line-height: 1;
}
.textLayer > span {
  color: transparent; position: absolute; white-space: pre;
  cursor: text; transform-origin: 0% 0%;
}
.textLayer .selected { background: rgba(0, 120, 255, 0.75) !important; border-radius: 2px; }
.textLayer .searchResult { background: rgba(255, 200, 0, 0.85) !important; border-radius: 2px; }
.textLayer .persistentSearchResult { background: rgba(255, 80, 0, 0.7) !important; border-radius: 2px; }
/* Indicateur champ actif pour FormFiller */
.ff-active-field { outline: 2px solid var(--theme-accent) !important; outline-offset: 2px; }
/* Champ obligatoire manquant */
.field-required-error {
  border: 2px solid var(--red) !important;
  box-shadow: 0 0 0 3px rgba(220,53,69,0.18) !important;
  border-radius: var(--r-sm) !important;
  animation: shake 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.pdf-unavail {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: rgba(255,255,255,0.3); font-size: 0.85rem; text-align: center; padding: 2rem;
}
.pdf-unavail svg { width: 40px; height: 40px; stroke: rgba(255,255,255,0.15); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.form-panel { flex: 1; overflow-y: auto !important; padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; min-height: 0; max-height: 100%; }
.split-handle { width: 5px; flex-shrink: 0; cursor: col-resize; background: var(--border); }
.split-handle:hover { background: var(--gold); }
.btn-pdf {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'Inter', sans-serif; font-size: 0.7rem; font-weight: 600;
  padding: 3px 9px; background: transparent;
  color: var(--gold-dark); border: 1px solid rgba(201,168,76,0.5);
  border-radius: var(--r-sm); cursor: pointer; transition: all 0.15s; white-space: nowrap;
  text-decoration: none;
}
.btn-pdf:hover { background: var(--gold); color: var(--ink); }
.btn-pdf svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .view { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  .pdf-panel { display: none; }
  .form-panel { width: 100%; }
}
.cv-dt-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.cv-dt-toolbar .dt-length { order: 1; }
.cv-dt-toolbar .dt-buttons { order: 2; display: flex; gap: 6px; flex-wrap: wrap; }
.cv-dt-toolbar .dt-search { order: 3; margin-left: auto; }
