:root {
  --bg: #f4f8fc;
  --surface: #ffffff;
  --border: #dde6ef;
  --text: #1a1a1a;
  --text-muted: #6b7a8c;
  --primary: #5ba8e4;
  --primary-dark: #3a8bcb;
  --primary-soft: #e4f1fb;
  --primary-softer: #f2f8fd;
  --sidebar-bg: #c9e2f6;
  --sidebar-text: #1a1a1a;
  --sidebar-muted: #3f5266;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --success: #1a7f37;
  --success-bg: #e6f4ea;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a {
  color: var(--text);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0 1.25rem 1rem;
  color: var(--text);
  text-decoration: none;
  display: block;
}
.sidebar .brand:hover {
  color: var(--primary-dark);
}
.sidebar .brand .beta-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  vertical-align: super;
  margin-left: 0.35rem;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: #7c3aed;
  color: #fff;
}

.sidebar .brand { padding-bottom: 0.35rem; }
.sidebar .sidebar-guides {
  display: block;
  margin: 0 0.75rem 0.8rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #5b21b6;
  background: rgba(124, 58, 237, 0.1);
  text-decoration: none;
}
.sidebar .sidebar-guides:hover { background: rgba(124, 58, 237, 0.18); }

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar nav a {
  color: var(--sidebar-text);
  padding: 0.6rem 1.25rem;
  margin: 0 0.5rem;
  border-radius: 6px;
  display: block;
}
.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.45);
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(58, 139, 203, 0.15);
  font-weight: 600;
}

.sidebar nav a.sidebar-back {
  color: var(--sidebar-muted);
  font-size: 0.85rem;
  padding-bottom: 0.3rem;
}
.sidebar-patient-name {
  padding: 0.3rem 1.25rem 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.3rem;
}
.sidebar nav a.sub-item {
  padding-left: 2.1rem;
  font-size: 0.85rem;
}

.sidebar .sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--sidebar-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar-user {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Language switch: plain text codes, the current one softly highlighted. */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}
.lang-option {
  background: none;
  border: none;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--sidebar-muted);
  cursor: pointer;
}
.lang-option:hover {
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.35);
}
.lang-option.active {
  color: var(--sidebar-text);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.45);
  cursor: default;
}
.lang-sep {
  color: var(--sidebar-muted);
  opacity: 0.6;
  font-size: 0.7rem;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.2rem 1.25rem;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

#view {
  padding: 1rem 1.25rem;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.patient-banner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.patient-banner-main {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.patient-banner-main strong {
  font-size: 1.05rem;
}
.patient-banner-referents {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  flex: 1;
}
.patient-banner #edit-referents-btn {
  margin-left: auto;
}

.page-header h1 {
  font-size: 1.4rem;
  margin: 0;
}

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 320px;
}

.login-card h1 {
  margin-top: 0;
  font-size: 1.3rem;
  color: var(--text);
}

/* ---------- Cards / surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ---------- Forms ---------- */

.field {
  margin-bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field textarea {
  resize: vertical;
  min-height: 70px;
}

.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.field-row > .field {
  flex: 1;
  min-width: 160px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-field label {
  font-weight: 500;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.btn:hover {
  background: var(--primary-softer);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-danger {
  background: var(--danger-bg);
  border-color: #f3b4ae;
  color: var(--danger);
}
.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}
.btn-block {
  width: 100%;
  justify-content: center;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Tables ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.range-repeat .range-repeat-until { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.8rem; }
.range-repeat .range-repeat-until[hidden] { display: none; }
.range-repeat-count { font-size: 0.85rem; margin-top: 0.2rem; }

table.data-table th.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data-table th.th-sortable:hover { color: var(--primary-dark); }
table.data-table .sort-arrow { display: inline-block; min-width: 0.9em; margin-left: 0.2em; }
table.data-table tbody tr:hover {
  background: var(--primary-softer);
}

.empty-state {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.tabs button,
.tabs a.tab-link {
  background: none;
  border: none;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tabs a.tab-link { text-decoration: none; }
.tabs button.active,
.tabs a.tab-link.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--text);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: #fff4e5; color: #92610a; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 60, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h2 {
  margin-top: 0;
  font-size: 1.1rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ---------- Toasts ---------- */

#toast-root {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  background: var(--text);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  max-width: 320px;
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }

/* ---------- Misc ---------- */

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 240px;
}

/* ---------- Agenda layout (calendar + tasks panel) ---------- */

.agenda-fit {
  display: flex;
  flex-direction: column;
  /* height is set in JS (fitAgendaHeight) to exactly fill the viewport
     below the toolbar, so the week view never needs a page scrollbar. */
}

.agenda-layout {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  min-height: 0;
}
.agenda-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.agenda-tasks-panel {
  flex-shrink: 0;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.6rem 1rem;
  margin: 0;
}
.agenda-tasks-panel .task-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  column-gap: 1.25rem;
  margin-top: 0.4rem;
}
.agenda-tasks-panel .task-item:last-child {
  border-bottom: 1px solid var(--border);
}
.task-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.task-panel-header h3 {
  margin-right: auto !important;
}

@media (max-width: 960px) {
  .agenda-fit {
    height: auto !important;
  }
  .cal-toolbar-row {
    flex-wrap: wrap;
  }
  .agenda-tasks-panel {
    max-height: 50vh;
  }
  /* height:auto above leaves the flex column no height to share out:
     flex:1 + min-height:0 (desktop rules) then collapsed the grid to its
     header row, ignoring height:70vh. Fixed size instead of flexing. */
  /* (.agenda-layout > .agenda-main: more specific than the plain
     .cal-grid-wrap rule further down, which would otherwise win.) */
  .agenda-layout {
    flex: none;
  }
  .agenda-layout > .agenda-main {
    flex: none;
    height: 70vh;
  }
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.task-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child {
  border-bottom: none;
}
.task-item-done .task-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.task-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.task-item-body {
  min-width: 0;
}
.task-item-title {
  font-size: 0.85rem;
  font-weight: 500;
}
.task-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.task-overdue {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Calendar (Agenda) ---------- */

/* Two fixed logical rows (nav/selectors, then actions) instead of one row
   that relies on flex-wrap to split itself -- nested flex-wrap made the
   wrap point unpredictable (1-3 lines depending on window width), which
   threw off fitAgendaHeight()'s height budget for the grid below it. */
.cal-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.cal-toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.4rem;
  min-width: 0;
}
.cal-range {
  font-size: 1rem;
  margin: 0 0.4rem;
  white-space: nowrap;
}
.cal-toolbar-row select {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 220px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  text-overflow: ellipsis;
}
.cal-toolbar-row .btn {
  white-space: nowrap;
  flex-shrink: 0;
}
.cal-toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.cal-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

#weekend-btn.cal-weekend-busy { border-color: #f5c98b; background: #fff3e0; color: #9a4b00; }

.cal-grid-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  min-height: 0;
}
/* #cal-grid-content (direct child, set in agenda.js) has no height of its
   own, so .cal-grid's height:100% would otherwise resolve against an
   auto-height parent (a no-op per spec) and collapse to content size. */
.cal-grid-wrap > div {
  height: 100%;
}

.cal-grid {
  display: grid;
  grid-template-columns: 50px repeat(var(--cal-n, 7), minmax(78px, 1fr));
  grid-template-rows: auto 1fr;
  min-width: 600px;
  height: 100%;
}

.cal-corner {
  grid-column: 1;
  grid-row: 1;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.cal-header-cell {
  grid-row: 1;
  text-align: center;
  padding: 0.5rem 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--primary-softer);
}
.cal-header-cell.today {
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--primary);
}
.cal-header-cell.today strong {
  color: var(--text);
}

.cal-time-col {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  border-right: 1px solid var(--border);
}
.cal-time-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.cal-days {
  grid-column: 2 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(var(--cal-n, 7), 1fr);
}

.cal-day {
  position: relative;
  border-right: 1px solid var(--border);
  /* background-size (the hour-band height, as a %) is set inline per
     column in JS, since it depends on GRID_TOTAL_HOURS. */
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-repeat: repeat-y;
  cursor: pointer;
}
.cal-day:last-child {
  border-right: none;
}
.cal-day-today {
  background-color: rgba(91, 168, 228, 0.13);
}

.cal-appt {
  position: absolute;
  left: 2px;
  right: 2px;
  min-height: 14px;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  cursor: grab;
  border-left: 3px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  touch-action: none;
  user-select: none;
}
.cal-appt-time {
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.3;
  opacity: 0.75;
}
.cal-appt-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-appt-video {
  width: 1.05em;
  height: 1.05em;
  margin-right: 0.25em;
  vertical-align: -0.15em;
  fill: currentColor;
  opacity: 0.8;
}
.cal-appt-short {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  padding-top: 1px;
  padding-bottom: 0;
}
.cal-appt-short .cal-appt-time {
  flex-shrink: 0;
}
.cal-appt-short .cal-appt-label {
  flex: 1;
  min-width: 0;
}
.cal-appt-cancelled {
  opacity: 0.5;
  text-decoration: line-through;
}
/* Vue réelle: past consultation without cotation (booked time kept). */
.cal-appt-uncoded {
  outline: 2px dashed rgb(0 0 0 / 55%);
  outline-offset: -2px;
  opacity: 0.75;
}
/* Vue réelle: the minutes coded, on the card. */
.cal-appt-mins {
  font-weight: 700;
  background: rgb(255 255 255 / 85%);
  color: #1d1d1d;
  border-radius: 3px;
  padding: 0 3px;
  white-space: nowrap;
}
.cal-appt-mins s {
  font-weight: 400;
  opacity: 0.7;
}
.cal-appt-mins-missing {
  color: #8a1c1c;
}
.cal-day-total {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #5a3d00;
}
.cal-online-hint.cal-real-hint {
  color: #5a3d00;
  background: #fff4d6;
}
.cal-appt-dragging {
  opacity: 0.85;
  cursor: grabbing;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.cal-appt-resize {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
}
.cal-appt-resize-top {
  top: 0;
}
.cal-appt-resize-bottom {
  bottom: 0;
}

.context-menu {
  position: fixed;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 0.25rem;
  min-width: 180px;
  display: flex;
  flex-direction: column;
}
.context-menu[hidden] {
  display: none;
}
.context-menu-item {
  text-align: left;
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.context-menu-item:hover {
  background: rgba(91, 168, 228, 0.08);
}
.context-menu-item.danger {
  color: var(--danger);
}
.context-menu-item.danger:hover {
  background: rgba(179, 38, 30, 0.08);
}

.cal-now-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px solid var(--danger);
  z-index: 5;
  pointer-events: none;
}
.cal-now-dot {
  position: absolute;
  left: -4px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
}

/* ---------- Paramètres > Durées par praticien ---------- */

.duration-row {
  display: grid;
  grid-template-columns: 12px 220px 90px auto;
  justify-content: start;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0;
}
.duration-row input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
}

/* ---------- Patient chart: denser layout + tasks column ---------- */

.patient-banner {
  margin-bottom: 0.75rem;
}
.patient-banner-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}
.patient-banner #edit-referents-btn {
  margin-left: 0;
}

.patient-layout {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.patient-main {
  flex: 1;
  min-width: 0;
}
.patient-aside {
  width: 270px;
  flex-shrink: 0;
  position: sticky;
  top: 0.75rem;
}

.dense .card {
  padding: 0.8rem 1rem;
  margin-bottom: 0.75rem;
}
.dense h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}
.dense .field {
  margin-bottom: 0.55rem;
  gap: 0.2rem;
}
.dense .field label {
  font-size: 0.8rem;
}
.dense .field input,
.dense .field select,
.dense .field textarea {
  padding: 0.38rem 0.55rem;
}
.dense .field-row {
  gap: 0.6rem;
}
.dense .data-table th,
.dense .data-table td {
  padding: 0.4rem 0.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 0.75rem;
  align-items: start;
}
.card-grid > .card,
.card-grid > div > .card {
  margin-bottom: 0;
}

.mt-05 { margin-top: 0.5rem; }
.nowrap { white-space: nowrap; }

