/* =====================================================================
   COMPONENTES
   ===================================================================== */

/* --- Superficies ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.card__body {
  padding: var(--sp-5);
}

.card__head {
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}

.card__foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
}

/* =====================================================================
   CHIPS: icono + texto + color. NUNCA color solo.
   El glifo de cada estado tiene FORMA distinta, no solo tono distinto,
   asi que el estado se lee tambien en escala de grises.
   ===================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 1px var(--sp-3) 1px var(--sp-2);
  border-radius: 999px;
  border: 1px solid var(--sem-idle-border);
  background: var(--sem-idle-bg);
  color: var(--sem-idle-text);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  max-width: 100%;
}

.chip .glyph {
  font-size: 10px;
  line-height: 1;
  width: 12px;
  text-align: center;
  flex: none;
}

.chip .chip__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip--ok {
  border-color: var(--sem-ok-border);
  background: var(--sem-ok-bg);
  color: var(--sem-ok-text);
}
.chip--warn {
  border-color: var(--sem-warn-border);
  background: var(--sem-warn-bg);
  color: var(--sem-warn-text);
}
.chip--error {
  border-color: var(--sem-error-border);
  background: var(--sem-error-bg);
  color: var(--sem-error-text);
}
.chip--run {
  border-color: var(--sem-run-border);
  background: var(--sem-run-bg);
  color: var(--sem-run-text);
}
/* RESERVADO: solo modo de escritura. */
.chip--write {
  border-color: var(--sem-write-border);
  background: var(--sem-write-bg);
  color: var(--sem-write-text);
  font-weight: 680;
}
.chip--idle {
  border-color: var(--sem-idle-border);
  background: var(--sem-idle-bg);
  color: var(--sem-idle-text);
}

.chip--mono .chip__label {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

.chip--lg {
  font-size: var(--fs-sm);
  padding: 2px var(--sp-4) 2px var(--sp-3);
}

.chip--lg .glyph {
  font-size: 11px;
}

/* =====================================================================
   BOTONES. El verbo comunica la consecuencia; el estilo la refuerza.
   ===================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  min-height: 30px;
  padding: 0 var(--sp-5);
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-text);
  border-color: var(--accent-text);
}

/* Boton que ESCRIBE. Lleva el color reservado, y solo el. */
.btn--write {
  background: var(--sem-write);
  border-color: var(--sem-write);
  color: #fff;
}

.btn--write:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn--danger {
  border-color: var(--sem-error-border);
  color: var(--sem-error-text);
  background: var(--sem-error-bg);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.btn--sm {
  min-height: 26px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-sm);
}

.btn--block {
  width: 100%;
}

@media (max-width: 780px) {
  /* Objetivos tactiles de 44 px en movil. */
  .btn {
    min-height: var(--touch);
    padding: 0 var(--sp-6);
  }
  .btn--sm {
    min-height: 36px;
  }
}

/* --- Control segmentado (filtro de nivel de log, rangos, etc.) -------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 2px;
  gap: 2px;
}

.segmented button {
  min-height: 26px;
  padding: 0 var(--sp-4);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 560;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.segmented button[aria-pressed="true"].is-error {
  color: var(--sem-error-text);
}

@media (max-width: 780px) {
  .segmented button {
    min-height: 38px;
  }
}

/* --- Campos ---------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field > label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 32px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
}

.input.mono,
.textarea.mono {
  font-family: var(--font-mono);
}

.textarea {
  min-height: 72px;
  resize: vertical;
}

.input::placeholder {
  color: var(--text-faint);
}

@media (max-width: 780px) {
  .input,
  .select {
    min-height: var(--touch);
    font-size: 16px; /* evita el zoom automatico de iOS al enfocar */
  }
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}

.check input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--sem-write);
}

/* =====================================================================
   BANDA DE SALUD DEL SISTEMA
   ===================================================================== */

.healthband {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sem-idle);
  border-radius: var(--radius);
  background: var(--surface);
}

