/* NaviOpen: colores tomados del logo (negro y azul). */
:root {
  --azul: #009fe3;
  --azul-osc: #0077ab;
  --negro: #111;
  --gris: #6b7280;
  --linea: #e5e7eb;
  --fondo: #f4f6f8;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif; color: var(--negro); background: var(--fondo); display: flex; flex-direction: column; }

/* ---------- Cabecera ---------- */
.cab { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--linea); }
.cab-logo img { display: block; height: 52px; width: auto; }
.cab-logos { display: flex; align-items: center; gap: 14px; margin-left: 2px; padding-left: 14px; border-left: 1px solid var(--linea); }
.cab-logos:empty { display: none; }
.cab-logos img { display: block; height: 56px; width: auto; max-width: 180px; object-fit: contain; }
.cab-raid { flex: 1; text-align: center; min-width: 0; }
.cab-raid-nombre { font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-reloj { text-align: right; line-height: 1.25; min-width: 170px; }
.cab-hora { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cab-raid-fechas { font-size: .95rem; color: var(--gris); font-weight: 600; margin-top: 2px; }
.cab-raid-fechas:empty { display: none; }
.cab-estado { font-size: .75rem; color: var(--gris); }
.cab-estado.ok { color: #16a34a; }
.cab-estado.ko { color: #dc2626; }

/* ---------- Menú ---------- */
.menu { display: flex; gap: 4px; padding: 0 12px; background: var(--negro); }
.menu a { color: #cbd5e1; text-decoration: none; padding: 10px 18px; font-weight: 600; border-bottom: 3px solid transparent; }
.menu a:hover { color: #fff; }
.menu a.activa { color: #fff; border-bottom-color: var(--azul); }

/* ---------- Mapa ---------- */
.mapa-layout { flex: 1; display: flex; min-height: 0; }
#panel { width: 290px; background: #fff; border-right: 1px solid var(--linea); display: flex; flex-direction: column; min-height: 0; }
.panel-cab { padding: 10px; border-bottom: 1px solid var(--linea); }
#buscar { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .95rem; }
.panel-fila { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .85rem; color: var(--gris); }
#ver-todos { background: var(--azul); color: #fff; border: 0; border-radius: 6px; padding: 5px 10px; font-weight: 600; cursor: pointer; }
#ver-todos:hover { background: var(--azul-osc); }
#lista { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#lista li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
#lista li:hover { background: #eef8fd; }
#lista li.sin-senal { color: #9ca3af; }
#lista .dorsal { flex: none; min-width: 42px; text-align: center; background: var(--azul); color: #fff; border-radius: 4px; padding: 1px 4px; font-weight: 700; font-size: .85rem; }
#lista li.sin-senal .dorsal { background: #9ca3af; }
#lista .nombre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
#lista .hora { flex: none; font-size: .75rem; color: var(--gris); font-variant-numeric: tabular-nums; }
#mapa { flex: 1; min-width: 0; }

.mk-wrap { background: none; border: 0; }
.mk { background: var(--azul); color: #fff; border: 2px solid #fff; border-radius: 12px; height: 24px; line-height: 20px; text-align: center; font-weight: 700; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* ---------- Clasificaciones ---------- */
.contenido { flex: 1; overflow: auto; padding: 16px; }
.barra { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 10px; }
.barra h1 { margin: 0; font-size: 1.3rem; }
.barra select { padding: 6px 10px; font-size: 1rem; border-radius: 6px; border: 1px solid #cbd5e1; }
.aviso { color: #b45309; }
.tabla-scroll { overflow-x: auto; background: #fff; border: 1px solid var(--linea); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: center; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
th { background: var(--negro); color: #fff; position: sticky; top: 0; }
.izq { text-align: left; }
td.pos { font-weight: 700; color: var(--azul-osc); }
td.total { font-weight: 800; }
tbody tr:hover { background: #eef8fd; }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .cab { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .cab-logo img { height: 40px; }
  .cab-logos { gap: 8px; padding-left: 8px; }
  .cab-logos img { height: 40px; max-width: 110px; }
  .cab-raid { order: 3; flex-basis: 100%; }
  .cab-raid-nombre { font-size: 1.15rem; }
  .cab-reloj { min-width: 0; margin-left: auto; }
  .cab-hora { font-size: 1.15rem; }
  .mapa-layout { flex-direction: column-reverse; }
  #panel { width: 100%; height: 34%; border-right: 0; border-top: 1px solid var(--linea); }
}

/* ---------- Categorías, selección, waypoints, leyenda ---------- */
.mk { transition: transform .15s; }
.mk.fin { border-color: #111; }
.mk.sin-senal { background: #9ca3af !important; }
.mk.sel { transform: scale(1.25); border-color: #111; box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0,0,0,.6); }
#lista li.sel { background: #dff3fc; box-shadow: inset 3px 0 0 var(--azul); }
#lista li.sin-senal .dorsal { background: #9ca3af !important; }
.punto { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.35); }

/* Iconos de inicio/fin de etapa y de tramo (imágenes en img/wp/) */
.wp-img { display: block; filter: drop-shadow(0 1px 3px rgba(0,0,0,.55)); }
.wp-mini { display: inline-block; vertical-align: middle; margin-right: 6px; }

.leyenda { background: rgba(255,255,255,.95); padding: 8px 10px; border-radius: 6px; box-shadow: 0 1px 5px rgba(0,0,0,.4); font-size: .82rem; line-height: 1.5; max-height: 45vh; overflow-y: auto; }
.ley-tit { font-weight: 700; margin-top: 2px; }
.ley-tit:not(:first-child) { margin-top: 8px; }
.ley-n { color: var(--gris); font-size: .75rem; }
.ley-cab { font-weight: 700; cursor: pointer; user-select: none; }
.leyenda.cerrada #ley-cuerpo { display: none; }
.leyenda.cerrada .ley-flecha { display: inline-block; transform: rotate(-90deg); }
#ley-cuerpo { margin-top: 4px; }

/* ---------- Flechas con rumbo y dorsal al lado ---------- */
.mkf { position: relative; width: 28px; height: 28px; }
.mkf .flecha { display: block; overflow: visible; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.mkf-dorsal { position: absolute; left: 27px; top: 5px; background: #fff; color: #111; border: 2px solid; border-radius: 9px; padding: 0 5px; font: 700 12px/16px system-ui, "Segoe UI", Arial, sans-serif; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.mkf.sel { transform: scale(1.3); transform-origin: 14px 14px; }
.mkf.sel .mkf-dorsal { background: #111; color: #fff; border-color: #111 !important; }
.mkf.sin-senal .mkf-dorsal { color: #6b7280; }
.mkf.fin .mkf-dorsal { border-color: #111 !important; }

/* ---------- Descargas ---------- */
.desc { max-width: 900px; }
.desc-tabla { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.desc-tabla th, .desc-tabla td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; }
.desc-tabla th { background: #f1f5f9; font-size: .85rem; color: var(--gris); }
.desc-tabla td.num, .desc-tabla th.num { text-align: right; white-space: nowrap; }
.desc-tabla input[type=checkbox] { width: 20px; height: 20px; }
.desc-tabla a { color: inherit; text-decoration: none; font-weight: 600; word-break: break-word; }
.desc-tabla a:hover { text-decoration: underline; }
.desc-acciones { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.btn { background: #0369a1; color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font-size: 1rem; font-weight: 700; cursor: pointer; }
.btn:disabled { background: #94a3b8; cursor: not-allowed; }
.btn.sec { background: #e2e8f0; color: #111; }
@media (max-width: 760px) { .desc-tabla .col-fecha { display: none; } }
