/* ==========================================================================
   Base commune — tokens dérivés, mise en page et composants (ALX-0028).
   Ne pas y mettre de couleur propre à un client : c'est le rôle de theme.css.
   Style : thème de la console Alexime, avec du relief (ombres teintées,
   fonds de blocs dégradés légers, halos de page, effets au survol).
   Sommaire : 1. Tokens  2. Socle  3. Mise en page  4. Composants
              5. Fenêtres et notifications  6. Impression  7. Animations
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  /* Valeurs par défaut, redéfinies dans theme.css. */
  --brand: #1f5f7a;
  --accent: #d9824a;
  --radius: 14px;
  --density: 1; /* 1 = compacte (bureau), 1.2 = confortable (terrain, tablette) */
  --font-body: system-ui, sans-serif;
  --font-display: system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  --success: #2e8a5f;
  --warning: #c98a12;
  --danger: #c2453d;
  --info: #3b73c4;
  --violet: #7a5cc4;

  --ink: #16303d;
  --muted: #5c7180;
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f5f8fa;
  --line: #dfe7ed;
  --line-strong: #c8d5de;

  /* Couleurs dérivées de la marque. */
  --brand-strong: color-mix(in oklab, var(--brand) 80%, black);
  --brand-soft: color-mix(in oklab, var(--brand) 13%, var(--surface));
  --brand-softer: color-mix(in oklab, var(--brand) 6%, var(--surface));
  --brand-ink: var(--brand);
  --on-brand: #ffffff;
  --accent-soft: color-mix(in oklab, var(--accent) 16%, var(--surface));

  /* Fond de page : deux halos (marque, accent) sur un fond clair. */
  --halo-1: color-mix(in oklab, var(--brand) 12%, var(--bg));
  --halo-2: color-mix(in oklab, var(--accent) 11%, var(--bg));
  /* Fond des blocs : dégradé très léger vers la teinte du bloc (--tint). */
  --tint: var(--brand);
  --block-bg: linear-gradient(165deg, var(--surface) 45%, color-mix(in oklab, var(--tint) 5%, var(--surface)));

  /* Ombres teintées de la couleur du texte (plus douces qu'un noir). */
  --shadow-color: 22 48 61;
  --shadow-sm: 0 1px 2px rgb(var(--shadow-color) / 6%), 0 1px 3px rgb(var(--shadow-color) / 5%);
  --shadow-md: 0 2px 4px rgb(var(--shadow-color) / 5%), 0 8px 22px rgb(var(--shadow-color) / 9%);
  --shadow-lg: 0 20px 56px rgb(var(--shadow-color) / 18%);
  --focus: 0 0 0 3px color-mix(in oklab, var(--brand) 30%, transparent);

  --radius-sm: calc(var(--radius) * 0.65);
  --radius-lg: calc(var(--radius) * 1.3);
  --radius-pill: 999px;

  /* Espacements (multipliés par la densité) et hauteur des contrôles. */
  --space-1: calc(4px * var(--density));
  --space-2: calc(8px * var(--density));
  --space-3: calc(12px * var(--density));
  --space-4: calc(16px * var(--density));
  --space-5: calc(24px * var(--density));
  --space-6: calc(32px * var(--density));
  --control-h: calc(40px * var(--density));
  --control-h-sm: calc(32px * var(--density));
  --card-pad: clamp(16px, 2.2vw, calc(24px * var(--density)));

  --fast: 140ms;
  --soft: 220ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --topbar-h: 64px;
  --page-max: none;
  --gutter: clamp(16px, 2.5vw, 40px);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e3eaee;
    --muted: #93a4ae;
    --bg: #0e161b;
    --surface: #162129;
    --surface-2: #1b2831;
    --line: #26343d;
    --line-strong: #34454f;
    --brand-ink: color-mix(in oklab, var(--brand) 55%, white);
    --brand-soft: color-mix(in oklab, var(--brand) 28%, var(--surface));
    --brand-softer: color-mix(in oklab, var(--brand) 14%, var(--surface));
    --accent-soft: color-mix(in oklab, var(--accent) 24%, var(--surface));
    --halo-1: color-mix(in oklab, var(--brand) 22%, var(--bg));
    --halo-2: color-mix(in oklab, var(--accent) 12%, var(--bg));
    --block-bg: linear-gradient(165deg, var(--surface) 45%, color-mix(in oklab, var(--tint) 10%, var(--surface)));
    --shadow-color: 0 0 0;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-md: 0 2px 4px rgb(0 0 0 / 25%), 0 10px 24px rgb(0 0 0 / 30%);
    --shadow-lg: 0 24px 60px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}

/* 2. Socle ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 520px at 8% -8%, var(--halo-1), transparent 70%),
    radial-gradient(900px 480px at 96% 0%, var(--halo-2), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; color: var(--ink); }
h1 { font-size: clamp(1.5rem, 1.25rem + 0.9vw, 2rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }

a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.icon { flex: none; }
.mono { font-family: var(--font-mono); font-size: 0.9em; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--brand); color: var(--on-brand); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* 3. Mise en page ---------------------------------------------------------- */

