/* ==========================================================================
   Gestion Logistique Croix-Rouge DT16 — feuille de style unique
   Mobile et tablette d'abord (cibles tactiles ≥ 48 px, pas de survol requis),
   puis desktop. Contrastes conformes WCAG AA.
   ========================================================================== */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #17202b;
  --muted: #4f5b69;
  --line: #d3dae2;
  --line-strong: #aeb8c4;
  --brand: #b3261e;
  --brand-dark: #8c1d17;
  --brand-soft: #fbeceb;
  --info: #24527a;
  --focus: #1f5fbf;
  --ok: #1f6b3a;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --late: #b3261e;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(23, 32, 43, .06), 0 2px 8px rgba(23, 32, 43, .05);
  --tap: 48px;
  --nav-h: 64px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
a { color: var(--info); text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
small { font-size: .85em; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 12px 16px; z-index: 100; }
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* --- Icônes ------------------------------------------------------------- */
.icon { width: 22px; height: 22px; flex: none; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 32px; height: 32px; }

/* --- Structure ---------------------------------------------------------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; }
.container:focus { outline: none; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 4px 8px 4px 16px;
  padding-top: max(4px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.topbar__brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; margin-right: auto; }
.topbar__nav { display: none; }
.topbar__user { display: flex; align-items: center; gap: 4px; }
.topbar__name { display: none; font-size: .9rem; text-align: right; line-height: 1.2; }
.topbar__name small { display: block; opacity: .85; }
.topbar .btn--ghost { color: #fff; }
.topbar .btn--ghost:hover { background: rgba(255,255,255,.15); }
.topbar form { margin: 0; }

/* Barre de navigation basse (smartphone / tablette portrait) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(23,32,43,.06);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 700;
}
.bottom-nav a.is-active { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }

.bottom-nav a { position: relative; }
.nav-badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: .75rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.bottom-nav .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); }
.brand-mark { position: relative; display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -2px; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: #fff; border-radius: 1px; }
.brand-mark::before { left: 6px; top: 0; width: 6px; height: 18px; }
.brand-mark::after { left: 0; top: 6px; width: 18px; height: 6px; }

/* Barre latérale (tablette paysage et ordinateur) */
.sidebar { display: none; }
@media (min-width: 1024px) {
  body.has-nav { padding-bottom: 32px; padding-left: 232px; }
  .bottom-nav { display: none; }
  .topbar { padding: 0 16px 0 20px; }
  .topbar__name { display: block; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; left: 0; top: 56px; bottom: 0; width: 232px; z-index: 20;
    padding: 12px 10px; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .sidebar a {
    display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px;
    border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 700;
  }
  .sidebar a:hover { background: var(--surface-2); }
  .sidebar a.is-active { background: var(--brand-soft); color: var(--brand-dark); box-shadow: inset 4px 0 0 var(--brand); }
  .sidebar .nav-badge { margin-left: auto; }
  .container { padding: 24px; }
}

/* --- Titres de page ----------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; flex: 1 1 auto; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link {
  flex-basis: 100%; display: inline-flex; align-items: center; gap: 4px; min-height: 40px;
  color: var(--muted); text-decoration: none; font-weight: 700;
}
@media (max-width: 599px) {
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}

/* --- Cartes ------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card--accent { border-top: 4px solid var(--ok); }
@media (min-width: 768px) { .card { padding: 20px 24px; } }

.grid-2 { display: grid; gap: 0 16px; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }

/* --- Boutons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border: 2px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 700; line-height: 1.2; text-decoration: none; text-align: center;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { border-color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn--block { width: 100%; }
.btn--icon { width: var(--tap); padding: 0; }
.btn--sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }

/* --- Formulaires -------------------------------------------------------- */
.form { display: grid; gap: 16px; }
.form--narrow { max-width: 760px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, fieldset legend { font-weight: 700; }
.field-row { display: grid; gap: 16px; }
@media (min-width: 600px) { .field-row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; } }
.field-row--tight { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.field-help { margin: 0; color: var(--muted); font-size: .9rem; }
.field-error { margin: 0; color: var(--brand); font-weight: 700; font-size: .95rem; }
.req { color: var(--brand); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], input[type="datetime-local"], input[type="color"],
select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--line-strong); border-radius: var(--radius-sm);
}
input[type="color"] { padding: 4px; }
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(31,95,191,.25); }
[aria-invalid="true"] { border-color: var(--brand) !important; }
input[type="file"] { width: 100%; padding: 10px; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); font: inherit; }
input[type="file"]::file-selector-button {
  min-height: 40px; margin-right: 12px; padding: 6px 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--brand); }
