/* Revteq UI · componentes (CSS puro, prefijo rq-). Requiere tokens.css antes. Todo color, espacio y radio sale de los tokens. */

.rq { font-family: var(--font-body); color: var(--ink); background: var(--surface-page); -webkit-font-smoothing: antialiased; }
.rq *, .rq *::before, .rq *::after { box-sizing: border-box; }

/* Tipografía de marca */
.rq-display {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-style: var(--display-slant);
  font-variation-settings: "wdth" var(--display-width);
  letter-spacing: var(--display-tracking);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.rq-eyebrow { font-family: var(--font-mono); font-size: 10.5px; line-height: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.rq-mono { font-family: var(--font-mono); font-size: 12px; line-height: 16px; }
.rq-muted { color: var(--ink-muted); }
.rq-title { font-size: 22px; }

/* Botón */
.rq-btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: var(--tap-target); padding: 0 var(--space-5);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border-radius: var(--radius-sm);
  font: 600 15px/1 var(--font-body);
  background: var(--accent); color: var(--on-accent);
  transition: filter .15s, transform .1s;
}
.rq-btn:hover { filter: brightness(1.08); }
.rq-btn:active { transform: translateY(1px); }
.rq-btn:focus-visible, .rq-seg button:focus-visible, .rq-toggle:focus-visible, .rq-tab:focus-visible, .rq-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rq-btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.rq-btn--danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.rq-btn--text { background: transparent; color: var(--accent-text); padding: 0 var(--space-2); }
.rq-btn--block { width: 100%; }
.rq-btn[disabled], .rq-btn[aria-busy="true"] { opacity: .45; cursor: not-allowed; filter: none; transform: none; }

/* Selector segmentado */
.rq-seg { display: flex; gap: 3px; padding: 3px; background: var(--surface-raised); border-radius: var(--radius-sm); }
.rq-seg button {
  flex: 1 1 0; min-width: 0; min-height: 40px; padding: 0 var(--space-2);
  border: 0; border-radius: calc(var(--radius-sm) - 1px); cursor: pointer;
  background: transparent; color: var(--ink-muted);
  font: 600 13px/1.1 var(--font-body);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rq-seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface-page); }

/* Interruptor */
.rq-toggle {
  position: relative; flex: none; width: 48px; height: 28px; padding: 0; border: 0; cursor: pointer;
  border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.rq-toggle::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: var(--radius-full); background: var(--ink-muted); transition: transform .15s; }
.rq-toggle[aria-checked="true"] { background: var(--accent); box-shadow: none; }
.rq-toggle[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }

/* Tarjeta y fila */
.rq-card { display: grid; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.rq-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.rq-card__title { margin: 0; font-size: 17px; line-height: 22px; font-weight: 700; }
.rq-list { display: grid; }
.rq-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: var(--tap-target); padding: var(--space-2) 0; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.rq-row:last-child { border-bottom: 0; }
.rq-row__v { color: var(--ink-muted); font-size: 13px; text-align: right; }
.rq-row--danger { color: var(--danger); }
.rq-row[href]::after { content: "›"; color: var(--ink-muted); margin-left: var(--space-2); }

/* Preferencia al encender */
.rq-pref { display: grid; gap: var(--space-3); }
.rq-pref__note { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.rq-pref__note b { color: var(--ink); font-weight: 600; }

/* Dato */
.rq-readout { display: grid; gap: var(--space-2); align-content: start; padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); min-width: 0; }
.rq-readout__value { font-size: 40px; color: var(--ink); white-space: nowrap; }
.rq-readout--m .rq-readout__value { font-size: 24px; }
.rq-readout__unit { margin-left: var(--space-1); font: 500 13px/1 var(--font-body); font-variation-settings: normal; letter-spacing: 0; color: var(--ink-muted); }
.rq-readout--warn .rq-readout__value { color: var(--warn); }
.rq-readout--danger .rq-readout__value { color: var(--danger); }
.rq-readout--stale .rq-readout__value { color: var(--ink-muted); }

/* Cronómetro */
.rq-stopwatch { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-6) var(--space-4); text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.rq-stopwatch__time { font-size: 64px; }
.rq-stopwatch__time .rq-readout__unit { font-size: 16px; }
.rq-stopwatch__meta { font-size: 13px; color: var(--ink-muted); }
.rq-stopwatch__meta b { color: var(--accent-text); font-weight: 600; }

/* Chip de estado */
.rq-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; white-space: nowrap;
  border-radius: var(--radius-xs); background: var(--surface-raised); color: var(--ink-muted);
  font: 600 10.5px/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase;
}
.rq-chip--dot::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }
.rq-chip--ok { color: var(--ok); }
.rq-chip--warn { color: var(--warn); }
.rq-chip--danger { color: var(--danger); }
.rq-chip--info { color: var(--info); }
.rq-chip--accent { background: var(--accent); color: var(--on-accent); }
@media (prefers-reduced-motion: no-preference) {
  .rq-chip--live::before { animation: rq-pulse 1.6s ease-in-out infinite; }
}
@keyframes rq-pulse { 50% { opacity: .3; } }

/* Franja de estado global */
.rq-banner {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4); background: var(--surface-raised);
  border-top: 3px solid var(--line-strong);
}
.rq-banner__title { margin: 0; font-size: 15px; line-height: 20px; font-weight: 700; }
.rq-banner__text { grid-column: 1; margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.rq-banner__action { grid-column: 2; grid-row: 1 / span 2; }
.rq-banner--danger { border-top-color: var(--danger); }
.rq-banner--danger .rq-banner__title { color: var(--danger); }
.rq-banner--warn { border-top-color: var(--warn); }
.rq-banner--info { border-top-color: var(--info); }
.rq-banner__progress { grid-column: 1 / -1; height: 4px; border-radius: var(--radius-full); background: var(--surface); overflow: hidden; }
.rq-banner__progress span { display: block; height: 100%; background: var(--warn); }

/* Función bloqueada o próxima */
.rq-locked { display: grid; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.rq-locked__body { opacity: .4; pointer-events: none; display: grid; gap: var(--space-3); }
.rq-locked__note { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: 13px; color: var(--ink-muted); }

/* Barra de pestañas */
.rq-tabbar {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface-page); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.rq-tab {
  position: relative; min-height: 56px; padding: 0 2px; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-muted); text-decoration: none;
  font: 600 11px/1.1 var(--font-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rq-tab[aria-current="page"] { color: var(--ink); }
.rq-tab[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; background: var(--accent); }

/* Traza CAN */
.rq-trace { display: block; width: 100%; height: auto; overflow: visible; }
.rq-trace__grid { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2 4; }
.rq-trace__h { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: miter; }
.rq-trace__l { fill: none; stroke: var(--ink-muted); stroke-width: 2.5; stroke-linejoin: miter; }