/* En-tête : collant, translucide et flouté. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid color-mix(in oklab, var(--line) 80%, transparent);
  box-shadow: 0 1px 0 rgb(var(--shadow-color) / 3%), 0 6px 18px rgb(var(--shadow-color) / 4%);
}
.topbar-inner {
  height: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); border-radius: var(--radius-sm); }
.brand:hover { color: var(--ink); }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: calc(var(--radius) * 0.75);
  background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand) 55%, var(--accent)));
  color: var(--on-brand); font: 700 16px/1 var(--font-display);
  box-shadow: 0 2px 6px color-mix(in oklab, var(--brand) 35%, transparent), inset 0 1px 0 rgb(255 255 255 / 25%);
  transition: transform var(--soft) var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-4deg) scale(1.04); }
.brand-name { font: 650 1.05rem/1 var(--font-display); letter-spacing: -0.01em; }

.nav { flex: 1; display: flex; align-items: center; gap: 16px; margin-left: 8px; }
.nav-list { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-link {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 540;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.nav-link:hover { color: var(--ink); background: var(--brand-softer); }
.nav-link.is-active { color: var(--brand-ink); background: var(--brand-soft); }
.nav-link.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -13px; height: 3px; border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--brand), color-mix(in oklab, var(--brand) 40%, var(--accent)));
}

/* Menus déroulants (<details> natif : fonctionne sans JavaScript) */
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; user-select: none; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-chevron { color: var(--muted); transition: transform var(--fast) var(--ease); }
.nav-menu details[open] .nav-chevron { transform: rotate(180deg); }
.nav-menu details[open] > summary { color: var(--ink); background: var(--brand-softer); }
.nav-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30; min-width: 250px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop var(--fast) var(--ease);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-weight: 520; white-space: nowrap;
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.nav-item .icon { color: var(--muted); transition: color var(--fast) var(--ease); }
.nav-item:hover { background: var(--brand-softer); color: var(--ink); transform: translateX(2px); }
.nav-item:hover .icon { color: var(--brand-ink); }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand-ink); }
.nav-item.is-active .icon { color: var(--brand-ink); }
.nav-item-button { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }

/* Compte (tout à droite) */
.user-menu { display: flex; align-items: center; gap: 6px; margin: 0; }
.user-link { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: var(--radius-pill); color: var(--ink); transition: background-color var(--fast) var(--ease); }
.user-link:hover, .user-link.is-active, .user-menu details[open] > .user-link { background: var(--brand-softer); }
.user-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in oklab, var(--accent) 30%, var(--surface)));
  color: color-mix(in oklab, var(--accent) 75%, var(--ink));
  font-weight: 650; font-size: 0.85rem; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 25%, transparent);
}
.user-name { font-weight: 560; font-size: 0.9rem; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown { left: auto; right: 0; min-width: 220px; }
.user-dropdown form { margin: 0; padding-top: 2px; border-top: 1px solid var(--line); }
@media (min-width: 861px) { .nav > .user-menu { margin-left: auto; } }

.nav-toggle {
  display: none; margin-left: auto;
  padding: 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); cursor: pointer;
}

.page {
  flex: 1;
  width: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: clamp(20px, 3.5vw, 36px) var(--gutter) 48px;
  display: flex; flex-direction: column; gap: var(--space-5);
}
.page:focus { outline: none; box-shadow: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.eyebrow { color: var(--brand-ink); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 6px; }
.lead { color: var(--muted); margin-top: 6px; }

.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.86rem; margin-bottom: calc(var(--space-5) * -0.5); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand-ink); text-decoration: underline; }

.footer {
  max-width: var(--page-max); width: 100%; margin: 0 auto;
  padding: 20px var(--gutter) 28px; color: var(--muted); font-size: 0.85rem;
  display: flex; gap: 16px; justify-content: center;
}
.footer a { color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--space-5); }
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-5); align-items: start; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .row { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.grow { flex: 1; }
.title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }

@media (max-width: 960px) { .layout-aside { grid-template-columns: 1fr; } }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; inset: var(--topbar-h) 0 auto 0;
    flex-direction: column; align-items: stretch; margin-left: 0;
    max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto;
    padding: 12px var(--gutter) 20px;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md);
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity var(--soft) var(--ease), transform var(--soft) var(--ease), visibility 0s linear var(--soft);
  }
  .nav.is-open { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
  .nav-list { flex-direction: column; }
  .nav-link { padding: 12px; font-size: 1rem; min-height: 44px; }
  .nav-link.is-active::after { display: none; }
  .nav-dropdown { position: static; box-shadow: none; border: 0; padding: 0 0 6px 12px; min-width: 0; animation: none; background: none; }
  .user-menu { padding-top: 12px; border-top: 1px solid var(--line); }
  .user-name { flex: 1; max-width: none; }
}

/* 4. Composants ------------------------------------------------------------ */

/* Bloc : surface au fond légèrement dégradé, liseré de couleur optionnel.
   `--tint` donne la teinte (marque par défaut) : .tone-* la change. */
.card {
  position: relative;
  background: var(--block-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--card-pad);
}
.card-accent { border-top: 3px solid var(--tint); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--space-4); }
.card-title { font-size: 0.78rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--space-3); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table-wrap { margin: 0; }
.card-head-padded { padding: var(--card-pad) var(--card-pad) 0; }
.card-pad { padding: 0 var(--card-pad) var(--card-pad); }
.card-muted { background: var(--brand-softer); border-style: dashed; box-shadow: none; }

/* Blocs cliquables : relief au survol. */
a.card, .card-link, .tile, .stat, .note-card {
  transition: transform var(--soft) var(--ease), box-shadow var(--soft) var(--ease), border-color var(--soft) var(--ease);
}
a.card:hover, .card-link:hover, .tile:hover, .stat:hover, .note-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: color-mix(in oklab, var(--tint) 35%, var(--line));
}
a.card:active, .stat:active, .note-card:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

/* Teintes : fond d'icône, liseré, dégradé des blocs. */
.tone-brand { --tint: var(--brand); }
.tone-accent { --tint: var(--accent); }
.tone-success { --tint: var(--success); }
.tone-warning { --tint: var(--warning); }
.tone-danger { --tint: var(--danger); }
.tone-info { --tint: var(--info); }
.tone-violet { --tint: var(--violet); }

