/* =========================================================================
   EMS NightShift — Mount Zonah Medical Center
   Design system : theme hopital, clair & professionnel, anime.
   ========================================================================= */

:root {
  --navy: #163a6b;
  --navy-2: #1d4e8f;
  --blue: #1f6fb2;
  --cyan: #29a8dd;
  --cyan-soft: #e6f4fb;
  --teal: #17a2a2;

  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --warn: #c77700;
  --warn-soft: #fdf3e2;
  --danger: #d0342c;
  --danger-soft: #fbe9e8;

  --bg: #f2f6fb;
  --bg-grid: #eaf1f8;
  --surface: #ffffff;
  --surface-2: #f7fafd;
  --border: #dbe6f1;
  --border-strong: #c3d4e6;

  --text: #16324f;
  --text-soft: #5b7492;
  --text-mute: #8ba0b6;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(22, 58, 107, 0.06), 0 1px 3px rgba(22, 58, 107, 0.08);
  --shadow: 0 6px 20px rgba(22, 58, 107, 0.10);
  --shadow-lg: 0 18px 50px rgba(22, 58, 107, 0.18);

  --sidebar-w: 256px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1826;
    --bg-grid: #10202f;
    --surface: #14263a;
    --surface-2: #10202f;
    --border: #22415f;
    --border-strong: #2c516f;
    --text: #e7f0fa;
    --text-soft: #a9c0d8;
    --text-mute: #7690ab;
    --cyan-soft: #10344a;
    --ok-soft: #113123;
    --warn-soft: #35270f;
    --danger-soft: #3a1613;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 55px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-grid), transparent),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ------------------------------ Animations ------------------------------ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulseHeart { 0%,100% { transform: scale(1); } 14% { transform: scale(1.18); } 28% { transform: scale(1); } 42% { transform: scale(1.12); } 70% { transform: scale(1); } }
@keyframes ecg { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: 200% 0; } }

.fade-up { animation: fadeUp .4s ease both; }

/* ------------------------------ Buttons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-2);
  color: var(--text); font-weight: 600; cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--navy-2)); color: #fff; box-shadow: 0 4px 14px rgba(31, 111, 178, .35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(31, 111, 178, .45); }
.btn-cyan { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { box-shadow: 0 6px 18px rgba(208, 52, 44, .4); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-block { width: 100%; }

/* ------------------------------ Badges ---------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border);
}
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-grade { color: #fff; border: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--cyan-soft); color: var(--blue); }

/* ------------------------------ Forms ----------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: 12px; color: var(--text-mute); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(41, 168, 221, .18);
}
textarea { resize: vertical; min-height: 74px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
input[type=color] { width: 46px; height: 40px; padding: 2px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }

/* ------------------------------ Cards ----------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

/* ============================ AUTH SCREENS ============================== */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 10% 0%, rgba(41,168,221,.12), transparent),
    radial-gradient(900px 500px at 100% 100%, rgba(22,58,107,.14), transparent),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 34px 30px;
  animation: pop .45s cubic-bezier(.2,.9,.3,1.2) both;
}
.auth-logo { display: block; width: 220px; max-width: 78%; margin: 0 auto 6px; }
.auth-sub { text-align: center; color: var(--text-soft); font-size: 13.5px; margin-bottom: 22px; }
.auth-title { text-align: center; font-size: 20px; margin-bottom: 4px; }
.ecg-line { height: 34px; margin: 4px 0 18px; display: block; width: 100%; }
.ecg-line path { fill: none; stroke: var(--cyan); stroke-width: 2.5; stroke-dasharray: 600; stroke-dashoffset: 600; animation: ecg 2.2s ease forwards .2s; }

/* password strength */
.pw-rules { list-style: none; padding: 0; margin: 8px 0 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.pw-rules li { font-size: 12px; color: var(--text-mute); display: flex; gap: 6px; align-items: center; transition: color .2s; }
.pw-rules li::before { content: "○"; font-size: 11px; }
.pw-rules li.ok { color: var(--ok); }
.pw-rules li.ok::before { content: "●"; }
.pw-meter { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 8px; }
.pw-meter > i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .3s ease, background .3s ease; }

