/* ============================================================
   M&A Gestión de Pruebas — sistema de diseño
   Paleta oficial del manual de marca M&A Ingeniería y Consultoría SAS
   (motivo eólico/solar). Tema único claro, optimizado para lectura en
   exteriores bajo luz solar directa — sin modo oscuro. Tipografías:
   Zilla Slab (encabezados) + IBM Plex Sans (interfaz) + IBM Plex Mono
   (datos/lecturas).

   Nota de accesibilidad: el manual no incluye un rojo, así que --danger
   se derivó aparte (no es un color de marca). Además, #258fbf y #3aaa35
   dan bajo contraste usados como TEXTO pequeño (ver informe), así que
   --accent-text/--success-text/--warning-text son variantes oscurecidas
   del mismo matiz para esos casos puntuales; los botones y rellenos
   sólidos SÍ usan los hex exactos del manual con texto oscuro (#152618)
   encima, tal como se pide para el amarillo.
   ============================================================ */

:root {
  --bg: #dadada;
  --surface: #ffffff;
  --surface-alt: #f2f2f2;
  --border: #b2b2b2;

  --text: #152618;
  --text-muted: #5a6983;
  --text-faint: #949eae;

  --accent: #258fbf;
  --accent-hover: #2ea6df;
  --accent-soft: #e9f4f9;
  --accent-text: #185d7c;
  --on-accent: #152618;

  --brand: #5a6983;

  --success: #3aaa35;
  --success-bg: #ebf7eb;
  --success-border: #bae1b8;
  --success-text: #205e1d;
  --on-success: #152618;

  --warning: #f4c123;
  --warning-bg: #fdf6de;
  --warning-border: #fbe9b2;
  --warning-text: #6e5710;
  --on-warning: #152618;

  --danger: #8f2d2d;
  --danger-bg: #f4eaea;
  --danger-border: #d8b6b6;
  --on-danger: #ffffff;

  /* Cromo de navegación (sidebar + barra inferior): gris pizarra corporativo,
     para dar peso a la marca sin sacrificar el área de trabajo clara. */
  --nav-bg: #5a6983;
  --nav-text: rgba(255,255,255,0.7);
  --nav-text-hover: rgba(255,255,255,0.95);
  --nav-hover-bg: rgba(255,255,255,0.08);
  --nav-label: rgba(255,255,255,0.45);
  --nav-border: rgba(255,255,255,0.14);
  --nav-active-bg: #2ea6df;
  --nav-active-text: #152618;

  --shadow: 0 1px 2px rgba(21,38,24,0.07), 0 10px 26px -12px rgba(21,38,24,0.18);
  --radius: 12px;
  --tap-min: 48px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: "Zilla Slab", Georgia, serif; text-wrap: balance; margin: 0; }

.mono, .num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
/* Cromo de marca: gris pizarra corporativo sólido, para dar peso visual a la
   navegación; el área de trabajo (main) se mantiene clara para el sol. */
