/* KMAR Interventions — feuille de style responsive (mobile d'abord) */
:root {
  --brand: #0d4073; --brand-2: #1560a8; --ink: #1c2129; --muted: #6b7280; --line: #e3e6eb;
  --bg: #f3f5f8; --card: #fff; --ok: #177a45; --warn: #b8730a; --bad: #b32626; --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); }
h1 { font-size: 1.4rem; margin: 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1rem; margin: 0 0 .75rem; color: var(--brand); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; }
.err { color: var(--bad); }
.pre { white-space: pre-wrap; margin: 0 0 1rem; }

/* En-tête */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; margin-right: auto; }
.brand img { background: #fff; border-radius: 6px; padding: 2px; }
.nav { display: flex; align-items: center; gap: .25rem; }
.nav a, .nav .linkbtn { color: #dbe7f5; text-decoration: none; padding: .45rem .7rem; border-radius: 6px; font-size: .92rem; }
.nav a:hover, .nav a.on, .nav .linkbtn:hover { background: rgba(255,255,255,.14); color: #fff; }
.burger { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }

main { padding: 20px 16px 40px; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 24px; }

/* Cartes, boutons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 480px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font: inherit; font-weight: 500; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: #c5cad3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #f0c9c9; }
.btn.danger:hover { background: #fdf1f1; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn.icon { padding: .4rem .7rem; }
.linkbtn { background: none; border: 0; color: var(--brand-2); cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; margin: 0; }

/* Messages */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 1.1rem; }
.flash.success { background: #edf8f1; border-color: #bfe3cc; color: #0f5a32; }
.flash.error { background: #fdf1f1; border-color: #f0c9c9; color: #8d1d1d; }
.flash.warning { background: #fff7e8; border-color: #f3dcae; color: #7a4d05; }

/* Badges */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.b-planifiee { background: #e7f0fa; color: var(--brand); }
.b-en_cours { background: #fff3dd; color: var(--warn); }
.b-terminee { background: #e3f4ea; color: var(--ok); }
.b-annulee { background: #f6e6e6; color: var(--bad); }
.e-sent { background: #e3f4ea; color: var(--ok); }
.e-pending { background: #fff3dd; color: var(--warn); }
.e-failed { background: #f6e6e6; color: var(--bad); }

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); border-left: 4px solid var(--line); }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.s-planifiee { border-left-color: var(--brand-2); } .s-en_cours { border-left-color: var(--warn); }
.s-terminee { border-left-color: var(--ok); } .s-annulee { border-left-color: var(--bad); }

/* Filtres */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filters input[type=search] { flex: 1 1 220px; }
.filters .mini { display: flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); margin: 0; }

/* Formulaires */
label { display: block; font-size: .88rem; font-weight: 600; color: #3a414d; margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: .55rem .7rem; font: inherit; font-weight: 400; color: var(--ink);
  border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc1ea; border-color: var(--brand-2); }
.filters input, .filters select { width: auto; margin: 0; }
textarea { resize: vertical; }
fieldset { margin: 0 0 16px; }
legend { font-weight: 700; color: var(--brand); padding: 0 6px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid .span2 { grid-column: span 2; }
.grid .end { display: flex; align-items: flex-end; margin-bottom: 12px; }
.duo { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.duo input { width: 80px; }
.bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 16px 0 8px; }
.bar .btn { min-width: 200px; }

.mat-head, .mat-row { display: grid; grid-template-columns: 2fr 1.3fr 80px 44px; gap: 8px; align-items: center; }
.mat-head { font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.mat-row { margin-bottom: 8px; }
.mat-row input { margin: 0; }

/* Tableaux */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.list th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8f9fb; padding: .6rem .75rem; }
.list td { padding: .6rem .75rem; border-top: 1px solid var(--line); vertical-align: top; }
.list tbody tr:hover { background: #fafbfc; }
.list.compact { border: 0; }
.actions { white-space: nowrap; text-align: right; }
.actions a { margin-left: .5rem; }
.inline-details { display: inline-block; margin-left: .6rem; }
.inline-details summary { color: var(--brand-2); cursor: pointer; }
.inline-details form { display: flex; gap: 6px; margin-top: 6px; }
.inline-details input { margin: 0; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }
.empty { text-align: center; padding: 40px 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dl { margin: 0; }
.dl > div { display: grid; grid-template-columns: 130px 1fr; padding: .35rem 0; border-bottom: 1px solid #f0f2f5; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* Connexion */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login h1 { justify-content: center; font-size: 1.2rem; margin-top: .5rem; }
.login .card { text-align: left; margin-top: 16px; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .burger { display: block; }
  .brand { flex: 1 1 0; min-width: 0; font-size: .95rem; line-height: 1.25; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 10px; }
  .nav.open { display: flex; }
  .nav form { display: block; } .nav .linkbtn { width: 100%; text-align: left; }
  .grid { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  main { padding-top: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; } .grid .span2 { grid-column: auto; }
  .filters input, .filters select, .filters .mini, .filters .btn { flex: 1 1 100%; width: 100%; }
  .filters .mini input { flex: 1; }
  .head .btn.primary, .btns .btn, .btns form, .btns form .btn { flex: 1 1 auto; }
  .bar .btn { width: 100%; }
  /* Tableaux → cartes */
  table.list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list thead { display: none; }
  table.list { background: transparent; border: 0; }
  .list tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 0; }
  .list td { border: 0; padding: .3rem .9rem; display: flex; gap: 10px; justify-content: space-between; text-align: right; }
  .list td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: .85rem; text-align: left; }
  .list td.actions { justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 4px; padding-top: .5rem; flex-wrap: wrap; }
  .mat-head { display: none; }
  .mat-row { grid-template-columns: 1fr 70px 44px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
  .mat-row input[name=mat_designation] { grid-column: 1 / -1; }
  .dl > div { grid-template-columns: 110px 1fr; }
}
@media print { .top, .btns, .foot, .bar { display: none; } }