.timeline-table tbody tr[data-consultation]:hover,
.timeline-table tbody tr[data-download]:hover,
.timeline-table tbody tr[data-prescription]:hover {
  background: var(--primary-softer);
}
.timeline-next {
  background: var(--success-bg);
}
/* Past consultation without a report (patients.js). */
.timeline-table tbody tr.tl-missing { background: #fdecec; }
.timeline-table tbody tr.tl-missing:hover { background: #fadada; }
.tl-missing-actions { display: inline-flex; gap: 0.35rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.timeline-table tbody tr.tl-unbilled:not(.tl-missing) { background: #fff3e0; }
.timeline-table tbody tr.tl-unbilled:not(.tl-missing):hover { background: #ffe8c7; }
.badge-unbilled { background: #fff3e0; color: #9a4b00; border: 1px solid #f5c98b; cursor: pointer; margin-left: 0.4rem; font-size: 0.75rem; vertical-align: middle; }
.btn-tardoc { background: #fff3e0; border-color: #f0a640; color: #8a4500; }
.btn-tardoc:hover { background: #ffe0b2; }
.badge-missing { background: #fdecec; color: #a12b2b; border: 1px solid #f3b9b9; cursor: pointer; margin-left: 0.4rem; font-size: 0.75rem; vertical-align: middle; }
@keyframes tl-flash { 0%, 100% { box-shadow: none; } 30%, 70% { box-shadow: inset 0 0 0 2px #d9534f; } }
.tl-flash { animation: tl-flash 1.4s ease 2; }

.patient-tasks-box.has-tasks {
  border-color: #f0c36d;
  background: #fffbf0;
}
.alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: #e8a317;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 0.4rem;
}
.task-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.plain-list li {
  padding: 0.15rem 0;
}
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--primary);
  cursor: pointer;
}

/* École / Professionnel */
.extra-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.extra-row input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.contact-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.6rem 0.5rem;
  margin-bottom: 0.5rem;
  background: var(--primary-softer);
}
.contact-extras {
  margin-bottom: 0.3rem;
}

/* Fiche praticien */
.plain-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.tag-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
}
.tag-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500 !important;
  cursor: pointer;
  background: var(--surface);
}
.tag-choice:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.tag-choice input {
  margin: 0;
}
.dense .card-grid {
  margin-bottom: 0.75rem;
}

@media (max-width: 1100px) {
  .patient-layout {
    flex-direction: column-reverse;
  }
  .patient-aside {
    width: 100%;
    position: static;
  }
}

/* ---------- Consultation window: transcription + report tabs ---------- */

.modal-box.modal-wide {
  max-width: 960px;
  width: 100%;
}
.consult-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6rem;
}
.consult-tab {
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.consult-tab.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
  margin-bottom: -1px;
}
.consult-tab:hover {
  color: var(--text);
}
.consult-add #consult-add-btn {
  font-weight: 700;
}
.consult-panel textarea {
  font-family: inherit;
  line-height: 1.45;
}
.report-text {
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--primary-softer);
  border-radius: 6px;
}
.timeline-digest td {
  background: var(--primary-softer);
}

/* ---------- Generated documents ---------- */

.form-review {
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 0.4rem;
}
.form-review-check {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  margin: 0.3rem 0;
  font-size: 0.88rem;
}
.form-fields-table td {
  vertical-align: top;
  font-size: 0.82rem;
}
.form-fields-table select,
.form-fields-table input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 5px;
}

/* ---------- Tableau de bord ---------- */

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.dash-header-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.dash-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.dash-chip:hover {
  background: var(--primary-softer);
}
.dash-chip.warn {
  background: #fff4e0;
  border-color: #f0c98a;
}
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}
.dash-col > .card {
  margin-bottom: 1rem;
}
.dash-agenda,
.dash-tasks {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}
.dash-appt {
  display: grid;
  grid-template-columns: 4px 52px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.5rem 0.45rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.dash-appt:hover {
  background: var(--primary-softer);
}
.dash-appt.past {
  opacity: 0.6;
}
.dash-appt.current {
  background: var(--primary-soft);
}
.dash-appt-bar {
  align-self: stretch;
  border-radius: 2px;
}
.dash-appt-time {
  font-size: 0.85rem;
  line-height: 1.25;
  text-align: right;
}
.dash-appt-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dash-appt-main strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-appt-main .muted {
  font-size: 0.8rem;
}
.dash-now {
  position: relative;
  border-top: 2px solid var(--danger);
  margin: 2px 0;
  height: 0;
}
.dash-now span {
  position: absolute;
  left: 0;
  top: -0.7rem;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 0 0.3rem;
  border-radius: 3px;
}
.dash-tasks li {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.dash-tasks li:last-child {
  border-bottom: none;
}
.dash-tasks input[type="checkbox"] {
  margin-top: 0.2rem;
}
.text-warning { color: #b45309; }
.text-danger {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Pagination ---------- */

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0;
  font-size: 0.85rem;
}
.pager select {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.85rem;
}

/* ---------- Mon compte: signature / tampon ---------- */

.signature-card {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  justify-content: space-between;
}
.signature-card > div:first-child {
  flex: 1;
  min-width: 0;
}
.signature-preview {
  flex-shrink: 0;
  width: 260px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  /* checkerboard: shows that the background is really transparent */
  background-color: #fff;
  background-image: linear-gradient(45deg, #eef1f4 25%, transparent 25%), linear-gradient(-45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1f4 75%), linear-gradient(-45deg, transparent 75%, #eef1f4 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.signature-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
@media (max-width: 700px) {
  .signature-card {
    flex-direction: column;
    align-items: stretch;
  }
  .signature-preview {
    width: 100%;
  }
}

/* ---------- Messagerie (Roundcube embedded) ---------- */

.mail-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.mail-views {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.mail-view-tabs {
  display: inline-flex;
  background: var(--primary-softer);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
}
.mail-view {
  border: 0;
  background: transparent;
  padding: 0.3rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.mail-view.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
}
.mail-accounts {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.mail-account-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.mail-account-tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  font-weight: 600;
}
.mail-toolbar-actions {
  display: flex;
  gap: 0.4rem;
}
.mail-frame-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.mail-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.mail-frame-wrap {
  position: relative;
}
.mail-frame.loading {
  visibility: hidden;
}
.mail-splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 1;
}
.mail-splash-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.mail-splash-icon {
  font-size: 2.4rem;
  color: var(--primary);
  animation: mail-splash-pulse 1.6s ease-in-out infinite;
}
.mail-splash-title {
  font-weight: 600;
  font-size: 1.05rem;
}
.mail-splash-bar {
  width: 180px;
  height: 4px;
  border-radius: 2px;
  background: var(--primary-soft);
  overflow: hidden;
  margin-top: 0.5rem;
}
.mail-splash-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--primary);
  animation: mail-splash-slide 1.2s ease-in-out infinite;
}
@keyframes mail-splash-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
@keyframes mail-splash-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1); }
}
.row-muted td {
  opacity: 0.55;
}
.rule-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
  margin: 0.4rem 0;
}
.rule-patient {
  margin-left: 1.5rem;
}
.rule-patient-results {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  margin-top: 0.3rem;
}
.rule-activity td {
  vertical-align: top;
}
@media (max-width: 640px) {
  .rule-options {
    grid-template-columns: 1fr;
  }
}
.mail-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.signature-preview-box {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  background: #fff;
  min-height: 2.2rem;
}
.mail-test-result {
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  background: var(--primary-softer);
  word-break: break-word;
}
.mail-test-result.ok {
  background: #e8f5e9;
  color: #1b5e20;
}
.mail-test-result.error {
  background: #fdecea;
  color: #8a1c14;
}

/* ---------- Notifications ---------- */

.bell {
  position: relative;
}
.bell-btn {
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  padding: 0.15rem 0.35rem;
  font-size: 1.05rem;
  line-height: 1;
}
.bell-count {
  position: absolute;
  top: -0.3rem;
  right: -0.35rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  min-width: 1rem;
  text-align: center;
}
.bell-count.urgent {
  background: var(--danger);
}
.bell-panel {
  position: absolute;
  right: 0;
  top: 1.9rem;
  width: 380px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 120;
  color: var(--text);
}
.bell-panel[hidden] {
  display: none;
}
.bell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.bell-list {
  overflow-y: auto;
}
.bell-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
}
.bell-item:hover {
  background: var(--primary-softer);
}
.bell-item.unread {
  background: var(--primary-soft);
}
.bell-item.urgent .bell-kind {
  color: var(--danger);
}
.bell-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.bell-body {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.bell-meta {
  font-size: 0.72rem;
}
.bell-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  align-self: flex-start;
}
.bell-title {
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.bell-title:hover {
  color: var(--primary);
  text-decoration: underline;
}
.bell-item.read .bell-text strong {
  font-weight: 500;
}
.bell-item.read {
  opacity: 0.85;
}
.bell-all-list .bell-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 65vh;
}
.bell-all-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}
.bell-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.notify-recipients {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}
.notify-recipients .check,
.notif-settings .check {
  display: block;
  padding: 0.25rem 0;
}
.inline-num {
  width: 4rem;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.banner-followup {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.followup-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  background: #e8f5e9;
}
.followup-pill.status-paused {
  background: #fff4e0;
}
.followup-pill.status-ended {
  background: #eceff1;
}
@media (max-width: 600px) {
  .bell-panel {
    width: calc(100vw - 2rem);
    right: -4rem;
  }
}

#rule-form label.check {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  margin: 0.25rem 0;
}
#rule-form label.check input {
  margin-top: 0.2rem;
}
.rule-patient[hidden] {
  display: none;
}

