/* Disposition : barre du haut fixe, puis carte à gauche (collante) et formulaire/liste à droite ; une seule colonne sur téléphone. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #14202b;
  --muted: #5d6b78;
  --line: #d9dfe5;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --ok: #1b7f4b;
  --ok-bg: #dff3e7;
  --warn: #9a5b00;
  --warn-bg: #fdeccc;
  --danger: #b42318;
  --focus: #1c6fd1;
  --shadow: 0 1px 2px rgba(20, 32, 43, .08), 0 4px 14px rgba(20, 32, 43, .06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1318;
    --surface: #17202a;
    --surface-2: #1d2833;
    --ink: #e8edf2;
    --muted: #9aa8b5;
    --line: #2a3744;
    --accent: #ff8a3d;
    --accent-ink: #1a0f06;
    --ok: #55c486;
    --ok-bg: #153325;
    --warn: #f2b85b;
    --warn-bg: #3a2a0d;
    --danger: #ff7b72;
    --focus: #6cb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Boutons et champs ---------------------------------------------------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: .55rem .9rem; min-height: 42px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: .3rem .65rem; font-size: .88rem; }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 42px; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
textarea { min-height: 76px; resize: vertical; }
.field { min-width: 0; }
.row { display: flex; gap: .6rem; align-items: flex-end; }
.row > .field { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.hint { font-size: .8rem; color: var(--muted); margin: .25rem 0 0; }
.error { color: var(--danger); font-size: .9rem; margin: .5rem 0 0; min-height: 1.2em; }

/* --- Barre du haut ---------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  background: #14202b; color: #f3f2ee;
  padding-block: .6rem;
  padding-top: calc(.6rem + env(safe-area-inset-top, 0));
  padding-left: max(16px, env(safe-area-inset-left, 0));
  padding-right: max(16px, env(safe-area-inset-right, 0));
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 1.05rem; letter-spacing: .01em; }
.brand span { font-size: .8rem; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: .25rem; }
.top .btn.ghost { color: #f3f2ee; min-height: 38px; }

.tabs { display: flex; gap: .25rem; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0)); padding-right: max(16px, env(safe-area-inset-right, 0)); }
.tab { appearance: none; border: 0; background: none; padding: .8rem .9rem; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer; min-height: 46px; }
.tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

/* --- Pages ------------------------------------------------------------------- */
.page {
  max-width: 1280px; margin: 0 auto;
  padding-block: 1rem;
  padding-left: max(16px, env(safe-area-inset-left, 0));
  padding-right: max(16px, env(safe-area-inset-right, 0));
  display: grid; gap: 1rem;
}
.split { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) {
  .split { grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); }
  .sticky { position: sticky; top: 76px; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card > h2 { margin-bottom: .75rem; }
.stack { display: grid; gap: .75rem; }

.daybar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.daybar input[type=date] { width: auto; min-width: 11rem; font-weight: 700; }
.daybar .btn { min-width: 42px; padding-inline: .6rem; }
.pill { display: inline-flex; align-items: center; padding: .2rem .65rem; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; min-width: 0; }
.stat b { display: block; font-size: 1.45rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.map { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: var(--surface-2); z-index: 0; }
@media (min-width: 960px) { .map { height: calc(100vh - 220px); min-height: 420px; } }
.leaflet-container { font: inherit; }
.pin { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--pin, #1b7f4b); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.pin > i { transform: rotate(45deg); color: #fff; font: 700 12px/1 var(--font); font-style: normal; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }

/* --- Formulaire de trajet ------------------------------------------------------ */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: var(--surface); padding: .55rem; font-weight: 700; cursor: pointer; min-height: 42px; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--bg); }
.addr { position: relative; }
.results { list-style: none; margin: .3rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.results li button { width: 100%; text-align: left; border: 0; background: none; padding: .6rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.results li:last-child button { border-bottom: 0; }
.results li button:hover { background: var(--surface-2); }
.duration { align-self: end; padding-bottom: .65rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.trip { display: grid; gap: .35rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.trip:first-child { border-top: 0; padding-top: 0; }
.trip-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.trip-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.trip-meta { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.trip-route { font-size: .9rem; overflow-wrap: anywhere; }
.trip-comment { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.trip-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.empty { color: var(--muted); padding: .5rem 0; }

/* --- Compte rendu admin ---------------------------------------------------------- */
.tech-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.tech-head .who { display: flex; align-items: center; gap: .5rem; min-width: 0; font-weight: 700; }
.tech-nums { display: flex; gap: 1rem; font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); flex-wrap: wrap; }
.tech-nums b { color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; margin: 0; font-size: .85rem; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }

.users { display: grid; gap: 0; }
.user { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: .7rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.user:first-child { border-top: 0; }
.user small { color: var(--muted); display: block; }

/* --- Connexion ------------------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem max(16px, env(safe-area-inset-left, 0)); background: #14202b; }
.login { width: min(100%, 380px); background: var(--surface); border-radius: 14px; padding: 1.5rem; display: grid; gap: .9rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.login h1 { font-size: 1.4rem; }
.login img { width: 48px; height: 48px; border-radius: 12px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom, 0)); z-index: 3000;
  background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); max-width: min(92vw, 460px); font-weight: 600; }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 520px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
