:root {
  --bg: #171a21;
  --bg-1: #212630;
  --bg-2: #2b313c;
  --bg-3: #373e4a;
  /* Color que toma el arco inferior del logo para fundirse con su contenedor.
     DEBE ir siempre igual a --bg-1 (sidebar, login y overlay usan ese fondo);
     si se desincroniza, el borde del logo deja de verse recortado. */
  --logo-bg: #212630;
  --border: rgba(255,255,255,0.10);
  --border-soft: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.20);
  --teal: #3f7cc2;
  --teal-dim: rgba(28,90,166,0.15);
  --blue: #1c5aa6;
  --blue-deep: #16385f;
  --amber: #f5a623;
  --red: #e5566d;
  --text: #f3f4f6;
  --text-dim: #bcc2ca;
  --text-faint: #8d949e;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 12px 28px rgba(0,0,0,0.4);
  /* Superficies de las tablas de registro, que antes iban con color fijo. */
  --reg-bg: #2c323d;
  --reg-head: #373e4a;
  --reg-head-text: #e4e9ef;
  --reg-col1: #333a45;
  --reg-col1-hover: #3d4551;
  --reg-total: #404856;
  --campo-bg: #1d222a;
  --campo-borde: rgba(255,255,255,0.26);
  --opcion-bg: #262b34;
  --opcion-text: #f3f4f6;
  --hover-fila: rgba(255,255,255,0.03);
  --hover-suave: rgba(255,255,255,0.06);
  --hover-fuerte: rgba(255,255,255,0.10);
  --pastilla: rgba(255,255,255,0.06);
  --esquema: dark;
  --font-head: 'Sora', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ---------------- Tema claro ----------------
   Para trabajar a pleno sol en obra: mismas medidas y misma estructura, solo
   cambian las superficies y el contraste. Los colores de estado (verde, azul,
   ambar) se mantienen porque significan lo mismo en los dos temas. */
html[data-tema="claro"] {
  --bg: #eef1f5;
  --bg-1: #ffffff;
  --bg-2: #f4f6f9;
  --bg-3: #e5e9ef;
  --logo-bg: #ffffff;
  --border: rgba(20,30,45,0.14);
  --border-soft: rgba(20,30,45,0.08);
  --border-strong: rgba(20,30,45,0.28);
  --teal: #1c5aa6;
  --teal-dim: rgba(28,90,166,0.12);
  --amber: #b9791a;
  --red: #c0392f;
  --text: #17202c;
  --text-dim: #45505f;
  --text-faint: #6b7686;
  --shadow: 0 10px 24px rgba(20,30,45,0.14);
  --reg-bg: #ffffff;
  --reg-head: #dfe5ec;
  --reg-head-text: #22303f;
  --reg-col1: #f2f5f9;
  --reg-col1-hover: #e6ebf2;
  --reg-total: #dfe5ec;
  --campo-bg: #ffffff;
  --campo-borde: rgba(20,30,45,0.30);
  --opcion-bg: #ffffff;
  --opcion-text: #17202c;
  --hover-fila: rgba(20,30,45,0.04);
  --hover-suave: rgba(20,30,45,0.06);
  --hover-fuerte: rgba(20,30,45,0.09);
  --pastilla: rgba(20,30,45,0.07);
  --esquema: light;
}
html[data-tema="claro"] body { background: var(--bg); color: var(--text); }

* { box-sizing: border-box; }

/* Evita que Chrome/Safari móvil agrande el texto automáticamente dentro de
   columnas angostas (tablas de checklist) — sin esto, las filas se ven
   mucho más grandes en el celular real de lo que muestra el CSS. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

/* ---------------- Login ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  display: flex;
  width: 100%;
  max-width: 920px;
  min-height: 520px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.login-side {
  flex: 1;
  background: #171a21;
  --logo-bg: #171a21;
  color-scheme: dark;
  border-right: 1px solid var(--border);
  color: white;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-logo {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.login-logo svg { width: 100%; height: 100%; }

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login-brand h1 { font-family: var(--font-head); font-size: 28px; margin: 0; letter-spacing: 0.5px; font-weight: 800; }
.badge-beta { font-size: 11px; font-weight: 700; background: var(--teal-dim); color: var(--teal); padding: 3px 9px; border-radius: 999px; }
.login-side .badge-beta { background: rgba(91,155,213,0.18); color: #9ec5ef; }
.login-side, .login-card { border-color: rgba(255,255,255,0.12); }

.login-tagline { color: #bcc2ca; line-height: 1.5; margin-bottom: 24px; max-width: 320px; }

.login-notice {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.28);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: #f3cd8f;
  margin-bottom: 22px;
  max-width: 340px;
}

.login-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.login-features li { display: flex; gap: 8px; align-items: center; font-size: 14px; color: #f3f4f6; }
.login-features li::before { content: "✓"; color: #5b9bd5; font-weight: 700; }

.login-footer { margin-top: 32px; font-size: 11px; letter-spacing: 1.5px; color: #8d949e; text-transform: uppercase; }

.login-form-side { flex: 1; background: var(--bg-1); padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; }
.login-form-side h2 { margin: 0 0 4px; font-size: 26px; font-family: var(--font-head); }
.login-form-side p.sub { color: var(--text-dim); margin: 0 0 28px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-dim); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.field-pass-wrap { position: relative; }
.field-pass-wrap .toggle-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--text-dim); background: none; border: none; font-size: 15px;
}

.btn {
  border: none;
  border-radius: 9px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #2568bd; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-teal { background: var(--teal); color: white; }
.btn-teal:hover { background: #4d8ad1; }
.btn-secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-danger { background: rgba(229,86,109,0.14); color: var(--red); }
.btn-danger:hover { background: rgba(229,86,109,0.24); }
.btn-redsolid { background: #d43a3a; color: white; }
.btn-redsolid:hover { background: #e04848; }
.btn-ghost { background: transparent; color: var(--teal); }
.btn-small { padding: 7px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.login-links { text-align: right; margin-top: -8px; margin-bottom: 20px; }
.login-links a { font-size: 13px; color: var(--teal); text-decoration: none; }

.form-error {
  background: rgba(229,86,109,0.12);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.form-error.visible { display: block; }
.form-error.ok { background: var(--teal-dim); color: var(--teal); }

@media (max-width: 720px) { .login-card { flex-direction: column; } }

/* ---------------- App shell ---------------- */

.app-shell {
  display: flex;
  max-width: 1700px;
  margin: 20px auto;
  min-height: calc(100vh - 40px);
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.sidebar {
  width: 92px;
  background: var(--bg-1);
  border-right: 1px solid var(--border-soft);
  border-radius: 24px 0 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  padding: 18px 0;
}

.sidebar-brand { margin-bottom: 18px; }
.side-logo {
  width: 46px; height: 46px; cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
  display: flex; align-items: center; justify-content: center;
}
.side-logo:hover { transform: scale(1.08); opacity: 0.85; }
.side-logo svg { width: 100%; height: 100%; display: block; }
/* El logo hereda el color del texto: blanco en oscuro, azul en claro. */
.side-logo { color: var(--text); }
html[data-tema="claro"] .side-logo { color: var(--blue); }
.login-logo, .progress-logo { color: #ffffff; }

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: center; flex: 1; overflow-y: auto; position: relative; }
#sidebar-nav .nav-more-trigger { display: none; }
.nav-more-panel { display: contents; }

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 74px;
  padding: 10px 4px;
  border-radius: 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: var(--font-body);
}
.nav-link .nav-icon { font-size: 18px; line-height: 1; }
.nav-link .nav-icon svg { width: 20px; height: 20px; }
.nav-link:hover { background: var(--hover-suave); color: var(--text); }
.nav-link.active { background: var(--teal); color: white; font-weight: 700; }

.sidebar-user { margin-top: auto; padding-top: 14px; }
.sidebar-user .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--blue);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
  cursor: pointer;
  border: none;
}