.sidebar {
  background: var(--nav-bg);
  color: #ffffff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
/* El <img> apunta a assets/logo-ma.png (logo oficial horizontal a color) —
   pendiente de que se suba el archivo; hasta entonces el navegador muestra
   el texto de `alt`. */
/* logo-ma.png es el emblema oficial completo (engranaje+turbina+sol, apilado sobre
   el wordmark "M&A / Ingeniería y Consultoría SAS") — un cuadrado, no un logo
   horizontal, así que solo se usa a tamaño grande (login) donde el texto se lee. */
.brand-logo { height: 96px; width: auto; display: block; }
.brand-logo-lg { height: 150px; }
/* Se muestra solo si assets/logo-ma.png falla en cargar (onerror en el <img>) —
   evita el icono de imagen rota mientras no se haya subido el archivo real. */
.brand-fallback { flex-direction: column; }
.brand-fallback .brand-word { font-family: "Zilla Slab", serif; font-weight: 700; font-size: 19px; color: var(--brand); line-height: 1.05; }
.brand-fallback .brand-sub { font-size: 9.5px; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; text-transform: uppercase; }
.sidebar .brand-fallback .brand-word { color: #ffffff; }
.sidebar .brand-fallback .brand-sub { color: var(--nav-label); }

/* Icono recortado (solo el emblema, sin texto) para la barra lateral compacta —
   el wordmark de al lado se compone con HTML/CSS, no con la imagen apilada. */
.brand-icon { height: 34px; width: 34px; display: block; flex: none; object-fit: contain; }

nav.mainnav { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--nav-label); font-weight: 600; padding: 0 10px; margin: 10px 0 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--nav-text); font-weight: 500; cursor: pointer; border: 1px solid transparent; font-size: 13.5px;
  position: relative; overflow: hidden;
}
.nav-item:hover { background: var(--nav-hover-bg); color: var(--nav-text-hover); }
/* Navegación activa: azul claro sólido (manual de marca), texto oscuro por contraste. */
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 600; }
.nav-item svg { flex: none; opacity: 0.85; }
.nav-item.disabled { cursor: not-allowed; color: rgba(255,255,255,0.35); pointer-events: none; }
.nav-item.disabled svg { opacity: 0.4; }

.tag.soon {
  background: rgba(255,255,255,0.1); color: var(--nav-label); border: 1px solid var(--nav-border);
  margin-left: auto; flex: none;
}

.sidebar-foot {
  margin-top: auto; border-top: 1px solid var(--nav-border); padding-top: 14px;
  display: flex; align-items: center; gap: 10px;
}

.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface); color: var(--nav-bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; flex: none; font-family: "Zilla Slab", serif;
}

.who-name { font-size: 12.5px; font-weight: 600; color: #ffffff; }
.who-role {
  font-size: 10px; color: var(--nav-active-text); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--nav-active-bg); padding: 1px 6px; border-radius: 4px; display: inline-block; margin-top: 2px;
}

/* ---------- Main ---------- */
main { min-width: 0; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 28px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 21px; font-weight: 600; }
.topbar p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }

.tenant-chip {
  font-size: 11.5px; color: var(--text-muted); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

.view { padding: 24px 28px 48px; max-width: 1180px; }
.view[hidden] { display: none; }

/* ---------- Cards / stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 11px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-family: "Zilla Slab", serif; font-size: 30px; font-weight: 700; margin-top: 4px; }
.stat-card .delta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-card .delta.up { color: var(--success-text); }
.stat-card .delta.warn { color: var(--warning-text); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 15.5px; font-weight: 600; }
.panel-head .hint { font-size: 12px; color: var(--text-faint); }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); font-weight: 600; padding: 9px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
td { padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--surface-alt); }

/* Pills: texto siempre oscuro (o el rojo de --danger, que sí es legible como texto);
   el matiz semántico vive en el punto (::before) y en el fondo/borde suaves —
   #258fbf y #3aaa35 puros no son legibles como texto pequeño (ver informe). */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
  color: var(--text);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.pill.success { background: var(--success-bg); border-color: var(--success-border); }
.pill.success::before { background: var(--success); }
.pill.warning { background: var(--warning-bg); border-color: var(--warning-border); }
.pill.warning::before { background: var(--warning); }
.pill.danger  { background: var(--danger-bg);  border-color: var(--danger-border); color: var(--danger); }
.pill.danger::before { background: var(--danger); }
.pill.neutral { color: var(--text-muted); background: var(--surface-alt); border-color: var(--border); }

.tag {
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent-text); text-transform: uppercase; letter-spacing: 0.03em;
}

