/*
 * Nexo2 Trace: estilos propios de las pantallas del proyecto. Usa los tokens
 * de nexo2-ui (`--color-*`, `--radius-nexo2*`, `--shadow-nexo2-*`); no define
 * paleta propia salvo los acentos de los KPI del boceto.
 */

/* --- Ficha del isométrico -------------------------------------------------- */
.trace-iso__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.trace-iso__kicker {
  color: var(--color-brand-600);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.trace-iso__title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 4px; }
.trace-iso__title-row h2 {
  margin: 0;
  color: var(--color-text-strong);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.trace-iso__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* KPI del análisis (uniones, componentes, ramales, flujo). */
.trace-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.trace-kpi {
  --accent: var(--color-brand-600);
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-nexo2-lg);
  background: var(--color-surface-panel);
  box-shadow: var(--shadow-nexo2-sm);
}
.trace-kpi__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
}
.trace-kpi > div { display: grid; min-width: 0; }
.trace-kpi strong { color: var(--color-text-strong); font-size: 26px; font-weight: 700; line-height: 1.1; }
.trace-kpi b { color: var(--color-text-strong); font-size: 15px; font-weight: 700; }
.trace-kpi span:not(.trace-kpi__icon) { color: var(--color-text-muted); font-size: 13px; }
.trace-kpi--teal { --accent: #0e9f9a; }
.trace-kpi--amber { --accent: #f08c00; }
.trace-kpi--green { --accent: var(--color-success-600); }
.trace-kpi--muted { --accent: var(--color-text-muted); }

/* Franja de metadatos del plano. */
.trace-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-nexo2-lg);
  background: var(--color-surface-panel);
}
.trace-meta > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 18px;
  font-size: 13.5px;
}
.trace-meta > div + div { border-left: 1px solid var(--color-border-subtle); }
.trace-meta i { color: var(--color-text-muted); }
.trace-meta span { color: var(--color-text-muted); }
.trace-meta b { min-width: 0; color: var(--color-text-strong); font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 720px) { .trace-meta > div + div { border-left: 0; border-top: 1px solid var(--color-border-subtle); } }

/* La ficha estándar dentro de la pestaña «Datos del plano»: sin doble marco. */
.trace-tabs__record > article { border: 0; border-radius: 0; }

/* --- Visor CAD --------------------------------------------------------------- */
.trace-visor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  padding: 16px;
}
@media (max-width: 1100px) { .trace-visor { grid-template-columns: 1fr; } }
.trace-visor__canvas {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border-radius: var(--radius-nexo2-lg);
  background: #1d2129;
  color: #c9d1dd;
}
.trace-visor__badge {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / .12);
  border-radius: var(--radius-nexo2);
  background: rgb(0 0 0 / .35);
  font-size: 13px;
}
.trace-visor__badge::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: #3ddc84; }
.trace-visor__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  font-size: 14px;
}
.trace-visor__empty i { font-size: 40px; color: #6b7a90; }
.trace-visor__empty a { color: #8fb4ff; }
.trace-visor__side { display: grid; align-content: start; gap: 16px; }
.trace-panel {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-nexo2-lg);
  background: var(--color-surface-panel);
}
.trace-panel > h3 {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-strong);
  font-size: 14px;
  font-weight: 700;
}
.trace-layers { margin: 0; padding: 6px 0; list-style: none; }
.trace-layers li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  font-size: 13.5px;
}
.trace-layers li > i { width: 18px; color: var(--color-text-muted); text-align: center; }
.trace-layers li > span { flex: 1; }
.trace-layers label { display: inline-flex; align-items: center; cursor: pointer; }
.trace-layers__empty { color: var(--color-text-muted); }

