/* Comptage de trafic — aux couleurs de GERMS Consulting (voir livrables/2-Charte-graphique.pdf) */
@font-face { font-family: Barlow; font-weight: 300; font-display: swap; src: url(fonts/barlow-latin-300-normal.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format('woff2'); }

:root {
  --red: #b40404;          /* Rouge GERMS */
  --red-2: #d8432b;        /* Rouge clair */
  --red-press: #8f0303;
  --red-tint: #fbeceb;
  --dark: #3f2226;         /* Bordeaux profond */
  --ink: #3a3335;          /* Encre */
  --muted: #8d8587;        /* Gris chaud */
  --tint: #f6f3f2;         /* Fond teinté */
  --line: #e6e0df;
  --bg: #ffffff;
  --blue: #1f5fae; --teal: #0f8a86; --ochre: #c98a12;
  --radius: 2px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--tint); color: var(--ink);
  font: 400 16px/1.45 Barlow, Calibri, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh; min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- Signature GERMS */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 40px; width: auto; display: block; flex-shrink: 0; }
.signature { line-height: 1; color: var(--ink); white-space: nowrap; }
.signature b { display: block; font-weight: 500; letter-spacing: .32em; font-size: 1rem; }
.signature i { display: block; font-style: normal; font-weight: 400; letter-spacing: .42em; font-size: .62rem; color: var(--muted); margin-top: 4px; }

