/* Nursalys — design system.
   Un logiciel de soins se lit debout, dans un couloir, parfois avec des gants et
   une seule main : hiérarchie franche, cibles larges, couleur réservée au sens
   (urgence, fait, à faire) plutôt qu'à la décoration. */

:root {
  /* Accent : un lime acidulé. Vif sur les actions, sourd partout ailleurs —
     la couleur reste au service du sens, elle ne décore pas l'interface.
     Le lime est trop lumineux pour porter du texte blanc : toute surface
     accentuée se lit en --on-accent (encre profonde), jamais en blanc. */
  --accent-50: #f5fee8;
  --accent-100: #e8fcc4;
  --accent-200: #d5f892;
  --accent-300: #bcf04f;
  --accent-400: #a6e022;   /* la signature : boutons, états actifs */
  --accent-500: #8cc413;
  --accent-600: #6f9e0c;   /* contours et focus (3:1 sur blanc) */
  --accent-700: #567a0d;   /* texte et liens (4.5:1 sur blanc) */
  --accent-800: #3f5a10;
  --accent-900: #233310;
  --on-accent: #15220c;    /* encre posée sur une surface lime */

  /* Neutres légèrement verts : le gris froid jurait avec l'acidulé. */
  --ink-900: #0f1a0d;
  --ink-800: #1f2b1d;
  --ink-700: #334034;
  --ink-600: #4a5a4c;
  --ink-500: #5f7060;
  --ink-400: #9aa89b;
  --ink-300: #c8d2c8;

  --line: #e3e9e0;
  --line-soft: #f0f4ee;
  --surface: #ffffff;
  --surface-sunken: #f8faf6;
  --ground: #f6f8f3;

  /* « Fait » passe en teal : avec un accent lime, un vert d'état ne se
     distinguerait plus de la couleur de marque. */
  --ok-50: #effcf9;  --ok-200: #99e8dc;  --ok-600: #0f7a70;  --ok-700: #115e56;
  --warn-50: #fffbeb; --warn-200: #fde68a; --warn-600: #d97706; --warn-700: #b45309;
  --alert-50: #fef2f2; --alert-200: #fecaca; --alert-600: #dc2626; --alert-700: #b91c1c;
  --violet-50: #f5f3ff; --violet-700: #6d28d9;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 26, 13, .05);
  --shadow: 0 1px 3px rgba(15, 26, 13, .07), 0 1px 2px rgba(15, 26, 13, .04);
  --shadow-lg: 0 12px 28px -8px rgba(15, 26, 13, .18), 0 4px 10px -4px rgba(15, 26, 13, .1);

  --header-h: 64px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-900);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.022em; margin: 0; }
