/* Epique — d'après le canevas « Epique — maquettes mobiles » */
:root {
  --fond: #F5F6F3; --carte: #FFFFFF; --texte: #15181C; --texte-2: #3D4248; --doux: #5B6168;
  --bord: #E3E5E1; --bord-2: #D5D8D3; --trait: #EEF0EC; --piste: #E9EBE7;
  --ia: #2450D8; --ia-fonce: #1A3BA8; --ia-pale: #E8EEFC; --ia-sur-noir: #9DB8FF;
  --regles: #8A8F96; --alerte: #C2570C; --alerte-texte: #A84A0A;
  --noir: #15181C; --noir-2: #2C3138; --sur-noir: #C9CED4;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body { font-family: 'Manrope', system-ui, sans-serif; font-size: 15px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
a { color: var(--ia); } a:hover { color: var(--ia-fonce); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ia); outline-offset: 2px; }
.mono { font-family: var(--mono); font-weight: 500; }
.doux { color: var(--doux); }
.chargement { padding: 40px 20px; color: var(--doux); text-align: center; }

#appli { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main.ecran { flex: 1; padding: 16px 20px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
main.ecran.avec-barre { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }

/* En-tête de l'accueil */
.entete { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding-top: env(safe-area-inset-top); }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.entete-actions { display: flex; gap: 8px; align-items: center; }
.rond { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--bord); background: var(--carte); display: flex; align-items: center; justify-content: center; position: relative; padding: 0; text-decoration: none; color: var(--texte); }
.pastille-alerte { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 4px; background: var(--alerte); }
.puce-profil { height: 44px; padding: 0 12px 0 6px; border-radius: 22px; border: 1px solid var(--bord); background: var(--carte); display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--texte); }
.avatar { width: 32px; height: 32px; border-radius: 16px; background: var(--ia); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; }
.avatar.nathan { background: var(--noir); }
.avatar.grand { width: 36px; height: 36px; border-radius: 18px; }

