@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --color-primary: #0E4B45;
  --color-primary-hover: #0c403b;
  --color-primary-dark: #0a352f;
  --color-primary-darker: #072722;
  --color-primary-bg: #e6edec;
  --color-primary-bg-soft: #f0f4f3;
  --color-accent: #C9A227;
  --color-accent-dark: #a9860f;

  --color-success: #27ae60;
  --color-success-bg: #e8f5e2;
  --color-warning: #f39c12;
  --color-warning-bg: #fff4e5;
  --color-danger: #e74c3c;
  --color-danger-bg: #fdecea;
  --color-info: #2980b9;
  --color-info-bg: #e3f0fb;

  --color-bg: #f4f6f5;
  --color-card: #ffffff;
  --color-border: #e3e8e6;
  --color-text: #1f2a28;
  --color-text-muted: #6b7975;
  --color-text-soft: #94a19e;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 2px 8px rgba(15, 40, 36, 0.06);
  --shadow-lg: 0 8px 28px rgba(15, 40, 36, 0.12);

  --sidebar-width: 240px;
  --topbar-height: 68px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

/* L'attribut [hidden] doit toujours l'emporter, même sur les éléments dont
   une classe définit display:flex/grid (.page-toolbar, .form-group, etc.). */
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }
ul { list-style: none; }

/* ---------- Layout : sidebar + topbar + contenu ---------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-card);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo { width: 34px; height: 34px; object-fit: contain; }
.sidebar-app-logo { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; border-radius: 6px; }
.sidebar-brand-divider { width: 1px; height: 26px; background: var(--color-border); flex-shrink: 0; }

.sidebar-brand-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary-darker);
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 13.5px;
  font-weight: 500;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--color-primary-bg-soft); color: var(--color-primary-dark); }
.nav-item.active { background: var(--color-primary-bg); color: var(--color-primary-dark); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 10px 18px;
  border-top: 1px solid var(--color-border);
}

.nav-logout { color: var(--color-danger); }
.nav-logout:hover { background: var(--color-danger-bg); }

.sidebar-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-soft);
  margin-top: 10px;
}
.sidebar-credit-logo { height: 40px; width: auto; object-fit: contain; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 50;
}

.mobile-toggle { display: none; font-size: 20px; color: var(--color-primary-dark); }

.topbar-title { font-size: 18px; font-weight: 600; color: var(--color-primary-darker); flex: 1; }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user-info { display: flex; flex-direction: column; align-items: flex-end; }
.topbar-user-name { font-size: 13px; font-weight: 600; }
.topbar-user-role { font-size: 11px; color: var(--color-text-soft); }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
}

.main-content {
  margin-left: var(--sidebar-width);
  padding-top: calc(var(--topbar-height) + 24px);
  padding-left: 24px;
  padding-right: 24px;
  padding-bottom: 40px;
  min-height: 100vh;
}

/* ---------- Boutons ---------- */

