/* ============================================================
   LegalTrack - Feuille de style
   Charte graphique :
   - Fond dominant : White #FFFFFF et Midnight #002032
   - Couleurs principales : Jade #007380, Seafoam #25E2CC, Blue #003D5B
   - Accent parcimonieux : Sunshine Yellow #FBCA18
   - Neutres : Cool Gray #F2F2F2, Dark Charcoal #2A2B2C
   - Teintes Seafoam pour fonds doux
   Aucun emoji n'est utilise : uniquement du texte et des formes CSS.
   ============================================================ */

:root {
  --white: #FFFFFF;
  --midnight: #002032;
  --jade: #007380;
  --seafoam: #25E2CC;
  --blue: #003D5B;
  --yellow: #FBCA18;
  --gray: #F2F2F2;
  --charcoal: #2A2B2C;
  --raspberry: #CC3262;   /* usage restreint : uniquement le badge Refuse */
  --tint-80: #51E8D6;
  --tint-60: #7CEEE0;
  --tint-40: #A8F3EB;
  --tint-20: #D3F8F5;
  --tint-10: #E9FCFA;
  --border: #DFEAEE;
  --text-soft: #5A6B72;
  --danger: #CC3262;
  --shadow: 0 1px 3px rgba(0, 32, 50, 0.10), 0 4px 14px rgba(0, 32, 50, 0.06);
  --radius: 10px;
  --font: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray);
  font-family: var(--font);
  color: var(--charcoal);
  font-size: 14.5px;
  line-height: 1.45;
}

button { font-family: var(--font); }
a { color: var(--jade); }

.boot-loading {
  padding: 60px;
  text-align: center;
  color: var(--text-soft);
}

/* ---------------- boutons ---------------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--jade); color: var(--white); }
.btn-primary:hover { background: #006370; }
.btn-ghost {
  background: var(--white);
  color: var(--jade);
  border-color: #BFD9DE;
}
.btn-ghost:hover { background: var(--tint-10); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 18px; }
.btn-del {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.btn-del:hover { text-decoration: underline; }

/* ---------------- champs ---------------- */
.input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--white);
  color: var(--charcoal);
  outline: none;
  font-family: var(--font);
}
.input:focus { border-color: var(--jade); box-shadow: 0 0 0 2px var(--tint-40); }
.input-sm { padding: 6px 10px; font-size: 13px; }
.grow { flex: 1 1 160px; min-width: 120px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue);
  margin: 10px 0 4px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
}