/* Accueil : salutation, indicateurs, tuiles par domaine */
.greeting h1 { font-size: clamp(1.8rem, 1.4rem + 1.4vw, 2.5rem); font-weight: 700; letter-spacing: -0.02em; }
.greeting .lead { margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-4); }
.stat {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
  padding: var(--space-4) calc(var(--space-4) + 2px);
  background: var(--block-bg); color: var(--ink); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.stat:hover { color: var(--ink); }
.stat-icon {
  grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, color-mix(in oklab, var(--tint) 16%, var(--surface)), color-mix(in oklab, var(--tint) 26%, var(--surface)));
  color: color-mix(in oklab, var(--tint) 85%, var(--ink));
}
.stat-label { color: var(--muted); font-size: 0.84rem; }
.stat-value { font: 650 1.55rem/1.1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: var(--space-4); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-height: 170px;
  padding: calc(var(--space-5) - 2px) var(--space-5) var(--space-4); overflow: hidden;
  background: linear-gradient(160deg, var(--surface) 40%, color-mix(in oklab, var(--tint) 9%, var(--surface)));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--tint), color-mix(in oklab, var(--tint) 30%, var(--surface))); }
.tile:nth-child(4n + 2) { --tint: var(--accent); }
.tile:nth-child(4n + 3) { --tint: var(--success); }
.tile:nth-child(4n + 4) { --tint: var(--violet); }
.tile-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.tile-desc { color: var(--muted); font-size: 0.88rem; }
.tile-links { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tile-links a {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--radius-pill);
  color: var(--ink); text-decoration: none; font-weight: 560; font-size: 0.9rem;
  background: color-mix(in oklab, var(--tint) 10%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tint) 14%, transparent);
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.tile-links a:hover { background: color-mix(in oklab, var(--tint) 20%, var(--surface)); transform: translateY(-1px); }
.tile-links a .icon { color: color-mix(in oklab, var(--tint) 80%, var(--ink)); }

/* Boutons : un seul bouton principal (.btn) par écran ; les autres en secondaire ou discret. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 calc(16px * var(--density));
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 88%, white), var(--brand));
  color: var(--on-brand);
  font: 600 0.94rem/1 var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 2px rgb(var(--shadow-color) / 12%), 0 3px 10px color-mix(in oklab, var(--brand) 22%, transparent), inset 0 1px 0 rgb(255 255 255 / 18%);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), filter var(--fast) var(--ease);
}
.btn:hover { color: var(--on-brand); filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 2px 4px rgb(var(--shadow-color) / 12%), 0 6px 16px color-mix(in oklab, var(--brand) 30%, transparent), inset 0 1px 0 rgb(255 255 255 / 18%); }
.btn:active { transform: translateY(0); filter: brightness(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }
.btn:focus-visible { border-radius: var(--radius-pill); box-shadow: var(--focus); }
.btn-secondary {
  background: linear-gradient(180deg, var(--surface), var(--surface-2)); color: var(--ink);
  border-color: var(--line-strong); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  color: var(--brand-ink); background: linear-gradient(180deg, var(--surface), var(--brand-softer));
  border-color: color-mix(in oklab, var(--brand) 40%, var(--line)); box-shadow: var(--shadow-md);
}
.btn-ghost { background: transparent; color: var(--brand-ink); box-shadow: none; }
.btn-ghost:hover { color: var(--brand-ink); background: var(--brand-soft); box-shadow: none; transform: none; }
.btn-danger { background: linear-gradient(180deg, color-mix(in oklab, var(--danger) 88%, white), var(--danger)); box-shadow: 0 3px 10px color-mix(in oklab, var(--danger) 22%, transparent); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 calc(12px * var(--density)); font-size: 0.86rem; }
.btn-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.btn-icon:hover { background: var(--brand-soft); color: var(--brand-ink); }

/* Pastilles (statuts, priorités) */
.badge {
  --tone: var(--brand);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, color-mix(in oklab, var(--tone) 10%, var(--surface)), color-mix(in oklab, var(--tone) 16%, var(--surface)));
  color: color-mix(in oklab, var(--tone) 80%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tone) 18%, transparent);
  font-size: 0.79rem; font-weight: 600; white-space: nowrap;
}
.badge-muted { --tone: var(--muted); }
.badge.tone-success { --tone: var(--success); }
.badge.tone-warning { --tone: var(--warning); }
.badge.tone-danger { --tone: var(--danger); }
.badge.tone-info { --tone: var(--info); }
.badge.tone-muted { --tone: var(--muted); }

.status-nouveau { --tone: var(--info); }
.status-qualifie { --tone: var(--violet); }
.status-en_cours { --tone: var(--brand); }
.status-a_valider { --tone: var(--warning); }
.status-en_attente_client { --tone: var(--accent); }
.status-clos { --tone: var(--muted); }
.priority-p1 { --tone: var(--danger); }
.priority-p2 { --tone: var(--warning); }
.priority-p3 { --tone: var(--info); }
.priority-p4 { --tone: var(--muted); }

/* Boutons de filtre (en haut d'une liste), avec compteur */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); text-decoration: none; font-weight: 560; font-size: 0.88rem;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.filter-chip:hover { color: var(--ink); border-color: color-mix(in oklab, var(--brand) 35%, var(--line)); background: var(--brand-softer); }
.filter-chip.is-active { color: var(--brand-ink); border-color: color-mix(in oklab, var(--brand) 45%, var(--line)); background: var(--brand-soft); }
.filter-count { min-width: 22px; padding: 1px 7px; border-radius: var(--radius-pill); background: color-mix(in oklab, var(--brand) 10%, var(--surface)); font-size: 0.78rem; text-align: center; font-variant-numeric: tabular-nums; }

/* Onglets (boutons [data-tab] et panneaux [data-panel] dans [data-tabs], voir app.js) */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; padding: 8px 14px; border: 0; background: none; font: inherit; font-weight: 540;
  color: var(--muted); cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.tab:hover { color: var(--ink); background: var(--brand-softer); }