.btn {
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  min-height: var(--tap-min); min-width: var(--tap-min);
  position: relative; overflow: hidden; transition: transform 0.08s ease-out, background 0.15s;
}
.btn:hover { background: var(--surface-alt); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Azul corporativo exacto del manual con texto oscuro encima (mejor contraste medido que blanco: 4.36:1 vs 3.65:1). */
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #ffffff; }
.btn.success:hover { background: var(--success-text); border-color: var(--success-text); }
.checkbox-row label { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.btn:focus-visible, .nav-item:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Microinteracciones: ripple táctil ---------- */
.ripple {
  position: absolute; border-radius: 50%; background: currentColor; opacity: 0.28;
  transform: scale(0); animation: ripple-expand 0.5s ease-out forwards; pointer-events: none;
}
@keyframes ripple-expand { to { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .ripple { display: none; }
  .btn:active { transform: none; }
}

.back-link {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer; margin-bottom: 12px;
}
.back-link:hover { color: var(--text); }

/* ---------- Transformer detail ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.detail-head h1 { font-size: 24px; }
.detail-head .meta { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.detail-head .actions { display: flex; gap: 8px; }
.badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.spec-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.spec-grid .cell { padding: 14px 18px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.spec-grid .cell:nth-child(4n) { border-right: none; }
.spec-grid .k { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.spec-grid .v { font-family: "IBM Plex Mono", monospace; font-size: 14px; margin-top: 3px; }
.spec-grid .v a { color: var(--accent-text); }

.special-banner {
  display: flex; gap: 10px; align-items: flex-start; background: var(--warning-bg); border: 1px solid var(--warning-border);
  color: var(--warning-text); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin: 16px 0;
}
.special-banner strong { color: inherit; }
.special-banner[hidden] { display: none; }

.test-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }

.field-row { display: flex; gap: 10px; padding: 8px 18px; border-bottom: 1px solid var(--border); align-items: center; }
.field-row:last-child { border-bottom: none; }
.field-row .tap-label { width: 108px; flex: none; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.result-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.result-row:last-child { border-bottom: none; }
.result-row .phase-name { font-weight: 600; color: var(--text-muted); width: 90px; }

/* Veredictos: relleno sólido + texto de alto contraste — más visible bajo luz solar
   directa que un tinte pálido. #152618 encima de amarillo/azul/verde por ser más
   legible que blanco en los tres casos (ver informe); el rojo usa blanco. */
.verdict-banner {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 18px;
  font-family: "Zilla Slab", serif; font-weight: 700; font-size: 16px;
  background: var(--surface-alt); color: var(--text-muted);
}
.verdict-banner.success { background: var(--success); color: var(--on-success); }
.verdict-banner.warning { background: var(--warning); color: var(--on-warning); }
.verdict-banner.danger { background: var(--danger); color: var(--on-danger); }
.verdict-banner span.tol { font-family: "IBM Plex Sans"; font-weight: 500; font-size: 11.5px; opacity: 0.8; }

.empty-note { padding: 30px 18px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

.yearly-chart-block + .yearly-chart-block { margin-top: 22px; }
.yearly-chart-title { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.yearly-chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.yearly-chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.yearly-chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.status-line { font-size: 12px; padding: 0 18px 14px; }
.status-line.error { color: var(--danger); }
.status-line.ok { color: var(--success-text); }
.status-line[hidden] { display: none; }

/* ---------- Fullscreen shells (login / suspended) ---------- */
.fullscreen-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(680px 420px at 15% 8%, var(--accent-soft), transparent 60%), var(--bg);
  padding: 24px;
}
.fullscreen-shell[hidden] { display: none; }

.auth-card {
  width: 100%; max-width: 408px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 30px 28px 24px;
}

.auth-form { display: flex; flex-direction: column; gap: 13px; margin-top: 20px; }

.field label {
  display: block; font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 5px;
}
.field input, .field select {
  width: 100%; font-family: "IBM Plex Sans", sans-serif; font-size: 16px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  min-height: var(--tap-min);
  /* font-size:16px evita el auto-zoom de iOS Safari al enfocar un campo en campo con guantes. */
}
.field input.mono, .field select.mono { font-family: "IBM Plex Mono", monospace; }
.field .field-note { font-size: 10.5px; color: var(--text-faint); margin-top: 4px; }

.auth-foot { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 18px; line-height: 1.6; }
.auth-foot .dev-links { display: inline-block; margin-top: 8px; font-size: 10.5px; }
.auth-foot a { color: var(--accent-text); cursor: pointer; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

.suspended-card { max-width: 420px; text-align: center; }
.suspended-icon {
  width: 52px; height: 52px; border-radius: 50%; background: var(--warning-bg); border: 1px solid var(--warning-border);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; color: var(--warning-text);
}
.suspended-card h1 { font-size: 21px; }
.suspended-card p { color: var(--text-muted); font-size: 13px; margin: 10px 0; }
.suspended-meta {
  display: flex; justify-content: space-between; font-size: 11.5px; background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; margin: 14px 0;
}
.suspended-meta .k { color: var(--text-faint); }
.suspended-hint { font-size: 12px; text-align: left; background: var(--surface-alt); border-radius: 8px; padding: 10px 12px; }
.suspended-card .btn { margin-top: 6px; }

/* ---------- Test-entry forms ---------- */
.context-strip {
  display: flex; gap: 22px; flex-wrap: wrap; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.context-strip > div { display: flex; flex-direction: column; gap: 2px; }
.context-strip .k { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.context-strip .v { font-size: 13px; font-weight: 600; }
.context-strip .role-toggle { margin-left: auto; flex-direction: row; align-items: center; gap: 8px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; background: var(--surface);
  color: var(--text-muted); border: none; cursor: pointer; border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--accent); color: var(--on-accent); }

.form-field-block { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; flex-wrap: wrap; }
.form-field-block .field { flex: 1; min-width: 140px; }

.tap-chip-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.tap-chip {
  font-family: "IBM Plex Mono", monospace; font-size: 13px; font-weight: 600; padding: 5px 14px;
  border-radius: 7px; border: 1px solid var(--border); background: var(--surface-alt); color: var(--text-muted); cursor: pointer;
  min-height: var(--tap-min); min-width: var(--tap-min);
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; transition: transform 0.08s ease-out;
}
.tap-chip:active { transform: scale(0.95); }
.tap-chip.current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tap-chip.filled:not(.current) { border-color: var(--success-border); color: var(--success-text); background: var(--success-bg); }

.phase-entry-grid { padding: 14px 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.phase-entry-grid-2col { padding: 14px 18px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.phase-entry-grid-3col { padding: 14px 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
/* Un item de grid no se encoge por debajo del ancho de su contenido
   (min-width:auto por defecto) — sin esto, .phase-entry-grid en 1 columna
   (breakpoint de abajo) no alcanza a angostarse: la tarjeta de fase entera
   sigue forzando el ancho de toda la fila/página al de su contenido más
   ancho (un input), aunque la grilla ya diga 1fr. Mismo problema un nivel
   arriba en .test-grid — sus dos columnas (paneles) tampoco se encogen sin
   esto. Encontrado midiendo scrollWidth en vivo, no a simple vista. */
.test-grid > * { min-width: 0; }
.phase-entry-grid > *, .phase-entry-grid-2col > *, .phase-entry-grid-3col > * { min-width: 0; }
.phase-entry { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.phase-entry .ph-name { font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.phase-entry .field + .field { margin-top: 8px; }
.phase-entry .field label { font-size: 9.5px; }
.phase-entry .field input { padding: 6px 8px; font-size: 16px; min-height: var(--tap-min); }

/* Punto 6 (2026-09-13): marcador "repetí esta lectura" — mismo criterio
   visual que .field-note (texto chico, discreto), no compite con los
   campos numéricos principales. */
.repeat-row { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.repeat-toggle { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); cursor: pointer; user-select: none; }
.repeat-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.repeat-note { width: 100%; margin-top: 6px; padding: 6px 8px; font-size: 13px; box-sizing: border-box; }

.rbac-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 12px 18px; padding: 10px 12px; border-radius: 8px;
  font-size: 12px; background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-text);
}
.rbac-note[hidden] { display: none; }

.matrix-table-wrap { overflow-x: auto; padding: 0 0 4px; }
table.matrix-table { width: 100%; border-collapse: collapse; min-width: 560px; }
table.matrix-table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint);
  font-weight: 600; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--border); background: var(--surface-alt);
}
table.matrix-table td { padding: 6px 10px 6px 18px; border-bottom: 1px solid var(--border); }
table.matrix-table input {
  width: 92px; font-family: "IBM Plex Mono", monospace; font-size: 16px; padding: 6px 7px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
  min-height: var(--tap-min);
}
table.matrix-table input:disabled { background: var(--surface-alt); color: var(--text-faint); }
.matrix-remove {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--danger); cursor: pointer; font-size: 13px; line-height: 1;
}
.matrix-remove:disabled { opacity: 0.35; cursor: not-allowed; }
.matrix-actions { display: flex; gap: 8px; padding: 12px 18px; flex-wrap: wrap; align-items: center; }

.preview-row {
  display: grid; grid-template-columns: 100px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 18px; border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.preview-row:last-of-type { border-bottom: none; }
.preview-row .phase-name { font-weight: 600; color: var(--text-muted); font-family: "IBM Plex Mono", monospace; font-size: 11.5px; }
.preview-row .num { color: var(--text-faint); }
.preview-row .err { font-family: "IBM Plex Mono", monospace; font-weight: 600; text-align: right; }
.preview-row .err.ok { color: var(--success-text); }
.preview-row .err.bad { color: var(--danger); }
.preview-row .err.pending { color: var(--text-faint); font-weight: 400; }
.preview-row .err.warn { color: var(--warning-text); }

/* TTR — teórico marcado como no disponible (falta tensión de placa) o no
   confiable (falta grupo de conexión, ver computeStandardTtrTheoretical_ en
   app.js / calculateTtr_ en Código.gs). */
.preview-row .theo-flag { display: inline-block; font-family: "IBM Plex Sans"; font-weight: 500; }
.preview-row .theo-unavailable { color: var(--text-faint); font-style: italic; }
.preview-row .theo-unreliable { color: var(--warning-text); }

.submit-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; flex-wrap: wrap; }

/* ---------- Navegación inferior (móvil, operación a una mano) ---------- */
/* Mismo cromo gris pizarra que el sidebar de escritorio, por identidad de marca. */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: var(--nav-bg); border-top: 1px solid var(--nav-border);
  align-items: center; justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px -8px rgba(21,38,24,0.3);
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1;
  background: none; border: none; color: var(--nav-text); font-family: inherit; font-size: 10px; font-weight: 600;
  min-height: var(--tap-min); padding: 4px 2px; border-radius: 10px; cursor: pointer;
  position: relative; overflow: hidden; transition: color 0.15s, background 0.15s;
}
.bottom-nav-item svg { opacity: 0.9; }
.bottom-nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-text); }
.bottom-nav-item:active { background: var(--nav-hover-bg); }
.bottom-nav-item.active:active { background: var(--nav-active-bg); }

.bottom-nav-fab {
  flex: none; width: 52px; height: 52px; margin-top: -22px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); border: 4px solid var(--nav-bg);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
  cursor: pointer; position: relative; overflow: hidden; transition: transform 0.08s ease-out;
}
.bottom-nav-fab:active { transform: scale(0.94); }

/* ---------- Hojas de acciones (bottom sheets) ---------- */
.sheet-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,14,20,0.45); z-index: 44;
}
.sheet-backdrop.open { display: block; }

