/* ══════════════════════════════════════════════════════════════
   LA PLAGE — L'ISLE-ADAM · feuille de style unique
   Système « Balisage » : chaque état de la flotte = un champ de couleur
   + une marque de balisage (▲ libre · ✕ ticket · ● sorti · ●● retard).
   Un bouton porte la couleur de l'état qu'il produit.
   Sommaire : 1 police · 2 jetons · 3 base · 4 coque · 5 boutons
   6 marques & badges · 7 notices, toasts, dialogue · 8 formulaires
   9 en-têtes de page · 10 sorties (lignes) · 11 planning
   12 gestion · 13 connexion · 14 responsive · 15 mouvement, impression
══════════════════════════════════════════════════════════════ */

/* ── 1. Police auto-hébergée (RGPD : aucun CDN tiers) ─────────── */
@font-face {
  font-family: 'Figtree';
  src: url("../fonts/figtree-latin-wght.a87b95d73b0a.woff2") format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url("../fonts/fraunces-latin-wght.eb2486760f75.woff2") format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── 2. Jetons ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* Surfaces : fond froid, lignes blanches sur filets */
  --ground:     #f3eee4;
  --surface:    #fffdf8;
  --surface-2:  #f8f4ea;
  --rule:       #ddd5c3;
  --rule-strong:#a99f8a;
  --ink:        #102a43;
  --ink-2:      #34495e;
  --ink-3:      #4a6278;

  /* Coque : bleu pétrole de la ville, liseré jaune signal */
  --shell:      #005378;
  --shell-2:    #186485;
  --shell-ink:  #ffffff;
  --shell-ink-2:#d6e8f0;
  --signal:     #f0a531;
  --accent:     #00abc2;

  /* États : champs pastel + encre foncée (contraste ≥ 7:1), texte d'état en toutes lettres */
  --libre:      #b8ecf3;  --libre-ink:  #00424d;
  --ticket:     #fde3a8;  --ticket-ink: #5a3a05;
  --sortie:     #d9d5ff;  --sortie-ink: #1d10a0;
  --retard:     #f4b3a4;  --retard-ink: #6e1a0a;
  --retard-line:#b42a12;
  --retard-wash:#fbe9e3;
  /* Texte d'état sur surface claire */
  --libre-text: #006478;
  --ticket-text:#8a5208;
  --sortie-text:#3b29ff;
  --retard-text:#b42a12;

  --link:   #3b29ff;
  --focus:  #3b29ff;
  --select: #f7d9a0;

  /* Surface inversée (toast) : marques lisibles sur l'encre */
  --inverse-libre:  #3cc47a;
  --inverse-sortie: #6fa6ff;
  --stripes-ticket:   repeating-linear-gradient(-45deg, #e8b84a 0 3px, transparent 3px 9px);
  --stripes-overtime: repeating-linear-gradient(-45deg, var(--retard) 0 6px, #1a0004 6px 10px);

  --radius: 12px;
  --radius-btn: 9px;
  --shadow-sm: 0 1px 2px rgba(16,42,67,.06), 0 2px 8px rgba(16,42,67,.05);
  --pill: 999px;
  --bar-h:  56px;
  --band-h: 52px;
  --tab-h:  0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease:   cubic-bezier(.22, 1, .36, 1);
}

/* ── 3. Base ──────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--ground);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
p a, .link { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--select); color: var(--ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border: 2px solid var(--surface-2); }
html { scrollbar-color: var(--rule-strong) var(--surface-2); }

.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only, .sr-only-mobile { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link {
  position: absolute; left: .75rem; top: -4rem; z-index: 300;
  background: var(--signal); color: var(--ticket-ink); padding: .7rem 1rem; font-weight: 800;
}
.skip-link:focus { top: .5rem; }

main { flex: 1; }
.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 1.5rem; }
.page-section { padding: 1.25rem 0 3rem; }

/* ── 4. Coque : barre du haut, onglets du bas ─────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--bar-h); background: var(--shell); color: var(--shell-ink);
}
.topbar-inner { height: 100%; max-width: 1440px; margin: 0 auto; padding: 0 .5rem 0 1.5rem; display: flex; align-items: center; gap: 1.5rem; }
.brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; min-height: 48px; }
.brand img { width: 26px; height: 29px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.06rem; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; font-size: .78rem; color: var(--shell-ink-2); }

.topnav-wrap { align-self: stretch; }
.topnav { height: 100%; display: flex; list-style: none; }
.topnav a {
  height: 100%; display: flex; align-items: center; gap: .5rem; padding: 0 1rem;
  color: var(--shell-ink-2); font-weight: 700; font-size: .95rem;
  box-shadow: inset 0 -3px 0 transparent;
}
.topnav a:hover { color: var(--shell-ink); background: var(--shell-2); }
.topnav a[aria-current="page"] { color: var(--shell-ink); box-shadow: inset 0 -3px 0 var(--signal); }
.topnav .icon { width: 1.15rem; height: 1.15rem; }

.topbar-clock { display: none; font-size: 1.35rem; font-weight: 800; padding: 0 .5rem; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.topbar-user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; padding: 0 .75rem; font-weight: 700; font-size: .92rem; }
.topbar-user small { font-weight: 500; font-size: .78rem; color: var(--shell-ink-2); }
.topbar-btn {
  min-width: 48px; height: 48px; padding: 0 .75rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  background: none; border: 0; color: var(--shell-ink-2); font-weight: 700; font-size: .92rem; cursor: pointer;
}
.topbar-btn:hover { color: var(--shell-ink); background: var(--shell-2); }
.topbar-btn--solid { background: var(--signal); color: var(--ticket-ink); }
.topbar-btn--solid:hover { filter: brightness(1.1); }
.topbar :focus-visible { outline-color: var(--signal); outline-offset: -3px; }

.tabbar { display: none; }

/* ── 5. Boutons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: 0 1rem; border: 1px solid transparent; border-radius: var(--radius-btn);
  font-weight: 800; font-size: .95rem; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, filter .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { filter: brightness(1.25); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-danger { background: var(--surface); color: var(--retard-text); border-color: var(--rule-strong); }
.btn-danger:hover { background: var(--retard-wash); border-color: var(--retard-text); }
.btn-danger-solid { background: var(--retard); color: var(--retard-ink); }
.btn-danger-solid:hover { filter: brightness(1.12); }
.btn-sm { min-height: 36px; padding: 0 .75rem; font-size: .88rem; }
.btn-lg { min-height: 52px; padding: 0 1.4rem; font-size: 1rem; }
.btn-icon { width: 44px; padding: 0; }
.btn-full { width: 100%; }

/* Actions d'exploitation : le bouton porte la couleur de l'état produit */
.btn-vendre { background: var(--ticket); color: var(--ticket-ink); }
.btn-sortir { background: var(--sortie); color: var(--sortie-ink); }
.btn-retour { background: var(--libre); color: var(--libre-ink); }
.btn-vendre:hover, .btn-sortir:hover, .btn-retour:hover { filter: brightness(1.1); }

/* Requête HTMX en cours : bouton figé, curseur d'attente */
.htmx-request .btn, .btn.htmx-request { opacity: .55; pointer-events: none; cursor: progress; }

.btn-group { display: inline-flex; align-items: stretch; }
.btn-group > * { border-radius: 0; }
.btn-group > :first-child { border-radius: var(--radius-btn) 0 0 var(--radius-btn); }
.btn-group > :last-child { border-radius: 0 var(--radius-btn) var(--radius-btn) 0; }
.btn-group > * + * { margin-left: -1px; }

/* ── 6. Marques de balisage & badges ──────────────────────────── */
.mark { width: 1em; height: 1em; flex-shrink: 0; fill: currentColor; }
.mark-libre  { color: var(--libre-text); }
.mark-ticket { color: var(--ticket-text); }
.mark-sortie { color: var(--sortie-text); }
.mark-retard { color: var(--retard-text); }
/* Couleur propre du bateau : carré, jamais rond (le rond est la marque « sorti ») */
.color-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25); }

.badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .5rem; border-radius: 2px;
  font-size: .8rem; font-weight: 800; white-space: nowrap; line-height: 1.2;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--rule);
}
.badge .mark { width: .8rem; height: .8rem; }
.badge-ticket { background: var(--ticket); color: var(--ticket-ink); border-color: transparent; }
.badge-sortie { background: var(--sortie); color: var(--sortie-ink); border-color: transparent; }
.badge-retard { background: var(--retard); color: var(--retard-ink); border-color: transparent; }
.badge-strong { background: var(--ink); color: var(--surface); border-color: transparent; }

/* ── 7. Notices, toasts, dialogue ─────────────────────────────── */
.notice {
  display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .9rem;
  border: 1px solid var(--rule-strong); background: var(--surface-2); font-size: .93rem;
}
.notice .icon { margin-top: .05rem; }
.notice-error { border-color: var(--retard-text); background: var(--retard-wash); color: var(--retard-text); font-weight: 700; }

.toast-stack {
  position: fixed; z-index: 400; top: calc(var(--bar-h) + .5rem); right: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
  width: min(420px, calc(100vw - 1rem)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: .65rem;
  min-height: 56px; padding: .4rem .4rem .4rem .9rem;
  background: var(--ink); color: var(--surface); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .28);
  font-weight: 700; font-size: .95rem;
  animation: toast-in .2s var(--ease);
}
.toast > span { flex: 1; padding: .35rem 0; }
.toast > .mark { width: 14px; height: 14px; }
.toast-success > .mark { color: var(--inverse-libre); }
.toast-info > .mark { color: var(--inverse-sortie); }
.toast-warning > .mark { color: var(--ticket); }
.toast-error { background: var(--retard); color: var(--retard-ink); }
.toast-action {
  flex-shrink: 0; min-height: 48px; padding: 0 1.1rem; border: 0; border-radius: var(--radius-btn);
  background: var(--signal); color: var(--ticket-ink); font-weight: 800; font-size: 1rem; cursor: pointer;
}
.toast-close {
  flex-shrink: 0; width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: inherit; opacity: .75; cursor: pointer;
}
.toast-close:hover { opacity: 1; }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.dialog {
  margin: auto; padding: 0; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 2rem));
  box-shadow: 0 16px 48px rgb(0 0 0 / .35);
}
.dialog::backdrop { background: rgb(5 8 10 / .6); }
.dialog[open] { animation: toast-in .18s var(--ease); }
.dialog-body { padding: 1.4rem 1.4rem 1rem; }
.dialog-title { display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; margin-bottom: .5rem; }
.dialog-title .mark { color: var(--retard-text); width: 1.1rem; height: 1.1rem; }
.dialog-text { font-size: .95rem; color: var(--ink-2); white-space: pre-line; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.4rem 1.3rem; flex-wrap: wrap; }
.dialog-actions .btn { min-height: 48px; min-width: 7.5rem; }

