/*
 * Console ZiamaGo — système de design commun (administration, Ministère, postes de sécurité).
 * Couleurs du drapeau en accents, surfaces claires, police Plus Jakarta Sans, icônes Lucide.
 */
:root {
  --primary: #00754A; --primary-dark: #00583A; --primary-soft: #E2F2E9;
  --ink: #0B2A1E; --ink-2: #133A2B;
  --danger: #C8102E; --danger-soft: #FCE8EB;
  --accent: #F2B705; --accent-soft: #FFF4CC; --accent-ink: #6B4E00;
  --text: #13221B; --muted: #5F6F67; --subtle: #8E9B94;
  --border: #E3E8E4; --bg: #F3F5F2; --surface: #FFFFFF; --surface-2: #F7F9F7;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11, 42, 30, .06), 0 4px 16px rgba(11, 42, 30, .06);
  --shadow-lg: 0 12px 40px rgba(11, 42, 30, .18);
  --ring: 0 0 0 3px rgba(0, 117, 74, .25);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --side: 256px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 800; }
h2 { font-size: 17px; margin: 0 0 8px; font-weight: 800; }
a { color: var(--primary-dark); font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-weight: 600; }
.error:empty { display: none; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }

/* ---------- Coquille : menu latéral + barre du haut ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100vh; }
.shell.no-session { grid-template-columns: minmax(0, 1fr); }
.shell.no-session .sidebar { display: none; }
.sidebar { background: var(--ink); color: #DCEBE3; display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; text-decoration: none; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; overflow: hidden; flex-shrink: 0; }
.brand .logo img { width: 38px; height: 38px; border-radius: 11px; display: block; }
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand small { display: block; font-size: 12px; color: #9FC1B0; font-weight: 600; }
.flagbar { display: flex; height: 4px; margin: 0 18px 10px; border-radius: 4px; overflow: hidden; }
.flagbar i { flex: 1; } .flagbar i:nth-child(1) { background: var(--danger); } .flagbar i:nth-child(2) { background: var(--accent); } .flagbar i:nth-child(3) { background: var(--primary); }
.navgroup { padding: 8px 12px; }
.navgroup > span { display: block; padding: 6px 10px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #7FA693; }
.navlink { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #DCEBE3; text-decoration: none; font-weight: 600; font-size: 14.5px; }
.navlink:hover { background: rgba(255,255,255,.07); color: #fff; }
.navlink.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.navlink.active svg { color: var(--primary); }
.sidebar .me { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 10px; }
.mecard { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; font-size: 14px; flex: none; }
.mecard b { display: block; color: #fff; font-size: 14px; line-height: 1.2; }
.role { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; background: rgba(255,255,255,.1); color: #fff; }
.role.ADMIN { background: var(--accent); color: var(--ink); }
.sidebar .me .row button { flex: 1; }

.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; }
.content > header { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 20px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); color: var(--ink); }
.content > header strong, .content > header .who strong { font-size: 18px; font-weight: 800; }
.menu-btn { display: none; }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 20px; }

/* ---------- Composants ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
form.card { display: grid; gap: 12px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
input, select, textarea { min-height: 44px; padding: 0 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: 15px; color: var(--text); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
textarea { padding: 10px 12px; min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[type='checkbox'], input[type='radio'] { min-height: 0; width: 18px; height: 18px; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1.5px solid transparent; border-radius: 11px; background: var(--primary); color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s; }
button:hover, .btn:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, button.ghost-dark { background: var(--surface); color: var(--ink); border-color: var(--border); }
button.secondary:hover, button.ghost-dark:hover { background: var(--surface-2); border-color: #CBD5CF; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); }
.sidebar button.ghost { color: #DCEBE3; border-color: rgba(255,255,255,.18); }
.sidebar button.ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
button.danger { background: var(--danger); }
button.danger:hover { background: #A50D26; }
button.warn { background: var(--accent); color: var(--ink); }
button.warn:hover { background: #DDA600; }
button.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
button.icon { width: 42px; padding: 0; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; margin-bottom: 14px; background: #E8EDE9; border-radius: 12px; width: fit-content; max-width: 100%; }
.tabs button { min-height: 36px; background: transparent; color: var(--muted); border: 0; border-radius: 9px; font-weight: 700; }
.tabs button:hover { background: rgba(255,255,255,.6); color: var(--ink); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge, .tag, .pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.tag { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.tag.ok, .tag.OFFICIAL { background: var(--primary-soft); color: var(--primary-dark); }
.tag.fixed { background: var(--ink); color: #fff; }
.tag.REJECTED { background: var(--danger-soft); color: var(--danger); }
.danger-text { color: var(--danger); font-weight: 700; }

/* Tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 11px 14px; font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFCFA; }
td .row { flex-wrap: nowrap; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 4px; }
.kpi .label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.kpi b { font-size: 28px; line-height: 1; color: var(--ink); font-weight: 800; }

/* Connexion */
form#login { width: min(420px, calc(100% - 32px)); margin: 8vh auto; padding: 28px; gap: 14px; }
form#login h1 { display: flex; align-items: center; gap: 10px; }
form#login button[type='submit'] { min-height: 48px; font-size: 15px; }
.notice { max-width: 520px; margin: 40px auto; }

/* Téléphone / tablette : menu en tiroir */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(var(--side), 86vw); z-index: 2000; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .shell.open .sidebar { transform: none; }
  .shell.open::after { content: ''; position: fixed; inset: 0; background: rgba(11,42,30,.4); z-index: 1999; }
  .menu-btn { display: inline-flex; }
  .shell.no-session .menu-btn { display: none; }
  main { padding: 14px; }
  .content > header { padding: 10px 14px; }
}
.badge { white-space: nowrap; margin: 2px 0; }
.shell.no-session [data-auth] { display: none; }

/* Mot de passe provisoire : fenêtre obligatoire */
.modal { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; padding: 16px; background: rgba(11, 42, 30, .55); backdrop-filter: blur(3px); }
.modal form { width: min(440px, 100%); margin: 0; padding: 24px; }
.modal h1 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.mecard small.post { display: block; margin-top: 3px; font-size: 12px; color: #9FC1B0; font-weight: 600; }

.forgot { font-size: 13.5px; color: var(--muted); }
.forgot summary { cursor: pointer; font-weight: 700; color: var(--primary-dark); }
.forgot ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.temp-pass { font-family: ui-monospace, monospace; font-size: 18px; font-weight: 800; letter-spacing: .05em; background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; user-select: all; }