.healthband--ok {
  border-left-color: var(--sem-ok);
}
.healthband--warn {
  border-left-color: var(--sem-warn);
  background: color-mix(in srgb, var(--sem-warn-bg) 45%, var(--surface));
}
.healthband--error {
  border-left-color: var(--sem-error);
  background: color-mix(in srgb, var(--sem-error-bg) 55%, var(--surface));
}

.healthband__glyph {
  font-size: 17px;
  line-height: 1;
  flex: none;
}

.healthband--ok .healthband__glyph {
  color: var(--sem-ok);
}
.healthband--warn .healthband__glyph {
  color: var(--sem-warn);
}
.healthband--error .healthband__glyph {
  color: var(--sem-error);
}

.healthband__title {
  font-weight: 640;
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
}

.healthband__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  margin-left: auto;
}

.metric {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.metric__value {
  font-size: var(--fs-lg);
  font-weight: 660;
  font-variant-numeric: tabular-nums;
}

.metric__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

@media (max-width: 780px) {
  .healthband__metrics {
    margin-left: 0;
    width: 100%;
    gap: var(--sp-6);
  }
}

/* =====================================================================
   REQUIERE TU ATENCION. La seccion mas importante del panel.
   ===================================================================== */

.attention {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.attention__head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}

.attention__head h2 {
  font-size: var(--fs-lg);
  font-weight: 660;
  letter-spacing: -0.01em;
}

.attention__count {
  font-variant-numeric: tabular-nums;
}

.attn-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-5);
  padding: var(--sp-5);
  border-top: 1px solid var(--border-subtle);
}

.attn-item:first-child {
  border-top: none;
}

.attn-item__glyph {
  flex: none;
  width: 20px;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
}

.attn-item--error .attn-item__glyph {
  color: var(--sem-error);
}
.attn-item--warn .attn-item__glyph {
  color: var(--sem-warn);
}
.attn-item--info .attn-item__glyph {
  color: var(--sem-run);
}

.attn-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.attn-item__title {
  font-weight: 620;
}