.trace-visor__stage { position: absolute; inset: 0; }
.trace-visor__canvas.is-ready .trace-visor__empty { display: none; }
.trace-visor__canvas.is-loading .trace-visor__empty i { animation: trace-pulse 1.2s ease-in-out infinite; }
@keyframes trace-pulse { 50% { opacity: .35; } }
.trace-visor__tools {
  position: absolute; z-index: 2; top: 14px; right: 14px; display: flex; gap: 4px; padding: 4px;
  border: 1px solid rgb(255 255 255 / .12); border-radius: var(--radius-nexo2); background: rgb(0 0 0 / .35);
}
.trace-visor__tools > * {
  display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px;
  background: transparent; color: #c9d1dd; cursor: pointer;
}
.trace-visor__tools > *:hover { background: rgb(255 255 255 / .1); color: #fff; }
.trace-visor__hint { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--color-text-muted); font-size: 12.5px; }

.trace-union [data-trace-visor-union-body] { display: grid; gap: 12px; padding: 14px 16px; }
.trace-union__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trace-union__head strong { color: var(--color-text-strong); font-size: 16px; }
.trace-union__data { display: grid; gap: 6px; margin: 0; font-size: 13.5px; }
.trace-union__data > div { display: flex; justify-content: space-between; gap: 12px; }
.trace-union__data dt { color: var(--color-text-muted); }
.trace-union__data dd { margin: 0; color: var(--color-text-strong); font-weight: 600; text-align: right; }
.trace-union__foot { margin: 0; padding: 0 16px 14px; }
.trace-union__foot[hidden] { display: none; }
.trace-union__link { display: inline-flex; align-items: center; gap: 6px; color: var(--color-brand-600); font-size: 13.5px; font-weight: 600; }
.trace-union__joins { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--color-border-subtle); }
.trace-union__label { color: var(--color-text-muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.trace-union__joins ol { position: relative; display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.trace-union__joins li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border: 1px solid var(--color-border-subtle); border-radius: var(--radius-nexo2); background: var(--color-surface-muted); font-size: 13px; }
.trace-union__joins li > span { color: var(--color-text-muted); }
.trace-union__joins a { color: var(--color-brand-600); font-weight: 600; text-align: right; }
.trace-union__joins code { margin-left: 4px; color: var(--color-text-muted); font-size: 11.5px; font-weight: 500; }
.trace-union__none { color: var(--color-text-muted); font-style: italic; }
.trace-union__empty { margin: 0; color: var(--color-text-muted); font-size: 13.5px; }

/* --- Inicio: Gestión de isométricos --------------------------------------- */
.trace-home__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.trace-home__title { display: flex; align-items: center; gap: 14px; }
.trace-home__mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: var(--color-brand-50); color: var(--color-brand-600); font-size: 21px;
}
.trace-home__title h2 { margin: 0; color: var(--color-text-strong); font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.trace-home__title p { margin: 2px 0 0; color: var(--color-text-muted); font-size: 13.5px; }
.trace-kpi small { color: var(--color-text-muted); font-size: 12px; }
.trace-home .trace-kpi > div > span:first-child { color: var(--color-text-body); font-size: 13px; font-weight: 600; }
.trace-kpi--red { --accent: var(--color-danger-600); }

.trace-latest__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--color-border-subtle); }
.trace-latest__head h3 { margin: 0; color: var(--color-text-strong); font-size: 16px; font-weight: 700; }
.trace-latest__head a { display: inline-flex; align-items: center; gap: 6px; color: var(--color-brand-600); font-size: 13.5px; font-weight: 600; }
.trace-latest__empty { padding: 28px; color: var(--color-text-muted); text-align: center; }
.trace-latest__scroll { overflow-x: auto; }
.trace-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.trace-table th {
  padding: 10px 16px; border-bottom: 1px solid var(--color-border-subtle); background: var(--color-surface-muted);
  color: var(--color-text-muted); font-size: 12px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .04em;
}
.trace-table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border-subtle); color: var(--color-text-body); vertical-align: middle; }
.trace-table tr:last-child td { border-bottom: 0; }
.trace-table tbody tr:hover { background: color-mix(in srgb, var(--color-brand-50) 45%, transparent); }
.trace-table a { color: var(--color-brand-600); }
.trace-table__plano { display: inline-flex; align-items: center; gap: 10px; color: var(--color-text-strong) !important; font-weight: 600; }
.trace-table__plano i { color: var(--color-brand-500); }
.trace-table__date { display: block; color: var(--color-text-strong); }
.trace-table td small { color: var(--color-text-muted); font-size: 12px; }
.trace-table__actions { white-space: nowrap; text-align: right; }
.trace-table__actions a { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-nexo2); color: var(--color-text-muted) !important; }
.trace-table__actions a:hover { background: var(--color-surface-muted); color: var(--color-brand-600) !important; }

