/* ================= Dotation : styles de l'appli (après socle.css) ================= */
:root { --vert: #2f7a3b; --vert-soft: #e5f1e6; --orange: #9a5a00; --orange-soft: #fdf0dc; --rouge: #b4371f; --rouge-soft: #fbe7e2;
  --jour: #7a5200; --jour-soft: #fff4d6; --nuit: #2c3a7a; --nuit-soft: #e4e8f7; --les2: #1d5c5c; --les2-soft: #e3f0ef; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --vert: #7cc98a; --vert-soft: #1f3122; --orange: #f0b35a; --orange-soft: #3a2c14; --rouge: #f08a72; --rouge-soft: #3a221c;
    --jour: #f0c860; --jour-soft: #332c14; --nuit: #a9b6f0; --nuit-soft: #1f2440; --les2: #7fcaca; --les2-soft: #183030; }
}
input[type=text], input[type=date], input[type=number], select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; color: var(--text); font: inherit;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- commun ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 13px; border-radius: 10px; cursor: pointer; white-space: nowrap; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; font: inherit; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 550; }
label.f input, label.f select { color: var(--text); font-weight: 400; font-size: 15px; }
.muted { color: var(--muted); }
.error { color: var(--err); font-size: 14px; min-height: 1.3em; margin: 0; }
.hint { font-size: 13px; color: var(--muted); margin: 0; font-weight: 400; }
.intro { color: var(--muted); font-size: 14px; margin: 0 0 14px; max-width: 760px; }
.chip { display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.jour { background: var(--jour-soft); color: var(--jour); }
.chip.nuit { background: var(--nuit-soft); color: var(--nuit); }
.chip.les2 { background: var(--les2-soft); color: var(--les2); }
.spacer { flex: 1; }
.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- barre ---------- */
header.bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar-in { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand .logo { width: 26px; height: 26px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-weight: 800; font-size: 18px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.service select { width: auto; max-width: 200px; padding: 5px 9px; font-size: 13.5px; border-radius: 99px; }
.onglets { display: flex; gap: 2px; flex-wrap: wrap; }
.onglets a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 9px; font-size: 14.5px; }
.onglets a:hover { color: var(--text); }
.onglets a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 250px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 30; }
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu-list button:hover { background: var(--surface-2); }

/* ---------- contenu ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 60px; display: grid; gap: 18px; }
h2.titre { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h3.titre { font-size: 16.5px; margin: 0; }
.loading { text-align: center; color: var(--muted); padding: 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vide { color: var(--muted); padding: 14px 0; text-align: center; }

/* ---------- période ---------- */
.periode { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 8px 13px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.nav-p { display: flex; align-items: center; gap: 6px; }
.nav-p .lib { font-size: 19px; font-weight: 750; min-width: 170px; text-align: center; }
.nav-p .btn { width: 40px; height: 40px; justify-content: center; padding: 0; font-size: 18px; }
.plage { display: flex; gap: 6px; align-items: center; }
.plage input { width: auto; }
.sous-titre { font-size: 13px; color: var(--muted); }

/* ---------- synthèse ---------- */
.cartes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.lbl { font-size: 12.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.gros { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.gros .pc { font-size: 58px; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gros .ecart { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.val small { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.ok { color: var(--vert); } .moyen { color: var(--orange); } .bas { color: var(--rouge); }
.etat { display: flex; align-items: flex-start; gap: 8px; border-radius: 9px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.etat.ok { background: var(--vert-soft); } .etat.moyen { background: var(--orange-soft); } .etat.bas { background: var(--rouge-soft); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.mini .t { font-size: 12.5px; color: var(--muted); }
.mini .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.lignes { display: grid; gap: 6px; font-size: 14px; }
.lignes div { display: flex; justify-content: space-between; gap: 10px; }
.lignes span:first-child { color: var(--muted); }
.lignes span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legende .ok i { background: var(--vert); } .legende .moyen i { background: var(--orange); } .legende .bas i { background: var(--rouge); }
.legende span { color: var(--muted); }

/* tableaux */
.tab-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th, .t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.t thead th { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.t tfoot td { font-weight: 700; border-bottom: 0; }
.t th.n, .t td.n { text-align: right; }
.t td .s { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.t tbody tr.clic { cursor: pointer; }
.t tbody tr.clic:hover td { background: var(--surface-2); }
.t td.ini { font-weight: 700; }
.barre { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.barre .bt { flex: 1; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.barre .bt span { display: block; height: 100%; border-radius: 99px; }
.barre .bt span.ok { background: var(--vert); } .barre .bt span.moyen { background: var(--orange); } .barre .bt span.bas { background: var(--rouge); }
.barre b { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-weight: 700; padding: 3px 10px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.pill.ok { background: var(--vert-soft); } .pill.moyen { background: var(--orange-soft); } .pill.bas { background: var(--rouge-soft); }

/* listes (paramètres) */
.liste-p { display: grid; gap: 8px; }
.ligne-p { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.ligne-p .q { flex: 1; min-width: 150px; }
.grille { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.postes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.poste { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.filtres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtres select { width: auto; max-width: 230px; }

/* ---------- fenêtres ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg, .dlg > form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); flex: none; }
.dlg-h h3 { margin: 0; font-size: 17px; }
.dlg-b { padding: 14px 16px; overflow-y: auto; display: grid; gap: 12px; align-content: start; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }
.dlg-f { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.contrat { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 8px; align-items: end; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--err); color: #fff; }

@media (max-width: 720px) {
  .bar-in { gap: 6px 10px; }
  .onglets { order: 5; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .onglets a { white-space: nowrap; padding: 6px 7px; font-size: 13.5px; }
  .nav-p { width: 100%; justify-content: space-between; }
  .nav-p .lib { min-width: 0; font-size: 17px; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 9px 4px; }
  .gros .pc { font-size: 48px; }
  .two, .contrat { grid-template-columns: 1fr 1fr; }
  .plage { width: 100%; }
  .plage input { flex: 1; }
  /* tableaux → une carte par ligne */
  .t.cartes-mobile thead, .t.cartes-mobile tfoot { display: none; }
  .t.cartes-mobile, .t.cartes-mobile tbody, .t.cartes-mobile tr, .t.cartes-mobile td { display: block; }
  .t.cartes-mobile tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  .t.cartes-mobile td { border: 0; padding: 2px 0; text-align: left !important; white-space: normal; }
  .t.cartes-mobile td:first-child, .t.cartes-mobile td.plein { grid-column: 1 / -1; }
  .t.cartes-mobile td .s { display: inline; margin-left: 6px; }
  .t.cartes-mobile td[data-lbl]::before { content: attr(data-lbl) " : "; color: var(--muted); font-size: 12.5px; }
  .t.cartes-mobile td:empty { display: none; }
  .barre { min-width: 0; }
}

/* ---------- impression (« Imprimer / PDF ») ---------- */
@media print {
  :root { color-scheme: light; }
  header.bar, .no-print, .toast, dialog { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; max-width: none; gap: 10px; }
  .card { break-inside: avoid; border-color: #ccc; }
  .print-titre { display: block !important; font-size: 16px; font-weight: 700; }
  .t tbody tr { break-inside: avoid; }
}
.print-titre { display: none; }