h2 { font-size: 1.0625rem; font-weight: 650; letter-spacing: -.012em; margin: 0; }
h3 { font-size: .9375rem; font-weight: 650; margin: 0 0 .6rem; }
p { margin: 0; }
a { color: var(--accent-700); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-500); }
.small { font-size: .8125rem; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack-sm > * + * { margin-top: .5rem; }
.stack > * + * { margin-top: 1rem; }
.spacer { flex: 1; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.85;
        stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.icon.xl { width: 34px; height: 34px; stroke-width: 1.4; }

/* ============================================================== ossature */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 0 .75rem 1rem;
  position: sticky; top: 0; height: 100vh;
}

.logo { display: flex; align-items: center; gap: .625rem; height: var(--header-h);
        padding: 0 .5rem; text-decoration: none; color: inherit; }
.logo:hover { text-decoration: none; }
.logo-mark { flex-shrink: 0; }
.logo-text { display: block; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.03em; color: var(--ink-900); }
.logo-sub { display: block; font-size: .6875rem; color: var(--ink-500); letter-spacing: .01em;
            max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: .5rem; }
.nav-label { font-size: .6875rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
             color: var(--ink-400); padding: 1rem .75rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .5625rem .75rem; border-radius: var(--r-sm);
  color: var(--ink-700); font-weight: 500; font-size: .9375rem; text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: var(--surface-sunken); text-decoration: none; }
.nav a.active { background: var(--accent-50); color: var(--accent-700); font-weight: 600; }
.nav a.active .icon { stroke-width: 2; }
.nav .count { margin-left: auto; font-size: .75rem; font-weight: 700; color: var(--ink-400); }
.nav a.active .count { color: var(--accent-600); }
.nav .dot { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
            background: var(--alert-600); color: #fff; font-size: .6875rem; font-weight: 700;
            display: grid; place-items: center; }

.sidebar-foot { margin-top: auto; padding: .75rem; }
.sidebar-note { font-size: .6875rem; line-height: 1.5; color: var(--ink-400);
                display: flex; gap: .4rem; align-items: flex-start; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ================================================================= header */

.topbar {
  height: var(--header-h); flex-shrink: 0; position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .88); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
}
.topbar-logo { display: none; }

/* Le pouls de la journée, dans l'en-tête : lisible depuis n'importe quel écran. */
.pulse { display: flex; align-items: center; gap: .25rem; }
.pulse-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .3125rem .625rem; border-radius: var(--r-sm);
  color: var(--ink-600); text-decoration: none; font-size: .8125rem; white-space: nowrap;
  transition: background .12s ease;
}
a.pulse-item:hover { background: var(--surface-sunken); text-decoration: none; color: var(--ink-900); }
.pulse-value { font-weight: 700; font-size: .9375rem; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.pulse-label { color: var(--ink-500); }
.pulse-item.is-alert { color: var(--alert-700); }
.pulse-item.is-alert .pulse-value { color: var(--alert-700); }
.pulse-item.is-warn { color: var(--warn-700); }
.pulse-item.is-warn .pulse-value { color: var(--warn-700); }
.pulse-sep { width: 1px; height: 26px; background: var(--line); margin: 0 .25rem; }

/* Anneau de progression de la tournée : une jauge lue d'un coup d'œil. */
.ring { width: 34px; height: 34px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 3.5; }
.ring .track { stroke: var(--line); }
.ring .value { stroke: var(--accent-600); stroke-linecap: round;
               transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dasharray .4s ease; }
.ring.done .value { stroke: var(--ok-600); }
.ring-text { font-size: 10.5px; font-weight: 700; fill: var(--ink-800);
             text-anchor: middle; dominant-baseline: central; stroke: none; }

.icon-button {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-sm);
  border: none; background: transparent; color: var(--ink-600); cursor: pointer;
  text-decoration: none;
}
.icon-button:hover { background: var(--surface-sunken); color: var(--ink-900); text-decoration: none; }
.icon-button .badge-dot {
  position: absolute; top: 5px; right: 4px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--alert-600); color: #fff;
  font-size: .625rem; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface);
}

/* Menu de profil : <details> natif, donc fonctionnel sans JavaScript. */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .4rem;
                  padding: .25rem .4rem .25rem .25rem; border-radius: 999px; transition: background .12s; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-sunken); }
.menu[open] > summary { background: var(--surface-sunken); }
.menu > summary .icon { color: var(--ink-400); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 40;
  min-width: 268px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: .375rem;
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-head { display: flex; align-items: center; gap: .65rem; padding: .625rem .625rem .75rem; }
.menu-head strong { display: block; font-size: .9375rem; }
/* :not(.avatar) est indispensable — sans lui cette règle, plus spécifique que
   .avatar, repasse la pastille en display:block et décentre les initiales. */
.menu-head span:not(.avatar) { display: block; font-size: .75rem; color: var(--ink-500); }
.menu-sep { height: 1px; background: var(--line-soft); margin: .25rem 0; }
.menu-item {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  padding: .5625rem .625rem; border-radius: var(--r-sm);
  color: var(--ink-700); font-size: .875rem; font-weight: 500; text-decoration: none;
  border: none; background: none; cursor: pointer; font-family: inherit; text-align: left;
}
.menu-item:hover { background: var(--surface-sunken); color: var(--ink-900); text-decoration: none; }
.menu-item .icon { color: var(--ink-400); }
.menu-item:hover .icon { color: var(--ink-600); }
.menu-swatches { display: flex; gap: .3rem; padding: .3rem .625rem .5rem; }
.menu-swatches input[type="color"] { width: 26px; height: 26px; padding: 0; border-radius: 999px;
                                      border: none; cursor: pointer; background: none; margin: 0; }

/* Le champ couleur natif peint sa pastille dans un cadre interne : arrondir
   l'input ne suffit pas, le rectangle reste visible dedans. Il faut aplatir le
   conteneur et arrondir la pastille elle-même. */
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 999px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 999px; }
input[type="color"] { -webkit-appearance: none; appearance: none; }
.menu-swatches input[type="color"] { box-shadow: 0 0 0 1px var(--line); }