/* ── 8. Formulaires ───────────────────────────────────────────── */
.form-field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.1rem; }
.form-field > label { font-weight: 700; font-size: .93rem; }
.form-optional { font-weight: 500; color: var(--ink-3); }
:where(select, textarea, input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="color"]) {
  width: 100%; min-height: 48px; padding: .6rem .8rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  font-size: 1rem;
}
textarea { min-height: 6rem; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356616b' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 1.1rem;
}
input[type="color"] { padding: .3rem; height: 48px; cursor: pointer; }
::placeholder { color: var(--ink-3); opacity: 1; }
select:hover, textarea:hover, input:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
.has-error select, .has-error textarea, .has-error input { border-color: var(--retard-text); border-width: 2px; }
.form-error { display: flex; align-items: center; gap: .4rem; color: var(--retard-text); font-weight: 700; font-size: .9rem; }
.form-error .mark { width: .85rem; height: .85rem; }
.form-help { font-size: .87rem; color: var(--ink-3); }
.form-check { flex-direction: row; align-items: center; gap: .6rem; min-height: 48px; cursor: pointer; font-weight: 700; }
.form-check input { width: 22px; height: 22px; accent-color: var(--ink); }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; padding-top: .4rem; }
.form-panel { max-width: 640px; background: var(--surface); border: 1px solid var(--rule); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-panel .notice { margin-bottom: 1.1rem; }

.password-field { position: relative; }
.password-field input { padding-right: 3.5rem; }
.password-toggle {
  position: absolute; right: 0; top: 0; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--ink-3); cursor: pointer;
}
.password-toggle[aria-pressed="true"] { color: var(--ink); }