/* ============================= APP SHELL =============================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--navy), #0f2c52);
  color: #dbe8f6; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 16px; }
.sidebar-brand img { width: 42px; height: 42px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); background: #fff; border-radius: 10px; padding: 4px; }
.sidebar-brand b { display: block; font-size: 14.5px; color: #fff; line-height: 1.15; }
.sidebar-brand span { font-size: 11px; color: #9dc3e6; letter-spacing: .05em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  border-radius: 10px; color: #cddff2; cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s, transform .1s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #fff; box-shadow: 0 6px 16px rgba(41,168,221,.35); }
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: 8px 4px; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: #7fa6cf; text-align: center; padding-top: 12px; }
/* Menu : aucun element ne doit etre ecrase (la barre de separation disparaissait),
   et le menu se resserre sur les ecrans peu hauts pour tenir sans defilement */
.sidebar { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.sidebar > * { flex-shrink: 0; }
@media (max-height: 940px) {
  .sidebar { padding: 14px 14px 12px; gap: 4px; }
  .sidebar-brand { padding: 4px 8px 10px; }
  .nav-item { padding: 8px 13px; }
  .nav-sep { margin: 6px 4px; }
  .sidebar-foot { padding-top: 8px; line-height: 1.35; }
}
@media (max-height: 800px) {
  .sidebar-brand img { width: 36px; height: 36px; }
  .nav-item { padding: 6px 13px; font-size: 13.5px; }
  .nav-sep { margin: 4px 4px; }
  .sidebar-foot { font-size: 10.5px; }
}
@media (max-height: 720px) {
  .sidebar { padding: 10px 14px 8px; gap: 2px; }
  .sidebar-brand { padding: 2px 8px 6px; }
  .sidebar-brand img { width: 32px; height: 32px; }
  .nav-item { padding: 4px 13px; font-size: 13px; }
  .nav-item svg { width: 17px; height: 17px; }
}

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--text-mute); font-size: 12.5px; }
.topbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.user-chip .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; background: linear-gradient(135deg, var(--cyan), var(--navy-2)); }
.user-chip .u-name { font-weight: 700; font-size: 13.5px; line-height: 1.1; }
.user-chip .u-role { font-size: 11.5px; color: var(--text-mute); }
.burger { display: none; }

.content { padding: 26px; animation: fadeIn .3s ease; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head .spacer { flex: 1; }

/* --------------------------- Dashboard stats ---------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  animation: fadeUp .4s ease both;
}
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%; background: var(--cyan-soft); opacity: .7; }
.stat .icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; margin-bottom: 12px; position: relative; z-index: 1; }
.stat .num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; position: relative; z-index: 1; }
.stat .lbl { color: var(--text-soft); font-size: 13px; font-weight: 600; position: relative; z-index: 1; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* ------------------------------ Tables ---------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.data th { background: var(--surface-2); color: var(--text-soft); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }
.row-click { cursor: pointer; }
.muted { color: var(--text-mute); }
.empty { text-align: center; padding: 46px 20px; color: var(--text-mute); }
.empty svg { width: 54px; height: 54px; opacity: .5; margin-bottom: 10px; }

/* ------------------------------ Toolbar --------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.search-box input { padding-left: 38px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-mute); }

/* ------------------------------ Modal ----------------------------------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,32,52,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; z-index: 100; animation: fadeIn .18s ease; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  animation: pop .28s cubic-bezier(.2,.9,.3,1.15) both; border: 1px solid var(--border);
}
.modal.lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.modal-close { margin-left: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; color: var(--text-soft); }

/* ------------------------------ Toast ----------------------------------- */
.toast-zone { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 13px 17px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  min-width: 260px; max-width: 380px; animation: fadeUp .3s ease both; font-weight: 600; font-size: 13.5px;
}
.toast .bar { width: 4px; align-self: stretch; border-radius: 4px; }
.toast.ok .bar { background: var(--ok); }
.toast.err .bar { background: var(--danger); }
.toast.info .bar { background: var(--cyan); }

/* ------------------------------ Misc ------------------------------------ */
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); margin: 8px 0 12px; font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.link-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px 12px; }
.link-box input { border: none; background: transparent; padding: 0; font-size: 13px; }
.info-banner { display: flex; gap: 10px; padding: 12px 14px; border-radius: 11px; background: var(--cyan-soft); color: var(--blue); font-size: 13px; margin-bottom: 16px; border: 1px solid rgba(41,168,221,.25); }

