/* ==========================================================================
   النماذج المعتمدة — مرافقة النقل المدرسي (A4, RTL, charte GSSI : bleu nuit + or)
   ========================================================================== */
:root {
  --navy: #0A3A8C; --deep: #002060; --night: #00133D; --gold: #FFD700; --gold-alt: #E8B400;
  --sand: #F6F2E9; --line: #C9D2E3; --soft: #EEF2FA; --muted: #5B6B8F; --red: #C62828; --green: #1E9E5A;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: #DCE2EC; font-family: 'Cairo', Tahoma, sans-serif; color: var(--night); direction: rtl; }
body { padding: 70px 0 40px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* ---- barre d'outils (écran seulement) ---- */
.toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; height: 54px; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: var(--night); color: #fff; box-shadow: 0 4px 14px rgba(0,19,61,.3);
}
.toolbar b { font-size: 17px; font-weight: 800; }
.toolbar .sp { flex: 1; }
.toolbar a, .toolbar button {
  font-family: inherit; font-size: 15px; font-weight: 800; padding: 7px 18px; border-radius: 999px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--gold); background: transparent; color: #fff;
}
.toolbar button.print { background: var(--gold); color: var(--night); }

/* ---- feuille A4 ---- */
.page {
  width: 210mm; min-height: 297mm; margin: 0 auto 24px; background: #fff; position: relative;
  padding: 11mm 12mm 14mm; box-shadow: 0 10px 30px rgba(0,19,61,.18); display: flex; flex-direction: column;
}
.page.land { width: 297mm; min-height: 210mm; }
.page::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 5px; background: linear-gradient(90deg, var(--gold), var(--gold-alt) 40%, var(--navy)); }

/* ---- en-tête ---- */
.hd { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--deep); }
.hd-org { display: flex; align-items: center; gap: 10px; }
.hd-org img { width: 54px; height: 54px; border-radius: 50%; }
.hd-org b { display: block; font-size: 15px; font-weight: 900; color: var(--deep); line-height: 1.3; }
.hd-org span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); }
.hd-title { text-align: center; }
.hd-title .k { display: inline-block; font-size: 10.5px; font-weight: 800; color: var(--deep); background: var(--soft); border-radius: 999px; padding: 2px 12px; margin-bottom: 3px; }
.hd-title h1 { font-size: 23px; font-weight: 900; color: var(--night); line-height: 1.3; }
.hd-title p { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.hd-meta { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 10.5px; min-width: 150px; }
.hd-meta div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 9px; border-bottom: 1px solid var(--line); }
.hd-meta div:last-child { border-bottom: 0; }
.hd-meta b { color: var(--muted); font-weight: 700; }
.hd-meta span { font-weight: 800; direction: ltr; }

/* ---- sections ---- */
.sec { margin-top: 9px; }
.sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.sec-h .n { width: 22px; height: 22px; border-radius: 6px; background: var(--deep); color: var(--gold); display: grid; place-items: center; font-size: 12px; font-weight: 900; flex-shrink: 0; }
.sec-h h2 { font-size: 14px; font-weight: 900; color: var(--deep); }
.sec-h small { font-size: 10.5px; font-weight: 700; color: var(--muted); margin-right: auto; }
.sec-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sec-h small + ::after { display: none; }

/* champs à remplir */
.fields { display: grid; gap: 6px 14px; }
.f2 { grid-template-columns: 1fr 1fr; } .f3 { grid-template-columns: repeat(3, 1fr); } .f4 { grid-template-columns: repeat(4, 1fr); }
.fld { display: flex; align-items: flex-end; gap: 6px; font-size: 11.5px; font-weight: 700; min-height: 24px; }
.fld b { white-space: nowrap; color: var(--deep); font-weight: 800; }
.fld i { flex: 1; border-bottom: 1.3px dotted #7D8AA8; height: 16px; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .full { grid-column: 1 / -1; }

/* cases à cocher */
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11.5px; font-weight: 700; }
.checks span { display: inline-flex; align-items: center; gap: 6px; }
.box { display: inline-block; width: 13px; height: 13px; border: 1.6px solid var(--deep); border-radius: 3px; flex-shrink: 0; }
.checks.grid { display: grid; grid-template-columns: repeat(5, 1fr); }