/* ── 9. En-têtes de page ──────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-title { font-size: 1.5rem; }
.page-title small { display: block; font-size: .9rem; font-weight: 600; color: var(--ink-3); letter-spacing: 0; margin-top: .1rem; }
.page-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.clock { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.date-input { min-height: 44px; width: auto; }

.empty-state { padding: 3rem 1.5rem; text-align: center; border: 1px solid var(--rule); border-top: 4px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.empty-state h2 { font-size: 1.25rem; margin-bottom: .35rem; }
.empty-state p { color: var(--ink-2); margin-bottom: 1rem; }

/* ── 10. Sorties : lignes d'embarcation ───────────────────────── */
/* Bandeau des retards (rempli par app.js) */
.late-band {
  position: sticky; top: var(--bar-h); z-index: 60;
  width: 100%; height: var(--band-h); display: flex; align-items: center; gap: .7rem; padding: 0 1rem;
  background: var(--retard); color: var(--retard-ink); border: 0; text-align: left;
  font-weight: 800; font-size: 1.05rem; cursor: pointer; margin-bottom: .75rem;
}
.late-band .mark { width: 1.1rem; height: 1.1rem; }
.late-band-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.late-band-go { display: flex; align-items: center; gap: .15rem; font-size: .92rem; }

/* Filtres par état */
.filters {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--rule); margin-bottom: 1rem;
}
.filter {
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  padding: .3rem .2rem; background: none; border: 0; border-left: 1px solid var(--rule); cursor: pointer; color: var(--ink);
}
.filter:first-child { border-left: 0; }
.filter strong { font-size: 1.45rem; font-weight: 800; line-height: 1; }
.filter span { display: flex; align-items: center; gap: .3rem; font-size: .84rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.filter .mark { width: .85rem; height: .85rem; }
.filter:hover { background: var(--surface-2); }
.filter[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.filter[aria-pressed="true"] span, .filter[aria-pressed="true"] .mark { color: inherit; }
.filter.is-alert strong { color: var(--retard-text); }
.filter.is-alert[aria-pressed="true"] { background: var(--retard); color: var(--retard-ink); }
.filter.is-alert[aria-pressed="true"] strong { color: inherit; }

.ponton-section { margin-bottom: 1.25rem; }
.ponton-section.is-empty { display: none; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; font-size: 1.05rem; padding: .35rem 0 .5rem; }
.section-title small { font-size: .88rem; font-weight: 600; color: var(--ink-3); }

.rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: .5rem; }
.rows-empty { grid-column: 1 / -1; color: var(--ink-3); font-size: .93rem; padding: .5rem 0; }

/* Une ligne = plaque d'état | nom + chiffre | action */
.tile {
  display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: stretch;
  min-height: 72px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.tile-state {
  grid-row: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  padding: .4rem .2rem; font-size: .82rem; font-weight: 800; text-align: center;
}
.tile-state .mark { width: 1.15rem; height: 1.15rem; color: inherit; }
.tile--libre    .tile-state { background: var(--libre);  color: var(--libre-ink); }
.tile--reservee .tile-state { background: var(--ticket); color: var(--ticket-ink); }
.tile--sortie   .tile-state { background: var(--sortie); color: var(--sortie-ink); }
.tile--sortie.is-late .tile-state { background: var(--retard); color: var(--retard-ink); }
/* Ligne libre : 2 rangées (nom, puis champ client + Vendre), la plaque couvre les deux */
.tile--libre .tile-state { grid-row: 1 / 3; }
.tile .mark-when-late { display: none; }
.tile.is-late .mark-when-late { display: block; }
.tile.is-late .mark-when-ontime { display: none; }
.tile .text-when-late { display: none; }
.tile.is-late .text-when-late { display: inline; }
.tile.is-late .text-when-ontime { display: none; }
.tile.is-late { background: var(--retard-wash); border: 2px solid var(--retard-line); }

.tile-body { padding: .45rem .75rem; display: flex; flex-direction: column; justify-content: center; gap: .1rem; min-width: 0; }
.tile-name { display: flex; align-items: center; gap: .45rem; font-size: 1.1rem; font-weight: 800; min-width: 0; }
.tile-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: .92rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-figure { display: block; font-size: 1.25rem; font-weight: 800; line-height: 1.15; color: var(--ink); }
.tile.is-late .tile-figure { color: var(--retard-text); }

.tile-action { display: flex; align-items: center; padding: .6rem .7rem .6rem 0; }
.tile-action .btn { min-width: 108px; min-height: 52px; font-size: 1.02rem; }
/* Ligne libre : le champ client rejoint le bouton sous le nom */
.tile-sell { grid-column: 2 / -1; display: flex; gap: .5rem; padding: 0 .7rem .7rem .75rem; }
.tile-input { flex: 1; min-width: 0; min-height: 52px; font-size: 1rem; background: var(--surface-2); }

/* Retour visuel après échange HTMX : la nouvelle ligne s'éclaire brièvement */
.tile.htmx-added { animation: tile-in .7s var(--ease); }
@keyframes tile-in { from { box-shadow: 0 0 0 4px var(--signal); } to { box-shadow: 0 0 0 0 transparent; } }

/* Filtres : masquer les lignes hors filtre */
[data-filter="libre"]    .tile:not([data-statut="libre"]),
[data-filter="reservee"] .tile:not([data-statut="reservee"]),
[data-filter="sortie"]   .tile:not([data-statut="sortie"]),
[data-filter="retard"]   .tile:not(.is-late) { display: none; }

/* ── 11. Planning ─────────────────────────────────────────────── */
.legend { display: flex; align-items: center; gap: .5rem 1.25rem; flex-wrap: wrap; margin-bottom: 1rem; font-size: .92rem; font-weight: 700; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-item strong { color: var(--ink); font-size: 1.05rem; }
.legend-swatch { width: 22px; height: 12px; flex-shrink: 0; border-radius: 1px; }
.legend-now { width: 2px; height: 16px; background: var(--ink); }
.rental-swatch { background: var(--sortie); }
.ticket-swatch { background: var(--stripes-ticket); box-shadow: inset 0 0 0 1px var(--ticket-text); }
.done-swatch { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--rule-strong); }
.overtime-swatch { background: var(--stripes-overtime); }

#tl-container { margin-bottom: 1.5rem; border: 1px solid var(--rule); background: var(--surface); overflow: hidden; }
.tl-toolbar, .mob-tl-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .4rem .5rem .4rem .9rem; background: var(--surface-2); border-bottom: 1px solid var(--rule);
}
.tl-toolbar-info { font-size: .88rem; font-weight: 700; color: var(--ink-3); }
.tl-toolbar-actions { display: flex; gap: .4rem; }
.fs-btn .icon-compress { display: none; }
.tl-fullscreen .fs-btn .icon-expand   { display: none; }
.tl-fullscreen .fs-btn .icon-compress { display: block; }

.tl-wrap, .mob-tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
#tl-inner, .mob-tl-inner { position: relative; display: inline-block; min-width: 100%; vertical-align: top; }

.tl-row, .mob-tl-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--rule); }
.tl-row:last-child, .mob-tl-row:last-child { border-bottom: none; }

