/* ==========================================================================
   Smart Health — modern.css
   Feuille de style autonome (aucun framework requis).
   Mode sombre : <html data-theme="dark">
   ========================================================================== */

/* ---------- 1. Variables ---------- */
:root {
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --primary-text: #ffffff;

  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;

  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;

  --sidebar-bg: #0b3b38;
  --sidebar-text: #cde7e4;
  --sidebar-active: #14b8a6;
  --sidebar-width: 256px;
  --topbar-height: 60px;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --transition: .18s ease;
}

html[data-theme="dark"] {
  --primary: #14b8a6;
  --primary-hover: #2dd4bf;
  --primary-soft: rgba(20, 184, 166, .16);
  --primary-text: #042f2e;

  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #16213a;
  --border: #23314d;
  --text: #e2e8f0;
  --text-muted: #94a3b8;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, .14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, .14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .14);

  --sidebar-bg: #070d18;
  --sidebar-text: #94a3b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { margin: 0 0 .6rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
small, .text-muted { color: var(--text-muted); }

/* ---------- 3. Mise en page ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  height: var(--topbar-height);
  padding: 0 1.25rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand .logo {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--sidebar-active);
  color: #042f2e;
  font-size: 1.1rem;
}

.sidebar-hopital {
  padding: .9rem 1.25rem;
  font-size: .85rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-hopital strong { display: block; color: #fff; font-size: .95rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0 1.5rem; }

.nav-section {
  padding: 1rem 1.25rem .35rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .6;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 2px .65rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: .93rem;
  transition: background var(--transition), color var(--transition);
}
.nav-link i { font-size: 1.1rem; width: 1.2rem; text-align: center; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: rgba(20, 184, 166, .18); color: #fff; box-shadow: inset 3px 0 0 var(--sidebar-active); }
.nav-link .badge { margin-left: auto; }

.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-titre { font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.user-chip {
  display: flex; align-items: center; gap: .55rem;
  padding: .3rem .7rem .3rem .3rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .88rem;
}
.avatar {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
}

.content { flex: 1; padding: 1.75rem 1.5rem 3rem; width: 100%; max-width: 1400px; }

.footer {
  padding: 1rem 1.5rem;
  font-size: .82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* Bouton du menu : replie le menu sur ordinateur, l'ouvre par-dessus la page sur mobile */
.sidebar-toggle { display: inline-flex; }
.sidebar-overlay { display: none; }
.main { transition: margin-left var(--transition); }
@media (min-width: 861px) {
  html.menu-replie .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform var(--transition), visibility 0s linear .18s; }
  html.menu-replie .main { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .main { transition: none; }
}

/* Page sans menu (connexion) */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 15% 20%, var(--primary-soft), transparent 40%),
    radial-gradient(circle at 85% 80%, var(--info-soft), transparent 40%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: 1.25rem; font-size: 1.35rem; font-weight: 700; color: var(--text); }
.auth-brand .logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--primary); color: var(--primary-text); font-size: 1.3rem; }

/* ---------- 4. En-tête de page ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 { margin: 0; }
.page-header p { margin: .25rem 0 0; color: var(--text-muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- 5. Cartes et grilles ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin: -1.25rem -1.25rem 1.25rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { margin: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-header { margin: 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.5rem; }
.section { margin-top: 1.75rem; }

/* Tuile de statistique */
.stat { display: flex; align-items: center; gap: 1rem; }
.stat + .stat { margin-top: 0; }
.stat-icon {
  flex: none;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.35rem;
}
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-label { display: block; font-size: .82rem; color: var(--text-muted); }
.stat strong, .stat-value { display: block; font-size: 1.55rem; font-weight: 700; line-height: 1.2; }

/* Actions rapides */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.quick-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: .5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.quick-action i { font-size: 1.4rem; color: var(--primary); }
.quick-action span { font-weight: 600; }
.quick-action small { color: var(--text-muted); }
.quick-action:hover { color: var(--text); border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ---------- 6. Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  font-size: .93rem;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-text); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); color: #fff; border-color: var(--danger); }
.btn-ghost, .btn-link { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-link { color: var(--primary); padding: .4rem .5rem; }
.btn-sm { min-height: 32px; padding: .35rem .7rem; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }

/* ---------- 7. Formulaires ---------- */
.form-group { margin-bottom: 1rem; }
label, .form-label { display: block; margin-bottom: .35rem; font-size: .88rem; font-weight: 550; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="tel"], input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="search"], select, textarea, .form-control {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus, .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-help, .helptext { display: block; margin-top: .3rem; font-size: .8rem; color: var(--text-muted); }
.errorlist { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--danger); font-size: .83rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }

/* Formulaires Django rendus avec {{ form.as_p }} */
form p { margin-bottom: 1rem; }
form p label { margin-bottom: .35rem; }

.input-icon { position: relative; }
.input-icon i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-icon input { padding-left: 2.3rem; }

/* ---------- 8. Tableaux ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 2rem 1rem !important; text-align: center; color: var(--text-muted); }

/* ---------- 9. Badges et alertes ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* Niveaux de triage des urgences */
.triage-rouge { background: #dc2626; color: #fff; border-color: transparent; }
.triage-orange { background: #ea580c; color: #fff; border-color: transparent; }
.triage-jaune { background: #facc15; color: #422006; border-color: transparent; }
.triage-vert { background: #16a34a; color: #fff; border-color: transparent; }

.alert {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--info-soft);
  color: var(--info);
  font-size: .93rem;
}
.alert i { font-size: 1.1rem; margin-top: .05rem; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info, .alert-debug { background: var(--info-soft); color: var(--info); }
.alert .alert-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; opacity: .7; }
.alert .alert-close:hover { opacity: 1; }

.banner-lecture-seule {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem 1rem;
  background: var(--warning);
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
}

/* ---------- 10. Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); }
.empty-state i { display: block; margin-bottom: .5rem; font-size: 2rem; opacity: .5; }

/* ---------- 11. Utilitaires ---------- */
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* ---------- 12. Responsive ---------- */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 35;
  }
  .main { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .content { padding: 1.25rem 1rem 2.5rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .user-chip .user-nom { display: none; }
}

/* ---------- 14. Écrans métier (patients, consultations, caisse) ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .85rem 1rem; }
.toolbar input, .toolbar select { min-height: 40px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; font-size: .88rem; }

.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-sidebar > div > .card + .card, .grid-sidebar > aside > .card + .card,
.grid-sidebar > aside > details + .card, .grid-sidebar > aside > .card + details { margin-top: 1rem; }
.grid-constantes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-montant { grid-template-columns: minmax(0, 1fr) 110px; }

.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
form > .card + .card, form > section + section { margin-top: 1rem; }

/* Bandeau du patient */
.patient-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 1.1rem; }
.patient-banner-infos { flex: 1; min-width: 240px; }
.patient-banner h1 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.patient-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; color: var(--text-muted); font-size: .9rem; }
.patient-meta i { margin-right: .25rem; }
.avatar-lg { width: 58px; height: 58px; font-size: 1.25rem; }
.page-actions form { display: inline-flex; margin: 0; }

/* Listes de définitions */
.dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: .55rem .9rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; }
.dl-large { grid-template-columns: 150px minmax(0, 1fr); }

/* Constantes */
.constantes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.constantes div { padding: .6rem .75rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.constantes span { display: block; font-size: .75rem; color: var(--text-muted); }
.constantes strong { font-size: 1.05rem; }

/* Tableaux de saisie (formsets) */
.table-form td { padding: .5rem .6rem; }
.table-form input[type="text"], .table-form input[type="number"], .table-form select { min-height: 38px; padding: .4rem .6rem; font-size: .9rem; }
.ajout-ligne { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .6rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); }
.ajout-ligne .form-group { margin: 0; }
.ligne-annulee td { color: var(--text-muted); text-decoration: line-through; }
.ligne-annulee td:last-child { text-decoration: none; }

/* Sections repliables */
details.repliable { border-top: 1px solid var(--border); }
details.repliable.card { border: 1px solid var(--border); padding: 0; }
details.repliable > summary { padding: .9rem 1.25rem; cursor: pointer; font-weight: 600; list-style: none; }
details.repliable > summary::-webkit-details-marker { display: none; }
details.repliable > summary::before { content: "\25B8"; display: inline-block; margin-right: .5rem; transition: transform var(--transition); }
details.repliable[open] > summary::before { transform: rotate(90deg); }
details.repliable > form { padding: 0 1.25rem 1.25rem; }
details.menu-inline { display: inline-block; }
details.menu-inline > summary { list-style: none; }
details.menu-inline > summary::-webkit-details-marker { display: none; }
details.menu-inline[open] > form { margin-top: .4rem; }
details.menu-inline input { min-height: 32px; padding: .3rem .5rem; font-size: .85rem; }

/* Totaux de facture */
.totaux { padding: 1rem 1.25rem; }
.ligne-total { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; font-size: .95rem; }
.ligne-total strong { font-variant-numeric: tabular-nums; }
.total-net { margin-top: .3rem; padding-top: .7rem; border-top: 1px solid var(--border); font-size: 1.1rem; }
.total-reste { font-size: 1.2rem; }
.encaissement { border-color: var(--success); }
.input-lg, .encaissement input[type="number"] { min-height: 52px; font-size: 1.35rem; font-weight: 700; }
.rendu { margin-bottom: 1rem; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); }