/* ---- Patient chart: growth curves ("Courbes") ---- */
.growth-layout { display: grid; grid-template-columns: minmax(330px, 420px) minmax(0, 1fr); gap: 12px; margin-top: 10px; align-items: start; }
@media (max-width: 1100px) { .growth-layout { grid-template-columns: 1fr; } }
.growth-side { display: flex; flex-direction: column; gap: 10px; }
.growth-side .card, .growth-main.card { margin: 0; }
.growth-layout .small { font-size: 12px; }
.growth-layout .flex-gap, .flex-between .flex-gap { display: inline-flex; gap: 6px; align-items: center; }
.growth-entry-row { display: grid; grid-template-columns: 1.35fr 1fr 1fr .8fr; gap: 6px; }
.growth-entry-row label, .growth-profile-row label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); min-width: 0; }
.growth-entry-row input, .growth-profile-row input { width: 100%; min-width: 0; padding: 5px 6px; font-size: 14px; }
.growth-bmi { display: block; padding: 6px 4px; font-size: 14px; font-weight: 600; color: var(--text); }
.growth-entry-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; min-height: 30px; }
.growth-profile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin-bottom: 6px; }
.growth-table-card { padding: 4px 6px; max-height: 420px; overflow: auto; }
.growth-table { font-size: 13px; }
.growth-table td, .growth-table th { padding: 5px 6px; white-space: nowrap; }
.growth-table tbody tr { cursor: pointer; }
.growth-table tbody tr:hover { background: var(--primary-softer); }
.growth-table tbody tr.editing { background: var(--primary-soft); }
.growth-z { display: block; font-size: 11px; color: var(--text-muted); }
.growth-z.growth-out { color: var(--danger); font-weight: 600; }
.growth-table .icon-btn { border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 15px; padding: 0 4px; border-radius: 4px; }
.growth-table .icon-btn:hover { color: var(--danger); background: var(--danger-bg); }
.growth-table .icon-btn.danger { color: #fff; background: var(--danger); font-size: 11px; padding: 2px 6px; }
.growth-toolbar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.growth-toolbar .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.growth-toolbar .seg button { border: 0; background: var(--surface); padding: 5px 14px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); }
.growth-toolbar .seg button + button { border-left: 1px solid var(--border); }
.growth-toolbar .seg button.active { background: var(--primary); color: #fff; font-weight: 600; }
.growth-chart { position: relative; }
.growth-chart svg { display: block; width: auto; max-width: 100%; height: calc(100vh - 250px); min-height: 560px; margin: 0 auto; box-shadow: 0 1px 6px rgba(0,0,0,.12); }
.growth-tip { position: absolute; z-index: 5; background: #222; color: #fff; font-size: 12px; line-height: 1.4; padding: 5px 8px; border-radius: 5px; pointer-events: none; white-space: nowrap; }
.growth-layout [hidden] { display: none !important; }
.growth-main.card { position: sticky; top: 8px; }

/* ---- Diagnoses: banner chips + Médical card ---- */
.patient-banner-dx { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding-top: 8px; margin-top: -2px; border-top: 1px solid var(--border); font-size: 0.82rem; }
.patient-banner-dx:empty { display: none; }
.dx-label { margin-right: 2px; }
.dx-empty { font-size: 0.82rem; }
.dx-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 2px 4px 2px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--primary-softer); cursor: pointer; line-height: 1.5; }
.dx-chip:hover { border-color: var(--primary); }
.dx-chip .dx-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.dx-chip.primary { background: var(--primary-soft); border-color: var(--primary); font-weight: 600; }
.dx-chip.suggested { background: #fffbea; border: 1px dashed #d4a72c; font-style: italic; font-weight: 400; }
.dx-star { color: #d4a72c; }
.dx-code { display: inline-block; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.78rem; font-style: normal; font-weight: 600; padding: 0 5px; border-radius: 4px; background: #fff; border: 1px solid var(--border); color: #2b4a66; }
.dx-code.dsm, .dx-dsm { color: #6a3fa0; }
.dx-dsm { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.74rem; font-style: normal; opacity: .85; padding-right: 4px; }
.dx-unvalidated { font-size: 0.72rem; font-style: normal; font-weight: 600; color: #8a6100; background: #fdf0c2; border-radius: 4px; padding: 0 5px; }
.dx-validate { border: 0; background: var(--success); color: #fff; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; line-height: 20px; padding: 0; cursor: pointer; flex: 0 0 auto; }
.dx-validate:hover { filter: brightness(1.15); }
#diagnoses-card .dx-head-actions { display: inline-flex; gap: .4rem; align-items: center; }
.dx-list { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dx-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.dx-row.primary { border-color: var(--primary); background: var(--primary-softer); }
.dx-row.suggested { border-style: dashed; border-color: #d4a72c; background: #fffdf3; }
.dx-row.dragging { opacity: .45; }
.dx-row.drop-before { box-shadow: 0 -3px 0 var(--primary); }
.dx-row.drop-after { box-shadow: 0 3px 0 var(--primary); }
.dx-handle { cursor: grab; color: var(--text-muted); user-select: none; padding-top: 2px; letter-spacing: -2px; }
.dx-body { flex: 1; min-width: 0; }
.dx-line1 { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.dx-line2, .dx-line3 { font-size: 0.8rem; margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dx-line3:empty { display: none; }
.dx-rank { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.dx-row.primary .dx-rank { color: var(--primary-dark); }
.dx-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.dx-icon { border: 1px solid transparent; background: none; color: var(--text-muted); cursor: pointer; border-radius: 5px; padding: 1px 6px; font-size: 14px; }
.dx-icon:hover:not(:disabled) { background: var(--primary-softer); border-color: var(--border); color: var(--text); }
.dx-icon:disabled { opacity: .3; cursor: default; }
.dx-icon.danger:hover { color: var(--danger); background: var(--danger-bg); }
.dx-icon.confirm { color: #fff; background: var(--danger); font-size: 11px; }
.dx-primary-btn { color: #c9ccd1; font-size: 16px; padding-top: 0; }
.dx-primary-btn.on { color: #d4a72c; }
.dx-link { border: 0; background: none; color: var(--primary-dark); cursor: pointer; padding: 0; font-size: 0.78rem; text-decoration: underline; }
.dx-add { margin-top: .6rem; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--primary-softer); display: flex; flex-direction: column; gap: 6px; }
.dx-add label { display: flex; flex-direction: column; gap: 3px; font-size: 0.8rem; color: var(--text-muted); }
.dx-search { position: relative; display: block; }
.dx-search input { width: 100%; }
.dx-line2 .dx-search { flex: 1; min-width: 220px; }
.dx-results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 300px; overflow: auto; }
.dx-results[hidden] { display: none; }
.dx-results li { padding: 5px 10px; cursor: pointer; font-size: 0.85rem; color: var(--text); }
.dx-results li.active, .dx-results li:hover { background: var(--primary-soft); }
.dx-picked { font-size: 0.85rem; min-height: 1.2em; }
.dx-add-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* AI draft: passages found in none of the sources, "à vérifier" */
.flag-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0 0.4rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #f0c36d;
  border-radius: 6px;
  background: #fff8e6;
  font-size: 0.8rem;
}
.flag-bar[hidden] {
  display: none;
}
.flag-title {
  color: #8a5a00;
  font-weight: 600;
  margin-right: 0.2rem;
}
.flag-chip {
  border: 1px solid #f0c36d;
  border-radius: 999px;
  background: #ffe9a8;
  padding: 0.05rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.flag-chip:hover {
  background: #ffd970;
}
.flag-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 6px;
}
.flag-wrap > textarea {
  position: relative;
  z-index: 1;
  background: transparent !important;
}
.flag-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: transparent;
  border: 1px solid transparent;
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.45;
  pointer-events: none;
}
.flag-backdrop mark {
  color: transparent;
  background: #ffe066;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #f0b400;
}

/* ---------- Patient autocomplete (appointment window) ---------- */
.patient-ac {
  position: relative;
}
.patient-ac input {
  width: 100%;
}
.patient-ac-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}
.patient-ac-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}
.patient-ac-item.active,
.patient-ac-item:hover {
  background: var(--primary-soft);
}
.patient-ac-empty {
  padding: 0.4rem 0.6rem;
}

/* The hidden attribute must win over component display rules (.field is
   display:flex, which otherwise keeps "hidden" fields on screen). */
[hidden] {
  display: none !important;
}

/* Hover preview of the quarter hour a click on the agenda will book. */
.cal-slot-hover {
  position: absolute;
  left: 2px;
  right: 2px;
  pointer-events: none;
  border-top: 2px solid var(--primary);
  background: var(--primary-soft);
  opacity: 0.85;
  font-size: 0.68rem;
  line-height: 1;
  padding: 1px 4px;
  color: var(--text);
  border-radius: 0 0 3px 3px;
  z-index: 1;
  overflow: visible;
  white-space: nowrap;
}

/* "Rendez-vous en visio" checkbox under the type select. */
.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  margin-top: 0.35rem;
  cursor: pointer;
}
.checkbox-inline input {
  width: auto;
  margin: 0;
}

/* Appointment selected by a single click (double click opens the chart). */
.cal-appt.cal-appt-selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  z-index: 3;
}

/* Two overlapping appointments of the same practitioner. Inset so the
   selection outline stays visible around it. */
.cal-appt.cal-appt-conflict {
  box-shadow: inset 0 0 0 2px var(--danger), 0 1px 2px rgba(0, 0, 0, 0.12);
  border-left-color: var(--danger);
}

/* Sidebar: practitioner's own space (title + indented items), then tools. */
.sidebar-group-title {
  padding: 0.5rem 1.25rem 0.25rem;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Facturation: relevé des prestations TARDOC, factures XML. */
.billing-help { font-size: 0.82rem; margin-top: 0.8rem; line-height: 1.45; }
.billing-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.2rem; }
.billing-mode label { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; font-weight: normal; }
.billing-mode.to-patient { background: #fff3e0; border-color: #f5c98b; }
.billing-practitioners { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; }
.billing-check { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: normal; cursor: pointer; white-space: nowrap; }
.billing-filters .btn-link { background: none; border: 0; padding: 0; color: var(--primary, #2563eb); cursor: pointer; font-size: 0.8rem; font-weight: normal; }
.billing-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.6rem; }
.billing-filters .field-row { flex-wrap: wrap; }
.billing-summary { align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.billing-warning { background: #fdecec; border: 1px solid #f3b4b4; color: #8a1f1f; padding: 0.4rem 0.6rem; border-radius: 6px; }
.billing-table td { vertical-align: top; }
.billing-table tr.billing-group td { border-top: 2px solid var(--border); }
.billing-table tr.billing-missing { background: #fdecec; }
.billing-label { font-size: 0.8rem; max-width: 22rem; }
.tardoc-defaults h4 { margin: 0.8rem 0 0.3rem; font-size: 0.85rem; color: var(--muted, #666); }
.tardoc-default-row { display: grid; grid-template-columns: 1fr 5.5rem 4.5rem; gap: 0.5rem; align-items: center; padding: 0.15rem 0; font-size: 0.88rem; }
.tardoc-default-row input { width: 100%; }

/* Admins only: the practice's administration, set apart at the bottom. */
.sidebar-admin {
  margin: 0.9rem 0.6rem 0;
  padding: 0.2rem 0 0.4rem;
  border-top: 2px solid var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.35);
  border-radius: 0 0 6px 6px;
}
.sidebar-admin .sidebar-group-title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
}
.sidebar-formation a.sidebar-group-title { display: block; text-decoration: none; padding: 0.4rem 0.75rem; }
.sidebar-formation a.sidebar-group-title.active,
.sidebar-formation a.sidebar-group-title:hover { color: var(--primary-dark); }
.sidebar-separator {
  border-top: 1px solid var(--border);
  margin: 0.6rem 1rem;
}

/* Global patient search in the topbar. */
.patient-search {
  position: relative;
  width: min(340px, 45vw);
}
.patient-search input {
  width: 100%;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg, #fff);
}
.patient-search .patient-ac-list {
  z-index: 50;
}

/* Tabs of a chart section, across the top of the main window. */
.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.chart-tab {
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: -1px;
}
.chart-tab:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--primary-softer);
}
.chart-tab.active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  border-color: var(--border);
}

/* Notification box: "re-scan now" buttons. */
.bell-scan {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.bell-scan .btn {
  font-size: 0.78rem;
}

/* Chart timeline: "+" unfolds a row's content in place. */
.timeline-table .tl-toggle {
  width: 1.8rem;
  padding-right: 0;
}
.tl-expand {
  width: 1.4rem;
  height: 1.4rem;
  line-height: 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.tl-expand:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.timeline-table tr.tl-detail td {
  background: var(--bg, #f7f8fa);
  cursor: default;
}
.tl-detail-block + .tl-detail-block {
  margin-top: 0.75rem;
}
.tl-detail-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.tl-detail-text {
  white-space: pre-wrap;
  font-size: 0.85rem;
  line-height: 1.45;
  max-height: 28rem;
  overflow: auto;
}

/* Document viewer (PDF / images / text), above any open window. */
.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vh 2vw;
}
.viewer-box {
  background: var(--surface);
  border-radius: 8px;
  width: min(1100px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.viewer-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.viewer-actions {
  display: flex;
  gap: 0.4rem;
  flex: none;
}
.viewer-content {
  flex: 1;
  min-height: 0;
  background: var(--bg);
}
.viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.viewer-image {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-image img {
  max-width: 100%;
  max-height: 100%;
  cursor: zoom-in;
}
.viewer-image img.zoomed {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.viewer-text {
  margin: 0;
  padding: 1rem;
  height: 100%;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.85rem;
}

/* Prescription editor */
.rx-modal.modal-box {
  width: min(980px, 96vw);
  max-width: none;
}
.rx-head {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.rx-head .rx-template-field {
  margin-left: auto;
}
.rx-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
}
.rx-item-head {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.rx-item-head .rx-search-wrap,
.rx-item-head .rx-label {
  flex: 1;
  min-width: 0;
}
.rx-item-head .rx-drug,
.rx-item-head .rx-label {
  width: 100%;
  font-weight: 600;
}
.rx-search-wrap {
  position: relative;
}
.rx-results {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 320px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.rx-result {
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.rx-result:hover,
.rx-result.active {
  background: var(--bg);
}
.rx-result.rx-narcotic {
  opacity: 0.75;
  cursor: not-allowed;
}
.rx-narcotic-note {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.78rem;
}
.rx-result-empty {
  padding: 0.5rem 0.6rem;
}
/* Drug interactions (EPha grades X / D / C / B, duplicates) */
.rx-alerts-box { margin: 0.5rem 0; padding: 0.5rem 0.6rem; border: 1px solid var(--border, #d8dee6); border-radius: 6px; font-size: 0.85rem; }
.rx-alerts-title { font-weight: 600; margin-bottom: 0.3rem; }
.rx-alert { border-left: 4px solid #9aa5b1; padding: 0.25rem 0.5rem; margin: 0.25rem 0; border-radius: 3px; background: var(--bg); }
.rx-alert summary { cursor: pointer; }
.rx-alert p { margin: 0.3rem 0 0.1rem; font-size: 0.8rem; }
.rx-alert-grade { display: inline-block; min-width: 6.5rem; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; }
.rx-alert-info { color: var(--text-muted); }
.rx-alert-X { border-left-color: var(--danger); background: var(--danger-bg); }
.rx-alert-X .rx-alert-grade { color: var(--danger); }
.rx-alert-D { border-left-color: #d9480f; background: #fff1e6; }
.rx-alert-D .rx-alert-grade { color: #c2410c; }
.rx-alert-C { border-left-color: #e0a800; background: #fff8e1; }
.rx-alert-C .rx-alert-grade { color: #92610a; }
.rx-alert-B .rx-alert-grade, .rx-alert-DUP .rx-alert-grade { color: var(--text-muted); }
.rx-alert-ok { color: var(--success); }
.rx-alert-note { font-size: 0.75rem; margin-top: 0.25rem; }
.rx-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
  margin-top: 0.4rem;
}
.rx-grid .field {
  flex: 1 1 10rem;
  margin: 0;
}
.rx-grid .rx-narrow {
  flex: 0 1 7rem;
}
.rx-grid .rx-prn-text {
  flex: 1 1 16rem;
}
.rx-poso {
  margin-top: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  border-radius: 6px;
}
.rx-mode {
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
}
.rx-steps {
  width: 100%;
  border-collapse: collapse;
  margin: 0.35rem 0;
}
.rx-steps th {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-muted, #667);
  padding: 0 0.25rem;
}
.rx-steps td {
  padding: 0.15rem 0.25rem;
}
.rx-steps input {
  width: 100%;
  min-width: 3rem;
}
.rx-steps .rx-days {
  max-width: 6rem;
}
.rx-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.rx-time {
  display: inline-flex;
  gap: 0.2rem;
}
.rx-time input[type="time"] {
  width: 6.5rem;
}
.rx-time input:not([type]) {
  width: 5rem;
}
.rx-item > .rx-instructions {
  width: 100%;
  margin-top: 0.4rem;
}
.rx-save-template {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}
.rx-save-template[hidden] {
  display: none;
}
.rx-lines {
  font-size: 0.8rem;
  font-style: italic;
}

/* Emails in the chart timeline */
.badge.badge-email {
  background: #e3effa;
  color: #1d5a8c;
}
.email-meta {
  font-size: 0.85rem;
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.email-body {
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.45;
  max-height: 60vh;
  overflow: auto;
}
.rx-duration-input {
  display: inline-flex;
  gap: 0.25rem;
  width: 100%;
}
.rx-duration-input input {
  width: 4.5rem;
  min-width: 3.5rem;
  flex: none;
}
.rx-duration-input select {
  flex: 1;
  min-width: 5.5rem;
}
.rx-grid .rx-duration-field {
  flex: 0 1 13rem;
}
.rx-steps td.rx-step-duration {
  width: 12rem;
}


/* Exam results (labs.js) */
.labs-table .labs-date {
  border: 1px solid transparent;
  background: transparent;
  padding: 0.1rem 0.2rem;
  font: inherit;
}
.labs-table .labs-date:hover,
.labs-table .labs-date:focus {
  border-color: var(--border);
}
.badge.labs-kind-lab { background: #e6f2ea; color: #23633a; }
.badge.labs-kind-ecg { background: #fbe9e9; color: #8a2b2b; }
.badge.labs-kind-imaging { background: #ece8f7; color: #4b3a8a; }
.labs-values {
  border-collapse: collapse;
  font-size: 0.84rem;
  margin-top: 0.4rem;
}
.labs-values td {
  padding: 0.12rem 0.75rem 0.12rem 0;
}
.labs-val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
tr.labs-out .labs-val,
tr.labs-out td:first-child {
  color: var(--danger);
}
.labs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.labs-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
}
.labs-chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.labs-chip.active .muted {
  color: rgba(255, 255, 255, 0.85);
}
.labs-count {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 0.15rem;
}
.labs-chart-title {
  margin-bottom: 0.25rem;
}
.labs-chart {
  width: 100%;
  max-width: 760px;
  height: auto;
  display: block;
}
.labs-band { fill: rgba(46, 160, 67, 0.12); }
.labs-grid { stroke: var(--border); stroke-width: 1; }
.labs-axis { font-size: 11px; fill: #7a8794; }
.labs-line { fill: none; stroke: var(--primary); stroke-width: 2; }
.labs-point { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.labs-point.out { stroke: var(--danger); fill: var(--danger); }
.labs-series {
  max-width: 520px;
  margin-top: 0.75rem;
}

.labs-filename {
  font-size: 0.75rem;
}

/* Cotation TARDOC (tardoc.js) */
.tardoc-box {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.tardoc-acts {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0;
  font-size: 0.85rem;
}
.tardoc-acts td {
  padding: 0.2rem 0.4rem 0.2rem 0;
  border-bottom: 1px solid var(--border);
}
.tardoc-add {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.4rem;
}
.tardoc-add .tardoc-entry {
  flex: 1;
  min-width: 0;
}
.tardoc-minutes {
  width: 15rem;
  flex: none;
}
.tardoc-minutes input {
  width: 6rem;
}
.tardoc-limit {
  font-size: 0.75rem;
  margin-top: 0.15rem;
  line-height: 1.3;
}
.tardoc-limit.tardoc-over {
  color: var(--danger);
  font-weight: 600;
}
.tardoc-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  font-size: 0.8rem;
}
.tardoc-meta input,
.tardoc-meta select {
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
}
.tardoc-note {
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

.pmail-ph {
  cursor: pointer;
  border: none;
  margin: 0.1rem 0;
  font-family: inherit;
}

/* Atelier IA */
.ailab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .ailab-grid { grid-template-columns: 1fr; }
}
.ailab-col textarea {
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
}
.ailab-params {
  align-items: flex-end;
}
.ailab-output {
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.45;
}
.ailab-warning {
  color: var(--danger);
  font-weight: 600;
}
.ailab-cmp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ---------- Heidi guide (scribe.js) ---------- */

.scribe-guide {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 1500;
  width: min(380px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.85rem;
}
.scribe-guide-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: var(--primary-softer); border-bottom: 1px solid var(--border); }
.scribe-guide-body { padding: 0.5rem 0.75rem 0.75rem; }
.scribe-guide ol { margin: 0.25rem 0 0.5rem; padding-left: 1.3rem; }
.scribe-guide li { margin: 0.35rem 0; cursor: pointer; line-height: 1.4; }
.scribe-guide li.done { color: var(--text-muted); text-decoration: line-through; }
.scribe-guide li.done::marker { content: "✓ "; }
.scribe-guide-copy { margin: 0 0 0.25rem; color: var(--success); }
.scribe-guide-copy.error { color: var(--danger); }
.scribe-guide-pill { display: none; }
.scribe-guide.collapsed { width: auto; border: none; box-shadow: none; background: none; overflow: visible; }
.scribe-guide.collapsed .scribe-guide-head,
.scribe-guide.collapsed .scribe-guide-body { display: none; }
.scribe-guide.collapsed .scribe-guide-pill { display: inline-block; padding: 0.45rem 0.9rem; border: none; border-radius: 999px; background: var(--primary); color: #fff; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }
@keyframes scribe-flash { 0%, 100% { box-shadow: none; } 30%, 70% { box-shadow: 0 0 0 4px var(--primary); } }
.scribe-flash { animation: scribe-flash 1.6s ease 2; }

/* ---------- Genogram (genogram.js, pages/genogram.js) ---------- */

/* Synthèse: the genogram framed in the diagnoses card, sized to its own
   shape (renderGenogramThumb), the diagnoses flowing around it. */
.medical-top { display: flow-root; }
.medical-top > #genogram-thumb { float: right; max-width: 50%; margin: 0 0 0.6rem 1rem; }
.medical-top > #genogram-thumb:empty { display: none; }
.genogram-thumb {
  display: flex; flex-direction: column; gap: 0.25rem; width: 100%; margin: 0;
  padding: 0.4rem; cursor: zoom-in; text-align: left; font: inherit; color: inherit; box-shadow: none;
}
.genogram-thumb:hover { border-color: var(--primary); }
.genogram-thumb-title { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.genogram-thumb .genogram-svg { width: 100%; height: 150px; flex: none; }
@media (max-width: 700px) {
  .medical-top > #genogram-thumb { float: none; max-width: none; width: auto !important; margin: 0 0 0.6rem; }
}
.modal-box.modal-genogram { max-width: min(1400px, 96vw); }
.genogram-large { height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.genogram-large .genogram-svg { width: 100%; height: 100%; }

.genogram-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.genogram-toolbar .flex-gap { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.genogram-help { font-size: 0.8rem; margin: 0.3rem 0 0.5rem; }
.genogram-editor { display: flex; gap: 0.75rem; align-items: flex-start; }
.genogram-canvas { position: relative; flex: 1; min-width: 0; padding: 0; overflow: hidden; background: #fff; }
.genogram-canvas svg { display: block; width: 100%; height: 68vh; min-height: 420px; touch-action: none; cursor: grab; user-select: none; }
.genogram-canvas svg.linking { cursor: crosshair; }
.genogram-linking { position: absolute; top: 0.5rem; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 0.8rem; pointer-events: none; }
.genogram-panel { width: 320px; flex: 0 0 320px; max-height: 68vh; overflow: auto; margin: 0; }
.genogram-panel h4 { margin: 0 0 0.5rem; }
.genogram-panel .flex-gap { display: flex; gap: 0.4rem; }
.gg-checks { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.85rem; margin: 0.25rem 0 0.5rem; }
.gg-checks label { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: normal; }
.gg-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.gg-error { color: var(--danger); font-size: 0.8rem; }
@media (max-width: 900px) {
  .genogram-editor { flex-direction: column; }
  .genogram-panel { width: 100%; flex: none; max-height: none; }
}

.genogram-svg, #gg-svg { font-family: inherit; }
.gg-person { cursor: move; }
.gg-selected { fill: #e3f2fd; stroke: #64b5f6; stroke-width: 1.5; }
.gg-age { font-size: 12px; font-weight: 700; fill: #222; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
/* White halo: the couple / child lines pass behind the texts. */
.gg-years, .gg-name, .gg-note, .gg-union-label, .gg-household-label { paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.gg-years { font-size: 10px; fill: #555; }
.gg-name { font-size: 12px; font-weight: 600; fill: #222; }
.gg-note { font-size: 10px; fill: #555; }
.gg-union-label { font-size: 10px; fill: #444; }
.gg-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.gg-union, .gg-relation { cursor: pointer; }
.gg-household path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gg-household-fill { stroke-opacity: 0.1; }
.gg-household-outline { stroke-opacity: 0.85; }
.gg-household-label { font-size: 11px; font-weight: 600; font-style: italic; }
.gg-household-row { display: flex; align-items: center; gap: 0.4rem; }
.gg-household-row input[type=text] { flex: 1; min-width: 0; padding: 0.15rem 0.35rem; font-size: 0.85rem; }
.gg-household-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; }
.gg-legend { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1.2rem; font-size: 0.8rem; }
.gg-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.gg-sample { flex: none; }
.gg-warnings { white-space: pre-wrap; font-size: 0.75rem; background: var(--bg); padding: 0.5rem; border-radius: 6px; max-height: 160px; overflow: auto; }

/* Suivi des bilans: checks and alerts in the patient banner. */
.patient-banner-checks { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.patient-banner-checks:empty { display: none; }
.check-chip { border: 1px solid var(--border, #d0d7de); background: #f6f8fa; border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.8rem; cursor: pointer; }
.check-chip.none { background: #fff; }
.check-chip.pending { background: #eef4ff; border-color: #b6ccf5; }
.check-chip.ok { background: #e8f6ec; border-color: #a7d8b5; }
.check-chip.bad { background: #fdecea; border-color: #f1aaa3; color: #8a1c13; }
.check-chip.due { box-shadow: 0 0 0 2px #f5c98b inset; }
.check-chip.alert { background: #fff3e0; border-color: #f0b35b; color: #8a4b00; font-weight: 600; }
.check-chip .check-why { font-weight: normal; opacity: 0.8; margin-left: 0.25rem; }
.monitoring-rules input, .monitoring-rules select { min-width: 0; width: 100%; }
.monitoring-rules td:nth-child(1) { min-width: 12rem; }
.monitoring-rules td:nth-child(3) { min-width: 12rem; }
.monitoring-rules td:nth-child(2) { min-width: 8.5rem; }
.monitoring-rules td:nth-child(4) { min-width: 11rem; }
.monitoring-rules td:nth-child(5) { width: 5.5rem; }
.monitoring-rules td:nth-child(1) input { min-width: 12rem; }
.totp-qr svg { width: 240px; height: 240px; background: #fff; }

/* Aide */
.sidebar-help { color: inherit; text-decoration: none; flex-shrink: 0; font-weight: 600; }
.sidebar-help:hover { text-decoration: underline; }
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 800px) { .help-layout { grid-template-columns: 1fr; } }
.help-nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.75rem; }
.help-nav a { padding: 0.35rem 0.5rem; border-radius: 6px; color: inherit; text-decoration: none; }
.help-nav a:hover { background: #f1f4f8; }
.help-nav a.active { background: #e7effa; font-weight: 600; }
.help-section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; margin: 0.4rem 0.5rem 0.2rem; }
.help-article { line-height: 1.55; max-width: 900px; }
.help-article h2 { margin-top: 0; }
.help-article h3 { margin-top: 1.4rem; }
.help-article code { background: #f3f4f6; padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.88em; word-break: break-all; }
.help-article li { margin: 0.25rem 0; }
.help-note { background: #eef4ff; border: 1px solid #c9dafb; border-radius: 8px; padding: 0.7rem 0.9rem; margin: 0.8rem 0; }

/* Portail serveur */
.portal-lock-card { max-width: 460px; }
.portal-session { display: inline-flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.portal-bar { display: block; height: 6px; background: #e5e7eb; border-radius: 3px; margin-top: 0.3rem; overflow: hidden; }
.portal-bar span { display: block; height: 100%; background: #3b82f6; }
.portal-db { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .portal-db { grid-template-columns: 1fr; } }
.portal-db-tables { display: flex; flex-direction: column; max-height: 75vh; overflow: auto; padding: 0.5rem; font-size: 0.85rem; }
.portal-db-tables a { padding: 0.25rem 0.4rem; border-radius: 5px; color: inherit; text-decoration: none; display: flex; justify-content: space-between; gap: 0.5rem; }
.portal-db-tables a:hover { background: #f1f4f8; }
.portal-db-tables a.active { background: #e7effa; font-weight: 600; }
.portal-grid td { font-size: 0.8rem; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-grid th { font-size: 0.75rem; white-space: nowrap; }
.portal-editable { cursor: cell; }
.portal-editable:hover { background: #fff8e1; }
.portal-logs { background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; max-height: 60vh; overflow: auto; font-size: 0.75rem; white-space: pre-wrap; word-break: break-all; }
.help-search { margin-bottom: 1rem; max-width: 640px; }
.help-search input { width: 100%; padding: 0.55rem 0.8rem; font-size: 1rem; border-radius: 8px; }
.help-results { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.help-hit { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.45rem 0.6rem; border-radius: 6px; color: inherit; text-decoration: none; }
.help-hit:hover { background: #f1f4f8; }
.help-hit span { font-size: 0.85rem; color: #4b5563; }
.help-results mark, .help-article mark.help-mark { background: #fde68a; padding: 0 0.1rem; border-radius: 2px; }

/* ---------- Fiche patient > App patient (Carnet) ---------- */
.carnet-tab { display: flex; flex-direction: column; gap: 1rem; }
.carnet-tab h3 { margin: 0 0 0.6rem; }
.carnet-tab h4 { margin: 0.9rem 0 0.4rem; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.carnet-cols { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .carnet-cols { grid-template-columns: 1fr; } }
.carnet-small { font-size: 0.8rem; }
.carnet-tab .mono, .carnet-code-big { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.06em; }
.carnet-tab .btn-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }
.carnet-devices { margin: 0.3rem 0; padding-left: 1.1rem; }
.carnet-tool { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.45rem 0.6rem; margin-bottom: 0.35rem; }
.carnet-tool.on { border-color: var(--primary); background: var(--primary-softer); }
.carnet-tool-head { display: flex; gap: 0.5rem; align-items: flex-start; cursor: pointer; }
.carnet-tool-head input { margin-top: 0.2rem; }
.carnet-tool-head .badge { margin-left: 0.3rem; }
.carnet-tool-opts { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.4rem 0 0.1rem 1.6rem; }
.carnet-tool-opts textarea { width: 100%; }
.carnet-opt { display: flex; gap: 0.4rem; align-items: center; font-size: 0.85rem; }
.carnet-data-tabs { margin-bottom: 0.6rem; flex-wrap: wrap; }
.carnet-data-tabs button { background: none; border: 0; cursor: pointer; }
.carnet-tab tr.clickable { cursor: pointer; }
.carnet-tab tr.carnet-flag td { background: var(--danger-bg); }
.carnet-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.8rem; margin: 0; }
.carnet-detail dt { color: var(--text-muted); }
.carnet-detail dd { margin: 0; white-space: pre-line; }
.carnet-tab .table-scroll { overflow-x: auto; }
.carnet-grid th:first-child { text-align: left; white-space: nowrap; }
.carnet-grid tbody th { text-transform: none; letter-spacing: 0; font-size: 0.85rem; font-weight: 500; color: var(--text); }
.carnet-grid td { text-align: center; min-width: 3.2rem; }
.carnet-heat { background: rgb(44 116 176 / calc(var(--a) * 0.85)); color: var(--text); }
.carnet-heat.strong { color: #fff; }
.carnet-yes { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.carnet-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; margin: 0.5rem 0; }
.carnet-stats > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.7rem; display: flex; flex-direction: column; }
.carnet-stats small, .carnet-stats span { color: var(--text-muted); font-size: 0.78rem; }
.carnet-stats strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.carnet-chart { margin: 0.5rem 0 0.8rem; }
.carnet-qr svg { width: 220px; height: 220px; display: block; margin: 0 auto; }
.carnet-code-big { text-align: center; font-size: 1.8rem; font-weight: 600; margin: 0.4rem 0; }
.carnet-steps { padding-left: 1.2rem; }
.seg-group { display: inline-flex; gap: 0.25rem; }

/* Line chart shared with the patient app (static/carnet/chart.js) */
.lc { position: relative; }
.lc svg { display: block; }
.lc-grid { stroke: #e6edf4; stroke-width: 1; }
.lc-axis { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.lc-line { fill: none; stroke: #2c74b0; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lc-dot, .lc-hot { fill: #2c74b0; stroke: var(--surface); stroke-width: 2; }
.lc-cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.lc-tip { position: absolute; pointer-events: none; white-space: nowrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.25rem 0.5rem; font-size: 0.8rem; box-shadow: 0 2px 8px rgb(0 0 0 / 12%); display: flex; flex-direction: column; }
.lc-tip span { color: var(--text-muted); }

/* ---------- Mot de passe ---------- */
.login-forgot { display: block; margin: 0.75rem auto 0; background: none; border: 0; color: var(--text-muted); text-decoration: underline; cursor: pointer; font-size: 0.85rem; }
.login-note { background: var(--primary-softer); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.75rem; font-size: 0.88rem; }
.password-form { max-width: 360px; }
.pwlink { display: flex; gap: 0.5rem; margin: 0.5rem 0; }
.pwlink input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }

/* ---------- Journal des accès ---------- */
.audit-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.audit-filters select, .audit-filters input { min-width: 12rem; }
.audit-path { font-size: 0.75rem; font-family: ui-monospace, Consolas, monospace; max-width: 22rem; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.audit-modal { max-height: 60vh; overflow: auto; }
.badge.audit-delete { background: var(--danger-bg); color: var(--danger); }
.badge.audit-create, .badge.audit-update { background: var(--primary-soft); color: var(--primary-dark); }
.badge.audit-download, .badge.audit-export { background: #fff4e5; color: #92610a; }

/* ---------- Agenda: ranges open to online booking ---------- */
.cal-online {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 0;
  pointer-events: none;
  /* Discreet: a faint tint with fine hatching, a thin green edge. */
  background: repeating-linear-gradient(135deg, rgb(26 127 55 / 7%) 0 1px, transparent 1px 9px), rgb(26 127 55 / 3%);
  border-left: 2px solid rgb(26 127 55 / 35%);
}
.cal-online span {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.62rem;
  color: #1a6b32;
  opacity: 0.6;
}
.cal-range-mode .cal-online {
  pointer-events: auto;
  cursor: pointer;
  outline: 1px dashed rgb(26 127 55 / 70%);
}
.cal-range-mode .cal-online:hover {
  background: repeating-linear-gradient(135deg, rgb(26 127 55 / 14%) 0 1px, transparent 1px 9px), rgb(26 127 55 / 8%);
}
.cal-range-mode .cal-appt { opacity: 0.55; }
.cal-dot-online {
  background: repeating-linear-gradient(135deg, rgb(26 127 55 / 30%) 0 1px, transparent 1px 3px), rgb(26 127 55 / 6%);
  border: 1px solid rgb(26 127 55 / 40%);
}
.cal-online-hint {
  font-size: 0.8rem;
  color: #1a6b32;
  background: #e6f4ea;
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  margin: 0 0 0.4rem;
}
.cal-day-site {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}
.cal-appt-online {
  width: 1em;
  height: 1em;
  margin-right: 0.2em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.8;
}
.range-row { display: flex; gap: 0.75rem; }
.presence-table { max-width: 760px; }
.presence-table th { width: 7rem; text-align: left; vertical-align: top; padding-top: 0.6rem; }
.presence-table td { display: flex; gap: 0.6rem; align-items: flex-start; flex-wrap: wrap; }
.presence-segs { display: flex; flex-direction: column; gap: 0.35rem; min-width: 24rem; }
.presence-seg { display: flex; gap: 0.4rem; align-items: center; }
.presence-seg select { min-width: 10rem; }
.range-row .field { flex: 1; }

/* Tableau de bord > Consultations à documenter: report state above the TARDOC badge */
.dash-undoc-state { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.dash-undoc-state .badge-unbilled { margin-left: 0; }
.dash-undoc-state > * { white-space: nowrap; }

/* ---------- Équipe > fiche de la structure ---------- */
.structure-sheet form { display: flex; flex-direction: column; gap: 0.9rem; }
.structure-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.9rem 0.8rem; margin: 0; }
.structure-section legend { font-weight: 600; padding: 0 0.35rem; color: var(--primary-dark); }
.structure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.2rem 0.9rem; }
.structure-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.35rem 0.9rem; }
.structure-module { display: flex; align-items: center; gap: 0.45rem; font-weight: 400; }
.structure-grid .field { margin-bottom: 0.4rem; }
.structure-grid .field-wide { grid-column: 1 / -1; }
.structure-grid textarea { width: 100%; resize: vertical; }
.structure-grid small { display: block; margin-top: 0.15rem; font-size: 0.75rem; }
.structure-hint { font-size: 0.8rem; margin: 0.2rem 0 0; }
.structure-logo-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.structure-letterhead { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.structure-preview-wrap { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; }
.structure-preview { aspect-ratio: 210 / 297; background: #fff; border: 1px solid var(--border); box-shadow: 0 2px 10px rgb(0 0 0 / 8%);
  padding: 7% 8%; display: flex; flex-direction: column; font-size: 0.62rem; color: #222; line-height: 1.35; }
.sp-head { display: flex; justify-content: space-between; gap: 0.6rem; }
.sp-left, .sp-right { display: flex; flex-direction: column; }
.sp-right { align-items: flex-end; text-align: right; }
.sp-head img { max-height: 2.2rem; max-width: 7rem; object-fit: contain; margin-bottom: 0.35rem; }
.sp-body { flex: 1; margin: 1.2rem 0; background: repeating-linear-gradient(#f1f3f6 0 0.35rem, transparent 0.35rem 0.9rem); opacity: 0.8; }
.sp-footer { display: flex; flex-direction: column; align-items: center; color: #777; font-size: 0.55rem; }
.structure-actions { display: flex; gap: 0.5rem; }
.structure-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.3rem 1.2rem; margin-top: 0.6rem; font-size: 0.88rem; }
@media (max-width: 900px) {
  .structure-grid, .structure-letterhead { grid-template-columns: 1fr; }
}

/* Notifications > courriers classés automatiquement */
.bell-scan { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.filed-table td { vertical-align: top; }
.filed-redirect-row td { background: var(--primary-softer); }
.filed-redirect-row input { width: 100%; max-width: 22rem; }
.filed-results { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }

/* Mes patients: follow-up filters and status, list going on */
.my-patients-filters { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; margin-bottom: 0.6rem; }
.followup-select { font-size: 0.82rem; padding: 0.15rem 0.3rem; border-radius: 6px; border: 1px solid var(--border); }
.followup-select.fu-active { background: var(--success-bg); color: var(--success); }
.followup-select.fu-paused { background: #fff4e5; color: #92610a; }
.followup-select.fu-ended { background: #eef1f4; color: var(--text-muted); }
.pager-more { display: block; width: 100%; margin: 0.5rem 0 0.3rem; padding: 0.55rem; border: 1px dashed var(--primary); border-radius: var(--radius);
  background: var(--primary-softer); color: var(--primary-dark); font-weight: 600; cursor: pointer; }
.pager-more:hover { background: var(--primary-soft); }

/* Fiche patient > note: type (list or typed freely) */
.note-type-field select, .note-type-field input { min-width: 14rem; }
.note-type-field input { margin-top: 0.3rem; display: block; }
.note-type-field input[hidden] { display: none; }
.note-type-edit { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 1rem; flex-wrap: wrap; }
.note-type-edit input { margin-top: 0; }
.note-types-text { width: 100%; max-width: 32rem; font-family: inherit; }

/* Fiche patient > note: date editable for a note of its own */
.note-date-edit { display: inline-flex; align-items: center; gap: 0.4rem; }
.note-date-edit input { font-size: 0.85rem; padding: 0.15rem 0.35rem; }

/* ---------- Formation (internes, cours, thèses, publications) ---------- */
.formation-count { display: inline-block; min-width: 1.4em; padding: 0 0.35em; margin-left: 0.25em; border-radius: 999px; background: var(--border); font-size: 0.75rem; text-align: center; }
.formation-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.8rem; margin-bottom: 0.8rem; }
.formation-stats .card { display: flex; flex-direction: column; gap: 0.2rem; margin: 0; }
.formation-stats strong { font-size: 1.6rem; color: var(--primary-dark); }
.formation-stats span { font-size: 0.85rem; color: var(--text-muted); }
.formation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.formation-card { margin: 0; }
.formation-list { list-style: none; padding: 0; margin: 0.6rem 0 0.3rem; }
.formation-list li { padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 0.9rem; }
.formation-list li:hover { background: var(--bg, #f6f8fb); }
.formation-toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.formation-toolbar input[type=search] { min-width: 14rem; }
.formation-table tbody tr { cursor: pointer; }
.formation-sub { font-size: 0.8rem; margin-top: 0.1rem; }
.formation-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.1rem 0.9rem; }
.formation-fields .field-wide { grid-column: 1 / -1; }
.formation-fields textarea, .formation-fields input, .formation-fields select { width: 100%; }
.formation-attendees { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; max-height: 9rem; overflow-y: auto; padding: 0.3rem 0; }
.formation-attendees input { width: auto; }
.formation-followed { font-size: 0.85rem; background: var(--bg, #f6f8fb); border-radius: var(--radius); padding: 0.5rem 0.8rem; margin: 0.4rem 0; }
.formation-followed ul { margin: 0.2rem 0 0.5rem; padding-left: 1.2rem; }
.formation-table tr.formation-group th { cursor: default; text-align: left; background: var(--bg, #f6f8fb); font-size: 0.9rem; padding-top: 0.6rem; }
.formation-hint { font-size: 0.85rem; margin: 0.2rem 0 0.6rem; }
.formation-biblio { width: 100%; font-family: inherit; }
@media (max-width: 900px) {
  .formation-grid, .formation-fields { grid-template-columns: 1fr; }
}

/* Formation > fichiers (supports, fiches, bibliothèque) */
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0 0.3rem; font-size: 0.85rem; }
.btn-link:hover { text-decoration: underline; }
.formation-files.over { outline: 2px dashed var(--primary); outline-offset: -6px; }
.formation-drop-hint { font-size: 0.82rem; margin: 0 0 0.6rem; }
.formation-theme { margin: 0.4rem 0 0.9rem; }
.formation-theme summary { cursor: pointer; padding: 0.35rem 0.2rem; border-bottom: 2px solid var(--border); list-style-position: inside; }
.formation-theme summary .btn-link { margin-left: 0.6rem; }
.formation-icon { font-size: 1.05rem; }
.ml-cover { width: 28px; height: 40px; object-fit: cover; border-radius: 3px; vertical-align: middle; margin-right: 0.4rem; }
.ml-row { cursor: pointer; }
.formation-drop { display: flex; align-items: center; justify-content: center; min-height: 6rem; border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer; text-align: center; padding: 1rem; margin-bottom: 0.6rem; }
.formation-drop.over, .formation-drop:hover { border-color: var(--primary); color: var(--primary-dark); }
.formation-picked { list-style: none; padding: 0; margin: 0 0 0.6rem; max-height: 12rem; overflow-y: auto; font-size: 0.88rem; }
.formation-picked li { padding: 0.15rem 0; }
.formation-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 0.4rem 0; flex-basis: 100%; }
.formation-progress[hidden] { display: none; }
.formation-progress div { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }
.formation-file-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.formation-file-actions label.btn { margin: 0; }
.formation-fileinfo { font-size: 0.82rem; margin: 0.2rem 0 0.4rem; }

/* Aide : textes à copier tels quels (modèles Heidi) */
.help-article pre.help-template { white-space: pre-wrap; font-size: 0.8rem; background: var(--bg, #f6f8fb); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.7rem 0.9rem; max-height: 22rem; overflow-y: auto; margin: 0.3rem 0 0.4rem; }
.help-article .help-copy { margin-top: 0.2rem; }

/* Dossier médical > synthèse lue mise en forme */
.summary-view { font-size: 0.92rem; line-height: 1.45; max-height: 32rem; overflow-y: auto; padding-right: 0.3rem; cursor: text; }
.summary-view h4 { margin: 0.9rem 0 0.25rem; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary-dark); border-bottom: 1px solid var(--border); padding-bottom: 0.15rem; }
.summary-view h4:first-child { margin-top: 0; }
.summary-view p { margin: 0.2rem 0; }
.summary-view ul, .summary-view ol { margin: 0.2rem 0 0.4rem; padding-left: 1.3rem; }
.summary-view li { margin: 0.1rem 0; }

/* Génogramme : proposition de l'IA locale */
.gg-ai-bar { margin: 0.4rem 0; }
.gg-ai-bar:empty { display: none; }
.gg-ai-msg { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.88rem; padding: 0.45rem 0.7rem;
  border-radius: var(--radius); background: #eef4fb; color: var(--primary-dark); }
.gg-ai-done { background: #e8f5e9; color: #1b5e20; }
.gg-ai-error { background: #fdecec; color: #a12b2b; }

/* Nouvelle version déployée pendant que la page est ouverte */
.version-banner { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; gap: 0.8rem; align-items: center;
  background: #1f2937; color: #fff; padding: 0.55rem 0.9rem; border-radius: 999px; box-shadow: 0 6px 20px rgb(0 0 0 / 25%); font-size: 0.9rem; }

/* Génogramme : foyers dans le panneau */
.gg-household-list { display: flex; flex-direction: column; gap: 0.2rem; }
.gg-household-link { display: inline-flex; align-items: center; gap: 0.4rem; text-align: left; }
.gg-household-members { max-height: 14rem; overflow-y: auto; }
.gg-household path.gg-household-fill { cursor: pointer; }

/* Dossier > Exporter > compte rendu de suivi */
.followup-form textarea { width: 100%; }
.followup-tools { margin: 0.2rem 0 0.4rem; }
.followup-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.2rem 1rem; }

/* ---- Plan de soins (pages/careplan.js) and its library (pages/careplan-library.js) ---- */
.cp-head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.cp-suggest { margin-top: .6rem; }
.cp-suggest-label { font-size: .85rem; margin-bottom: .35rem; }
.cp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-chip { font-size: .85rem; }
.cp-chip:hover { border-color: var(--primary); background: var(--primary-softer); }
.cp-problem-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.cp-problem-title { margin: 0; cursor: text; }
.cp-sub { font-size: .82rem; }
.cp-resolved { opacity: .7; }
.cp-progress { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-muted); }
.cp-progress-bar { display: inline-block; width: 80px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.cp-progress-bar > span { display: block; height: 100%; background: var(--success); }
.cp-group { margin-top: .8rem; }
.cp-group-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: .25rem; }
.cp-item { display: flex; align-items: flex-start; gap: 8px; padding: 5px 6px; border-radius: 6px; }
.cp-item:hover { background: var(--primary-softer); }
.cp-item > input[type=checkbox] { margin-top: 3px; flex: 0 0 auto; }
.cp-bullet { width: 13px; text-align: center; color: var(--text-muted); flex: 0 0 auto; }
.cp-item-body { flex: 1; min-width: 0; }
.cp-text { cursor: text; }
.cp-done .cp-text { text-decoration: line-through; color: var(--text-muted); }
.cp-num { font-weight: 600; color: var(--text-muted); }
.cp-custom { font-size: .75rem; }
.cp-note { font-size: .82rem; color: var(--text-muted); font-style: italic; cursor: text; margin-top: 2px; }
.cp-hw { font-size: .8rem; margin-top: 2px; }
.cp-item-actions { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.cp-date { font-size: .8rem; padding: 1px 4px; }
.cp-date.cp-late { border-color: var(--danger); color: var(--danger); }
.cp-lang { font-size: .8rem; padding: 1px 4px; }
.cp-picker { display: flex; flex-direction: column; gap: .6rem; }
.cp-picker-list, .cl-results { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.cp-picker-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; background: none; text-align: left; cursor: pointer; color: inherit; text-decoration: none; font: inherit; }
.cp-picker-row:hover { border-color: var(--border); background: var(--primary-softer); }
.cp-free-problem { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: .6rem; }
.cp-free-problem input { flex: 1; min-width: 12rem; }
.cp-picker details { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.cp-picker summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.cp-pick-line { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; cursor: pointer; }
.cp-pick-line input { margin-top: 3px; }
.cp-pick-line.cp-have { color: var(--text-muted); }
.cp-pick-objective { border-top: 1px dashed var(--border); padding: 4px 0; }
.cp-pick-ints { margin-left: 1.6rem; font-size: .88rem; }
.cp-free label { display: block; margin-bottom: .6rem; }
.cp-free textarea, .cp-free select { width: 100%; }
.cl-books td { vertical-align: top; }
.cl-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.cl-warn { white-space: pre-wrap; font-size: .78rem; max-height: 12rem; overflow: auto; }
.cl-book-head { margin: .8rem 0 .2rem; color: var(--text-muted); }
.cl-line { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--border); }
.cl-line-body { flex: 1; }
.cl-fr { color: var(--primary-dark); margin-top: 2px; }
.cl-langs { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-search-row { display: flex; gap: 6px; width: 100%; }
.cp-search-row input { flex: 1; min-width: 0; }
.cp-picker > input[type=search] { width: 100%; }
.banner-age { font-weight: 500; color: var(--text-muted); margin-left: .35rem; }
.banner-measures { flex-basis: 100%; font-size: .82rem; margin-top: -0.35rem; }
.dx-open-dsm { cursor: pointer; }
.dx-open-dsm:hover { color: var(--primary); text-decoration: underline; }
.dx-dsm-manual { margin-top: .5rem; }
.dx-dsm-manual .dx-search, .dx-dsm-manual input { width: 100%; }

/* ---------- Équipe (team.js): structures bar, members, antennes, shares ---------- */

.team-structures { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 0.8rem; }
.team-structure-pill { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 0.35rem 0.9rem; font: inherit; font-weight: 500; cursor: pointer; }
.team-structure-pill:hover { border-color: var(--primary); }
.team-structure-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.team-structure-pill.inactive { opacity: 0.6; text-decoration: line-through; }
.team-header { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.team-header > div:first-child { flex: 1; min-width: 220px; }
.team-header h2 { margin: 0 0 0.2rem; font-size: 1.2rem; }
.team-header-stats { display: flex; gap: 1.2rem; color: var(--text-muted); }
.team-header-stats strong { color: var(--text); font-size: 1.1rem; }
.team-toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.8rem; }
.team-toolbar .search-input { min-width: 220px; flex: 0 1 300px; }
.team-toolbar select { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.team-toolbar-spacer { flex: 1; }
.team-sub { font-size: 0.82rem; }
.team-members td { vertical-align: top; }
.team-sites-cell { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.team-site-chip { display: inline-block; background: var(--primary-softer); border: 1px solid var(--primary-soft); border-radius: 6px; padding: 0.15rem 0.5rem; font-size: 0.82rem; white-space: nowrap; }
.team-site-chip.inactive { opacity: 0.55; }
.team-candidate { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.team-member-form { display: flex; flex-direction: column; gap: 0.9rem; }
.team-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 1rem 0.9rem; margin: 0; }
.team-section legend { font-weight: 600; padding: 0 0.3rem; }
.team-section .checkbox-inline { margin-right: 1rem; }
.team-inline-actions { display: flex; gap: 0.5rem; margin-top: 0.7rem; flex-wrap: wrap; }
.team-days { border-collapse: collapse; width: 100%; }
.team-days th, .team-days td { padding: 0.35rem 0.4rem; text-align: center; border-bottom: 1px solid var(--border); }
.team-days tbody th { text-align: left; font-weight: 500; }
.team-days input[type="checkbox"] { width: 1.05rem; height: 1.05rem; cursor: pointer; }
.team-share-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.35rem 0; }
.team-share-row select { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; }
.team-modal-actions { align-items: center; }
.team-planning-wrap { overflow-x: auto; }
.team-planning th, .team-planning td { vertical-align: top; min-width: 110px; }
.team-person { display: block; background: var(--primary-softer); border-left: 3px solid var(--primary); border-radius: 4px; padding: 0.15rem 0.4rem; margin-bottom: 0.25rem; font-size: 0.82rem; }
.team-site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.8rem; margin-top: 0.8rem; }
.team-site-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem; display: flex; flex-direction: column; gap: 0.2rem; }
.team-site-card.inactive { opacity: 0.6; }
.team-share-add { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.team-share-add h4 { margin: 0 0 0.6rem; }
[data-scope] { padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; }

/* Genogram picture export (copy / PNG) */
.gg-export-preview { border: 1px solid var(--border, #ccd3dc); border-radius: 6px; background: #fff; padding: 0.5rem; max-height: 60vh; overflow: auto; text-align: center; }
.gg-export-preview img { max-width: 100%; height: auto; }

/* Documents attached to a chart note */
.note-att { border: 1px dashed var(--border); border-radius: 6px; padding: 0.5rem 0.7rem; margin-bottom: 0.6rem; }
.note-att-over .note-att { border-color: var(--primary, #1e88e5); background: rgba(30, 136, 229, 0.06); }
.note-att-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.note-att-tools { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.note-att-tools select { min-width: 0; max-width: 16rem; }
.note-att-list { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.note-att-list li { display: flex; gap: 0.5rem; align-items: center; padding: 0.15rem 0; }
.note-att-empty { margin: 0.3rem 0 0; font-size: 0.82rem; }
.note-att-links { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin: 0.3rem 0 0.5rem; }

/* Therapy prescriptions: top bar chip, chart panel */
.therapy-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.therapy-chip.warn {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}
.therapy-panel .bell-item {
  align-items: center;
  cursor: pointer;
}
.therapy-balances {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.therapy-balance {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Time clock (side bar) */
.timeclock {
  margin: 0.6rem 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.timeclock-btn {
  width: 100%;
}
.timeclock-since {
  font-size: 0.8rem;
  opacity: 0.8;
}
.timeclock-totals {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  background: none;
  border: none;
  color: inherit;
  font-size: 0.8rem;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.table-scroll {
  overflow-x: auto;
}

/* Chat, directory, referrals */
.nav-count {
  display: inline-block;
  margin-left: 0.4rem;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
.nav-count[hidden] {
  display: none;
}
.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 1rem;
  align-items: start;
}
.chat-list {
  display: flex;
  flex-direction: column;
  padding: 0.25rem;
  max-height: 70vh;
  overflow-y: auto;
}
.chat-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem;
  color: inherit;
  cursor: pointer;
}
.chat-item:hover,
.chat-item.active {
  background: var(--bg);
}
.chat-item.unread .chat-item-title {
  font-weight: 700;
}
.chat-item-title {
  flex: 1;
}
.chat-item-last {
  flex-basis: 100%;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread {
  display: flex;
  flex-direction: column;
  height: 70vh;
  padding: 0;
}
.chat-thread-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.chat-back {
  display: none;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-msg {
  max-width: 75%;
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.45rem 0.7rem;
}
.chat-msg.mine {
  align-self: flex-end;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.chat-msg.mine .link-btn {
  color: #fff;
}
.chat-msg-who {
  font-size: 0.75rem;
  font-weight: 600;
}
.chat-msg-body {
  white-space: normal;
  word-wrap: break-word;
}
.chat-msg-time {
  font-size: 0.7rem;
  opacity: 0.7;
  text-align: right;
}
.chat-compose {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem;
  border-top: 1px solid var(--border);
}
.chat-compose textarea {
  flex: 1;
  resize: vertical;
}
.chat-pick-list {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.referral-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
}
@media (max-width: 800px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-layout.has-thread .chat-list {
    display: none;
  }
  .chat-layout:not(.has-thread) .chat-thread {
    display: none;
  }
  .chat-back {
    display: inline-block;
  }
  .chat-msg {
    max-width: 90%;
  }
}

/* Appointment guests */
.cal-appt-invited {
  opacity: 0.85;
  border: 2px dashed var(--text) !important;
}
.cal-appt-invited-pending {
  background: repeating-linear-gradient(135deg, #c9c9c9, #c9c9c9 6px, #dcdcdc 6px, #dcdcdc 12px) !important;
  color: #333 !important;
}
.invitee-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}
.invitee-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.85rem;
}
.invitee-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

/* Sign-in approved on the trusted phone: the number to tap there. */
.login-number { font-size: 3rem; font-weight: 700; text-align: center; letter-spacing: 0.1em; color: var(--primary, #2563eb); min-height: 3.6rem; }
.devices-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.devices-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.45rem 0; border-top: 1px solid var(--border, #e5e7eb); }

/* A notice in a tab (e.g. a recurring slot to renew). */
.alert { padding: 0.65rem 0.9rem; border-radius: 8px; margin-bottom: 0.75rem; border: 1px solid transparent; }
.alert-warning { background: #fff4e5; border-color: #f0c27a; color: #7a4b00; }

/* Which occurrences of a recurring series (agenda: change / delete). */
.series-scope { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.series-scope-card { background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 1rem 1.2rem; width: min(22rem, 92%); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12); display: flex; flex-direction: column; gap: 0.5rem; }
.series-scope-card h3 { margin: 0 0 0.3rem; }

/* Modèles de documents (Paramètres) */
.ttpl-list { display: flex; flex-direction: column; }
.ttpl-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.55rem 0.2rem; border-bottom: 1px solid var(--border); }
.ttpl-item:last-child { border-bottom: none; }
.ttpl-main { flex: 1; min-width: 0; cursor: pointer; }
.ttpl-excerpt { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttpl-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.ttpl-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.ttpl-chip { border: 1px solid var(--border); background: var(--primary-softer); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.8rem; cursor: pointer; color: var(--text); }
.ttpl-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.ttpl-form textarea { font-family: inherit; }

/* Agenda: a second agenda laid over (Superposer) -- its busy times hatched */
.cal-overlay-busy {
  position: absolute; left: 0; right: 0; z-index: 0;
  background: repeating-linear-gradient(135deg, rgba(142, 68, 173, 0.20) 0 6px, rgba(142, 68, 173, 0.06) 6px 12px);
  border-left: 3px solid rgba(142, 68, 173, 0.7);
  border-radius: 3px; overflow: hidden;
}
.cal-overlay-busy span { position: absolute; right: 4px; top: 1px; font-size: 0.68rem; color: #6c3483; white-space: nowrap; }
#overlay-select.cal-overlay-on { border-color: rgba(142, 68, 173, 0.8); background: rgba(142, 68, 173, 0.08); }

/* Patient lists: structure / antenne filters */
.patient-place-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.patient-place-filters select { max-width: 16rem; }
.share-list { display: flex; flex-direction: column; gap: 0.15rem; max-height: 50vh; overflow-y: auto; margin-bottom: 0.5rem; }
.share-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0; }
/* While an agenda is laid over, the displayed one's blocks leave a strip on
   the right: the other's busy times stay visible beside them. */
.cal-with-overlay .cal-appt { max-width: 76%; }

/* MediData (Administration) */
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.md-stats { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.8rem 0 0.4rem; }
.md-stat { flex: 1 1 8rem; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; padding: 0.55rem 0.7rem; display: flex; flex-direction: column; }
.md-stat strong { font-size: 1.3rem; }
.md-stat span { font-size: 0.8rem; color: var(--text-muted, #6b7280); }
.md-stat-warn { border-color: #f0c27a; background: #fff8ec; }
.md-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.md-filters .search-input:first-child { flex: 1 1 16rem; }
.md-run { margin-top: 1rem; border-top: 1px solid var(--border, #e5e7eb); padding-top: 0.8rem; }
.md-log { white-space: pre-wrap; font-size: 0.8rem; background: var(--surface-2, #f8fafc); padding: 0.6rem; border-radius: 6px; max-height: 20rem; overflow: auto; }
.md-settings summary { cursor: pointer; }

/* Ninja signed in as another account (impersonate.js). */
.imp-banner { position: sticky; top: 0; z-index: 9500; display: flex; gap: 1rem; align-items: center; justify-content: center;
  padding: 0.4rem 1rem; background: #111827; color: #fff; font-size: 0.9rem; }
.imp-banner .btn { background: #fff; color: #111827; }

/* Chart header: prescriptions box under the buttons (therapy.js). */
.patient-banner-side { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.patient-banner-side .patient-banner-actions { margin-left: 0; }
.banner-rx { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; padding: 0.35rem 0.6rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg, #f8fafc); font-size: 0.85rem; min-width: 16rem; }
.banner-rx:empty { display: none; }
.banner-rx-line { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.banner-rx .btn { margin-top: 0.15rem; }
/* The prescription window: large preview of the scan beside the fields. */
.modal-box.modal-wide { width: min(1300px, 96vw); max-width: 96vw; }
.rx-modal { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1rem; }
.rx-preview { height: 75vh; border: 1px solid var(--border); border-radius: 6px; background: #525659; overflow: auto;
  display: flex; align-items: flex-start; justify-content: center; }
.rx-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.rx-preview img { max-width: 100%; height: auto; background: #fff; }
.rx-preview-empty { margin: auto; color: #e5e7eb; padding: 2rem; text-align: center; }
.rx-fields .field input, .rx-fields .field select { width: 100%; }
@media (max-width: 900px) { .rx-modal { grid-template-columns: 1fr; } .rx-preview { height: 50vh; } }
.banner-rx-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
/* Result said in consultation, no exam document seen (monitoring.js). */
.check-chip.declared { background: #f3effa; border-color: #c9b8e8; color: #4c3a75; border-style: dashed; }
.check-chip.is-declared { text-align: center; line-height: 1.15; }
.check-chip .check-declared { display: block; font-size: 0.72rem; font-style: italic; opacity: 0.85; }
.type-dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; vertical-align: middle; }

/* First connection: the 2FA set up after the link's password. */
.enroll-steps { padding-left: 1.2rem; font-size: 0.9rem; margin: 0.4rem 0; }
.enroll-steps li { margin-bottom: 0.3rem; }
.enroll-qr { display: flex; justify-content: center; margin: 0.4rem 0; }
.enroll-qr svg { width: 180px; height: 180px; background: #fff; padding: 6px; border-radius: 6px; }

/* Super-admin: GitHub issues (/issues). */
.issue-filters { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.issue-filters .tabs { margin: 0; }
.issue-table tr.clickable { cursor: pointer; }
.issue-table tr.clickable:hover { background: var(--primary-softer); }
.issue-label { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.05rem 0.45rem; border-radius: 999px; vertical-align: middle; }
.issue-state { font-size: 0.8rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; }
.issue-state.open { background: #dcfce7; color: #166534; }
.issue-state.done { background: #ede9fe; color: #5b21b6; }
.issue-state.skip { background: #f1f5f9; color: #475569; }
.issue-label-picks { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; font-size: 0.85rem; }
.issue-body { margin-top: 0.8rem; }
.markdown img { max-width: 100%; }
.markdown pre { background: var(--bg, #f6f8fa); padding: 0.6rem; border-radius: 6px; overflow-x: auto; }
.markdown table { border-collapse: collapse; }
.markdown td, .markdown th { border: 1px solid var(--border); padding: 0.2rem 0.5rem; }
.login-guide { display: block; text-align: center; font-size: 0.85rem; margin-top: 0.6rem; }
/* Mes patients: a chart with consultations to complete (toggle). */
.data-table tr.row-todo td { background: #fff8e6; }
.data-table tr.row-todo td:first-child { box-shadow: inset 3px 0 0 #e8a33d; }
[data-part][hidden] { display: none !important; }
/* Window narrower than full screen: the chart header stays compact (one
   line of referents, buttons and boxes side by side) and the tasks go
   under the tab, not above it; the top bar keeps one line. */
.user-name { white-space: nowrap; }
@media (max-width: 1600px) {
  .patient-banner { gap: 0.5rem 1rem; }
  .patient-banner-referents { flex: 1 1 100%; gap: 0.3rem 1.25rem; order: 1; }
  .patient-banner-side { flex: 1 1 100%; order: 2; margin-left: 0; flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .patient-banner-side .patient-banner-actions { flex-wrap: wrap; flex: 1 1 100%; }
  .banner-rx { min-width: 0; align-items: flex-start; flex: 1 1 14rem; }
  .banner-rx-line { justify-content: flex-start; }
  .patient-banner-referrals, .patient-banner-dx, .patient-banner-checks { order: 3; }
}
@media (max-width: 1200px) {
  .user-role { display: none; }
}
@media (max-width: 1100px) {
  .patient-layout { flex-direction: column; }
}
@media (max-width: 1280px) {
  /* Agenda toolbar: on two lines rather than past the window's edge. */
  .cal-toolbar-row { flex-wrap: wrap; }
}
@media (min-width: 721px) and (max-width: 1100px) {
  .sidebar { width: 190px; }
  table.data-table th, table.data-table td { padding: 0.45rem 0.45rem; }
}
@media (max-width: 960px) {
  /* Wide lists (patients, team...): they scroll sideways in their card. */
  table.data-table:not(.timeline-table) { display: block; overflow-x: auto; }
}
/* Chart tabs: a bar that stands out (blue frame, filled active tab), kept
   in sight while scrolling the tab's content. */
.chart-tabs {
  gap: 0.3rem;
  padding: 0.35rem;
  background: var(--primary-soft);
  border: 1px solid #b9dbf5;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(30, 80, 130, 0.08);
}
.chart-tab {
  padding: 0.45rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 7px;
  margin-bottom: 0;
  color: #1f4e75;
  font-size: 0.92rem;
  font-weight: 500;
}
.chart-tab:hover { background: #fff; color: #12395a; }
.chart-tab.active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(30, 80, 130, 0.25);
}
.tl-detail-tardoc ul { margin: 0.2rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; }
.tl-detail-tardoc li { margin: 0.1rem 0; }
table.data-table.timeline-table .tl-time { text-align: right; font-variant-numeric: tabular-nums; }
/* × of a window: closes without saving. */
.modal-x { position: sticky; top: 0; float: right; margin: -0.6rem -0.6rem 0 0.5rem; z-index: 5; width: 2rem; height: 2rem;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted);
  font-size: 1.3rem; line-height: 1; cursor: pointer; }
.modal-x:hover { background: #fdecec; color: #a12b2b; border-color: #f3b9b9; }
.checkbox-inline[hidden] { display: none !important; }
.tardoc-min[hidden], .tardoc-add[hidden] { display: none !important; }
.tardoc-exclusive { margin: 0.3rem 0; }
.followup-select.fu-assistant { background: #eef2ff; color: #3730a3; }
.followup-pill.status-assistant { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }
/* Bell: one group per kind, folded with +/-. */
.bell-group { border-bottom: 1px solid var(--border); }
.bell-group-head { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.7rem; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.bell-group.open .bell-group-head { background: var(--primary-softer); }
.bell-fold { width: 1.5rem; height: 1.5rem; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); cursor: pointer; font-weight: 700; line-height: 1; }
.bell-group-title { flex: 1; text-align: left; background: none; border: 0; cursor: pointer; font-weight: 600; font-size: 0.86rem; color: var(--text); padding: 0; }
.bell-group-count { display: inline-block; min-width: 1.3rem; padding: 0 0.35rem; border-radius: 999px; background: var(--primary-soft); color: #1f4e75; font-size: 0.75rem; text-align: center; margin-left: 0.2rem; }
.bell-group-read { font-size: 0.78rem; white-space: nowrap; }
.bell-kind.urgent { color: var(--danger); }
.bell-group-items[hidden] { display: none; }
.bell-group-items .bell-item { padding-left: 2.2rem; }
.bell-actions { display: flex; flex-direction: column; gap: 0.1rem; align-self: flex-start; }
.bell-mute { font-size: 0.85rem; }
/* Online ranges mode: the appointments are only shown (no click, no drag);
   ranges drawn / moved / stretched by drag and drop. */
.cal-range-mode .cal-appt { pointer-events: none; opacity: 0.4; }
.cal-range-mode { cursor: crosshair; touch-action: none; }
.cal-range-mode .cal-online { cursor: grab; }
.cal-range-mode .cal-online::before, .cal-range-mode .cal-online::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; cursor: ns-resize; }
.cal-range-mode .cal-online::before { top: 0; }
.cal-range-mode .cal-online::after { bottom: 0; }
.cal-range-preview { position: absolute; left: 2px; right: 2px; z-index: 6; pointer-events: none; border: 2px dashed #1a7f37;
  background: rgb(26 127 55 / 15%); border-radius: 4px; font-size: 0.72rem; color: #14532d; padding: 2px 4px; font-weight: 600; }
/* Appointment with the psychiatrist (psychotherapy prescription to renew). */
.psy-rdv-tabs { display: flex; gap: 1.2rem; margin-bottom: 0.6rem; }
.psy-rdv-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.6rem; max-height: 55vh; overflow-y: auto; }
.psy-rdv-day > div { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }
#psy-mail input[type=email], #psy-mail select { width: 100%; margin-bottom: 0.3rem; }

/* Heidi inside MediGrego (scribe.js): one frame, over the chart's Heidi tab or docked on the right. */
:root { --heidi-w: min(560px, 42vw); }
.heidi-dock { position: fixed; border: 0; background: #fff; z-index: 40; visibility: hidden; pointer-events: none; }
.heidi-dock.on { visibility: visible; pointer-events: auto; }
.heidi-side-bar { display: none; }
body.heidi-side .heidi-dock { top: 44px; right: 0; width: var(--heidi-w); height: calc(100vh - 44px); z-index: 110; border-left: 1px solid var(--border, #dde6ef); box-shadow: -4px 0 12px rgba(0,0,0,.08); }
body.heidi-side .heidi-side-bar { display: flex; gap: 8px; align-items: center; position: fixed; top: 0; right: 0; width: var(--heidi-w); height: 44px; padding: 0 10px; box-sizing: border-box; background: var(--surface, #fff); border-left: 1px solid var(--border, #dde6ef); border-bottom: 1px solid var(--border, #dde6ef); z-index: 111; }
body.heidi-side .heidi-side-bar .muted { flex: 1; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.heidi-side .main-area { margin-right: var(--heidi-w); }
body.heidi-side .modal-overlay { right: var(--heidi-w); }

/* Messages: Équipe / Patients switch; patient threads are links */
.chat-tabs {
  margin-top: 0.75rem;
}
.chat-tabs .nav-count {
  margin-left: 0.25rem;
}
a.chat-item {
  text-decoration: none;
}

/* Decision aids: guideline watch (guidelines.js) */
.gl-card > summary { cursor: pointer; list-style: revert; }
.gl-topic { margin-top: 0.75rem; }
.gl-topic h4 { margin: 0 0 0.3rem; }
.gl-dx { font-weight: normal; font-size: 0.8rem; }
.gl-group { margin: 0.35rem 0 0.6rem; }
.gl-group-title { font-weight: 600; font-size: 0.82rem; margin-bottom: 0.2rem; }
.gl-item { border-left: 3px solid var(--border, #d8dee6); padding: 0.2rem 0.5rem; margin: 0.2rem 0; }
.gl-item > summary { cursor: pointer; font-size: 0.85rem; }
.gl-title { font-weight: 500; }
.gl-where { font-size: 0.78rem; margin-left: 0.3rem; }
.gl-badge { display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; padding: 0 0.35rem; border-radius: 3px; margin-right: 0.3rem; }
.gl-swiss { background: #fdecea; color: #b3261e; }
.gl-cochrane { background: #e8eef9; color: #1f4e9c; }
.gl-intl { background: #eef3ea; color: #3c6e2f; }
.gl-body { font-size: 0.82rem; padding: 0.3rem 0 0.2rem; }
.gl-summary { white-space: pre-wrap; max-height: 22rem; overflow: auto; }
.gl-authors { margin: 0; }
.gl-body-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; }
.gl-open { white-space: normal; text-align: left; }
.gl-open-end { margin: 0.4rem 0 0; }
.gl-source { margin: 0.4rem 0 0; font-size: 0.78rem; }
.gl-more > summary { cursor: pointer; font-size: 0.8rem; color: var(--text-muted); }
.gl-status { font-size: 0.75rem; margin-top: 0.6rem; }
.gl-topic-tag { display: inline-block; font-size: 0.7rem; padding: 0 0.35rem; margin-left: 0.3rem; border-radius: 3px; background: var(--bg-muted, #eef1f5); color: var(--text-muted); }
.gl-veille-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; }
.gl-veille-filter { font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; }
.gl-veille-topic { border-bottom: 1px solid var(--border, #d8dee6); padding: 0.45rem 0; }
.gl-veille-topic > summary { cursor: pointer; }
.gl-veille-topic .badge { margin-left: 0.35rem; }
.gl-mine-badge { background: #e8eef9; color: #1f4e9c; }
.gl-veille-body { padding: 0.3rem 0 0 0.8rem; font-size: 0.85rem; }
.gl-sources { margin: 0.2rem 0 0.4rem; padding-left: 1.1rem; font-size: 0.85rem; }
.gl-consult { margin: 0.75rem 0 0.25rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border, #d8dee6); border-radius: 6px; }

.formation-account { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.6rem 0; padding: 0.5rem 0.7rem; border: 1px solid var(--border, #d8dee6); border-radius: 6px; font-size: 0.9rem; }

/* Ninja: structures */
/* Ninja > Structures: key figures, one card per structure (its own hue),
   the team as small cards with initials. */
.ninja-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin: 0.4rem 0 1.1rem; }
.ninja-kpi { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem 1rem; box-shadow: 0 1px 2px rgba(20, 50, 80, 0.04); }
.ninja-kpi > span { grid-row: 1 / 3; font-size: 1.35rem; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 10px; background: var(--primary-softer); }
.ninja-kpi b { font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ninja-kpi small { color: var(--text-muted); font-size: 0.8rem; }
.ninja-list { display: flex; flex-direction: column; gap: 0.8rem; }
.ninja-structure { --h: 205; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid hsl(var(--h) 60% 62%);
  border-radius: 12px; box-shadow: 0 1px 3px rgba(20, 50, 80, 0.05); overflow: hidden; transition: box-shadow 0.15s; }
.ninja-structure:hover, .ninja-structure[open] { box-shadow: 0 4px 14px rgba(20, 50, 80, 0.08); }
.ninja-structure.is-off { opacity: 0.75; border-left-color: #c9ced6; }
.ninja-structure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.9rem; padding: 0.9rem 1.1rem; }
.ninja-structure > summary::-webkit-details-marker { display: none; }
.ninja-structure > summary:hover { background: var(--primary-softer); }
.ninja-mono { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 12px; display: grid; place-items: center; font-weight: 700; letter-spacing: 0.02em;
  color: hsl(var(--h) 55% 32%); background: hsl(var(--h) 70% 92%); }
.ninja-title { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.ninja-name { font-weight: 650; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ninja-sub { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.85rem; }
.ninja-pill { font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; }
.ninja-pill.on { background: var(--success-bg); color: var(--success); }
.ninja-pill.off { background: #fff4e5; color: #92610a; }
.ninja-stats { display: flex; gap: 0.5rem; }
.ninja-stat { display: flex; flex-direction: column; align-items: center; min-width: 5.5rem; padding: 0.3rem 0.7rem; border-radius: 10px; background: var(--bg);
  font-size: 0.72rem; color: var(--text-muted); }
.ninja-stat b { font-size: 1.1rem; color: var(--text); font-variant-numeric: tabular-nums; }
.ninja-chevron { flex: none; width: 0.6rem; height: 0.6rem; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg); transition: transform 0.2s; margin: 0 0.3rem; }
.ninja-structure[open] .ninja-chevron { transform: rotate(45deg); }
.ninja-body { border-top: 1px solid var(--border); padding: 0.9rem 1.1rem 1.1rem; background: linear-gradient(var(--primary-softer), var(--surface) 4rem); }
.ninja-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.9rem; }
.ninja-section { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-right: auto; }
.ninja-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.6rem; }
.ninja-member { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 0; }
.ninja-member.is-inactive { opacity: 0.55; background: var(--bg); }
.ninja-avatar { flex: none; width: 2.3rem; height: 2.3rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
  color: var(--primary-dark); background: var(--primary-soft); }
.ninja-member-body { min-width: 0; flex: 1; }
.ninja-member-name { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ninja-member-mail { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ninja-member-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.ninja-tag { font-size: 0.72rem; padding: 0.08rem 0.45rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); }
.ninja-tag-alt { background: #ede9fe; color: #5b21b6; }
.ninja-empty { margin: 0; }
.ninja-orphans { margin-top: 1rem; }
@media (max-width: 640px) {
  .ninja-structure > summary { flex-wrap: wrap; }
  .ninja-stats { order: 3; width: 100%; }
  .ninja-stat { flex: 1; }
}
.ninja-delete ul { margin: 0.2rem 0 0.8rem; }

/* Ninja > Pipeline: four columns, cards moved by their buttons. */
.pl-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; align-items: start; }
@media (max-width: 1100px) { .pl-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .pl-board { grid-template-columns: 1fr; } }
.pl-col { background: var(--surface-2, #f4f6f8); border-radius: var(--radius); padding: 0.6rem; min-height: 8rem; }
.pl-col h3 { margin: 0 0 0.2rem; font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.pl-count { font-size: 0.75rem; background: #fff; border-radius: 999px; padding: 0 0.45rem; color: #475569; }
.pl-col-help { font-size: 0.75rem; margin: 0 0 0.5rem; }
.pl-col-review { background: #fff8e1; }
.pl-empty { font-size: 0.85rem; }
.pl-card { background: #fff; border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.5rem 0.6rem; margin-bottom: 0.5rem; cursor: pointer; }
.pl-card:hover { border-color: #94a3b8; }
.pl-card-title { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.pl-card-meta { font-size: 0.75rem; margin-top: 0.25rem; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.pl-card-actions { display: flex; gap: 0.35rem; justify-content: flex-end; margin-top: 0.4rem; flex-wrap: wrap; }
.pl-col { min-width: 0; }
.pl-card-actions .btn { white-space: normal; max-width: 100%; }

/* Facturation > Messages assureurs (GNOT) */
.gn-layout { display: grid; grid-template-columns: minmax(16rem, 1fr) 2fr; gap: 0.75rem; align-items: start; }
@media (max-width: 900px) { .gn-layout { grid-template-columns: 1fr; } }
.gn-list { padding: 0.4rem; max-height: 70vh; overflow: auto; }
.gn-thread { display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--radius); padding: 0.5rem; cursor: pointer; font: inherit; color: inherit; }
.gn-thread:hover { background: var(--primary-softer, #f1f5f9); }
.gn-thread.active { border-color: #94a3b8; background: var(--primary-softer, #f1f5f9); }
.gn-msg { border-radius: var(--radius); padding: 0.5rem 0.7rem; margin-bottom: 0.5rem; }
.gn-msg.gn-in { background: #f1f5f9; margin-right: 15%; }
.gn-msg.gn-out { background: #e8f1fb; margin-left: 15%; }
.gn-hit { display: block; font-size: 0.9rem; padding: 0.2rem 0; }

/* Équipe: members grouped by job; new patients, next free slot, tests */
.team-members tr.team-group td { background: var(--surface-2, #f1f5f9); font-weight: 600; padding-top: 0.45rem; padding-bottom: 0.45rem; }
.team-tests { margin-top: 0.25rem; display: flex; flex-wrap: wrap; gap: 0.2rem; }
.badge.badge-test { background: #ede9fe; color: #5b21b6; font-size: 0.7rem; }
.intake-tests { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font-size: 0.9rem; }

/* Annuaire: the practitioner's sheet as badges (a click filters on it) */
.dir-badges { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-top: 0.3rem; max-width: 28rem; }
.dir-badge { border: 0; border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.72rem; cursor: pointer; font: inherit; font-size: 0.72rem; }
.dir-badge:hover { filter: brightness(0.93); }
.dir-public { background: #dcfce7; color: #166534; }
.dir-lang { background: #e0f2fe; color: #075985; }
.dir-spec { background: #fef3c7; color: #92400e; }
.dir-approach { background: #fce7f3; color: #9d174d; }
.dir-test { background: #ede9fe; color: #5b21b6; }
.dir-mode { background: #f1f5f9; color: #334155; }

/* Aide: the best passage shown as the answer */
.help-answer { border-left: 3px solid var(--primary, #2563eb); padding: 0.4rem 0.8rem; background: var(--surface-2, #f8fafc); border-radius: 0 var(--radius) var(--radius) 0; }
.help-answer-where { font-size: 0.82rem; margin-bottom: 0.3rem; }
.help-answer-body { font-size: 0.92rem; }
.help-answer-body > :first-child { margin-top: 0; }
.help-answer .btn { margin-top: 0.4rem; }

/* Agenda > Créneau commun: everyone's busy times hatched (as Superposer),
   the slots free for all in green, clickable (new appointment, the others
   invited). */
.cal-free-band {
  position: absolute; left: 3px; right: 3px; z-index: 1; cursor: pointer;
  background: rgba(26, 127, 55, 0.14); border: 1px solid rgba(26, 127, 55, 0.55);
  border-radius: 5px; overflow: hidden; transition: background 0.15s;
}
.cal-free-band:hover { background: rgba(26, 127, 55, 0.26); }
.cal-free-band span { position: absolute; left: 5px; top: 2px; font-size: 0.72rem; font-weight: 600; color: var(--success); white-space: nowrap; }
.cal-common-hint { background: var(--success-bg); border-color: rgba(26, 127, 55, 0.35); }
.common-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.2rem 0.8rem; margin: 0.6rem 0 0.9rem; }

/* Annuaire: a table when there is room; in a narrow window (half a screen,
   a laptop) each person becomes a card -- name and buttons on top, then
   role and badges, antennas / days, new patients, contact. Driven by the
   card's own width (container query), not the screen's. */
.dir-head { flex-wrap: wrap; gap: 0.6rem; }
.dir-wrap { container-type: inline-size; }
.dir-contact a { overflow-wrap: anywhere; }
@container (max-width: 1080px) {
  .dir-table thead { display: none; }
  .dir-table, .dir-table tbody { display: block; width: 100%; }
  table.dir-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.45rem 1rem;
    grid-template-areas: "name actions" "role role" "sites intake" "contact contact";
    padding: 0.85rem 0.2rem; border-bottom: 1px solid var(--border);
  }
  table.dir-table tr:last-child { border-bottom: 0; }
  table.dir-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .dir-table td:nth-child(1) { grid-area: name; }
  .dir-table td:nth-child(2) { grid-area: role; }
  .dir-table .dir-sites { grid-area: sites; }
  .dir-table .dir-intake { grid-area: intake; }
  .dir-table .dir-contact { grid-area: contact; }
  .dir-table .dir-actions { grid-area: actions; align-self: start; }
  .dir-table .dir-sites::before, .dir-table .dir-intake::before {
    content: attr(data-label); display: block; font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.15rem;
  }
  .dir-table .dir-sites > div { display: inline-block; margin-right: 0.9rem; }
  .dir-table .dir-contact > a, .dir-table .dir-contact > div { display: inline-block; margin-right: 1rem; }
}
@container (max-width: 520px) {
  table.dir-table tr { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "actions" "role" "sites" "intake" "contact"; }
  .dir-table .dir-actions { text-align: left; }
}

/* Sidebar: E-mails / Chat with unread messages -- "(3)" and bold */
#sidebar-nav a.has-unread {
  font-weight: 700;
}

/* Équipe > Membres: a table when there is room; in a narrow window (half a
   screen, a laptop) each member becomes a card -- name and buttons on top,
   role, then new patients / antennas / identifiers side by side. Driven by
   the list's own width (container query), as the Annuaire. */
#members-table { container-type: inline-size; }
@container (max-width: 1100px) {
  .team-members thead { display: none; }
  .team-members, .team-members tbody { display: block; width: 100%; }
  .team-members tr.team-group { display: block; }
  .team-members tr.team-group td { display: block; }
  .team-members tr[data-member] {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem 1rem;
    grid-template-areas: "name name role" "actions actions actions" "intake sites ids";
    padding: 0.85rem 0.6rem; border-bottom: 1px solid var(--border);
  }
  .team-members tr[data-member] td { display: block; padding: 0; border: 0; min-width: 0; white-space: normal; }
  .team-members .tm-name { grid-area: name; }
  .team-members .tm-role { grid-area: role; }
  .team-members .tm-intake { grid-area: intake; }
  .team-members .tm-sites { grid-area: sites; }
  .team-members .tm-ids { grid-area: ids; }
  .team-members .tm-actions { grid-area: actions; text-align: left; display: flex !important; flex-wrap: wrap; gap: 0.35rem; }
  .team-members .tm-intake::before, .team-members .tm-sites::before, .team-members .tm-ids::before {
    content: attr(data-label); display: block; font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.15rem;
  }
  .team-members .tm-name .team-sub { overflow-wrap: anywhere; }
}
@container (max-width: 560px) {
  .team-members tr[data-member] { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "role" "actions" "intake" "sites" "ids"; }
}

/* ---------------------------------------------------------------- Formation: journal clubs and courses (pages/teaching-sessions.js) */
.ts-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.6rem; align-items: center; }
.ts-filter, .ts-tools { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.ts-help { margin: 0.4rem 0 0.8rem; font-size: 0.88rem; }
.ts-list { display: grid; gap: 0.8rem; }
.ts-card { display: flex; gap: 1rem; cursor: pointer; transition: box-shadow 0.15s; }
.ts-card:hover { box-shadow: 0 6px 18px -10px rgba(30, 60, 90, 0.35); }
.ts-cancelled { opacity: 0.6; }
.ts-date { flex: 0 0 64px; height: 64px; border-radius: 12px; background: var(--primary-soft); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--primary-dark); }
.ts-day { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.ts-month { font-size: 0.8rem; text-transform: uppercase; }
.ts-main { flex: 1; min-width: 0; }
.ts-main h3 { margin: 0.2rem 0 0.2rem; font-size: 1.05rem; }
.ts-main p { margin: 0 0 0.3rem; }
.ts-head { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; font-size: 0.82rem; }
.ts-kind { padding: 0.1rem 0.55rem; border-radius: 999px; font-weight: 600; }
.ts-kind-journal { background: #ede7fb; color: #5b3fb5; }
.ts-kind-course { background: #e3f4ec; color: #1f7a4d; }
.ts-articles { list-style: none; padding: 0; margin: 0.3rem 0; font-size: 0.9rem; }
.ts-articles li { padding: 0.15rem 0; }
.ts-design { display: inline-block; margin-right: 0.4rem; padding: 0 0.45rem; border-radius: 6px; background: #f1f3f6; font-size: 0.75rem; color: #475569; }
.ts-evidence { display: inline-block; margin-right: 0.4rem; padding: 0 0.45rem; border-radius: 6px; font-size: 0.75rem; }
.ts-ev-high { background: #dcfce7; color: #166534; } .ts-ev-moderate { background: #e0f2fe; color: #075985; }
.ts-ev-low { background: #fef3c7; color: #92400e; } .ts-ev-very_low { background: #fee2e2; color: #991b1b; }
.ts-supports { font-size: 0.88rem; }
.ts-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.4rem; font-size: 0.85rem; }
.ts-detail h3 { margin: 1rem 0 0.4rem; }
.ts-article { border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.9rem; margin-bottom: 0.7rem; }
.ts-article h4 { margin: 0.2rem 0; }
.ts-links { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0.3rem 0; }
.ts-abstract summary { cursor: pointer; color: var(--primary-dark); font-size: 0.9rem; }
.ts-abstract p { font-size: 0.88rem; white-space: pre-line; }
.ts-appraisal { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--border); }
.ts-appraisal-row strong { font-size: 0.8rem; color: #475569; text-transform: uppercase; letter-spacing: 0.03em; }
.ts-appraisal-row p { margin: 0.1rem 0 0; font-size: 0.9rem; white-space: pre-line; }
.ts-att td { padding: 0.25rem 0.5rem; }
.ts-notes { white-space: pre-line; }
.ts-plan { margin-top: 0.6rem; }
.ts-slot-bar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; font-size: 0.88rem; margin: 0.4rem 0; }
.ts-slot-bar input, .ts-slot-bar select { width: auto; display: inline-block; }
.ts-slot-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.5rem; }
.ts-slot-list p { width: 100%; margin: 0; font-size: 0.85rem; }
.ts-slot { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; padding: 0.4rem 0.7rem; border-radius: 10px; border: 1.5px solid #86c5a0; background: #effaf3; cursor: pointer; font: inherit; font-size: 0.88rem; }
.ts-slot small { color: #3f6f52; }
.ts-slot-partial { border-color: #e2c27a; background: #fff8e8; }
.ts-slot-partial small { color: #8a6516; }
.ts-slot.active { outline: 3px solid var(--primary); }
.ts-check { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.9rem; }
.ts-check input { width: auto; margin-top: 0.2rem; }
.ts-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.2rem 1rem; }
.ts-person { display: flex; gap: 0.4rem; align-items: center; font-size: 0.9rem; }
.ts-person input { width: auto; }
.ts-lookup { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.ts-lookup input { max-width: 260px; }
.ts-lookup .muted { font-size: 0.82rem; }
.ts-grid { margin-top: 0.6rem; }
.ts-uploads { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
@media (max-width: 700px) { .ts-appraisal { grid-template-columns: 1fr; } .ts-date { flex-basis: 52px; height: 52px; } }

/* Help articles: tables (Licences open source...) */
.help-table { width: 100%; border-collapse: collapse; margin: 0.4rem 0 1rem; font-size: 0.9rem; }
.help-table th, .help-table td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.help-table th { background: var(--primary-softer); font-weight: 600; }

/* « Nouveautés » (release-notes.js) */
.release-notes h3 { margin: 0.2rem 0 0.4rem; font-size: 1.02rem; }
.release-notes h3 .muted { font-weight: 400; font-size: 0.85rem; }
.release-notes ul { margin: 0 0 0.9rem; padding-left: 1.2rem; }
.release-notes li { margin: 0.25rem 0; line-height: 1.4; }

/* Referral window: filtered list of colleagues (chat.js openReferModal). */
.refer-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 0.8rem; }
.refer-cands { max-height: 18rem; overflow-y: auto; border: 1px solid var(--border, #e2e8f0); border-radius: 8px; }
.refer-cand { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.5rem 0.7rem; cursor: pointer; border-bottom: 1px solid var(--border, #e2e8f0); font-weight: normal; }
.refer-cand[hidden] { display: none; }
.refer-cand:hover { background: rgba(58, 139, 203, 0.06); }
.refer-cand:has(input:checked) { background: rgba(58, 139, 203, 0.12); }
.refer-cand input { margin-top: 0.25rem; }
.refer-cand-place { font-size: 0.85rem; margin-top: 0.15rem; }
.refer-cand .dir-badge { cursor: default; }
.refer-cand .dir-badge.refer-hit { outline: 2px solid currentColor; }
.refer-cands [data-none] { padding: 0.6rem 0.7rem; margin: 0; }

/* Paramètres > Démo (demo-invites.js). */
.demo-invite-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 0.9rem; }
.badge-muted { background: #f1f5f9; color: #475569; }