/* ---------- Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: #fff; color: var(--ink); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  min-height: 60px;
}
.topbar .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 1rem; padding-left: 12px; border-left: 1px solid var(--line); }
.topbar .sub { font-weight: 400; color: var(--muted); font-size: .85rem; display: block; overflow: hidden; text-overflow: ellipsis; }
.topbar button { background: #fff; border: 1px solid var(--red); color: var(--red); padding: 7px 12px; border-radius: var(--radius); font-size: .9rem; font-weight: 500; }
.topbar button:active, .topbar button:hover { background: var(--red); color: #fff; }
@media (max-width: 420px) { .topbar .signature { display: none; } .topbar { gap: 10px; padding-left: 12px; padding-right: 12px; } }

.page { max-width: 1240px; margin: 0 auto; padding: 20px; }
@media (max-width: 600px) { .page { padding: 16px; } }
.center-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }

/* ---------- Cartes, formulaires, boutons */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.stack > * + * { margin-top: 12px; }
label.field { display: block; }
label.field > span { display: block; font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { accent-color: var(--red); width: 18px; height: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--red); border-radius: var(--radius); padding: 11px 18px; min-height: 46px; font-weight: 500;
  background: var(--red); color: #fff;
}
.btn:hover { background: var(--red-press); border-color: var(--red-press); }
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 1.12rem; letter-spacing: .02em; }
.btn.green { background: var(--red); border-color: var(--red); }           /* action principale */
.btn.red { background: var(--dark); border-color: var(--dark); }           /* action forte / fin */
.btn.red:hover { background: #2a1619; }
.btn.ghost { background: #fff; color: var(--red); border-color: var(--red); }
.btn.ghost:hover { background: var(--red); color: #fff; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.grid-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.error { color: var(--red); font-size: .9rem; min-height: 1.2em; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .04em; padding: 3px 8px; border-radius: var(--radius); white-space: nowrap; border: 1px solid currentColor; }
.badge.sent { color: var(--teal); background: #e7f4f3; }
.badge.ended { color: #96650a; background: #fbf3e3; }
.badge.live { color: var(--blue); background: #e9f0f9; }
.badge.off { color: var(--muted); background: var(--tint); }

/* Bloc de titre de la charte : surtitre gris, titre rouge léger, filet rouge */
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.section-title h2, .section-title h3 { font-weight: 300; color: var(--red); font-size: 1.55rem; }
.section-title h3 { font-size: 1.3rem; }
.section-title h2::after { content: ""; display: block; width: 36px; height: 2px; background: var(--red); margin-top: 8px; }

/* ---------- Connexion */
.login { width: 100%; max-width: 400px; padding: 28px 24px; }
.login .brand { flex-direction: column; gap: 14px; margin-bottom: 18px; }
.login .brand img { height: 96px; }
.login .signature { text-align: center; }
.login .signature b { font-size: 1.5rem; }
.login .signature i { font-size: .78rem; }
.login h1 { text-align: center; font-weight: 300; color: var(--red); font-size: 1.7rem; }
.login h1::after { content: ""; display: block; width: 36px; height: 2px; background: var(--red); margin: 10px auto 0; }
.login p.muted { text-align: center; margin: 12px 0 20px; }

/* ---------- Accueil agent */
.assign { text-align: center; padding: 32px 18px; }
.assign .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.assign .value { font-size: 1.9rem; font-weight: 300; color: var(--red); margin: 2px 0 20px; word-break: break-word; }

/* ---------- Choix du mouvement directionnel */
.dir-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dir-opt { position: relative; display: block; cursor: pointer; }
.dir-opt input { position: absolute; opacity: 0; pointer-events: none; }
.dir-opt span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 72px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); font-weight: 500; line-height: 1.2; background: #fff;
}
.dir-opt input:checked + span { border: 2px solid var(--red); color: var(--red); background: var(--red-tint); }
.dir-opt input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.dir-banner { background: var(--dark); color: #fff; text-align: center; padding: 6px 12px; font-size: .9rem; }
.dir-banner b { font-weight: 600; letter-spacing: .02em; }

/* ---------- Écran de comptage */
.count-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--muted); padding: 8px 12px 0; max-width: 1240px; margin: 0 auto;
  font-variant-numeric: tabular-nums;
}
.sync { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.sync::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); }
.sync.pending::before { background: var(--ochre); }
.sync.offline::before { background: var(--red); }
.counter-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  padding: 8px; max-width: 1240px; margin: 0 auto;
  padding-bottom: calc(96px + var(--safe-b));
}
.cell {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; min-height: 136px;
}
.cell .name {
  background: var(--dark); color: #fff; font-weight: 600; font-size: .8rem; line-height: 1.15;
  padding: 6px; text-align: center; min-height: 2.9em; display: flex; align-items: center; justify-content: center;
  hyphens: auto; overflow-wrap: anywhere;
}
.cell .value { font-size: 2rem; font-weight: 500; color: var(--ink); text-align: center; padding: 2px 0; font-variant-numeric: tabular-nums; }
.cell .value.nz { color: var(--red); }
.cell .value.bump { animation: bump .18s ease-out; }
@keyframes bump { 50% { transform: scale(1.18); } }
.cell .btns { display: grid; grid-template-columns: 1fr 1.6fr; gap: 6px; padding: 0 6px 6px; margin-top: auto; }
.cell button { border-radius: var(--radius); font-weight: 500; min-height: 48px; user-select: none; -webkit-user-select: none; line-height: 1; }
.cell .minus { background: #fff; border: 1px solid var(--red); color: var(--red); font-size: 1.7rem; }
.cell .minus:active { background: var(--red-tint); }
.cell .plus { background: var(--red); border: 1px solid var(--red); color: #fff; font-size: 2.1rem; }
.cell .plus:active { background: var(--red-press); }
.cell .minus:disabled { opacity: .3; }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + var(--safe-b));
  display: flex; gap: 10px; align-items: center; justify-content: center;
}
.bottom-bar .total { font-weight: 500; white-space: nowrap; }
.bottom-bar .total span { color: var(--red); font-size: 1.15rem; }
.bottom-bar .btn { flex: 1; max-width: 420px; }

@media (min-width: 700px) {
  .cell { min-height: 190px; }
  .cell .name { font-size: .95rem; }
  .cell .value { font-size: 2.7rem; }
  .cell button { min-height: 64px; }
  .counter-grid { gap: 14px; padding: 14px; padding-bottom: 110px; }
}
@media (max-width: 340px) {
  .cell .name { font-size: .7rem; }
  .cell .value { font-size: 1.6rem; }
  .cell .btns { grid-template-columns: 1fr 1.3fr; gap: 4px; padding: 0 4px 4px; }
}

/* ---------- Tableaux (filets fins) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1.5px solid var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; color: var(--red); border-top: 1.5px solid var(--ink); }
table.compact th, table.compact td { padding: 6px 8px; font-size: .85rem; white-space: nowrap; }

/* ---------- Admin */
.tabs {
  display: flex; gap: 2px; overflow-x: auto; background: #fff; padding: 0 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 60px; z-index: 9; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; color: var(--ink); padding: 12px 12px 10px; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs button:hover { color: var(--red); }
.tabs button.active { color: var(--red); border-bottom-color: var(--red); }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .main strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list-item .actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.report { cursor: pointer; }
.report:hover { background: var(--tint); }
.report .big { font-size: 1.8rem; font-weight: 500; color: var(--red); text-align: right; line-height: 1; font-variant-numeric: tabular-nums; }
.report .big small { display: block; font-size: .7rem; color: var(--muted); font-weight: 400; letter-spacing: .06em; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--tint); border-radius: var(--radius); padding: 10px 12px; }
.kpi .k { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.kpi .v { font-weight: 500; font-size: 1.05rem; overflow-wrap: anywhere; }
.kpi.hl .v { color: var(--red); font-size: 1.5rem; }
.chart-box { position: relative; height: 320px; }
@media (max-width: 600px) { .chart-box { height: 260px; } }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

/* ---------- Toast / modale / chargement */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--dark); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-size: .95rem;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
.overlay { position: fixed; inset: 0; background: rgba(63, 34, 38, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; padding: 22px; border-top: 3px solid var(--red); }
.modal h3 { margin-bottom: 12px; font-weight: 300; color: var(--red); font-size: 1.4rem; }
.modal .row.end { justify-content: flex-end; margin-top: 16px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.success-icon { width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--red); color: var(--red); display: grid; place-items: center; font-size: 2.4rem; margin: 0 auto 14px; font-weight: 500; }
.assign h2 { font-weight: 300; color: var(--red); font-size: 1.7rem; }
