/* Eorzea Tracker — hoja de estilos única. Móvil primero, sin florituras. */

:root {
  --fondo: #12131a;
  --fondo-elevado: #1b1d27;
  --fondo-hundido: #16171f;
  --borde: #2c2f3d;
  --texto: #e6e7ee;
  --texto-apagado: #9a9daf;
  --acento: #6d9eeb;
  --hecho: #4a9d5f;
  --hecho-fondo: #1d2f22;
  --excluido: #6b6f80;
  --conflicto: #cf6a5a;
  --radio: 6px;
}

@media (prefers-color-scheme: light) {
  :root {
    --fondo: #f7f7fa;
    --fondo-elevado: #ffffff;
    --fondo-hundido: #eeeff4;
    --borde: #dcdde4;
    --texto: #1c1d24;
    --texto-apagado: #62657a;
    --acento: #2f5496;
    --hecho: #2f7d45;
    --hecho-fondo: #e6f4ea;
    --excluido: #85899a;
    --conflicto: #b03d2c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--acento); }

.oculto-visual {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* --- Cabecera --------------------------------------------------------------- */

.cabecera {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--borde);
  background: var(--fondo-elevado);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.marca { font-weight: 600; text-decoration: none; color: var(--texto); }

.buscador { flex: 1 1 12rem; }

.buscador input {
  width: 100%;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--fondo);
  color: var(--texto);
  font-size: 0.95rem;
}

.nav-usuario { display: flex; align-items: center; gap: 0.75rem; }
.usuario { color: var(--texto-apagado); font-size: 0.9rem; }

/* --- Disposición ------------------------------------------------------------ */

.disposicion { display: flex; align-items: flex-start; }

.lateral {
  width: 20rem;
  flex: 0 0 20rem;
  border-right: 1px solid var(--borde);
  padding: 1rem 0.5rem 4rem;
  background: var(--fondo-hundido);
  max-height: calc(100vh - 3.2rem);
  overflow-y: auto;
  position: sticky;
  top: 3.2rem;
}

.contenido {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 78rem;
  padding: 1.5rem 1rem 5rem;
}

.sin-lateral .contenido { margin: 0 auto; }

/* --- Árbol lateral ---------------------------------------------------------- */

.arbol { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.arbol .arbol { padding-left: 0.85rem; }

.rama { margin: 0; }

.rama-fila {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: var(--radio);
  padding-right: 0.3rem;
}

.rama-fila:hover { background: var(--fondo-elevado); }

/* El pico se dibuja en CSS: como triángulo inline pesaba 240 bytes por nodo. */
.pico {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.5rem;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  position: relative;
}

.pico:not(.pico-vacio)::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 5px;
  height: 5px;
  border-right: 1.6px solid var(--texto-apagado);
  border-bottom: 1.6px solid var(--texto-apagado);
  transform: translate(-60%, -50%) rotate(-45deg);
  transition: transform 0.12s;
}

.pico:hover::before { border-color: var(--acento); }
.pico-vacio { cursor: default; }

.rama.desplegada > .rama-fila > .pico::before {
  transform: translate(-50%, -60%) rotate(45deg);
}

.pico:focus-visible { outline: 2px solid var(--acento); outline-offset: -2px; border-radius: 3px; }

/* El nombre corto se calcula en la importación; aquí solo se corta lo que aun así se pase. */
.rama-nombre {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--texto);
  text-decoration: none;
  padding: 0.3rem 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rama-nombre:hover { color: var(--acento); }
.rama.activa > .rama-fila { background: var(--fondo-elevado); }
.rama.activa > .rama-fila > .rama-nombre { color: var(--acento); font-weight: 600; }

/* Lo terminado se aparta del camino sin desaparecer: si no hay nada que hacer ahí,
   no debe competir por la atención con lo que sí. */
.rama.completa > .rama-fila > .rama-nombre { color: var(--texto-apagado); }
.rama.completa > .barra { opacity: 0.45; }

.rama-estado {
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--texto-apagado);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.rama-estado.hecha { color: var(--hecho); }

.barra {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--borde);
  overflow: hidden;
  margin: 0 0.3rem 0.25rem 1.45rem;
}

.barra-hecho, .barra-excluido { display: block; height: 100%; float: left; }
.barra-hecho { background: var(--hecho); }
.barra-excluido { background: var(--excluido); opacity: 0.5; }

.ramas:empty { display: none; }
.rama:not(.desplegada) > .ramas { display: none; }

/* --- Panel ------------------------------------------------------------------ */

.resumen {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.kpi {
  background: var(--fondo-elevado);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 0.9rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 11rem;
}

.kpi-cifra { font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.kpi-nombre { font-size: 0.9rem; }
.kpi-detalle { font-size: 0.8rem; color: var(--texto-apagado); }

.kpi-formulario { justify-content: center; }
.kpi-formulario label { font-size: 0.85rem; color: var(--texto-apagado); }
.kpi-formulario input {
  width: 5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--fondo);
  color: var(--texto);
  font-size: 1.1rem;
}

.bloque { margin-bottom: 2.5rem; }

h1 { font-size: 1.4rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.3rem; }
.apagado { color: var(--texto-apagado); font-size: 0.88rem; margin: 0.2rem 0 0.8rem; }

.filtros { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; align-items: center; }

.filtro {
  font-size: 0.82rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--borde);
  border-radius: 999px;
  cursor: pointer;
  background: var(--fondo-elevado);
  user-select: none;
}

.filtro input { display: none; }
.filtro.activo { border-color: var(--acento); color: var(--acento); }
.quitar-filtros { font-size: 0.82rem; }

/* --- Tablas ----------------------------------------------------------------- */

.tabla-entradas {
  width: 100%;
  border-collapse: collapse;
  background: var(--fondo-elevado);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow: hidden;
  margin-bottom: 1.2rem;
}

.tabla-entradas th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--texto-apagado);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--borde);
}