.check--box { padding: 8px 12px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.field--checks { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 599px) { .form-actions .btn { flex: 1; } }
.file-preview { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.file-preview li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.file-preview li.is-error { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.stack-sm { margin-bottom: 12px; }

/* --- Messages ----------------------------------------------------------- */
.alert { padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius-sm); border-left: 6px solid; font-weight: 700; background: var(--surface); }
.alert--success { border-color: var(--ok); color: var(--ok); background: #eaf6ee; }
.alert--error { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.alert--warning { border-color: #c48a00; color: var(--warn-ink); background: var(--warn-bg); }
.alert--info { border-color: var(--info); color: var(--info); background: #e9f1f8; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); }

/* --- Badges ------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; line-height: 1.4; white-space: nowrap;
}
.badge--nouveau    { background: #e5edfc; color: #1e3a8a; }
.badge--assigne    { background: #ede9fe; color: #4c1d95; }
.badge--en_cours   { background: #fdf0c4; color: #6b3d00; }
.badge--en_attente { background: #fbe4f0; color: #831843; }
.badge--resolu     { background: #dcf3e3; color: #14532d; }
.badge--cloture    { background: #e5e7eb; color: #374151; }
.badge--priority   { background: var(--surface); color: var(--ink); border: 2px solid var(--prio, #1d4ed8); }
.badge--priority::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--prio, #1d4ed8); }
.badge--overdue    { background: var(--late); color: #fff; }
.badge--internal   { background: var(--warn-bg); color: var(--warn-ink); }
.badge--role       { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge--off        { background: #e5e7eb; color: #374151; }
.stars { color: #b7791f; letter-spacing: 1px; white-space: nowrap; }
.stars__off { color: #cfd6de; }

/* --- Filtres ------------------------------------------------------------ */
.filters { margin-bottom: 12px; }
.filters__search { display: flex; gap: 8px; margin-bottom: 8px; }
.filters__search input { flex: 1; }
.filters__more > summary { list-style: none; }
.filters__more > summary::-webkit-details-marker { display: none; }
.filters__grid {
  display: grid; gap: 12px; margin-top: 12px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
@media (min-width: 600px) { .filters__grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .filters__grid { grid-template-columns: repeat(4, 1fr); } }
.filters__actions { display: flex; gap: 8px; margin-top: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: thin; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 2px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  color: var(--ink); text-decoration: none; font-weight: 700;
}
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.result-count { color: var(--muted); font-size: .95rem; margin: 4px 0 8px; }

/* --- Liste de tickets : la tranche gauche porte la couleur de priorité --- */
.ticket-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.ticket {
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--prio, #1d4ed8);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.ticket__link { display: grid; gap: 6px; padding: 12px 16px; color: inherit; text-decoration: none; }
.ticket__link:hover .ticket__title { text-decoration: underline; }
.ticket__top { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.ticket__ref { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.ticket__date { color: var(--muted); }
.ticket__title { font-weight: 700; font-size: 1.08rem; }
.ticket__badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.ticket__meta { color: var(--muted); font-size: .92rem; }
.ticket__due { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; color: var(--muted); }
.ticket__due.is-late { color: var(--late); font-weight: 700; }
@media (min-width: 1024px) {
  .ticket__link { grid-template-columns: 150px 1fr auto; grid-template-areas: "top title badges" "top meta due"; align-items: center; column-gap: 20px; }
  .ticket__top { grid-area: top; flex-direction: column; gap: 2px; }
  .ticket__title { grid-area: title; }
  .ticket__badges { grid-area: badges; justify-content: flex-end; }
  .ticket__meta { grid-area: meta; }
  .ticket__due { grid-area: due; justify-self: end; }
}

/* --- Pagination --------------------------------------------------------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 16px 0; }
.pagination__info { color: var(--muted); padding: 0 8px; }

/* --- Fiche ticket ------------------------------------------------------- */
.ticket-head { border-left: 6px solid var(--prio, var(--brand)); padding-left: 14px; }
.ticket-head h1 { flex-basis: 100%; }
.ticket-head__ref { margin: 0; flex-basis: 100%; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticket-layout { display: grid; gap: 0 20px; }
@media (min-width: 900px) {
  .ticket-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .ticket-desc { grid-column: 1; grid-row: 1; }
  .ticket-conv { grid-column: 1; grid-row: 2; }
  .ticket-side { grid-column: 2; grid-row: 1 / span 2; }
}
.prose { overflow-wrap: anywhere; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }
.details .is-late { color: var(--late); }
.inline-form { margin-top: 12px; }
.inline-form > summary { list-style: none; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] > summary { margin-bottom: 12px; }
.time-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; font-size: .95rem; }
.time-list li { padding-top: 8px; border-top: 1px solid var(--line); }

.files { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.file__open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.file__open img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--line); }
.file__type { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 4px; background: var(--brand); color: #fff; font-weight: 700; }
.file__name { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.file__name small { display: block; font-weight: 400; color: var(--muted); }

.timeline { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 12px; }
.event {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px;
  padding: 4px 0 4px 14px; border-left: 3px solid var(--line); color: var(--muted); font-size: .93rem;
}
.event .old { text-decoration: line-through; }
.event .new { color: var(--ink); font-weight: 700; }
.msg { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.msg--staff { background: #f1f6fb; border-color: #cfdcea; }
.msg--internal { background: var(--warn-bg); border: 2px dashed #d9a92b; }
.msg__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px; }
.msg__head time { margin-left: auto; color: var(--muted); font-size: .9rem; }
.msg__body { overflow-wrap: anywhere; }
.reply { padding-top: 16px; border-top: 2px solid var(--line); }
.reply.is-internal { background: var(--warn-bg); margin: 0 -16px -16px; padding: 16px; border-radius: 0 0 var(--radius) var(--radius); }

/* Notation par étoiles (boutons radio, utilisable au clavier et au doigt) */
.rating { border: 0; padding: 0; margin: 0; }
.rating__stars { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; margin-top: 6px; }
.rating__stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating__stars label { width: 48px; height: 48px; cursor: pointer; display: grid; place-items: center; }
.rating__stars label::before { content: "★"; font-size: 40px; line-height: 1; color: #cfd6de; }
.rating__stars input:checked ~ label::before,
.rating__stars label:hover::before, .rating__stars label:hover ~ label::before { color: #b7791f; }
.rating__stars input:focus-visible + label { outline: 3px solid var(--focus); border-radius: 6px; }

/* --- Tableau de bord ---------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: grid; gap: 2px; padding: 16px; min-height: 104px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.tile__value { font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile__label { font-weight: 700; color: var(--muted); }
.tile--alert { border-color: var(--late); background: var(--brand-soft); }
.tile--alert .tile__value { color: var(--brand-dark); }
.dash-grid { display: grid; gap: 0 20px; }
@media (min-width: 1024px) { .dash-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 10px; }
.section-head h2 { margin: 0; }
.quick-take { display: flex; align-items: center; gap: 8px; }
.quick-take .ticket { flex: 1; min-width: 0; }

/* --- Kanban ------------------------------------------------------------- */
.kanban {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(82vw, 1fr);
  gap: 12px; overflow-x: auto; padding-bottom: 12px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
@media (min-width: 600px) { .kanban { grid-auto-columns: minmax(300px, 1fr); } }
@media (min-width: 1280px) { .kanban { grid-auto-columns: minmax(230px, 1fr); } }
.kanban__col {
  scroll-snap-align: start; display: flex; flex-direction: column; min-height: 60vh;
  background: #e3e8ed; border-radius: var(--radius); border: 2px solid transparent;
}
.kanban__col.is-over { border-color: var(--focus); background: #d9e6f5; }
.kanban__head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 8px; font-weight: 700; }
.kanban__count { min-width: 32px; padding: 2px 8px; border-radius: 999px; background: var(--surface); text-align: center; font-variant-numeric: tabular-nums; }
.kanban__list { list-style: none; margin: 0; padding: 0 8px 8px; display: grid; gap: 8px; align-content: start; flex: 1; }
.kcard {
  position: relative; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--line); border-left: 5px solid var(--prio, #1d4ed8); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.kcard.is-dragging { opacity: .35; }
.kcard.is-pending { opacity: .6; }
.kcard__ref { font-size: .85rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.kcard__title { display: block; margin: 2px 0 6px; font-weight: 700; color: var(--ink); text-decoration: none; }
.kcard__meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: .85rem; color: var(--muted); }
.kcard__move { margin-top: 8px; }
.kcard__move select { min-height: 40px; padding: 6px 8px; font-size: .9rem; }
.kanban-ghost {
  position: fixed; z-index: 50; pointer-events: none; width: 260px; transform: rotate(2deg);
  box-shadow: 0 12px 28px rgba(23,32,43,.25); opacity: .95;
}
.kanban-help { color: var(--muted); font-size: .95rem; }
body.is-dragging { cursor: grabbing; }

/* --- Tableaux (administration) ----------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { margin: 0; }

/* Listes responsives : chaque ligne devient une carte sous 768 px */
@media (max-width: 767px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .table-cards td { border: 0; padding: 3px 0; }
  .table-cards td[data-label]::before { content: attr(data-label) " : "; font-weight: 700; color: var(--muted); }
  .table-cards td.num { text-align: left; }
}

.admin-links { display: grid; gap: 12px; }
@media (min-width: 600px) { .admin-links { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .admin-links { grid-template-columns: repeat(3, 1fr); } }
.admin-link {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px; min-height: 96px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.admin-link .icon { width: 28px; height: 28px; color: var(--brand); }
.admin-link strong { display: block; font-size: 1.05rem; }
.admin-link span { color: var(--muted); font-size: .93rem; }

.editable-list { display: grid; gap: 12px; }
.edit-row { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
@media (min-width: 900px) { .edit-row { grid-template-columns: 2fr 3fr 1fr auto auto; align-items: end; } }
.edit-row--prio { }
@media (min-width: 900px) { .edit-row--prio { grid-template-columns: 1fr 2fr 1fr 1fr 90px auto auto; } }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; background: var(--c); }

/* --- Statistiques ------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi__value { display: block; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi__label { color: var(--muted); font-size: .9rem; font-weight: 700; }
.chart { width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font); fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .9rem; margin: 6px 0 0; padding: 0; list-style: none; }
.legend li::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; background: var(--c); vertical-align: -1px; }
details.data-table > summary { cursor: pointer; color: var(--info); font-weight: 700; min-height: 40px; display: flex; align-items: center; }

/* --- Connexion ---------------------------------------------------------- */
body.is-bare .container { max-width: 480px; padding-top: 6vh; }
.auth__app { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 1.35rem; font-weight: 700; margin-bottom: 20px; }
.auth__mark { position: relative; width: 34px; height: 34px; }
.auth__mark::before, .auth__mark::after { content: ""; position: absolute; background: var(--brand); border-radius: 2px; }
.auth__mark::before { left: 12px; top: 0; width: 10px; height: 34px; }
.auth__mark::after { left: 0; top: 12px; width: 34px; height: 10px; }
.auth__card { padding: 24px; }
.auth__link { text-align: center; margin: 16px 0 0; }
.auth__link a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* --- Pages d'erreur ----------------------------------------------------- */
.error-page { text-align: center; padding: 40px 20px; }
.error-page__code { font-size: 4rem; font-weight: 700; color: var(--brand); margin: 0; line-height: 1; }

/* --- Notifications éphémères ------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%);
  z-index: 60; max-width: min(92vw, 520px); padding: 12px 18px;
  background: var(--ink); color: #fff; border-radius: var(--radius-sm); font-weight: 700; box-shadow: var(--shadow);
}
.toast--error { background: var(--brand-dark); }
@media (min-width: 1024px) { .toast { bottom: 24px; } }

/* --- Impression --------------------------------------------------------- */
@media print {
  .topbar, .bottom-nav, .filters, .chips, .reply, .ticket-side form, .inline-form, .page-actions { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ==========================================================================
   Modules ERP
   ========================================================================== */
.badge--ok     { background: #dcf3e3; color: #14532d; }
.badge--warn   { background: #fdf0c4; color: #6b3d00; }
.badge--danger { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #e8b4b0; }
.badge--info   { background: #e5edfc; color: #1e3a8a; }
.badge--muted  { background: #e5e7eb; color: #374151; }

/* Liste d'alertes du tableau de bord */
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alerts li a, .alerts li > span {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px;
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); text-decoration: none;
}
.alerts li a:hover { background: #e7ecf1; }
.alerts .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #c48a00; }
.alerts .dot--danger { background: var(--brand); }
.alerts .dot--info { background: var(--info); }
.alerts small { margin-left: auto; color: var(--muted); text-align: right; }
.all-good { display: flex; align-items: center; gap: 10px; color: var(--ok); font-weight: 700; }

/* Cartes de liste génériques (véhicules, lots, crises…) */
.cards { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
@media (min-width: 700px) { .cards--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .cards--3 { grid-template-columns: repeat(3, 1fr); } }
.item-card {
  display: grid; gap: 6px; padding: 14px 16px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
}
a.item-card:hover .item-card__title { text-decoration: underline; }
.item-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-card__title { font-weight: 700; font-size: 1.08rem; }
.item-card__meta { color: var(--muted); font-size: .92rem; }
.item-card__alerts { display: flex; flex-wrap: wrap; gap: 6px; }
.group-title { margin: 20px 0 10px; font-size: 1.05rem; color: var(--muted); }

/* Tableaux de saisie (contrôle de lot) */
.check-table input[type="number"] { max-width: 110px; }
.check-table input[type="date"] { max-width: 170px; }
.check-table tr.is-missing td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.check-table .diff { font-weight: 700; color: var(--brand-dark); }
@media (max-width: 767px) {
  .check-table input[type="number"], .check-table input[type="date"] { max-width: none; }
}

/* Lignes dynamiques du formulaire secouriste */
.lines { display: grid; gap: 10px; }
.line {
  display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
@media (min-width: 700px) { .line { grid-template-columns: 2fr 1.5fr 100px auto; align-items: end; } }
.line .btn--icon { justify-self: end; }
.choice { display: grid; gap: 10px; }
@media (min-width: 700px) { .choice { grid-template-columns: 1fr 1fr; } }
.choice label {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; min-height: 64px;
  border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 700;
}
.choice input { width: 24px; height: 24px; flex: none; accent-color: var(--brand); margin-top: 2px; }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.public-head { text-align: center; margin-bottom: 16px; }
body.is-bare .container.container--wide { max-width: 860px; padding-top: 16px; }
.success-panel { text-align: center; padding: 32px 20px; }
.success-panel .icon { width: 56px; height: 56px; color: var(--ok); }

/* Main courante */
.logbook { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.log-entry { display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.log-entry time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.log-entry time small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.log-entry__head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: .92rem; color: var(--muted); }
.log-entry__msg { grid-column: 2; overflow-wrap: anywhere; }
.log-entry.is-important { border: 2px solid #d9a92b; background: var(--warn-bg); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.step { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.step.is-done .step__title { text-decoration: line-through; color: var(--muted); }
.step__time { font-weight: 700; font-variant-numeric: tabular-nums; }
.step select { min-height: 40px; padding: 4px 8px; font-size: .9rem; }
.quick-log textarea { min-height: 80px; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + 8px); z-index: 5; }
@media (min-width: 1024px) { .sticky-actions { bottom: 8px; } }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 700; }
.tabs a.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.num-big { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.qty-low { color: var(--brand-dark); font-weight: 700; }
.inline-forms { display: grid; gap: 12px; }
@media (min-width: 900px) { .inline-forms { grid-template-columns: repeat(3, 1fr); align-items: start; } }
.inline-forms .card { margin: 0; }

/* --- Uniformes ---------------------------------------------------------- */
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.size-cell { display: grid; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; }
.size-cell.is-empty { background: var(--brand-soft); border-color: #e8b4b0; }
.size-cell__size { font-weight: 700; font-size: 1.05rem; }
.size-cell input { text-align: center; padding: 6px; min-height: 44px; }
.size-cell__out { font-size: .8rem; color: var(--muted); }
.clauses { margin: 0 0 16px; padding-left: 22px; display: grid; gap: 8px; }
.clauses-text { white-space: normal; font-size: .95rem; }
.signature { display: grid; gap: 8px; }
.signature__pad {
  width: 100%; max-width: 640px; height: 220px; touch-action: none;
  background: #fff; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); cursor: crosshair;
}
.signature.has-ink .signature__pad { border-style: solid; border-color: var(--focus); }
.signature .btn { justify-self: start; }
.signature__img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }

/* Champ email avec bouton « @ » */
.input-with-keys { display: flex; gap: 8px; }
.input-with-keys input { flex: 1; min-width: 0; }
.key-btn { min-width: var(--tap); padding: 0 14px; font-size: 1.2rem; }

/* Formulaire public large : 95 % sur téléphone, 75 % minimum sur grand écran */
body.is-bare.is-wide .container { max-width: none; width: 95%; padding: 12px 0 24px; }
@media (min-width: 768px) { body.is-bare.is-wide .container { width: 85%; } }
@media (min-width: 1024px) { body.is-bare.is-wide .container { width: 75%; } }
body.is-wide .card { padding: 20px; }
@media (min-width: 768px) { body.is-wide .card { padding: 28px 32px; } }