.action-sheet {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 32px -8px rgba(21,38,24,0.3);
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s ease-out;
}
.action-sheet.open { display: block; transform: translateY(0); }
.action-sheet-handle { width: 36px; height: 4px; border-radius: 999px; background: var(--border); margin: 4px auto 12px; }
.action-sheet h3 { font-size: 16px; margin-bottom: 2px; }
.action-sheet-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; }
.action-sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: none; border: none; border-top: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 14.5px; font-weight: 500; padding: 13px 4px; cursor: pointer;
  min-height: var(--tap-min); position: relative; overflow: hidden;
}
.action-sheet-item:first-of-type { border-top: none; }
.action-sheet-item:active { background: var(--surface-alt); }
.action-sheet-item.disabled, .action-sheet-item:disabled { color: var(--text-faint); cursor: not-allowed; }
.action-sheet-item .tag.soon { margin-left: auto; }

/* ---------- Modal de contexto (Cliente/Proyecto o Equipo faltante) ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,14,20,0.45); z-index: 54;
}
.modal-backdrop.open { display: block; }

.modal {
  display: none; position: fixed; left: 50%; top: 50%; z-index: 55;
  transform: translate(-50%, -50%) scale(0.96); opacity: 0;
  width: calc(100% - 32px); max-width: 420px; max-height: calc(100vh - 64px); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform 0.15s ease-out, opacity 0.15s ease-out;
}
.modal.open { display: block; transform: translate(-50%, -50%) scale(1); opacity: 1; }
.modal.modal-wide { max-width: 640px; }
.modal-body table th, .modal-body table td { font-size: 12.5px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  flex: none; width: 32px; height: 32px; border-radius: 8px; border: none; background: none;
  color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--surface-alt); color: var(--text); }
.modal-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-body .field { margin: 0; }
.modal-divider {
  display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 4px 0;
}
.modal-divider::before, .modal-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.modal-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.modal-list-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; cursor: pointer; font-family: inherit; min-height: var(--tap-min);
  position: relative; overflow: hidden;
}
.modal-list-item:hover { border-color: var(--accent); }
.modal-list-item strong { font-size: 13.5px; color: var(--text); }
.modal-list-item span { font-size: 12px; color: var(--text-muted); }

/* ---------- Secciones activables por checkbox (formulario de Aceite) ---------- */
.oil-section-head { cursor: pointer; user-select: none; min-height: var(--tap-min); }
.oil-section-toggle-group { display: flex; align-items: center; gap: 10px; }
.oil-section-toggle-group input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; cursor: pointer; }
.oil-section-toggle-group h2 { font-size: 15.5px; font-weight: 600; }

/* ---------- Toast (aviso no bloqueante) ----------
   Patrón local-first: al crear/editar Sitios y Equipos la UI se actualiza de
   inmediato con datos locales; el toast solo informa el resultado del guardado
   real en segundo plano. Nunca requiere que el usuario lo cierre. */
.toast-stack {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column-reverse; gap: 8px; align-items: stretch;
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  pointer-events: auto; box-sizing: border-box; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 12px 16px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(10, 14, 20, 0.18);
  opacity: 0; transform: translateY(12px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.toast.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.toast.warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }

/* Pill clicable (reintentar sincronización de un registro pendiente/con error) */
.pill.pill-btn { cursor: pointer; font-family: inherit; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .stat-row, .test-grid, .spec-grid, .phase-entry-grid { grid-template-columns: 1fr 1fr; }
  .toast-stack { bottom: calc(64px + env(safe-area-inset-bottom) + 10px); }
}

/* Celular real (no solo tablet) — .test-grid en 2 columnas (regla de arriba)
   deja "Lecturas de campo" y "Vista previa" apretados uno junto al otro, y
   .phase-entry-grid en 2 columnas deja cada tarjeta de fase sin espacio para
   sus 3 inputs. A este ancho los dos colapsan a 1 sola columna, apilados.
   .phase-entry-grid-2col/-3col son las mismas grillas de Aceite
   (Fisicoquímico/DGA/PCB) — antes fijas por estilo inline, sin responder a
   ningún breakpoint; ver index.html. */
@media (max-width: 600px) {
  .test-grid, .phase-entry-grid, .phase-entry-grid-2col, .phase-entry-grid-3col { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .action-sheet, .bottom-nav-fab, .btn, .tap-chip, .modal, .toast { transition: none; }
}
