/* ============================================================
   RécupFacture — Charte Elecom (thème centralisé, modifiable ici)
   Remplacez les hex ci-dessous par les couleurs officielles Elecom.
   ============================================================ */
:root {
  --brand:        #1b5cff;   /* bleu électrique Elecom (accent principal) */
  --brand-strong: #0d3fd4;
  --brand-2:      #00c2b8;   /* teal audiovisuel (accent secondaire) */
  --navy:         #0f1e3d;   /* bleu nuit (barres, sidebar) */
  --navy-2:       #16294f;

  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --surface-2:    #f9fafd;
  --border:       #e5e9f2;
  --ink:          #10192b;
  --muted:        #647089;
  --muted-2:      #99a3b7;

  --ok:           #16a34a;
  --ok-bg:        #e7f6ec;
  --warn:         #d97706;
  --warn-bg:      #fdf1de;
  --danger:       #dc2626;
  --danger-bg:    #fbe9e9;
  --info-bg:      #e8eefe;

  --radius:   14px;
  --radius-s: 9px;
  --shadow:   0 1px 2px rgba(16,25,43,.04), 0 8px 24px rgba(16,25,43,.06);
  --shadow-lg:0 12px 40px rgba(16,25,43,.14);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3 { margin: 0; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 9px 15px; font-size: 14px; font-weight: 600; background: var(--surface-2); color: var(--ink); transition: .15s; }
.btn:hover { background: #eef1f7; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(27,92,255,.28); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.danger:hover { background: #f6dada; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 15% -10%, #1b3a7a 0%, var(--navy) 45%, #0a1428 100%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 34px 30px; }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card h1 { font-size: 20px; }
.login-card p.sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 24px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-s); font-size: 14px; background: var(--surface); color: var(--ink); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27,92,255,.15); }
.form-error { color: var(--danger); font-size: 13px; margin: 6px 0 0; min-height: 18px; }

/* ---------- Logo ---------- */
.logo { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; flex: none;
  box-shadow: 0 6px 16px rgba(27,92,255,.35); }
.logo.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }
.wordmark { font-weight: 800; letter-spacing: -.02em; }
.wordmark .accent { color: var(--brand); }

/* ---------- Layout appli ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #c9d4ea; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; color: #fff; }
.sidebar .brand .wordmark { font-size: 16px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #b7c4de; font-weight: 600; font-size: 14px; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(27,92,255,.9), rgba(27,92,255,.55)); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.sidebar .userbox { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; font-size: 13px; }
.sidebar .userbox .who { color: #fff; font-weight: 700; }
.sidebar .userbox .role { color: var(--muted-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar .userbox .links { display: flex; gap: 12px; margin-top: 8px; }
.sidebar .userbox .links a { color: #9fb0d0; font-size: 12.5px; }
.sidebar .userbox .links a:hover { color: #fff; }

.main { padding: 26px 30px 60px; max-width: 1500px; }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topline h1 { font-size: 23px; letter-spacing: -.02em; }
.topline .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* ---------- Cards / KPIs ---------- */
.grid-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; }
.kpi .value.small { font-size: 24px; }
.kpi .foot { color: var(--muted-2); font-size: 12px; margin-top: 6px; }
.kpi.accent { background: linear-gradient(135deg, var(--navy), var(--navy-2)); border: none; color: #fff; }
.kpi.accent .label { color: #a8b6d6; }
.kpi.accent .foot { color: #8fa0c4; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-h { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card .card-h h2 { font-size: 16px; }
.card .card-b { padding: 16px 18px; }

/* ---------- Jauge taux ---------- */
.gauge { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; margin: 6px auto 2px;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--border) 0); }
.gauge .inner { width: 104px; height: 104px; background: var(--surface); border-radius: 50%; display: grid; place-items: center; text-align: center; }
.gauge .inner b { font-size: 27px; font-weight: 800; }
.gauge .inner span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Layout détail (2 colonnes) ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.stat-row:last-child { border-bottom: none; }
.stat-row .k { color: var(--muted); }
.stat-row .v { font-weight: 700; }

/* ---------- Tableau lignes ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; padding: 11px 12px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
td.montant { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.libelle { font-weight: 600; }

/* ---------- Badges statut ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 100px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-a_chercher { color: #b45309; background: var(--warn-bg); }
.st-en_cours   { color: var(--brand-strong); background: var(--info-bg); }
.st-recupere   { color: var(--ok); background: var(--ok-bg); }
.st-introuvable{ color: var(--danger); background: var(--danger-bg); }
.st-deja_ok    { color: #15803d; background: #e9f7ee; }

select.statut-select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; background: var(--surface); }

/* ---------- Dropzone ---------- */
.dropzone { border: 2px dashed #c3ccdd; border-radius: var(--radius); padding: 34px 20px; text-align: center; background: var(--surface-2); transition: .15s; }
.dropzone.drag { border-color: var(--brand); background: var(--info-bg); }
.dropzone .big { font-size: 15px; font-weight: 700; margin: 10px 0 4px; }
.dropzone .hint { color: var(--muted); font-size: 13px; }

/* ---------- Demandes list ---------- */
.demandes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.demande-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; cursor: pointer; transition: .15s; }
.demande-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: #d3dcec; }
.demande-card h3 { font-size: 15.5px; margin-bottom: 4px; }
.demande-card .meta { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.progress { height: 8px; background: var(--border); border-radius: 100px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 100px; }
.demande-card .row2 { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- Utilisateurs ---------- */
.role-pill { padding: 3px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 700; }
.role-super_admin { background: #efe7fb; color: #6b21a8; }
.role-admin { background: var(--info-bg); color: var(--brand-strong); }
.role-gestionnaire { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,30,61,.5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; padding: 24px; }
.modal h2 { font-size: 18px; margin-bottom: 6px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 16px; font-weight: 700; color: var(--ink); margin: 8px 0 4px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 100; max-width: 90vw; }
.toast.err { background: var(--danger); }
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(27,92,255,.25); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-full { display: grid; place-items: center; min-height: 100vh; }
.pill-note { display: inline-block; background: var(--warn-bg); color: #92500a; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 236px; left: -260px; transition: left .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .main { padding: 18px 16px 60px; }
  .detail-grid { grid-template-columns: 1fr; }
  .dash-col { position: static; order: -1; }
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }
