/* ============================================================
   styles.css — Portail Patient JULiA V3
   Tokens + composants + responsive (un seul fichier)
   ============================================================ */

/* ---- Google Fonts (chargées dans le HTML) ---- */

:root {
  /* fonds & encre */
  --bg: #F5F3F0;
  --bg-warm: #F0EDE8;
  --surface: #FFFFFF;
  --ink: #2D2D2D;
  --ink-2: #4A4A4A;
  --ink-soft: #8A8A8A;
  --line: #E5E2DD;
  --line-soft: #F0EDEA;

  /* primaire — orange JULiA : actions, CTA, navigation */
  --sage: #E8772E;
  --sage-dk: #D06825;
  --sage-soft: #FEF0E6;
  --sage-ink: #B45A1A;

  /* accent chaud — terracotta : reste à charge, urgent */
  --clay: #D4532A;
  --clay-soft: #FDECE7;
  --clay-ink: #9C3415;

  /* secondaire — ambre : MUTUELLE */
  --amber: #CF9A45;
  --amber-soft: #FDF5E8;
  --amber-ink: #7A5320;

  /* info — bleu : SÉCURITÉ SOCIALE, documents */
  --blue: #5A7CA0;
  --blue-soft: #EAF0F6;
  --blue-ink: #36506C;

  /* validé / succès — vert */
  --good: #4E8A6B;
  --good-soft: #E8F5EE;
  --good-ink: #2D6B4A;

  /* sidebar — charcoal très foncé (style JULiA) */
  --sidebar-bg: #2D2D2D;
  --sidebar-bg-deep: #232323;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 4px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;

  --sidebar-w: 232px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }

/* ---- Accessibility ---- */

:focus-visible {
  outline: 2px solid rgba(232,119,46,0.6);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Typography ---- */

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.3;
}

.tabular-nums { font-variant-numeric: tabular-nums; }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */

.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* ---- Sidebar (Desktop ≥ 1024px) ---- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-deep) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sage) 0%, var(--amber) 100%);
  z-index: 1;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 0.5rem;
  font-family: var(--sans);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--sage);
  text-transform: uppercase;
}
.sidebar-logo span {
  opacity: 0.45;
  font-weight: 400;
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  margin-left: 0.15rem;
}

.sidebar-family {
  margin: 0.5rem 0.75rem 1rem;
  padding: 0.75rem 0.85rem;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--sage);
}
.sidebar-family-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}
.sidebar-family-meta {
  font-size: 0.72rem;
  opacity: 0.5;
}

.sidebar-nav {
  flex: 1;
  padding: 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  transition: all var(--transition);
  position: relative;
}
.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.6;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.sidebar-nav a:hover svg { opacity: 0.9; }
.sidebar-nav a.active {
  background: rgba(232,119,46,0.15);
  color: var(--sage);
  font-weight: 600;
  border-left: 3px solid var(--sage);
  margin-left: -3px;
}
.sidebar-nav a.active svg { opacity: 1; color: var(--sage); }

.nav-badge {
  margin-left: auto;
  background: var(--sage);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 1.1rem;
  height: 1.1rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
  box-shadow: 0 1px 4px rgba(232,119,46,0.3);
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: auto;
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.6);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.sidebar-footer a:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}
.sidebar-footer a svg { width: 18px; height: 18px; opacity: 0.5; }

/* ---- Topbar ---- */

.topbar {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sage) 0%, var(--amber) 100%);
}

.topbar-bell, .topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.topbar-bell:hover { background: var(--line-soft); }
.topbar-bell svg { width: 20px; height: 20px; color: var(--ink-soft); }
.topbar-avatar {
  background: var(--sage);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--sage);
}

/* ---- Main area ---- */

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1200px;
  width: 100%;
  min-width: 0;
  overflow-x: clip;
}

/* ---- Bottom nav (mobile) ---- */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 0.35rem 0;
  padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--ink-soft);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  position: relative;
  transition: color var(--transition);
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active {
  color: var(--sage);
  font-weight: 600;
}
.bottom-nav a.active svg { color: var(--sage); }
.bottom-nav a .nav-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  margin-left: 0;
  font-size: 0.6rem;
  min-width: 1rem;
  height: 1rem;
}

/* ============================================================
   COMPOSANTS RÉUTILISABLES
   ============================================================ */

/* ---- Boutons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--sans);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn--primary {
  background: var(--sage);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232,119,46,0.25);
}
.btn--primary:hover {
  background: var(--sage-dk);
  box-shadow: 0 4px 14px rgba(232,119,46,0.35);
  transform: translateY(-1px);
}

.btn--clay {
  background: var(--clay);
  color: #fff;
  box-shadow: 0 2px 8px rgba(188,98,68,0.25);
}
.btn--clay:hover {
  background: #A8563B;
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn--ghost:hover {
  background: var(--bg-warm);
  border-color: var(--ink-soft);
}

.btn--soft {
  background: var(--sage-soft);
  color: var(--sage-ink);
}
.btn--soft:hover {
  background: rgba(232,119,46,0.15);
}

.btn--sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}
.btn--sm svg { width: 15px; height: 15px; }

.btn--full { width: 100%; }

.btn--lg {
  padding: 0.75rem 1.75rem;
  font-size: 0.95rem;
}

.btn:disabled, .btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---- Tags / badges ---- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.4;
}

.tag--neutral { background: var(--line-soft); color: var(--ink-2); }
.tag--sage { background: var(--good-soft); color: var(--good-ink); }
.tag--orange { background: var(--sage-soft); color: var(--sage-ink); }
.tag--clay { background: var(--clay-soft); color: var(--clay-ink); }
.tag--amber { background: var(--amber-soft); color: var(--amber-ink); }
.tag--blue { background: var(--blue-soft); color: var(--blue-ink); }
.tag--solid { background: var(--good); color: #fff; }

/* ---- Avatars ---- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.7rem;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}
.avatar--sm { width: 28px; height: 28px; font-size: 0.6rem; }
.avatar--md { width: 36px; height: 36px; font-size: 0.75rem; }
.avatar--lg { width: 44px; height: 44px; font-size: 0.85rem; }

/* ---- Chips (patient) ---- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem 0.2rem 0.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip .avatar { width: 22px; height: 22px; font-size: 0.55rem; }

.chip--active {
  background: var(--sage-soft);
  border-color: var(--sage);
  color: var(--sage-ink);
  box-shadow: 0 1px 4px rgba(232,119,46,0.15);
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
}
.card--clickable:hover {
  transform: translateY(-1px);
  cursor: pointer;
}
.card--clay { border-left: 3px solid var(--clay); }
.card--sage { border-left: 3px solid var(--sage); }
.card--amber { border-left: 3px solid var(--amber); }

/* ---- Cost bar (répartition Sécu / Mutuelle / Reste) ---- */

.cost-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line-soft);
}
.cost-bar__seg {
  height: 100%;
  transition: width 0.4s ease;
}
.cost-bar__seg--secu { background: var(--blue); }
.cost-bar__seg--mutuelle { background: var(--amber); }
.cost-bar__seg--reste { background: var(--clay); }

.cost-bar--lg { height: 14px; }

/* ---- Cost legend ---- */

.cost-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.82rem;
}
.cost-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.cost-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cost-dot--secu { background: var(--blue); }
.cost-dot--mutuelle { background: var(--amber); }
.cost-dot--reste { background: var(--clay); }

/* ---- Section titles ---- */

.section-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-title svg { width: 20px; height: 20px; color: var(--sage); opacity: 0.85; }

/* ---- Encarts (info boxes) ---- */

