/* ============================================================================
   Dentium — Design system
   Sobre, professionnel, « logiciel métier » pour cabinet dentaire.
   Un seul accent : bleu dentaire (#1c7ca6), teinte claire pour les fonds.
   ============================================================================ */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #f0f3f7;
  --border: #e4e9ef;
  --border-strong: #d2dae2;
  --text: #1b2733;
  --text-2: #566472;
  --text-3: #8794a1;
  --accent: #1c7ca6;
  --accent-hover: #166a8f;
  --accent-press: #115674;
  --accent-tint: #e6f2f8;
  --accent-tint-2: #cfe5f0;
  --danger: #b5382b;
  --danger-tint: #f7ecea;
  --ok: #1f7a52;
  --ok-tint: #e6f3ec;
  --warn: #9a6a12;
  --warn-tint: #fdf3dd;
  --ring: rgba(28, 124, 166, 0.20);
  --r-sm: 5px;
  --r: 7px;
  --r-lg: 10px;
  --sh-1: 0 1px 2px rgba(20, 30, 45, 0.05), 0 1px 3px rgba(20, 30, 45, 0.05);
  --sh-2: 0 10px 34px rgba(18, 28, 42, 0.20), 0 2px 8px rgba(18, 28, 42, 0.10);
  --sh-pop: 0 6px 20px rgba(18, 28, 42, 0.14), 0 1px 3px rgba(18, 28, 42, 0.10);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-doc: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

input, button, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea { user-select: text; }

.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico--lg { width: 34px; height: 34px; stroke-width: 1.4; }

/* ─────────────────────────  BARRE D'APPLICATION  ───────────────────────── */
.appbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark { width: 34px; height: 34px; flex: none; display: block; }
.brand__mark svg { width: 100%; height: 100%; display: block; }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name { font-size: 18px; font-weight: 700; letter-spacing: 0.3px; color: var(--accent); }
.brand__by { font-size: 10px; font-weight: 600; color: var(--text-3); letter-spacing: 0.2px; margin-top: 2px; }
.appbar__doctor { margin-left: 6px; flex: 1; color: var(--text-2); font-size: 13px; }
.appbar__doctor strong { color: var(--text); font-weight: 600; }
.appbar__doctor .sep { margin: 0 8px; color: var(--border-strong); }

/* ─────────────────────────  BOUTONS  ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13.5px; font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s ease, border-color .13s ease, box-shadow .13s ease, color .13s ease;
}
.btn .ico { width: 16px; height: 16px; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-hover); }
.btn--accent:active { background: var(--accent-press); }
.btn--soft { background: var(--surface); color: var(--accent); border-color: var(--border-strong); }
.btn--soft:hover { background: var(--accent-tint); border-color: var(--accent-tint-2); }
.btn--ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--print { padding: 0 18px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.iconbtn {
  width: 34px; height: 34px; border-radius: var(--r);
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; color: var(--text-2);
  cursor: pointer; transition: background .13s;
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }
.iconbtn--light { color: rgba(255,255,255,.85); }
.iconbtn--light:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ─────────────────────────  LAYOUT  ───────────────────────── */
.layout {
  height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 344px 1fr;
  gap: 16px;
  padding: 16px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ─────────────────────────  PANNEAU PATIENT  ───────────────────────── */
/* Petit écran (portable, zoom Windows 125-150 %) : si la fiche + l'historique ne tiennent pas,
   c'est TOUTE la colonne Patient qui défile — l'historique garde au moins ~3 documents visibles
   (avant : il était écrasé à 0 px et les ordonnances du patient étaient inaccessibles). */
.patient { padding: 0; overflow-y: auto; overflow-x: hidden; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
}
.panel__title { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.patient > .search, .patient__form, .history { padding: 0 18px; }

.search { position: relative; margin-bottom: 6px; }
.search__ico { position: absolute; left: 28px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search__input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color .13s, box-shadow .13s, background .13s;
}
.search__input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--ring); }
.search__results {
  position: absolute; top: 42px; left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--sh-pop); max-height: 280px; overflow-y: auto; padding: 4px;
}
.search__item { padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.search__item:hover, .search__item.is-active { background: var(--accent-tint); }
.search__item strong { font-weight: 600; }
.search__item small { display: block; color: var(--text-3); font-size: 12px; }
.search__none { padding: 12px 10px; color: var(--text-3); font-size: 13px; }

.patient__form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 11px 12px;
  padding-top: 8px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field label {
  font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .2px;
}
.field .opt { font-weight: 500; color: var(--text-3); }
.field input[type="text"], .field input[type="number"], .field input[type="date"] {
  height: 36px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r);
  background: #fff; transition: border-color .13s, box-shadow .13s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.inline { display: flex; align-items: center; gap: 8px; }
.input--age { width: 100%; }
.inline__unit { color: var(--text-3); font-size: 13px; }

/* Segment (bascule) */
.segment { display: inline-flex; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r); padding: 3px; gap: 3px; }
.segment button {
  border: none; background: transparent; cursor: pointer;
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 550; color: var(--text-2);
  transition: background .12s, color .12s, box-shadow .12s;
}
.segment button:hover { color: var(--text); }
.segment button.is-active { background: #fff; color: var(--accent); box-shadow: var(--sh-1); }
.segment--sm button { padding: 5px 12px; font-size: 12.5px; }

/* Historique */
.history { flex: 1; min-height: 280px; display: flex; flex-direction: column; padding-top: 14px; padding-bottom: 14px; }
.history__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.history__head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 700; }
.history__count { font-size: 12px; color: var(--text-3); }
.history__list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.history__empty { color: var(--text-3); font-size: 13px; line-height: 1.5; margin: 6px 2px; }
.hist-item {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 11px; margin-bottom: 8px; background: var(--surface-2);
  transition: border-color .12s, background .12s;
}
.hist-item:hover { border-color: var(--border-strong); background: #fff; }
.hist-item__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hist-item__date { font-size: 12.5px; font-weight: 600; color: var(--text); }
.hist-item__tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-tint); padding: 2px 7px; border-radius: 20px; }
.hist-item__tag--cert { color: #7a5b12; background: #f5efdf; }
.hist-item__sum { font-size: 12.5px; color: var(--text-2); margin: 5px 0 8px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hist-item__dup { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; }
.hist-item__dup .ico { width: 14px; height: 14px; }
.hist-item__dup:hover { text-decoration: underline; }

/* ─────────────────────────  PANNEAU TRAVAIL  ───────────────────────── */
.work { padding: 16px 20px 0; }
.segment--tabs { align-self: flex-start; margin-bottom: 16px; flex-wrap: wrap; }
.segment--tabs button { padding: 8px 15px; font-size: 13.5px; }

.doc-pane { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow-y: auto; }
/* Le certificat (beaucoup de champs) doit pouvoir défiler sur petits écrans */
#paneCertificat { padding-bottom: 12px; }

/* Saisie ordonnance */
.rx-entry {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px 16px; margin-bottom: 14px;
}
.rx-entry__row { display: flex; gap: 12px; }
.rx-entry__row--2 { margin-top: 11px; align-items: flex-end; }
.field--grow { flex: 1; }
.field--duree { width: 140px; flex: none; }
.field--addbtn { flex: none; }
.field--addbtn .btn { height: 36px; }

.ac { position: relative; }
.ac__input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; transition: border-color .13s, box-shadow .13s; }
.ac__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.ac__list {
  position: absolute; top: 42px; left: 0; right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--sh-pop); max-height: 320px; overflow-y: auto; padding: 4px;
}
.ac__item { display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.ac__item:hover, .ac__item.is-active { background: var(--accent-tint); }
.ac__brand { font-weight: 600; }
.ac__dose { color: var(--text); font-weight: 500; }
.ac__meta { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.ac__dci { color: var(--text-2); font-size: 12.5px; }

/* Composeur : marque / dosage / posologie sélectionnables */
.rx-suggest { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; padding-top: 12px; border-top: 1px dashed var(--border-strong); }
.rx-suggest__g { display: grid; grid-template-columns: 74px 1fr; align-items: start; gap: 10px; }
.rx-suggest__lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); padding-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  border-radius: 16px; padding: 4px 12px; font-size: 12.5px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s; max-width: 100%; text-align: left; line-height: 1.35;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip--poso { border-radius: 8px; white-space: normal; }
.chip--dose { font-variant-numeric: tabular-nums; }

/* Constructeur de posologie : quantité · prise · moment */
.poso-builder { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.pb-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pb-lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); width: 58px; flex: none; }
.pb-chip {
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-2);
  border-radius: 16px; padding: 3px 11px; font-size: 12px; cursor: pointer; transition: all .12s; white-space: nowrap;
}
.pb-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.pb-chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pb-chip--form.is-drug { border-color: var(--accent-tint-2); color: var(--accent); font-weight: 600; }
.pb-chip--form.is-drug.is-on { color: #fff; border-color: var(--accent); }

/* QSP : durées fréquentes cliquables */
.qsp-quick { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.qsp-chip {
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-2);
  border-radius: 14px; padding: 2px 9px; font-size: 11.5px; cursor: pointer; transition: all .12s; white-space: nowrap;
}
.qsp-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }

/* Naissance : date complète OU année seule */
.dob-row { display: flex; align-items: center; gap: 8px; }
.dob-row input[type="date"] { flex: 1; min-width: 0; }
.dob-row__or { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.dob-row #pAnnee { width: 74px; text-align: center; }
/* Barre d'action : date du document + « sans date » */
.docdate { height: 32px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13px; }
.docnodate { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.docnodate input { width: 15px; height: 15px; cursor: pointer; }
/* Paramètres : activités (une par ligne) */
#hActivites { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-family: inherit; font-size: 13.5px; line-height: 1.5; resize: vertical; }
/* En-tête du document : ligne des activités / spécialités */
.doc__acts { margin-top: 2.5mm; display: flex; flex-wrap: wrap; justify-content: center; gap: .6mm 0; font-size: .84em; color: #2a3946; line-height: 1.4; }
.doc__acts-sep { color: var(--accent); margin: 0 2mm; font-weight: 700; }
.doc[data-fmt="A5"] .doc__acts { font-size: .76em; margin-top: 1.5mm; }

/* Impression (Paramètres) */
.print-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.print-row select { flex: 1; min-width: 0; }
.print-row .btn { height: 34px; padding: 0 10px; }

/* Import / Export des données */
.data-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.import-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.import-pick__name { font-size: 12.5px; color: var(--text-3); }
.import-info { margin: 12px 0 8px; font-size: 12.5px; color: var(--text-2); }
.import-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.imf { display: flex; align-items: center; gap: 8px; }
.imf__lbl { min-width: 92px; flex: none; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.imf__req { color: #b23; }
.imf select { flex: 1; min-width: 0; padding: 5px 7px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; font-size: 12.5px; }
.import-preview { margin-top: 12px; max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.imp-tbl { border-collapse: collapse; font-size: 11.5px; white-space: nowrap; }
.imp-tbl th, .imp-tbl td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.imp-tbl th { background: var(--accent-tint); color: var(--text-1); position: sticky; top: 0; }
@media screen and (max-width: 720px) { .import-fields { grid-template-columns: 1fr; } }

/* Certificats */
.segment--wrap { display: flex; flex-wrap: wrap; width: 100%; }
.segment--wrap button { flex: 1 1 auto; }
#certFields { display: flex; flex-direction: column; gap: 14px; }
#certFields textarea {
  width: 100%; min-height: 56px; padding: 9px 11px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff;
  font-family: inherit; font-size: 14px; line-height: 1.45;
}
#certFields textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
/* Modèles de compte rendu d'échographie */
.echo-models { display: flex; flex-wrap: wrap; gap: 6px; }
.echo-model { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 16px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.echo-model:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.echo-model.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Barre « Mes modèles » (textes libres réutilisables — certificats & orientations) */
.models-bar__row { display: flex; gap: 8px; align-items: center; }
.models-sel { flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13px; cursor: pointer; }
.models-sel:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.models-del { flex: none; width: 36px; padding: 0; }
.models-save { flex: none; white-space: nowrap; }

/* ─────────────────────────  MESSAGERIE INTERNE (postes du cabinet)  ───────────────────────── */
.tab-badge { display: inline-block; margin-left: 6px; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--danger); border-radius: 10px; text-align: center; vertical-align: middle; }
#paneMessages { overflow: hidden; }
.msg-head { flex: none; margin-bottom: 10px; }
.msg-head label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.msg-head input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13.5px; }
.msg-head input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.msg-list { flex: 1 1 auto; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); }
.msg-empty { color: var(--text-3); font-size: 13.5px; margin: auto; text-align: center; }
.msg { max-width: 78%; align-self: flex-start; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 7px 11px; box-shadow: var(--sh-1); }
.msg--own { align-self: flex-end; background: var(--accent-tint); border-color: var(--accent-tint-2); }
.msg__meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.msg__from { font-size: 12px; font-weight: 700; color: var(--accent); }
.msg__time { font-size: 10.5px; color: var(--text-3); }
.msg__text { font-size: 13.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.msg-compose { flex: none; display: flex; gap: 8px; margin-top: 10px; }
.msg-compose input { flex: 1; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 14px; }
.msg-compose input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.msg-compose .btn { flex: none; padding: 0 18px; }
.cert-hint { margin: 2px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.cert-hint b { color: var(--text); font-weight: 600; }

/* Barre d'outils ordonnance (Modèles) */
.rx-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* Modèles d'ordonnance */
.tpl-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.tpl-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2);
  transition: border-color .12s, background .12s;
}
.tpl-item:hover { border-color: var(--border-strong); background: #fff; }
.tpl-item__info { min-width: 0; }
.tpl-item__name { font-weight: 600; font-size: 13.5px; }
.tpl-item__sum { font-size: 12px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.tpl-item__actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tpl-item__tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-3); background: var(--surface-3); padding: 2px 7px; border-radius: 20px; }
.tpl-save { display: flex; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.tpl-save input { flex: 1; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--r); }
.tpl-save input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* Liste des lignes de prescription */
.rx-list { flex: 1 0 auto; min-height: 120px; margin: 0 -4px; padding: 0 4px 16px; }
.rx-list__empty { min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-3); text-align: center; }
.rx-list__empty .ico { color: var(--border-strong); }
.rx-list__empty p { margin: 0; font-size: 13.5px; }

.rx-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 12px 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 9px; background: #fff;
}
.rx-item__num {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; margin-top: 1px;
}
.rx-item__body { flex: 1; min-width: 0; }
.rx-item__med { font-weight: 600; font-size: 14.5px; }
.rx-item__det { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.rx-item__det .dot { margin: 0 7px; color: var(--border-strong); }
.rx-item__remove { flex: none; }
.rx-item__remove .ico { width: 16px; height: 16px; }
.rx-item.is-free .rx-item__num { background: var(--surface-3); color: var(--text-3); }

/* Certificat */
.cert-form { display: flex; flex-direction: column; gap: 14px; }
.cert-form__row { display: flex; gap: 14px; }
.field--jours { width: 180px; }
.cert-preview {
  margin-top: 18px; padding: 16px 18px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-lg); border-left: 3px solid var(--accent);
}
.cert-preview__label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 700; margin-bottom: 8px; }
.cert-preview p { margin: 0; font-size: 14.5px; line-height: 1.65; color: var(--text); }

/* Barre d'action */
.actionbar {
  margin: auto -20px 0; padding: 14px 20px;
  border-top: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
}
.actionbar__left, .actionbar__right { display: flex; align-items: center; gap: 12px; }
.actionbar__fmtlabel { font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ─────────────────────────  MODALES  ───────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(20, 30, 42, 0.42); backdrop-filter: none; }
.modal__box {
  position: relative; width: 560px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px);
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-2);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.modal__body { padding: 18px 20px; overflow-y: auto; }
.modal__hint { margin: 0 0 16px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 14px; }

.logo-row { display: flex; align-items: center; gap: 14px; }
.logo-preview {
  width: 96px; height: 60px; border: 1px dashed var(--border-strong); border-radius: var(--r);
  display: grid; place-items: center; background: var(--surface-2); overflow: hidden;
}
.logo-preview span { font-size: 11px; color: var(--text-3); }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 8px; }