.avatar {
  border-radius: 999px; color: #fff; display: inline-grid; place-items: center;
  font-size: .75rem; font-weight: 650; flex-shrink: 0; width: 32px; height: 32px;
  letter-spacing: .02em;
}
.avatar.sm { width: 26px; height: 26px; font-size: .625rem; }
.avatar.lg { width: 42px; height: 42px; font-size: .9375rem; }

/* ================================================================ contenu */

.content { padding: 1.5rem; width: 100%; max-width: 1240px; margin: 0 auto; }
.content.narrow { max-width: 880px; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
             gap: 1rem; margin-bottom: 1.25rem; }
.page-head .sub { color: var(--ink-500); font-size: .875rem; margin-top: .1rem; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.back-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-500);
             font-size: .8125rem; font-weight: 500; margin-bottom: .75rem; }
.back-link:hover { color: var(--ink-800); text-decoration: none; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
                 margin: 1.75rem 0 .875rem; }
.section-title h2 { display: flex; align-items: center; gap: .5rem; }
.section-title .icon { color: var(--ink-400); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
        box-shadow: var(--shadow-sm); }
.card-head { padding: .875rem 1.125rem; border-bottom: 1px solid var(--line-soft);
             display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-body { padding: 1.125rem; }
.card-list { list-style: none; margin: 0; padding: 0; }
.card-list > li { padding: .75rem 1.125rem; border-bottom: 1px solid var(--line-soft);
                  display: flex; align-items: center; gap: .875rem; }
.card-list > li:last-child { border-bottom: none; }
.card-list > li.linkish { padding: 0; }
.card-list > li.linkish > a { display: flex; align-items: center; gap: .875rem; width: 100%;
                              padding: .75rem 1.125rem; color: inherit; text-decoration: none; }
.card-list > li.linkish > a:hover { background: var(--surface-sunken); text-decoration: none; }

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 1.25rem; align-items: start; }
.split.wide-right { grid-template-columns: minmax(0, 1fr) 380px; }

.badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px;
         padding: .1875rem .5rem; font-size: .75rem; font-weight: 600; white-space: nowrap;
         background: var(--surface-sunken); color: var(--ink-600); border: 1px solid transparent; }
.badge .icon { width: 13px; height: 13px; stroke-width: 2; }
.badge.ok { background: var(--ok-50); color: var(--ok-700); }
.badge.warn { background: var(--warn-50); color: var(--warn-700); }
.badge.alert { background: var(--alert-50); color: var(--alert-700); }
.badge.accent { background: var(--accent-50); color: var(--accent-700); }
.badge.violet { background: var(--violet-50); color: var(--violet-700); }
.badge.outline { background: transparent; border-color: var(--line); color: var(--ink-500); }

.alert-box { border-radius: var(--r); padding: .75rem .875rem; font-size: .875rem;
             display: flex; gap: .625rem; align-items: flex-start; margin-bottom: 1rem; }
.alert-box .icon { flex-shrink: 0; margin-top: 1px; }
.alert-box.error { background: var(--alert-50); color: var(--alert-700); }
.alert-box.success { background: var(--ok-50); color: var(--ok-700); }
.alert-box.warning { background: var(--warn-50); color: var(--warn-700); border: 1px solid var(--warn-200); }
.alert-box.info { background: var(--accent-50); color: var(--accent-700); }

.empty { text-align: center; padding: 3rem 1.5rem; color: var(--ink-500); }
.empty .icon { color: var(--ink-300); margin-bottom: .75rem; }
.empty strong { display: block; color: var(--ink-800); font-size: .9375rem; margin-bottom: .25rem; }
.empty p { max-width: 42ch; margin: 0 auto; font-size: .875rem; }
.empty .actions { margin-top: 1.25rem; }