.tab.is-active { color: var(--brand-ink); }
.tab.is-active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }
.tab-panel { padding-top: var(--space-4); }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--space-4); }
.form-wide { max-width: 860px; }
.form-narrow { max-width: 520px; }
.form-section { border: 0; margin: 0; padding: 0 0 8px; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 20px; }
.form-section legend { font: 650 1rem/1.2 var(--font-display); padding: 0; margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; }
fieldset.field { border: 0; margin: 0; padding: 0; }
.field-full { grid-column: 1 / -1; }
.field-short { max-width: 200px; }
.field-label { font-weight: 580; font-size: 0.9rem; }
.field-hint { color: var(--muted); font-size: 0.82rem; }
.optional { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.field-error { display: flex; align-items: center; gap: 6px; color: var(--danger); font-size: 0.84rem; font-weight: 520; }
input:not([type="checkbox"], [type="radio"]), select, textarea {
  width: 100%; min-height: var(--control-h); padding: calc(9px * var(--density)) 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit;
  box-shadow: inset 0 1px 2px rgb(var(--shadow-color) / 4%);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in oklab, var(--brand) 35%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); background: var(--surface); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 25%, transparent) !important; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.check-card { align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease); }
.check-card:hover { border-color: color-mix(in oklab, var(--brand) 30%, var(--line)); }
.check-card input { margin-top: 3px; }
.check-card:has(input:checked) { border-color: color-mix(in oklab, var(--brand) 50%, var(--line)); background: var(--brand-softer); }
.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line); }
.segmented label { position: relative; padding: 6px 14px; border-radius: var(--radius-pill); cursor: pointer; font-weight: 540; color: var(--muted); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.segmented label:hover { color: var(--ink); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar select { width: auto; min-width: 190px; }
.search { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; border-radius: var(--radius-pill); }

/* Messages */
.alert {
  --tone: var(--info);
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: linear-gradient(165deg, color-mix(in oklab, var(--tone) 8%, var(--surface)), color-mix(in oklab, var(--tone) 13%, var(--surface)));
  border: 1px solid color-mix(in oklab, var(--tone) 25%, var(--surface));
  border-left: 4px solid var(--tone);
  color: color-mix(in oklab, var(--tone) 72%, var(--ink));
}
.alert .icon { margin-top: 2px; }
.alert-success { --tone: var(--success); }
.alert-warning { --tone: var(--warning); }
.alert-danger { --tone: var(--danger); }
.alert-info { --tone: var(--info); }

/* Tableau : en-tête teinté, survol de ligne, ligne entière cliquable */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--card-pad) * -1); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: calc(11px * var(--density)) var(--card-pad); text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: color-mix(in oklab, var(--brand) 4%, var(--surface-2)); color: var(--muted); font-size: 0.76rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; }
.table tbody tr { transition: background-color var(--fast) var(--ease); }
.table tbody tr:hover { background: var(--brand-softer); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-muted td { opacity: 0.55; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .wrap { white-space: normal; }
.table-clickable tbody tr { position: relative; cursor: pointer; }
.row-link { color: var(--ink); text-decoration: none; font-weight: 580; transition: color var(--fast) var(--ease); }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:focus-visible { box-shadow: none; }
.table-clickable tbody tr:hover .row-link { color: var(--brand-ink); }
.table-clickable tbody tr:has(.row-link:focus-visible) { box-shadow: inset 0 0 0 2px var(--brand); }

/* Fiche : liste de faits */
.facts { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 560; text-align: right; overflow-wrap: anywhere; }
.facts-grand { padding-top: 8px; border-top: 1px solid var(--line); font-size: 1.05rem; }
.facts-grand dt { color: var(--ink) !important; font-weight: 650; }
.notes { white-space: pre-wrap; color: var(--ink); }

/* État vide */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 48px 24px; }
.empty p { color: var(--muted); max-width: 46ch; }
.empty-icon {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, color-mix(in oklab, var(--tint) 7%, var(--surface)), color-mix(in oklab, var(--tint) 18%, var(--surface)));
  color: color-mix(in oklab, var(--tint) 85%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tint) 15%, transparent);
}

/* Utilitaires */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }

/* Écrans de connexion : carte centrée, étroite */
.auth {
  width: 100%; max-width: 420px; margin: clamp(16px, 8vh, 72px) auto 0;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: clamp(24px, 4vw, 36px); box-shadow: var(--shadow-md);
}
.auth .form { width: 100%; margin-top: 8px; text-align: left; }
.auth .alert { width: 100%; text-align: left; }
.auth-wide { max-width: 600px; }

/* Module d'exemple « Notes » */
.note-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.note-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: var(--space-4); color: inherit; text-decoration: none; }
.note-card p { margin: 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-search { margin-bottom: 14px; }
.note-meta { font-size: 0.8rem; color: var(--muted); }
.prose h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.prose h2:first-child { margin-top: 0; }

/* Comptes */
.user-row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-row-form input[name="display_name"] { min-width: 160px; flex: 1; }
.user-actions { display: flex; flex-wrap: wrap; gap: 4px; }

/* 5. Fenêtres et notifications ------------------------------------------- */

/* Fenêtre modale (<dialog> natif) : 3 tailles. dialog-wide = 90 % de l'écran. */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog:not([open]) { display: none !important; }
.dialog[open] { display: flex; flex-direction: column; animation: pop var(--soft) var(--ease); }
.dialog::backdrop { background: rgb(22 48 61 / 42%); backdrop-filter: blur(3px); }
.dialog-md { width: min(720px, calc(100vw - 32px)); }
.dialog-wide, .dialog:has([data-dialog-wide]) { width: min(90vw, 1400px); max-width: 90vw; max-height: 90dvh; }
.dialog [data-remote-body] { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dialog [data-remote-body] > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dialog-head, .dialog-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: var(--space-4) var(--space-5); }
.dialog-head { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--brand-softer), var(--surface)); }
.dialog-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-5); color: var(--ink); }
.dialog-foot { justify-content: flex-end; border-top: 1px solid var(--line); background: var(--surface-2); }