.encart {
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid;
}
.encart--sage {
  background: var(--sage-soft);
  border-color: rgba(232,119,46,0.15);
}
.encart--clay {
  background: var(--clay-soft);
  border-color: rgba(188,98,68,0.2);
}
.encart--amber {
  background: var(--amber-soft);
  border-color: rgba(207,154,69,0.2);
}
.encart--blue {
  background: var(--blue-soft);
  border-color: rgba(90,124,160,0.2);
}
.encart--flex {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.encart-body {
  flex: 1;
  min-width: 0;
}
.encart-visual {
  flex-shrink: 0;
  align-self: flex-start;
}
.encart-visual .dental-chart-wrap {
  max-width: min(200px, 100%);
}

/* ---- Timeline ---- */

.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-step {
  position: relative;
  padding-bottom: 1.5rem;
}
.timeline-step:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 0.1rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  box-shadow: 0 1px 4px rgba(232,119,46,0.25);
}
.timeline-step--wait .timeline-dot {
  background: var(--amber-soft);
  color: var(--amber-ink);
  border: 2px dashed var(--amber);
}

.timeline-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
}

.timeline-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
.timeline-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.timeline-desc {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.6;
}
.timeline-but {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-warm);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: var(--ink-2);
}
.timeline-but strong { color: var(--ink); }

/* ---- Overlay / Modal ---- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(42,40,35,0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.overlay.is-open {
  opacity: 1;
  visibility: visible;
}
.overlay-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform 0.3s ease;
}
.overlay.is-open .overlay-panel {
  transform: translateY(0);
}
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.overlay-header h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
}
.overlay-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: all var(--transition);
}
.overlay-close:hover { background: var(--line-soft); color: var(--ink); }
.overlay-close svg { width: 20px; height: 20px; }
.overlay-body { padding: 1.5rem; }
.overlay-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ---- Legal banner (mineur) ---- */

.legal-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--amber-soft);
  border: 1px solid rgba(207,154,69,0.25);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--amber-ink);
  margin-bottom: 1rem;
}
.legal-banner svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Details / Accordion ---- */

.accord summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.75rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.accord summary::-webkit-details-marker { display: none; }
.accord summary .chevron {
  margin-left: auto;
  transition: transform var(--transition);
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
}
.accord[open] summary .chevron { transform: rotate(180deg); }

/* ---- Signature canvas ---- */

.sig-canvas {
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: crosshair;
  touch-action: none;
  width: 100%;
  height: 180px;
}
.sig-canvas.has-sig { border-color: var(--good); border-style: solid; }

/* ---- Checkbox custom ---- */

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1.5;
}
.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 0.1rem;
  accent-color: var(--sage);
  flex-shrink: 0;
}

/* ---- Empty state ---- */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ink-soft);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ---- Stub page ---- */

.stub-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  min-height: 60vh;
}
.stub-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--sage-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.stub-icon svg { width: 32px; height: 32px; color: var(--sage); opacity: 0.8; }
.stub-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.stub-desc {
  font-size: 0.9rem;
  color: var(--ink-soft);
  max-width: 400px;
  line-height: 1.6;
}

/* ---- Confirmation ---- */

.confirm-check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--good-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.confirm-check svg { width: 32px; height: 32px; color: var(--good); }

/* ---- Onglets ---- */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 0.6rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  transition: color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background var(--transition);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--sage);
  font-weight: 700;
}
.tab-btn.active::after {
  background: var(--sage);
  height: 3px;
  border-radius: 3px 3px 0 0;
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 0.3rem;
  margin-left: 0.35rem;
  background: var(--line-soft);
  color: var(--ink-soft);
}
.tab-btn.active .tab-count {
  background: var(--sage);
  color: #fff;
}

/* ---- Patient group header ---- */

