:root {
  --fond: #f4f2ec; --carte: #ffffff; --texte: #1d1e22; --gris: #6b6f78; --bord: #e3e0d6;
  --or: #b8860b; --or-doux: #f3e6c4; --vert: #1f8a4c; --rouge: #c0392b; --bleu: #2f6fdb;
  --ombre: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #14161b; --carte: #1d2027; --texte: #eceae4; --gris: #9aa0ab; --bord: #2c3039;
    --or: #e0b04a; --or-doux: #3a3120; --vert: #3fbf75; --rouge: #ef6a5a; --bleu: #6fa0ff;
    --ombre: none;
  }
}
:root[data-theme="dark"] {
  --fond: #14161b; --carte: #1d2027; --texte: #eceae4; --gris: #9aa0ab; --bord: #2c3039;
  --or: #e0b04a; --or-doux: #3a3120; --vert: #3fbf75; --rouge: #ef6a5a; --bleu: #6fa0ff; --ombre: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.4rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--gris); font-weight: 600; }
p { margin: .3rem 0; }
.cache { display: none !important; }
.centre { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--or); color: #fff; font-weight: 800;
  font-size: 1.4rem; display: grid; place-items: center; margin: 0 auto .8rem; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 14px;
  margin: 0 0 12px; box-shadow: var(--ombre); }
.etroite { width: 100%; max-width: 380px; text-align: center; }
.etroite label { text-align: left; }
label { display: block; margin: .7rem 0; font-size: .9rem; color: var(--gris); }
input[type=password], input[type=text], input[type=number], input[type=time], textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem; font-size: 1rem; color: var(--texte);
  background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; }
textarea { min-height: 70px; font: inherit; }
fieldset { border: 1px solid var(--bord); border-radius: 10px; margin: .8rem 0; padding: .4rem .8rem; }
legend { color: var(--gris); font-size: .85rem; padding: 0 .3rem; }
button, .bouton { font: inherit; border-radius: 10px; padding: .7rem 1rem; border: 1px solid var(--bord);
  background: var(--carte); color: var(--texte); cursor: pointer; display: inline-block; text-decoration: none;
  width: 100%; margin: .3rem 0; text-align: center; }
button.principal { background: var(--or); color: #fff; border-color: var(--or); font-weight: 600; }
button.danger { background: var(--rouge); color: #fff; border-color: var(--rouge); font-weight: 800; font-size: 1.05rem; padding: 1rem; }
button.lien { background: none; border: none; color: var(--bleu); width: auto; padding: .3rem 0; }
button:disabled { opacity: .5; }
.erreur { color: var(--rouge); min-height: 1.2em; }
.ok { color: var(--vert); min-height: 1.2em; }
.petit { font-size: .85rem; }
.gris { color: var(--gris); }
.vert { color: var(--vert); }
.rouge { color: var(--rouge); }
.qr { display: flex; justify-content: center; margin: .6rem 0; }
.qr img, .qr canvas { background: #fff; padding: 8px; border-radius: 8px; }
.cle-totp { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; color: var(--gris); }

/* barre et onglets */
.barre { 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(--fond); border-bottom: 1px solid var(--bord); }
.cours { font-size: 1.05rem; white-space: nowrap; }
.cours strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.sym { color: var(--gris); font-size: .85rem; }
.pastille { font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: var(--or-doux); color: var(--or); }
.pastille-bouton { width: auto; margin: 0; padding: .35rem .7rem; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.pastille-bouton.on { background: rgba(31,138,76,.15); color: var(--vert); border-color: var(--vert); }
.pastille-bouton.off { background: rgba(192,57,43,.15); color: var(--rouge); border-color: var(--rouge); }
main { max-width: 900px; margin: 0 auto; padding: 12px 16px calc(90px + env(safe-area-inset-bottom)); }
.onglets { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--carte);
  border-top: 1px solid var(--bord); padding-bottom: env(safe-area-inset-bottom); }
.onglets button { border: none; border-radius: 0; margin: 0; background: none; color: var(--gris); font-size: .7rem;
  padding: .5rem 0 .55rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.onglets svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onglets button.actif { color: var(--or); }
@media (min-width: 900px) {
  .onglets { position: sticky; top: 0; bottom: auto; max-width: 900px; margin: 0 auto; border: 1px solid var(--bord); border-radius: 0 0 12px 12px; }
  main { padding-bottom: 40px; }
}

/* contenus */
.ligne-titre { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: .6rem; }
.ligne-titre h2 { margin: 0; }
.segments { display: inline-flex; border: 1px solid var(--bord); border-radius: 10px; overflow: hidden; }
.segments.large { display: flex; margin-bottom: 12px; }
.segments button { width: auto; flex: 1; margin: 0; border: none; border-radius: 0; padding: .4rem .65rem; font-size: .85rem; background: var(--carte); }
.segments button.actif { background: var(--or); color: #fff; }
.grille-chiffres { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
@media (min-width: 600px) { .grille-chiffres { grid-template-columns: repeat(4, 1fr); } }
.chiffre { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: 10px 12px; }
.chiffre span { display: block; font-size: .75rem; color: var(--gris); }
.chiffre strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.graphique { height: 340px; width: 100%; }
.petit-graphique { height: 220px; }
.alerte { background: rgba(192,57,43,.12); color: var(--rouge); border-radius: 10px; padding: .55rem .8rem; margin-bottom: 8px; font-size: .9rem; font-weight: 600; }
.info { background: var(--or-doux); border-radius: 10px; padding: .55rem .8rem; margin: 8px 0; font-size: .9rem; }
.position-tete { display: flex; justify-content: space-between; align-items: baseline; }
.gros { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.barre-prog { position: relative; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--rouge), var(--bord) 25%, var(--bord) 75%, var(--vert)); margin: 12px 0 4px; }
.barre-prog i { position: absolute; top: -4px; width: 4px; height: 18px; background: var(--texte); border-radius: 2px; }
.legende-prog { display: flex; justify-content: space-between; font-size: .75rem; color: var(--gris); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .35rem .3rem; border-bottom: 1px solid var(--bord); }
th { color: var(--gris); font-weight: 600; }
.trade { cursor: pointer; }
.trade-tete { display: flex; justify-content: space-between; gap: 8px; }
.trade-detail { margin-top: 8px; font-size: .88rem; }
.etiquette { font-size: .72rem; padding: .05rem .45rem; border-radius: 6px; background: var(--bord); color: var(--gris); margin-left: 4px; }
.etiquette.p7 { background: var(--or-doux); color: var(--or); }
.journal-sys { font-family: ui-monospace, monospace; font-size: .75rem; max-height: 300px; overflow: auto; white-space: pre-wrap; background: var(--fond); padding: 8px; border-radius: 8px; }
.notif { border-left: 3px solid var(--bord); padding-left: 10px; }
.notif.haute { border-left-color: var(--or); }
.notif.urgente { border-left-color: var(--rouge); }
.notif pre { white-space: pre-wrap; font: inherit; font-size: .88rem; margin: .3rem 0 0; }
.fenetre { display: flex; gap: 6px; align-items: center; }
.fenetre input { margin: 0; }
.fenetre button { width: auto; margin: 0; padding: .4rem .6rem; }
.interrupteur { display: flex; align-items: center; gap: 10px; color: var(--texte); font-size: 1rem; }
.interrupteur input { width: 22px; height: 22px; accent-color: var(--or); }
.urgence { border-color: var(--rouge); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 10; background: var(--texte);
  color: var(--fond); padding: .8rem 1rem; border-radius: 12px; text-align: center; max-width: 500px; margin: 0 auto; }
