/* PHOENIX — thème sombre unique (charte §10) */

@font-face { font-family: "Cormorant Garamond"; font-weight: 600; font-display: swap; src: url("../fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 700; font-display: swap; src: url("../fonts/cormorant-garamond-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Lato"; font-weight: 400; font-display: swap; src: url("../fonts/lato-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Lato"; font-weight: 700; font-display: swap; src: url("../fonts/lato-latin-700-normal.woff2") format("woff2"); }

:root {
  --nuit: #050C26;
  --carte: #0B1535;
  --carte-2: #111D43;
  --bord: #1C2A57;
  --marine: #14306F;
  --bleu: #295CAF;
  --ciel: #68C1E9;
  --glace: #E3F8FD;
  --blanc: #FFFFFF;
  --or: #C9A55C;
  --ambre: #E8A33D;
  --ambre-fond: rgba(232, 163, 61, 0.14);
  --texte: #E3F8FD;
  --texte-2: #93A6CF;
  --texte-3: #5F7199;
  --rayon: 14px;
  --titre: "Cormorant Garamond", Georgia, serif;
  --corps: "Lato", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--nuit); color: var(--texte); font-family: var(--corps); font-size: 16px; line-height: 1.4; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
h1, h2, h3 { font-family: var(--titre); font-weight: 600; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ciel); }
.chiffre { font-variant-numeric: tabular-nums; }
.muet { color: var(--texte-2); }
.petit { font-size: 0.85rem; }
.ciel { color: var(--ciel); }
.ambre { color: var(--ambre); }
.cache { display: none !important; }

/* ── Structure ── */
#app { max-width: 680px; margin: 0 auto; padding: 0 14px calc(84px + env(safe-area-inset-bottom)); }
.entete { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.entete img { height: 34px; }
.etat-reseau { font-size: 0.75rem; padding: 3px 9px; border-radius: 99px; background: var(--carte-2); color: var(--texte-2); }
.etat-reseau.hors-ligne { background: var(--ambre-fond); color: var(--ambre); }

.onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: rgba(5, 12, 38, 0.96); border-top: 1px solid var(--bord); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(8px); }
.onglets nav { display: flex; width: 100%; max-width: 680px; }
.onglets a { flex: 1; text-align: center; padding: 10px 0 9px; text-decoration: none; color: var(--texte-3); font-size: 0.72rem; }
.onglets a span { display: block; font-size: 1.25rem; line-height: 1.2; filter: grayscale(1); opacity: 0.7; }
.onglets a.actif { color: var(--ciel); }
.onglets a.actif span { filter: none; opacity: 1; }

.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; margin: 12px 0; }
.carte > h2, .carte > h3 { margin-bottom: 10px; }
.ligne { display: flex; align-items: center; gap: 10px; }
.ligne.espace { justify-content: space-between; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pile > * + * { margin-top: 10px; }

/* ── Boutons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--bord); background: var(--carte-2);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; min-height: 44px; transition: background 0.15s, border-color 0.15s; }
.btn:hover { border-color: var(--bleu); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.principal { background: var(--ciel); border-color: var(--ciel); color: var(--nuit); font-weight: 700; }
.btn.danger { color: var(--ambre); border-color: rgba(232, 163, 61, 0.4); background: transparent; }
.btn.discret { background: transparent; }
.btn.plein { width: 100%; }
.btn.petit { min-height: 34px; padding: 5px 10px; font-size: 0.85rem; }
.btn.actif { border-color: var(--ciel); color: var(--ciel); background: rgba(104, 193, 233, 0.1); }

/* ── Champs ── */
label.champ { display: block; }
label.champ > span { display: block; font-size: 0.8rem; color: var(--texte-2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=date], input[type=month], select, textarea {
  width: 100%; background: var(--nuit); border: 1px solid var(--bord); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ciel); }
textarea { min-height: 72px; resize: vertical; }
input[type=color] { width: 44px; height: 36px; border: 1px solid var(--bord); border-radius: 8px; background: none; padding: 2px; }

/* ── Écran Aujourd'hui ── */
.date-jour { font-family: var(--titre); font-size: 1.35rem; color: var(--texte-2); margin-top: 4px; }
.en-cours { border-color: var(--ciel); background: linear-gradient(135deg, rgba(104, 193, 233, 0.16), rgba(41, 92, 175, 0.12)); }
.en-cours .libelle { font-size: 1.45rem; font-weight: 700; color: var(--ciel); }
.en-cours .groupe { font-size: 0.85rem; color: var(--texte-2); }
.en-cours .duree { font-size: 2rem; font-weight: 700; color: var(--glace); white-space: nowrap; }
.totaux { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.totaux div b { display: block; font-size: 1.25rem; }
.totaux div b.ciel { color: var(--ciel); }
.totaux div span { font-size: 0.72rem; color: var(--texte-2); }
.barre-repartition { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--carte-2); margin-top: 10px; }

.depuis { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.depuis input { width: auto; min-height: 38px; padding: 6px 10px; }
.boutons-bascule { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bascule { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-align: left; border-radius: 14px;
  padding: 10px 10px 10px 16px; min-height: 60px; background: var(--carte); border: 1px solid var(--bord); cursor: pointer; overflow: hidden; }
.bascule::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--bleu)); }
.bascule .ico { font-size: 1.3rem; grid-row: span 2; }
.bascule .nat { font-weight: 700; line-height: 1.2; }
.bascule .gr:empty { display: none; }
.bascule .gr { font-size: 0.75rem; color: var(--texte-2); }
.bascule.courante { border-color: var(--ciel); box-shadow: inset 0 0 0 1px var(--ciel); }
.bascule:active { transform: scale(0.98); }
.bascule.autres { display: flex; align-items: center; justify-content: center; color: var(--texte-2); }