.patient-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
  min-width: 0;
}
.patient-group-info {
  flex: 1;
  min-width: 0;
}
.patient-group-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}
.patient-group-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.patient-group-stats {
  text-align: right;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ---- Devis card (list) ---- */

.devis-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 0.75rem;
  transition: all var(--transition);
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.devis-card:hover {
  box-shadow: var(--shadow);
  border-color: rgba(232,119,46,0.2);
}
.devis-card--expired {
  opacity: 0.6;
}
.devis-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  min-width: 0;
}
.devis-card-title {
  flex: 1;
  min-width: 0;
}
.devis-card-title h4 {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.15rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.devis-card-title p {
  font-size: 0.78rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.devis-card-header .tag {
  flex-shrink: 0;
}
.devis-card-context {
  margin-bottom: 0.75rem;
}
.devis-card-context .care-context {
  margin-top: 0;
}
.devis-card-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.devis-stat {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.devis-stat strong {
  display: block;
  font-size: 0.92rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.devis-stat--clay strong { color: var(--clay-ink); }
.devis-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.devis-card-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.devis-card-meta {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* ---- Écheancier cards ---- */

.echeance-cards {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}
.echeance-card {
  flex: 0 0 auto;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  scroll-snap-align: start;
  text-align: center;
}
.echeance-card-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}
.echeance-card-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.echeance-card-date {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
}

/* ---- Decision rail (sticky droite, desktop) ---- */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.detail-main { min-width: 0; }

.detail-rail {
  display: none;
}

/* ---- Sticky bar mobile (devis signature) ---- */

.sticky-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 16px rgba(42,40,35,0.1);
}
.sticky-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.sticky-bar-amount {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.sticky-bar-amount strong {
  display: block;
  font-size: 1.1rem;
  color: var(--clay-ink);
  font-variant-numeric: tabular-nums;
}

/* ---- Document list items ---- */

.doc-list-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  max-width: 100%;
  min-width: 0;
}
.doc-list-item:hover {
  box-shadow: var(--shadow);
  border-color: rgba(232,119,46,0.2);
}
.doc-list-item.is-viewed { opacity: 0.65; }
.doc-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.doc-icon--pdf { background: var(--clay-soft); color: var(--clay-ink); }
.doc-icon--video { background: var(--blue-soft); color: var(--blue-ink); }
.doc-icon svg { width: 20px; height: 20px; }
.doc-info { flex: 1; min-width: 0; }
.doc-info-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}
.doc-info-sub {
  font-size: 0.75rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.doc-list-item-arrow { color: var(--ink-soft); flex-shrink: 0; }
.doc-list-item--required {
  border-color: rgba(207,154,69,0.45);
  background: var(--surface);
}
.doc-list-item--required:hover {
  border-color: var(--amber);
  box-shadow: 0 2px 12px rgba(207,154,69,0.15);
}

/* ---- Documents à signer (encart prioritaire) ---- */

.docs-sign-prompt {
  background: linear-gradient(135deg, var(--amber-soft) 0%, rgba(255,248,235,0.95) 100%);
  border: 1.5px solid rgba(207,154,69,0.35);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}
.docs-sign-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}
.docs-sign-prompt-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}
.docs-sign-prompt-title svg { color: var(--amber-ink); flex-shrink: 0; }
.docs-sign-prompt-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--amber-ink);
  background: rgba(255,255,255,0.7);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.docs-sign-prompt-desc {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}
.docs-sign-progress {
  height: 4px;
  background: rgba(207,154,69,0.2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.85rem;
}
.docs-sign-progress-bar {
  height: 100%;
  background: var(--amber-ink);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.docs-sign-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.docs-complement-desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: -0.5rem 0 0.85rem;
  line-height: 1.5;
}
.docs-complement-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---- Rail : checklist documents ---- */

.rail-docs-checklist {
  margin-bottom: 1rem;
  padding: 0.85rem;
  background: var(--amber-soft);
  border: 1px solid rgba(207,154,69,0.25);
  border-radius: var(--radius-sm);
}
.rail-docs-checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.rail-docs-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--amber-ink);
}
.rail-doc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.35rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  transition: background var(--transition);
}
.rail-doc-item:hover { background: rgba(255,255,255,0.5); }
.rail-doc-check {
  width: 16px;
  height: 16px;
  border: 2px solid var(--amber-ink);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.rail-doc-item.is-viewed .rail-doc-check {
  background: var(--good);
  border-color: var(--good);
}
.rail-doc-item.is-viewed .rail-doc-check::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.rail-doc-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}
.rail-doc-item.is-viewed .rail-doc-label {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,0.15);
}