.attn-item__detail {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.attn-item__actions {
  flex: none;
  display: flex;
  gap: var(--sp-3);
  align-items: center;
}

@media (max-width: 780px) {
  .attn-item {
    flex-wrap: wrap;
  }
  .attn-item__actions {
    width: 100%;
    padding-left: calc(20px + var(--sp-5));
  }
}

.empty {
  padding: var(--sp-6) var(--sp-5);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.empty--ok {
  color: var(--sem-ok-text);
}

.empty__glyph {
  font-size: 15px;
}

/* =====================================================================
   TARJETA DE MICROPROYECTO. Cuatro ejes, SIN COLAPSAR.
   ===================================================================== */

.mp-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.mp-card--offscope {
  background: var(--surface-2);
  border-style: dashed;
  box-shadow: none;
}

.mp-card__head {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.mp-card__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
}

.mp-card__title h3 {
  font-size: var(--fs-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.mp-card__title a {
  color: inherit;
  text-decoration: none;
}

.mp-card__title a:hover {
  text-decoration: underline;
}

.mp-card__id {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.mp-card__summary {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Los cuatro ejes, cada uno en su fila etiquetada. */
.axes {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  align-items: center;
}

.axes__label {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 640;
}

.axes__value {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  min-width: 0;
}

.mp-card__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
}

.mp-card__foot .btn:first-child {
  margin-right: auto;
}

.mp-card__note {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--sem-warn-bg);
  color: var(--sem-warn-text);
  font-size: var(--fs-sm);
}

.mp-card__note--idle {
  background: var(--surface-3);
  color: var(--text-muted);
}

/* =====================================================================
   TABLAS -> LISTAS DE TARJETAS EN MOVIL. Nunca scroll horizontal del body.
   ===================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}

table.data th {
  text-align: left;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 640;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

table.data td {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data tbody tr:hover {
  background: var(--surface-2);
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 580;
}

.cell-link:hover {
  text-decoration: underline;
}

/* En movil cada fila se convierte en una tarjeta con etiquetas propias. */
@media (max-width: 780px) {
  .table-wrap {
    overflow-x: visible;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  table.data,
  table.data tbody,
  table.data tr,
  table.data td {
    display: block;
    width: 100%;
  }

  table.data thead {
    display: none;
  }

  table.data tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    box-shadow: var(--shadow-1);
  }

  table.data td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-5);
    padding: var(--sp-2) 0;
    border-bottom: none;
    text-align: right;
  }

  table.data td::before {
    content: attr(data-label);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    font-weight: 640;
    text-align: left;
    flex: none;
  }

  table.data td[data-label=""]::before {
    content: none;
  }
}

/* =====================================================================
   PESTANAS DE MICROPROYECTO
   ===================================================================== */

.tabs {
  display: flex;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a {
  padding: var(--sp-4) var(--sp-5);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--fs-md);
  font-weight: 580;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* =====================================================================
   LISTAS DESCRIPTIVAS Y PREPARACION LINEA A LINEA
   ===================================================================== */

.kv {
  display: grid;
  grid-template-columns: minmax(120px, 190px) 1fr;
  gap: var(--sp-3) var(--sp-5);
  font-size: var(--fs-md);
}

.kv dt {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .kv {
    grid-template-columns: 1fr;
    gap: var(--sp-1) 0;
  }
  .kv dd {
    margin-bottom: var(--sp-3);
  }
}

/* Preparacion: una linea por comprobacion, con su veredicto. */
.checklist {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.checkline {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface);
}

.checkline:first-child {
  border-top: none;
}

.checkline__glyph {
  flex: none;
  width: 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

.checkline--ok .checkline__glyph {
  color: var(--sem-ok);
}
.checkline--warn .checkline__glyph {
  color: var(--sem-warn);
}
.checkline--error .checkline__glyph {
  color: var(--sem-error);
}
.checkline--idle .checkline__glyph {
  color: var(--text-faint);
}

.checkline__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.checkline__what {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}

.checkline__why {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* =====================================================================
   CONSOLA DE LOGS
   ===================================================================== */

.logs {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.logs__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

.logs__search {
  flex: 1 1 180px;
  min-width: 140px;
}

.logs__body {
  position: relative;
  overflow: auto;
  max-height: 52vh;
  min-height: 180px;
  background: var(--surface-inset);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  scroll-behavior: auto;
}

@media (max-width: 780px) {
  .logs__body {
    max-height: 60vh;
  }
}

.logline {
  display: grid;
  grid-template-columns: 62px 46px 1fr;
  gap: var(--sp-4);
  padding: 1px var(--sp-5);
  border-left: 2px solid transparent;
  align-items: baseline;
}

.logline:hover {
  background: var(--surface-3);
}

.logline__at {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: var(--fs-xs);
}

.logline__level {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.logline__msg {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.logline--debug .logline__level {
  color: var(--text-faint);
}
.logline--info .logline__level {
  color: var(--sem-run-text);
}
.logline--warn {
  border-left-color: var(--sem-warn);
  background: color-mix(in srgb, var(--sem-warn-bg) 35%, transparent);
}
.logline--warn .logline__level {
  color: var(--sem-warn-text);
}
.logline--error {
  border-left-color: var(--sem-error);
  background: color-mix(in srgb, var(--sem-error-bg) 40%, transparent);
}
.logline--error .logline__level {
  color: var(--sem-error-text);
}

.logline__ctx {
  color: var(--text-faint);
  font-size: var(--fs-xs);
}

mark.hit {
  background: color-mix(in srgb, var(--sem-warn) 40%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.logs__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.logs__jump {
  margin-left: auto;
}

/* Barra de progreso indeterminada: el unico movimiento continuo. */
.progress {
  height: 2px;
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}

.progress__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: var(--sem-run);
  animation: nsh-indeterminate 1.6s var(--ease) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .progress__bar {
    animation: none;
    width: 100%;
    opacity: 0.35;
  }
}

/* =====================================================================
   CABECERA DE EJECUCION
   ===================================================================== */

.runhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.runhead__timer {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xl);
  font-weight: 640;
  letter-spacing: -0.02em;
}

.runhead__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  margin-left: auto;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

@media (max-width: 780px) {
  .runhead__meta {
    margin-left: 0;
    width: 100%;
  }
}

/* --- JSON crudo ------------------------------------------------------- */

pre.json {
  margin: 0;
  padding: var(--sp-5);
  background: var(--surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
  overflow-x: auto;
  max-height: 420px;
}

/* =====================================================================
   CONFIGURACION: tres clases visualmente distintas
   ===================================================================== */

.cfg-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.cfg-group__head {
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.cfg-group__head h3 {
  font-size: var(--fs-md);
  font-weight: 660;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Clase 1: editable desde la consola. Superficie normal, accion disponible. */
.cfg-group--editable .cfg-group__head {
  background: var(--surface-2);
}

/* Clase 2: secreto. Fondo distinto y sin valor jamas. */
.cfg-group--secret {
  border-color: var(--border-strong);
}
.cfg-group--secret .cfg-group__head {
  background: var(--surface-3);
}

/* Clase 3: pestillo. Color reservado de escritura: es la segunda llave. */
.cfg-group--latch {
  border-color: var(--sem-write-border);
}
.cfg-group--latch .cfg-group__head {
  background: var(--sem-write-bg);
  color: var(--sem-write-text);
}

.cfg-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr auto;
  gap: var(--sp-4) var(--sp-5);
  align-items: start;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
}

.cfg-row:first-of-type {
  border-top: none;
}

.cfg-row__key {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 620;
  overflow-wrap: anywhere;
}

.cfg-row__value {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.cfg-row__value code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: var(--surface-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

.cfg-row__actions {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 780px) {
  .cfg-row {
    grid-template-columns: 1fr;
  }
  .cfg-row__actions {
    justify-content: flex-start;
  }
}

/* =====================================================================
   CONECTORES
   ===================================================================== */

.conn-card__figures {
  display: flex;
  gap: var(--sp-7);
  padding: var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

/* =====================================================================
   QUOTE BUILDER: el campo del OTP
   =====================================================================
   Grande, monoespaciado y separado: es un codigo que se pega o se teclea
   mirando un email en el otro dedo, no una frase. `text-transform` es solo
   cosmetico -- el mayusculado real ocurre en JS (otp-form.js), porque el
   valor que se manda al servidor tiene que ser el que el usuario ve.
   ===================================================================== */

.otp-input {
  max-width: 220px;
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  text-transform: uppercase;
}

.otp-countdown {
  font-size: 1.05em;
}

.otp-countdown--critical {
  color: var(--sem-error-text);
}

/* =====================================================================
   DIALOGOS DE CONFIRMACION (friccion proporcional al riesgo)
   ===================================================================== */

dialog.modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow-2);
}

dialog.modal::backdrop {
  background: rgba(6, 8, 12, 0.55);
}

.modal__head {
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.modal__head h2 {
  font-size: var(--fs-lg);
  font-weight: 660;
}

.modal__body {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-height: 60vh;
  overflow-y: auto;
}

.modal__foot {
  padding: var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--sp-4);
  justify-content: flex-end;
  background: var(--surface-2);
}

@media (max-width: 560px) {
  .modal__foot {
    flex-direction: column-reverse;
  }
  .modal__foot .btn {
    width: 100%;
  }
}

/* El resumen de consecuencias dentro del dialogo, con numeros reales. */
.consequences {
  border: 1px solid var(--sem-write-border);
  border-radius: var(--radius);
  background: var(--sem-write-bg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.consequences__title {
  font-weight: 660;
  color: var(--sem-write-text);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.consequences li {
  display: flex;
  gap: var(--sp-4);
  font-size: var(--fs-sm);
  padding: var(--sp-1) 0;
}

.consequences li .num {
  font-weight: 680;
  min-width: 3ch;
  text-align: right;
}

/* =====================================================================
   AVISOS EN LINEA / ERRORES QUE EXPLICAN
   ===================================================================== */

.notice {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sem-idle);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-sm);
}

.notice__glyph {
  flex: none;
  font-size: 13px;
  line-height: 1.4;
}

.notice__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.notice__title {
  font-weight: 640;
  font-size: var(--fs-md);
}

.notice--warn {
  border-left-color: var(--sem-warn);
  background: color-mix(in srgb, var(--sem-warn-bg) 40%, var(--surface));
}
.notice--warn .notice__glyph {
  color: var(--sem-warn-text);
}

.notice--error {
  border-left-color: var(--sem-error);
  background: color-mix(in srgb, var(--sem-error-bg) 45%, var(--surface));
}
.notice--error .notice__glyph {
  color: var(--sem-error-text);
}

.notice--info {
  border-left-color: var(--sem-run);
}
.notice--info .notice__glyph {
  color: var(--sem-run-text);
}

.notice--write {
  border-left-color: var(--sem-write);
  background: color-mix(in srgb, var(--sem-write-bg) 45%, var(--surface));
}
.notice--write .notice__glyph {
  color: var(--sem-write-text);
}

.notice__fix {
  color: var(--text-muted);
}

/* =====================================================================
   ACCESO
   ===================================================================== */

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
}

.login__card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: var(--sp-7);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.login__brand {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.login__brand h1 {
  font-size: var(--fs-xl);
  font-weight: 660;
  letter-spacing: -0.02em;
}

/* --- Aviso de datos de ejemplo --------------------------------------- */

.demo-ribbon {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5);
  background: var(--sem-warn-bg);
  color: var(--sem-warn-text);
  border-bottom: 1px solid var(--sem-warn-border);
  font-size: var(--fs-xs);
  font-weight: 620;
}

/* --- Barra de estado del sondeo --------------------------------------- */

.pollstate {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sem-idle);
  flex: none;
}

.dot--run {
  background: var(--sem-run);
}
.dot--ok {
  background: var(--sem-ok);
}
.dot--error {
  background: var(--sem-error);
}

/* =====================================================================
   TIPOS DE PROJECT LOG (project-log-photos). Una lista de casillas con un
   selector de modo por fila. La fila marcada se distingue por fondo y peso,
   no solo por la casilla, para que la seleccion se lea de un vistazo.
   ===================================================================== */

.plt__head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.plt__head h2 {
  font-size: var(--fs-lg);
}

.plt__legend {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-1) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.plt__legend dt {
  font-weight: 640;
  color: var(--text);
}

.plt__notices {
  border-bottom: 1px solid var(--border-subtle);
}

.plt__removed {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
}

.plt__fieldset {
  border: 0;
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  min-width: 0;
}

.plt__list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.plt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.plt-row:hover {
  background: var(--surface-2);
}

.plt-row.is-on {
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border-subtle));
}

/* Con menos de ~9rem para el nombre, el selector de modo baja de linea. */
.plt-row__pick {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 1 1 9rem;
  min-width: 0;
  min-height: 36px;
  cursor: pointer;
  flex-wrap: wrap;
}

.plt-row__pick input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.plt-row__name {
  font-size: var(--fs-md);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.plt-row.is-on .plt-row__name {
  color: var(--text);
  font-weight: 620;
}

.plt-row__mode {
  flex: none;
  margin-left: auto;
}

.plt-row__mode button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.plt-row.is-on .plt-row__mode button[aria-pressed="true"] {
  color: var(--accent-text);
}

.plt__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.plt__status {
  font-size: var(--fs-sm);
  outline: none;
}

.plt-status--ok {
  color: var(--sem-ok-text);
  font-weight: 600;
}

.plt-status--pending {
  color: var(--sem-warn-text);
  font-weight: 600;
}

.plt-status--error {
  color: var(--sem-error-text);
}

@media (max-width: 780px) {
  .plt-row__pick {
    min-height: var(--touch);
  }
}

/* Solo para lectores de pantalla: el nombre del grupo de casillas. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