/* --- Flujo y ramales: recorrido -------------------------------------------- */
.trace-flow { display: grid; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--color-border-subtle); background: var(--color-surface-muted); }
.trace-flow__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.trace-flow__head strong { display: inline-flex; align-items: center; gap: 8px; color: var(--color-text-strong); font-size: 14px; }
/* Principal a la izquierda; derivaciones colgando de él (tronco + rama), sin encadenarse. */
.trace-flow__tree { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 0; }
.trace-flow__mains { display: grid; gap: 10px; }
.trace-flow__branches { position: relative; display: grid; gap: 10px; margin: 0 0 0 28px; padding: 0 0 0 24px; list-style: none; }
.trace-flow__branches::before { /* enlace principal → tronco */
  content: ""; position: absolute; left: -28px; top: 50%; width: 28px; border-top: 2px solid var(--color-border-strong, #c4cad6);
}
.trace-flow__branches > li { position: relative; }
.trace-flow__branches > li::before { /* tronco vertical */
  content: ""; position: absolute; left: -24px; top: -5px; bottom: -5px; border-left: 2px solid var(--color-border-strong, #c4cad6);
}
.trace-flow__branches > li:first-child::before { top: 50%; }
.trace-flow__branches > li:last-child::before { bottom: 50%; }
.trace-flow__branches > li:only-child::before { display: none; }
.trace-flow__branches > li::after { /* rama horizontal */
  content: ""; position: absolute; left: -24px; top: 50%; width: 24px; border-top: 2px solid var(--color-border-strong, #c4cad6);
}
.trace-flow__step {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 14px;
  border: 1px solid var(--color-border-subtle); border-radius: var(--radius-nexo2-lg); background: var(--color-surface-panel);
}
.trace-flow__step.is-main { border-color: var(--color-brand-500); box-shadow: inset 3px 0 0 var(--color-brand-600); }
.trace-flow__code {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 999px;
  background: var(--color-brand-50); color: var(--color-brand-700); font-size: 12.5px; font-weight: 700;
}
.trace-flow__step.is-main .trace-flow__code { background: var(--color-brand-600); color: #fff; }
.trace-flow__step > div { display: grid; min-width: 0; }
.trace-flow__step strong { color: var(--color-text-strong); font-size: 13.5px; }
.trace-flow__step small { color: var(--color-text-muted); font-size: 12px; }
.trace-flow__step small a { color: var(--color-brand-600); font-weight: 600; }

/* --- Login con portada ------------------------------------------------------- */
.trace-landing { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); background: var(--color-surface-page); }
@media (max-width: 900px) { .trace-landing { grid-template-columns: 1fr; } }
.trace-landing__hero {
  position: relative; display: flex; flex-direction: column; gap: 40px; overflow: hidden; padding: 48px 56px;
  background:
    radial-gradient(1200px 500px at 110% -10%, rgb(116 152 184 / .22), transparent 60%),
    linear-gradient(160deg, #06284c 0%, #07345f 55%, #05233f 100%);
  color: #dbe5f0;
}
/* Trama isométrica muy suave (30°/150°), guiño al dibujo técnico. */
.trace-landing__hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background-image:
    repeating-linear-gradient(30deg, #fff 0 1px, transparent 1px 46px),
    repeating-linear-gradient(150deg, #fff 0 1px, transparent 1px 46px);
}
.trace-landing__hero > * { position: relative; }
.trace-landing__brand { height: 64px; }
.trace-landing__brand svg { display: block; width: auto; height: 100%; max-width: 100%; }
.trace-landing__pitch { display: grid; gap: 16px; max-width: 34rem; margin-top: auto; }
.trace-landing__kicker { color: #8fb4d6; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.trace-landing__pitch h1 { margin: 0; color: #fff; font-size: clamp(26px, 3vw, 38px); font-weight: 700; line-height: 1.15; letter-spacing: -.015em; }
.trace-landing__pitch p { margin: 0; color: #b9c8d8; font-size: 16px; line-height: 1.55; }
.trace-landing__features { display: grid; gap: 14px; max-width: 34rem; margin: 0; padding: 0; list-style: none; }
.trace-landing__features li { display: flex; align-items: flex-start; gap: 14px; }
.trace-landing__features li > span {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 1px solid rgb(255 255 255 / .14);
  border-radius: 12px; background: rgb(255 255 255 / .06); color: #a9c6e2; font-size: 16px;
}
.trace-landing__features div { display: grid; gap: 2px; }
.trace-landing__features strong { color: #fff; font-size: 15px; }
.trace-landing__features small { color: #a8b8c9; font-size: 13.5px; }
.trace-landing__foot { margin: auto 0 0; color: #7f93a8; font-size: 12.5px; }
.trace-landing__access { display: grid; place-items: center; padding: 48px 32px; }
.trace-landing__form { width: 100%; max-width: 400px; }
.trace-landing__mark { width: 44px; height: 44px; margin-bottom: 18px; }
.trace-landing__mark svg { display: block; width: 100%; height: 100%; }
.trace-landing__form h2 { margin: 0; color: var(--color-text-strong); font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.trace-landing__form > p { margin: 6px 0 24px; color: var(--color-text-muted); font-size: 14px; }
@media (max-width: 900px) {
  .trace-landing__hero { gap: 24px; padding: 32px 24px; }
  .trace-landing__features, .trace-landing__foot { display: none; }
  .trace-landing__pitch { margin-top: 0; }
  .trace-landing__brand { height: 48px; }
  .trace-landing__access { padding: 32px 20px 48px; }
}

/* Pestaña «WMAP»: hoja «WMAP BASE», columnas N–T. */
.trace-wmap__scroll { overflow-x: auto; }
.trace-wmap__caption { caption-side: top; padding: 12px 16px 4px; text-align: left; color: var(--color-text-muted); font-size: 12.5px; }
.trace-wmap__table th[scope="col"] { white-space: nowrap; }
.trace-wmap__letter { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-right: 6px; border-radius: 4px; background: var(--color-surface-muted); color: var(--color-text-muted); font-size: 11px; font-weight: 700; }
.trace-wmap__code { display: block; margin-top: 2px; color: var(--color-text-muted); font-size: 10.5px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.trace-wmap__table tbody th { padding: 12px 16px; background: transparent; text-align: left; font-size: 13.5px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--color-text-strong); border-bottom: 1px solid var(--color-border-subtle); }
.trace-wmap__table tbody tr:last-child th { border-bottom: 0; }
.trace-wmap__table tbody tr.is-updated { animation: trace-wmap-updated 1.6s ease-out; }
@keyframes trace-wmap-updated { from { background: color-mix(in srgb, var(--color-success-500, #22c55e) 18%, transparent); } to { background: transparent; } }
.trace-wmap__empty { margin: 0; padding: 24px 16px; color: var(--color-text-muted); }

/* Pestaña «Espesores»: número de palillo como en las flechas verdes del plano. */
.trace-thk__palillo { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: color-mix(in srgb, var(--color-success-500, #22c55e) 16%, transparent); color: var(--color-success-700, #15803d); font-weight: 700; }
.trace-thk__label { display: block; margin-top: 2px; }
