:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --card: #fff; --text: #1c2128; --muted: #667080; --line: #dfe3e8;
  --on: #1a7f4b; --tx: #c62828; --warn-bg: #fff4d6; --warn-text: #7a5600;
}
/* Nuit : choisie avec le bouton Jour/Nuit (theme.js), sinon d'apres le reglage du systeme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b; --card: #1d2126; --text: #e6e9ed; --muted: #97a1ad; --line: #30363d;
    --on: #3fb97f; --tx: #f0605c; --warn-bg: #3b3115; --warn-text: #f0cf7a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171b; --card: #1d2126; --text: #e6e9ed; --muted: #97a1ad; --line: #30363d;
  --on: #3fb97f; --tx: #f0605c; --warn-bg: #3b3115; --warn-text: #f0cf7a;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.03em;
         text-transform: uppercase; }
.brand img { width: 28px; height: 28px; }
/* Le logo et le nom ramenent toujours a la carte. */
a.brand { flex: none; font-size: 22px; text-decoration: none; }
a.brand:hover span { text-decoration: underline; }
/* Bandeau du haut, le meme sur toutes les pages. */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
       padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.page-title { margin: 0; font-size: 18px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.menu { position: relative; flex: none; margin-left: auto; }
.menu summary { list-style: none; padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px;
                cursor: pointer; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--bg); }
/* Au-dessus de la carte, de ses boutons et de la fiche d'intervention. */
.menu nav { position: absolute; top: calc(100% + 4px); right: 0; z-index: 1200; display: grid; min-width: 230px;
            padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
            box-shadow: 0 4px 16px rgb(0 0 0 / 0.35); }
.menu nav a { padding: 8px 10px; border-radius: 6px; text-decoration: none; white-space: nowrap; }
.menu nav a[aria-current="page"] { font-weight: 700; }
.menu nav button { padding: 8px 10px; border: 0; border-radius: 6px; text-align: left; white-space: nowrap; }
.menu nav a:hover, .menu nav a:focus-visible, .menu nav button:hover, .menu nav button:focus-visible {
  background: var(--bg); }
/* Pages autres que la carte : le bandeau, puis le contenu centre. */
.page main { margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.page section, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
                        min-width: 0; }
.page section > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.page section > h2 small { font-size: 14px; font-weight: 400; color: var(--muted); }
.hint { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.error-box { padding: 6px 10px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-text);
             overflow-wrap: anywhere; }
.field { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
         padding: 4px 8px; min-width: 0; }
.field.err { border-color: var(--tx); }
.danger-button { color: var(--tx); border-color: currentColor; font-weight: 600; }
.danger-button:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 600px) {
  .page main { padding: 10px; }
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 1px solid var(--line);
         border-radius: 6px; padding: 3px 10px; cursor: pointer; }
input.name { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line);
             border-radius: 4px; padding: 2px 6px; min-width: 0; }
input.name.err { border-color: var(--tx); }
.st-disponible { --fill: #1a7f4b; --ink: #fff; }
.st-indisponible { --fill: #6b7480; --ink: #fff; }
.st-appele { --fill: #7b4fc9; --ink: #fff; }
.st-depart { --fill: #c62828; --ink: #fff; }
.st-sur_place { --fill: #f28c28; --ink: #1c2128; }
.st-evacuation { --fill: #0b6bcb; --ink: #fff; }
.steps-box { overflow-x: auto; }
.steps { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.steps th { padding: 0 2px 2px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center;
            vertical-align: bottom; }
.steps td { padding: 2px; border-top: 1px solid var(--line); text-align: center; }
.steps th:first-child, .steps td:first-child { text-align: left; font-weight: 600; overflow-wrap: break-word; }
.history { margin: 0; padding: 0; list-style: none; font-size: 14px; font-variant-numeric: tabular-nums; }
.history li { padding: 2px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.history time { display: block; font-size: 12px; color: var(--muted); }
#confirm { width: min(420px, calc(100vw - 32px)); padding: 14px 16px; color: var(--text); background: var(--card);
           border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.35); }
#confirm::backdrop { background: rgb(0 0 0 / 0.45); }
#confirm p { margin: 0; overflow-wrap: anywhere; }
#confirm-title { font-size: 18px; font-weight: 600; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#confirm-ok { color: var(--tx); border-color: currentColor; font-weight: 600; }
/* Reperes des fichiers GPX : leur nom n'apparait qu'en zoomant. */
.gpx-mark { position: relative; display: block; width: 10px; height: 10px; border-radius: 50%;
            background: var(--gpx); border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.5); }
.gpx-mark span { display: none; position: absolute; left: 12px; top: -6px; white-space: nowrap; font-size: 12px;
                 font-weight: 700; line-height: 16px; color: #1c2128; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.gpx-labels .gpx-mark span { display: block; }
.grid-label { display: none; text-align: center; font-size: 12px; font-weight: 700; line-height: 16px;
              text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.grid-label span { color: color-mix(in srgb, var(--gpx) 65%, #000); }
.grid-labels .grid-label { display: block; }
