:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --amber: #d97706;
  --green: #059669;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button { cursor: pointer; font: inherit; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 60%, #134e4a 100%); }
.login-card { background: var(--card); border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.logo { font-size: 28px; font-weight: 800; color: var(--brand); letter-spacing: -.5px; }
.logo span { color: var(--text); }
.tagline { color: var(--muted); margin: 4px 0 24px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; border: none; margin: 0 0 0 8px; vertical-align: middle; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 11px 18px; font-weight: 600; width: 100%; }
.btn:hover { background: var(--brand-dark); }
.btn-sm { width: auto; padding: 7px 14px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn-danger { background: var(--danger); }
.error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #0b3b38; color: #d1fae5; padding: 20px 12px; display: flex; flex-direction: column; }
.sidebar .logo { color: #5eead4; padding: 0 10px 18px; }
.sidebar .logo span { color: #fff; }
.nav-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: #a7f3d0;
  padding: 11px 12px; border-radius: 8px; font-size: 15px; margin-bottom: 2px; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 10px; font-size: 13px; color: #99f6e4; }
.lang-switch { display: flex; gap: 6px; margin-bottom: 10px; }
.lang-switch button { flex: 1; background: rgba(255,255,255,.1); color: #d1fae5; border: 0; border-radius: 6px; padding: 6px; }
.lang-switch button.on { background: #5eead4; color: #0b3b38; font-weight: 700; }

.main { padding: 26px 30px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }

/* cards & tables */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--brand); }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 12px 14px; background: #f9fafb; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.active, .badge.completed, .badge.approved { background: #d1fae5; color: var(--green); }
.badge.published { background: #e0e7ff; color: #4338ca; }
.badge.in_progress, .badge.pending { background: #fef3c7; color: var(--amber); }
.badge.inactive { background: #f3f4f6; color: var(--muted); }
.badge.exception, .badge.rejected { background: #fee2e2; color: var(--danger); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center;
  justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border-radius: 14px; padding: 24px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px; }
  .sidebar .logo { padding: 0 8px; font-size: 20px; }
  .nav-item { width: auto; }
  .sidebar-footer { margin: 0 0 0 auto; display: flex; gap: 8px; align-items: center; }
  .main { padding: 16px; }
  .modal .row { grid-template-columns: 1fr; }
}

/* v4 : branding & onboarding */
.beta { background: #f59e0b; color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; vertical-align: middle; letter-spacing: .5px; }
.foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }
.foot a { color: var(--brand); }
.onb { display: flex; flex-direction: column; gap: 2px; font-size: 12px; white-space: nowrap; }
.onb label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.onb input { width: auto; }

/* v6 : logo */
.logo-img { width: 84px; height: 84px; display: block; margin: 0 auto 10px; }
.login-card .logo, .login-card .tagline { text-align: center; }
.logo-side { width: 26px; height: 26px; vertical-align: middle; margin-right: 6px; }
.sidebar .logo { display: flex; align-items: center; gap: 2px; }

/* v6.1 : lockup paysage sur la page de connexion */
.brand-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 20px; }
.brand-icon { width: 72px; height: 72px; flex-shrink: 0; }
.brand-row .logo { font-size: 30px; }
.brand-sub { font-size: 11px; letter-spacing: 2px; color: var(--brand); font-weight: 700; margin-top: 2px; }

/* v9 : logo paysage (image du serveur si présente, sinon lockup CSS) */
.brand-land { margin-bottom: 20px; }
.brand-land .with-img { display: flex; align-items: center; justify-content: center; gap: 10px; }
.logo-landscape { max-width: 260px; width: 100%; height: auto; }
.logo {
  max-width: 250px;        /* Controls the size of the logo */
  height: auto;
}
/* v16 : tableau de bord compact (2 rangées, cartes réduites) */
.stats { grid-template-columns: repeat(3, 230px); justify-content: start; gap: 12px; }
.stat { padding: 12px 16px; }
.stat .num { font-size: 22px; }
.stat .lbl { font-size: 12px; }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* v19 : page compte */
.acct-section { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; margin: 4px 0 8px; }
.acct-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); text-decoration: none;
  font-weight: 600; }
.acct-row:last-child { border-bottom: 0; }
.acct-row:hover { background: #f9fafb; }

/* v20 : panneaux du compte */
.acct-panel { padding: 14px 18px; border-bottom: 1px solid var(--border); background: #fafafa; }
.chk { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: 500; }
.chk input { width: auto; }

/* v31 : capture guidée de la pièce d'identité */
.idcard { margin: 14px 0; }
.idcard-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--brand-dark); }
.idframe { position: relative; border: 3px dashed var(--border); border-radius: 12px; aspect-ratio: 1.586;
  display: flex; align-items: center; justify-content: center; background: #fafafa; overflow: hidden;
  text-align: center; padding: 10px; }
.idframe span { font-size: 12px; color: var(--muted); }
.idframe img { width: 100%; height: 100%; object-fit: cover; }
.idframe.ok { border-color: var(--green); border-style: solid; }
.idframe.bad { border-color: var(--danger); border-style: solid; }
.idwarn { position: absolute; left: 0; right: 0; bottom: 0; background: var(--danger); color: #fff;
  font-size: 12px; padding: 4px 8px; }

/* v35 : carte */
#mapBox { height: 560px; border-radius: 12px; border: 1px solid var(--border); z-index: 1; }
.maplegend { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.maplegend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px;
  vertical-align: middle; }
.maplegend .dot.pat { background: #dc2626; }
.maplegend .dot.cg { background: #0f766e; }
.maplegend .dot.lnk { background: #059669; border-radius: 2px; width: 18px; height: 3px; }
.leaflet-popup-content { font-family: inherit; }