/* tableaux */
table.t { width: 100%; border-collapse: collapse; font-size: 11px; table-layout: fixed; }
table.t th { background: var(--deep); color: #fff; font-weight: 800; padding: 5px 4px; border: 1px solid var(--deep); line-height: 1.3; }
table.t th.g { background: var(--gold); color: var(--night); border-color: var(--gold-alt); }
table.t th small { display: block; font-size: 9px; font-weight: 700; opacity: .85; }
table.t td { border: 1px solid var(--line); height: 25px; padding: 2px 5px; font-weight: 700; }
table.t tr:nth-child(even) td { background: #F8FAFD; }
table.t td.num { text-align: center; color: var(--muted); font-weight: 800; background: var(--soft) !important; }
table.t td.c { text-align: center; }
table.t.tall td { height: 31px; }
.sub-th th { background: var(--navy) !important; font-size: 9.5px; }

/* zones d'écriture */
.lines { border: 1px solid var(--line); border-radius: 8px; padding: 2px 10px 6px; background:
  repeating-linear-gradient(to bottom, transparent 0 23px, #D9DFEA 23px 24px); background-origin: content-box; }
.lines.h3 { height: 82px; } .lines.h4 { height: 106px; } .lines.h5 { height: 130px; } .lines.h6 { height: 154px; }
.lines .hint { font-size: 9.5px; font-weight: 700; color: var(--muted); }

/* encadrés */
.note { display: flex; gap: 10px; align-items: flex-start; border-radius: 8px; padding: 7px 12px; font-size: 10.8px; font-weight: 700; line-height: 1.6; }
.note.gold { background: #FFF6D6; border-right: 5px solid var(--gold-alt); }
.note.red { background: #FDECEC; border-right: 5px solid var(--red); color: #5A0F0F; }
.note.navy { background: var(--soft); border-right: 5px solid var(--navy); }
.note .k { flex-shrink: 0; font-weight: 900; padding: 1px 9px; border-radius: 5px; background: var(--gold); color: var(--night); font-size: 10.5px; }
.note.red .k { background: var(--red); color: #fff; }
.note.navy .k { background: var(--navy); color: #fff; }
.mandatory { display: flex; align-items: center; gap: 12px; border: 2.5px solid var(--red); border-radius: 10px; padding: 8px 14px; background: #FFF8F8; font-size: 12.5px; font-weight: 900; }
.mandatory .box { width: 18px; height: 18px; border-color: var(--red); border-width: 2.2px; }
.mandatory small { display: block; font-size: 10px; font-weight: 700; color: var(--muted); }

/* compteurs */
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cnt { border: 1.5px solid var(--line); border-radius: 10px; padding: 5px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; font-weight: 800; }
.cnt i { width: 44px; height: 26px; border: 1.5px solid var(--deep); border-radius: 6px; background: #fff; }
.cnt.key { border-color: var(--gold-alt); background: #FFF9E3; }

/* signatures */
.signs { display: grid; gap: 12px; margin-top: auto; padding-top: 10px; }
.s2 { grid-template-columns: 1fr 1fr; } .s3 { grid-template-columns: repeat(3, 1fr); } .s4 { grid-template-columns: repeat(4, 1fr); }
.sign { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 74px; display: flex; flex-direction: column; }
.sign b { font-size: 11px; font-weight: 900; color: var(--deep); }
.sign span { font-size: 9.5px; font-weight: 700; color: var(--muted); }
.sign i { margin-top: auto; border-bottom: 1.3px dotted #7D8AA8; height: 14px; }
.sign.adm { background: var(--soft); border-style: dashed; border-color: var(--navy); }

/* pied */
.ft { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 5px; border-top: 1px solid var(--line); font-size: 9.5px; font-weight: 700; color: var(--muted); }

/* légende */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 10px; font-weight: 700; color: var(--muted); }
.legend b { display: inline-grid; place-items: center; min-width: 20px; height: 17px; padding: 0 4px; border-radius: 4px; background: var(--soft); color: var(--deep); font-weight: 900; margin-left: 4px; }

/* ---- impression ---- */
@page { size: A4 portrait; margin: 0; }
@page land { size: A4 landscape; margin: 0; }
@media print {
  html, body { background: #fff; }
  body { padding: 0; }
  .toolbar { display: none; }
  .page { margin: 0; box-shadow: none; page-break-after: always; break-after: page; height: 297mm; overflow: hidden; }
  .page.land { page: land; height: 210mm; }
  .page:last-child { page-break-after: auto; break-after: auto; }
}

/* ---- page d'accueil des modèles ---- */
.home { max-width: 1100px; margin: 0 auto; padding: 10px 24px 40px; }
.home h1 { font-size: 34px; font-weight: 900; color: var(--night); margin-bottom: 4px; }
.home > p { font-size: 16px; font-weight: 700; color: var(--muted); margin-bottom: 26px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.card {
  display: flex; gap: 18px; text-decoration: none; color: inherit; background: #fff; border-radius: 18px; padding: 22px 24px;
  border-top: 8px solid var(--deep); box-shadow: 0 10px 26px rgba(0,19,61,.1); transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(0,19,61,.18); }
.card.r { border-top-color: var(--red); } .card.g { border-top-color: var(--gold-alt); }
.card .ic { flex-shrink: 0; width: 64px; height: 64px; border-radius: 16px; background: var(--deep); color: var(--gold); display: grid; place-items: center; }
.card.r .ic { background: var(--red); color: #fff; }
.card .ic svg { width: 34px; height: 34px; }
.card .code { font-size: 12px; font-weight: 800; color: var(--muted); direction: ltr; text-align: right; }
.card h2 { font-size: 22px; font-weight: 900; color: var(--night); margin: 2px 0 6px; }
.card p { font-size: 14px; font-weight: 600; line-height: 1.6; color: #33415F; }
.card .when { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 800; padding: 3px 12px; border-radius: 999px; background: var(--soft); color: var(--deep); }
.card .act { margin-top: 10px; display: flex; gap: 8px; }
.card .act span { font-size: 12.5px; font-weight: 800; padding: 4px 14px; border-radius: 999px; background: var(--gold); color: var(--night); }
.card .act span.pdf { background: var(--deep); color: #fff; }

/* ---- ajustements de hauteur (tient sur une page A4) ---- */
.page.land table.t td { height: 21px; }
.page.land .sign { min-height: 56px; }
.f6 { grid-template-columns: repeat(6, 1fr); }
.page.compact .sec { margin-top: 6px; }
.page.compact table.t td { height: 22px; }
.page.compact .sign { min-height: 62px; }
.lines.h2 { height: 58px; }
.page.land { padding: 8mm 10mm 9mm; }
.page.compact { padding-top: 9mm; padding-bottom: 9mm; }
.page.compact .sign { min-height: 52px; } .page.compact .hd { padding-bottom: 6px; }
.page.compact .lines.h2 { height: 46px; }
.toolbar a.back { background: var(--gold); color: var(--night); }