/* ---------------- ecran de connexion ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--tint-20) 0%, transparent 60%),
    linear-gradient(160deg, var(--midnight) 0%, var(--blue) 100%);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 38px 40px 30px;
  width: 100%;
  max-width: 430px;
}
.login-brand { text-align: center; margin-bottom: 18px; }
.brand-mark {
  font-size: 30px;
  font-weight: 800;
  color: var(--midnight);
  letter-spacing: -0.5px;
}
.brand-mark.small { font-size: 21px; }
.brand-sub { color: var(--text-soft); font-size: 13px; margin-top: 2px; }
.brand-sub.tiny { font-size: 11px; }
.login-error {
  background: #FCE9EF;
  color: var(--raspberry);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-top: 10px;
}
.login-help {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.demo-banner {
  background: var(--yellow);
  color: var(--charcoal);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.demo-banner-top { border-radius: 0; margin: 0; text-align: center; }

/* ---------------- entete application ---------------- */
.topbar {
  background: var(--midnight);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.topbar-brand { min-width: 150px; }
.topbar-brand .brand-mark { color: var(--white); font-size: 20px; }
.topbar-brand .brand-sub { color: var(--tint-60); }
.topnav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  background: transparent;
  border: none;
  color: #C6D8E0;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-btn:hover { color: var(--white); background: rgba(255, 255, 255, 0.08); }
.nav-active { color: var(--midnight); background: var(--seafoam); }
.nav-active:hover { background: var(--tint-80); color: var(--midnight); }
.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.user-chip { display: flex; flex-direction: column; align-items: flex-end; }
.user-name { font-size: 13px; font-weight: 600; }
.role-badge {
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 8px;
  margin-top: 2px;
}
.role-admin { background: var(--seafoam); color: var(--midnight); }
.role-user { background: rgba(255, 255, 255, 0.15); color: var(--tint-60); }
.topbar-user .btn-ghost { background: transparent; color: var(--tint-60); border-color: #29515F; }
.topbar-user .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

.main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ---------------- panneaux et barres d'outils ---------------- */
.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 22px;
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.panel-title { margin: 0; font-size: 19px; color: var(--midnight); }
.panel-count { color: var(--text-soft); font-size: 13px; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  flex-wrap: wrap;
}
.toolbar-wrap { flex-wrap: wrap; }
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.toolbar-sep { color: var(--text-soft); font-size: 12.5px; }
.note {
  background: var(--tint-10);
  border: 1px solid var(--tint-40);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 12.8px;
  color: var(--blue);
  margin: 10px 0;
}
.save-state { font-size: 12.5px; color: var(--text-soft); min-width: 120px; }
.save-state.save-ok { color: var(--jade); font-weight: 600; }
.save-state.save-err { color: var(--danger); font-weight: 600; }
.loading { color: var(--text-soft); padding: 26px; text-align: center; }
.empty-state {
  color: var(--text-soft);
  padding: 26px 16px;
  text-align: center;
  font-size: 13.5px;
}

/* ---------------- onglets de modules ---------------- */
.module-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.tab-group { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tab-group-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-soft);
  min-width: 76px;
}
.tab-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--blue);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.chip:hover { border-color: var(--jade); color: var(--jade); }
.chip-active {
  background: var(--jade);
  border-color: var(--jade);
  color: var(--white);
}
.chip-active:hover { color: var(--white); }
.tag-registre {
  background: var(--tint-20);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 12px;
  padding: 2px 8px;
  vertical-align: middle;
  text-transform: uppercase;
}
.tag-formalite {
  background: var(--tint-10);
  border: 1px solid var(--tint-40);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 12px;
  padding: 2px 8px;
  vertical-align: middle;
  text-transform: uppercase;
}
.sel-hint { font-size: 12px; color: var(--text-soft); }

/* ---------------- menus deroulants a selections multiples (v2) ---------------- */
.ms { position: relative; display: inline-flex; }
.ms-btn {
  text-align: left;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.ms-btn.ms-active { border-color: var(--jade); color: var(--jade); font-weight: 600; }
.ms-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 250px;
  max-height: 280px;
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 40;
  padding: 6px 0;
}
.ms-group {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-soft);
  padding: 7px 12px 3px;
  border-top: 1px solid var(--border);
}
.ms-group:first-child { border-top: none; }
.ms-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ms-opt:hover { background: var(--tint-10); }
.ms-opt input { accent-color: var(--jade); margin: 0; }

/* ---------------- import des anciennes donnees (v3) ---------------- */
.import-summary { font-size: 13px; font-weight: 600; color: var(--blue); margin: 10px 0 6px; }
.imp-bad { background: #FCE9EF; }
.imp-err { color: var(--danger); font-weight: 600; }
#imp-paste { font-size: 12.5px; font-family: monospace; }
.users-table .input { min-width: 110px; }

/* ---------------- tableau des saisies ---------------- */
.entries-wrap { overflow: hidden; }
/* Zone deroulante : les tableaux longs scannent verticalement, en-tetes figes */
.table-scroll { overflow: auto; max-height: 62vh; border: 1px solid var(--border); border-radius: 8px; }
.entries-table { border-collapse: collapse; width: max-content; min-width: 100%; }
.entries-table th {
  background: var(--midnight);
  color: var(--white);
  font-size: 11.8px;
  font-weight: 600;
  text-align: left;
  padding: 8px 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.entries-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.entries-table tr.row-editable:nth-child(even) td { background: var(--tint-10); }
.entries-table tr.row-locked td { background: var(--gray); }
.entries-table tr.row-locked .cell-static { color: var(--text-soft); }
.cell-input {
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 6px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--charcoal);
  border-radius: 6px;
  min-width: 90px;
  outline: none;
}
select.cell-input, input[type="date"].cell-input {
  border: 1px solid var(--border);
  background: var(--white);
}
.cell-input:hover { border-color: var(--tint-60); }
.cell-input:focus { border-color: var(--jade); background: var(--white); }
textarea.cell-area { resize: vertical; min-width: 180px; max-width: 340px; line-height: 1.35; }
.cell-static { font-size: 13px; padding: 4px 8px; white-space: nowrap; }
.cell-agent { font-weight: 600; color: var(--blue); min-width: 130px; }
.cell-link { display: flex; align-items: center; gap: 6px; }
.link-open {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--white);
  background: var(--blue);
  border-radius: 5px;
  padding: 3px 7px;
  text-decoration: none;
  white-space: nowrap;
}
.link-open:hover { background: var(--jade); }
.cell-actions { white-space: nowrap; min-width: 110px; }
.row-state { font-size: 10.5px; margin-left: 6px; color: var(--text-soft); }
.row-state.saving { color: var(--text-soft); }
.row-state.saved { color: var(--jade); font-weight: 700; }
.row-state.save-err { color: var(--danger); font-weight: 700; }