/* Aperçu / impression */
.modal--preview { flex-direction: column; align-items: stretch; justify-content: flex-start; background: #55606c; }
.preview-toolbar {
  height: 56px; flex: none; background: #2c343d; color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px; z-index: 2;
}
.preview-toolbar__title { font-size: 14px; font-weight: 600; }
.preview-toolbar__right { display: flex; align-items: center; gap: 12px; }
.preview-toolbar__right .actionbar__fmtlabel { color: rgba(255,255,255,.75); }
.preview-toolbar__right .segment { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.14); }
.preview-toolbar__right .segment button { color: rgba(255,255,255,.75); }
.preview-toolbar__right .segment button.is-active { background: #fff; color: var(--accent); }
.preview-scroll { flex: 1; overflow: auto; padding: 28px; display: flex; justify-content: center; align-items: flex-start; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: #21303e; color: #fff; padding: 11px 18px; border-radius: var(--r);
  font-size: 13.5px; box-shadow: var(--sh-2); z-index: 200; opacity: 0;
  transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Démonstration : pastille + écran de blocage */
.demo-chip { font-size: 12px; font-weight: 600; color: #8a5a12; background: #fdf1dc; border: 1px solid #f2dcae; padding: 5px 11px; border-radius: 20px; white-space: nowrap; }
.demo-chip.is-warn { color: #b5382b; background: #f9e7e4; border-color: #eecac4; }
.demo-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(20, 30, 42, 0.55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.demo-overlay__box { background: #fff; border-radius: 14px; box-shadow: var(--sh-2); padding: 34px 40px; max-width: 460px; text-align: center; }
.demo-overlay__logo { width: 72px; height: 72px; display: inline-block; margin-bottom: 16px; }
.demo-overlay__logo svg { width: 100%; height: 100%; }
.demo-overlay__box h2 { margin: 0 0 12px; font-size: 20px; color: var(--text); font-weight: 650; }
.demo-overlay__box p { margin: 0 0 8px; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }
.demo-overlay__box p:last-child { margin-bottom: 0; }
.demo-overlay__sub { color: var(--text-3) !important; }

/* Écran d'activation (clé de licence) */
.license-form { margin: 10px 0 14px; display: flex; flex-direction: column; gap: 10px; }
.license-form textarea { width: 100%; resize: none; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--r); font-family: "Consolas", "Courier New", monospace; font-size: 12.5px; line-height: 1.55; letter-spacing: .4px; background: var(--surface-2); }
.license-form textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--ring); }
.license-form .btn { align-self: center; padding: 0 30px; }
.license-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.license-actions .btn { padding: 0 22px; }
.license-err { color: var(--danger); font-size: 12.5px; margin: 0; font-weight: 600; text-align: left; }

/* Médicament ajouté par le médecin (badge dans l'autocomplétion) */
.ac__tag { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-tint); border: 1px solid var(--accent-tint-2); border-radius: 10px; padding: 1px 7px; vertical-align: middle; }

/* ─────────────────────────  RÉSEAU (PLUSIEURS POSTES)  ───────────────────────── */
/* Bandeau d'alerte : n'apparaît que si le dossier partagé est injoignable. */
.net-banner {
  height: 28px; display: flex; align-items: center; justify-content: center;
  background: #fbece3; color: #9b2f42; border-bottom: 1px solid #f2ccd6;
  font-size: 12.5px; font-weight: 600; padding: 0 16px; text-align: center;
  position: relative; z-index: 19;
}
body.has-net-banner .layout { height: calc(100vh - 56px - 28px); }

/* Section « plusieurs postes » dans les Paramètres */
.net-settings { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.net-settings__hint { margin: 2px 0 10px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.net-settings .segment { display: inline-flex; }
.net-folder {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
}
.net-folder__path {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 8px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: "Consolas", "Courier New", monospace;
}
.net-settings__status { margin: 10px 0 0; font-size: 12.5px; font-weight: 600; }
.net-settings__status.is-ok { color: var(--accent); }
.net-settings__status.is-warn { color: var(--danger); }

/* Sous-titre de section dans les Paramètres (ex. en-tête en arabe) */
.settings-sep { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; margin-bottom: -2px; }
.settings-sep > label { font-weight: 650; color: var(--text); }

/* Panneau « Style du document » (contrôle total : couleur, police, taille…) */
.style-panel { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.style-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.style-ctl__lbl { flex: 0 0 110px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.style-color { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.style-color input[type="color"] { width: 40px; height: 30px; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: #fff; cursor: pointer; }
.style-swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.style-sw { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.style-sw:hover { transform: scale(1.12); }
#hFont { height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13.5px; min-width: 180px; cursor: pointer; }
#hFont:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

.style-preview-wrap { margin-top: 12px; }
.style-preview-lbl { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-bottom: 5px; }
.style-preview { border: 1px solid var(--border); border-radius: var(--r); background: #fff; padding: calc(14px * var(--doc-margin, 1)) calc(18px * var(--doc-margin, 1)); overflow: hidden; }
.sp-doc { color: #16202b; font-size: calc(13px * var(--doc-scale, 1)); line-height: var(--doc-lh, 1.6); }
.sp-name { font-weight: 700; font-size: calc(20px * var(--doc-scale, 1)); color: #122; line-height: 1.15; }
.sp-spec { color: #2a3946; font-size: calc(12px * var(--doc-scale, 1)); }
.sp-rule { height: 2px; background: var(--accent); margin: 7px 0 10px; }
.sp-title { text-align: center; color: var(--accent); font-weight: 700; letter-spacing: 2px; font-size: calc(11px * var(--doc-scale, 1)); margin-bottom: 8px; }
.sp-line { margin: 2px 0; }
.sp-line b { color: var(--accent); }
.sp-sub { color: #566472; font-size: calc(11.5px * var(--doc-scale, 1)); }

/* ─────────────────────────  EXAMENS COMPLÉMENTAIRES (panneau)  ───────────────────────── */
#paneExamen { overflow: hidden; }
.exam-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; flex: none; }
.exam-search { flex: 1 1 200px; margin: 0; position: relative; }
/* La barre d'examens n'a pas le padding 18px de la colonne patient → recaler la loupe */
.exam-search .search__ico { left: 12px; }
.exam-catalog { flex: 1 1 auto; min-height: 90px; overflow-y: auto; padding-right: 4px; }
.exam-group { margin-bottom: 12px; }
.exam-group__name { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.exam-group__items { display: flex; flex-wrap: wrap; gap: 6px; }
.exam-chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 16px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.exam-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.exam-chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.exam-empty { color: var(--text-3); font-size: 13px; padding: 8px 0; }

.exam-selected { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; flex: none; }
.exam-selected__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.exam-selected__head h3 { margin: 0; font-size: 13px; font-weight: 650; color: var(--text); }
.exam-selected__count { font-size: 12px; color: var(--text-3); }
.exam-add { display: flex; gap: 8px; margin-bottom: 8px; }
.exam-add input { flex: 1; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; }
.exam-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.exam-list { max-height: 30vh; overflow-y: auto; }
.exam-list__empty { color: var(--text-3); font-size: 13px; }
.exam-fam { margin-bottom: 8px; }
.exam-fam__name { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.exam-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dotted var(--border); }
.exam-item__name { font-size: 13px; }
.exam-item__rm { width: 26px; height: 26px; }
.exam-item__rm .ico { width: 15px; height: 15px; }

/* Étiquette « Examen » dans l'historique */
.hist-item__tag--exam { color: #7a5b12; background: #fbf1da; }
/* Étiquette « Orientation » dans l'historique */
.hist-item__tag--orient { color: #3b4b8a; background: #e8ecf9; }

/* Orientation : espace sous chaque champ du formulaire */
.orient-form .field { margin-bottom: 12px; }
.orient-form textarea { width: 100%; resize: vertical; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-family: inherit; font-size: 13.5px; line-height: 1.5; }
.orient-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ─────────────────────────  DOSSIER MÉDICAL  ───────────────────────── */
#paneDossier { overflow-y: auto; }
.dossier-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dossier-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dossier-head__info { min-width: 0; }
.dossier-head__info h3 { margin: 0; font-size: 16px; font-weight: 650; color: var(--text); }
.dossier-head__count { font-size: 12.5px; color: var(--text-3); }
.consult-form { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; margin-bottom: 14px; }
.consult-form .field { margin-bottom: 10px; }
.consult-form textarea { width: 100%; resize: vertical; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-family: inherit; font-size: 13.5px; line-height: 1.5; }
.consult-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.consult-form__actions { display: flex; justify-content: flex-end; gap: 8px; }
.dossier-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.dossier__empty { color: var(--text-3); font-size: 13.5px; padding: 12px 0; }
.consult { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-lg); background: var(--surface); padding: 12px 14px; box-shadow: var(--sh-1); }
.consult__date { font-size: 12.5px; font-weight: 650; color: var(--accent); margin-bottom: 8px; }
.consult__block { margin-bottom: 8px; }
.consult__block:last-child { margin-bottom: 0; }
.consult__lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-bottom: 2px; }
.consult__txt { font-size: 13.5px; color: var(--text); line-height: 1.55; white-space: pre-wrap; }
.consult__vitals { font-size: 13.5px; color: var(--text); font-weight: 600; }

/* Constantes (Taille / Poids / TA / FC / FR) — saisie des chiffres */
.vitals { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.vitals__item { display: flex; align-items: center; gap: 6px; }
.vitals__lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.vitals__item input { width: 62px; height: 32px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; text-align: center; font-size: 13.5px; }
.vitals__item input#vTa { width: 72px; }
.vitals__item input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.vitals__unit { font-size: 12px; color: var(--text-3); }

/* ============================================================================
   LE DOCUMENT (ordonnance / certificat) — livrable-roi
   Dimensions en mm : l'aperçu à l'écran = l'impression, au pixel près.
   ============================================================================ */
.paper { background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.28); }
.paper[data-fmt="A4"] .doc { width: 210mm; min-height: 297mm; }
.paper[data-fmt="A5"] .doc { width: 148mm; min-height: 210mm; }

.doc {
  background: #fff; color: var(--ink, #16202b);
  display: flex; flex-direction: column;
  font-family: var(--doc-font, var(--font)); /* police choisie par le médecin */
  position: relative; isolation: isolate; /* contexte pour filigranes et cadres */
  -webkit-print-color-adjust: exact; print-color-adjust: exact; /* couleurs/fonds imprimés tels quels */
}
/* Filigrane « DÉMONSTRATION » (version web de démonstration uniquement) */
.doc__watermark { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; justify-content: space-around; align-items: center; pointer-events: none; overflow: hidden; }
.doc__watermark span { font-size: 24pt; font-weight: 800; color: rgba(190, 40, 40, 0.11); letter-spacing: 3px; transform: rotate(-24deg); white-space: nowrap; }
/* Marges (--doc-margin) et taille (--doc-scale) pilotées par les réglages. */
.doc[data-fmt="A4"] { padding: calc(16mm * var(--doc-margin, 1)) calc(18mm * var(--doc-margin, 1)) max(7mm, calc(14mm * var(--doc-margin, 1))); font-size: calc(11.4pt * var(--doc-scale, 1) * var(--doc-fit, 1)); }
/* A5 : rythme vertical COMPACT (la page fait 210 mm, l'A4 297 mm). Les réglages « grand /
   larges » sont plafonnés sur A5 pour ne jamais rejeter le bas de page sur une 2ᵉ feuille. */
.doc[data-fmt="A5"] { padding: max(6mm, calc(9mm * min(var(--doc-margin, 1), 1.15))) calc(10mm * min(var(--doc-margin, 1), 1.15)) max(7mm, calc(8mm * min(var(--doc-margin, 1), 1.15))); font-size: calc(9.4pt * min(var(--doc-scale, 1), 1.12) * var(--doc-fit, 1)); }
.doc[data-fmt="A5"] .doc__header { gap: 5mm; }
.doc[data-fmt="A5"] .doc__name { font-size: 1.3em; }
.doc[data-fmt="A5"] .doc__name-ar { font-size: 1.4em; }
.doc[data-fmt="A5"] .doc__logo { max-height: 16mm; max-width: 32mm; }
.doc[data-fmt="A5"] .doc__ident-fields { font-size: .8em; gap: .35mm; margin-top: 1.6mm; }
.doc[data-fmt="A5"] .hf__lbl { min-width: 19mm; }
.doc[data-fmt="A5"] .hf--ar .hf__lbl { min-width: 14mm; }
.doc[data-fmt="A5"] .doc__rule { margin-top: 3mm; }
.doc[data-fmt="A5"] .doc__meta { margin-top: 3.5mm; gap: 5mm; }
.doc[data-fmt="A5"] .doc__patient--fields { gap: .35mm; font-size: .92em; }
.doc[data-fmt="A5"] .pf__lbl { min-width: 28mm; }
.doc[data-fmt="A5"] .doc__title { margin: 4mm 0 2.5mm; }
.doc[data-fmt="A5"] .rx-line { padding: 1.8mm 0; gap: 3mm; }
.doc[data-fmt="A5"] .rx-line__det { margin-top: .3mm; }
.doc[data-fmt="A5"] .rx-line__qsp { min-width: 20mm; }
.doc[data-fmt="A5"] .doc__certbody { margin-top: 5mm; }
.doc[data-fmt="A5"] .doc__orient { margin-top: 3.5mm; }
.doc[data-fmt="A5"] .doc__orient, .doc[data-fmt="A5"] .doc__certbody { line-height: calc(var(--doc-lh, 1.75) * .92); }
.doc[data-fmt="A5"] .doc__orient p, .doc[data-fmt="A5"] .doc__certbody p { margin-bottom: 2mm; }
.doc[data-fmt="A5"] .doc__exams { margin-top: 3mm; }
.doc[data-fmt="A5"] .doc__foot { margin-top: 6mm; }
.doc[data-fmt="A5"] .doc__sign { width: 50mm; }
.doc[data-fmt="A5"] .doc__sign .box { height: 15mm; }
/* Impression : ne jamais couper une ligne de médicament, le bloc patient ou la signature en deux. */
.rx-line, .doc__meta, .doc__foot, .doc-orient__opts { break-inside: avoid; page-break-inside: avoid; }

/* En-tête du document */
/* En-tête bilingue : français à gauche, arabe à droite, logo au centre */
.doc__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; }
.doc__ident { flex: 1 1 0; min-width: 0; }
.doc__logo-wrap { flex: 0 0 auto; display: flex; align-items: flex-start; padding-top: 1mm; }
.doc__logo { max-height: 22mm; max-width: 44mm; display: block; }
.doc__name { font-family: var(--doc-name-font, var(--font-doc)); font-size: 1.55em; font-weight: 700; color: #123; line-height: 1.15; }
.doc__spec { font-size: 1.02em; color: #2a3946; margin-top: 1mm; letter-spacing: .2px; }
.doc__contact { margin-top: 2.5mm; font-size: .82em; color: #47555f; line-height: 1.55; }
.doc__contact div { display: flex; gap: 6px; }
.doc__contact .k { color: #7c8894; min-width: 0; }
/* En-tête en champs libellés (Spécialité / Adresse / Téléphone …) */
.doc__ident-fields { margin-top: 2.5mm; display: flex; flex-direction: column; gap: .8mm; font-size: .88em; }
.hf { display: flex; align-items: baseline; gap: 2mm; }
.hf__lbl { min-width: 24mm; flex: none; color: #47555f; font-weight: 700; }
.hf__lbl::after { content: " :"; }
.hf__val { color: #2a3946; }
/* Version arabe des libellés (colonne de droite, RTL) */
.doc__ident-fields--ar { font-family: "Segoe UI", Tahoma, sans-serif; direction: rtl; text-align: right; }
.hf--ar .hf__lbl { min-width: 18mm; text-align: right; }
/* Colonne arabe (droite) — miroir de l'en-tête */
.doc__aside-ar { flex: 1 1 0; min-width: 0; text-align: right; direction: rtl; line-height: 1.5; }
.doc__name-ar { font-family: "Traditional Arabic", "Segoe UI", Tahoma, sans-serif; font-size: 1.7em; font-weight: 700; color: #123; line-height: 1.25; }
.doc__spec-ar { font-family: "Segoe UI", Tahoma, sans-serif; font-size: 1.05em; color: #2a3946; margin-top: 1mm; }
.doc__contact-ar { font-family: "Segoe UI", Tahoma, sans-serif; margin-top: 2.5mm; font-size: .84em; color: #47555f; line-height: 1.65; }
.doc__rule { height: 0; border: none; border-top: 2px solid var(--accent); margin: 5mm 0 0; }
.doc__rule2 { height: 0; border: none; border-top: 1px solid #d7dee4; margin: 1.2px 0 0; }

/* Ligne méta : date + patient */
.doc__meta { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 6mm; gap: 8mm; }
.doc__patient { font-size: .96em; }
.doc__patient .lbl { color: #7c8894; font-size: .82em; text-transform: uppercase; letter-spacing: .6px; }
.doc__patient .val { font-weight: 600; font-size: 1.12em; color: #16202b; margin-top: 1mm; }
.doc__patient .sub { color: #47555f; font-size: .92em; margin-top: .5mm; }
/* Bloc patient en champs libellés (Nom / Prénom / Âge / Date de naissance) */
.doc__patient--fields { display: flex; flex-direction: column; gap: .8mm; }
.pf { display: flex; align-items: baseline; gap: 2mm; }
.pf__lbl { min-width: 34mm; flex: none; color: #16202b; font-weight: 700; }
.pf__lbl::after { content: " :"; }
.pf__val { color: #16202b; }
.pf__dots { color: #9aa4ad; letter-spacing: .5px; }
.doc__date { text-align: right; font-size: .92em; color: #2a3946; white-space: nowrap; }

/* Titre du document */
.doc__title { text-align: center; margin: 7mm 0 5mm; }
.doc__title span { font-size: .82em; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); font-weight: 700; border-bottom: 1px solid var(--accent-tint-2); padding-bottom: 1.5mm; }

/* Corps : prescription */
.doc__body { flex: 1; }
.rx-line { display: flex; align-items: baseline; gap: 4mm; padding: 2.6mm 0; border-bottom: 1px dotted #dbe1e7; }
.rx-line:last-child { border-bottom: none; }
.rx-line__mark { color: var(--accent); font-weight: 700; min-width: 7mm; flex: none; }
.rx-line__content { flex: 1; }
.rx-line__med { font-weight: 700; font-size: 1.04em; }
.rx-line__det { color: #3c4a55; margin-top: .6mm; }
.rx-line__det .dot { margin: 0 2.2mm; color: #b7c0c8; }
/* QSP alignée en colonne à droite de chaque ligne */
.rx-line__qsp { flex: none; min-width: 26mm; text-align: right; white-space: nowrap; color: var(--accent); font-weight: 600; }

/* Corps : certificat */
.doc__certbody { flex: 1; font-size: 1.05em; line-height: var(--doc-lh, 1.8); margin-top: 8mm; }
.doc__certbody p { margin: 0 0 3mm; }
.doc__certbody p:empty { margin: 0; }
.doc__certbody .fill { font-weight: 600; }

/* Corps : examens complémentaires (« Prière de faire ») */
.doc__exams { flex: 1; margin-top: 5mm; }
.doc-exam__fam { margin-bottom: 5mm; break-inside: avoid; }
.doc-exam__famname { font-weight: 700; color: var(--accent); font-size: .9em; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--accent-tint-2); padding-bottom: 1mm; margin-bottom: 2.5mm; }
.doc-exam__items { column-count: 2; column-gap: 9mm; }
.doc-exam__item { display: flex; align-items: center; gap: 2.5mm; padding: 1.05mm 0; break-inside: avoid; font-size: .96em; }
.doc-exam__box { width: 3.3mm; height: 3.3mm; border: 1px solid #4a4a4a; border-radius: .5mm; flex: none; display: inline-block; }
/* Feuille d'examens : un tiret devant chaque examen (pas de case à cocher — la liste
   imprimée est déjà la liste des examens à faire). */
.doc-exam__dash { width: 4mm; height: 0; border-top: 1.5px solid var(--accent); flex: none; display: inline-block; }
.doc-exam__empty { color: #9aa4ad; }
.doc[data-fmt="A5"] .doc-exam__items { column-count: 1; }

/* Corps : orientation (lettre de liaison) */
.doc__orient { flex: 1; font-size: 1.05em; line-height: var(--doc-lh, 1.8); margin-top: 6mm; }
.doc__orient p { margin: 0 0 3mm; }
.doc-orient__opts { margin: 1mm 0 3mm 4mm; }
.doc-orient__opt { display: flex; align-items: center; gap: 2.5mm; padding: 1mm 0; }
.doc-orient__box { width: 3.6mm; height: 3.6mm; border: 1px solid #333; border-radius: .5mm; display: inline-flex; align-items: center; justify-content: center; font-size: 2.9mm; line-height: 1; flex: none; color: #16202b; }

/* Dossier patient imprimable (export PDF) */
.dd-patient { margin: 4mm 0 1mm; font-size: 1.02em; }
.dd-section { margin: 6mm 0 2.5mm; font-weight: 700; color: var(--accent); font-size: .85em; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid #dbe1e7; padding-bottom: 1mm; }
.dd-consult { border-left: 2px solid var(--accent); padding-left: 3.5mm; margin-bottom: 4.5mm; break-inside: avoid; }
.dd-date { font-weight: 700; color: var(--accent); font-size: .9em; margin-bottom: 1.5mm; }
.dd-block { margin-bottom: 2mm; }
.dd-lbl { font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #7c8894; }
.dd-txt { white-space: pre-wrap; font-size: .95em; color: #16202b; }
.dd-empty { color: #9aa4ad; }
.dd-doc { display: flex; gap: 4mm; padding: 1.2mm 0; border-bottom: 1px dotted #dbe1e7; font-size: .92em; }
.dd-doc-date { color: var(--accent); font-weight: 600; min-width: 34mm; flex: none; }

/* Pied : signature */
.doc__foot { margin-top: 10mm; display: flex; justify-content: flex-end; }
.doc__sign { text-align: center; width: 62mm; }
.doc__sign .lbl { font-size: .84em; color: #47555f; }
.doc__sign .box { height: 24mm; border-bottom: 1px solid #c4ccd3; margin-top: 1mm; }

/* ============================================================================
   STUDIO DE DESIGN — briques du document
   Chaque brique = une classe sur .doc ; couleurs/polices = variables CSS.
   Le HTML ne change pas : rien ne peut casser la mise en page.
   ============================================================================ */
.doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc__name, .doc__name-ar { color: var(--ink, #16202b); }

/* — Papier — */
.doc--paper-cream { background: #fbf7ee; }
.doc--paper-grid { background-color: #fff; background-image: linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px); background-size: 5mm 5mm; }
.doc--paper-dots { background-color: #fff; background-image: radial-gradient(rgba(0,0,0,.10) .35mm, transparent .45mm); background-size: 4mm 4mm; }

/* — Logo — */
.doc--logo-left .doc__logo-wrap { order: -1; }
.doc--logo-right .doc__logo-wrap { order: 3; }
.doc__logo-wm { position: absolute; left: 50%; top: 50%; width: 110mm; max-height: 110mm; object-fit: contain; transform: translate(-50%, -50%); opacity: .07; z-index: -1; pointer-events: none; }

/* — Cadres de page (pseudo-élément dans la marge : n'affecte pas le contenu) — */
.doc--f-thin::before, .doc--f-double::before, .doc--f-rounded::before, .doc--f-corners::before { content: ""; position: absolute; inset: 7mm; pointer-events: none; z-index: 2; }
.doc[data-fmt="A5"].doc--f-thin::before, .doc[data-fmt="A5"].doc--f-double::before, .doc[data-fmt="A5"].doc--f-rounded::before, .doc[data-fmt="A5"].doc--f-corners::before { inset: 5mm; }
.doc--f-thin::before { border: 1px solid var(--accent); }
.doc--f-double::before { border: 3px double var(--accent); }
.doc--f-rounded::before { border: 1.5px solid var(--accent); border-radius: 4mm; }
.doc--f-corners::before { background:
  linear-gradient(var(--accent), var(--accent)) left top / 10mm 1.5px no-repeat, linear-gradient(var(--accent), var(--accent)) left top / 1.5px 10mm no-repeat,
  linear-gradient(var(--accent), var(--accent)) right top / 10mm 1.5px no-repeat, linear-gradient(var(--accent), var(--accent)) right top / 1.5px 10mm no-repeat,
  linear-gradient(var(--accent), var(--accent)) left bottom / 10mm 1.5px no-repeat, linear-gradient(var(--accent), var(--accent)) left bottom / 1.5px 10mm no-repeat,
  linear-gradient(var(--accent), var(--accent)) right bottom / 10mm 1.5px no-repeat, linear-gradient(var(--accent), var(--accent)) right bottom / 1.5px 10mm no-repeat; }
/* Bandeau + cadre : la partie du cadre qui traverse le bandeau devient un liseré blanc (voulu, pas un défaut). */
.doc--h-band.doc--f-thin::before, .doc--h-band.doc--f-double::before, .doc--h-band.doc--f-rounded::before { border-top-color: rgba(255,255,255,.6); }
.doc--f-sideband::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6mm; background: var(--accent); z-index: 2; }
.doc--f-sideband[data-fmt="A4"] { padding-left: calc(18mm * var(--doc-margin, 1) + 4mm); }
.doc--f-sideband[data-fmt="A5"] { padding-left: calc(10mm * min(var(--doc-margin, 1), 1.15) + 4mm); }

/* — En-tête — */
.doc--h-band .doc__header { background: var(--accent); color: #fff; }
.doc--h-band[data-fmt="A4"] .doc__header { margin: calc(-16mm * var(--doc-margin, 1)) calc(-18mm * var(--doc-margin, 1)) 0; padding: 8mm calc(18mm * var(--doc-margin, 1)) 6mm; }
.doc--h-band[data-fmt="A5"] .doc__header { margin: calc(-9mm * min(var(--doc-margin, 1), 1.15)) calc(-10mm * min(var(--doc-margin, 1), 1.15)) 0; padding: 6mm calc(10mm * min(var(--doc-margin, 1), 1.15)) 5mm; }
.doc--h-band .doc__name, .doc--h-band .doc__name-ar, .doc--h-band .hf__val { color: #fff; }
.doc--h-band .hf__lbl { color: rgba(255,255,255,.82); }
.doc--h-band .doc__rule { display: none; }
.doc--h-band .doc__rule2 { border-top-color: var(--accent-tint-2); margin-top: 0; }
.doc--h-band .doc__logo { background: #fff; padding: 1.5mm; border-radius: 1.5mm; }

.doc--h-centered .doc__header { flex-direction: column; align-items: center; text-align: center; gap: 2.5mm; }
.doc--h-centered .doc__ident, .doc--h-centered .doc__aside-ar { flex: none; width: 100%; text-align: center; }
.doc--h-centered .doc__logo-wrap { order: -1; padding-top: 0; }
.doc--h-centered .hf, .doc--h-centered .hf--ar { justify-content: center; }
.doc--h-centered .hf__lbl, .doc--h-centered .hf--ar .hf__lbl { min-width: 0; }
.doc--h-centered .doc__name { font-size: 1.75em; }

.doc--h-underline .doc__name { display: inline-block; border-bottom: 2.5px solid var(--accent); padding-bottom: 1mm; }
.doc--h-underline .doc__rule { display: none; }

.doc--h-compact .doc__name { font-size: 1.25em; }
.doc--h-compact .doc__ident-fields { font-size: .8em; gap: .3mm; margin-top: 1.5mm; }
.doc--h-compact .doc__name-ar { font-size: 1.35em; }
.doc--h-compact .doc__logo { max-height: 16mm; }
.doc--h-compact .doc__rule { border-top-width: 1px; margin-top: 3mm; }
.doc--h-compact .doc__rule2 { display: none; }

.doc--h-boxed .doc__header { background: var(--accent-tint); border: 1px solid var(--accent-tint-2); border-radius: 2mm; padding: 4mm 5mm; }
.doc--h-boxed .doc__rule, .doc--h-boxed .doc__rule2 { display: none; }

/* — Titre « Ordonnance » — */
.doc--t-pill .doc__title span { background: var(--accent); color: #fff; border: none; border-radius: 20mm; padding: 1.6mm 7mm; letter-spacing: 2px; }
.doc--t-plain .doc__title span { border: none; letter-spacing: 1px; font-size: 1.05em; color: var(--ink, #16202b); text-transform: none; padding: 0; }
.doc--t-boxed .doc__title span { border: 1.5px solid var(--accent); padding: 1.6mm 6mm; }
.doc--t-underline .doc__title span { border-bottom: 2px solid var(--accent); font-size: 1em; letter-spacing: 2px; padding-bottom: 1mm; }
.doc--t-left .doc__title { text-align: left; }
.doc--t-left .doc__title span { border-bottom: none; border-left: 3px solid var(--accent); padding: 0 0 0 3mm; letter-spacing: 2px; }

/* — Lignes de médicaments — */
.doc--m-bullets .rx-line__mark { font-size: 1.35em; line-height: 1; min-width: 5mm; }
.doc--m-rx .rx-line__mark { font-style: italic; }
.doc--m-lined .rx-line, .doc--m-lined .rx-line:last-child { border-bottom: 1px solid var(--accent-tint-2); padding: 3mm 0; }
.doc--m-boxed .rx-line, .doc--m-boxed .rx-line:last-child { border: 1px solid var(--accent-tint-2); border-radius: 1.5mm; padding: 2.6mm 3.2mm; margin-bottom: 2.2mm; background: rgba(255,255,255,.65); }
.doc--m-table .doc__body { flex: 0 0 auto; border: 1px solid var(--accent-tint-2); border-radius: 1.2mm; overflow: hidden; }
.doc--m-table .doc__foot { margin-top: auto; padding-top: 10mm; }
.doc--m-table .rx-head { display: flex; gap: 4mm; align-items: center; background: var(--accent); color: #fff; font-size: .74em; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 1.8mm 3mm; }
.doc--m-table .rx-head__n { min-width: 7mm; flex: none; }
.doc--m-table .rx-head__m { flex: 1; }
.doc--m-table .rx-head__q { min-width: 26mm; text-align: right; flex: none; }
.doc--m-table .rx-line, .doc--m-table .rx-line:last-child { border-bottom: 1px solid var(--accent-tint-2); padding: 2.3mm 3mm; margin: 0; }
.doc--m-table .rx-line:last-child { border-bottom: none; }
.doc--m-table .rx-line:nth-child(odd) { background: var(--accent-tint); }

/* — Bloc patient — */
.doc--p-inline .doc__patient--fields { flex-direction: row; flex-wrap: wrap; gap: 1mm 7mm; }
.doc--p-inline .pf__lbl { min-width: 0; color: #47555f; font-weight: 600; }
.doc--p-boxed .doc__meta { border: 1px solid var(--accent-tint-2); border-radius: 1.5mm; padding: 3mm 4mm; align-items: flex-start; }
.doc--p-card .doc__meta { background: var(--accent-tint); border-radius: 2mm; padding: 3.5mm 4.5mm; align-items: flex-start; }
.doc--p-card .pf__lbl { color: var(--accent); }

/* — Signature — */
.doc--s-line .doc__sign .box { height: 16mm; border-bottom: 1px solid var(--ink, #16202b); }
.doc--s-stamp .doc__sign .box { height: 26mm; border: 1.5px dashed var(--accent); border-radius: 2mm; margin-top: 2mm; }
.doc--s-left .doc__foot { justify-content: flex-start; }

/* — Pied de page : adresse + téléphone (FR à gauche, AR à droite), puis horaires / texte — */
.doc__footer { display: block; margin-top: 6mm; padding-top: 2.5mm; border-top: 1px solid var(--accent-tint-2); font-size: .78em; color: #47555f; line-height: 1.45; letter-spacing: .2px; }
.doc__footer-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 6mm; }
.doc__footer--solo .doc__footer-row { justify-content: center; text-align: center; }
.doc__footer-ar { text-align: right; font-family: var(--doc-ar-font, "Segoe UI", Tahoma, sans-serif); }
.doc__footer-extra { text-align: center; margin-top: .8mm; }
.doc--h-band .doc__footer { border-top: none; background: var(--accent); color: #fff; padding: 2.5mm 4mm; border-radius: 1mm; }

/* ============================================================================
   STUDIO DE DESIGN — l'écran
   ============================================================================ */
.modal--studio { flex-direction: column; align-items: stretch; justify-content: flex-start; background: #55606c; z-index: 130; }
.studio { flex: 1; display: flex; min-height: 0; }
.studio__stage { flex: 1; min-width: 0; display: flex; align-items: flex-start; justify-content: center; padding: 22px; overflow: auto; }
.studio__scale { position: relative; overflow: hidden; box-shadow: 0 6px 30px rgba(0,0,0,.35); background: #fff; flex: none; }
.studio__scale .paper { position: absolute; left: 0; top: 0; transform-origin: top left; box-shadow: none; }
.studio__side { width: 400px; flex: none; background: #fff; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.studio__tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.studio__tabs button { flex: 1; padding: 13px 8px; font-weight: 700; font-size: 13.5px; color: var(--text-3); background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.studio__tabs button.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.studio__panel { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.studio__hint { font-size: 12.5px; color: var(--text-3); margin: 0 0 12px; line-height: 1.45; }
.sd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sd-card { border: 2px solid var(--border); border-radius: 10px; padding: 8px; cursor: pointer; background: var(--surface-2); transition: border-color .12s, box-shadow .12s; content-visibility: auto; contain-intrinsic-size: auto 320px; }
.sd-thumb { contain: strict; }
.sd-card:hover { border-color: var(--accent-tint-2); }
.sd-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.sd-thumb { width: 100%; aspect-ratio: 210 / 297; overflow: hidden; position: relative; background: #fff; border: 1px solid var(--border); border-radius: 4px; pointer-events: none; }
.sd-thumb__scale { position: absolute; left: 0; top: 0; width: 210mm; transform-origin: top left; transform: scale(var(--thumb-s, .2)); }
.sd-thumb .doc { width: 210mm; min-height: 297mm; }
.sd-card__name { margin-top: 8px; font-weight: 700; font-size: 13px; color: var(--text); }
.sd-card__desc { font-size: 11.5px; color: var(--text-3); line-height: 1.35; margin-top: 2px; }
.sd-sec { margin-bottom: 18px; content-visibility: auto; contain-intrinsic-size: auto 90px; }
.sd-sec__title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); margin-bottom: 8px; }
.sd-opts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sd-opt { border: 1px solid var(--border-strong); background: #fff; border-radius: 8px; padding: 6px 11px; font-size: 12.5px; cursor: pointer; color: var(--text-2); transition: all .12s; }
.sd-opt:hover { border-color: var(--accent); color: var(--accent); }
.sd-opt.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sd-pal { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.18); cursor: pointer; padding: 0; background: linear-gradient(135deg, var(--pa) 0 58%, var(--pt) 58% 100%); transition: transform .1s; }
.sd-pal:hover { transform: scale(1.1); }
.sd-pal.is-active { box-shadow: 0 0 0 2.5px var(--accent); }
.sd-custom { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); cursor: pointer; }
.sd-custom input[type="color"] { width: 34px; height: 34px; padding: 0; border: 1px solid var(--border-strong); border-radius: 50%; background: #fff; cursor: pointer; }
.sd-pairs { display: flex; flex-direction: column; gap: 6px; }
.sd-pair { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; background: #fff; cursor: pointer; text-align: left; }
.sd-pair:hover { border-color: var(--accent); }
.sd-pair.is-active { border-color: var(--accent); background: var(--accent-tint); }
.sd-pair__t { font-size: 15px; font-weight: 700; color: var(--text); }
.sd-pair__b { font-size: 12px; color: var(--text-2); }
.sd-fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 176px; overflow-y: auto; padding-right: 4px; }
.sd-font { border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 9px; font-size: 14px; cursor: pointer; background: #fff; text-align: left; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-font:hover { border-color: var(--accent); }
.sd-font.is-active { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.sd-input { width: 100%; margin-top: 8px; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13px; }
.style-open { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.style-open__sum { font-size: 12.5px; color: var(--text-3); }
.btn--onDark { color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.25); }
.btn--onDark:hover { background: rgba(255,255,255,.12); color: #fff; }
@media screen and (max-width: 860px) {
  .studio { flex-direction: column; }
  .studio__stage { flex: 0 0 45%; }
  .studio__side { width: 100%; flex: 1; border-left: none; border-top: 1px solid var(--border); }
}

/* ============================================================================
   STUDIO — Phase 2 : nouvelles briques
   ============================================================================ */
/* Police arabe choisie */
.doc__name-ar, .doc__ident-fields--ar, .doc__title-ar { font-family: var(--doc-ar-font, "Traditional Arabic", "Segoe UI", Tahoma, sans-serif); }
/* Style du nom du médecin */
.doc--n-upper .doc__name { text-transform: uppercase; letter-spacing: .5px; }
.doc--n-smallcaps .doc__name { font-variant: small-caps; letter-spacing: .6px; }
.doc--n-accent .doc__name { color: var(--accent); }
.doc--n-upperaccent .doc__name { text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.doc--h-band.doc--n-accent .doc__name, .doc--h-band.doc--n-upperaccent .doc__name,
.doc--h-two-tone.doc--n-accent .doc__name, .doc--h-two-tone.doc--n-upperaccent .doc__name { color: #fff; }
/* En-tête bicolore (comme le bandeau, avec la couleur secondaire à droite) */
.doc--h-two-tone .doc__header { background: linear-gradient(100deg, var(--accent) 0 66%, var(--accent2) 66% 100%); color: #fff; }
.doc--h-two-tone[data-fmt="A4"] .doc__header { margin: calc(-16mm * var(--doc-margin, 1)) calc(-18mm * var(--doc-margin, 1)) 0; padding: 8mm calc(18mm * var(--doc-margin, 1)) 6mm; }
.doc--h-two-tone[data-fmt="A5"] .doc__header { margin: calc(-9mm * min(var(--doc-margin, 1), 1.15)) calc(-10mm * min(var(--doc-margin, 1), 1.15)) 0; padding: 6mm calc(10mm * min(var(--doc-margin, 1), 1.15)) 5mm; }
.doc--h-two-tone .doc__name, .doc--h-two-tone .doc__name-ar, .doc--h-two-tone .hf__val { color: #fff; }
.doc--h-two-tone .hf__lbl { color: rgba(255,255,255,.82); }
.doc--h-two-tone .doc__rule { display: none; }
.doc--h-two-tone .doc__rule2 { border-top-color: var(--accent-tint-2); margin-top: 0; }
.doc--h-two-tone .doc__logo { background: #fff; padding: 1.5mm; border-radius: 1.5mm; }
.doc--h-two-tone .doc__footer { border-top: none; background: var(--accent); color: #fff; padding: 2.5mm 4mm; border-radius: 1mm; }
/* En-tête empilé : français en haut, arabe en dessous, logo dans l'angle */
.doc--h-stack .doc__header { flex-direction: column; align-items: stretch; gap: 2mm; position: relative; }
.doc--h-stack .doc__ident, .doc--h-stack .doc__aside-ar { flex: none; width: 100%; }
.doc--h-stack .doc__aside-ar { border-top: 1px solid var(--accent-tint-2); padding-top: 1.5mm; }
.doc--h-stack .doc__logo-wrap { position: absolute; right: 0; top: 0; }
.doc--h-stack.doc--logo-left .doc__logo-wrap { right: auto; left: 0; }
.doc--h-stack.doc--logo-left .doc__ident { padding-left: 48mm; }
.doc--h-stack .doc__name-ar { font-size: 1.5em; }
/* En-tête « arabe dominant » */
.doc--h-split-ar .doc__name-ar { font-size: 2.1em; }
.doc--h-split-ar .doc__name { font-size: 1.2em; }
.doc--h-split-ar .doc__ident-fields { font-size: .8em; }
.doc--h-split-ar .doc__ident-fields--ar { font-size: 1em; }
.doc--h-split-ar .doc__aside-ar { flex: 1.25 1 0; }
/* Cadres : filet haut, bande basse */
.doc--f-topline::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5mm; background: var(--accent); z-index: 2; }
.doc--f-bottomband::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6mm; background: var(--accent2); z-index: 2; }
/* Titre : bilingue, bande teintée */
.doc__title-sep { opacity: .5; }
.doc__title-ar { font-size: 1.2em; letter-spacing: 0; text-transform: none; }
.doc--t-bilingual .doc__title span { letter-spacing: 1.5px; }
.doc--t-band .doc__title { background: var(--accent-tint); padding: 2mm; border-radius: 1.2mm; }
.doc--t-band .doc__title span { border: none; }
/* Médicaments : cases à cocher, pointillés, QSP en badge */
.rx-line__box { display: inline-block; width: 3.6mm; height: 3.6mm; border: 1px solid var(--ink, #16202b); border-radius: .6mm; vertical-align: -.4mm; }
.doc--m-check .rx-line__mark { min-width: 6mm; }
.doc--m-check .rx-line { border-bottom: 1px dotted var(--accent-tint-2); }
.doc--m-dashed .rx-line, .doc--m-dashed .rx-line:last-child { border-bottom: 1px dashed var(--accent-tint-2); padding: 2.6mm 0; }
.doc--m-pillqsp .rx-line__qsp { background: var(--accent); color: #fff; border-radius: 20mm; padding: .6mm 2.8mm; font-size: .85em; min-width: 0; align-self: center; }
/* Bloc patient : grille 2 colonnes, lignes pointillées */
.doc--p-grid .doc__patient--fields { display: grid; grid-template-columns: 1fr 1fr; gap: .8mm 7mm; }
.doc--p-grid .pf__lbl { min-width: 22mm; }
.doc--p-dotted .doc__patient { flex: 1; }
.doc--p-dotted .pf__val { flex: 1; border-bottom: 1px dotted #8a949c; padding-bottom: .3mm; }
.doc--p-dotted .pf__dots { visibility: hidden; }
/* Signature : Signature + Cachet, centrée */
.doc__foot--double { justify-content: space-between; gap: 8mm; }
.doc--s-double .doc__sign { width: 46mm; }
.doc--s-center .doc__foot { justify-content: center; }
/* Papiers pastel et lin */
.doc--paper-blue { background: #f3f8fc; }
.doc--paper-pink { background: #fdf5f7; }
.doc--paper-mint { background: #f2faf5; }
.doc--paper-linen { background-color: #fbf9f4; background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.025) 0 1px, transparent 1px 3px); }
/* A5 : compléments compacts pour les nouvelles briques */
/* En-têtes centré / empilé : les champs passent sur une ligne (ou 2 colonnes) — sinon
   l'en-tête empile FR puis AR et mange la petite page. */
.doc[data-fmt="A5"].doc--h-centered .doc__ident-fields, .doc[data-fmt="A5"].doc--h-centered .doc__ident-fields--ar { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: .2mm 4mm; font-size: .76em; margin-top: 1mm; }
.doc[data-fmt="A5"].doc--h-centered .doc__header { gap: 1.5mm; }
.doc[data-fmt="A5"].doc--h-centered .doc__name { font-size: 1.45em; }
.doc[data-fmt="A5"].doc--h-centered .doc__name-ar { font-size: 1.35em; }
.doc[data-fmt="A5"].doc--h-stack .doc__ident-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .2mm 4mm; font-size: .76em; }
.doc[data-fmt="A5"].doc--h-stack .doc__ident-fields--ar { display: flex; flex-direction: row; flex-wrap: wrap; gap: .2mm 4mm; font-size: .9em; }
.doc[data-fmt="A5"].doc--h-stack .doc__aside-ar { padding-top: 1mm; }
.doc[data-fmt="A5"].doc--h-stack .doc__name-ar { font-size: 1.3em; }
/* Tableau, signature double et pied double : plus serrés en A5 */
.doc[data-fmt="A5"].doc--m-table .rx-line, .doc[data-fmt="A5"].doc--m-table .rx-line:last-child { padding: 1.5mm 2.5mm; }
.doc[data-fmt="A5"].doc--m-table .rx-head { padding: 1.2mm 2.5mm; }
.doc[data-fmt="A5"].doc--m-table .doc__foot { padding-top: 6mm; }
.doc[data-fmt="A5"] .doc__footer { margin-top: 4mm; padding-top: 1.8mm; font-size: .72em; line-height: 1.35; }
.doc[data-fmt="A5"].doc--s-double .doc__sign .box { height: 13mm; }
.doc[data-fmt="A5"].doc--h-split-ar .doc__name-ar { font-size: 1.7em; }
.doc[data-fmt="A5"] .doc--s-double .doc__sign, .doc[data-fmt="A5"].doc--s-double .doc__sign { width: 40mm; }
.doc[data-fmt="A5"].doc--f-topline::before { height: 4mm; }
.doc[data-fmt="A5"].doc--f-bottomband::after { height: 5mm; }

/* ============================================================================
   STUDIO — Phase 3 : barre du haut, catégories, Mes designs, partage
   ============================================================================ */
.preview-toolbar--studio { height: auto; min-height: 56px; padding: 6px 16px; gap: 10px; flex-wrap: wrap; }
.preview-toolbar--studio .preview-toolbar__left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview-toolbar--studio .preview-toolbar__right { flex-wrap: wrap; gap: 8px; }
.preview-toolbar .segment { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.14); }
.preview-toolbar .segment button { color: rgba(255,255,255,.75); }
.preview-toolbar .segment button.is-active { background: #fff; color: var(--accent); }
.studio-scope-lbl { font-size: 12px; color: rgba(255,255,255,.7); }
.studio-tag { font-size: 11px; font-weight: 700; color: #fff; background: rgba(255,255,255,.18); border-radius: 20px; padding: 3px 9px; }
.studio__actions { flex: none; border-top: 1px solid var(--border); padding: 10px 12px; background: var(--surface-2); }
.sd-actions__row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sd-actions__row + .sd-actions__row { margin-top: 8px; }
.sd-actions__row input, .sd-favform input { flex: 1; min-width: 140px; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13px; }
.sd-favform { display: flex; gap: 8px; margin-top: 8px; }
.sd-share { margin-top: 8px; }
.sd-share .studio__hint { margin-bottom: 8px; }
.sd-share__msg { margin-top: 8px; }
.sd-share__msg[data-ok="0"] { color: #b23; }
.sd-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.sd-cat { border: 1px solid var(--border-strong); border-radius: 16px; padding: 4px 11px; font-size: 12px; background: #fff; cursor: pointer; color: var(--text-2); }
.sd-cat:hover { border-color: var(--accent); color: var(--accent); }
.sd-cat.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sd-sub { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); margin: 6px 0 8px; }
.sd-grid + .sd-cats, .sd-grid + .sd-sub { margin-top: 16px; }
.sd-card { position: relative; }
.sd-card--fav { background: var(--accent-tint); }
.sd-card__del { position: absolute; top: 6px; right: 6px; z-index: 2; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); background: #fff; color: var(--text-2); font-size: 15px; line-height: 1; cursor: pointer; padding: 0; }
.sd-card__del:hover { background: #b23; color: #fff; border-color: #b23; }
.sd-fonts--ar .sd-font { font-size: 17px; text-align: right; }

/* ============================================================================
   TENIR SUR LA PAGE — garde-fou automatique
   Avant l'aperçu / l'impression, le document est mesuré hors écran ; s'il
   déborderait de la feuille, on le resserre d'un ou deux crans (police + espaces)
   pour qu'il reste TOUJOURS sur une seule page. Les sélecteurs portent [data-fmt]
   pour l'emporter sur les réglages A5.
   ============================================================================ */
.doc-measure { position: fixed; left: -20000px; top: 0; visibility: hidden; pointer-events: none; }
.doc-measure .paper .doc { min-height: 0 !important; }
/* A5 : briques « lourdes » un peu plus serrées */
.doc[data-fmt="A5"].doc--m-boxed .rx-line, .doc[data-fmt="A5"].doc--m-boxed .rx-line:last-child { padding: 1.8mm 2.5mm; margin-bottom: 1.4mm; }
.doc[data-fmt="A5"].doc--p-card .doc__meta, .doc[data-fmt="A5"].doc--p-boxed .doc__meta { padding: 2mm 3mm; }
.doc[data-fmt="A5"].doc--h-band .doc__header, .doc[data-fmt="A5"].doc--h-two-tone .doc__header { padding-top: 4.5mm; padding-bottom: 4mm; }
.doc[data-fmt="A5"].doc--h-boxed .doc__header { padding: 2.5mm 3.5mm; }
/* Crans de resserrement */
.doc[data-fmt].doc--fit-1 { --doc-fit: .94; }
.doc[data-fmt].doc--fit-2 { --doc-fit: .86; }
.doc[data-fmt].doc--fit-1 .rx-line, .doc[data-fmt].doc--fit-2 .rx-line, .doc[data-fmt].doc--fit-1 .rx-line:last-child, .doc[data-fmt].doc--fit-2 .rx-line:last-child { padding-top: 1.3mm; padding-bottom: 1.3mm; margin-bottom: 1mm; }
.doc[data-fmt].doc--fit-1 .rx-line__det, .doc[data-fmt].doc--fit-2 .rx-line__det { margin-top: .2mm; }
.doc[data-fmt].doc--fit-1 .doc__meta, .doc[data-fmt].doc--fit-2 .doc__meta { margin-top: 2.5mm; padding-top: 1.6mm; padding-bottom: 1.6mm; }
.doc[data-fmt].doc--fit-1 .doc__patient--fields, .doc[data-fmt].doc--fit-2 .doc__patient--fields { gap: .2mm; }
.doc[data-fmt].doc--fit-1 .doc__title, .doc[data-fmt].doc--fit-2 .doc__title { margin: 2.5mm 0 2mm; }
.doc[data-fmt].doc--fit-1 .doc__ident-fields, .doc[data-fmt].doc--fit-2 .doc__ident-fields { gap: .2mm; margin-top: 1mm; }
.doc[data-fmt].doc--fit-1 .doc__rule, .doc[data-fmt].doc--fit-2 .doc__rule { margin-top: 2.5mm; }
.doc[data-fmt].doc--fit-1 .doc__foot, .doc[data-fmt].doc--fit-2 .doc__foot { margin-top: 4mm; padding-top: 4mm; }
.doc[data-fmt].doc--fit-1 .doc__sign .box, .doc[data-fmt].doc--fit-2 .doc__sign .box { height: 12mm; }
.doc[data-fmt].doc--fit-1 .doc__footer, .doc[data-fmt].doc--fit-2 .doc__footer { margin-top: 2.5mm; padding-top: 1.5mm; }
.doc[data-fmt].doc--fit-2.doc--h-band .doc__header, .doc[data-fmt].doc--fit-2.doc--h-two-tone .doc__header { padding-top: 3.5mm; padding-bottom: 3mm; }
.doc[data-fmt].doc--fit-2 .doc__logo { max-height: 14mm; }
.doc[data-fmt].doc--fit-2 .doc__orient, .doc[data-fmt].doc--fit-2 .doc__certbody { line-height: calc(var(--doc-lh, 1.75) * .85); }
/* 3ᵉ cran (ordonnances longues : 10 à 12 médicaments sur A5). En dessous, le texte deviendrait
   trop petit : on laisse alors l'ordonnance continuer sur une 2ᵉ feuille (doc--pages-2). */
.doc[data-fmt].doc--fit-3 { --doc-fit: .78; }
.doc[data-fmt].doc--fit-3 .rx-line, .doc[data-fmt].doc--fit-3 .rx-line:last-child { padding-top: .8mm; padding-bottom: .8mm; margin-bottom: .5mm; }
.doc[data-fmt].doc--fit-3 .rx-line__det { margin-top: 0; }
.doc[data-fmt].doc--fit-3 .doc__meta { margin-top: 2mm; padding-top: 1.2mm; padding-bottom: 1.2mm; }
.doc[data-fmt].doc--fit-3 .doc__patient--fields { gap: 0; }
.doc[data-fmt].doc--fit-3 .doc__title { margin: 2mm 0 1.5mm; }
.doc[data-fmt].doc--fit-3 .doc__ident-fields { gap: 0; margin-top: .8mm; }
.doc[data-fmt].doc--fit-3 .doc__rule { margin-top: 2mm; }
.doc[data-fmt].doc--fit-3 .doc__foot { margin-top: 3mm; padding-top: 2mm; }
.doc[data-fmt].doc--fit-3 .doc__sign .box { height: 10mm; }
.doc[data-fmt].doc--fit-3.doc--h-band .doc__header, .doc[data-fmt].doc--fit-3.doc--h-two-tone .doc__header { padding-top: 3mm; padding-bottom: 2.5mm; }
.doc[data-fmt].doc--fit-3 .doc__logo { max-height: 13mm; }
.doc[data-fmt].doc--fit-3 .doc__footer { margin-top: 2mm; padding-top: 1.2mm; }
.doc[data-fmt].doc--fit-3 .doc__orient, .doc[data-fmt].doc--fit-3 .doc__certbody { line-height: calc(var(--doc-lh, 1.75) * .8); }
/* Plusieurs feuilles : hauteur = N pages (pied de page en bas de la dernière) ; à l'écran, un
   trait pointillé montre où la feuille se coupe. */
.paper[data-fmt="A4"] .doc.doc--pages-2 { min-height: 594mm; }
.paper[data-fmt="A5"] .doc.doc--pages-2 { min-height: 420mm; }
.paper[data-fmt="A4"] .doc.doc--pages-3 { min-height: 891mm; }
.paper[data-fmt="A5"] .doc.doc--pages-3 { min-height: 630mm; }
.doc-measure .paper .doc[class*="doc--pages-"] { min-height: 0 !important; }
.doc[class*="doc--pages-"]::after { content: "fin de la 1re feuille — la suite s'imprime sur une 2e feuille"; position: absolute; left: 0; right: 0; top: 297mm; border-top: 1.5px dashed #c0392b; color: #c0392b; font: 600 8pt/1.6 "Segoe UI", sans-serif; text-align: center; z-index: 5; pointer-events: none; }
.doc[data-fmt="A5"][class*="doc--pages-"]::after { top: 210mm; }
/* Page de réglage de l'imprimante (Paramètres → Impression) */
.doc.doc--test { position: relative; padding: 0 !important; font-family: "Segoe UI", Arial, sans-serif; color: #000; overflow: hidden; }
.doc--test[data-fmt="A4"] { height: 296mm; } .doc--test[data-fmt="A5"] { height: 209mm; }
.tp-frame { position: absolute; left: 5mm; right: 5mm; top: 5mm; bottom: 5mm; border: .4mm solid #000; }
.tp-frame--10 { left: 10mm; right: 10mm; top: 10mm; bottom: 10mm; border: .25mm dashed #555; }
.tp-tick { position: absolute; background: #000; font-style: normal; }
.tp-tick b { position: absolute; font-size: 6.5pt; font-weight: 400; }
.tp-tick--x { left: var(--p); top: 5mm; width: .25mm; height: 3mm; } .tp-tick--x b { top: 3.2mm; left: -2mm; width: 4mm; text-align: center; }
.tp-tick--y { top: var(--p); left: 5mm; height: .25mm; width: 3mm; } .tp-tick--y b { left: 3.6mm; top: -1.4mm; }
.tp-edge { position: absolute; left: 0; right: 0; text-align: center; font-size: 8.5pt; font-weight: 700; letter-spacing: .5px; }
.tp-edge--top { top: 12mm; } .tp-edge--bottom { bottom: 12mm; }
.tp-mid { position: absolute; left: 16mm; right: 16mm; top: 50%; transform: translateY(-50%); text-align: center; font-size: 10pt; line-height: 1.5; }
.tp-title { font-size: 15pt; font-weight: 700; margin-bottom: 2mm; }
.tp-help { margin-top: 4mm; font-size: 9pt; color: #222; }
.tp-corner { position: absolute; font-size: 7pt; color: #333; }
.tp-corner--tl { left: 11mm; top: 22mm; } .tp-corner--tr { right: 11mm; top: 22mm; } .tp-corner--bl { left: 11mm; bottom: 22mm; } .tp-corner--br { right: 11mm; bottom: 22mm; }
/* Paramètres → Impression : position de la feuille + page de réglage */
.print-adv { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.print-adv__lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.print-adv__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.print-tune { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 4px; }
.print-tune label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.print-tune input { width: 120px; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13.5px; }

/* ============================================================================
   IMPRESSION
   ============================================================================ */
#print-root { display: none; }

@media print {
  html, body { height: auto !important; overflow: visible !important; }
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  /* FEUILLE ANCRÉE EN HAUT. La taille de page n'est pas imposée en CSS pour l'impression
     réelle (voir applyPageSize) : si le pilote de l'imprimante reste sur un papier plus
     grand que le format choisi (A4 ou B5 au lieu d'A5…), le moteur d'impression centrait la
     page sur ce papier → en-tête descendu, pied de page hors de la feuille. Ici le document
     part toujours du bord haut ; seule sa position horizontale se règle (Paramètres). */
  #print-root { display: block; }
  #print-root .paper { box-shadow: none; margin: 0 auto; transform: translate(var(--print-dx, 0mm), var(--print-dy, 0mm)); }
  #print-root[data-align="left"] .paper { margin: 0 auto 0 0; }
  #print-root[data-align="right"] .paper { margin: 0 0 0 auto; }
  #print-root .paper[data-fmt="A4"] { width: 210mm; }
  #print-root .paper[data-fmt="A5"] { width: 148mm; }
  #print-root .doc { box-shadow: none; }
  /* Le document imprimé a la taille exacte de la page (1 mm de marge de sécurité
     pour éviter une 2ᵉ page blanche due aux arrondis) : l'impression = l'aperçu. */
  #print-root .paper[data-fmt="A4"] .doc { width: 210mm; min-height: 296mm; }
  #print-root .paper[data-fmt="A5"] .doc { width: 148mm; min-height: 209mm; }
  /* Ordonnance trop longue pour une feuille : le pied de page reste en bas de la DERNIÈRE page. */
  #print-root .paper[data-fmt="A4"] .doc.doc--pages-2 { min-height: 593mm; }
  #print-root .paper[data-fmt="A5"] .doc.doc--pages-2 { min-height: 419mm; }
  #print-root .paper[data-fmt="A4"] .doc.doc--pages-3 { min-height: 890mm; }
  #print-root .paper[data-fmt="A5"] .doc.doc--pages-3 { min-height: 629mm; }
  .doc[class*="doc--pages-"]::after { display: none !important; }
  .paper { box-shadow: none; }
}


/* ============================================================================
   RESPONSIVE — tablette & téléphone (version web ; le bureau reste ≥ 1000px)
   ============================================================================ */
@media screen and (max-width: 860px) {
  html, body { height: auto; overflow: auto; -webkit-text-size-adjust: 100%; }
  .appbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px 12px; position: sticky; top: 0; }
  .appbar__doctor { order: 5; flex-basis: 100%; margin-left: 0; }
  .demo-chip { order: 4; }
  .layout { display: block; height: auto; padding: 12px; }
  .panel { display: block; height: auto; overflow: visible; margin-bottom: 12px; }
  .patient > .search, .patient__form, .history { padding: 0 14px; }
  .history { min-height: 0; }
  .work { padding: 14px; }
  .doc-pane { overflow: visible; }
  #paneExamen { overflow: visible; }
  .exam-catalog { overflow: visible; min-height: 0; }
  .exam-list { max-height: none; }
  .segment--tabs { width: 100%; }
  .segment--tabs button { padding: 8px 12px; font-size: 13px; }
  /* Modales plein écran sur mobile */
  .modal__box { max-width: 100%; width: 100%; max-height: 100%; border-radius: 0; }
  .rx-entry__row--2 { flex-wrap: wrap; }
  .field--duree, .field--addbtn { flex-basis: 100%; }
  /* Aperçu : le papier tient dans l'écran */
  .preview-scroll { padding: 10px; }
  .paper[data-fmt="A4"] .doc, .paper[data-fmt="A5"] .doc { width: 100%; min-height: 0; }
  .doc[data-fmt="A4"] { padding: 10mm 8mm; }
  .preview-toolbar { flex-wrap: wrap; height: auto; gap: 8px; padding: 8px 12px; }
}
@media screen and (max-width: 480px) {
  .brand__by { display: none; }
  .btn span { font-size: 13px; }
  .style-grid { grid-template-columns: 1fr 1fr; }
}

/* ── TABLEAU : signature et pied de page en bas de la feuille ─────────────────
   (les règles A5 et doc--fit-N fixaient une marge en mm qui annulait « auto ») */
.doc[data-fmt].doc--m-table .doc__foot { margin-top: auto; }
.doc[data-fmt][class*="doc--fit-"].doc--m-table .doc__foot { margin-top: auto; }
.doc[data-fmt="A5"].doc--m-table .doc__foot { padding-top: 5mm; }
.doc[data-fmt][class*="doc--fit-"].doc--m-table .doc__foot { padding-top: 3mm; }

/* ══ Statistiques du cabinet ══ */
.modal__box--stats { width: 760px; }
.stats-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.segment--wrap-sm { flex-wrap: wrap; }
.stats-range { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.st-title { margin: 2px 0 12px; font-size: 15.5px; font-weight: 650; }
.st-title::first-letter { text-transform: uppercase; }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.st-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; }
.st-tile--big { background: var(--accent-tint); border-color: var(--accent-tint-2); }
.st-tile__n { font-size: 25px; font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.st-tile--big .st-tile__n { font-size: 31px; color: var(--accent); }
.st-tile__l { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.st-tile__s { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.3; }
.st-docs { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 4px; font-size: 13px; color: var(--text-2); }
.st-docs b { color: var(--text); }
.st-empty { margin: 18px 0 4px; color: var(--text-3); font-size: 13.5px; }
.st-hint { margin: 16px 0 6px; font-size: 12px; color: var(--text-3); }
.st-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13.5px; }
.st-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.st-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.st-table__h { width: 58px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.st-table__w { color: var(--text-2); }
.st-bars { display: flex; flex-direction: column; gap: 2px; }
.st-bar { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; width: 100%; padding: 3px 6px; border: 0; border-radius: 6px; background: none; font: inherit; font-size: 13px; color: var(--text); text-align: left; cursor: pointer; }
.st-bar:hover { background: var(--surface-2); }
.st-bar.is-zero { color: var(--text-3); }
.st-bar__track { height: 12px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.st-bar__fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.st-bar__n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
@media screen and (max-width: 560px) {
  .st-bar { grid-template-columns: 78px 1fr 34px; gap: 6px; }
  .stats-range { flex-wrap: wrap; }
}

/* ══ Certificat d'arrêt de travail (formulaire : 1° arrêt, 2° prolongation, 3° reprise) ══ */
.doc__certbody--at { display: flex; flex-direction: column; gap: 1.6mm; line-height: 1.45; font-size: 1em; margin-top: 5mm; }
.doc__certbody--at .at-intro { margin: 0 0 1mm; }
.at-l { display: flex; align-items: baseline; gap: 2mm; min-width: 0; }
.at-l > span:not(.at-fill) { flex: none; white-space: nowrap; }
.at-fill { flex: 1 1 auto; min-width: 12mm; border-bottom: 1px dotted #555; min-height: 1.25em; padding: 0 1.5mm; font-weight: 700; font-style: normal; overflow-wrap: anywhere; }
.at-fill--s { flex: 0 0 auto; min-width: 18mm; text-align: center; white-space: nowrap; padding: 0 2.5mm; }
.at-fill--off { font-weight: 400; text-align: center; color: #333; }
.at-fill--age { flex: 0 0 24mm; }
.at-item { margin-top: 2.6mm; display: flex; flex-direction: column; gap: 1.2mm; }
.at-h { font-weight: 500; font-style: italic; text-transform: uppercase; letter-spacing: .2px; }
.at-l--in { padding-left: 7mm; font-style: italic; }
.at-sortie { display: flex; align-items: center; gap: 9mm; margin-top: 4mm; padding-left: 7mm; font-style: italic; }
.at-opt { display: inline-flex; align-items: center; gap: 2mm; }
.at-box { width: 3.6mm; height: 3.6mm; border: 1px solid #333; border-radius: .5mm; display: inline-flex; align-items: center; justify-content: center; font-size: 2.9mm; line-height: 1; font-style: normal; color: #16202b; }
.at-med { margin-top: 3mm; padding-left: 3mm; font-style: italic; }
.doc .doc__foot.doc__foot--at { justify-content: flex-end; margin-top: 2mm; }
.at-date { font-style: italic; }
.doc[data-fmt="A5"] .doc__certbody--at { margin-top: 3mm; gap: 1.1mm; line-height: 1.38; }
.doc[data-fmt="A5"] .at-item { margin-top: 1.8mm; gap: .8mm; }
.doc[data-fmt="A5"] .at-sortie { margin-top: 2.6mm; }
.doc[data-fmt="A5"] .at-med { margin-top: 2mm; }
.doc[data-fmt].doc--fit-1 .doc__certbody--at, .doc[data-fmt].doc--fit-2 .doc__certbody--at, .doc[data-fmt].doc--fit-3 .doc__certbody--at { line-height: 1.3; gap: .8mm; }
.doc[data-fmt].doc--fit-2 .at-item, .doc[data-fmt].doc--fit-3 .at-item { margin-top: 1.2mm; gap: .5mm; }

/* ══ Historique : Modifier / Dupliquer ══ */
.hist-item__acts { display: flex; align-items: center; gap: 16px; }
.hist-item__edit { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; }
.hist-item__edit .ico { width: 14px; height: 14px; }
.hist-item__edit:hover { text-decoration: underline; }
.hist-item__mod { font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.hist-item.is-editing { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: #fff; }
.hist-item__tag--res { color: #1d6b45; background: #e3f4ea; }
/* ══ Bandeau « Vous modifiez … » ══ */
.edit-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 14px; padding: 9px 12px; border: 1px solid #f0d9a8; background: #fdf6e7; border-radius: var(--r); color: #6b4d12; font-size: 13px; }
.edit-banner .ico { color: #b07a12; }
.edit-banner__text { flex: 1 1 260px; line-height: 1.4; }
.edit-banner .btn { height: 32px; padding: 0 14px; font-size: 13px; }
/* ══ Onglet Résultats ══ */
#paneResultat { display: flex; flex-direction: column; gap: 14px; }
#paneResultat[hidden] { display: none; }
.res-source { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13.5px; color: var(--text); }
.res-box { display: flex; flex-direction: column; gap: 12px; }
.res-list { display: flex; flex-direction: column; gap: 6px; }
.res-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 1fr) 32px; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.res-row__name { font-size: 13.5px; font-weight: 600; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.res-row__val { height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; font-size: 13.5px; min-width: 0; }
.res-row__val:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.res-row__del { width: 30px; height: 30px; }
.res-empty { margin: 4px 2px; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.res-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.res-hint { font-size: 12px; color: var(--text-3); flex: 1 1 240px; }
/* Document imprimé « Résultats d'examens » */
.doc__results { flex: 1; margin-top: 6mm; font-size: 1.02em; }
.res-doc__ref { margin: 0 0 3mm; font-style: italic; color: #47555f; }
.res-doc__tbl { display: flex; flex-direction: column; border-top: 1px solid #c9d1d8; }
.res-doc__row { display: flex; align-items: baseline; gap: 6mm; padding: 1.8mm 1mm; border-bottom: 1px solid #dfe5ea; break-inside: avoid; }
.res-doc__name { flex: 1 1 auto; min-width: 0; }
.res-doc__val { flex: 0 0 auto; max-width: 55%; text-align: right; font-weight: 700; }
.res-doc__concl { margin-top: 5mm; line-height: 1.5; }
.doc[data-fmt="A5"] .doc__results { margin-top: 4mm; }
.doc[data-fmt="A5"] .res-doc__row { padding: 1.2mm .8mm; }
.doc[data-fmt].doc--fit-2 .res-doc__row, .doc[data-fmt].doc--fit-3 .res-doc__row { padding: .8mm .6mm; }

/* ══ Dossier : une seule case « Consultation » qui s'agrandit (pas de défilement interne) ══ */
.consult-form textarea.consult-text { min-height: 180px; overflow: hidden; resize: none; line-height: 1.55; }
/* Portables (≤ 1240 px utiles) : onglets resserrés pour tenir sur UNE ligne (6 onglets avec « Résultats ») */
@media screen and (max-width: 1240px) {
  .segment--tabs button { padding: 8px 10px; font-size: 13px; }
}
@media screen and (max-width: 1060px) {
  .segment--tabs button { padding: 7px 7px; font-size: 12.5px; }
}

/* ══ Fiche patient : décès ══ */
.deces { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px 14px; flex-wrap: wrap; }
.deces__check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; font-weight: 600; }
.deces__check input { width: 16px; height: 16px; margin: 0; accent-color: #8a2f3b; }
.deces__row { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.deces__row[hidden] { display: none; }
.deces__row .btn { height: 32px; padding: 0 12px; font-size: 13px; }
.deces.is-on .deces__check { color: #8a2f3b; }
.deces__row .docdate { width: 148px; }

/* Âge : unité ans / mois / jours (bébés) */
.age-unit { flex: none; align-self: stretch; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13px; color: var(--text-2); cursor: pointer; }
.age-unit:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ══ Dossier entièrement modifiable (06/10/2026) ══ */
.consult__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.consult__head .consult__date { margin-bottom: 0; }
.consult__head .hist-item__edit { margin-left: auto; }
.consult.is-editing { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.dossier-doc { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); padding: 10px 14px; }
.dossier-doc__body { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.consult-form__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.consult-form__title { font-size: 13.5px; font-weight: 650; color: var(--text); }
.consult-form__date { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.fiche-status { font-size: 11.5px; font-weight: 600; color: var(--accent); margin-left: 6px; opacity: 0; transition: opacity .25s; }
.fiche-status.is-on { opacity: 1; }

/* Examens ajoutés par le médecin */
.exam-group--mine .exam-group__name { color: var(--accent); }

/* ══ Ordonnances types (07/10/2026) ══ */
.edit-banner--type { border-color: var(--accent-tint-2); background: var(--accent-tint); color: var(--text); }
.edit-banner--type .ico { color: var(--accent); }
.type-banner__title { font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.type-banner__name { flex: 1 1 220px; min-width: 0; height: 34px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; font-size: 13.5px; }
.type-banner__name:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
#paneType { display: flex; flex-direction: column; gap: 12px; }
#paneType[hidden] { display: none; }
.type-hint { margin: -4px 0 0; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.type-list { display: flex; flex-direction: column; gap: 10px; }
.type-item { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-lg); background: var(--surface); padding: 12px 14px; box-shadow: var(--sh-1); }
.type-item.is-editing { box-shadow: 0 0 0 3px var(--ring); }
.type-item__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.type-item__name { font-size: 14.5px; font-weight: 650; color: var(--text); }
.type-item__n { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.type-item__lines { font-size: 13px; color: var(--text-2); line-height: 1.55; }
.type-item__line b { color: var(--text); font-weight: 600; }
.type-item__qsp { color: var(--accent); font-weight: 600; }
.type-item__acts { display: flex; align-items: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.type-item__acts .btn { height: 32px; padding: 0 12px; font-size: 13px; }
.type-item__del { color: var(--danger); }