/* Cartes */
.carte { background: var(--carte); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.carte h2, .section h2 { margin: 0; font-size: 15px; font-weight: 800; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-titre { display: flex; justify-content: space-between; align-items: baseline; }
.section-titre h2 { font-size: 16px; }
.section-titre a { font-size: 13px; font-weight: 700; text-decoration: none; }
h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
h1.grand { font-size: 24px; }

.carte-tete { background: var(--noir); color: #fff; border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; }
.carte-tete:hover { color: #fff; }
.carte-tete .ligne { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--sur-noir); }
.carte-tete .badge-noir { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--noir-2); color: var(--ia-sur-noir); }
.carte-tete .nom { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.carte-tete .valeur { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.carte-tete .valeur .mono:first-child { font-size: 34px; letter-spacing: -0.02em; line-height: 1; }
.carte-tete .detail { font-size: 13px; color: var(--sur-noir); line-height: 1.5; }
.carte-tete .plus { color: var(--ia-sur-noir); }
.carte-tete .moins { color: #FFB27A; }
.jauge { height: 6px; border-radius: 3px; background: var(--noir-2); }
.jauge > div { height: 6px; border-radius: 3px; background: var(--ia-sur-noir); }

.alerte { background: var(--carte); border: 1.5px solid var(--alerte); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.alerte .ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alerte .type { font-size: 12px; font-weight: 800; color: var(--alerte-texte); }
.alerte p { margin: 0; font-size: 14px; line-height: 1.4; }
.alerte .boutons { display: flex; gap: 8px; }

.rangee { display: flex; align-items: center; gap: 12px; background: var(--carte); border-radius: 14px; padding: 10px 12px; text-decoration: none; color: var(--texte); min-height: 56px; }
.rangee:hover { color: var(--texte); }
.rangee .milieu { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rangee .titre { font-size: 14px; font-weight: 700; }
.rangee .sous { font-size: 12px; color: var(--doux); }
.rangee .droite { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.rangee .droite .petit { font-size: 11px; color: var(--doux); }
.icone-ordre { width: 36px; height: 36px; border-radius: 18px; background: var(--ia-pale); color: var(--ia); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icone-ordre.vente { background: #FBEBDD; color: var(--alerte-texte); }
.icone-ordre.refus { background: var(--trait); color: var(--doux); }
.chevron { color: var(--doux); flex-shrink: 0; }

.plus { color: var(--ia); } .moins { color: var(--alerte-texte); } .neutre { color: var(--doux); }

/* Boutons */
.btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--bord-2); background: var(--carte); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--texte); text-decoration: none; padding: 0 16px; }
.btn.plein { flex: 1; height: 48px; border-radius: 14px; }
.btn.noir { background: var(--noir); color: #fff; border: 0; font-weight: 800; }
.btn.contour { border: 1.5px solid var(--noir); font-weight: 800; }
.btn.bleu { background: var(--ia); color: #fff; border: 0; font-weight: 800; }
.btn.discret { border: 0; background: transparent; color: var(--ia); padding: 0 4px; }
.btn[disabled] { opacity: .5; cursor: default; }
.retour { min-height: 44px; display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; text-decoration: none; align-self: flex-start; }

/* Barre du bas */
nav.barre { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--carte); border-top: 1px solid var(--bord); }
nav.barre .interieur { max-width: 480px; margin: 0 auto; height: 76px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding-bottom: 8px; }
nav.barre { padding-bottom: env(safe-area-inset-bottom); }
nav.barre a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--doux); text-decoration: none; position: relative; }
nav.barre a[aria-current="page"] { color: var(--ia); font-weight: 800; }
nav.barre .centre { width: 48px; height: 48px; border-radius: 24px; background: var(--noir); color: #fff; display: flex; align-items: center; justify-content: center; }
nav.barre a[aria-current="page"] .centre { background: var(--ia); }
nav.barre .point { position: absolute; top: 10px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 4px; background: var(--alerte); }

.barre-action { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 9; background: var(--carte); border-top: 1px solid var(--bord); }
.barre-action .interieur { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; align-items: center; padding: 12px 20px; }
.barre-action .note { font-size: 12px; color: var(--doux); flex: 1; line-height: 1.35; }

/* Détail d'une simulation */
.etiquettes { display: flex; gap: 6px; flex-wrap: wrap; }
.etiquette { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--carte); border: 1px solid var(--bord); color: var(--texte-2); }
.etiquette.bleue { background: var(--ia-pale); border-color: var(--ia-pale); color: var(--ia-fonce); font-weight: 700; }
.etiquette.orange { background: #FBEBDD; border-color: #FBEBDD; color: var(--alerte-texte); font-weight: 700; }
.chiffres { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.chiffres .gauche { display: flex; flex-direction: column; gap: 4px; }
.chiffres .gauche > .mono { font-size: 30px; letter-spacing: -0.02em; line-height: 1; }
.chiffres .droite { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--doux); }
.chiffres .droite .mono { font-size: 15px; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--texte-2); flex-wrap: wrap; }
.legende span { display: flex; align-items: center; gap: 6px; }
.trait-ia { width: 18px; height: 3px; border-radius: 2px; background: var(--ia); }
.trait-regles { width: 18px; border-top: 2px solid var(--regles); }
.trait-temoin { width: 18px; border-top: 2px dashed var(--regles); }
.courbe svg { display: block; width: 100%; height: auto; }
.tuiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tuiles.deux { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tuile { background: var(--carte); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.tuile .etiq { font-size: 11px; color: var(--doux); }
.tuile .mono { font-size: 15px; }
.position { display: flex; flex-direction: column; gap: 4px; }
.position .ligne { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
.barre-pct { height: 5px; border-radius: 3px; background: var(--trait); }
.barre-pct > div { height: 5px; border-radius: 3px; background: var(--ia); }
.onglets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; padding: 3px; background: var(--piste); border-radius: 12px; }
.onglets button { height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 13px; font-weight: 600; color: var(--texte-2); }
.onglets button[aria-pressed="true"] { background: var(--carte); font-weight: 800; color: var(--texte); }
.onglets.quatre { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.onglets.quatre button { font-size: 12px; }
.onglets.trois { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.journal { display: flex; flex-direction: column; gap: 8px; }
.analyse { background: var(--carte); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.analyse .haut { display: flex; justify-content: space-between; gap: 8px; }
.analyse .haut b { font-weight: 700; }

/* Détail d'un ordre */
.badge { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: var(--ia); color: #fff; }
.badge.vente { background: var(--alerte-texte); }
.badge.refus { background: var(--doux); }
.code-ia { font-family: var(--mono); font-size: 13px; padding: 3px 8px; border-radius: 6px; background: var(--ia-pale); color: var(--ia-fonce); word-break: break-all; }
.lignes-ind > div { display: flex; align-items: center; justify-content: space-between; min-height: 36px; border-bottom: 1px solid var(--trait); gap: 8px; font-size: 14px; }
.lignes-ind > div:last-child { border-bottom: 0; }
.valeur-ind { font-family: var(--mono); font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--trait); color: var(--texte-2); }
.valeur-ind.bleue { background: var(--ia-pale); color: var(--ia-fonce); font-family: 'Manrope', sans-serif; font-weight: 700; }
.valeur-ind.orange { background: #FBEBDD; color: var(--alerte-texte); font-family: 'Manrope', sans-serif; font-weight: 700; }
.fiche { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.fiche dt { color: var(--doux); } .fiche dd { margin: 0; font-family: var(--mono); text-align: right; }

/* Classement */
.tableau { background: var(--carte); border-radius: 16px; padding: 2px 14px; display: flex; flex-direction: column; }
.tableau .tete, .tableau .rang { display: grid; grid-template-columns: 18px minmax(0, 1fr) 50px 50px 30px; align-items: center; gap: 8px; }
.tableau .tete { min-height: 30px; font-size: 11px; color: var(--doux); border-bottom: 1px solid var(--trait); }
.tableau .tete span:nth-child(n+3), .tableau .rang > span:nth-child(n+3) { text-align: right; }
.tableau .rang > span { white-space: nowrap; }
.tableau .rang > .nom-rang { white-space: normal; }
.tableau .rang { min-height: 52px; border-bottom: 1px solid var(--trait); text-decoration: none; color: var(--texte); }
.tableau .rang:last-child { border-bottom: 0; }
.tableau .nom-rang { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 14px; font-weight: 700; }
.tableau .mini { height: 3px; border-radius: 2px; background: var(--trait); }
.tableau .mini > span { display: block; height: 3px; border-radius: 2px; background: var(--ia); }
.humain { font-size: 11px; font-weight: 700; color: var(--texte-2); padding: 1px 6px; border-radius: 4px; background: var(--trait); }
.avertissement { margin: 0; font-size: 12px; line-height: 1.45; color: var(--alerte-texte); font-weight: 700; }
.lien-noir { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; background: var(--noir); border-radius: 14px; padding: 8px 14px; text-decoration: none; color: #fff; }
.lien-noir:hover { color: #fff; }
.lien-noir .sous { font-size: 12px; color: var(--sur-noir); }

/* Formulaires */
label.etiq, legend.etiq { font-size: 13px; font-weight: 700; padding: 0; }
.champ { display: flex; flex-direction: column; gap: 6px; }
textarea, input[type="text"], input[type="password"], input[type="number"], input[type="time"], select {
  width: 100%; border-radius: 12px; border: 1px solid var(--bord-2); background: var(--carte); padding: 10px 12px; font-size: 16px; line-height: 1.4; }
input, select { min-height: 44px; }
textarea { resize: vertical; min-height: 84px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.aide { font-size: 12px; color: var(--doux); }
.encart-bleu { display: flex; align-items: center; gap: 12px; background: var(--ia-pale); border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.4; color: var(--ia-fonce); }
.options { background: var(--carte); border-radius: 14px; padding: 0 14px; display: flex; flex-direction: column; }
.options > * { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--trait); }
.options > *:last-child { border-bottom: 0; }
.options .gauche { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.options .gauche b { font-size: 14px; }
.options .gauche span { font-size: 12px; color: var(--doux); }
.cases { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.cases label { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; border-radius: 10px; border: 1px solid var(--bord-2); background: var(--carte); font-size: 13px; font-weight: 700; }
.cases input { width: 16px; height: 16px; min-height: 0; margin: 0; }
.message-retour { font-size: 13px; padding: 10px 12px; border-radius: 12px; }
.message-retour.ok { background: var(--ia-pale); color: var(--ia-fonce); }
.message-retour.erreur { background: #FBEBDD; color: var(--alerte-texte); font-weight: 700; }
.interrupteur { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #C9CED4; flex-shrink: 0; }
.interrupteur span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; }

/* Feuille (ordre manuel) */
.voile { position: fixed; inset: 0; background: rgba(21, 24, 28, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.feuille { background: var(--fond); width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-height: 92vh; overflow: auto; }
.feuille .haut { display: flex; justify-content: space-between; align-items: center; }

/* Connexion */
.connexion { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 32px 24px; }
.connexion .logo { font-size: 34px; }
.profils { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profils button { min-height: 120px; border-radius: 18px; border: 1px solid var(--bord); background: var(--carte); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 16px; font-weight: 800; }
.profils .avatar { width: 52px; height: 52px; border-radius: 26px; font-size: 20px; }

/* Discussion */
.fil { display: flex; flex-direction: column; gap: 10px; }
.bulle { max-width: 84%; display: flex; flex-direction: column; gap: 4px; }
.bulle .corps { background: var(--carte); border-radius: 16px 16px 16px 4px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bulle.moi { align-self: flex-end; align-items: flex-end; }
.bulle.moi .corps { background: var(--ia); color: #fff; border-radius: 16px 16px 4px 16px; }
.bulle.moi .corps a { color: #fff; }
.bulle .qui { font-size: 11px; color: var(--doux); }
.partage { display: flex; align-items: center; gap: 8px; text-decoration: none; background: var(--ia-pale); color: var(--ia-fonce); border-radius: 12px; padding: 8px 10px; font-size: 13px; font-weight: 700; }
.bulle.moi .partage { background: rgba(255,255,255,.18); color: #fff; }
.saisie { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 9; background: var(--carte); border-top: 1px solid var(--bord); }
.saisie form { max-width: 480px; margin: 0 auto; display: flex; gap: 8px; padding: 10px 12px; }
.saisie textarea { min-height: 44px; height: 44px; resize: none; }
.vide { text-align: center; color: var(--doux); padding: 30px 10px; font-size: 14px; }

.note-ligne { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 4px 10px; align-items: center; font-size: 13px; }
.note-ligne .barre-pct { grid-column: 1 / -1; }
.note-grande { font-family: var(--mono); font-size: 28px; line-height: 1; }
.faits { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.tableau.rapport .tete, .tableau.rapport .rang { grid-template-columns: 18px minmax(0, 1fr) 54px 54px 30px; }

.rapport-md h2.md { font-size: 20px; margin: 4px 0 0; } .rapport-md h3.md { font-size: 16px; margin: 14px 0 0; }
.rapport-md h4.md { font-size: 14px; margin: 10px 0 0; } .rapport-md p.md { margin: 0; font-size: 14px; color: var(--texte-2); }
.rapport-md table { font-size: 12px; } .rapport-md th, .rapport-md td { padding: 6px 5px; white-space: nowrap; }
.code-md { background: var(--fond); border-radius: 10px; padding: 8px 10px; font-size: 11px; white-space: pre-wrap; word-break: break-word; margin: 0; }
.rapport-md { min-width: 0; max-width: 100%; overflow: hidden; }
.rapport-md .t { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
main.ecran > * { min-width: 0; }
