:root {
  --fondo: #131219;
  --panel: #1b1a24;
  --panel2: #232231;
  --borde: #302e40;
  --texto: #e9e7f2;
  --suave: #a29ebb;
  --acento: #7b5bf2;
  --acento2: #9b82ff;
  --ok: #3ec98a;
  --aviso: #ffb454;
  --mal: #ff6b6b;
  --radio: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --fondo: #f5f4f9; --panel: #ffffff; --panel2: #f0eef7; --borde: #dedbec;
    --texto: #1d1b28; --suave: #63607a;
  }
}

* { 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;
  padding-bottom: 5rem;
}

header {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem; background: var(--panel);
  border-bottom: 1px solid var(--borde);
}
.marca { display: flex; align-items: center; gap: .8rem; }
.logo { font-size: 1.8rem; }
h1 { font-size: 1.15rem; margin: 0; letter-spacing: .01em; }
header p { margin: 0; color: var(--suave); font-size: .8rem; }

.pastillas { display: flex; gap: .5rem; flex-wrap: wrap; }
.pastilla {
  display: flex; align-items: center; gap: .45rem;
  background: var(--panel2); border: 1px solid var(--borde);
  border-radius: 999px; padding: .3rem .75rem; font-size: .8rem;
}
.punto { width: .55rem; height: .55rem; border-radius: 50%; background: var(--suave); flex: none; }
.punto.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(62,201,138,.18); }
.punto.off { background: #575569; }
.punto.err { background: var(--mal); box-shadow: 0 0 0 3px rgba(255,107,107,.18); }

nav {
  display: flex; gap: .25rem; overflow-x: auto; padding: .6rem 1.1rem 0;
  background: var(--panel); border-bottom: 1px solid var(--borde);
}
nav button {
  background: none; border: none; color: var(--suave); cursor: pointer;
  padding: .55rem .85rem; border-radius: var(--radio) var(--radio) 0 0;
  font: inherit; font-size: .9rem; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav button:hover { color: var(--texto); }
nav button.activa { color: var(--texto); border-bottom-color: var(--acento); background: var(--fondo); }

main { max-width: 60rem; margin: 0 auto; padding: 1.4rem 1.1rem; }

.tarjeta {
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.tarjeta > h2 { font-size: 1rem; margin: 0 0 .2rem; }
.tarjeta > h2 + p.sub { margin: 0 0 1rem; color: var(--suave); font-size: .85rem; }
.tarjeta h3 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--suave); margin: 1.4rem 0 .7rem; font-weight: 600;
}
.tarjeta h3:first-child { margin-top: 0; }

.campo { margin-bottom: 1rem; }
.campo > label { display: block; font-weight: 500; margin-bottom: .3rem; font-size: .92rem; }
.campo .ayuda { color: var(--suave); font-size: .82rem; margin: .3rem 0 0; }
.campo .unidad { color: var(--suave); font-size: .82rem; margin-left: .4rem; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--panel2); color: var(--texto);
  border: 1px solid var(--borde); border-radius: 8px; padding: .5rem .65rem;
  font: inherit; font-size: .92rem;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px rgba(123,91,242,.2);
}
textarea { min-height: 8rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
input[type=number] { max-width: 12rem; }

.interruptor { display: flex; align-items: flex-start; gap: .7rem; }
.interruptor input { margin-top: .25rem; width: 1.05rem; height: 1.05rem; accent-color: var(--acento); flex: none; }
.interruptor label { font-weight: 500; }

button {
  font: inherit; font-size: .88rem; cursor: pointer; border-radius: 8px;
  padding: .45rem .9rem; border: 1px solid var(--borde);
  background: var(--panel2); color: var(--texto);
}
button:hover { border-color: var(--acento); }
button:disabled { opacity: .5; cursor: default; }
button.primario { background: var(--acento); border-color: var(--acento); color: #fff; font-weight: 600; }
button.primario:hover { background: var(--acento2); }
button.secundario { background: transparent; }
button.peligro { border-color: #6a3140; color: #ffb0b0; }

.fila { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.derecha { margin-left: auto; }

.aviso {
  border-radius: 8px; padding: .6rem .8rem; margin-bottom: .6rem; font-size: .88rem;
  border: 1px solid; display: flex; gap: .5rem;
}
.aviso.error { border-color: #6a3140; background: rgba(255,107,107,.09); }
.aviso.aviso2 { border-color: #6b5326; background: rgba(255,180,84,.09); }
.aviso.ok { border-color: #24614a; background: rgba(62,201,138,.09); }

pre.salida {
  background: #0f0e14; color: #d6d2e8; border: 1px solid var(--borde);
  border-radius: 8px; padding: .8rem; overflow: auto; max-height: 26rem;
  font-size: .8rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
pre.logs { max-height: 34rem; white-space: pre; word-break: normal; }

table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--borde); }
th { color: var(--suave); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.recorta { max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--panel); border-top: 1px solid var(--acento);
  padding: .7rem 1.2rem; box-shadow: 0 -6px 24px rgba(0,0,0,.28);
}
.barra.oculta { display: none; }
.barra > div { display: flex; gap: .5rem; }

.brindis {
  position: fixed; right: 1rem; bottom: 4.5rem; z-index: 30;
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-end;
}
.brindis div {
  background: var(--panel2); border: 1px solid var(--borde);
  border-left: 3px solid var(--acento);
  padding: .55rem .9rem; border-radius: 8px; font-size: .86rem; max-width: 26rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.brindis div.mal { border-left-color: var(--mal); }
.brindis div.bien { border-left-color: var(--ok); }

.cargando { color: var(--suave); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.tenue { color: var(--suave); }
.cambia { color: var(--ok); }
.igual { color: var(--suave); }

.modulo-cabecera {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding-bottom: .8rem; margin-bottom: .8rem; border-bottom: 1px solid var(--borde);
}
.modulo-cabecera .crece { flex: 1 1 14rem; }

details.avanzado { margin-top: 1rem; border-top: 1px dashed var(--borde); padding-top: .8rem; }
details.avanzado summary { cursor: pointer; color: var(--suave); font-size: .86rem; }
details.avanzado[open] summary { margin-bottom: .9rem; }

@media (max-width: 640px) {
  header { padding: .8rem 1rem; }
  main { padding: 1rem .8rem; }
  .barra { flex-direction: column; align-items: stretch; }
  .barra > div { justify-content: flex-end; }
}

/* --- añadidos de la v3: matriz, globos y botones-enlace ------------------ */

a.boton {
  display: inline-block; text-decoration: none; color: var(--texto);
  background: var(--panel2); border: 1px solid var(--borde);
  border-radius: 8px; padding: .45rem .9rem; font-size: .88rem;
}
a.boton:hover { border-color: var(--acento); }

.globo {
  display: inline-block; margin-left: .4rem; background: var(--aviso);
  color: #2a1c04; border-radius: 999px; padding: 0 .4rem;
  font-size: .72rem; font-weight: 700; line-height: 1.35;
}

.tabla-scroll { overflow-x: auto; }
table.matriz { min-width: 40rem; }
table.matriz th:first-child, table.matriz td:first-child { min-width: 18rem; }
table.matriz td.cel {
  text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.matriz td.cel small { display: block; font-size: .68rem; color: var(--suave); }
table.matriz td.si { color: var(--ok); font-weight: 700; }
table.matriz td.parcial { color: var(--aviso); font-weight: 600; }
table.matriz td.vacia { color: #55536a; }

/* ---- Torrents: filas desplegables con los archivos de cada copia ---- */
table.matriz td.abridor { cursor: pointer; user-select: none; }
table.matriz td.abridor:hover { color: var(--acento, #7aa2f7); }
table.matriz td.abridor .flecha { display: inline-block; width: 1rem; color: var(--suave); }
table.matriz tr.detalle.oculto { display: none; }
table.matriz tr.detalle > td { background: rgba(255, 255, 255, .03); padding: .6rem .8rem; }
.archivos { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.archivos .grupo { flex: 1 1 22rem; min-width: 0; }
.archivos h4 { margin: 0 0 .2rem; font-size: .82rem; }
.archivos ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.archivos li { font-size: .78rem; line-height: 1.5; word-break: break-all; }
.archivos li small { color: var(--suave); }

/* ---- Torrents: el mando de cada torrent (descargas y etapas) ---- */
button.chico { padding: .25rem .55rem; font-size: .74rem; }
.mando { margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--borde, #2a2940); }
.mando .fila { align-items: center; gap: .4rem; flex-wrap: wrap; }
.ficha { margin-top: .6rem; }
ol.etapas { margin: .4rem 0 .6rem; padding-left: 1.4rem; }
ol.etapas li { font-size: .8rem; line-height: 1.6; list-style: decimal; }
ol.etapas li.pendiente { color: var(--suave); }
ol.etapas li .marca { display: inline-block; width: 1rem; font-weight: 700; }
ol.etapas li.hecha .marca { color: var(--ok); }
ol.etapas li small { color: var(--suave); }
.botonera { margin-top: .5rem; }

/* ---- pantalla de acceso ---- */
.acceso { max-width: 28rem; margin: 3rem auto; background: var(--tarjeta, #1b1a2b);
          border: 1px solid var(--borde, #2a2940); border-radius: 12px; padding: 1.6rem; }
.acceso h2 { margin: 0 0 .3rem; font-size: 1.1rem; }
.acceso .fila { margin-top: .8rem; gap: .5rem; }
.acceso input { flex: 1 1 12rem; }
.acceso .ayuda { margin-top: 1rem; line-height: 1.6; }
.oculta { display: none; }