/* ============================================================= contrôles */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-700); font: inherit; font-size: .875rem; font-weight: 550;
  padding: .5rem .875rem; min-height: 40px; cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
  white-space: nowrap;
}
.button:hover { background: var(--surface-sunken); border-color: var(--ink-300); text-decoration: none; }
.button:active { transform: translateY(.5px); }
.button:focus-visible { outline: 2px solid var(--accent-600); outline-offset: 2px; }
.button.primary { background: var(--accent-400); border-color: var(--accent-400); color: var(--on-accent); box-shadow: var(--shadow-sm); font-weight: 650; }
.button.primary:hover { background: var(--accent-300); border-color: var(--accent-300); }
.button.success { background: var(--ok-600); border-color: var(--ok-600); color: #fff; }
.button.success:hover { background: var(--ok-700); border-color: var(--ok-700); }
.button.ghost { border-color: transparent; background: transparent; color: var(--ink-600); }
.button.ghost:hover { background: var(--surface-sunken); color: var(--ink-900); }
.button.danger-ghost { border-color: transparent; background: transparent; color: var(--alert-700); }
.button.danger-ghost:hover { background: var(--alert-50); }
.button.sm { min-height: 32px; padding: .3125rem .625rem; font-size: .8125rem; border-radius: var(--r-sm); }
.button.lg { min-height: 46px; padding: .6875rem 1.125rem; font-size: .9375rem; }
.button.block { width: 100%; }
.button[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 550; font-size: .8125rem; color: var(--ink-700); margin-bottom: .875rem; }
label > small { display: inline; font-weight: 400; color: var(--ink-400); margin-left: .3rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3125rem;
  border: 1px solid var(--ink-300); border-radius: var(--r-sm);
  padding: .5rem .6875rem; font: inherit; font-size: .9375rem; font-weight: 400;
  color: var(--ink-900); background: var(--surface); min-height: 40px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-400); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-100);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
select { appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .625rem center; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; margin: 0;
                                               accent-color: var(--accent-600); flex-shrink: 0; }
input[type="color"] { padding: 0; height: 34px; width: 34px; border-radius: 999px;
                      border: none; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
input[type="date"] { min-width: 9.5rem; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.field-row-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .875rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: .875rem 1rem; margin: 0 0 .875rem; }
legend { font-size: .8125rem; font-weight: 650; padding: 0 .35rem; color: var(--ink-700); }
.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400;
         font-size: .875rem; margin: 0 1rem .35rem 0; color: var(--ink-700); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); gap: .375rem; }
.check-grid label { display: flex; align-items: center; gap: .55rem; font-weight: 400; font-size: .875rem;
                    border: 1px solid var(--line); border-radius: var(--r-sm); padding: .5rem .6875rem;
                    margin: 0; cursor: pointer; transition: border-color .12s, background .12s; }
.check-grid label:hover { background: var(--surface-sunken); border-color: var(--ink-300); }
.check-grid label:has(:checked) { border-color: var(--accent-500); background: var(--accent-50); }
.check-grid .ngap { margin-left: auto; font-size: .75rem; color: var(--ink-400); font-variant-numeric: tabular-nums; }
.inline-form { display: inline-flex; }

/* Segments : remplacent les onglets, plus proches d'un contrôle d'application. */
.segments { display: inline-flex; gap: 2px; background: var(--surface-sunken);
            border: 1px solid var(--line); padding: 3px; border-radius: var(--r); }
.segments a, .segments button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .375rem .75rem;
  border-radius: 9px; font-size: .8125rem; font-weight: 550; color: var(--ink-600);
  text-decoration: none; border: none; background: none; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.segments a:hover { color: var(--ink-900); text-decoration: none; }
.segments a.active { background: var(--surface); color: var(--ink-900); box-shadow: var(--shadow-sm); }
.segments .n { font-size: .75rem; color: var(--ink-400); font-variant-numeric: tabular-nums; }
.segments a.active .n { color: var(--accent-600); }