/* ---- Alternative block ---- */

.alternative-block {
  background: var(--bg-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
}
.alternative-block h4 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.alternative-block p {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.6;
}

/* ---- Greeting (accueil) ---- */

.greeting-title {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--ink);
}
.greeting-sub {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
}

/* ---- Hero card chips ---- */

.hero-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* ---- Hero card (accueil) ---- */

.hero-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--clay);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
}
.hero-card-visual {
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 0;
  width: auto;
  max-width: min(220px, 36%);
  background: var(--sage-soft);
  border: 1px solid rgba(232,119,46,0.18);
  padding: 0.5rem 0.45rem;
}
.hero-card-visual .dental-chart-wrap {
  width: auto;
  max-width: 100%;
}
.hero-card-visual .dental-chart-label {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.25rem;
  line-height: 1.3;
  text-align: center;
}
.hero-card-body { flex: 1; min-width: 0; }
.hero-card-body h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}
.hero-card-body p {
  font-size: 0.85rem;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.hero-card-amounts {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.hero-card-amounts .devis-stat strong { font-size: 1rem; }

/* ---- À faire list ---- */

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: all var(--transition);
}
.todo-item:hover { box-shadow: var(--shadow-sm); }
.todo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.todo-icon--devis { background: var(--clay-soft); color: var(--clay); }
.todo-icon--pay { background: var(--amber-soft); color: var(--amber); }
.todo-icon--doc { background: var(--blue-soft); color: var(--blue); }
.todo-icon svg { width: 18px; height: 18px; }
.todo-info { flex: 1; min-width: 0; }
.todo-info-title { font-weight: 600; font-size: 0.85rem; color: var(--ink); }
.todo-info-meta { font-size: 0.72rem; color: var(--ink-soft); }
.todo-amount {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--clay-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- RDV mini cards ---- */

.rdv-mini {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}
.rdv-date-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 0.35rem 0.5rem;
  background: var(--sage-soft);
  border-radius: var(--radius-xs);
  text-align: center;
  border-top: 2px solid var(--sage);
}
.rdv-date-day { font-size: 1.1rem; font-weight: 700; color: var(--sage-ink); line-height: 1; }
.rdv-date-month { font-size: 0.6rem; font-weight: 700; color: var(--sage); text-transform: uppercase; letter-spacing: 0.04em; }
.rdv-info { flex: 1; }
.rdv-info-title { font-weight: 600; font-size: 0.85rem; color: var(--ink); }
.rdv-info-meta { font-size: 0.75rem; color: var(--ink-soft); }

/* Contexte cabinet + praticien (accueil, devis, RDV) */
.care-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
  line-height: 1.4;
}
.care-context-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  min-width: 0;
}
.care-context-item span {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.care-context-item svg {
  width: 12px;
  height: 12px;
  opacity: 0.5;
  flex-shrink: 0;
}
.care-context-sep {
  opacity: 0.35;
  user-select: none;
}
.hero-card-body .care-context {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

/* ---- Finance mini ---- */

/* ---- Finance section (accueil enrichie) ---- */

.finance-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.finance-global-solde {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.finance-global-solde-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.finance-global-solde-amount {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--clay-ink);
  font-variant-numeric: tabular-nums;
}

.finance-next-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: var(--sage-soft);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
}
.finance-next-banner strong {
  color: var(--sage-ink);
  font-variant-numeric: tabular-nums;
}
.finance-next-banner-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.finance-next-banner-icon svg { width: 14px; height: 14px; color: var(--sage); }

.finance-cabinets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 0.65rem;
}