/* PPA form */
.ppa-section { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; background: var(--surface); }
.ppa-section > header { padding: 13px 18px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; font-weight: 700; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.ppa-section .q { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.ppa-section .q:last-child { border-bottom: none; }
.ppa-q-title { font-weight: 600; margin-bottom: 9px; font-size: 14px; }
.ppa-q-note { font-size: 12px; color: var(--warn); background: var(--warn-soft); padding: 4px 9px; border-radius: 7px; display: inline-block; margin-bottom: 8px; }
.yn { display: inline-flex; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.seg button { padding: 7px 15px; background: var(--surface); border: none; cursor: pointer; font-weight: 600; border-right: 1px solid var(--border); transition: background .12s; }
.seg button:last-child { border-right: none; }
.seg button.sel-oui { background: var(--ok); color: #fff; }
.seg button.sel-non { background: var(--text-soft); color: #fff; }
.seg button.sel-green { background: var(--ok); color: #fff; }
.seg button.sel-yellow { background: #d9b100; color: #fff; }
.seg button.sel-orange { background: var(--warn); color: #fff; }
.seg button.sel-red { background: var(--danger); color: #fff; }
.decision-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.decision-cards label { border: 2px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; text-align: center; font-weight: 700; transition: all .15s; }
.decision-cards label:hover { border-color: var(--cyan); }
.decision-cards input { display: none; }
.decision-cards input:checked + span { display: block; }
.decision-cards label.sel-apte { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.decision-cards label.sel-temp { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.decision-cards label.sel-def { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* Detail definition list */
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 22px; }
.dl > div { border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.dl dt { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.dl dd { margin: 2px 0 0; font-weight: 600; }
.hidden { display: none !important; }

/* Timeline PPA */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline .tl-item { position: relative; padding: 0 0 16px 8px; }
.timeline .tl-item::before { content: ""; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); border: 2px solid var(--surface); }

/* ---------------------------- Responsive -------------------------------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 250px; transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .burger { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row, .form-row-3, .dl { grid-template-columns: 1fr; }
  .decision-cards { grid-template-columns: 1fr; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
}
@media (min-width: 901px) { .scrim { display: none; } }

/* ------------------------------ Impression ------------------------------ */
.print-only { display: none; }
.print-header { display: none; }

/* --------------------------- Contacts multiples ------------------------- */
.contact-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }

/* ----------------------------- Ordonnances ------------------------------ */
.med-row { display: grid; grid-template-columns: 2fr 1.4fr 1.2fr auto; gap: 8px; align-items: center; }
.med-head { display: grid; grid-template-columns: 2fr 1.4fr 1.2fr auto; gap: 8px; margin-bottom: 6px; font-size: 12px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .03em; }
@media (max-width: 640px) { .med-head { display: none; } .med-row { grid-template-columns: 1fr; } }
/* Rendu PDF (dans .cert-inner) */
.ordo-meta { display: flex; justify-content: space-between; gap: 20px; margin: 16px 0; padding-bottom: 12px; border-bottom: 1px solid #ccc; }
.ordo-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #888; }
.ordo-val { font-weight: 700; color: #163a6b; font-size: 15px; }
.ordo-rx { display: flex; gap: 16px; margin: 8px 0 16px; }
.ordo-rx-symbol { font-family: Georgia, 'Times New Roman', serif; font-size: 46px; font-weight: 700; color: #163a6b; line-height: 1; }
.ordo-med { padding: 9px 0; border-bottom: 1px dashed #dcdcdc; }
.ordo-med:last-child { border-bottom: none; }
.ordo-med-nom { font-size: 15px; font-weight: 700; color: #14243a; }
.ordo-med-sub { font-size: 12.5px; color: #444; margin-top: 3px; }
.ordo-notes { margin-top: 6px; font-size: 12.5px; font-style: italic; color: #444; }

/* --------------------------- Visite medicale ---------------------------- */
.visit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 16px; }
.visit-grid .field { margin-bottom: 0; }
.field.full { grid-column: 1 / -1; }
.visit-line { font-size: 12.5px; line-height: 1.5; color: #14243a; }
.visit-cols { column-count: 2; column-gap: 26px; }
.visit-cols .visit-line { break-inside: avoid; margin-bottom: 2px; }

/* ============================== Facturation ============================== */
.inv-grid { display: flex; flex-direction: column; gap: 8px; }
.inv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: background .12s, border-color .12s; }
.inv-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.inv-row.inv-disabled { opacity: .4; pointer-events: none; text-decoration: line-through; }
.inv-lspd { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid rgba(199,119,0,.25); font-size: 13.5px; color: var(--text); cursor: pointer; }
/* Contrat Sheriff : meme regime que la LSPD (deplacements non factures + remise) */
.inv-lspd.inv-sheriff { margin-top: 8px; background: var(--warn-soft); border-color: rgba(138,109,59,.35); }
.badge-sheriff { background: var(--warn-soft); color: #8a6d3b; }
/* Reduction temporaire : grille tarifaire allegee */
.inv-lspd.inv-reduction { margin: 16px 0 6px; background: var(--cyan-soft); border-color: rgba(41,168,221,.3); }
.inv-lspd.inv-reduction.inv-disabled { opacity: .5; cursor: not-allowed; }
.badge-reduction { background: var(--cyan-soft); color: var(--blue); }
.badge.badge-reduced { background: var(--ok-soft); color: var(--ok); }
/* Bouton "avantages" du contrat : accentue quand des notes existent */
.btn-icon.has-notes { color: var(--cyan, #1f8f9c); }
.notes-view { padding: 4px 2px; font-size: 14px; color: var(--text); }
/* Accordeon des recaps contrats */
.acc-item { overflow: hidden; }
.acc-head { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 15px 18px; background: transparent; border: none; cursor: pointer; font-weight: 700; color: var(--text); font-size: 14.5px; text-align: left; }
.acc-head:hover { background: var(--surface-2); }
.acc-chev { color: var(--text-mute); transition: transform .2s ease; font-size: 13px; }
.acc-item.open .acc-chev { transform: rotate(90deg); }
.acc-body { max-height: 0; overflow: hidden; padding: 0 18px; transition: max-height .28s ease, padding .28s ease; }
.acc-item.open .acc-body { max-height: 240px; padding-bottom: 16px; }
.inv-total { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; }
.inv-total span:first-child { font-size: 15px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.inv-total span:last-child { font-size: 26px; font-weight: 800; }
.week-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* ================= PPA — questionnaire Forces de l ordre ================= */
.badge-fdo { background: var(--navy); color: #fff; white-space: nowrap; }
.fdo-intro { font-style: italic; color: var(--text-soft); }
.fdo-scenario {
  border-left: 3px solid var(--navy-2); background: var(--cyan-soft); border-radius: 0 9px 9px 0;
  padding: 10px 14px; margin-bottom: 10px; line-height: 1.55;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.fdo-scenario-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); margin-bottom: 4px; }
.fdo-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.fdo-choices .seg { display: flex; width: 100%; }
.fdo-choices .seg button { flex: 1; }
.fdo-choice-result { padding: 7px 12px; border: 1px solid var(--border); border-radius: 9px; }
.fdo-choice-result .picked { font-weight: 700; color: var(--ok); }
.fdo-answer { white-space: pre-wrap; padding: 8px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); }
.fdo-grid-row .seg { flex-wrap: wrap; }
.fdo-grid-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 4px 26px; }
.fdo-grid-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.decision-cards.fdo-avis { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 640px) { .decision-cards.fdo-avis { grid-template-columns: 1fr; } }

/* ============ Bouton d export avec menu deroulant (PDF / PNG) ============ */
.dd { position: relative; display: inline-block; }
.dd-btn .dd-caret { margin-left: 6px; font-size: 11px; opacity: .8; }
.dd-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 240px; padding: 6px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.dd.open .dd-menu { display: block; }
.dd.dd-left .dd-menu { left: 0; right: auto; }
.dd-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px;
  background: none; border: none; border-radius: 8px; cursor: pointer;
  color: var(--text); text-align: left; font: inherit;
}
.dd-item:hover { background: var(--cyan-soft); }
.dd-item b { display: block; font-size: 13.5px; }
.dd-item small { display: block; font-size: 11.5px; color: var(--text-mute); }

/* ===================== Certificat officiel (impression) ================== */
.certificate { display: none; }
.cert-inner {
  font-family: Georgia, 'Times New Roman', serif;
  color: #14243a; background: #fff; position: relative;
  border: 3px double #163a6b; padding: 11mm 16mm; min-height: 250mm;
  page-break-inside: avoid; break-inside: avoid;
}
.cert-inner::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: url(/assets/logo-mark.jpg) center 48% / 120mm no-repeat;
  opacity: 0.05; pointer-events: none;
}
.cert-inner > * { position: relative; z-index: 1; }
.cert-head { text-align: center; border-bottom: 2px solid #163a6b; padding-bottom: 10px; margin-bottom: 14px; }
.cert-head img { width: 300px; max-width: 72%; height: auto; object-fit: contain; }
.cert-dept { font-size: 11.5px; color: #555; margin-top: 4px; letter-spacing: .5px; }
.cert-title { text-align: center; font-size: 22px; color: #163a6b; margin: 6px 0 3px; letter-spacing: 2px; text-transform: uppercase; }
.cert-subtitle { text-align: center; font-size: 14px; font-style: italic; color: #444; }
.cert-ref { text-align: center; font-size: 11px; color: #777; margin: 4px 0 16px; letter-spacing: .5px; }
.cert-p { font-size: 12.5px; line-height: 1.6; text-align: justify; margin: 0 0 10px; }
.cert-patient { text-align: center; margin: 13px 0; font-size: 14px; }
.cert-patient b { display: block; font-size: 20px; color: #163a6b; letter-spacing: .5px; margin-top: 3px; }
.cert-decision { text-align: center; font-weight: 700; font-size: 18px; padding: 10px; margin: 15px auto; max-width: 82%; border: 2px solid; border-radius: 8px; letter-spacing: 1.5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cert-decision.apte { color: #1f7a4d; border-color: #1f7a4d; background: #eafaf0; }
.cert-decision.temp { color: #b06a00; border-color: #b06a00; background: #fdf3e2; }
.cert-decision.def { color: #b0241c; border-color: #b0241c; background: #fbe9e8; }
.cert-sign { display: flex; justify-content: space-between; margin-top: 26px; gap: 30px; }
.cert-sign .block { width: 46%; text-align: center; }
.cert-sign .line { border-top: 1.5px solid #14243a; margin-top: 40px; padding-top: 6px; font-size: 11.5px; color: #444; }
.cert-sign .who { font-weight: 700; color: #14243a; font-size: 13px; }
.cert-foot { margin-top: 16px; border-top: 1px solid #ccc; padding-top: 8px; font-size: 9.5px; color: #999; text-align: center; line-height: 1.5; }

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-soft: #333; --border: #bbb; }
  body { background: #fff !important; font-size: 12px; }
  .sidebar, .topbar, .scrim, .toast-zone, .modal-zone, .page-head .btn, .btn, .actions { display: none !important; }
  .shell { display: block; }
  .content { padding: 0 !important; }
  .card, .ppa-section, .table-wrap { box-shadow: none !important; border: 1px solid #999 !important; break-inside: avoid; margin-bottom: 22px !important; }
  .ppa-section > header { background: #163a6b !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #fff !important; padding: 12px 18px; }
  .ppa-section .q { padding: 15px 18px; line-height: 1.6; }
  .ppa-q-title { margin-bottom: 8px; }
  .dl { gap: 14px 24px; }
  .badge { border: 1px solid #999 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block; }
  .print-header { display: flex; align-items: center; gap: 16px; padding: 0 0 14px; margin-bottom: 16px; border-bottom: 3px solid #163a6b; }
  .print-header img { width: 64px; height: 64px; object-fit: contain; }
  .print-header h1 { font-size: 18px; color: #163a6b; margin: 0; }
  .print-header .sub { font-size: 12px; color: #555; }
  .print-sign { display: flex; justify-content: space-between; margin-top: 40px; gap: 40px; }
  .print-sign > div { flex: 1; border-top: 1px solid #333; padding-top: 6px; font-size: 11px; color: #333; }
  /* Mode certificat : on masque le questionnaire et on montre le certificat */
  body.cert-mode .page-head, body.cert-mode .print-header, body.cert-mode .print-sign,
  body.cert-mode .card, body.cert-mode .ppa-section { display: none !important; }
  body.cert-mode .certificate { display: block !important; }
  /* Visite medicale : on choisit d'imprimer soit le certificat, soit les reponses */
  body.cert-mode.show-cert .visit-answers { display: none !important; }
  body.cert-mode.show-answers .visit-cert { display: none !important; }
  .cert-inner { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 12mm; }
}

/* ============================ MUTUELLE SANTE ============================= */
.badge-muted { background: var(--surface-2); color: var(--text-mute); border: 1px solid var(--border); }
.badge-plan-essentiel { background: var(--cyan-soft); color: var(--blue); }
.badge-plan-serenite { background: rgba(123, 45, 142, .13); color: #9446ad; }
.badge-plan-plenitude { background: rgba(199, 119, 0, .14); color: #b06a00; }
.badge-plan-entreprise { background: rgba(23, 162, 162, .14); color: #138585; }
.badge.badge-mutuelle { background: rgba(123, 45, 142, .13); color: #9446ad; }

/* Nouveau contrat : choix de la formule */
.mut-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.mut-plan.mut-plan-company { border-style: dashed; }
.mut-plan-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; vertical-align: 2px; background: rgba(23, 162, 162, .14); color: #138585; }
.mut-plan {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px 14px 10px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.mut-plan:hover { border-color: var(--border-strong); }
.mut-plan.sel { border-color: var(--cyan); background: var(--cyan-soft); box-shadow: 0 0 0 3px rgba(41, 168, 221, .18); }
.mut-plan-name { font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.mut-plan-price { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.mut-plan-price small { font-size: 12px; font-weight: 600; color: var(--text-mute); }
.mut-plan-rule { font-size: 11.5px; color: #138585; font-weight: 600; margin-bottom: 4px; }
.inv-lspd.mut-launch { margin: 0 0 14px; background: var(--ok-soft); border-color: rgba(31, 157, 85, .3); }
.mut-plan-benefit { font-size: 12.5px; color: var(--text-soft); margin-bottom: 8px; }
.mut-plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; font-size: 12.5px; }
.mut-plan li.yes { color: var(--ok); font-weight: 600; }
.mut-plan li.yes::before { content: "✓ "; }
.mut-plan li.no { color: var(--text-mute); text-decoration: line-through; }
.mut-plan li.no::before { content: "✗ "; }
.mut-discord-check { font-size: 12.5px; min-height: 18px; }
.mut-ok { color: var(--ok); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.mut-err { color: var(--danger); }

/* Zone de signature */
.sig-canvas {
  display: block; width: 100%; height: auto; margin: 0 auto; cursor: crosshair;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: linear-gradient(transparent calc(100% - 34px), #dfe6ee calc(100% - 34px), #dfe6ee calc(100% - 33px), transparent calc(100% - 33px)), #fff;
}
.mut-sign-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }

/* Facturation : patient adherent */
.inv-row.inv-covered { opacity: .5; background: var(--surface-2); }
.inv-lspd.inv-mutuelle { margin-top: 8px; background: rgba(123, 45, 142, .07); border-color: rgba(123, 45, 142, .28); }
.inv-lspd.inv-mutuelle.inv-disabled { opacity: .5; cursor: not-allowed; }
.inv-mut-pick { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 6px; padding: 12px 14px; border: 1px dashed rgba(123, 45, 142, .35); border-radius: var(--radius-sm); }
.inv-mut-info { font-size: 12.5px; color: var(--text-soft); }
.inv-mut-service { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 6px; color: var(--warn); }

/* Fiche du recensement */
.mut-census { display: flex; align-items: center; gap: 10px; padding: 11px 14px; margin-bottom: 16px; border-radius: 11px; font-size: 13.5px; color: var(--text); background: rgba(123, 45, 142, .07); border: 1px solid rgba(123, 45, 142, .25); }
.mut-census svg { color: #9446ad; flex: none; }
.mut-census .badge { margin-left: auto; }

/* Page publique de signature */
.mut-sign-page {
  min-height: 100vh;
  background: radial-gradient(900px 500px at 10% 0%, rgba(41,168,221,.12), transparent),
    radial-gradient(900px 500px at 100% 100%, rgba(22,58,107,.14), transparent), var(--bg);
}
.mut-sign-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: #fff; background: linear-gradient(135deg, var(--navy), var(--navy-2)); box-shadow: var(--shadow); }
.mut-sign-head img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.mut-sign-head b { display: block; font-size: 15px; }
.mut-sign-head span { font-size: 12.5px; opacity: .85; }
.mut-sign-body { max-width: 860px; margin: 0 auto; padding: 22px 16px 60px; }
.mut-sign-card { margin-top: 16px; }
.mut-sign-msg { text-align: center; }
.mut-sign-msg-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 14px auto 4px; background: var(--cyan-soft); color: var(--blue); }
.mut-sign-msg-icon.ok { background: var(--ok-soft); color: var(--ok); }

/* Contrat d'adhesion (document officiel) : compact pour tenir sur une page A4 */
.certificate.mut-visible { display: block; max-width: 820px; margin: 0 auto 20px; }
.certificate.mut-visible .cert-inner { box-shadow: var(--shadow); }
/* Contrat entreprise : annexe (personnel couvert) sur une 2e page A4. L'ecart
   place l'annexe en haut de la 2e page dans l'export PNG. */
.mut-pages .mut-annex { margin-top: 47mm; }
.mut-members td:first-child, .mut-members th:first-child { text-align: left; }
.cert-inner.mut-doc { padding: 8mm 14mm; }
.mut-doc .cert-head { padding-bottom: 8px; margin-bottom: 8px; }
.mut-doc .cert-head img { width: 190px; }
.mut-doc .cert-ref { margin-bottom: 8px; }
.mut-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 8px; }
.mut-party { border: 1px solid #c9d6e4; border-left: 3px solid #163a6b; border-radius: 4px; padding: 5px 10px; background: rgba(22, 58, 107, .03); }
.mut-role, .mut-sign-role { font-size: 9.5px; letter-spacing: 1.2px; text-transform: uppercase; color: #6a7c90; font-weight: 700; }
.mut-name { font-size: 14px; font-weight: 700; color: #163a6b; margin: 2px 0; }
.mut-meta { font-size: 10.5px; color: #3c4c5e; line-height: 1.38; }
.mut-art { margin: 0 0 5px; }
.mut-art-title { font-size: 11.5px; font-weight: 700; color: #163a6b; letter-spacing: .3px; margin-bottom: 2px; }
.mut-p { font-size: 10.8px; line-height: 1.42; text-align: justify; margin: 0; }
.mut-cov { width: 100%; border-collapse: collapse; font-size: 10.8px; margin-top: 3px; }
.mut-cov th { text-align: center; vertical-align: middle; background: #163a6b; color: #fff; padding: 3px 6px; line-height: 1.25; font-weight: 600; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mut-cov { table-layout: fixed; }
.mut-cov td { text-align: center; padding: 4px 6px; border: 1px solid #dfe6ee; border-top: none; color: #14243a; background: transparent; }
.mut-yes { color: #1f7a4d; font-weight: 700; }
/* Bareme des majorations de retard */
.mut-late td.mut-late-label { font-weight: 700; color: #163a6b; background: rgba(22, 58, 107, .05); }
.mut-late th { font-size: 10px; }
.mut-late th.mut-late-label { width: 17%; }
.mut-late .mut-no-pay { color: #b0241c; }
.mut-no { color: #a0a9b4; }
.mut-signs { margin-top: 12px; }
.mut-signs .block { display: flex; flex-direction: column; }
.mut-signs .line { margin-top: auto; }
.mut-signs .mut-sig, .mut-signs .mut-sig-empty { margin-bottom: 2px; }
.mut-fonction { font-size: 11px; color: #555; margin-bottom: 30px; }
.mut-fonction.mut-fonction-sig { margin-bottom: 0; }
.mut-sig { display: block; height: 42px; max-width: 100%; margin: 4px auto 0; object-fit: contain; }
.mut-sig-empty { height: 42px; margin: 4px auto 0; display: grid; place-items: center; border: 1px dashed #c3cfdb; border-radius: 4px; color: #98a4b1; font-size: 10.5px; font-style: italic; }
.mut-doc .cert-foot { margin-top: 10px; }

@media screen and (max-width: 640px) {
  .mut-pages .mut-annex { margin-top: 16px; }
  .mut-plans, .mut-parties { grid-template-columns: 1fr; }
  .mut-visible .cert-inner { padding: 16px 14px; min-height: 0; }
  .mut-visible .cert-sign { flex-direction: column; gap: 16px; }
  .mut-visible .cert-sign .block { width: 100%; }
  /* Garanties en liste sur petit ecran */
  .mut-visible .mut-cov thead { display: none; }
  .mut-visible .mut-cov, .mut-visible .mut-cov tbody, .mut-visible .mut-cov tr { display: block; }
  .mut-visible .mut-cov td { display: flex; justify-content: space-between; gap: 10px; text-align: right; border-top: 1px solid #dfe6ee; }
  .mut-visible .mut-cov td::before { content: attr(data-label); font-weight: 600; color: #163a6b; text-align: left; }
  .mut-visible .mut-late td.mut-late-label { display: none; }
  .mut-sign-head { padding: 10px 14px; }
}
@media print {
  .certificate.mut-visible { box-shadow: none; margin: 0; max-width: none; }
  .certificate.mut-visible .cert-inner { box-shadow: none; }
  .mut-pages .mut-annex { margin-top: 0; break-before: page; page-break-before: always; }
  body.cert-mode .mut-screen-only { display: none !important; }
}

/* Mutuelle : sections de la liste, personnel des contrats entreprise */
.mut-list-title { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; font-weight: 700; font-size: 15px; }
.mut-member-add { display: grid; grid-template-columns: 1fr 1fr 150px 140px auto; gap: 8px; margin-top: 12px; align-items: center; }
.mut-emp-head, .mut-emp-row { display: grid; grid-template-columns: 1fr 1fr 160px 150px 42px; gap: 8px; align-items: center; }
.mut-emp-head { font-size: 12px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.mut-emp-rows { display: flex; flex-direction: column; gap: 8px; }
@media screen and (max-width: 640px) {
  .mut-emp-head { display: none; }
  .mut-emp-row, .mut-member-add { grid-template-columns: 1fr 1fr; }
  .mut-emp-row { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
  .mut-emp-row .btn-icon { grid-column: 1 / -1; justify-self: end; }
}