.toolbar { display: flex; flex-wrap: wrap; gap: .625rem; align-items: center; margin-bottom: 1.125rem; }
.search { position: relative; flex: 1; min-width: 240px; max-width: 420px; }
.search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--ink-400); }
.search input { margin-top: 0; padding-left: 2.375rem; }

/* ================================================== feuille (panneau modal) */

.sheet[open] > summary { position: fixed; inset: 0; z-index: 50; background: rgba(11, 18, 32, .38);
                         backdrop-filter: blur(2px); border-radius: 0; }
.sheet > summary { list-style: none; cursor: pointer; }
.sheet > summary::-webkit-details-marker { display: none; }
.sheet-body {
  position: fixed; z-index: 51; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); overflow-y: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: sheet-in .16s ease-out;
}
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.985); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
              padding: 1.125rem 1.25rem; border-bottom: 1px solid var(--line-soft);
              position: sticky; top: 0; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; }
.sheet-content { padding: 1.25rem; }
.sheet-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem;
              border-top: 1px solid var(--line-soft); position: sticky; bottom: 0; background: var(--surface); }

/* ================================================================ tournée */

.visit { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
         margin-bottom: .625rem; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.visit:hover { border-color: var(--ink-300); }
.visit.current { border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-100); }
.visit.done { background: var(--surface-sunken); }
.visit.done .visit-name { color: var(--ink-500); }
.visit-head { display: flex; align-items: center; gap: .875rem; padding: .8125rem 1rem; }
.visit-order { display: flex; flex-direction: column; align-items: center; gap: .1rem; width: 2.25rem; flex-shrink: 0; }
.visit-order .button { min-height: 20px; padding: 0 .2rem; border: none; background: none; color: var(--ink-300); }
.visit-order .button:hover { color: var(--ink-700); background: none; }
.visit-num { width: 26px; height: 26px; border-radius: 999px; background: var(--surface-sunken);
             color: var(--ink-600); display: grid; place-items: center; font-size: .75rem; font-weight: 700;
             border: 1px solid var(--line); }
.visit.done .visit-num { background: var(--ok-50); color: var(--ok-700); border-color: var(--ok-200); }
.visit.current .visit-num { background: var(--accent-400); color: var(--on-accent); border-color: var(--accent-400); }
.visit-time { font-weight: 700; font-size: .9375rem; font-variant-numeric: tabular-nums; width: 3rem; flex-shrink: 0; }
.visit-main { flex: 1; min-width: 0; }
.visit-name { font-weight: 650; font-size: .9375rem; display: block; }
.visit-sub { color: var(--ink-500); font-size: .8125rem; display: block; }
.visit-body { border-top: 1px solid var(--line-soft); padding: .875rem 1rem 1rem; background: var(--surface-sunken); }
.visit-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.125rem; color: var(--ink-600);
              font-size: .8125rem; margin-bottom: .875rem; }
.visit-meta > * { display: inline-flex; align-items: center; gap: .35rem; }
.visit-meta .icon { color: var(--ink-400); }
.visit-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .75rem; }

.care { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
        padding: .5625rem .75rem; margin-bottom: .375rem; cursor: pointer; font: inherit;
        min-height: 46px; transition: border-color .12s, background .12s; }
.care:hover { border-color: var(--accent-500); }
.care .box { width: 22px; height: 22px; border-radius: 6px; border: 1.75px solid var(--ink-300);
             display: grid; place-items: center; flex-shrink: 0; color: transparent; background: var(--surface); }
.care.done .box { background: var(--ok-600); border-color: var(--ok-600); color: #fff; }
.care.done .care-label { text-decoration: line-through; color: var(--ink-400); }
.care-label { flex: 1; font-weight: 500; font-size: .875rem; }
.care-note { display: block; font-weight: 400; font-size: .75rem; color: var(--ink-500); text-decoration: none; }

.progress { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-600); border-radius: 999px;
                   transition: width .3s ease; }
.progress.done > span { background: var(--ok-600); }

.nurse-stripe { width: 4px; align-self: stretch; border-radius: 999px; flex-shrink: 0; min-height: 34px; }

