/* Tableau — feuille de style. Thème clair/sombre suivant le système. */

:root {
  --fond: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --survol: rgba(0, 0, 0, .035);
  --ligne: rgba(0, 0, 0, .075);
  --texte: #1c1c1e;
  --texte-2: #5f5f66;
  --texte-3: #94949b;
  --accent: #4f46e5;
  --accent-doux: rgba(79, 70, 229, .1);
  --sur-accent: #ffffff;
  --retard: #dc3d43;
  --retard-doux: rgba(220, 61, 67, .1);
  --jour: #4f46e5;
  --attente: #b45309;
  --attente-doux: rgba(217, 119, 6, .12);
  --ok: #2f9e6a;
  --ombre: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --ombre-forte: 0 12px 48px rgba(0,0,0,.18);
  --verre: rgba(245, 245, 243, .82);
  --rayon: 14px;
  --police: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f0f11;
    --surface: #18181b;
    --surface-2: #222226;
    --survol: rgba(255, 255, 255, .04);
    --ligne: rgba(255, 255, 255, .08);
    --texte: #ececef;
    --texte-2: #a3a3ab;
    --texte-3: #6c6c74;
    --accent: #8f88ff;
    --accent-doux: rgba(143, 136, 255, .14);
    --sur-accent: #0f0f11;
    --retard: #ff6b70;
    --retard-doux: rgba(255, 107, 112, .13);
    --jour: #8f88ff;
    --attente: #f5a524;
    --attente-doux: rgba(245, 165, 36, .13);
    --ok: #4cc38a;
    --ombre: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
    --ombre-forte: 0 12px 48px rgba(0,0,0,.6);
    --verre: rgba(15, 15, 17, .8);
    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 var(--police);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sprites { display: none; }
kbd { font: 600 11px var(--police); padding: 1px 5px; border-radius: 5px; background: rgba(255,255,255,.2); margin-left: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* --- Mise en page ---------------------------------------------------------- */
.app { min-height: 100dvh; }
.barre-laterale { display: none; }
.principal {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 120px);
}
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 18px 2px 10px; }
.sur-titre { font-size: 13px; font-weight: 600; color: var(--texte-3); letter-spacing: .01em; min-height: 18px; }
h1 { font-size: 32px; line-height: 1.1; letter-spacing: -.025em; margin: 2px 0 0; font-weight: 750; }
.entete-actions { display: flex; gap: 8px; align-items: center; }
.bouton-icone { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--texte-2); }
.bouton-icone:hover { background: var(--survol); color: var(--texte); }
.bouton-principal {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--sur-accent); font-weight: 600; font-size: 15px;
  padding: 9px 14px; border-radius: 10px; transition: transform .1s, filter .15s;
}
.bouton-principal:hover { filter: brightness(1.08); }
.bouton-principal:active { transform: scale(.97); }
.bouton-principal:disabled { opacity: .5; cursor: default; }
.bouton-principal svg { width: 18px; height: 18px; stroke-width: 2.2; }
.ordinateur { display: none; }
.lien-discret { color: var(--accent); font-weight: 500; }

.barre-recherche {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; padding: 0 12px;
  background: var(--surface); border-radius: 12px; box-shadow: var(--ombre);
}
.barre-recherche svg { color: var(--texte-3); }
.barre-recherche input { flex: 1; border: 0; background: none; outline: none; padding: 12px 0; font-size: 16px; min-width: 0; }