.btn-add, .btn-submit, .btn-save, .erp-btn {
  background: var(--color-primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.btn-add:hover, .btn-submit:hover, .btn-save:hover, .erp-btn:hover { background: var(--color-primary-hover); }
.btn-add:disabled, .btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-accent {
  background: var(--color-accent);
  color: #fff;
}
.btn-accent:hover { background: var(--color-accent-dark); }

.btn-cancel {
  background: #fff;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13.5px;
}
.btn-cancel:hover { background: #f7f8f8; }

.btn-danger { background: var(--color-danger); color: #fff; padding: 10px 18px; border-radius: var(--radius); font-weight: 600; font-size: 13.5px; }
.btn-danger:hover { background: #c0392b; }

.btn-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
}
.btn-icon:hover { background: var(--color-primary-bg-soft); color: var(--color-primary-dark); }
.btn-icon.danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }

/* ---------- En-tête de page + barre d'outils ---------- */

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 14px;
  min-width: 260px;
}
.search-box input { border: none; outline: none; flex: 1; background: transparent; }

.filter-btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}
.filter-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.filter-btn:hover:not(.active) { background: var(--color-primary-bg-soft); }

.filtre-date-input {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
}

/* ---------- Cards / dashboard ---------- */

.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-label { font-size: 12.5px; color: var(--color-text-muted); font-weight: 600; }
.stat-card-value { font-size: 26px; font-weight: 700; color: var(--color-primary-darker); }
.stat-card-icon { font-size: 20px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

/* ---------- Tables ---------- */

.erp-table-wrap {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.erp-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.erp-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  background: #f8f9fa;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.erp-table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border); font-size: 13.5px; }
.erp-table tbody tr:hover { background: var(--color-primary-bg-soft); }
.erp-table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; }
.table-empty { padding: 40px; text-align: center; color: var(--color-text-soft); }
.apercu-cell { color: var(--color-text-muted); max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); border-color: #bce2a8; }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: #fcdfa6; }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #f8b8b8; }
.badge-info { background: var(--color-info-bg); color: var(--color-info); border-color: #b8d9f2; }
.badge-neutral { background: #f0f0f0; color: #666; }

/* ---------- Formulaires ---------- */

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); }
.form-group input, .form-group select, .form-group textarea {
  border: 1px solid #d8dedc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  background: #fff;
  color: var(--color-text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.form-hint { font-size: 11.5px; color: var(--color-text-soft); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.bloc-certificat { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.mention-item { background: #fff; border: 1px solid var(--color-border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; transition: border-color .15s, background .15s; }
.mention-item:last-child { margin-bottom: 0; }
.mention-item.active { border-color: var(--color-primary); background: var(--color-primary-bg-soft); }
.mention-item .checkbox-row label { font-size: 13.5px; font-weight: 600; color: var(--color-text); }
.mention-sub { margin-top: 12px; }
fieldset:disabled { opacity: .5; }
.form-group input[readonly] { background: var(--color-bg); color: var(--color-text-muted); font-weight: 600; }

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 23, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.visible { display: flex; }

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.15s ease;
}
.modal-box.large { max-width: 780px; }

.modal-box form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-border);
}
.modal-header h2 { font-size: 16px; font-weight: 700; color: var(--color-primary-darker); }
.modal-close { font-size: 18px; color: var(--color-text-muted); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Écrans d'authentification ---------- */

.page-auth {
  background: linear-gradient(160deg, var(--color-primary-darker) 0%, var(--color-primary) 55%, var(--color-accent) 150%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-wrap { width: 100%; max-width: 420px; padding: 20px; }

.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}

.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand-logos { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 10px; }
.auth-brand-logo { width: 90px; height: auto; display: inline-block; }
.auth-brand-divider { width: 1px; height: 54px; background: var(--color-border); flex-shrink: 0; }
.auth-brand-logo-clinique { max-width: 90px; max-height: 90px; width: auto; height: auto; object-fit: contain; }
.auth-clinique-nom { font-weight: 700; font-size: 14px; color: var(--color-primary-darker); margin-top: 2px; }
.auth-subtitle { font-size: 12.5px; color: var(--color-text-soft); margin-top: 4px; }

/* Comptes de test affichés sur l'écran de connexion de la copie de DÉMO
   uniquement (voir login.html) - cliquer une ligne remplit le formulaire. */
.auth-demo-comptes {
  background: var(--color-primary-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 22px;
}
.auth-demo-titre { font-size: 11px; font-weight: 700; color: var(--color-primary-darker); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; text-align: center; }
.auth-demo-compte {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.auth-demo-compte + .auth-demo-compte { margin-top: 8px; }
.auth-demo-compte:hover { border-color: var(--color-primary); background: #fff; }
.auth-demo-compte-id strong { color: var(--color-primary-darker); }
.auth-demo-compte-role { font-size: 10.5px; color: var(--color-text-soft); background: var(--color-bg); padding: 3px 8px; border-radius: 20px; white-space: nowrap; }

.auth-form .form-group { margin-bottom: 18px; }
.auth-form .btn-submit { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

.auth-erreur {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

.auth-lien-secondaire {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  text-decoration: underline;
}

.auth-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 11.5px;
  color: var(--color-text-soft);
}
.auth-credit-logo { height: 52px; width: auto; object-fit: contain; }

/* ---------- Widget de démo (compte à rebours + guide) ---------- */
/* Injecté dynamiquement par elements/Content.js sur chaque page - voir
   Backend/server.js pour GET /api/demo-info (heure de la prochaine
   réinitialisation automatique). */
#widget-demo {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
#demo-compte-rebours strong { color: var(--color-primary-darker); }
#demo-heure-fin { color: var(--color-text-soft); }
#btn-revoir-guide {
  border: none;
  background: var(--color-primary-bg-soft);
  color: var(--color-primary-darker);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
}
#btn-revoir-guide:hover { background: var(--color-primary-bg); }
@media screen and (max-width: 480px) {
  #widget-demo { left: 12px; right: 12px; flex-direction: column; align-items: stretch; text-align: center; }
}

/* ---------- Guide interactif de démo ---------- */
.tour-demo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 23, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 20px;
}
.tour-demo-overlay[hidden] { display: none; }
.tour-demo-boite {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 28px 26px 22px;
  animation: modalIn 0.15s ease;
}
.tour-demo-progres { display: flex; justify-content: center; gap: 6px; margin-bottom: 18px; }
.tour-demo-point { width: 7px; height: 7px; border-radius: 50%; background: var(--color-border); }
.tour-demo-point.actif { background: var(--color-primary); width: 20px; border-radius: 4px; }
.tour-demo-boite h3 { font-size: 17px; color: var(--color-primary-darker); margin-bottom: 10px; text-align: center; }
.tour-demo-boite p { font-size: 13px; color: var(--color-text-muted); line-height: 1.7; text-align: center; }
.tour-demo-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 24px; }
.tour-demo-nav { display: flex; gap: 8px; }
#tour-passer {
  border: none;
  background: none;
  color: var(--color-text-soft);
  font-size: 12.5px;
  text-decoration: underline;
  cursor: pointer;
}
#tour-precedent {
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- Impression ---------- */

#zone-impression { display: none; }

/* Aperçu à l'écran avant impression : #zone-impression devient une modale
   plein écran tant que .apercu-actif est présent (voir impression.js). */
#zone-impression.apercu-actif {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 18, 0.55);
  z-index: 500;
  overflow-y: auto;
  padding: 30px 16px;
}
#zone-impression .apercu-page {
  background: #fff;
  max-width: 820px;
  margin: 0 auto 30px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
#zone-impression .apercu-barre {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 14px 24px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 2;
}
#zone-impression .apercu-titre { font-size: 13.5px; font-weight: 700; color: var(--color-primary-darker); }

@media print {
  /* Sans ça, Chrome/Edge/Firefox n'impriment pas les couleurs et dégradés de
     fond (bandeau or/olive de l'en-tête d'ordonnance, badges...) tant que
     l'utilisateur n'a pas coché manuellement "Graphiques d'arrière-plan"
     dans la boîte de dialogue d'impression - invisible pour la plupart des
     gens. Électron contourne déjà ça via printBackground:true côté natif
     (voir main.js), mais pas l'impression depuis un navigateur classique
     (accès "web" de l'appli, window.print()) : ces deux propriétés forcent
     l'impression des couleurs de fond partout, sans dépendre de ce réglage.
     Sur l'élément ET tous ses descendants (print-color-adjust ne se propage
     pas toujours de façon fiable aux enfants ayant leur propre background).
  */
  #zone-impression, #zone-impression * {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }
  /* display:none (pas juste visibility:hidden) : le reste de la page (sidebar,
     contenu principal, modales) doit être retiré du flux, sinon sa hauteur
     invisible s'ajoute quand même à la hauteur totale du document et
     Chromium ajoute une page vierge supplémentaire pour la "couvrir". */
  body > *:not(#zone-impression) { display: none !important; }
  /* Spécificité égale à #zone-impression.apercu-actif (règle définie plus
     haut) + !important : sans ça, cette dernière gagne quand même (fixed,
     inset:0, overflow:auto) et le contenu imprimé se retrouve tronqué à la
     hauteur d'une page - Chromium réimprime alors la même vue tronquée sur
     chaque page au lieu de paginer le contenu réel. */
  #zone-impression.apercu-actif {
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: none !important;
    padding: 0 !important;
  }
  #zone-impression .apercu-barre { display: none !important; }
  #zone-impression .apercu-page {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  /* Le vrai saut de page (juste en dessous) suffit à l'impression réelle -
     le séparateur visuel ajouté pour l'écran ne doit pas apparaître imprimé. */
  .piece-jointe-page {
    border-top: none !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  .piece-jointe-page::before { display: none !important; }
}

/* Pièce jointe d'un rapport imprimé (voir pages/rapports/rapports.js) :
   page-break-before force le saut de page à l'impression réelle ; à l'écran
   dans l'aperçu (simple défilement continu où cette propriété n'a aucun
   effet visible), la bordure + le repère "Nouvelle page" simulent le début
   d'une page pour que ce soit visible AVANT d'imprimer. */
.piece-jointe-page {
  page-break-before: always;
  break-before: page;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 2px dashed var(--color-border);
  position: relative;
}
.piece-jointe-page::before {
  content: 'Nouvelle page à l\'impression';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-soft);
  letter-spacing: .3px;
}

/* ---------- Odontogramme (état des dents) ---------- */
/* Disposition en arcade (SVG) : les positions/rotations sont calculées en JS
   (voir positionArche dans fiche.js): l'ellipse fixe (viewBox 460x640) garde
   les mêmes proportions à toute taille, sans logique de largeur séparée pour
   l'impression comme l'ancienne disposition en rangées droites. */

.odontogramme {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.odontogramme-svg {
  width: 100%;
  max-width: 420px;
  height: auto;
}

.arche-croix { stroke: #d5dbda; stroke-width: 1.5; }
.arche-label {
  font-size: 16px;
  font-weight: 700;
  fill: var(--color-primary-dark);
  font-family: 'Poppins', Arial, sans-serif;
}

.dent { cursor: pointer; }
.dent-numero-texte {
  font-size: 12px;
  font-weight: 700;
  fill: #555;
  font-family: 'Poppins', Arial, sans-serif;
  pointer-events: none;
}
/* Numéro d'une dent de lait (dentition mixte) : légèrement plus petit et en
   italique pour rester lisible tout en se distinguant d'une dent définitive. */
.dent-numero-lait {
  font-size: 10.5px;
  font-style: italic;
  fill: var(--color-accent);
}

.odontogramme.lecture-seule .dent { cursor: default; }

/* ---------- Recherche de patient (autocomplétion) ---------- */
/* Remplace le <datalist> natif (popup non stylé du navigateur) par un menu
   déroulant personnalisé - voir autocomplete-patient.js. */
.autocomplete-champ { position: relative; width: 100%; }
.autocomplete-champ input { width: 100%; box-sizing: border-box; }
.autocomplete-resultats {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  max-height: 260px;
  overflow-y: auto;
  z-index: 40;
  padding: 6px;
}
.autocomplete-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.autocomplete-item:hover, .autocomplete-item.active { background: var(--color-primary-bg-soft); }
.autocomplete-item-nom { font-weight: 600; font-size: 13.5px; color: var(--color-text); }
.autocomplete-item-detail { font-size: 12px; color: var(--color-text-soft); white-space: nowrap; }
.autocomplete-vide { padding: 10px; font-size: 12.5px; color: var(--color-text-soft); text-align: center; }

.legende-dents {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}
.legende-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--color-text-muted); }
.legende-pastille { display: inline-flex; width: 14px; height: 14px; flex-shrink: 0; }
.legende-pastille svg { display: block; }

/* ---------- Responsive ---------- */

@media screen and (max-width: 1024px) {
  .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media screen and (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: block; }
  .dashboard-cards { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: 1fr; }
}

@media screen and (max-width: 480px) {
  .main-content { padding-left: 14px; padding-right: 14px; }
  .topbar { padding: 0 14px; }
  .auth-card { padding: 26px 20px; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 0; }
}

/* ---------- Licence ---------- */

/* position:fixed + z-index élevé : la sidebar (z-index:100) et la topbar
   (z-index:50) sont elles-mêmes en position fixe et couvrent tout le haut de
   l'écran — une bannière en flux normal (juste ajoutée en tête de <body>)
   se retrouverait entièrement cachée derrière elles, présente dans le DOM
   mais invisible. body.a-bandeau-licence pousse sidebar/topbar/contenu vers
   le bas pour lui faire de la place au lieu de les recouvrir. */
.bandeau-licence {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #b23b3b;
  color: #fff;
  text-align: center;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
}
.bandeau-licence a { color: #fff; text-decoration: underline; margin-left: 8px; }

body.a-bandeau-licence .sidebar { top: 40px; }
body.a-bandeau-licence .topbar { top: 40px; }
body.a-bandeau-licence .main-content { padding-top: calc(var(--topbar-height) + 24px + 40px); }

/* ---------- Connexion réseau (lente/perdue) ---------- */
/* Même principe que .bandeau-licence ci-dessus (position:fixed pour passer
   au-dessus de la sidebar/topbar, qui sont elles-mêmes fixed) - voir
   api.js pour la logique. Les deux bandeaux peuvent apparaître en même
   temps (licence invalide ET connexion instable) : le sélecteur combiné
   body.a-bandeau-licence.a-bandeau-reseau gère cet empilement. */
.bandeau-reseau {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 998;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
}
.bandeau-reseau.visible { display: flex; }
.bandeau-reseau.etat-lent { background: #c98a2e; }
.bandeau-reseau.etat-perdu { background: #b93d34; }

body.a-bandeau-reseau .sidebar { top: 32px; }
body.a-bandeau-reseau .topbar { top: 32px; }
body.a-bandeau-reseau .main-content { padding-top: calc(var(--topbar-height) + 24px + 32px); }

body.a-bandeau-licence.a-bandeau-reseau .bandeau-reseau { top: 40px; }
body.a-bandeau-licence.a-bandeau-reseau .sidebar { top: 72px; }
body.a-bandeau-licence.a-bandeau-reseau .topbar { top: 72px; }
body.a-bandeau-licence.a-bandeau-reseau .main-content { padding-top: calc(var(--topbar-height) + 24px + 72px); }

.licence-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-primary-darker) 0%, var(--color-primary) 55%, var(--color-accent) 150%);
  padding: 20px;
}
.licence-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.licence-icone { font-size: 48px; margin-bottom: 12px; }
.licence-card h1 { font-size: 19px; color: var(--color-danger); margin-bottom: 10px; }
.licence-card p { font-size: 13.5px; color: var(--color-text-muted); line-height: 1.6; }
.licence-card textarea {
  width: 100%;
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #d8dedc;
  border-radius: 8px;
  font-size: 12.5px;
  font-family: monospace;
  resize: vertical;
}