.tabla-entradas td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--borde);
  vertical-align: top;
}

.tabla-entradas tr:last-child td { border-bottom: 0; }

.celda-marca { width: 2.4rem; }
.celda-nivel { width: 3rem; color: var(--texto-apagado); font-variant-numeric: tabular-nums; }
.celda-tipo { width: 9rem; }
.celda-donde { width: 16rem; font-size: 0.82rem; color: var(--texto-apagado); }
.celda-verificacion { width: 2rem; text-align: center; }

.marca {
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--borde);
  border-radius: 4px;
  background: var(--fondo);
  color: var(--texto);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}

.marca:hover { border-color: var(--acento); }

.fila.estado-done { background: var(--hecho-fondo); }
.fila.estado-done .marca { color: var(--hecho); border-color: var(--hecho); }
.fila.estado-done .nombre { color: var(--texto-apagado); }

.fila.estado-excluded { opacity: 0.5; }
.fila.estado-excluded .nombre { text-decoration: line-through; }

.nombre { display: block; }

.enlace-wiki {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--texto-apagado);
  border: 1px solid var(--borde);
  border-radius: 3px;
  padding: 0 0.3rem;
  vertical-align: 1px;
  opacity: 0;
  transition: opacity 0.1s;
}

.fila:hover .enlace-wiki, .enlace-wiki:focus { opacity: 1; }
.enlace-wiki:hover { color: var(--acento); border-color: var(--acento); }

/* En táctil no hay hover: el enlace se ve siempre. */
@media (hover: none) {
  .enlace-wiki { opacity: 1; }
}
.notas { display: block; font-size: 0.8rem; color: var(--texto-apagado); margin-top: 0.15rem; }
.npc { display: block; }
.zona { display: block; }

.etiqueta-desbloqueo {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--acento);
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin: 0.2rem 0.2rem 0 0;
}

.pastilla {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--fondo-hundido);
  border: 1px solid var(--borde);
  color: var(--texto-apagado);
  white-space: nowrap;
}

.verif { font-weight: 700; }
.verif.confirmada { color: var(--hecho); }
.verif.conflicto { color: var(--conflicto); }
.verif.sin-datos, .verif.desmentida, .verif.no-verificable { color: var(--excluido); font-weight: 400; }

/* --- Vista de sección ------------------------------------------------------- */

.cabecera-vista { margin-bottom: 1.5rem; }

.barra-grande {
  height: 8px;
  border-radius: 4px;
  background: var(--borde);
  overflow: hidden;
  max-width: 28rem;
  margin: 0.4rem 0;
}

.barra-grande span { display: block; height: 100%; background: var(--hecho); }

.titulo-bloque {
  margin: 1.8rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.titulo-bloque.nivel-2 { font-size: 1rem; }
.titulo-bloque.nivel-3 { font-size: 0.92rem; color: var(--texto-apagado); }

.nota-seccion {
  margin: 1.2rem 0;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--acento);
  background: var(--fondo-elevado);
  font-size: 0.88rem;
  color: var(--texto-apagado);
}

/* --- Formularios y avisos --------------------------------------------------- */

.tarjeta {
  background: var(--fondo-elevado);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.5rem;
}

.tarjeta-estrecha { max-width: 24rem; margin: 3rem auto; }

.formulario { display: flex; flex-direction: column; gap: 0.4rem; }
.formulario label { font-size: 0.85rem; color: var(--texto-apagado); margin-top: 0.6rem; }

.formulario input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--fondo);
  color: var(--texto);
  font-size: 1rem;
}

.boton {
  margin-top: 1.2rem;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: var(--radio);
  background: var(--acento);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.boton-pequeno { margin-top: 0.4rem; padding: 0.3rem 0.7rem; font-size: 0.85rem; }

.boton-enlace {
  border: 0; background: none; color: var(--acento);
  cursor: pointer; font-size: 0.9rem; padding: 0;
}

.avisos { list-style: none; margin: 0 auto; padding: 0.75rem 1rem 0; max-width: 70rem; }

.aviso {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
  background: var(--fondo-elevado);
  margin-bottom: 0.5rem;
}

.aviso-error { border-color: var(--conflicto); color: var(--conflicto); }

.solo-movil { display: none; }

/* --- Móvil ------------------------------------------------------------------ */

@media (max-width: 60rem) {
  .solo-movil { display: inline; }

  .lateral {
    display: none;
    position: fixed;
    inset: 3.4rem 0 0 0;
    width: 100%;
    flex: none;
    max-height: none;
    z-index: 20;
  }

  .menu-abierto .lateral { display: block; }

  .celda-donde, .celda-tipo { display: none; }
  .celda-verificacion { width: 1.6rem; }
  .contenido { padding: 1rem 0.6rem 4rem; }
  .buscador { order: 3; flex-basis: 100%; }
  .kpi { flex: 1 1 8rem; min-width: 0; }
}