/* --- Onglets (mobile) ------------------------------------------------------ */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 4px);
  background: var(--verre); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--ligne);
}
.onglet { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-size: 10.5px; font-weight: 600; color: var(--texte-3); position: relative; }
.onglet svg { width: 24px; height: 24px; }
.onglet[aria-current="page"] { color: var(--accent); }
.onglet .pastille { position: absolute; top: 0; left: calc(50% + 6px); }
.pastille {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--retard); color: #fff; font-variant-numeric: tabular-nums;
}
.bouton-flottant {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 21;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--sur-accent); box-shadow: 0 6px 20px rgba(79,70,229,.4);
  transition: transform .15s;
}
.bouton-flottant:active { transform: scale(.92); }
.bouton-flottant svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* --- Résumé du jour -------------------------------------------------------- */
.resume { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 18px; }
.indicateur {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--ombre); font-size: 13.5px; font-weight: 600; color: var(--texte-2);
}
.indicateur b { font-variant-numeric: tabular-nums; color: var(--texte); }
.indicateur .point { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.indicateur.retard { color: var(--retard); }
.indicateur.jour { color: var(--jour); }
.indicateur.attente { color: var(--attente); }
.indicateur.ok { color: var(--ok); }

/* --- Sections et tâches ---------------------------------------------------- */
.section { margin-bottom: 22px; }
.section-titre {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3);
  padding: 6px 4px 8px;
}
.section-titre .compte { font-weight: 600; color: var(--texte-3); letter-spacing: 0; text-transform: none; }
.section-titre.retard { color: var(--retard); }
.section-titre.jour { color: var(--jour); }
.section-titre svg.chevron { width: 14px; height: 14px; transition: transform .2s; stroke-width: 2.4; }
.section.ouverte > .section-titre svg.chevron { transform: rotate(90deg); }
.section.repliable:not(.ouverte) > .liste { display: none; }
.section-titre .droite { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }

.liste { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); overflow: hidden; }
.tache {
  display: flex; gap: 12px; padding: 13px 14px 13px 12px; position: relative; cursor: pointer;
  transition: background .15s, opacity .3s;
}
.tache + .tache::before { content: ""; position: absolute; top: 0; left: 46px; right: 0; border-top: 0.5px solid var(--ligne); }
.tache:hover { background: var(--survol); }
.coche {
  width: 24px; height: 24px; border-radius: 50%; flex: none; margin-top: 0;
  border: 1.8px solid var(--texte-3); display: grid; place-items: center; color: transparent;
  transition: background .2s, border-color .2s, transform .15s, color .2s;
  position: relative;
}
.coche::after { content: ""; position: absolute; inset: -10px; } /* cible tactile de 44 px */
.coche svg { width: 15px; height: 15px; stroke-width: 3; }
.coche:hover { border-color: var(--accent); color: var(--accent-doux); }
.coche:active { transform: scale(.88); }
.tache.retard .coche { border-color: var(--retard); }
.tache.faite .coche, .tache.cochee .coche { background: var(--ok); border-color: var(--ok); color: #fff; }
.tache.cochee .coche { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.18); } }
.tache.faite .titre, .tache.cochee .titre { color: var(--texte-3); text-decoration: line-through; text-decoration-color: var(--texte-3); }
.tache.cochee .suite, .tache.faite .suite { opacity: .6; }
.tache.sortante { opacity: 0; }
.corps { flex: 1; min-width: 0; }
.titre { font-size: 15.5px; line-height: 1.38; font-weight: 500; overflow-wrap: anywhere; }
.suite {
  font-size: 13.5px; line-height: 1.4; color: var(--texte-2); margin-top: 2px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mention { color: var(--accent); font-weight: 550; }
.titre code, .suite code, .texte-complet code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-size: 12.5px; color: var(--texte-3); font-weight: 500; }
.meta > span { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 13px; height: 13px; stroke-width: 2; }
.meta .date { font-variant-numeric: tabular-nums; }
.meta .date.retard { color: var(--retard); font-weight: 650; }
.meta .date.jour { color: var(--jour); font-weight: 650; }
.meta .attente { color: var(--attente); font-weight: 600; }
.meta .sujet { color: var(--texte-2); }

.vide { text-align: center; padding: 56px 20px; color: var(--texte-3); }
.vide svg { width: 44px; height: 44px; stroke-width: 1.3; color: var(--texte-3); opacity: .7; }
.vide p { margin: 10px 0 0; font-size: 15px; }
.vide strong { display: block; color: var(--texte-2); font-size: 17px; margin-top: 12px; }

