:root {
  --fondo: #f6f7f5;
  --superficie: #ffffff;
  --superficie-2: #f0f2ee;
  --texto: #1b1f1c;
  --suave: #5c645e;
  --borde: #dfe3dd;
  --acento: #15803d;
  --acento-fuerte: #14532d;
  --acento-claro: #dcfce7;
  --peligro: #b91c1c;
  --peligro-claro: #fee2e2;
  --aviso: #a16207;
  --aviso-claro: #fef3c7;
  --c1: #15803d; --c2: #2563eb; --c3: #d97706; --c4: #9333ea; --c5: #0891b2; --c6: #db2777; --c7: #65a30d; --c8: #64748b;
  --radio: 10px;
  --sombra: 0 1px 2px rgb(0 0 0 / .05), 0 1px 1px rgb(0 0 0 / .03);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #111412; --superficie: #191d1a; --superficie-2: #212622; --texto: #e7ebe8; --suave: #9aa39c; --borde: #2c332e;
    --acento: #4ade80; --acento-fuerte: #86efac; --acento-claro: #163020; --peligro: #f87171; --peligro-claro: #3b1616;
    --aviso: #fbbf24; --aviso-claro: #362a0c;
    --c1: #4ade80; --c2: #60a5fa; --c3: #fbbf24; --c4: #c084fc; --c5: #22d3ee; --c6: #f472b6; --c7: #a3e635; --c8: #94a3b8;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, 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); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
code, pre, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .86em; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--superficie-2); padding: .8rem 1rem; border-radius: 8px; margin: .4rem 0; border: 1px solid var(--borde); }
.cargando { padding: 3rem; text-align: center; color: var(--suave); }