.tl-label, .mob-tl-label {
  position: sticky; left: 0; z-index: 20; flex-shrink: 0;
  width: 248px; min-width: 248px; padding: .3rem .6rem .3rem .8rem;
  display: flex; align-items: center; gap: .55rem;
  background: var(--surface); border-right: 1px solid var(--rule-strong);
}
.mob-tl-label { width: 150px; min-width: 150px; padding: .25rem .45rem; gap: .35rem; }
.tl-label-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tl-label-name { font-size: .98rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label-state { display: flex; align-items: center; gap: .3rem; font-size: .82rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-label-state .mark { width: .75rem; height: .75rem; }
.tl-label form { margin: 0; flex-shrink: 0; }
.tl-label .btn { min-height: 48px; min-width: 76px; padding: 0 .6rem; font-size: .88rem; }
.mob-tl-label .tl-label-name { font-size: .86rem; line-height: 1.15; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mob-tl-label .btn { min-height: 48px; min-width: 0; padding: 0 .5rem; font-size: .8rem; }

.tl-track, .mob-tl-track { position: relative; flex: 1; }

.tl-row-axis, .mob-tl-row-axis { height: 36px; background: var(--surface-2); border-bottom: 1px solid var(--rule-strong); }
.tl-row-axis .tl-label, .mob-tl-row-axis .mob-tl-label { background: var(--surface-2); font-size: .84rem; font-weight: 700; color: var(--ink-3); }
.hour-tick, .mob-tl-tick {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  font-size: .86rem; font-weight: 800; color: var(--ink-2); white-space: nowrap; pointer-events: none;
}
.hour-tick-last, .mob-tl-tick-last { transform: translate(-100%, -50%); }
.hour-tick-day { background: var(--signal); color: var(--ticket-ink); padding: 0 .35rem; }

.tl-row-ponton, .mob-tl-row-ponton { height: 34px; background: var(--surface-2); }
.tl-row-ponton .tl-label, .mob-tl-row-ponton .mob-tl-label { background: var(--surface-2); font-size: .95rem; font-weight: 800; }

.tl-row-emb { height: 58px; }
.mob-tl-row-emb { height: 52px; }
.tl-row-emb:hover, .tl-row-emb:hover .tl-label { background: var(--surface-2); }

.grid-h, .grid-hh, .mob-tl-gh, .mob-tl-ghh { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rule); pointer-events: none; }
.grid-hh, .mob-tl-ghh { opacity: .45; }
.grid-day { width: 2px; background: var(--ink); opacity: .6; }

/* Ticket vendu : hachures jaunes depuis la vente */
.reserved-block {
  position: absolute; top: 6px; bottom: 6px; z-index: 1; pointer-events: none;
  background: var(--stripes-ticket);
  box-shadow: inset 1px 0 0 var(--ticket-text);
  opacity: .9;
}
/* Location : bleu tant que non rendue, neutre une fois rendue */
.rental-block {
  position: absolute; top: 10px; bottom: 10px; z-index: 10; min-width: 6px;
  display: flex; align-items: center; justify-content: center; padding: 0 8px;
  border-radius: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: .84rem; font-weight: 800; cursor: default;
  background: var(--sortie); color: var(--sortie-ink);
}
.rental-block.is-done { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule-strong); }
.rental-block.is-narrow { font-size: 0; padding: 0; }
/* Dépassement : rayures rouge / noir (marque de danger isolé) */
.overtime-block {
  position: absolute; top: 10px; bottom: 10px; z-index: 11; min-width: 4px;
  background: var(--stripes-overtime);
}
.now-line, .mob-tl-now {
  position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; z-index: 9; pointer-events: none;
  background: var(--ink);
}
.now-pill {
  position: absolute; top: 50%; transform: translate(-50%, -50%); z-index: 13; pointer-events: none;
  padding: .15rem .45rem; background: var(--ink); color: var(--surface);
  font-size: .84rem; font-weight: 800; white-space: nowrap;
}

/* Plein écran (affichage mural) */
#tl-container.tl-fullscreen { position: fixed; inset: 0; z-index: 9999; margin: 0; border: none; display: flex; flex-direction: column; }
#tl-container.tl-fullscreen .tl-wrap { flex: 1; overflow: auto; }
#tl-container.tl-fullscreen .tl-row-axis { position: sticky; top: 0; z-index: 30; }
#tl-container.tl-fullscreen .tl-row-axis .tl-label { z-index: 31; }
body.tl-fs-active { overflow: hidden; }

/* Planning mobile : choix de vue */
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--rule-strong); margin-bottom: 1rem; background: var(--surface); }
.segmented button {
  min-height: 48px; border: 0; background: none; color: var(--ink-2); font-weight: 800; font-size: .95rem; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--rule-strong); }