.main { flex: 1; min-width: 0; padding: 22px 30px 60px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 14px;
}
.topbar-left { position: relative; padding-left: 17px; }
.topbar-left::before {
  content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px;
  border-radius: 4px; background: var(--blue);
}
.topbar-eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: var(--teal); text-transform: uppercase; }
.topbar h1 {
  margin: 4px 0 0; font-size: 28px; font-family: var(--font-head); font-weight: 800; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 12px;
  color: var(--text);
}
.topbar h1 .badge-beta { font-size: 11px; padding: 4px 11px; -webkit-text-fill-color: var(--teal); }
.topbar .sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.topbar-right { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.topbar-clock { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-family: var(--font-mono); font-size: 13px; }
.topbar-clock strong { color: var(--text); font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.topbar-user strong { color: var(--text); }
/* Nombre de la persona antes del correo; se oculta si el usuario no tiene
   nombre cargado en usuario_roles. */
.user-nombre { margin-left: 3px; }
.user-nombre.hidden { display: none; }
.user-mail {
  color: inherit; text-decoration: none; border-radius: 6px; padding: 2px 5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.user-mail:hover { background: var(--teal-dim); }
.user-mail:hover strong { color: var(--teal); text-decoration: underline; }

.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; }
.pill-teal { background: var(--teal-dim); color: var(--teal); }
/* Rol con alcance limitado: se distingue del acceso total de un vistazo. */
.pill.role-limitado { background: rgba(245,166,35,0.16); color: #f5be6a; }
.pill-gray { background: var(--pastilla); color: var(--text-dim); }
.pill-amber { background: rgba(245,166,35,0.15); color: var(--amber); }
.pill-red { background: rgba(229,86,109,0.15); color: var(--red); }

.card {
  background: var(--bg-1);
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.card-header h2 { font-size: 15px; margin: 0; font-family: var(--font-head); display: flex; align-items: center; gap: 8px; }
.card-header .hint { font-size: 12px; color: var(--text-faint); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-family: var(--font-mono);
}
table.data-table th.sortable-th { cursor: pointer; user-select: none; transition: color 0.12s ease; }
table.data-table th.sortable-th:hover { color: var(--text); }
table.data-table th.sortable-th .sort-arrow { display: inline-block; margin-left: 4px; font-size: 9px; opacity: 0.35; }
table.data-table th.sortable-th.sort-active .sort-arrow { opacity: 1; color: var(--teal); }
table.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}
table.data-table tr:hover td { background: var(--hover-fila); }
.actions-cell { display: flex; gap: 6px; white-space: nowrap; }

.empty-state { text-align: center; color: var(--text-faint); padding: 30px 10px; font-size: 14px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,10,18,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 18px; padding: 30px 34px; width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 20px; font-family: var(--font-head); font-size: 22px; font-weight: 800; }
.modal .field { margin-bottom: 20px; }
.modal .field label { font-size: 13.5px; margin-bottom: 7px; }
.modal .field input, .modal .field select, .modal .field textarea { padding: 13px 15px; border-radius: 10px; font-size: 14.5px; }
.modal-backdrop { animation: fadeIn 0.15s ease; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat-card .stat-label { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); margin-bottom: 6px; }
.stat-card .stat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stat-card .stat-value { font-size: 24px; font-weight: 800; font-family: var(--font-head); }
.kpi-click { cursor: pointer; }
.kpi-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; font-family: var(--font-mono); }
.est-row { display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-radius: var(--radius-sm); transition: background 0.15s ease, transform 0.18s ease; }
.est-row:hover { background: var(--hover-fila); transform: translateX(3px); }
.est-row + .est-row { border-top: 1px solid var(--border-soft); }
.est-icon { flex-shrink: 0; display: flex; align-items: center; }
.est-body { flex: 1; min-width: 0; }
.est-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.est-head strong { font-size: 13.5px; }
.est-pct { font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
.est-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; font-family: var(--font-mono); }

.checklist-group { margin-bottom: 18px; }
.checklist-group h3 { font-size: 14px; margin: 0; color: var(--text); font-family: var(--font-head); }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
.checklist-item input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--teal); }
.checklist-item.done span { text-decoration: line-through; color: var(--text-faint); }
.progress-bar { height: 7px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress-bar-fill { height: 100%; background: var(--teal); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search], .toolbar input[type=date], .toolbar select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  background: var(--bg-2); color: var(--text); font-family: var(--font-body);
}
.toolbar input[type=search] { flex: 1; min-width: 180px; }
.toolbar-label { font-size: 12px; color: var(--text-faint); }

.group-search { display: flex; gap: 10px; margin-bottom: 18px; }
.group-search input { flex: 1; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-1); color: var(--text); font-size: 14px; }
.group-actions { display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 14px; }

.rubric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.rubric-card {
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color 0.15s, transform 0.1s;
  display: flex; flex-direction: column; gap: 12px;
}
.rubric-card:hover { border-color: var(--teal); transform: translateY(-2px); }
.rubric-card-top { display: flex; align-items: center; justify-content: space-between; }
.rubric-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--bg-3);
}
.rubric-card h3 { margin: 0; font-size: 15px; font-family: var(--font-head); }
.rubric-card .rubric-sub { font-size: 12.5px; color: var(--text-faint); font-family: var(--font-mono); }
.rubric-arrow { color: var(--text-faint); }

.detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.detail-header h2 {
  margin: 0; font-size: 17px; font-family: var(--font-head); font-weight: 700;
  border-bottom: 2px solid var(--teal); padding: 6px 10px 12px;
}
.pill-outline { background: transparent; border: 1px solid var(--teal); color: var(--teal); font-family: var(--font-mono); font-weight: 500; padding: 5px 13px; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--teal); font-family: var(--font-mono); margin-left: auto; }
.live-dot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 0 rgba(63,124,194,0.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63,124,194,0.5); } 70% { box-shadow: 0 0 0 6px rgba(63,124,194,0); } 100% { box-shadow: 0 0 0 0 rgba(63,124,194,0); } }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.35); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); z-index: 100;
  opacity: 0; transform: translateY(10px); transition: all 0.25s ease; max-width: 340px;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--red); color: #ffd7dd; }

/* ---------------- Cambio de contraseña ---------------- */

.clave-box { max-width: 420px; }
.clave-campo { display: block; font-size: 0.76rem; color: var(--text-dim); margin-bottom: 12px; }
.clave-campo input {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-body); font-size: 14px;
}
.clave-campo input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim); }
.clave-ver { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.clave-ver input { width: 15px; height: 15px; accent-color: var(--teal); }
.clave-nota { font-size: 12px; color: var(--text-faint); line-height: 1.45; margin: 12px 0 0; }
.clave-msg { font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.clave-msg.mal { color: var(--red); }
.clave-msg.bien { color: #4fb88a; }
.clave-correo {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-2); padding: 12px 14px; margin: 14px 0 4px;
}
.clave-correo-tit {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); margin-bottom: 4px;
}
.clave-correo strong { font-size: 14px; word-break: break-all; }

/* ---------------- Ayuda ---------------- */

.ayuda-box { max-width: 560px; }
.ayuda-intro { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; margin: 2px 0 16px; }
.ayuda-seccion { margin-bottom: 16px; }
.ayuda-seccion h4 {
  display: flex; align-items: center; gap: 7px; margin: 0 0 8px;
  font-family: var(--font-head); font-size: 13px; color: var(--text);
}
.ayuda-seccion ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.ayuda-seccion li { font-size: 13px; color: var(--text-dim); line-height: 1.45; }

.ayuda-soporte {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-2); padding: 14px 16px; margin-bottom: 16px;
}
.ayuda-soporte-tit {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); margin-bottom: 6px;
}
.ayuda-persona { font-family: var(--font-head); font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.ayuda-dato {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  font-size: 13.5px; color: var(--teal); text-decoration: none;
  border-top: 1px solid var(--border-soft);
}
.ayuda-dato:hover { text-decoration: underline; }

.install-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200;
  max-width: 420px; margin: 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 13px;
  transform: translateY(140%); transition: transform 0.35s cubic-bezier(.2,.8,.2,1);
}
.install-banner.visible { transform: translateY(0); }
.install-banner .ib-icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--blue-deep);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.install-banner .ib-icon svg { width: 26px; height: 26px; }
.install-banner .ib-body { flex: 1; min-width: 0; }
.install-banner .ib-title { font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--text); }
.install-banner .ib-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.install-banner .ib-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.install-banner .ib-btn {
  border: none; border-radius: 8px; padding: 8px 14px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: var(--font-body); white-space: nowrap;
}
.install-banner .ib-install { background: var(--teal); color: white; }
.install-banner .ib-dismiss { background: transparent; color: var(--text-faint); }
.install-banner .ib-dismiss:hover { color: var(--text); }
@media (max-width: 520px) {
  .install-banner { flex-wrap: wrap; padding: 14px; }
  .install-banner .ib-body { order: 1; }
  .install-banner .ib-icon { order: 0; }
  .install-banner .ib-actions { order: 2; flex-direction: row; width: 100%; margin-top: 4px; }
  .install-banner .ib-btn { flex: 1; justify-content: center; }
}