/* ── Feuilles (panneaux du bas) ── */
.voile { position: fixed; inset: 0; z-index: 40; background: rgba(2, 6, 20, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.feuille { width: 100%; max-width: 680px; max-height: 88dvh; overflow-y: auto; background: var(--carte); border: 1px solid var(--bord);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); animation: monte 0.18s ease-out; }
@keyframes monte { from { transform: translateY(30px); opacity: 0; } }
.feuille .poignee { width: 40px; height: 4px; border-radius: 2px; background: var(--bord); margin: -6px auto 12px; }
.liste-groupes h3 { font-size: 1.05rem; color: var(--texte-2); margin: 14px 0 6px; }

/* Note de concentration : carte flottante non bloquante */
.flottant { position: fixed; left: 12px; right: 12px; margin: 0 auto; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 640px; background: var(--carte-2); border: 1px solid var(--bleu); border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: monte 0.18s ease-out; }
.notes { display: flex; gap: 6px; }
.notes button { flex: 1; min-height: 42px; border-radius: 10px; border: 1px solid var(--bord); background: var(--nuit); cursor: pointer; font-weight: 700; }
.notes button.choisi { background: var(--ciel); color: var(--nuit); border-color: var(--ciel); }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { border: 1px solid var(--bord); background: var(--nuit); border-radius: 99px; padding: 5px 11px; font-size: 0.85rem; cursor: pointer; }
.puce.choisie { border-color: var(--ciel); color: var(--ciel); background: rgba(104, 193, 233, 0.1); }

.toast { position: fixed; left: 12px; right: 12px; margin: 0 auto; width: fit-content; top: calc(12px + env(safe-area-inset-top)); z-index: 60; background: var(--carte-2);
  border: 1px solid var(--bord); border-radius: 12px; padding: 10px 16px; max-width: calc(100% - 24px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.toast.erreur { border-color: var(--ambre); color: var(--ambre); }

/* ── Frise ── */
.nav-jour { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.nav-jour .titre { text-align: center; flex: 1; }
.nav-jour input[type=date] { width: auto; min-height: 34px; padding: 4px 8px; font-size: 0.85rem; }
.frise { position: relative; margin: 10px 0 0 52px; user-select: none; touch-action: pan-y; }
.frise .graduation { position: absolute; left: -52px; width: 44px; text-align: right; font-size: 0.72rem; color: var(--texte-3); transform: translateY(-50%); }
.frise .trait { position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(28, 42, 87, 0.7); }
.frise .maintenant { position: absolute; left: -6px; right: 0; border-top: 2px solid var(--ciel); z-index: 3; }
.bloc-f { position: absolute; left: 0; right: 0; border-radius: 8px; padding: 3px 10px; overflow: hidden; cursor: pointer;
  background: var(--c); color: var(--blanc); font-size: 0.85rem; border: 1px solid rgba(5, 12, 38, 0.9); z-index: 1; }
.bloc-f.sombre { color: var(--texte-2); }
.bloc-f.ouvert { box-shadow: inset 0 0 0 2px var(--ciel); }
.bloc-f .l1 { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; white-space: nowrap; }
.bloc-f .l2 { font-size: 0.75rem; opacity: 0.85; white-space: nowrap; }
.bloc-f .note-c { font-size: 0.75rem; background: rgba(5, 12, 38, 0.45); border-radius: 6px; padding: 0 6px; }
.bloc-f.court { padding-top: 0; padding-bottom: 0; font-size: 0.75rem; }
.trou { position: absolute; left: 0; right: 0; border-radius: 8px; border: 1px dashed var(--ambre); background: var(--ambre-fond); color: var(--ambre);
  font-size: 0.8rem; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1; }
.poignee-bord { position: absolute; left: 25%; right: 25%; height: 18px; z-index: 4; cursor: ns-resize; touch-action: none; display: flex; align-items: center; justify-content: center; }
.poignee-bord::after { content: ""; width: 36px; height: 4px; border-radius: 2px; background: rgba(227, 248, 253, 0.55); }
.poignee-bord.glisse::after { background: var(--ciel); }
.etiquette-glisse { position: absolute; right: 4px; z-index: 5; background: var(--ciel); color: var(--nuit); font-weight: 700; font-size: 0.8rem;
  padding: 2px 8px; border-radius: 8px; transform: translateY(-50%); }

/* ── CS ── */
table.tableau { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.tableau th { text-align: left; color: var(--texte-2); font-weight: 400; font-size: 0.75rem; border-bottom: 1px solid var(--bord); padding: 6px 4px; }
table.tableau td { padding: 8px 4px; border-bottom: 1px solid rgba(28, 42, 87, 0.5); }
table.tableau td.n, table.tableau th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.tableau tr.cliquable { cursor: pointer; }
.chiffres-cles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chiffres-cles div { background: var(--nuit); border: 1px solid var(--bord); border-radius: 12px; padding: 10px; }
.chiffres-cles b { display: block; font-size: 1.35rem; color: var(--ciel); font-variant-numeric: tabular-nums; }
.chiffres-cles span { font-size: 0.75rem; color: var(--texte-2); }

/* ── Réglages ── */
.ligne-cat { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(28, 42, 87, 0.5); }
.ligne-cat .pastille { width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }
.ligne-cat .nom { flex: 1; }
.ligne-cat.masquee .nom { color: var(--texte-3); text-decoration: line-through; }
.aide { font-size: 0.85rem; color: var(--texte-2); border-left: 3px solid var(--or); padding: 6px 10px; background: rgba(201, 165, 92, 0.06); border-radius: 0 8px 8px 0; }

/* ── Connexion / ouverture ── */
.ouverture { min-height: 90dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.ouverture img.symbole { width: 120px; }
.ouverture form { width: 100%; max-width: 360px; }
.ouverture .marque h1 { font-size: 2.85rem; line-height: 1.05; }
.ouverture .devise { margin: 4px 0 0; font-family: var(--corps); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.3em; padding-left: 0.3em; color: var(--ciel); }

/* ── Impression (export PDF CS) ── */
#impression { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #050C26; }
  #app, .onglets, .voile, .toast, .flottant { display: none !important; }
  #impression { display: block; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-family: var(--corps); }
  #impression .bandeau { background: #050C26; color: #E3F8FD; padding: 14px 18px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
  #impression .bandeau img { height: 46px; }
  #impression h1 { font-family: var(--titre); color: #14306F; margin: 18px 0 6px; }
  #impression table { width: 100%; border-collapse: collapse; font-size: 11pt; }
  #impression th { background: #14306F; color: #fff; text-align: left; padding: 6px; }
  #impression td { border-bottom: 1px solid #c8d3ea; padding: 6px; }
  #impression .n { text-align: right; }
  #impression tfoot td { font-weight: 700; border-top: 2px solid #295CAF; }
}
label.ligne { cursor: pointer; }
label.ligne input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ciel); }

/* Statistiques */
.segments { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.barre-stat { padding: 6px 0; }
.barre-stat .ligne { font-size: 0.9rem; }
.piste { position: relative; height: 8px; margin-top: 5px; border-radius: 4px; background: var(--nuit); overflow: hidden; }
.piste > div { height: 100%; border-radius: 4px; }
.piste.jauge { height: 12px; margin: 10px 0 6px; overflow: visible; }
.piste.jauge i { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--glace); }
details.groupe-stat > summary { list-style: none; cursor: pointer; }
details.groupe-stat > summary::-webkit-details-marker { display: none; }
details.groupe-stat[open] { padding-bottom: 8px; }
details.groupe-stat[open] > .barre-stat { margin-left: 14px; font-size: 0.85rem; }
.colonnes-jours { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.colonnes-jours > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.colonnes-jours > div > div { width: 100%; max-width: 28px; background: var(--ciel); border-radius: 3px 3px 0 0; min-height: 0; }
.colonnes-jours span { font-size: 0.65rem; color: var(--texte-2); margin-top: 3px; }
svg.courbes { width: 100%; height: auto; display: block; margin: 6px 0 10px; }
.puce-couleur { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
