:root {
  --fond: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --texte: #14202b;
  --texte-2: #5b6b7a;
  --bord: #d9e0e6;
  --accent: #0f766e;
  --accent-texte: #ffffff;
  --accent-doux: #d7f0ec;
  --danger: #b42318;
  --ok: #15803d;
  --attente: #b45309;
  --ombre: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --rayon: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0d1418;
    --surface: #152027;
    --surface-2: #1c2a33;
    --texte: #e6edf2;
    --texte-2: #93a4b2;
    --bord: #2a3a45;
    --accent: #2dd4bf;
    --accent-texte: #062a26;
    --accent-doux: #12352f;
    --danger: #f97066;
    --ok: #4ade80;
    --attente: #fbbf24;
    --ombre: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0d1418; --surface: #152027; --surface-2: #1c2a33; --texte: #e6edf2; --texte-2: #93a4b2;
  --bord: #2a3a45; --accent: #2dd4bf; --accent-texte: #062a26; --accent-doux: #12352f;
  --danger: #f97066; --ok: #4ade80; --attente: #fbbf24; --ombre: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.cache { display: none !important; }
.discret { color: var(--texte-2); }
.petit { font-size: .85rem; }

.entete {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
.marque { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.pastilles { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.fleche-sens { color: var(--accent); font-weight: 700; font-size: 1rem; line-height: 1; }
.pastille {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--texte-2); white-space: nowrap;
}
.pastille::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--texte-2); }
.pastille.eveille::before { background: var(--ok); }
.pastille.veille::before { background: var(--attente); }
.pastille.hors::before { background: var(--danger); }

.ecran { max-width: 720px; margin: 0 auto; padding: 16px; }
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; }
.formulaire { display: flex; flex-direction: column; gap: 12px; margin-top: 8vh; }
.formulaire h1 { margin: 0; font-size: 1.4rem; }
.formulaire p { margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--texte-2); }
input[type=text], input[type=password], input[type=search], input:not([type]) {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--bord); border-radius: 10px; background: var(--fond); color: var(--texte);
}
input:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.erreur { color: var(--danger); min-height: 1.2em; font-size: .9rem; }

button.principal {
  min-height: 48px; border: 0; border-radius: 12px; padding: 0 18px;
  background: var(--accent); color: var(--accent-texte); font-weight: 650;
}
button.principal:disabled { opacity: .45; cursor: not-allowed; }
button.secondaire, .barre-outils button, .actions-carte button {
  min-height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
}
button.danger { color: var(--danger); }
button.large { width: 100%; margin-top: 16px; }
button.lien { background: none; border: 0; color: var(--accent); padding: 6px 0; text-decoration: underline; }

.onglets {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 12px;
}
.onglets button {
  min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--texte-2);
  font-size: .88rem; font-weight: 600; padding: 0 2px;
  display: flex; align-items: center; justify-content: center; gap: 3px; white-space: nowrap;
}
.onglets button[aria-selected="true"] { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); }

.etat-nas { margin: 0 0 10px; font-size: .9rem; color: var(--texte-2); }
.barre-outils { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.barre-outils button { flex: 1 1 auto; }

.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.element { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 12px; box-shadow: var(--ombre); }
.element.decoche { opacity: .6; }
.ligne-titre { display: flex; gap: 10px; align-items: flex-start; }
.ligne-titre input[type=checkbox] { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.nom { font-weight: 600; overflow-wrap: anywhere; }
.infos { font-size: .85rem; color: var(--texte-2); }
.recent { color: var(--attente); }
.bouton-destination {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 44px; margin-top: 10px; padding: 8px 12px;
  border: 1px dashed var(--bord); border-radius: 10px; background: var(--fond); text-align: left;
}
.bouton-destination.choisie { border-style: solid; border-color: var(--accent); background: var(--accent-doux); }
.bouton-destination span { overflow-wrap: anywhere; }
.actions-carte { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.actions-carte label { flex-direction: row; align-items: center; gap: 6px; margin-left: auto; font-size: .85rem; }
.actions-carte input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--danger); }

.pied {
  position: sticky; bottom: 0; margin: 12px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--bord);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.pied .discret { grid-column: 1 / -1; margin: 0; }
.resume { font-size: .9rem; }
.vide { text-align: center; color: var(--texte-2); padding: 32px 16px; background: var(--surface); border: 1px dashed var(--bord); border-radius: var(--rayon); }

.demande { border-color: var(--attente); margin-bottom: 12px; }
.demande p { margin: 0 0 10px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .08em; }
.boutons { display: flex; gap: 8px; flex-wrap: wrap; }
.carte-nas { margin-bottom: 10px; }
.carte-nas h3 { margin: 0 0 6px; font-size: 1.05rem; }
.carte-nas p { margin: 2px 0; font-size: .9rem; color: var(--texte-2); }

dialog {
  width: 100%; max-width: 720px; max-height: 92vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 18px 18px 0 0; background: var(--surface); color: var(--texte);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
@media (min-width: 760px) { dialog { margin: auto; border-radius: 18px; } }
.feuille { display: flex; flex-direction: column; gap: 10px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92vh; }
.feuille-entete { display: flex; align-items: center; justify-content: space-between; }
.feuille-entete h2 { margin: 0; font-size: 1.15rem; }
.fermer { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface-2); }
.fil { display: flex; flex-wrap: wrap; gap: 4px; font-size: .9rem; }
.fil button { border: 0; background: none; color: var(--accent); padding: 4px 2px; }
.fil span { color: var(--texte-2); }
.liste-dossiers { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 120px; border: 1px solid var(--bord); border-radius: 12px; }
.liste-dossiers li + li { border-top: 1px solid var(--bord); }
.liste-dossiers button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  min-height: 46px; padding: 8px 12px; border: 0; background: none; text-align: left;
}
.liste-dossiers .chemin { font-size: .8rem; color: var(--texte-2); display: block; }
.liste-dossiers .vide-dossier { padding: 14px; color: var(--texte-2); font-size: .9rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 999px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px);
}
.toast.visible { opacity: 1; }

.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-texte); font-size: .7rem; line-height: 18px; }
.etapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0 6px; }
.etape { font-size: .72rem; text-align: center; color: var(--texte-2); }
.etape::before { content: ""; display: block; height: 6px; border-radius: 3px; background: var(--surface-2); margin-bottom: 4px; }
.etape.faite::before { background: var(--accent); }
.etape.active { color: var(--texte); font-weight: 650; }
.etape.active::before { background: var(--accent); opacity: .55; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .etape.active::before { animation: none; } }
.message { font-size: .88rem; margin: 6px 0 0; }
.alerte { color: var(--attente); font-weight: 600; }
.erreur-carte { border-color: var(--danger); }
.conflit-carte { border-color: var(--attente); }
.historique .ligne { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; color: var(--texte-2); }
.note-envoyes { margin: 0 0 10px; font-size: .88rem; }
.espace-haut { margin-top: 10px; }
.etiquette { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); color: var(--texte-2); font-size: .72rem; font-weight: 600; vertical-align: middle; }