/* Pastilles et filtres segmentés */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { padding: .4rem .8rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .88rem; }
.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.segmented a { padding: .4rem .8rem; border-radius: 6px; color: var(--text-muted); font-size: .88rem; font-weight: 550; }
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

@media (max-width: 1100px) {
  .grid-sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .grid-constantes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl, .dl-large { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
}

/* ---------- 15. Phase 2 : urgences, laboratoire, maternité, décès ---------- */
.ligne-alerte td { background: var(--danger-soft); }
.ligne-alerte td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.ligne-anormale td { background: var(--warning-soft); }

/* Résumé et choix du triage */
.triage-resume { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
.triage-case { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: .9rem .5rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-align: center; }
.triage-case strong { font-size: 1.9rem; line-height: 1.1; }
.triage-case span { font-size: .8rem; font-weight: 600; }
.triage-choix { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.triage-option { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 56px; padding: .6rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 650; text-align: center; opacity: .55; transition: opacity var(--transition), transform var(--transition); margin: 0; }
.triage-option:hover { opacity: .85; }
.triage-option:has(input:checked) { opacity: 1; transform: scale(1.03); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px currentColor; }
.triage-option input { accent-color: currentColor; }
.patient-banner.bord-rouge { border-left: 6px solid #dc2626; }
.patient-banner.bord-orange { border-left: 6px solid #ea580c; }
.patient-banner.bord-jaune { border-left: 6px solid #facc15; }
.patient-banner.bord-vert { border-left: 6px solid #16a34a; }

.patient-choisi { display: flex; align-items: center; gap: .8rem; padding: .7rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.patient-choisi > div:nth-child(2) { flex: 1; }

/* Cases à cocher groupées (examens, prévention CPN) */
.groupe-examens { border: 0; margin: 0 0 1rem; padding: 0; }
.groupe-examens legend { margin-bottom: .5rem; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.cases { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.cases .form-group { margin-bottom: .5rem; }
.case-examen { display: inline-flex; align-items: center; gap: .5rem; padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 500; margin: 0; }
.case-examen:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.case-examen small { color: var(--text-muted); }

/* Étapes de suivi */
.suivi { list-style: none; margin: 0; padding: 0; }
.suivi li { position: relative; padding: 0 0 1rem 1.75rem; }
.suivi li::before { content: ""; position: absolute; left: 0; top: .2rem; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); }
.suivi li::after { content: ""; position: absolute; left: 6px; top: 1.1rem; bottom: 0; width: 2px; background: var(--border); }
.suivi li:last-child::after { display: none; }
.suivi li.fait::before { border-color: var(--success); background: var(--success); }
.suivi li small { display: block; color: var(--text-muted); }

/* Nouveau-nés */
fieldset.bebe { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin: 0 0 1rem; }
fieldset.bebe legend { padding: 0 .4rem; font-weight: 650; }

.grid-cause { grid-template-columns: minmax(0, 1fr) 160px; }

@media (max-width: 860px) {
  .triage-resume { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .triage-choix { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 16. Phase 3 : statistiques et épidémiologie ---------- */
.banner-alerte { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .55rem 1rem; background: var(--danger); color: #fff; font-size: .9rem; font-weight: 650; }
.banner-alerte:hover { color: #fff; filter: brightness(1.08); }
.selecteur-periode { justify-content: flex-start; }
.selecteur-periode input[type="date"] { min-height: 38px; }
.selecteur-libelle { margin-left: auto; font-size: .95rem; }
.variation { display: inline-flex; align-items: center; gap: .2rem; font-weight: 650; color: var(--text-muted); }
.variation.hausse { color: var(--info); }
.variation.baisse { color: var(--warning); }
.graphique { position: relative; width: 100%; }
.constantes-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.classement { margin: 0; padding-left: 1.4rem; }
.classement li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.classement li:last-child { border-bottom: 0; }
.journal { margin: 0; padding: .8rem; white-space: pre-wrap; font-family: inherit; font-size: .88rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 320px; overflow-y: auto; }
.chip.triage-rouge, .chip.triage-orange, .chip.triage-jaune, .chip.triage-vert { border-color: transparent; font-weight: 650; }
.table tfoot td { background: var(--surface-2); border-top: 2px solid var(--border); }
@media (max-width: 860px) {
  .constantes-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .selecteur-libelle { margin-left: 0; width: 100%; }
}

/* ---------- 17. Gestion : plan des lits, planning des gardes, comptes ---------- */
.plan-lits { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.plan-lits .card + .card { margin-top: 0; }
.lits { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.lit { display: flex; flex-direction: column; gap: .2rem; min-height: 96px; padding: .6rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface-2); font-size: .85rem; }
.lit-entete { font-weight: 650; }
.lit-patient { font-weight: 650; line-height: 1.25; }
.lit-actions { display: flex; gap: .25rem; margin-top: auto; }
.lit-actions .btn { min-height: 28px; padding: .2rem .45rem; }
.lit-libre { border-left-color: var(--success); }
.lit-occupe { border-left-color: var(--danger); background: var(--danger-soft); }
.lit-nettoyage { border-left-color: var(--warning); background: var(--warning-soft); }
.lit-hors_service { border-left-color: var(--text-muted); opacity: .75; }
.chip.lit-libre { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip.lit-occupe { color: var(--danger); border-color: transparent; }
.chip.lit-nettoyage { color: var(--warning); border-color: transparent; }

.planning { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; }
.planning .card + .card { margin-top: 0; }
.jour { padding: .75rem; min-height: 160px; }
.jour-actuel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.jour-entete { margin-bottom: .5rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.garde { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .3rem; padding: .45rem .5rem; margin-bottom: .45rem; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 3px solid var(--primary); font-size: .82rem; }
.garde > div:first-child { flex: 1 1 100%; }
.garde-nuit { border-left-color: #6366f1; }
.garde-astreinte { border-left-color: var(--warning); }
.garde-actions { display: flex; gap: .2rem; }
.garde .btn { min-height: 26px; padding: .15rem .4rem; }
code.mot-de-passe { display: inline-block; margin: .2rem 0; padding: .25rem .6rem; border-radius: 6px; background: var(--surface); color: var(--text); font-size: 1.15rem; letter-spacing: .08em; border: 1px dashed var(--warning); }

@media (max-width: 1100px) { .planning { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 700px) { .planning { grid-template-columns: 1fr; } .plan-lits { grid-template-columns: 1fr; } }
@media print { .planning { grid-template-columns: repeat(7, 1fr); } .jour { border: 1px solid #ccc; } }

/* ---------- 18. Espace plateforme (super-administrateur) ---------- */
a.card.stat { color: inherit; transition: border-color var(--transition), box-shadow var(--transition); }
a.card.stat:hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.stat small { display: block; margin-top: .15rem; }
.stat-petit { font-size: 1.05rem !important; }
.montant-devise { display: block; }
.montant-devise + .montant-devise { font-size: .8em; color: var(--text-muted); }
.champ-suffixe { display: flex; align-items: stretch; }
.champ-suffixe input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.champ-suffixe span { display: flex; align-items: center; padding: 0 .75rem; border: 1px solid var(--border); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--text-muted); font-size: .9rem; white-space: nowrap; }
.grille-formules { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; align-items: start; }
.grille-formules .card + .card { margin-top: 0; }
.formule-inactive { opacity: .7; }
.formule-prix { margin: 0 0 .75rem; font-size: 1rem; }
.formule-prix strong { font-size: 1.45rem; }
.liste-modules { list-style: none; margin: 1rem 0 0; padding: 0; font-size: .88rem; }
.liste-modules li { display: flex; align-items: center; gap: .45rem; padding: .22rem 0; }
.liste-modules .inclus i { color: var(--success); }
.liste-modules .exclu { color: var(--text-muted); }

/* ---------- 19. Signature de l'éditeur (Nami Industries) ---------- */
.footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.signature { display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--text-muted); white-space: nowrap; }
.signature strong { color: var(--text); font-weight: 650; }
.signature-logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #fff; border: 1px solid var(--border); }
.signature-logo img { width: 18px; height: 18px; object-fit: contain; }

/* ---------- 20. Pharmacie et rendez-vous ---------- */
.d-block { display: block; }
.creneaux { display: flex; flex-wrap: wrap; gap: .4rem; }
.creneaux .btn { min-width: 64px; justify-content: center; }
a.garde { color: inherit; text-decoration: none; }
a.garde:hover { box-shadow: 0 0 0 2px var(--primary-soft); }
.garde.rdv-confirme { border-left-color: var(--info); }
.garde.rdv-arrive { border-left-color: var(--primary); background: var(--primary-soft); }
.garde.rdv-termine { border-left-color: var(--success); }
.garde.rdv-absent, .garde.rdv-annule { opacity: .55; border-left-color: var(--text-muted); text-decoration: line-through; }

/* ---------- 13. Impression ---------- */
@media print {
  .sidebar, .topbar, .footer, .page-actions, .no-print, .btn { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
