:root {
  --fond: #f6f6f3; --surface: #ffffff; --texte: #1d1d1b; --discret: #666; --bord: #d4d4cf;
  --accent: #1f5f99; --accent-texte: #fff; --erreur: #b3261e; --ok: #1e7b34;
  --existe: #7fc97f; --a-creer: #e6e6e6; --sel: #fdae61; --survol: #fff3b0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1b1c1e; --surface: #25272a; --texte: #e8e8e4; --discret: #a0a09a; --bord: #3c3e42;
    --accent: #5aa0e0; --accent-texte: #0d1620; --erreur: #ff8a80; --ok: #7bd389;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, sans-serif; background: var(--fond); color: var(--texte); }
a { color: var(--accent); }
button, select, input { font: inherit; }
button { padding: 5px 10px; border: 1px solid var(--bord); border-radius: 4px; background: var(--surface); color: var(--texte); cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: wait; }
button.principal { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--erreur); }
button.lien { border: 0; background: none; color: var(--accent); padding: 0; }
button.large { width: 100%; margin-top: 8px; padding: 8px; }
input, select { padding: 5px 7px; border: 1px solid var(--bord); border-radius: 4px; background: var(--surface); color: var(--texte); }

.barre { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--bord); flex-wrap: wrap; }
.marque { font-weight: 700; text-decoration: none; color: var(--texte); }
.barre nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.barre nav form { margin: 0; }
.messages { padding: 8px 16px 0; }
.msg { margin: 0 0 6px; padding: 8px 12px; border-radius: 4px; background: var(--surface); border-left: 4px solid var(--accent); }
.msg.erreur { border-color: var(--erreur); }
.msg.ok { border-color: var(--ok); }

main.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
.carte-form { max-width: 420px; margin: 24px auto; padding: 20px; background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; display: flex; flex-direction: column; gap: 12px; }
.carte-form label { display: flex; flex-direction: column; gap: 4px; }
.tableau-defile { overflow-x: auto; }
.tableau { width: 100%; border-collapse: collapse; background: var(--surface); }
.tableau th, .tableau td { padding: 6px 8px; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; }
.tableau tr.inactif td { color: var(--discret); }
form.ligne { display: inline-flex; gap: 4px; margin: 2px 4px 2px 0; }

/* page principale : carte + panneau */
main.appli { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 12px; padding: 12px; height: calc(100vh - 50px); }
.zone-carte { display: flex; flex-direction: column; min-height: 0; }
#carte { flex: 1; min-height: 300px; border: 1px solid var(--bord); border-radius: 4px; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 2px; font-size: 13px; }
.legende i { display: inline-block; width: 14px; height: 14px; border: 1px solid #333; vertical-align: -2px; margin-right: 4px; }
.legende .aide { color: var(--discret); margin-left: auto; }
.panneau { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
fieldset { margin: 0; border: 1px solid var(--bord); border-radius: 6px; background: var(--surface); padding: 8px 12px 12px; }
legend { font-weight: 600; padding: 0 4px; }
fieldset label { display: block; margin-top: 6px; }
label.case { display: flex; gap: 6px; align-items: center; }
.boutons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.fort { font-weight: 600; margin: 0; }
.discret { color: var(--discret); margin: 2px 0 0; }
.liste { list-style: none; margin: 0; padding: 0; max-height: 160px; overflow-y: auto; font-family: Consolas, monospace; font-size: 13px; }
.liste li { padding: 2px 0; border-bottom: 1px dotted var(--bord); }
.liste li.existe { color: var(--ok); }
.liste.petite { font-family: inherit; }
#journal { margin: 0; height: 220px; overflow: auto; white-space: pre-wrap; font: 12px/1.4 Consolas, monospace; }
#journal .err { color: var(--erreur); }
#journal .ok { color: var(--ok); }

@media (max-width: 860px) {
  main.appli { grid-template-columns: 1fr; height: auto; padding: 8px 16px; }
  #carte { height: 55vh; }
}
.leaflet-tooltip.etiquette { background: transparent; border: 0; box-shadow: none; font-weight: 600; color: #1d1d1b; padding: 0; }
.leaflet-tooltip.etiquette::before { display: none; }
