:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16202b;
  --muted: #5d6b7a;
  --line: #e1e5ea;
  --brand: #e8590c;
  --brand-ink: #ffffff;
  --run: #1c7ed6;
  --ok: #2b8a3e;
  --warn: #e67700;
  --sos: #e03131;
  --off: #868e96;
  --out: #343a40;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--run); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: #f1f3f5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--sos); border-color: #ffc9c9; }
.btn.danger.solid { background: var(--sos); color: #fff; border-color: var(--sos); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #ffd8a8; border-color: var(--brand); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.field > input, label.field > select { font-size: 14px; color: var(--ink); font-weight: 400; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

table.data { border-collapse: collapse; width: 100%; background: #fff; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
table.data th { position: sticky; top: 0; background: #f8f9fa; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; z-index: 1; }
table.data tr:hover td { background: #fff8f2; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #fff; background: var(--off); }
.st-inscrito { background: #adb5bd; }
.st-conectado { background: #74c0fc; color: #0b3a5e; }
.st-en_carrera { background: var(--run); }
.st-finalizado { background: var(--ok); }
.st-retirado { background: var(--out); }
.st-sin_senal { background: var(--warn); }
.st-sos { background: var(--sos); }

/* Marcadores de dorsal en el mapa */
.bib-marker { background: none; border: none; }
.bib-marker div {
  min-width: 26px; height: 26px; padding: 0 5px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45);
  transform: translate(-50%, -50%); position: absolute; left: 0; top: 0; white-space: nowrap;
}
.bib-marker.sel div { outline: 3px solid #ffd43b; z-index: 1000; }
.bib-marker.fav div { border-color: #ffd43b; }
.bib-marker.sos div { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(224,49,49,.8); } 50% { box-shadow: 0 0 0 10px rgba(224,49,49,0); } }
.cp-marker { background: none; border: none; }
.cp-marker div {
  width: 22px; height: 22px; border-radius: 4px; background: #fff; border: 2px solid var(--ink); display: flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700; transform: translate(-50%,-50%); position: absolute;
}
.cp-marker.finish div { background: repeating-conic-gradient(#000 0 25%, #fff 0 50%) 50% / 8px 8px; border-color: #000; }
.cp-marker.start div { background: var(--ok); color: #fff; border-color: #fff; }

.leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
.popup h4 { margin: 0 0 4px; font-size: 15px; }
.popup .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; }
.popup .kv > span:nth-child(odd) { color: var(--muted); }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 5000; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--sos); }
.toast.warn { background: var(--warn); }

.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: flex; align-items: center; justify-content: center; z-index: 4000; }
.modal { background: #fff; border-radius: 12px; padding: 18px; width: min(460px, 94vw); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 12px; }
.modal .fields { display: grid; gap: 10px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Perfil del recorrido */
.elev { background: rgba(255,255,255,.96); border-radius: 12px; box-shadow: var(--shadow); padding: 6px 8px 4px; display: flex; flex-direction: column; font-size: 12px; }
.elev-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 0 2px 2px; min-height: 16px; }
.elev-stats { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.elev-stats b { color: var(--ink); }
.elev-hover { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.elev-plot { flex: 1; min-height: 70px; position: relative; }
.elev-plot svg { position: absolute; inset: 0; display: block; cursor: crosshair; touch-action: pan-y; }
.elev-area { fill: rgba(232,89,12,.16); }
.elev-line { fill: none; stroke: #e8590c; stroke-width: 2; stroke-linejoin: round; }
.elev-grid { stroke: #e9ecef; stroke-width: 1; }
.elev-ax { fill: #868e96; font-size: 10px; }
.elev-cp { stroke: #16202b; stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; }
.elev-cpl { fill: #16202b; font-size: 9px; font-weight: 700; }
.elev-mk circle { stroke: #fff; stroke-width: 1.5; }
.elev-mk.sel circle { stroke: #fab005; stroke-width: 2.5; }
.elev-mk text { font-size: 10px; font-weight: 700; fill: #16202b; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.elev-cur { stroke: #16202b; stroke-width: 1; }
.elev-dot { fill: #fff; stroke: #e8590c; stroke-width: 2.5; }
.elev-empty { fill: #868e96; font-size: 12px; }

/* Logo del organizador y "Acerca de" */
.evlogo { height: 34px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 7px; padding: 2px 4px; flex: none; }
.about p { margin: 0 0 10px; line-height: 1.5; }
.infobtn { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); background: transparent; color: #fff; font-weight: 700; font-size: 16px; font-family: Georgia, serif; font-style: italic; cursor: pointer; flex: none; }