/* Notifications éphémères */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: color-mix(in oklab, var(--ink) 94%, var(--brand)); color: var(--surface); box-shadow: var(--shadow-lg);
  animation: toast-in var(--soft) var(--ease);
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--soft) var(--ease), transform var(--soft) var(--ease); }

/* 6. Impression ------------------------------------------------------------- */

/* Portrait par défaut ; .print-landscape pour un tableau large (planning…). */
@media print {
  @page { size: A4 portrait; margin: 14mm; }
  @page landscape { size: A4 landscape; margin: 10mm; }
  .print-landscape { page: landscape; }
  body { background: #fff !important; color: #000; }
  .topbar, .footer, .toasts, .no-print, .skip-link, .breadcrumb, .md-widget { display: none !important; }
  .page { padding: 0; }
  .card { background: #fff; box-shadow: none; border-color: #ccc; }
  a { color: inherit; text-decoration: none; }
  tr, .card { break-inside: avoid; }
}

/* 7. Animations ------------------------------------------------------------ */

.page.is-entering > * { animation: rise 320ms var(--ease) both; }
.page.is-entering > *:nth-child(2) { animation-delay: 30ms; }
.page.is-entering > *:nth-child(3) { animation-delay: 60ms; }
.page.is-entering > *:nth-child(n+4) { animation-delay: 90ms; }
.page.is-loading { opacity: 0.55; transition: opacity var(--soft) var(--ease) 80ms; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; transition-duration: 1ms !important; }
  a.card:hover, .card-link:hover, .tile:hover, .stat:hover, .note-card:hover, .btn:hover, .nav-item:hover { transform: none; }
}

/* 8. Module métier (KIN-0002) --------------------------------------------- */

/* Couleurs des secteurs et des rééducateurs (pastilles, initiales). */
.color-bleu { --tone: #3b73c4; --tint: #3b73c4; }
.color-vert { --tone: #2e8a5f; --tint: #2e8a5f; }
.color-orange { --tone: #d9824a; --tint: #d9824a; }
.color-violet { --tone: #7a5cc4; --tint: #7a5cc4; }
.color-rouge { --tone: #c2453d; --tint: #c2453d; }
.color-jaune { --tone: #b8901a; --tint: #b8901a; }
.color-gris { --tone: #6b7c86; --tint: #6b7c86; }
.color-rose { --tone: #c25a8f; --tint: #c25a8f; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 2px color-mix(in oklab, var(--tone) 20%, transparent); }

/* Initiales des soignants attitrés */
.initials { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.initial {
  display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 6px; border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--tone) 14%, var(--surface)); color: color-mix(in oklab, var(--tone) 80%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tone) 20%, transparent); font-size: 0.75rem; font-weight: 650;
}

/* Résumé de plan « 2 K · 2 E · 1 P » */
.plan-summary { font-weight: 600; font-variant-numeric: tabular-nums; }
.warn-mark { color: var(--warning); display: inline-flex; vertical-align: -3px; }

/* Fiche en fenêtre : formulaire sur toute la hauteur, contenu défilant */
.sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain:disabled input, fieldset.plain:disabled select, fieldset.plain:disabled textarea { background: var(--surface-2); color: var(--ink); }

/* Compteur « − 2 + » (passages par semaine) */
.plan-rows { display: grid; gap: 8px; max-width: 520px; }
.plan-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.plan-row.is-zero { color: var(--muted); }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper input { width: 58px; min-height: 36px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.stepper .btn-icon { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface); font-size: 1.1rem; font-weight: 700; }
.plan-total { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--brand-softer); border: 1px dashed color-mix(in oklab, var(--brand) 30%, var(--line)); }
.plan-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.plan-head .field { flex: 1 1 220px; }

/* Présence par demi-journée (fiche rééducateur) */
.presence-grid { display: grid; grid-template-columns: 110px repeat(2, auto); gap: 6px 10px; align-items: center; justify-content: start; }
.presence-grid .head { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.presence-chip { position: relative; display: inline-grid; place-items: center; min-width: 60px; height: 32px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 650; font-size: 0.82rem; color: var(--muted); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.presence-chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: inherit; }
.presence-chip:has(input:checked) { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.presence-chip:has(input:focus-visible) { box-shadow: var(--focus); }
.presence-short { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.check-list { display: flex; flex-wrap: wrap; gap: 8px; }
.check-list .check-card { padding: 8px 12px; }
.patient-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.confirm-delete summary { list-style: none; cursor: pointer; display: inline-flex; }
.confirm-delete summary::-webkit-details-marker { display: none; }
.confirm-delete[open] summary { display: none; }
.dialog-foot .grow { margin-right: auto; }

/* Étiquette « pastille + nom » (secteurs, rééducateurs) : en ligne, alignées. */
.tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; vertical-align: middle; }
.tags { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }

/* Adresse : suggestions de la Base Adresse Nationale */
.address-field { position: relative; }
.address-suggestions {
  position: absolute; z-index: 40; top: calc(100% - 22px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 260px; overflow-y: auto;
}
.address-suggestions li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.address-suggestions li:hover, .address-suggestions li.is-active { background: var(--brand-soft); color: var(--brand-ink); }
.address-status.is-verified, .address-status:has(.icon) { color: var(--success); }

/* Fiches patient et rééducateur : fenêtre à 80 % de la largeur */
.dialog-wide, .dialog:has([data-dialog-wide]) { width: min(80vw, 1400px); max-width: 80vw; }
@media (max-width: 860px) { .dialog-wide, .dialog:has([data-dialog-wide]) { width: calc(100vw - 16px); max-width: none; } }

/* Absences d'un rééducateur */
.absence-rows { display: grid; gap: 10px; margin-bottom: 12px; }
.absence-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.absence-row .field { flex: 0 1 150px; }
.absence-row .field.grow { flex: 1 1 200px; }
.absence-row.is-past { opacity: 0.6; }

/* 9. Planning de la semaine (KIN-0003) ------------------------------------ */

.half-badge { display: inline-block; min-width: 1.9em; padding: 0 5px; border-radius: 4px; font-size: 0.68rem; font-weight: 700; line-height: 1.6; text-align: center; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.half-badge.is-am { background: #2f86b8; }
.half-badge.is-pm { background: #8a5cc4; }

.plan-wrap .table-wrap { margin: 0; }
.plan-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.82rem; table-layout: fixed; }
.plan-grid th, .plan-grid td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px; vertical-align: top; }
.plan-grid thead th { position: sticky; top: 0; z-index: 2; background: color-mix(in oklab, var(--brand) 5%, var(--surface-2)); text-align: center; font-weight: 650; }
.plan-grid thead th.is-holiday { color: var(--muted); }
.plan-grid .plan-who { width: 190px; text-align: left; border-left: 0; background: var(--surface); position: sticky; left: 0; z-index: 1; font-weight: 600; }
.plan-grid .plan-half { padding: 2px; }
.plan-group th { background: var(--brand-softer); text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 10px; }
.plan-print { margin-left: 4px; color: var(--muted); }
.plan-slot { min-width: 96px; height: 54px; background: var(--surface); position: relative; }
.plan-slot.is-pm { border-left-style: dashed; }
.plan-slot.is-off { background: var(--surface-2); }
.plan-slot.is-holiday { background: var(--surface-2); }
.plan-slot.is-absent { background: repeating-linear-gradient(135deg, color-mix(in oklab, var(--warning) 9%, var(--surface)) 0 6px, var(--surface) 6px 12px); }
.plan-slot.is-over { box-shadow: inset 0 0 0 2px var(--danger); }
.plan-slot.is-target { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-softer); }
.slot-note { display: block; font-size: 0.72rem; color: color-mix(in oklab, var(--warning) 80%, var(--ink)); font-weight: 600; }
.slot-count { position: absolute; right: 4px; bottom: 2px; font-size: 0.68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot-count.is-over { color: var(--danger); font-weight: 700; }
.plan-slot .slot-add { display: inline-block; padding: 0 6px; border-radius: 4px; color: transparent; text-decoration: none; font-weight: 700; }
.plan-slot:hover .slot-add, .slot-add:focus-visible { color: var(--brand-ink); background: var(--brand-softer); }

.visit-chip {
  display: flex; align-items: baseline; gap: 4px; margin-bottom: 3px; padding: 2px 6px 2px 3px; border-radius: 6px;
  border: 1px dashed color-mix(in oklab, var(--tone) 55%, var(--line)); border-left: 4px solid var(--tone);
  background: color-mix(in oklab, var(--tone) 9%, var(--surface)); color: var(--ink); text-decoration: none; line-height: 1.25; cursor: grab;
  overflow: hidden; white-space: nowrap;
}
.visit-chip.is-locked { border-style: solid; }
.visit-chip:hover { background: color-mix(in oklab, var(--tone) 18%, var(--surface)); color: var(--ink); }
.visit-chip.is-dragging { opacity: 0.4; }
.visit-chip small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.visit-rank { flex: none; display: inline-grid; place-items: center; min-width: 16px; height: 16px; border-radius: 50%; background: var(--tone); color: #fff; font-size: 0.65rem; font-weight: 700; }
.visit-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.drop-marker { height: 3px; margin: 1px 0 3px; border-radius: 2px; background: var(--brand); }

.unplaced { border-left: 4px solid var(--warning); }
.unplaced summary { cursor: pointer; display: flex; gap: 8px; align-items: center; }
.unplaced ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.need { display: inline-block; margin: 0 6px 2px 0; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.need.is-missing { background: color-mix(in oklab, var(--warning) 16%, var(--surface)); color: color-mix(in oklab, var(--warning) 80%, var(--ink)); }

.unavailable-grid { display: grid; grid-template-columns: minmax(150px, auto) repeat(3, auto) minmax(140px, 1fr); gap: 6px 10px; align-items: center; }
.unavailable-grid .head { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-align: center; }
.unavailable-grid .presence-chip { min-width: 44px; }

/* Tournée imprimable */
.round-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.round-day h2 { margin-bottom: 8px; }
.round-half { margin: 10px 0 4px; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.round-list { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.round-list li { display: flex; flex-direction: column; }
@media print {
  .round-days { grid-template-columns: 1fr 1fr; gap: 8px; }
  .round-day { padding: 8px; }
}
.to-enter { border-left: 4px solid var(--info); }
.to-enter summary { cursor: pointer; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.to-enter ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 4px; }

/* 10. Ma tournée (KIN-0007), pensée d'abord pour le téléphone ------------- */

.tour-week { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); max-width: 720px; }
.tour-week-title { margin: 0; font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tour-day { padding: 14px; }
.tour-day.is-today { box-shadow: inset 4px 0 0 var(--brand), var(--shadow-sm, 0 1px 2px rgb(0 0 0 / 6%)); }
.tour-day-title { margin: 0 0 6px; font-size: 1.05rem; }
.tour-half + .tour-half { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tour-half-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.tour-go { margin-left: auto; }
.tour-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.tour-stop { display: flex; gap: 10px; align-items: flex-start; }
.tour-rank { --tone: var(--brand); min-width: 26px; height: 26px; font-size: 0.85rem; margin-top: 1px; }
.tour-stop-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tour-note { color: color-mix(in oklab, var(--warning) 80%, var(--ink)); }
.tour-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tour-nav { position: relative; }
.tour-nav summary { list-style: none; cursor: pointer; }
.tour-nav summary::-webkit-details-marker { display: none; }
.tour-nav-menu {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; min-width: 170px; display: grid; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}
.tour-nav-menu a { padding: 10px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); font-weight: 600; }
.tour-nav-menu a:hover, .tour-nav-menu a:focus-visible { background: var(--brand-softer); }
.tour-foot { max-width: 720px; }
/* Doigt sur un téléphone : boutons plus hauts. */
@media (max-width: 640px) {
  .tour-actions .btn, .tour-go { min-height: 40px; }
  .tour-go { margin-left: 0; width: 100%; justify-content: center; }
}

/* Code de connexion reçu par e-mail (KIN-0007) */
.code-input { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; max-width: 12ch; }

/* 11. Cloche des notifications (KIN-0008, même présentation que la console) */

.bell-slot { display: flex; align-items: center; }
.bell { position: relative; }
.bell > summary { list-style: none; }
.bell > summary::-webkit-details-marker { display: none; }
.bell-button {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  color: var(--muted); cursor: pointer; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.bell-button:hover, .bell[open] .bell-button { background: var(--brand-softer); color: var(--ink); }
.bell-count {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--danger); color: #fff; font: 700 0.68rem/18px var(--font-body); text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.bell-count[hidden] { display: none; }
.bell-panel {
  position: absolute; top: calc(100% + 8px); right: -8px; z-index: 30; width: min(360px, calc(100vw - 24px));
  padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); animation: pop var(--fast) var(--ease);
}
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bell-head form { margin: 0; }
.bell-title { margin: 0; font-size: 0.74rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 4px 8px; }
.bell-empty { padding: 8px; margin: 0; }
.bell-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 2px; max-height: min(60vh, 420px); overflow-y: auto; }
.bell-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px 9px 18px; border-radius: calc(var(--radius-sm) - 2px); color: var(--ink); text-decoration: none; font-size: 0.9rem; position: relative; }
.bell-item:hover { background: var(--brand-softer); color: var(--ink); }
.bell-item.is-unread { font-weight: 600; background: color-mix(in oklab, var(--brand) 5%, var(--surface)); }
.bell-item.is-unread::before { content: ""; position: absolute; left: 6px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.bell-item small { font-weight: 400; }
.bell-all { display: block; padding: 8px; border-top: 1px solid var(--line); text-align: center; font-size: 0.88rem; }
.bell-page .bell-list { max-height: none; }
@media (max-width: 860px) {
  .bell-slot { margin-left: 4px; }
  .bell-panel { right: -48px; }
}

/* Notifications sur l'écran de l'appareil (KIN-0015, repris d'ALX-0044) : bouton d'abonnement dans
   la cloche, sur Mon compte et dans Ma tournée. */
.push-toggle[hidden], .push-toggle [hidden] { display: none; }
.push-toggle { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.push-status { margin: 0; color: var(--muted); font-size: 0.88rem; }
.push-status:empty { display: none; }
.push-toggle-bell { padding: 8px; border-top: 1px solid var(--line); }
.push-toggle-bell .push-status { font-size: 0.82rem; }

/* Fenêtre d'un passage : jour, demi-journée, rang (déplacement sur le téléphone) */
.visit-move { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 640px) { .visit-move { grid-template-columns: 1fr 1fr; } .visit-move .field:first-child { grid-column: 1 / -1; } }
.tour-call { font-variant-numeric: tabular-nums; }

/* Agenda personnel (KIN-0004) */
.tour-agenda { max-width: 720px; display: grid; gap: 10px; }
.tour-agenda input[readonly] { font-size: 0.85rem; }
.tour-howto summary { cursor: pointer; font-weight: 600; }
.tour-howto ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; }

/* Ma tournée : glisser-déposer au doigt (KIN-0009) */
.tour-stop[data-tour-stop] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; border-radius: var(--radius-sm); transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease); }
.tour-stop.is-pressing { background: var(--brand-softer); transform: scale(0.99); }
.tour-stop.is-dragging { opacity: 0.35; }
.tour-ghost {
  position: fixed; z-index: 1000; margin: 0; padding: 8px; list-style: none; pointer-events: none;
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgb(0 0 0 / 22%); transform: rotate(-1deg) scale(1.02);
}
.tour-marker { list-style: none; height: 4px; margin: 2px 0; border-radius: 2px; background: var(--brand); }
.is-tour-dragging .tour-half:has([data-tour-zone]) { outline: 2px dashed color-mix(in oklab, var(--brand) 30%, transparent); outline-offset: 2px; border-radius: var(--radius-sm); }
.is-tour-dragging { overscroll-behavior: none; }
.toast-action { display: flex; align-items: center; gap: 12px; }
.toast-button { border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 4px; }

/* Ma tournée : chaque passage est une tuile, sur un fond distinct du bloc du jour ;
   sur ordinateur, les jours sont disposés en colonnes (KIN-0009). */
.tour-stop[data-tour-stop], .tour-stop {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 4%, var(--surface-2)), var(--surface-2));
  box-shadow: 0 1px 2px rgb(var(--shadow-color, 0 0 0) / 5%);
}
.tour-stop:hover { border-color: color-mix(in oklab, var(--brand) 30%, var(--line)); box-shadow: var(--shadow-sm); }
.tour-stop.is-pressing { background: var(--brand-softer); }
.tour-list { gap: 8px; }
.tour-ghost { border: 1px solid color-mix(in oklab, var(--brand) 40%, var(--line)); background: var(--surface-2); }
@media (min-width: 900px) {
  .tour-week { max-width: none; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); align-items: start; }
  .tour-week-title, .tour-week > p { grid-column: 1 / -1; }
}

/* Ma tournée : passage tenu au-dessus d'une autre semaine (refusé, KIN-0011). */
.tour-ghost.is-refused { opacity: 0.85; outline: 2px dashed var(--danger); outline-offset: 2px; }
.tour-ghost.is-refused::after { content: "Autre semaine : voir avec le responsable"; position: absolute; left: 8px; bottom: -26px; padding: 2px 10px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.tour-stop[data-tour-stop] { cursor: grab; }

/* Outils de l'en-tête (ALX-0038, KIN-0012) : roue dentée (administrateur) et cloche, à
   gauche du nom du compte sur ordinateur ; sur le téléphone, dans la barre, à
   côté du bouton du menu. */
.topbar-tools { display: flex; align-items: center; gap: 4px; }
.settings-link { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--muted); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--soft) var(--ease); }
.settings-link:hover, .settings-link.is-active { background: var(--brand-softer); color: var(--ink); }
.settings-link:hover .icon { transform: rotate(45deg); transition: transform var(--soft) var(--ease); }
@media (min-width: 861px) {
  .topbar .nav { display: contents; }
  .topbar .nav-list { order: 1; margin-left: 8px; }
  .topbar .topbar-tools { order: 2; margin-left: auto; }
  .topbar .nav > .user-menu { order: 3; margin-left: 0; }
}
/* Logo choisi dans Paramètres : à la place de l'initiale. */
/* Le logo garde ses proportions : aussi haut que possible dans la barre, sans cadre. */
.brand-mark.has-logo { display: block; width: auto; height: auto; max-width: none; padding: 0; border-radius: 0; background: none; box-shadow: none; }
/* Hauteur explicite : une hauteur en % n'est pas appliquée à l'image dans ce bloc. */
.brand-mark.has-logo img { display: block; height: calc(var(--topbar-h) - 18px); width: auto; max-width: 220px; object-fit: contain; }
/* Logo sur fond blanc : en mode clair, le blanc se fond dans l'en-tête ; en mode
   sombre, petite plaque blanche pour qu'il reste lisible. */
.brand-mark.has-logo img { mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) {
  .brand-mark.has-logo { padding: 3px 8px; border-radius: 8px; background: #ffffff; }
  .brand-mark.has-logo img { mix-blend-mode: normal; height: calc(var(--topbar-h) - 24px); }
}
.brand:hover .brand-mark.has-logo { transform: none; }
@media (max-width: 860px) { .brand-mark.has-logo img { height: calc(var(--topbar-h) - 24px); max-width: 150px; } }

/* Paramètres › Visuel (ALX-0038) */
a.tab { text-decoration: none; display: inline-flex; align-items: center; }
.settings-tabs { margin-bottom: calc(var(--space-2) * -1); }
.logo-field { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.logo-preview { width: 72px; height: 72px; font-size: 28px; flex: none; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.color-field { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.color-field.is-custom { border-color: color-mix(in oklab, var(--info) 35%, var(--line)); }
.color-field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.color-field-inputs { display: flex; align-items: center; gap: 8px; }
.color-field-inputs input[type="color"] { width: 46px; height: 38px; padding: 2px; border-radius: 10px; cursor: pointer; flex: none; }
.color-field-hex { max-width: 110px; }
.color-sample { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 34px; }
.sample-tab { padding: 4px 12px; border-radius: var(--radius-pill); background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; font-size: 0.86rem; }
.sample-accent { --tone: var(--accent); }
.sample-topbar { padding: 6px 14px; border-radius: 8px; background: var(--topbar-bg, var(--ink)); color: #f2f6fa; font-weight: 600; font-size: 0.86rem; }
.swatches { display: inline-flex; gap: 4px; margin-left: auto; }
.swatch { display: inline-block; width: 26px; height: 26px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%); }
.swatch-brand-strong { background: var(--brand-strong); }
.swatch-brand-soft { background: var(--brand-soft); }
.swatch-brand-softer { background: var(--brand-softer); }
.swatch-bg { background: var(--bg); }
.swatch-halo1 { background: var(--halo-1); }
.swatch-halo2 { background: var(--halo-2); }
.background-preview {
  display: grid; place-items: center; height: 120px; margin-bottom: var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: radial-gradient(420px 160px at 8% -20%, var(--halo-1), transparent 70%), radial-gradient(380px 160px at 96% -10%, var(--halo-2), transparent 65%), var(--bg);
}
.background-preview-card { padding: 10px 18px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 600; }
.settings-actions { position: sticky; bottom: 0; z-index: 5; align-items: center; padding: 12px var(--card-pad); border-radius: var(--radius); background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-md); border-top: 0; }
.settings-actions .muted { margin-right: auto; font-size: 0.86rem; }
.styleguide-themes { margin-top: 12px; }

/* Mon planning (une seule ligne) : noms complets, sur plusieurs lignes si besoin (KIN-0014). */
.plan-own .visit-chip { white-space: normal; align-items: flex-start; flex-wrap: wrap; }
.plan-own .visit-name, .plan-own .visit-chip small { overflow: visible; text-overflow: clip; }
.plan-own .plan-slot { height: auto; min-height: 54px; }

/* Bandeau des versions de test (KIN-0018) : rayé, bien visible, au-dessus de l'en-tête. */
.test-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 7px var(--gutter);
  background: repeating-linear-gradient(135deg, #f6c343 0 14px, #f3b72a 14px 28px); color: #3b2a00;
  font-weight: 650; font-size: 0.88rem; text-align: center;
}
.test-banner .icon { flex: none; }
@media print { .test-banner { display: none; } }