/* Bandeau calendrier */
.daystrip { display: flex; gap: .25rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.daystrip a { display: flex; flex-direction: column; align-items: center; gap: .1rem;
              min-width: 3.25rem; padding: .4375rem .35rem; border-radius: var(--r);
              text-decoration: none; color: var(--ink-600); border: 1px solid transparent; }
.daystrip a:hover { background: var(--surface); border-color: var(--line); text-decoration: none; }
.daystrip .dow { font-size: .6875rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-400); }
.daystrip .dom { font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.daystrip a.today .dom { color: var(--accent-700); }
.daystrip a.active { background: var(--accent-400); border-color: var(--accent-400); }
.daystrip a.active .dow, .daystrip a.active .dom { color: var(--on-accent); }
.daystrip .load { display: flex; gap: 2px; margin-top: .15rem; height: 4px; }
.daystrip .load i { width: 4px; height: 4px; border-radius: 999px; background: var(--ink-300); }
.daystrip a.active .load i { background: rgba(21, 34, 12, .45); }

/* =========================================================== transmissions */

.tx { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
      margin-bottom: .625rem; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.tx:hover { border-color: var(--ink-300); box-shadow: var(--shadow); }
.tx.urgent { border-left: 3px solid var(--alert-600); }
.tx.important { border-left: 3px solid var(--warn-600); }
.tx.unread { background: linear-gradient(90deg, var(--accent-50) 0 3px, var(--surface) 3px); }
.tx.resolved { opacity: .78; }

.tx > summary { list-style: none; cursor: pointer; padding: .875rem 1.125rem; display: block; }
.tx > summary::-webkit-details-marker { display: none; }
.tx > summary:hover { background: var(--surface-sunken); }
.tx[open] > summary { background: var(--surface-sunken); border-bottom: 1px solid var(--line-soft); }

.tx-top { display: flex; align-items: center; gap: .625rem; }
/* Le nom du patient porte l'information : il vient en premier, en gras. */
.tx-patient { font-weight: 680; font-size: .9375rem; color: var(--ink-900); letter-spacing: -.01em; }
.tx-target { color: var(--ink-500); font-size: .8125rem; }
.tx-target::before { content: "·"; margin: 0 .4rem; color: var(--ink-300); }
.tx-when { margin-left: auto; color: var(--ink-400); font-size: .75rem; white-space: nowrap; }
.tx-chevron { color: var(--ink-400); transition: transform .15s ease; }
.tx[open] .tx-chevron { transform: rotate(180deg); }
.tx-summary { color: var(--ink-600); font-size: .875rem; margin-top: .3125rem;
              display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.tx[open] .tx-summary { display: none; }
.tx-meta { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.tx-author { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-500); font-size: .75rem; }
.tx-unread-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent-600); flex-shrink: 0; }

.tx-body { padding: 1rem 1.125rem 1.125rem; }
.dar { display: grid; gap: .625rem; margin: 0; }
.dar-line { display: grid; grid-template-columns: 5.25rem 1fr; gap: .875rem; }
.dar-line dt { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
               color: var(--ink-400); padding-top: .15rem; }
.dar-line dd { margin: 0; white-space: pre-wrap; color: var(--ink-700); font-size: .9375rem; }

.comments { list-style: none; margin: 1rem 0 0; padding: 1rem 0 0; border-top: 1px solid var(--line-soft);
            display: grid; gap: .625rem; }
.comments li { display: flex; gap: .5625rem; }
.comment-bubble { background: var(--surface-sunken); border-radius: var(--r); padding: .5rem .75rem; flex: 1; }
.comment-bubble p { margin: .2rem 0 0; white-space: pre-wrap; font-size: .875rem; color: var(--ink-700); }
.tx-foot { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
           margin-top: 1rem; padding-top: .875rem; border-top: 1px solid var(--line-soft); }
.tx-readers { margin-left: auto; color: var(--ink-400); font-size: .75rem;
              display: inline-flex; align-items: center; gap: .35rem; }
.comment-form { display: flex; gap: .4rem; flex: 1; min-width: 220px; }
.comment-form input { margin-top: 0; min-height: 36px; font-size: .875rem; }

/* ================================================================ patients */

.patient-card { display: block; background: var(--surface); border: 1px solid var(--line);
                border-radius: var(--r-lg); padding: 1rem; text-decoration: none; color: inherit;
                transition: border-color .12s, box-shadow .12s, transform .12s; height: 100%; }
.patient-card:hover { border-color: var(--accent-500); box-shadow: var(--shadow); text-decoration: none; }
.patient-card.archived { background: var(--surface-sunken); border-style: dashed; }
.patient-card.archived .patient-name { color: var(--ink-500); }
.patient-head { display: flex; align-items: flex-start; gap: .75rem; }
.patient-name { font-weight: 650; font-size: .9375rem; letter-spacing: -.01em; display: block; }
.patient-sub { color: var(--ink-500); font-size: .75rem; }
.patient-lines { margin-top: .75rem; display: grid; gap: .25rem; color: var(--ink-600); font-size: .8125rem; }
.patient-lines > span { display: flex; align-items: center; gap: .4rem; }
.patient-lines .icon { color: var(--ink-400); }
.patient-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .875rem; }