.finance-cabinet-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
}
.finance-cab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.finance-cab-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}
.finance-cab-solde {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--clay-ink);
  font-variant-numeric: tabular-nums;
}
.finance-cab-meta {
  font-size: 0.75rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.finance-echeancier {
  margin-top: 0.5rem;
}
.finance-ech-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}
.finance-ech-steps {
  display: flex;
  gap: 0.35rem;
}
.finance-ech-step {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.25rem;
  background: var(--line-soft);
  border-radius: var(--radius-xs);
  position: relative;
}
.finance-ech-step--due {
  background: var(--sage-soft);
  border: 1px solid rgba(232,119,46,0.25);
}
.finance-ech-step-amount {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.finance-ech-step--due .finance-ech-step-amount {
  color: var(--sage-ink);
}
.finance-ech-step-date {
  font-size: 0.6rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}

.finance-single-pay {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-2);
  padding: 0.5rem 0.65rem;
  background: var(--sage-soft);
  border-radius: var(--radius-xs);
}
.finance-single-pay svg { width: 14px; height: 14px; color: var(--sage); flex-shrink: 0; }
.finance-single-pay strong { color: var(--sage-ink); font-variant-numeric: tabular-nums; }

/* Ancien finance-mini (gardé pour rétrocompat) */
.finance-mini {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.finance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
}
.finance-row + .finance-row { border-top: 1px solid var(--line-soft); }
.finance-label { font-size: 0.82rem; color: var(--ink-soft); }
.finance-value { font-weight: 700; font-size: 0.95rem; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- Conseils rail ---- */

.conseils-rail {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
  max-width: 100%;
}
.conseil-card {
  flex: 0 0 auto;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
  scroll-snap-align: start;
}
.conseil-card h4 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
.conseil-card p {
  font-size: 0.75rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ---- Actes table ---- */

.actes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.actes-table th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--line);
}
.actes-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.actes-table tr:last-child td { border-bottom: none; }
.actes-table .col-label { font-weight: 500; color: var(--ink); }
.actes-table .col-secu { color: var(--blue-ink); }
.actes-table .col-mutuelle { color: var(--amber-ink); }
.actes-table .col-reste { color: var(--clay-ink); font-weight: 600; }

/* ---- Back link ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 1rem;
  transition: color var(--transition);
}
.back-link:hover { color: var(--ink); }
.back-link svg { width: 18px; height: 18px; }

/* ---- Detail header (devis detail) ---- */

.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.detail-header h1 {
  font-size: 1.35rem;
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.detail-header-amount {
  text-align: right;
}
.detail-header-amount-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.detail-header-amount-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--clay-ink);
  font-variant-numeric: tabular-nums;
}

/* ---- Reassurance ---- */

.reassurance {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.75rem;
}
.reassurance svg { width: 16px; height: 16px; color: var(--sage); flex-shrink: 0; }

/* ---- Section spacer ---- */

.section-spacer { margin-bottom: 2rem; }

/* ---- Dashboard grid ---- */

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.dash-col { min-width: 0; }

/* ============================================================
   RESPONSIVE — Tablette (768–1023px)
   ============================================================ */