/* Barra superior */
.barra { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: var(--superficie); border-bottom: 1px solid var(--borde); }
.marca { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--texto); text-decoration: none; font-size: 1.05rem; }
.marca img { width: 26px; height: 26px; }
.barra nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.barra nav a, .barra nav button { color: var(--suave); text-decoration: none; padding: .35rem .7rem; border-radius: 7px; background: none; border: 0; font: inherit; cursor: pointer; }
.barra nav a:hover, .barra nav button:hover, .barra nav a.activo { background: var(--superficie-2); color: var(--texto); }
.barra select { max-width: 220px; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.cabecera { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cabecera p { margin: 0; color: var(--suave); }

/* Pestañas */
.pestanas { display: flex; gap: .25rem; border-bottom: 1px solid var(--borde); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: thin; }
.pestanas a { padding: .55rem .85rem; color: var(--suave); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.pestanas a:hover { color: var(--texto); }
.pestanas a.activo { color: var(--texto); border-color: var(--acento); font-weight: 600; }

/* Tarjetas y rejillas */
.rejilla { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.rejilla.dos { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.1rem; box-shadow: var(--sombra); min-width: 0; }
.tarjeta > h2, .tarjeta > h3 { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tarjeta + .tarjeta, .rejilla + .tarjeta, .tarjeta + .rejilla, .rejilla + .rejilla { margin-top: 1rem; }
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: .85rem 1rem; box-shadow: var(--sombra); }
.kpi .etq { color: var(--suave); font-size: .82rem; }
.kpi .valor { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: .15rem; }
.kpi .nota { color: var(--suave); font-size: .8rem; }
.sitio-tarjeta { cursor: pointer; transition: border-color .15s; text-decoration: none; color: inherit; display: block; }
.sitio-tarjeta:hover { border-color: var(--acento); }
.sitio-tarjeta .mini { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .75rem; margin-top: .75rem; }
.sitio-tarjeta .mini b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.sitio-tarjeta .mini span { color: var(--suave); font-size: .8rem; }
.vacio { color: var(--suave); padding: 1.25rem; text-align: center; border: 1px dashed var(--borde); border-radius: var(--radio); }

/* Tablas */
.tabla-env { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .55rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { color: var(--suave); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td .ruta { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* Etiquetas */
.etiqueta { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .76rem; background: var(--superficie-2); color: var(--suave); border: 1px solid var(--borde); white-space: nowrap; }
.etiqueta.ok, .etiqueta.positivo { background: var(--acento-claro); color: var(--acento-fuerte); border-color: transparent; }
.etiqueta.mal, .etiqueta.negativo, .etiqueta.alta { background: var(--peligro-claro); color: var(--peligro); border-color: transparent; }
.etiqueta.media, .etiqueta.aviso { background: var(--aviso-claro); color: var(--aviso); border-color: transparent; }
.etiqueta.entrenamiento { color: var(--c3); } .etiqueta.busqueda { color: var(--c2); } .etiqueta.agente { color: var(--c1); }
.punto { display: inline-block; width: .65rem; height: .65rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }

/* Formularios */
button, .boton { font: inherit; cursor: pointer; border-radius: 8px; padding: .45rem .9rem; border: 1px solid var(--borde); background: var(--superficie); color: var(--texto); text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .boton:hover { border-color: var(--suave); }
button.primario, .boton.primario { background: var(--acento-fuerte); border-color: var(--acento-fuerte); color: #fff; }
@media (prefers-color-scheme: dark) { button.primario, .boton.primario { color: #0b1a10; background: var(--acento); border-color: var(--acento); } }
button.primario:hover { filter: brightness(1.08); }
button.peligro { color: var(--peligro); }
button.mini { padding: .2rem .55rem; font-size: .82rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--texto); background: var(--superficie); border: 1px solid var(--borde); border-radius: 8px; padding: .45rem .6rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--acento) 35%, transparent); border-color: var(--acento); }
input[type=checkbox] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--suave); margin-bottom: .75rem; }
label > input, label > select, label > textarea { margin-top: .25rem; color: var(--texto); }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--texto); }
.fila { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.fila.fin { justify-content: flex-end; }
.campos { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.ayuda { color: var(--suave); font-size: .85rem; margin: .25rem 0 .75rem; }
.competidor { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .5rem; margin-bottom: .5rem; }

/* Gráficos */
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico .eje { fill: var(--suave); font-size: 11px; }
.grafico .rejilla-linea { stroke: var(--borde); stroke-width: 1; }
.leyenda { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .8rem; color: var(--suave); margin-top: .5rem; }
.barras-h .item { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: .6rem; align-items: center; padding: .2rem 0; font-size: .88rem; }
.barras-h .item .nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barras-h .pista { background: var(--superficie-2); border-radius: 4px; height: .7rem; overflow: hidden; }
.barras-h .relleno { height: 100%; border-radius: 4px; background: var(--acento); }
.barras-h .valor { font-variant-numeric: tabular-nums; color: var(--suave); font-size: .82rem; min-width: 3.5rem; text-align: right; }
.barras-h .item.propio .nombre { font-weight: 700; }

/* Respuestas */
.respuesta { border: 1px solid var(--borde); border-radius: var(--radio); padding: .75rem 1rem; margin-bottom: .75rem; background: var(--superficie); }
.respuesta .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--suave); margin-bottom: .4rem; }
.respuesta .cuerpo { white-space: pre-wrap; font-size: .9rem; max-height: 280px; overflow: auto; }
.respuesta .cuerpo mark { background: var(--acento-claro); color: var(--acento-fuerte); border-radius: 3px; padding: 0 2px; }
.respuesta .cuerpo mark.rival { background: var(--aviso-claro); color: var(--aviso); }
.citas { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.citas a { font-size: .78rem; text-decoration: none; }
.celda-modelo { text-align: center; white-space: nowrap; }
.si { color: var(--acento); font-weight: 700; } .no { color: var(--suave); } .err { color: var(--peligro); }

/* Auditoría */
.puntuacion { font-size: 3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.puntuacion.buena { color: var(--acento); } .puntuacion.regular { color: var(--aviso); } .puntuacion.mala { color: var(--peligro); }
.compr { display: grid; grid-template-columns: 1.5rem 1fr auto; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--borde); font-size: .9rem; }
.compr:last-child { border-bottom: 0; }
.recomendacion { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; padding: .75rem 0; border-bottom: 1px solid var(--borde); }
.recomendacion:last-child { border-bottom: 0; }
.recomendacion p { margin: .1rem 0 0; color: var(--suave); font-size: .9rem; }

/* Entrada */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.entrada form { width: min(360px, 100%); }
.entrada .marca { justify-content: center; margin-bottom: 1rem; font-size: 1.3rem; }

#aviso { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--texto); color: var(--fondo); padding: .55rem 1rem; border-radius: 8px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 2rem); z-index: 50; }
#aviso.visible { opacity: 1; }
#aviso.error { background: var(--peligro); color: #fff; }

dialog { border: 1px solid var(--borde); border-radius: 12px; background: var(--superficie); color: var(--texto); padding: 1.25rem; width: min(720px, calc(100% - 2rem)); max-height: calc(100vh - 3rem); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
.progreso { height: 6px; background: var(--superficie-2); border-radius: 3px; overflow: hidden; margin: .5rem 0; }
.progreso div { height: 100%; background: var(--acento); transition: width .3s; }
.md { font-size: .92rem; }
.md h1, .md h2, .md h3 { margin-top: 1rem; }

@media (max-width: 700px) {
  .barra { flex-wrap: wrap; padding: .5rem 1rem; }
  .barra nav { margin-left: 0; width: 100%; overflow-x: auto; }
  main { padding: 1rem 1rem 3rem; }
  .rejilla.dos { grid-template-columns: 1fr; }
  .competidor { grid-template-columns: 1fr 1fr; }
  .kpi .valor { font-size: 1.4rem; }
}