.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .625rem;
                font-size: .875rem; color: var(--ink-700); }
.contact-list li { display: flex; gap: .625rem; align-items: flex-start; }
.contact-list .icon { color: var(--ink-400); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; color: var(--ink-500); font-weight: 600; font-size: .6875rem;
     text-transform: uppercase; letter-spacing: .05em; padding: .625rem 1.125rem;
     border-bottom: 1px solid var(--line-soft); }
td { padding: .6875rem 1.125rem; border-bottom: 1px solid var(--line-soft); color: var(--ink-700); }
tr:last-child td { border-bottom: none; }

code.invite { background: var(--ink-900); color: #fff; border-radius: var(--r-sm);
              padding: .5rem .875rem; font-size: 1rem; font-weight: 700; letter-spacing: .16em;
              font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ===================================================================== carte */

.map-wrap { background: var(--surface-sunken); border-radius: var(--r-lg);
            border: 1px solid var(--line); overflow: hidden; }
/* Le cadre épouse la carte : pas de bande vide quand la colonne est plus large. */
.map-wrap { width: fit-content; max-width: 100%; margin: 0 auto; }
.map-canvas { position: relative; overflow: hidden; max-width: 100%; }
.map-tile { position: absolute; width: 256px; height: 256px; user-select: none;
            -webkit-user-drag: none; }
.map-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-overlay .map-stop { pointer-events: auto; }

/* Le tracé porte un liseré blanc : lisible aussi bien sur une forêt que sur une zone dense. */
.map-route-halo { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round;
                  stroke-linejoin: round; opacity: .85; }
.map-route { fill: none; stroke: var(--accent-600); stroke-width: 3.5; stroke-linecap: round;
             stroke-linejoin: round; }
.map-stop .pin { fill: var(--accent-600); stroke: #fff; stroke-width: 3;
                 filter: drop-shadow(0 1px 2px rgba(11, 18, 32, .35)); }
.map-stop.done .pin { fill: var(--ok-600); }
.map-stop text { fill: #fff; font-size: 12px; font-weight: 700; text-anchor: middle;
                 dominant-baseline: central; stroke: none; }
.map-home circle { fill: var(--surface); stroke: var(--ink-700); stroke-width: 2.5;
                   filter: drop-shadow(0 1px 2px rgba(11, 18, 32, .3)); }
.map-home path { fill: var(--ink-700); stroke: none; }
.map-credit { position: absolute; right: 0; bottom: 0; background: rgba(255, 255, 255, .82);
              color: var(--ink-500); font-size: .625rem; padding: .1rem .35rem;
              border-top-left-radius: 5px; }
.map-legend { display: flex; flex-wrap: wrap; gap: .875rem; padding: .75rem 1rem;
              border-top: 1px solid var(--line); background: var(--surface);
              font-size: .8125rem; color: var(--ink-600); align-items: center; }
.map-legend b { color: var(--ink-900); font-variant-numeric: tabular-nums; }
.map-missing { padding: 2.5rem 1.5rem; text-align: center; color: var(--ink-500); font-size: .875rem; }

/* Bandeau de copie hors ligne : l'utilisatrice doit savoir qu'elle ne lit pas
   l'état courant du cabinet. */
.offline-banner {
  display: flex; align-items: center; gap: .5rem; justify-content: center;
  background: var(--warn-50); color: var(--warn-700);
  border-bottom: 1px solid var(--warn-200);
  padding: .5rem 1rem; font-size: .8125rem; font-weight: 550;
  position: sticky; top: var(--header-h); z-index: 25;
}

.billing-banner {
  display: flex; align-items: center; gap: .625rem; flex-wrap: wrap;
  background: var(--accent-50); color: var(--accent-900);
  border-bottom: 1px solid var(--accent-200);
  padding: .625rem 1.25rem; font-size: .8125rem;
}
.billing-banner.locked { background: var(--warn-50); color: var(--warn-700);
                         border-bottom-color: var(--warn-200); }
.billing-banner .button { margin-left: auto; }

.plan { display: flex; flex-direction: column; }
.plan.current { border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-100); }
.plan-price { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; margin: .35rem 0 .5rem; }
.plan-features { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .45rem;
                 font-size: .8125rem; color: var(--ink-600); }