/* --- Sujets ---------------------------------------------------------------- */
.ligne-sujet { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; position: relative; }
.ligne-sujet + .ligne-sujet::before { content: ""; position: absolute; top: 0; left: 50px; right: 0; border-top: 0.5px solid var(--ligne); }
.ligne-sujet:hover { background: var(--survol); }
.ligne-sujet .icone-sujet { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-doux); color: var(--accent); }
.ligne-sujet .icone-sujet svg { width: 16px; height: 16px; }
.ligne-sujet .nom { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-sujet .nombre { color: var(--texte-3); font-variant-numeric: tabular-nums; font-size: 14px; }
.ligne-sujet .chevron { color: var(--texte-3); width: 16px; height: 16px; }
.retour { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 500; font-size: 15px; margin-left: -6px; }

/* --- Feuille (détail, ajout) ---------------------------------------------- */
.voile { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.32); opacity: 0; transition: opacity .25s; }
.voile.visible { opacity: 1; }
.feuille {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--ombre-forte);
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.9,.25,1);
}
.feuille.visible { transform: none; }
.poignee { width: 36px; height: 5px; border-radius: 3px; background: var(--ligne); margin: 0 auto 12px; }
.feuille-entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.feuille-entete .sujet-feuille { font-size: 13px; font-weight: 600; color: var(--texte-3); display: inline-flex; gap: 6px; align-items: center; }
.feuille-entete .sujet-feuille svg { width: 14px; height: 14px; }
.feuille h2 { font-size: 20px; line-height: 1.3; letter-spacing: -.01em; margin: 4px 0 8px; font-weight: 650; }
.texte-complet { color: var(--texte-2); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.faits { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.fait { font-size: 12.5px; font-weight: 600; padding: 4px 9px; border-radius: 7px; background: var(--surface-2); color: var(--texte-2); display: inline-flex; gap: 5px; align-items: center; }
.fait svg { width: 13px; height: 13px; }
.fait.retard { background: var(--retard-doux); color: var(--retard); }
.fait.attente { background: var(--attente-doux); color: var(--attente); }
.bloc { margin-top: 18px; }
.bloc-titre { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); margin-bottom: 8px; }
.puces-choix { display: flex; flex-wrap: wrap; gap: 8px; }
.choix {
  padding: 8px 13px; border-radius: 10px; background: var(--surface-2); font-size: 14.5px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 6px; position: relative; transition: background .15s, transform .1s;
}
.choix:hover { background: var(--accent-doux); }
.choix:active { transform: scale(.96); }
.choix[aria-pressed="true"] { background: var(--accent); color: var(--sur-accent); }
.choix small { font-weight: 500; color: var(--texte-3); font-size: 12.5px; }
.choix[aria-pressed="true"] small { color: inherit; opacity: .8; }
.choix.danger { color: var(--retard); }
.choix input[type="date"] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.actions-feuille { display: flex; gap: 10px; margin-top: 24px; }
.actions-feuille .bouton-principal { flex: 1; padding: 13px; font-size: 16px; border-radius: 12px; }
.bouton-secondaire { flex: 1; padding: 13px; border-radius: 12px; background: var(--surface-2); font-weight: 600; }
.interrupteur { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.interrupteur span { font-weight: 550; font-size: 15px; }
.interrupteur small { display: block; color: var(--texte-3); font-weight: 500; font-size: 12.5px; }
.interrupteur input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--ligne); position: relative; transition: background .2s; flex: none; cursor: pointer; margin: 0; }
.interrupteur input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.interrupteur input:checked { background: var(--attente); }
.interrupteur input:checked::after { transform: translateX(18px); }
.champ-texte {
  width: 100%; border: 0; outline: none; resize: none; background: none; font-size: 19px; font-weight: 500; line-height: 1.35; padding: 6px 0;
  min-height: 56px;
}
.champ-texte::placeholder { color: var(--texte-3); }
.selecteur {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 0; background: var(--surface-2); font-size: 15.5px; font-weight: 500;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--texte-3) 50%), linear-gradient(135deg, var(--texte-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}

/* --- Toast ----------------------------------------------------------------- */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translate(-50%, 20px); opacity: 0; transition: transform .25s, opacity .25s;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: #1c1c1e; color: #f2f2f4; padding: 11px 16px; border-radius: 12px; box-shadow: var(--ombre-forte);
  font-size: 14.5px; font-weight: 500;
}
@media (prefers-color-scheme: dark) { .toast { background: #2c2c31; } }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.toast button { color: #a5a0ff; font-weight: 650; }
.toast.erreur { background: var(--retard); color: #fff; }
.toast.erreur button { color: #fff; }

/* --- Verrou ---------------------------------------------------------------- */
.verrou { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.verrou-carte { width: 100%; max-width: 380px; text-align: center; background: var(--surface); border-radius: 20px; padding: 32px 24px; box-shadow: var(--ombre); }
.verrou-carte img { border-radius: 14px; }
.verrou-carte h1 { font-size: 26px; margin: 12px 0 6px; }
.verrou-carte p { color: var(--texte-2); font-size: 15px; margin: 0 0 18px; }
.verrou-carte form { display: flex; flex-direction: column; gap: 10px; }
.verrou-carte input { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--surface-2); outline: none; font-size: 16px; }
.verrou-carte input:focus { border-color: var(--accent); }
.verrou-carte .bouton-principal { padding: 12px; font-size: 16px; border-radius: 12px; }
.erreur { color: var(--retard); font-size: 14px; min-height: 20px; margin: 12px 0 0 !important; }

/* --- Chargement ------------------------------------------------------------ */
.squelette { height: 64px; border-radius: var(--rayon); background: var(--surface); margin-bottom: 10px; opacity: .6; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* --- Ordinateur ------------------------------------------------------------ */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 264px 1fr; }
  .barre-laterale {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 20px 12px; border-right: 0.5px solid var(--ligne); background: var(--surface-2);
  }
  @media (prefers-color-scheme: light) { .barre-laterale { background: #efefec; } }
  .marque { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 10px 18px; letter-spacing: -.01em; }
  .marque img { border-radius: 7px; }
  .nav-laterale { display: flex; flex-direction: column; gap: 1px; }
  .lien-vue {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: 14.5px; font-weight: 500;
    color: var(--texte-2); text-align: left; width: 100%;
  }
  .lien-vue:hover { background: var(--survol); color: var(--texte); }
  .lien-vue[aria-current="page"] { background: var(--surface); color: var(--texte); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
  .lien-vue[aria-current="page"] svg { color: var(--accent); }
  .lien-vue .nombre { margin-left: auto; font-size: 13px; color: var(--texte-3); font-variant-numeric: tabular-nums; }
  .lien-vue .nombre.alerte { color: var(--retard); font-weight: 700; }
  .lien-vue svg { width: 18px; height: 18px; }
  .sujets-lateraux { margin-top: 24px; flex: 1; }
  .etiquette-section { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--texte-3); padding: 0 10px 6px; }
  .lien-vue.sujet { font-size: 14px; padding: 5px 10px; }
  .lien-vue.sujet .puce-couleur { width: 8px; height: 8px; border-radius: 3px; background: var(--accent); opacity: .55; flex: none; margin: 0 5px; }
  .pied-lateral { font-size: 12.5px; color: var(--texte-3); padding: 12px 10px 0; }
  .pied-lateral .lien-discret { font-size: 12.5px; color: var(--texte-3); text-decoration: underline; }
  .principal { padding: 28px 40px 80px; width: 100%; }
  .ordinateur { display: inline-flex; }
  .onglets, .bouton-flottant { display: none; }
  h1 { font-size: 34px; }
  .toast { bottom: 28px; }
  .feuille {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; max-height: 86vh; border-radius: 18px;
    transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .22s, opacity .22s; padding: 22px 26px 24px;
  }
  .feuille.visible { transform: translate(-50%, -50%); opacity: 1; }
  .poignee { display: none; }
}

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