@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .bottom-nav { display: block; }
  .main-content {
    padding: 1.5rem;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-rail { display: none; }
  .sticky-bar { display: block; bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* ============================================================
   RESPONSIVE — Mobile (< 768px)
   ============================================================ */

@media (max-width: 767px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { display: flex; padding: 0.5rem 1rem; }
  .bottom-nav { display: block; }
  .main-content {
    padding: 1rem;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .dash-grid { grid-template-columns: 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-rail { display: none; }
  .sticky-bar { display: block; bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px)); }

  .hero-card {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1.15rem;
  }
  .hero-card-visual {
    width: auto;
    min-width: 0;
    max-width: 100%;
    padding: 0.65rem 0.5rem;
    order: -1;
    align-self: center;
  }
  .hero-card-visual .dental-chart-wrap {
    width: auto;
    max-width: min(200px, 72vw);
    margin: 0 auto;
  }
  .hero-card-visual .dental-chart-label {
    font-size: 0.75rem;
  }

  .devis-card {
    padding: 1rem;
  }
  .devis-card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .devis-card-footer .btn {
    width: 100%;
    white-space: normal;
    text-align: center;
  }
  .devis-card-meta {
    width: 100%;
  }

  .todo-item,
  .rdv-mini,
  .finance-cabinet-card,
  .card,
  .docs-sign-prompt {
    max-width: 100%;
    min-width: 0;
  }
  .todo-info,
  .rdv-info {
    min-width: 0;
  }
  .todo-info-meta {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .todo-info-meta .chip {
    max-width: 100%;
    white-space: normal;
  }

  .tab-btn {
    padding: 0.6rem 0.85rem;
    font-size: 0.82rem;
  }

  .encart--flex {
    flex-direction: column;
  }
  .encart-body {
    min-width: 0;
    width: 100%;
  }
  .encart-visual {
    width: 100%;
    max-width: 100%;
    align-self: center;
  }
  .encart-visual .dental-chart-wrap {
    width: auto;
    max-width: min(180px, 65vw);
    margin: 0 auto;
  }

  .finance-ech-steps { flex-wrap: wrap; }
  .finance-ech-step { min-width: calc(50% - 0.2rem); flex: 0 0 auto; }

  .finance-global-solde-amount { font-size: 1.1rem; }
  .finance-cabinets-grid { grid-template-columns: 1fr; }

  .actes-table { font-size: 0.75rem; }
  .actes-table th, .actes-table td { padding: 0.5rem; }

  .echeance-cards {
    gap: 0.5rem;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
  .echeance-card { min-width: min(140px, 78vw); }

  .detail-header-amount {
    width: 100%;
    text-align: left;
  }

  .docs-sign-prompt {
    padding: 1rem;
  }

  .overlay-panel { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; align-self: flex-end; }
}

/* ============================================================
   RESPONSIVE — Desktop (≥ 1024px)
   ============================================================ */

@media (min-width: 1024px) {
  .topbar { display: flex; }

  .detail-layout {
    grid-template-columns: 1fr 340px;
  }
  .detail-rail {
    display: block;
    position: sticky;
    top: 1rem;
    align-self: start;
  }
  .sticky-bar { display: none; }
}

/* ---- Utilities ---- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1.25rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.75rem; }
.mt-3 { margin-top: 1rem; }
.text-sage { color: var(--sage-ink); }
.text-clay { color: var(--clay-ink); }
.text-amber { color: var(--amber-ink); }
.text-blue { color: var(--blue-ink); }
.text-soft { color: var(--ink-soft); }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 0.82rem; }
.fs-xs { font-size: 0.72rem; }

/* ---- Schéma dentaire ---- */

.dental-chart-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  max-width: 100%;
}
.dental-chart-wrap--sm { gap: 0.15rem; }

.dental-chart {
  display: block;
  overflow: hidden;
  width: auto;
  height: auto;
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 409 / 694;
}
/* Ratio viewBox 409×694 — hauteur plafonnée pour ne pas envahir la page */
.dental-chart--sm { max-height: 88px;  max-width: min(160px, 48vw); }
.dental-chart--md { max-height: 112px; max-width: min(200px, 55vw); }
.dental-chart--lg { max-height: 136px; max-width: min(240px, 62vw); }
.dental-chart--pro {
  width: auto;
  height: auto;
}
.dental-chart--pro .dental-tooth {
  transition: opacity 0.2s ease;
}
.dental-chart--pro .dental-tooth:not(.dental-tooth--active) .dental-tooth-body {
  opacity: 0.92;
}
.dental-chart--pro .dental-tooth--active {
  filter: drop-shadow(0 2px 4px rgba(232,119,46,0.35));
}
.dental-chart--pro .dental-tooth--active .dental-tooth-outline {
  stroke-width: 1.8;
}
.dental-chart--pro .dental-tooth-label {
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(0,0,0,0.2);
  stroke-width: 0.4px;
  font-family: var(--sans);
}

.dental-chart-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sage-ink);
  text-align: center;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.dental-chart-wrap--sm .dental-chart-label { font-size: 0.6rem; }
.dental-chart-wrap--lg .dental-chart-label { font-size: 0.82rem; }
