/* Portail VELORQ : style sobre, clair et sombre, utilisable sur iPhone. */
:root {
  --bg:#f4f3f0; --fg:#1f2421; --muted:#6a706b; --line:#dcdad4; --card:#ffffff; --soft:#efeee9;
  --accent:#1f5f52; --accent-fg:#ffffff; --accent-soft:#e3eeea; --red:#a8322a; --red-soft:#f7e7e5;
  --amber:#9a5b00; --amber-soft:#f8eedc; --green:#2f6b35; --green-soft:#e6f0e5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg:#161816; --fg:#e8e9e6; --muted:#9aa09b; --line:#333733; --card:#1f221f; --soft:#262a26;
  --accent:#7fc0ae; --accent-fg:#10201b; --accent-soft:#203630; --red:#e8877f; --red-soft:#3a2320;
  --amber:#e3b061; --amber-soft:#382c17; --green:#8cc792; --green-soft:#1f3222; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg:#161816; --fg:#e8e9e6; --muted:#9aa09b; --line:#333733; --card:#1f221f; --soft:#262a26;
  --accent:#7fc0ae; --accent-fg:#10201b; --accent-soft:#203630; --red:#e8877f; --red-soft:#3a2320;
  --amber:#e3b061; --amber-soft:#382c17; --green:#8cc792; --green-soft:#1f3222; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Roboto", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }

.portail { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.cote { background: var(--soft); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.cote .logo { font-weight: 800; letter-spacing: 2px; margin: 0 10px 16px; }
.cote a { padding: 8px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 14px; }
.cote a.on { background: var(--card); color: var(--fg); font-weight: 600; }
.flotte-nom { margin: 22px 10px 0; font-size: 13px; color: var(--muted); }
.principal { min-width: 0; display: flex; flex-direction: column; }
.haut { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.haut-droite { display: flex; gap: 10px; align-items: center; }
.source { display: flex; align-items: center; font-size: 13.5px; }
main { padding: 18px 20px 60px; display: flex; flex-direction: column; gap: 14px; max-width: 1400px; width: 100%; outline: none; }

@media (max-width: 820px) {
  .portail { grid-template-columns: 1fr; }
  .cote { position: sticky; top: 0; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--line); z-index: 6; gap: 4px; -webkit-overflow-scrolling: touch; padding-top: max(8px, env(safe-area-inset-top)); }
  .cote .logo { margin: 0 6px 0 2px; align-self: center; }
  .cote a { white-space: nowrap; flex: 0 0 auto; }
  .flotte-nom { display: none; }
  .haut { position: static; padding: 8px 16px; }
  main { padding: 14px 16px 60px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.titre-page { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lab { font-size: 12.5px; color: var(--muted); }
.big { font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; flex: 0 0 auto; }
.dot.g { background: var(--green); } .dot.a { background: var(--amber); } .dot.r { background: var(--red); } .dot.n { background: var(--muted); } .dot.b { background: var(--accent); }
.code { font: 600 12px ui-monospace, Menlo, monospace; padding: 1px 6px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; }
.sev { font-size: 12.5px; font-weight: 700; } .sev.r { color: var(--red); } .sev.a { color: var(--amber); } .sev.g { color: var(--green); } .sev.n { color: var(--muted); }

.btn { appearance: none; font: inherit; font-size: 13.5px; font-weight: 600; border-radius: 10px; padding: 8px 13px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; min-height: 38px; }
.btn:hover { border-color: var(--muted); }
.btn.pri { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.btn.petit { white-space: nowrap; min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: default; }
.boutons { display: flex; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.seg button { appearance: none; border: 0; background: transparent; font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 9px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.bar { height: 7px; background: var(--soft); border-radius: 6px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); }
.bar i.a { background: var(--amber); } .bar i.r { background: var(--red); }

.alerte { border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line); }
.alerte.r { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.alerte.a { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.alerte.n { background: var(--soft); }
ol.fix { margin: 6px 0 0; padding-left: 20px; font-size: 14px; } ol.fix li { margin-bottom: 4px; }
.qui { font-weight: 600; }

.liste .ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.liste .ligne:last-child { border-bottom: none; }
.vide { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
tr.clic { cursor: pointer; } tr.clic:hover td { background: var(--soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.carte { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--soft); }
.carte svg { display: block; width: 100%; height: auto; }
.carte text { fill: var(--muted); font-size: 12px; font-family: inherit; }
.carte .marque { cursor: pointer; transition: transform .1s linear; }
.carte .marque text { fill: var(--fg); font-weight: 600; font-size: 12px; paint-order: stroke; stroke: var(--soft); stroke-width: 3px; }

.courbes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.courbe { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.courbe svg { display: block; width: 100%; height: 70px; }
.courbe text { fill: var(--muted); font-size: 10px; }

.mesures { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.mesure .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.champ { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
input[type=number], select { font: inherit; font-size: 15px; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--fg); min-height: 38px; }
input[type=number] { width: 96px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
label.case { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: 14px; cursor: pointer; }
.refus { font-size: 13px; color: var(--red); margin-top: 4px; }
.accepte { font-size: 13px; color: var(--green); margin-top: 4px; }
.lock { font-size: 12.5px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); }

.waves { display: flex; gap: 6px; } .waves span { flex: 1; text-align: center; font-size: 12.5px; padding: 7px 0; border-radius: 8px; background: var(--soft); color: var(--muted); }
.waves span.done { background: var(--green-soft); color: var(--green); font-weight: 600; } .waves span.now { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.journal { font: 12.5px/1.5 ui-monospace, Menlo, monospace; max-height: 260px; overflow: auto; }
.journal div { padding: 2px 0; border-bottom: 1px dashed var(--line); word-break: break-word; }
.journal .ko { color: var(--red); }

#toasts { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.toast.r { border-left-color: var(--red); } .toast.a { border-left-color: var(--amber); } .toast.g { border-left-color: var(--green); }
td .refus, td .accepte { white-space: normal; max-width: 360px; }

/* Retour terrain (boîte noire) */
.barre { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; text-align: left; appearance: none; font: inherit;
  background: transparent; border: 0; border-radius: 9px; padding: 6px 6px; color: var(--fg); cursor: pointer; }
.barre:hover { background: var(--soft); } .barre.on { background: var(--accent-soft); }
.barre-nom { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-n { font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.barre-fond { grid-column: 1 / -1; height: 6px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.barre-fond i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.courbes-bn { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.courbes-bn .courbe svg { height: auto; aspect-ratio: 400 / 130; overflow: visible; }
.courbes-bn .courbe text { fill: var(--muted); font-size: 15px; font-family: inherit; }
.leg { font-size: 12px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.leg i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
@media (max-width: 520px) { .courbes-bn { grid-template-columns: 1fr; } }