.activity-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
/* min-width:0 en los hijos: sin esto un flex-item no baja de su ancho de
   contenido y el detalle largo del log empujaba la fila fuera de la tarjeta. */
.activity-row > div { min-width: 0; }
.activity-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-extra { display: none; }
#recent-activity.audit-abierto .audit-extra { display: flex; }
.audit-toggle {
  width: 100%; margin-top: 8px; padding: 7px 10px; background: none; cursor: pointer;
  border: 1px dashed var(--border); border-radius: 8px; color: var(--text-dim);
  font-family: inherit; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.audit-toggle:hover { color: var(--teal); border-color: var(--teal); background: var(--teal-dim); }
#recent-activity.audit-abierto .audit-toggle svg { transform: rotate(180deg); }
.audit-toggle svg { transition: transform 0.18s ease; }

.activity-detalle {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--bg-3); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.activity-meta { color: var(--text-faint); font-size: 11.5px; }

.report-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 4px; border-bottom: 1px solid var(--border-soft); }
.report-row:last-child { border-bottom: none; }
.report-row strong { font-family: var(--font-head); font-size: 14px; }


.powered { text-align:center; color:var(--text-faint); font-size:12px; padding:18px 0; }
.powered strong { color: var(--text-dim); }

.progress-overlay {
  position: fixed; inset: 0; background: rgba(4,10,18,0.72);
  display: flex; align-items: center; justify-content: center; z-index: 120;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.progress-box {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 32px; width: min(430px, 90vw); text-align: center;
  box-shadow: var(--shadow);
}
.progress-box .progress-logo {
  width: 52px; height: 52px; margin: 0 auto 14px;
}
.progress-box .progress-logo svg { width: 100%; height: 100%; }
.progress-box h3 { margin: 0 0 4px; font-family: var(--font-head); font-size: 16px; }
.progress-track { height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin: 18px 0 10px; }
.progress-fill { height: 100%; width: 0%; background: var(--blue); transition: width 0.3s ease; border-radius: 999px; }
.progress-msg { font-size: 12.5px; color: var(--text-dim); font-family: var(--font-mono); min-height: 17px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

.chk-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.struct-cards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; }
.struct-card { min-width: 132px; flex-shrink: 0; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; }
.struct-card .sc-name { font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; margin-bottom: 8px; white-space: nowrap; display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.struct-card .sc-pct { font-family: var(--font-mono); font-size: 12px; color: var(--teal); margin-top: 6px; font-weight: 700; }
.struct-card .sc-abscisa { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.struct-card .sc-edit-abs { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 2px; display: inline-flex; border-radius: 4px; }
.struct-card .sc-edit-abs:hover { color: var(--teal); background: var(--teal-dim); }
/* Tarjeta clicable que abre la ficha de la estructura (igual que en Montaje). */
button.struct-card { font: inherit; text-align: left; cursor: pointer; color: var(--text); }
button.struct-card:hover .sc-name { color: var(--teal); }
.struct-card .sc-abs { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin: -4px 0 7px; }
/* Nombre de la estructura en el encabezado de la matriz: abre la misma ficha. */
.chk-th-name {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  color: inherit; letter-spacing: inherit; text-transform: inherit; white-space: nowrap;
}
.chk-th-name:hover { color: var(--teal); text-decoration: underline; }
.chk-cell { position: relative; }
.chk-medida { font-size: 10px; color: var(--text-faint); font-family: var(--font-mono); margin-top: 4px; }
.chk-table td:first-child { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ta-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0.45; transition: opacity 0.15s ease; }
.chk-table tr:hover .ta-actions { opacity: 1; }
.ta-edit, .ta-del { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 3px; display: inline-flex; border-radius: 4px; }
.ta-edit:hover { color: var(--teal); background: var(--teal-dim); }
.ta-del:hover { color: var(--red); background: rgba(224,90,90,0.12); }
.chk-matrix-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--border-soft); border-radius: 10px; }
.chk-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 100%; }
.chk-table th, .chk-table td { border-bottom: 1px solid var(--border-soft); padding: 11px 13px; }
.chk-table thead th {
  position: sticky; top: 0; background: var(--bg-2); z-index: 2;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.5px;
  color: var(--text-dim); text-transform: uppercase; text-align: center; white-space: nowrap;
}
.chk-table thead th:first-child { text-align: left; left: 0; z-index: 3; }
.chk-table tbody td:first-child {
  position: sticky; left: 0; background: var(--bg-1); z-index: 1;
  font-family: var(--font-mono); font-size: 13px; white-space: nowrap;
}
.chk-table tbody tr:hover td { background: var(--hover-fila); }
.chk-table tbody tr:hover td:first-child { background: var(--bg-2); }
.chk-cell { text-align: center; }
.chk-box {
  width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--bg-2); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.12s, background 0.15s, border-color 0.15s; color: transparent;
}
.chk-box.checked { background: #2fbf71; border-color: #2fbf71; color: #04220f; }
.chk-box:hover:not(.disabled) { transform: scale(1.1); border-color: var(--teal); }
.chk-box.missing { border-style: dashed; opacity: 0.55; }
.chk-box.disabled { cursor: default; }
/* En claro, una casilla vacía sobre fondo blanco casi no se ve: se le sube el
   contraste del borde y del relleno para que se distinga de una hecha. */
html[data-tema="claro"] .chk-box:not(.checked) { border-color: var(--border-strong); background: var(--bg-3); }

/* Textos de estado: los tonos claros se leen sobre fondo oscuro, pero sobre
   una pastilla clara desaparecen. En el tema claro se usan los mismos colores
   en version oscura, manteniendo el significado. */
html[data-tema="claro"] .mh-estado.ok { color: #12653b; border-color: rgba(18,101,59,0.35); }
html[data-tema="claro"] .mh-estado.med { color: #1a4e8a; border-color: rgba(26,78,138,0.35); }
html[data-tema="claro"] .mh-estado.pend { color: var(--text-dim); }
html[data-tema="claro"] .mh-sop.ok .mh-sop-tag { color: #12653b; border-color: rgba(18,101,59,0.4); }
html[data-tema="claro"] .qty-input.partial { color: #12653b; border-color: rgba(18,101,59,0.55); }
html[data-tema="claro"] .mt-falta { color: #9a6112; }
html[data-tema="claro"] .tramo-select.t10, html[data-tema="claro"] .tramo-select.t1 { color: #17466f; }
html[data-tema="claro"] .tramo-select.t8 { color: #7d5510; }
html[data-tema="claro"] .tramo-select.t9 { color: #83364f; }
html[data-tema="claro"] .tramo-select.t7 { color: #10603f; }
html[data-tema="claro"] .tramo-select.tph { color: #443371; }
html[data-tema="claro"] .qty-fecha.vacia { opacity: 0.4; }
html[data-tema="claro"] .qty-input.missing { opacity: 0.6; }
.chk-note { font-size: 12px; color: var(--text-faint); margin-top: 10px; }

/* ---------------- CVA Mecánico ---------------- */

.cva-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.cva-tab {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 11px 20px; border-radius: 9px; font-size: 16px; font-weight: 700; letter-spacing: 0.3px;
  cursor: pointer; font-family: var(--font-body); display: inline-flex; align-items: center; gap: 8px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cva-tab:hover { color: var(--text); border-color: var(--border-strong); }
.cva-tab.active { background: var(--teal); border-color: var(--teal); color: white; }
.cva-tab-badge {
  font-family: var(--font-mono); font-size: 12px; padding: 3px 8px; border-radius: 999px;
  background: var(--pastilla); color: inherit;
}
.cva-tab.active .cva-tab-badge { background: rgba(0,0,0,0.22); }

.cva-planos { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-2); margin-bottom: 14px; overflow: hidden; }
.cva-planos-head {
  width: 100%; background: none; border: none; color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; font-family: var(--font-body); font-size: 13px; font-weight: 600;
}
.cva-planos-head > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.cva-planos-head:hover { background: var(--bg-3); }
.cva-planos-chev { color: var(--text-faint); transition: transform 0.18s ease; }
.cva-planos-head[aria-expanded="false"] .cva-planos-chev { transform: rotate(-90deg); }
/* Un solo plano (el corte): se centra y se limita el ancho para que no se
   estire de lado a lado en pantallas anchas. */
.cva-planos-body { display: grid; grid-template-columns: 1fr; justify-items: center; gap: 12px; padding: 4px 14px 14px; }
/* El atributo hidden lo anulaba la regla de arriba, así que el botón de plegar
   no hacía nada visible. Con esto vuelve a ocultarse. */
.cva-planos-body[hidden] { display: none; }
.cva-planos-body .cva-plano { max-width: 720px; width: 100%; }
.cva-plano { margin: 0; }
.cva-plano img {
  width: 100%; aspect-ratio: 900 / 620; object-fit: contain; display: block; background: #ffffff;
  border: 1px solid var(--border); border-radius: 8px; cursor: zoom-in;
  transition: border-color 0.15s ease;
}
.cva-plano img:hover { border-color: var(--teal); }
.cva-plano figcaption { font-size: 11px; color: var(--text-faint); margin-top: 6px; text-align: center; line-height: 1.35; }

/* Área de registro: fondo más claro que el resto para que resalten los
   cuadros donde se escriben las cantidades. */
.cva-wrap { background: var(--reg-bg); border-color: var(--border-strong); }
.cva-wrap .chk-table thead th { background: var(--reg-head); color: var(--reg-head-text); }
.cva-wrap .chk-table tbody td:first-child { background: var(--reg-col1); }
.cva-wrap .chk-table tbody tr:hover td { background: var(--hover-suave); }
.cva-wrap .chk-table tbody tr:hover td:first-child { background: var(--reg-col1-hover); }
.cva-wrap .chk-table th, .cva-wrap .chk-table td { border-bottom-color: var(--border); }

/* Celdas de cantidad (accesorios de válvula de aire) */
.qty-input {
  width: 48px; padding: 6px 4px; text-align: center; border-radius: 7px;
  border: 1.5px solid var(--campo-borde); background: var(--campo-bg); color: var(--text);
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input::placeholder { color: #6b7280; font-weight: 400; }
.qty-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim); }
.qty-input.partial { background: rgba(47,191,113,0.2); border-color: rgba(47,191,113,0.6); color: #93f2c1; }
.qty-input.full { background: #2fbf71; border-color: #2fbf71; color: #04220f; }
.qty-input.missing { opacity: 0.4; border-style: dashed; }
.qty-input:disabled { cursor: default; }

/* "/n" = total que exige el cuadro de accesorios para esa cámara. */
.qty-wrap { display: inline-flex; align-items: baseline; gap: 3px; }
/* Fecha de registro debajo de la cantidad. Discreta mientras está vacía para
   que la vista siga siendo legible con 39 estructuras en pantalla. */
.qty-fecha {
  display: block; margin: 5px auto 0; width: 106px; padding: 2px 4px;
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: 5px;
  color: var(--text-faint); font-family: var(--font-mono); font-size: 10.5px; text-align: center;
  color-scheme: var(--esquema);
}
.qty-fecha.puesta { color: var(--text-dim); border-color: var(--border); }
/* Sin cantidad registrada la fecha se dibuja igual pero casi transparente: así
   todas las filas miden lo mismo y la tabla no salta de alto de una a otra. */
.qty-fecha.vacia { opacity: 0.18; border-color: transparent; }
.qty-fecha.vacia:hover, .qty-fecha.vacia:focus { opacity: 1; border-color: var(--border-soft); }
.qty-fecha:focus { outline: none; border-color: var(--teal); color: var(--text); }
.qty-fecha:disabled { opacity: 0.35; }
.qty-fecha.vacia:disabled { opacity: 0.12; }
.qty-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); font-weight: 600; }
.stat-sub { font-family: var(--font-mono); font-size: 0.62em; color: var(--text-dim); font-weight: 500; }


/* Resumen general del proyecto (anillo + desglose) */
.resumen-grid { display: grid; grid-template-columns: 240px 1fr; gap: 26px; align-items: center; }
.resumen-chart { position: relative; height: 220px; }
.resumen-centro {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.resumen-centro-num { font-family: var(--font-head); font-size: 34px; font-weight: 800; color: var(--text); line-height: 1; }
.resumen-centro-lbl { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.resumen-leyenda { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px; }
.rl-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.rl-item strong { color: var(--text); font-family: var(--font-mono); font-size: 15px; }
.rl-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.resumen-rubricas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.rr-fila {
  cursor: pointer; border-radius: 8px; padding: 7px 9px; margin: -7px -9px;
  border: 1px solid transparent; transition: background 0.15s ease, border-color 0.15s ease;
}
.rr-fila:hover, .rr-fila:focus-visible { background: var(--bg-2); border-color: var(--border); outline: none; }
.rr-fila:hover .rr-nombre { color: var(--teal); }
.rr-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.rr-nombre { font-size: 12.5px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.rr-pct { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--teal); }
.rr-meta { font-size: 11px; color: var(--text-faint); margin-top: 5px; }

/* Resumen de avance del montaje */
.cva-kpis { margin: 4px 0 6px; }
.kpi-hero {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 12px;
}
.kpi-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.kpi-hero-val { font-family: var(--font-head); font-size: 26px; font-weight: 800; color: var(--text); margin-top: 3px; }
.kpi-hero-pct { font-family: var(--font-head); font-size: 30px; font-weight: 800; color: var(--teal); line-height: 1; }
.kpi-hero-meta { font-size: 12px; color: var(--text-dim); margin-top: 9px; }
.progress-bar.lg { height: 11px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 13px;
  transition: border-color 0.18s ease;
}
.kpi-card:hover { border-color: var(--border-strong); }
.kpi-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.kpi-code { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--text); }
.kpi-pct { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--teal); }
.kpi-name { font-size: 11px; color: var(--text-dim); margin: 3px 0 9px; line-height: 1.3; min-height: 28px; }
.kpi-num { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--text); margin-top: 7px; }

/* Nombre corto del accesorio bajo su literal en el encabezado. */
.ta-acc {
  display: block; margin-top: 3px; font-family: var(--font-body); font-size: 9.5px;
  font-weight: 500; color: var(--teal); letter-spacing: 0; text-transform: none; line-height: 1.25;
}

.cva-total-cell { text-align: center; font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
/* Fila de totales al final de la tabla. No se fija al pie a propósito: al
   combinar sticky-bottom con la columna congelada de la izquierda, Chrome
   pintaba la primera celda por debajo y el rótulo quedaba tapado. */
.cva-total-row td {
  background: var(--reg-total); font-family: var(--font-mono); font-weight: 700; font-size: 12.5px;
  text-align: center; color: var(--text); border-top: 2px solid var(--border-strong);
}
/* Sin sticky y con display de celda: .chk-table pone la primera columna en flex,
   y un td en flex no se estira al alto de la fila; de ahí el hueco oscuro que
   quedaba bajo el rótulo. El cuerpo ya lo corregía, el pie no. */
.cva-total-row td:first-child {
  display: table-cell; vertical-align: middle;
  text-align: left; background: var(--reg-total);
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600; color: var(--text-dim);
}
.cva-ficha-acc { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.cva-ficha-acc strong { font-family: var(--font-mono); font-size: 12.5px; }
.cva-ficha-acc em { font-style: normal; font-size: 10.5px; color: var(--text-faint); line-height: 1.3; }

.cva-lightbox-inner { position: relative; background: #ffffff; border-radius: 12px; padding: 14px; max-width: min(94vw, 900px); }
.cva-lightbox-inner img { width: 100%; height: auto; display: block; }
.cva-lightbox-inner p { margin: 8px 0 0; font-size: 12px; color: #55606c; text-align: center; }
.cva-lightbox-inner .cva-ficha-close { position: absolute; top: 8px; right: 8px; color: #55606c; background: rgba(255,255,255,0.9); }
.cva-lightbox-inner .cva-ficha-close:hover { background: #e7ebf0; color: #1a2330; }

.cva-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0 12px; }
.cva-filters input[type="text"], .cva-filters select {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font-size: 13px; font-family: var(--font-body);
}
.cva-filters input[type="text"] { flex: 1; min-width: 200px; }
.cva-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); white-space: nowrap; cursor: pointer; }
.cva-check input { width: auto; cursor: pointer; }

.cva-table thead th { text-align: center; }
.cva-table thead th:first-child { text-align: center; min-width: 100px; }

/* Escala de la tabla de montaje: ancho fijo por columna para que el encabezado,
   los registros y la fila de totales queden alineados. La primera columna y la
   de avance son más anchas porque llevan texto; las de accesorio, todas iguales. */
.cva-table { table-layout: fixed; width: 100%; }
.cva-table th, .cva-table td { padding: 5px 8px; }
.cva-table thead th { vertical-align: middle; width: 118px; }
/* Columna del nombre: solo lleva "CVA 01" y su abscisa, así que se deja
   estrecha y centrada. El resto de columnas reparte el ancho sobrante. */
.cva-table thead th:first-child { width: 100px; min-width: 100px; }
.cva-table thead th.th-tramo { width: 96px; }
.cva-table thead th:last-child { width: 128px; }

/* Desplegable del botón de reportes: parte diario o acumulado. */
.rep-menu { position: relative; display: inline-flex; }
.rep-opts {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  display: flex; flex-direction: column; min-width: 168px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35); overflow: hidden;
}
.rep-opts button {
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 9px 13px; text-align: left; font-family: var(--font-body); font-size: 12.5px;
}
.rep-opts button:hover { background: var(--bg-3); color: var(--teal); }
/* Sin esto el display de arriba pisa al atributo hidden y el menú se ve siempre. */
.rep-opts[hidden] { display: none; }

/* Cabecera del montaje: una sola línea con la cifra, la barra y el porcentaje.
   Antes era un bloque alto con el número en grande. */
.mont-total {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px;
  padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-2); margin-bottom: 10px;
}
.mt-tit { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.mt-cifra { font-family: var(--font-mono); font-size: 17px; font-weight: 700; color: var(--text); }
.mt-cifra i { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.mt-barra-tot { flex: 1; min-width: 120px; height: 6px; }
.mt-tot-pct { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--teal); }
.mt-meta { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* Tarjetas de tramo: cámaras terminadas, las que faltan y las piezas. */
.mont-tramos { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 8px; }
.mt-card {
  --t: var(--teal);
  padding: 8px 11px; border: 1px solid color-mix(in srgb, var(--t) 45%, transparent);
  border-left: 5px solid var(--t);
  border-radius: 8px;
  background: color-mix(in srgb, var(--t) 12%, var(--bg-2));
}
.mt-card .mt-head b { color: color-mix(in srgb, var(--t) 55%, var(--text)); }
.mt-card .mt-pct { color: var(--t); }
.mt-card .mt-barra { background: color-mix(in srgb, var(--t) 22%, var(--bg-3)); }
.mt-card .mt-barra .progress-bar-fill { background: var(--t); }
.mt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mt-head b { font-size: 12px; font-weight: 700; color: var(--text); }
.mt-pct { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--teal); }
.mt-linea { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.mt-ok { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--text); }
.mt-falta { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: #e0a458; }
.mt-card .mt-barra { display: block; height: 5px; margin: 6px 0 4px; }
.mt-pzs { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }
/* Un color por tramo. Se define una sola vez y de ahí salen el borde, el
   fondo, el título, el porcentaje y la barra de la tarjeta. */
.mt-card.t10, .mt-card.t1 { --t: #5b9bd5; }
.mt-card.t8 { --t: #d69e4a; }
.mt-card.t9 { --t: #c9768f; }
.mt-card.t7 { --t: #4fb88a; }
.mt-card.tph { --t: #9684d2; }
.mt-card.tx { --t: #8d949e; }

/* Tinte por tramo: se usa un inset en vez de background para no pisar el fondo
   propio de cada celda (la primera columna y el hover tienen el suyo). */
.cva-table tbody tr.tramo-10 td, .cva-table tbody tr.tramo-1 td { box-shadow: inset 0 0 0 999px rgba(91,155,213,0.17); }
.cva-table tbody tr.tramo-8 td { box-shadow: inset 0 0 0 999px rgba(214,158,74,0.17); }
.cva-table tbody tr.tramo-9 td { box-shadow: inset 0 0 0 999px rgba(201,118,143,0.17); }
.cva-table tbody tr.tramo-7 td { box-shadow: inset 0 0 0 999px rgba(79,184,138,0.16); }
.cva-table tbody tr.tramo-ph td { box-shadow: inset 0 0 0 999px rgba(150,132,210,0.17); }
/* La primera columna del grupo lleva el color un punto más marcado, para que
   la franja se lea de un vistazo al recorrer la tabla. */
.cva-table tbody tr[class*="tramo-"] td:first-child { border-left: 4px solid transparent; }
.cva-table tbody tr.tramo-10 td:first-child, .cva-table tbody tr.tramo-1 td:first-child { border-left-color: #5b9bd5; }
.cva-table tbody tr.tramo-8 td:first-child { border-left-color: #d69e4a; }
.cva-table tbody tr.tramo-9 td:first-child { border-left-color: #c9768f; }
.cva-table tbody tr.tramo-7 td:first-child { border-left-color: #4fb88a; }
.cva-table tbody tr.tramo-ph td:first-child { border-left-color: #9684d2; }
.tramo-select.t10, .tramo-select.t1 { border-color: #5b9bd5; color: #d9e8f7; background: rgba(91,155,213,0.22); }
.tramo-select.t8 { border-color: #d69e4a; color: #f7e9d2; background: rgba(214,158,74,0.22); }
.tramo-select.t9 { border-color: #c9768f; color: #f6dde5; background: rgba(201,118,143,0.22); }
.tramo-select.t7 { border-color: #4fb88a; color: #d7f3e6; background: rgba(79,184,138,0.22); }
.tramo-select.tph { border-color: #9684d2; color: #e4dff7; background: rgba(150,132,210,0.22); }

/* Tramo del trazado al que pertenece la cámara. */
.tramo-select {
  width: 84px; padding: 4px 3px; border-radius: 6px; text-align: center;
  border: 1px solid var(--border-soft); background: var(--bg-1); color: var(--text-faint);
  font-family: var(--font-body); font-size: 11px; font-weight: 600; cursor: pointer;
  /* Sin esto el desplegable nativo se abre en claro y hereda el color del
     texto del selector: los números salían casi invisibles sobre blanco. */
  color-scheme: var(--esquema);
}
/* La lista desplegable la dibuja el sistema: hay que darle su propio color,
   no puede heredar el del tramo. */
.tramo-select option {
  background: var(--opcion-bg);
  color: var(--opcion-text);
  font-weight: 600;
}
.tramo-select.puesto { color: var(--text); border-color: var(--border); }
.tramo-select:focus { outline: none; border-color: var(--teal); color: var(--text); }
.tramo-select:disabled { cursor: default; opacity: 0.5; }

.ta-herramientas { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 4px; }
.ta-filtro {
  flex: 1; min-width: 0; max-width: 84px; padding: 2px 4px; border-radius: 5px;
  border: 1px solid var(--border-soft); background: var(--bg-1); color: var(--text-dim);
  font-family: var(--font-body); font-size: 9.5px; font-weight: 600;
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.ta-filtro:focus { outline: none; border-color: var(--teal); color: var(--text); }
.ta-pdf {
  background: none; border: 1px solid var(--border-soft); border-radius: 5px;
  color: var(--text-faint); cursor: pointer; padding: 2px 4px; display: inline-flex; flex-shrink: 0;
}
.ta-pdf:hover { color: var(--teal); border-color: var(--teal); background: var(--teal-dim); }
/* Columna con filtro activo: se distingue de un vistazo. */
.cva-table thead th.ta-filtrada { background: var(--teal-dim); }
.cva-table thead th.ta-filtrada .ta-filtro { color: var(--teal); border-color: var(--teal); }

/* Fila de totales: cifra, barra y porcentaje del accesorio, bajo su columna. */
.cva-total-row .tot-num { display: block; font-size: 12.5px; }
.cva-total-row .tot-bar { display: block; height: 5px; margin: 3px auto 2px; max-width: 78px; }
.cva-total-row .tot-bar .progress-bar-fill { display: block; height: 100%; }
.cva-total-row .tot-pct { display: block; font-size: 10.5px; color: var(--text-dim); }

/* La celda de cantidad ocupa el ancho de su columna, sin desbordarla. Aquí se
   aprieta más que en el resto de checklists porque son 39 filas por 5 columnas
   y con la fecha debajo la tabla se iba de alto. */
.cva-table .qty-input { width: 46px; padding: 3px 4px; font-size: 12.5px; }
.cva-table .qty-fecha { width: 92px; margin-top: 3px; padding: 1px 3px; font-size: 10px; }
.cva-table tbody td:first-child { display: table-cell; }
.cva-name {
  background: none; border: none; padding: 0; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%; font-family: var(--font-mono);
  color: var(--text); transition: color 0.15s ease;
}
.cva-name:hover { color: var(--teal); }
.cva-name:hover .cva-name-id { text-decoration: underline; }
.cva-name-id { font-size: 12.5px; font-weight: 700; }
.cva-name-meta { font-size: 10.5px; color: var(--text-faint); }
.cva-pct-cell { min-width: 96px; }
.cva-pct-cell .progress-bar { margin-top: 0; }
.cva-pct { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); display: block; margin-top: 4px; text-align: center; }

.cva-ficha { max-width: 480px; }
.cva-ficha-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cva-ficha-head h3 { margin: 2px 0 0; font-family: var(--font-head); font-size: 20px; }
.cva-ficha-eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--teal); }
.cva-ficha-close { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 3px; display: inline-flex; border-radius: 6px; }
.cva-ficha-close:hover { color: var(--text); background: var(--bg-3); }
.cva-ficha-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0 0 14px; }
.cva-ficha-grid dt, .cva-ficha-ref dt { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); font-family: var(--font-mono); margin-bottom: 3px; }
.cva-ficha-grid dd, .cva-ficha-ref dd { margin: 0; font-size: 14px; color: var(--text); font-weight: 600; }
.cva-ficha-ref { margin-bottom: 16px; }
.cva-ficha-ref dd { font-size: 13px; font-weight: 400; line-height: 1.45; color: var(--text-dim); }
.cva-ficha-prog { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cva-ficha-prog .progress-bar { flex: 1; margin-top: 0; }
.cva-ficha-prog span { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.cva-ficha-list { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 2px; }
.cva-ficha-list li {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text-dim); background: var(--bg-2);
}
.cva-ficha-list li.ok { color: var(--text); }
.cva-ficha-mark {
  width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: transparent;
}
.cva-ficha-list li.ok .cva-ficha-mark { background: var(--teal); border-color: var(--teal); color: white; }
.cva-ficha-medida { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

.form-hint {
  background: var(--teal-dim); border: 1px solid rgba(63,124,194,0.3); color: var(--teal);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; margin-bottom: 16px;
  display: flex; gap: 8px; align-items: flex-start; line-height: 1.45;
}
.form-hint svg { margin-top: 2px; }

.nav-link .nav-icon svg { display: block; margin: 0 auto; }
.rubric-icon { color: var(--teal); }
.card-header h2 svg { color: var(--teal); }
.group-title svg { color: var(--teal); }
.activity-icon { color: var(--text-dim); }
.btn svg { flex-shrink: 0; }

.hidden { display: none !important; }

.inline-form { border-top: 1px solid var(--border-soft); padding-top: 16px; margin-bottom: 18px; animation: viewIn 0.22s ease; }
.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 16px; margin-bottom: 14px; }
.inline-fields .field { margin-bottom: 0; }
.inline-fields .field label { color: var(--text-faint); font-weight: 500; }
.inline-fields .field input:disabled { color: var(--text-dim); background: var(--bg-1); }
.inline-actions { display: flex; gap: 10px; }

.user-menu {
  position: fixed; width: 250px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px; z-index: 90; box-shadow: var(--shadow);
  animation: modalIn 0.15s ease;
}
.um-head { display: flex; gap: 11px; align-items: center; padding: 8px 8px 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 8px; }
.um-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--blue); color: white; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.um-email { font-size: 12.5px; word-break: break-all; }
.um-role { font-size: 10.5px; color: var(--teal); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; margin-top: 2px; }
.um-nombre { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 1px; }
.um-alcance { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.35; }
.um-item { display: flex; gap: 9px; align-items: center; width: 100%; background: transparent; border: none; color: var(--red); padding: 10px 11px; border-radius: 9px; cursor: pointer; font-size: 13.5px; font-family: var(--font-body); transition: background 0.15s ease; }
.um-item:hover { background: rgba(229, 86, 109, 0.12); }

/* ---------------- Pulido moderno ---------------- */

.view-anim { animation: viewIn 0.28s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.btn { transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn-primary { background: var(--blue); box-shadow: none; }
.btn-primary:hover { background: #2568bd; }
.btn-teal { background: var(--teal); box-shadow: none; }
.btn-teal:hover { background: #4d8ad1; }
.btn-redsolid { box-shadow: none; }

.sidebar { background: var(--bg-1); }
.nav-link { transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease; }
.nav-link:hover { transform: translateY(-1px); }
.nav-link.active { background: var(--teal); box-shadow: none; }

.card {
  background: var(--bg-1);
  transition: border-color 0.2s ease;
}
.stat-card { transition: transform 0.18s ease, border-color 0.18s ease; }
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong, rgba(255,255,255,0.16)); }
.stat-card .stat-value {
  color: var(--text);
}

.progress-bar-fill { background: var(--blue); transition: width 0.5s ease; }

table.data-table td { transition: background 0.12s ease; }
.rubric-card { transition: border-color 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease; }
.rubric-card:hover { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3); }

.chk-box.checked { box-shadow: none; }
.struct-card { transition: transform 0.18s ease, border-color 0.18s ease; }
.struct-card:hover { transform: translateY(-2px); border-color: var(--border-strong, rgba(255,255,255,0.16)); }

.field input, .field select, .field textarea, .toolbar input, .toolbar select, .group-search input {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus,
.toolbar input:focus, .toolbar select:focus, .group-search input:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim);
}

.activity-row { transition: background 0.12s ease; border-radius: 8px; }
.activity-row:hover { background: rgba(255, 255, 255, 0.025); }

::-webkit-scrollbar-thumb { background: var(--bg-3); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------------- Responsive ---------------- */

@media (max-width: 1024px) {
  .main { padding: 20px 20px 50px; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; margin: 10px; border-radius: 18px; min-height: calc(100vh - 20px); }
  .sidebar {
    width: 100%; height: auto; flex-direction: row; align-items: center; justify-content: space-between;
    position: sticky; top: 10px; z-index: 40; padding: 10px 14px;
    border-right: none; border-bottom: 1px solid var(--border-soft);
    border-radius: 18px 18px 0 0;
  }
  .sidebar-brand { margin: 0 8px 0 0; }
  .side-logo { width: 32px; height: 32px; }
  .sidebar-nav {
    flex-direction: row; align-items: center; justify-content: space-between;
    width: auto; flex: 1; gap: 2px; padding: 0; margin: 0; overflow: visible;
  }
  .nav-link {
    flex-direction: column; width: auto; min-width: 0; flex: 1; gap: 3px;
    padding: 7px 4px; font-size: 10px; border-radius: 10px;
  }
  .nav-link .nav-icon { font-size: 15px; }
  .nav-link .nav-icon svg { width: 15px; height: 15px; }
  #sidebar-nav .nav-more-trigger { display: flex; }
  .nav-more-panel {
    display: flex; position: absolute; top: calc(100% + 10px); right: 0;
    flex-direction: column; background: var(--bg-2); border: 1px solid var(--border-soft);
    border-radius: 12px; padding: 6px; min-width: 190px;
    box-shadow: 0 16px 36px rgba(0,0,0,0.45); z-index: 80; gap: 2px;
    opacity: 0; transform: translateY(-6px) scale(0.97); pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(.2,.8,.2,1);
    transform-origin: top right;
  }
  .nav-more-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
  .nav-more-panel .nav-link {
    flex-direction: row; justify-content: flex-start; width: 100%; gap: 10px;
    padding: 10px 12px; font-size: 13px; border-radius: 8px;
  }
  .nav-more-panel .nav-link .nav-icon { font-size: 17px; }
  .nav-more-panel .nav-link .nav-icon svg { width: 17px; height: 17px; }
  .sidebar-user { margin: 0 0 0 6px; padding: 0; }
  .sidebar-user .avatar { width: 34px; height: 34px; font-size: 11px; }
  .main { padding: 14px 12px 36px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 12px; margin-bottom: 16px; }
  .topbar-left { padding-left: 13px; }
  .topbar-eyebrow { font-size: 10px; letter-spacing: 1.4px; }
  .topbar h1 { font-size: 18px; gap: 8px; margin-top: 3px; }
  .topbar h1 .badge-beta { font-size: 9.5px; padding: 3px 8px; }
  .topbar .sub { font-size: 12px; }
  .topbar-right { gap: 8px 14px; justify-content: flex-start; }
  .topbar-clock { font-size: 11.5px; }
  .topbar-user { font-size: 11.5px; flex-wrap: wrap; }
  .detail-header h2 { font-size: 15px; }
  .group-search { flex-direction: column; }
  .group-search .btn { justify-content: center; }
  .group-actions { flex-direction: column; }
  .group-actions .btn { flex: 1; justify-content: center; width: 100%; }
  .rubric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .rubric-card { padding: 14px; }
  .rubric-card h3 { font-size: 13.5px; }
  .rubric-card .rubric-sub { font-size: 11.5px; }
  .rubric-icon { font-size: 15px; width: 34px; height: 34px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 11px 13px; }
  .stat-card .stat-label { font-size: 10px; }
  .stat-card .stat-value { font-size: 18px; }
  .kpi-sub { font-size: 10px; }
  .card-header h2 { font-size: 13.5px; }
  .group-title { font-size: 11.5px; }
  .est-row { gap: 10px; padding: 10px 6px; }
  .est-head strong { font-size: 12.5px; }
  .est-pct { font-size: 12px; }
  .est-meta { font-size: 10.5px; }
  .struct-card { min-width: 104px; padding: 10px 12px; }
  .struct-card .sc-name { font-size: 11px; }
  .struct-card .sc-abscisa { font-size: 10.5px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input[type=search] { min-width: 0; flex: 1; }
  .toolbar-label { font-size: 11px; }
  .card { padding: 13px 13px; }
  .btn { font-size: 12.5px; padding: 8px 13px; }
  .btn-small { font-size: 11.5px; padding: 6px 10px; }
  table.data-table { font-size: 12px; }
  table.data-table th { font-size: 9.5px; padding: 8px 8px; }
  table.data-table td { padding: 8px 8px; font-size: 12px; }
  .chk-table th, .chk-table td { padding: 6px 8px; font-size: 11.5px; line-height: 1.2; }
  .chk-table tbody td:first-child { font-size: 12px; max-width: 128px; overflow: hidden; text-overflow: ellipsis; }
  .chk-box { width: 24px; height: 24px; }
  .chk-box svg { width: 13px; height: 13px; }
  .chk-medida { font-size: 8.5px; margin-top: 2px; }
  .chk-matrix-wrap { max-height: 60vh; box-shadow: inset -14px 0 12px -12px rgba(0,0,0,0.45); }
  .modal h3 { font-size: 18px; }
  .modal .field label { font-size: 12.5px; }
  .modal .field input, .modal .field select, .modal .field textarea { padding: 11px 13px; font-size: 13.5px; }
  .modal { padding: 18px; }
  .login-form-side { padding: 32px 24px; }
  .login-side { padding: 32px 24px; }
  .chk-actions { flex-wrap: wrap; }
  .chk-actions .btn { flex: 1; justify-content: center; min-width: 120px; }
  .activity-row { font-size: 12px; }
  .activity-meta { font-size: 10.5px; }
}

/* En pantallas angostas la fecha se pasa debajo del texto en vez de competir
   por el ancho con el detalle del cambio. */
@media (max-width: 640px) {
  .activity-row { flex-wrap: wrap; }
  .activity-row > .activity-meta:last-child {
    width: 100%; padding-left: 40px; margin-top: 2px; order: 3;
  }
  .activity-detalle { white-space: normal; }
}

@media (max-width: 520px) {
  .rubric-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar-clock { font-size: 11px; }
  .topbar-user { font-size: 11px; flex-wrap: wrap; }
  .actions-cell { flex-direction: column; }
  .actions-cell .btn { padding: 6px 9px; font-size: 11.5px; width: 100%; justify-content: center; }
  .toast { left: 14px; right: 14px; max-width: none; }
  .topbar h1 { font-size: 16.5px; gap: 6px; }
  .badge-beta { font-size: 9px; padding: 2px 7px; }
  .struct-card { min-width: 96px; }
  .est-head strong { font-size: 12px; }
  .stat-card .stat-value { font-size: 16.5px; }
  .card-header h2 { font-size: 13px; }
  .rubric-card h3 { font-size: 13px; }
  .nav-link { font-size: 8.8px; padding: 6px 2px; }
  .nav-link .nav-icon { font-size: 14px; }
  .nav-link .nav-icon svg { width: 14px; height: 14px; }
  .side-logo { width: 26px; height: 26px; }
  .sidebar-user .avatar { width: 28px; height: 28px; font-size: 10px; }
  .chk-table th, .chk-table td { padding: 5px 6px; font-size: 10.5px; }
  .chk-table tbody td:first-child { max-width: 96px; font-size: 11px; }
  .chk-box { width: 21px; height: 21px; border-radius: 6px; }
  .chk-box svg { width: 11px; height: 11px; }
  .chk-medida { font-size: 8px; }
  .chk-matrix-wrap { max-height: 54vh; }
  .struct-cards { gap: 8px; }
  .activity-row { font-size: 11px; padding: 7px 0; gap: 8px; }
  .activity-icon { width: 26px; height: 26px; }
  .activity-meta { font-size: 10px; }
  .cva-filters { gap: 7px; }
  .cva-filters input[type="text"], .cva-filters select { padding: 7px 10px; font-size: 12px; }
  .cva-filters input[type="text"] { min-width: 0; }
  .cva-table thead th:first-child { min-width: 88px; }
  .cva-name-id { font-size: 11px; }
  .cva-name-meta { font-size: 9px; }
  .cva-pct-cell { min-width: 62px; }
  .cva-pct { font-size: 9px; }
  .cva-ficha-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cva-ficha-head h3 { font-size: 17px; }
  .cva-ficha-list li { font-size: 12px; padding: 7px 9px; }
  .cva-tabs { gap: 5px; margin-bottom: 12px; }
  .cva-tab { padding: 8px 13px; font-size: 14px; gap: 7px; }
  .cva-tab-badge { font-size: 11px; padding: 2px 6px; }
  .resumen-grid { grid-template-columns: 1fr; gap: 16px; }
  .resumen-chart { height: 180px; }
  .resumen-centro-num { font-size: 28px; }
  .resumen-rubricas { grid-template-columns: 1fr; }
  .cva-planos-body { grid-template-columns: 1fr; gap: 10px; padding: 4px 10px 12px; }
  .cva-planos-head { padding: 9px 11px; font-size: 12px; }
  .cva-plano figcaption { font-size: 10px; }
}

/* ---------------- Marcos H ---------------- */

/* Una sola lámina: la del plano, centrada y con su proporción real. */
.mh-planos-body .cva-plano { max-width: 1000px; width: 100%; }
.mh-planos-body .cva-plano img { aspect-ratio: auto; }

/* Una sola tarjeta de avance: se le pone ancho propio para que no se estire
   de lado a lado como cuando eran cuatro. */
#mh-stats { grid-template-columns: minmax(200px, 320px); }

.mh-wrap { overflow-x: auto; }

.mh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.mh-table thead th {
  background: var(--bg-2);
  color: var(--text-dim);
  font-family: var(--font-head);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mh-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.mh-table tbody tr:hover td { background: var(--hover-fila); }

/* Estado del marco a primera vista: sin tocar, a medias o terminado. El ámbar
   queda reservado para los marcos con actividades adicionales. */
.mh-table tbody tr.mh-ok td { box-shadow: inset 0 0 0 999px rgba(47,191,113,0.09); }
.mh-table tbody tr.mh-proceso td { box-shadow: inset 0 0 0 999px rgba(63,124,194,0.10); }
/* La franja de estado va solo en la celda del marco, no en la segunda fila
   de un doble: ahí la primera celda es la del soporte y salía una línea suelta. */
.mh-table tbody tr:not(.mh-sigue) td:first-child { border-left: 3px solid transparent; }
.mh-table tbody tr.mh-ok:not(.mh-sigue) td:first-child { border-left-color: #2fbf71; }
.mh-table tbody tr.mh-proceso:not(.mh-sigue) td:first-child { border-left-color: #3f7cc2; }
.mh-table tbody tr.mh-pendiente:not(.mh-sigue) td:first-child { border-left-color: var(--border); }

/* El encabezado se queda fijo al desplazar los 29 marcos. */
.mh-table thead th { position: sticky; top: 0; z-index: 2; }

.mh-c-num { min-width: 190px; }
.mh-c-inst { width: 290px; }

.mh-c-foto { width: 190px; }

.mh-num {
  display: block;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.mh-tipo {
  display: block;
  font-size: 0.72rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.mh-estado {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.mh-estado.pend { color: var(--text-faint); border-color: var(--border); }
.mh-estado.med { color: #9ec5ef; background: rgba(63,124,194,0.16); border-color: rgba(63,124,194,0.45); }
.mh-estado.ok { color: #93f2c1; background: rgba(47,191,113,0.16); border-color: rgba(47,191,113,0.45); }

/* Marcos con volúmenes: en el Excel de obra van resaltados en amarillo y aquí
   se mantiene esa señal, con el nombre convertido en botón. */
.mh-vol-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(245,166,35,0.10);
  border: 1px solid rgba(245,166,35,0.35);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.mh-vol-btn:hover { background: rgba(245,166,35,0.18); border-color: rgba(245,166,35,0.6); }
.mh-vol-btn .mh-num { color: var(--amber); }
.mh-vol-tag {
  display: inline-block;
  margin-top: 5px;
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(245,166,35,0.4);
  border-radius: 999px;
  padding: 1px 7px;
}

/* Bloque de soporte: una línea por soporte, siempre en la misma cuadrícula
   (etiqueta · casilla · fecha) para que todas las filas queden alineadas,
   tengan uno o dos soportes. */
.mh-sop {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 118px;
  align-items: center;
  column-gap: 9px;
  padding: 3px 0;
}
.mh-sop + .mh-sop {
  border-top: 1px dashed var(--border-soft);
  margin-top: 4px;
  padding-top: 7px;
}
.mh-sop-tag {
  display: inline-flex; align-items: center; justify-content: center;
  height: 19px; border-radius: 5px;
  background: var(--bg-3); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; color: var(--text-faint);
}
.mh-sop.ok .mh-sop-tag { background: rgba(47,191,113,0.18); border-color: rgba(47,191,113,0.5); color: #93f2c1; }

.mh-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.mh-sop.ok .mh-check { color: var(--text); }
.mh-check input { width: 16px; height: 16px; accent-color: var(--teal); cursor: pointer; }

.mh-fecha, .mh-medida {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.78rem;
  padding: 5px 8px;
}
.mh-fecha { width: 100%; color-scheme: var(--esquema); }
.mh-medida { width: 100%; text-align: right; font-family: var(--font-mono); }


.mh-fecha.vacia { color: var(--text-faint); border-style: dashed; }
.mh-fecha:disabled, .mh-medida:disabled { opacity: 0.55; cursor: not-allowed; }
/* Los dos soportes de un marco doble se leen como un bloque: entre ellos solo
   una línea muy tenue, y la separación marcada va entre marco y marco. */
.mh-table tbody tr.mh-sigue td { border-top: 1px solid var(--border-soft); border-bottom: none; }
.mh-table tbody tr:not(.mh-sigue) td { border-top: 1px solid var(--border); }
.mh-table tbody tr:first-child td { border-top: none; }
.mh-table tbody td { border-bottom: none; }

/* Encabezado en dos niveles: el grupo arriba y los lados debajo. */
.mh-table thead th.mh-c-grupo { text-align: center; border-bottom: 1px solid var(--border-soft); }
.mh-table thead tr.mh-sub th {
  top: 33px; font-size: 0.64rem; letter-spacing: 0.05em; text-align: center;
  color: var(--text-faint); padding-top: 4px; padding-bottom: 8px;
}
.mh-c-med { width: 84px; }
.mh-c-med .mh-medida { width: 100%; }

.mh-subir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.76rem;
  padding: 6px 10px;
  cursor: pointer;
}
.mh-subir:hover { color: var(--teal); border-color: var(--teal); }
.mh-sin-foto { color: var(--text-faint); font-size: 0.76rem; }

.mh-foto-ok { display: inline-flex; align-items: center; gap: 8px; }
.mh-foto-ok img {
  width: 54px; height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
}
.mh-foto-acc { display: inline-flex; gap: 4px; }
.mh-mini {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  padding: 5px 7px;
  cursor: pointer;
  line-height: 1;
}
.mh-mini:hover { color: var(--teal); border-color: var(--teal); }
.mh-mini-borrar:hover { color: var(--red); border-color: var(--red); }

/* Ventana de actividades adicionales: una línea por actividad, con su
   cantidad y su fecha, para que se lea como el cuadro de obra. */
.mh-modal { max-width: 520px; }

.mh-act-head, .mh-act {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 10px;
  align-items: center;
}
.mh-act-head {
  padding: 0 12px 6px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
.mh-act-head span:nth-child(2) { text-align: right; }
.mh-act-lista {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  overflow: hidden;
  margin-bottom: 14px;
}
.mh-act { padding: 10px 12px; }
.mh-act + .mh-act { border-top: 1px solid var(--border-soft); }
.mh-act:hover { background: var(--hover-fila); }
.mh-act-nom {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.mh-act-nom em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
}
.mh-act input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  padding: 7px 9px;
  color-scheme: var(--esquema);
}
.mh-act-cant input { text-align: right; }
.mh-act input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim); }
.mh-act input:disabled { opacity: 0.55; }

.mh-vol-obs {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}
.mh-vol-obs textarea {
  width: 100%;
  margin-top: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 8px 10px;
  resize: vertical;
}

@media (max-width: 700px) {
  .mh-c-inst { width: auto; }
  .mh-sop { grid-template-columns: 24px minmax(0, 1fr); row-gap: 5px; }
  .mh-sop .mh-fecha { grid-column: 2; }
  .mh-act-head { display: none; }
  .mh-act { grid-template-columns: 1fr 1fr; grid-template-areas: "nom nom" "cant fecha"; row-gap: 6px; }
  .mh-act-nom { grid-area: nom; }
  .mh-act-cant { grid-area: cant; }
  .mh-act-fecha { grid-area: fecha; }
}