.plan-features li { display: flex; gap: .5rem; align-items: flex-start; }
.plan-features .icon { color: var(--ok-600); margin-top: 2px; }

/* ======================================================= authentification */

.page-auth { background: var(--surface); }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-form { display: flex; flex-direction: column; justify-content: center;
             padding: 3rem 2.5rem; max-width: 470px; margin: 0 auto; width: 100%; }
.auth-form h1 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-aside { background: linear-gradient(160deg, var(--accent-800), var(--accent-900));
              color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-claim { font-size: 1.55rem; font-weight: 700; line-height: 1.32; margin: 2rem 0 1rem; letter-spacing: -.02em; }
.auth-text { color: rgba(255, 255, 255, .8); margin: 0; font-size: .9375rem; }
.auth-list { list-style: none; padding: 0; margin: 2.25rem 0 0; display: grid; gap: .625rem;
             color: rgba(255, 255, 255, .8); font-size: .875rem; }
.auth-list li { display: flex; gap: .625rem; align-items: flex-start; }
.auth-list .icon { color: rgba(255, 255, 255, .55); margin-top: 2px; }

.page-error { display: grid; place-items: center; min-height: 100vh; background: var(--ground); }
.error-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
              padding: 2.5rem; text-align: center; max-width: 440px; box-shadow: var(--shadow); }

/* ============================================================== responsive */

@media (max-width: 1100px) {
  .split, .split.wide-right { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .auth-grid { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .pulse-item.optional { display: none; }
}

@media (max-width: 780px) {
  :root { --header-h: 58px; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; width: 100%;
    flex-direction: row; padding: 0; z-index: 40;
    border-right: none; border-top: 1px solid var(--line);
    box-shadow: 0 -1px 3px rgba(11, 18, 32, .06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar .logo, .sidebar-foot, .nav-label { display: none; }
  .nav { flex-direction: row; margin: 0; width: 100%; }
  .nav a { flex: 1; flex-direction: column; gap: .15rem; font-size: .625rem; font-weight: 550;
           padding: .5rem .2rem; border-radius: 0; justify-content: center; position: relative; }
  .nav a.active { background: transparent; }
  .nav .count { display: none; }
  .nav .dot { position: absolute; top: .3rem; left: 50%; margin-left: 4px; }
  /* Le repère de marque revient dans la barre haute quand la colonne disparaît. */
  .topbar .logo { display: flex; height: auto; padding: 0; margin-right: .25rem; }
  .topbar { padding: 0 .875rem; }
  .pulse-item .pulse-label { display: none; }
  .content { padding: 1rem .875rem calc(4.75rem + env(safe-area-inset-bottom)); }
  .field-row { grid-template-columns: 1fr; }
  .dar-line { grid-template-columns: 1fr; gap: .15rem; }
  .sheet-body { width: 100vw; max-width: none; height: 100vh; max-height: none; border-radius: 0;
                top: 0; left: 0; transform: none; }
  .sheet-head { border-radius: 0; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