.segmented button.active { background: var(--ink); color: var(--surface); }
.mob-tl-outer { border: 1px solid var(--rule); background: var(--surface); overflow: hidden; margin-bottom: 1.5rem; }
.mob-tl-row-axis { position: sticky; top: 0; z-index: 15; height: 30px; }
.mob-tl-tick { font-size: .78rem; }

/* ── 12. Gestion (administration) ─────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - var(--bar-h)); }
.admin-sidebar { width: 220px; flex-shrink: 0; padding: 1rem .6rem; background: var(--surface); border-right: 1px solid var(--rule); }
.admin-sidebar nav { position: sticky; top: calc(var(--bar-h) + 1rem); display: flex; flex-direction: column; gap: 2px; }
.sidebar-heading { padding: .9rem .7rem .3rem; font-size: .8rem; font-weight: 800; color: var(--ink-3); }
.sidebar-heading:first-child { padding-top: 0; }
.sidebar-link {
  display: flex; align-items: center; gap: .6rem; min-height: 44px; padding: 0 .7rem;
  font-weight: 700; font-size: .95rem; color: var(--ink-2); border-radius: var(--radius);
}
.sidebar-link .icon { width: 1.1rem; height: 1.1rem; }
.sidebar-link:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-link.active { background: var(--ink); color: var(--surface); }
.admin-main { flex: 1; min-width: 0; padding: 1.5rem 2rem 3rem; }

/* Tableau de bord : listes de liens, chiffre à droite */
.panel { background: var(--surface); border: 1px solid var(--rule); }
.panel-title { font-size: 1rem; padding: .8rem 1rem; border-bottom: 1px solid var(--rule); }
.link-list { list-style: none; }
.link-list a { display: flex; align-items: center; gap: .65rem; min-height: 48px; padding: 0 1rem; font-weight: 700; border-top: 1px solid var(--rule); }
.link-list li:first-child a { border-top: 0; }
.link-list a:hover { background: var(--surface-2); }
.link-list .icon { color: var(--ink-3); }
.link-list a > span { flex: 1; }
.link-list .count { flex: none; font-size: 1.15rem; font-weight: 800; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); }
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data-table th {
  position: sticky; top: 0; text-align: left; padding: 0; background: var(--surface-2);
  border-bottom: 1px solid var(--rule-strong); font-size: .86rem; font-weight: 800; color: var(--ink-2); white-space: nowrap;
}
.data-table th > span, .th-sort { display: flex; align-items: center; gap: .35rem; width: 100%; min-height: 44px; padding: 0 .8rem; }
.th-sort { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.th-sort:hover { color: var(--ink); background: var(--rule); }
.th-sort .icon { width: .9rem; height: .9rem; opacity: .35; }
th.cell-num .th-sort { justify-content: flex-end; }
th[aria-sort] .th-sort { color: var(--ink); }
th[aria-sort] .th-sort .icon { opacity: 1; }
th[aria-sort="descending"] .th-sort .icon { transform: rotate(180deg); }
.data-table td { padding: .55rem .8rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.col-title { font-weight: 800; }
.cell-main { display: flex; align-items: center; gap: .55rem; }
.cell-muted { color: var(--ink-2); }
.cell-num { text-align: right; }
.cell-clip { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.col-actions { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.row-actions form { display: contents; }
.empty-row td { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3); }
.user-avatar {
  width: 28px; height: 28px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--surface); font-size: .82rem; font-weight: 800; text-transform: uppercase;
}

/* ── 13. Connexion ────────────────────────────────────────────── */
.login-page { background: var(--ground); }
.login-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; gap: 1rem; }
.login-card { width: min(400px, 100%); background: var(--surface); color: var(--ink); border-radius: var(--radius); overflow: hidden; box-shadow: 0 14px 34px rgba(16,42,67,.2); }
.login-head { display: flex; align-items: center; gap: .9rem; padding: 1.2rem 1.4rem; background: var(--shell); color: var(--shell-ink); border-radius: var(--radius) var(--radius) 0 0; }
.login-head img { width: 44px; height: 48px; }
.login-head h1 { font-size: 1.35rem; }
.login-head p { font-size: .9rem; color: var(--shell-ink-2); font-weight: 600; }
.login-card form { padding: 1.3rem 1.4rem 1.4rem; }
.login-card .notice { margin: 1.1rem 1.4rem 0; }
.login-foot { padding: .9rem 1.4rem; background: #fff; border-top: 1px solid var(--rule); }
.login-foot img { width: 100%; height: auto; max-width: 260px; margin: 0 auto; }
.login-link { display: inline-flex; align-items: center; gap: .5rem; min-height: 48px; padding: 0 .5rem; color: var(--link); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.login-page :focus-visible { outline-color: var(--signal); }
.login-page .login-card :focus-visible { outline-color: var(--focus); }

/* ── 14. Responsive ───────────────────────────────────────────── */
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
  .sr-only-mobile { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .mobile-planning, .mob-tl-outer, .segmented { display: none !important; }
}

@media (max-width: 1023px) {
  .topbar-user { display: none; }
  .topnav a { padding: 0 .75rem; }
  .admin-sidebar { width: 190px; }
  .admin-main { padding: 1.25rem 1.25rem 2.5rem; }
}

@media (max-width: 768px) {
  body.has-tabbar { --tab-h: 64px; }
  .hide-mobile { display: none !important; }
  .container { padding: 0 .75rem; }
  .page-section { padding: .9rem 0 2rem; }

  .topbar-inner { padding: 0 0 0 .75rem; gap: .5rem; }
  .topnav-wrap { display: none; }
  .topbar-clock { display: block; margin-left: auto; }
  .topbar-clock + .topbar-end { margin-left: 0; }
  .page-section--flush { padding-top: 0; }
  .topbar-btn { padding: 0; }
  .topbar-btn--solid { padding: 0 .9rem; }

  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--shell);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    font-size: .82rem; font-weight: 700; color: var(--shell-ink-2); position: relative;
  }
  .tab .icon { width: 1.5rem; height: 1.5rem; }
  .tab.active { color: var(--shell-ink); box-shadow: inset 0 3px 0 var(--signal); }
  .tab:focus-visible { outline-color: var(--signal); outline-offset: -3px; }
  .tab-badge {
    position: absolute; top: 6px; left: calc(50% + 6px); min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
    background: var(--retard); color: var(--retard-ink); font-size: .8rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
  }

  .toast-stack { left: .5rem; right: .5rem; width: auto; top: calc(var(--bar-h) + .4rem); }
  .has-late-band .toast-stack { top: calc(var(--bar-h) + var(--band-h) + .4rem); }

  .page-header { margin-bottom: .75rem; }
  .page-title { font-size: 1.3rem; }
  .clock { font-size: 1.5rem; }

  .late-band { margin: 0 -.75rem .6rem; width: calc(100% + 1.5rem); }
  .filters { margin: 0 -.75rem .9rem; border-left: 0; border-right: 0; }
  .filter span { font-size: .78rem; }
  .filter strong { font-size: 1.35rem; }

  .rows { gap: 1px; margin: 0 -.75rem; background: var(--rule); border-block: 1px solid var(--rule); }
  .tile { border: 1px solid var(--rule); }
  .tile.is-late { box-shadow: inset 0 0 0 2px var(--retard-line); }
  .section-title { padding-top: .5rem; }

  #tl-container { display: none !important; }

  /* Gestion : menu latéral → onglets défilants, tables → fiches */
  .admin-layout { flex-direction: column; min-height: 0; }
  .admin-sidebar { width: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--rule); position: sticky; top: var(--bar-h); z-index: 50; }
  .admin-sidebar nav { position: static; flex-direction: row; gap: 0; overflow-x: auto; scrollbar-width: none; }
  .admin-sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar-heading, .sidebar-secondary { display: none; }
  .sidebar-link { flex-shrink: 0; min-height: 48px; padding: 0 .9rem; border-radius: 0; font-size: .92rem; }
  .sidebar-link .icon { display: none; }
  .sidebar-link.active { background: none; color: var(--ink); box-shadow: inset 0 -3px 0 var(--ink); }
  .admin-main { padding: 1rem .75rem 2rem; }

  .table-wrap { border: 0; background: none; overflow: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tbody tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .1rem .75rem;
    background: var(--surface); border: 1px solid var(--rule); padding: .6rem .8rem .7rem; margin-bottom: .5rem;
  }
  .data-table tbody tr:hover td { background: none; }
  .data-table td { padding: .2rem 0; border: 0; font-size: .93rem; min-width: 0; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; font-weight: 700; color: var(--ink-3); }
  .data-table td.col-title { grid-column: 1 / -1; font-size: 1.05rem; padding-bottom: .35rem; }
  .data-table td.col-actions { grid-column: 1 / -1; width: 100%; padding-top: .55rem; }
  .data-table .row-actions { justify-content: stretch; }
  .data-table .row-actions .btn { flex: 1; min-height: 44px; }
  .data-table .empty-row { display: block; }
  .data-table .empty-row td { padding: 2rem 0; }
  .cell-clip { max-width: 100%; }
  .data-table td.cell-num { text-align: left; }
  .form-panel { padding: 1rem; border-left: 0; border-right: 0; margin: 0 -.75rem; }
  .form-actions .btn { flex: 1; }
}

@media (max-width: 359px) {
  .filter span { font-size: 0; }
  .filter .mark { width: 1rem; height: 1rem; }
}

/* ── 15. Mouvement réduit, impression ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  /* L'état reste lisible : la ligne échangée garde un liseré fixe le temps du réglage */
  .tile.htmx-added { box-shadow: 0 0 0 3px var(--signal); }
}

@media print {
  .topbar, .tabbar, .toast-stack, .admin-sidebar, .page-actions, .tl-toolbar, .late-band, .filters { display: none !important; }
  body { background: #fff; padding: 0; }
}

/* ── Pastel : pas de pictogrammes d'état, bords discrets ──────── */
.tile-state .mark, .filter .mark, .badge .mark, .late-band .mark, .tl-label-state .mark,
.legend-item .mark, .tile-state .mark-when-ontime, .tile-state .mark-when-late { display: none; }
.btn-vendre, .btn-sortir, .btn-retour, .badge-ticket, .badge-sortie, .badge-retard { box-shadow: inset 0 0 0 1px rgb(16 42 67 / .16); }
.btn-vendre:hover, .btn-sortir:hover, .btn-retour:hover { filter: brightness(.96); }
.tile-state { border-right: 1px solid rgb(16 42 67 / .12); }