/* badges de statut */
.statut-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
  padding: 2px 9px;
  white-space: nowrap;
}
.st-valide { background: var(--tint-40); color: var(--jade); }
.st-refuse { background: #FCE9EF; color: var(--raspberry); }
.st-attente { background: var(--yellow); color: var(--charcoal); }
.st-nt { background: var(--gray); color: var(--charcoal); }
.st-remonte { background: var(--tint-20); color: var(--blue); }
.st-unk { background: var(--gray); color: var(--text-soft); }

/* ---------------- formulaire nouvelle ligne ---------------- */
.new-form {
  background: var(--tint-10);
  border: 1px solid var(--tint-40);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 12px 0;
}
.new-form-title { margin: 0 0 4px; font-size: 15.5px; color: var(--midnight); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 16px;
}
.form-grid-narrow { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.form-field .input, .form-field textarea.input { width: 100%; }
.form-field textarea.input { resize: vertical; }
.new-form-actions { margin-top: 14px; display: flex; gap: 10px; }

/* ---------------- dashboard ---------------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}
.kpi {
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--gray);
  border: 1px solid var(--border);
}
.kpi-value { font-size: 27px; font-weight: 800; color: var(--midnight); }
.kpi-label { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.kpi-valide { background: var(--tint-20); border-color: var(--tint-60); }
.kpi-valide .kpi-value { color: var(--jade); }
.kpi-refuse { background: #FCE9EF; border-color: #F2B9CB; }
.kpi-refuse .kpi-value { color: var(--raspberry); }
.kpi-attente { background: #FFF7DB; border-color: var(--yellow); }
.kpi-nt { background: var(--gray); }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.chart-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--white);
}
.chart-wide { grid-column: span 2; }
.chart-title { margin: 0 0 8px; font-size: 13.5px; color: var(--blue); }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--text-soft); text-align: center; padding: 40px 10px; font-size: 13px; }
.doughnut-wrap { display: flex; align-items: center; gap: 18px; }
.doughnut-svg { width: 150px; flex-shrink: 0; }
.legend { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.section-title { font-size: 15px; color: var(--midnight); margin: 22px 0 10px; }

/* ---------------- tableaux secondaires ---------------- */
.mini-table { border-collapse: collapse; width: 100%; }
.mini-table th {
  background: var(--tint-10);
  color: var(--blue);
  font-size: 12px;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.mini-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-table tr:hover td { background: var(--tint-10); }
.cell-small { font-size: 12px; color: var(--text-soft); }
.users-table select.input-sm { min-width: 120px; }

/* ---------------- listes ---------------- */
.chips-values { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip-value {
  background: var(--tint-10);
  border: 1px solid var(--tint-40);
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}
.chip-del {
  background: none;
  border: none;
  color: var(--raspberry);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.chip-del:hover { text-decoration: underline; }

/* ---------------- modal et toasts ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 32, 50, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 24px 26px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.modal-title { margin: 0 0 8px; color: var(--midnight); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal .input { width: 100%; }

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.toast {
  background: var(--midnight);
  color: var(--white);
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13.5px;
  max-width: 380px;
  opacity: 0;
  transform: translateY(8px);
  transition: all .3s ease;
  border-left: 4px solid var(--seafoam);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-err { border-left-color: var(--raspberry); background: #4A0F20; }

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: span 1; }
  .topbar { gap: 10px; }
  .topbar-user { margin-left: 0; width: 100%; }
}
