:root {
  --bg: #f5f6f8; --fg: #1d2330; --card: #fff; --line: #dde1e8;
  --accent: #1f6feb; --ok: #1a7f37; --err: #cf222e; --warn: #9a6700; --run: #8250df;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
main { max-width: 1080px; margin: 0 auto; padding: 1rem 1.2rem 4rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; margin-top: 1.6rem; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: #667; } .error { color: var(--err); font-weight: 600; }

.topbar { display: flex; align-items: center; gap: 1.1rem; padding: .55rem 1.2rem;
  background: #14181f; color: #e6e8ec; flex-wrap: wrap; }
.topbar a { color: #e6e8ec; } .topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .cta { background: var(--accent); padding: .25rem .7rem; border-radius: 6px; }
.topbar .topbar-cta { order: 1; }
.topbar .spacer { flex: 1; order: 2; }
.topbar .who { color: #9aa3b2; font-size: .9rem; }
.topbar .link { background: none; border: 0; color: #9aa3b2; cursor: pointer; }
.topbar-drawer, .topbar-admin-group, .topbar-user-group { display: contents; }
.topbar-admin-group > a, .topbar-user-group > * { order: 3; }
.topbar-section-label, .mobile-menu-btn, .mobile-nav-backdrop, .mobile-bottom-nav { display: none; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; }

table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #eef1f5; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
td.diag { font-size: .85rem; max-width: 360px; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; color: #fff; background: #888; }
.badge.ok { background: var(--ok); } .badge.err { background: var(--err); }
.badge.warn { background: var(--warn); } .badge.run { background: var(--run); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.2rem; margin: .8rem 0; }
.card.warn { border-color: var(--warn); background: #fff8e6; }
.card.form { max-width: 640px; }
.card.login { max-width: 360px; margin-top: 12vh; }

label { display: block; margin: .7rem 0; font-weight: 600; font-size: .9rem; }
label input, label select { display: block; width: 100%; max-width: 100%; margin-top: .25rem;
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; box-sizing: border-box; }
label.check { font-weight: 400; } label.check input { display: inline; width: auto; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; } .row label { flex: 1 1 200px; min-width: 0; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: .55rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; }
button.danger { background: var(--err); }
.btn { display: inline-flex; align-items: center; background: #eef1f5; border: 1px solid var(--line);
  border-radius: 6px; padding: .5rem .9rem; color: var(--fg); line-height: 1.2; }
.actions { display: flex; gap: .6rem; align-items: stretch; flex-wrap: wrap; margin: .8rem 0; }
.actions form { margin: 0; }

.logbox { background: #0d1117; color: #c9d1d9; border-radius: 8px; padding: .9rem;
  width: 100%; max-width: 100%; box-sizing: border-box;
  font: 12.5px/1.45 ui-monospace, monospace; max-height: 60vh; overflow: auto;
  white-space: pre-wrap; word-break: break-word; min-height: 8rem; }
/* Timeline de iteraciones (eventos `iter` del SSE estructurado). */
.iters { list-style: none; margin: .4rem 0 1rem; padding: 0; max-height: 38vh;
  overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.iters:empty { display: none; }
.iters li { padding: .45rem .7rem; border-bottom: 1px solid var(--line);
  font-size: .88rem; line-height: 1.45; }
.iters li:last-child { border-bottom: 0; }
.iters li:nth-child(even) { background: #fafbfc; }
.iters code { margin-right: .3rem; }
.live { color: var(--err); font-size: .8rem; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.centered { display: flex; justify-content: center; }
.okmsg { color: var(--ok); font-weight: 600; }
.tabs { margin: .8rem 0 0; }
.tab { background: #eef1f5; color: var(--fg); border: 1px solid var(--line);
  border-bottom: 0; border-radius: 8px 8px 0 0; padding: .45rem 1rem; font-weight: 600; }
.tab.active { background: var(--card); color: var(--accent); }
.card.wide { max-width: none; }
.rowtable input { width: 100%; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: 5px; font: inherit; }
.rowtable .del { background: none; border: 0; color: var(--err); cursor: pointer; font-size: 1rem; padding: 0 .3rem; }
.btn.add { margin: .4rem 0 0; cursor: pointer; }
label textarea { display: block; width: 100%; margin-top: .25rem; padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.acciones-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.acciones-grid .card.form { max-width: none; margin: 0; }
.mdtext { white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, monospace;
  max-height: 40vh; overflow: auto; }
/* Markdown renderizado por app.js (SOLICITUD / post-mortem). */
.mdrendered { font-size: .95rem; line-height: 1.55; max-height: 50vh; overflow: auto; }
.mdrendered h2, .mdrendered h3, .mdrendered h4 { margin: .9rem 0 .35rem; line-height: 1.3; }
.mdrendered h2 { font-size: 1.1rem; } .mdrendered h3 { font-size: 1rem; } .mdrendered h4 { font-size: .95rem; }
.mdrendered p { margin: .35rem 0; }
.mdrendered ul, .mdrendered ol { margin: .35rem 0; padding-left: 1.4rem; }
.mdrendered li { margin: .15rem 0; }
.mdrendered.card { max-height: none; }
.card.okline { border-color: var(--ok); background: #effaf1; display: flex;
  align-items: center; gap: 1rem; }
.yamleditor { width: 100%; font: 13px/1.5 ui-monospace, monospace; border: 1px solid var(--line);
  border-radius: 8px; padding: .8rem; background: #fbfcfe; resize: vertical; }
.meta { color: #556; font-size: .92rem; }
code { background: #eef1f5; padding: .08rem .35rem; border-radius: 4px; font-size: .85em; }
:not(pre) > code { overflow-wrap: anywhere; word-break: break-word; }

/* Calendario de etapas del proceso: color por cercanía del vencimiento
   (critica ≤ 24 h, urgente ≤ 3 días, proxima ≤ 7 días, lejana > 7 días,
   pasada vencida, sindata sin fecha en el pliego). */
.cal-leyenda { display: flex; gap: 1rem; flex-wrap: wrap; margin: .2rem 0 .8rem;
  font-size: .82rem; color: #667; }
.cal-key { display: inline-flex; align-items: center; gap: .35rem; }
.cal-dot { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block;
  background: #8a919c; flex: none; }
.cal-dot.critica { background: var(--err); } .cal-dot.urgente { background: #d15704; }
.cal-dot.proxima { background: #e3b341; } .cal-dot.lejana { background: var(--ok); }
.cal-dot.pasada { background: #b6bcc6; } .cal-dot.sindata { background: #8a919c; }
.cal-etapas { list-style: none; margin: 0; padding: 0; }
.cal-etapa { display: flex; align-items: center; gap: .6rem; padding: .45rem .2rem;
  border-bottom: 1px solid var(--line); }
.cal-etapa:last-child { border-bottom: 0; }
.cal-etapa.pasada { opacity: .55; }
.cal-etapa.critica .cal-nombre { font-weight: 700; }
.cal-fecha { min-width: 8.2rem; white-space: nowrap; font-size: .9rem;
  font-variant-numeric: tabular-nums; }
.cal-nombre { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.badge.cal-badge { white-space: nowrap; }
.badge.cal-badge.critica { background: var(--err); }
.badge.cal-badge.urgente { background: #d15704; }
.badge.cal-badge.proxima { background: var(--warn); }
.badge.cal-badge.lejana { background: var(--ok); }
.badge.cal-badge.pasada, .badge.cal-badge.sindata { background: #8a919c; }

/* Modales bloqueantes del Operador y Notificaciones de Semáforo SERCOP */
#alertas-bloqueantes-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 26, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  overflow-y: auto;
}

.alerta-modal {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  border: 2px solid;
  overflow: hidden;
  animation: modalEntrada 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEntrada {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.alerta-modal-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.alerta-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}

.alerta-modal-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.alerta-modal-body {
  padding: 1.3rem 1.4rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #24292f;
}

.alerta-modal-meta {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  font-size: 0.88rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.8rem;
}

.alerta-modal-meta dt {
  font-weight: 600;
  color: #57606a;
}

.alerta-modal-meta dd {
  margin: 0;
  font-weight: 500;
}

.alerta-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.02);
}

/* Colores de Semáforo según Severidad */
/* 🔴 Crítica: Convalidación requerida o Descalificación */
.alerta-modal.critica {
  border-color: #cf222e;
}
.alerta-modal.critica .alerta-modal-header {
  background: #ffebe9;
  color: #a40e26;
}
.alerta-modal.critica .alerta-btn-ack {
  background: #cf222e;
  color: #fff;
  font-weight: 600;
}
.alerta-modal.critica .alerta-btn-ack:hover {
  background: #a40e26;
}

/* 🟡 Urgente: Plazo por vencer en menos de 2 horas */
.alerta-modal.urgente {
  border-color: #d15704;
}
.alerta-modal.urgente .alerta-modal-header {
  background: #fff8c5;
  color: #8a3b00;
}
.alerta-modal.urgente .alerta-btn-ack {
  background: #d15704;
  color: #fff;
  font-weight: 600;
}
.alerta-modal.urgente .alerta-btn-ack:hover {
  background: #9a3f00;
}

/* 🟢 Éxito: Calificado y Habilitado para Puja (Subir Oferta Inicial) */
.alerta-modal.exito {
  border-color: #1a7f37;
}
.alerta-modal.exito .alerta-modal-header {
  background: #dafbe1;
  color: #116329;
}
.alerta-modal.exito .alerta-btn-ack {
  background: #1a7f37;
  color: #fff;
  font-weight: 600;
}
.alerta-modal.exito .alerta-btn-ack:hover {
  background: #116329;
}

/* 🔵 Info: Informativo */
.alerta-modal.info {
  border-color: #0969da;
}
.alerta-modal.info .alerta-modal-header {
  background: #ddf4ff;
  color: #0550ae;
}
.alerta-modal.info .alerta-btn-ack {
  background: #0969da;
  color: #fff;
  font-weight: 600;
}

/* Módulo M1: Seguridad 2FA TOTP */
.qr-box {
  display: flex;
  justify-content: center;
  padding: 0.65rem;
  margin: 0.6rem 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.qr-box svg {
  display: block;
  max-width: 220px;
  height: auto;
}
.totp-secret-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  margin: 0.6rem 0;
  word-break: break-word;
}
.totp-code-input {
  font-family: ui-monospace, monospace;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  text-align: center;
}
.backup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.backup-code-item {
  display: block;
  text-align: center;
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: #ffffff;
  border: 1px solid #d8b454;
}
.totp-devices {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.85rem;
}
.totp-devices li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.totp-devices li:last-child {
  border-bottom: 0;
}

/* ==========================================================================
   Módulo M2: Diseño Móvil sin Pérdida de Datos (Progressive Disclosure)
   ========================================================================== */

[hidden] {
  display: none !important;
}

/* Contenedor de tabla con scroll horizontal táctil e indicador sutil de sombra */
.table-responsive,
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  background-color: var(--card);
  background-image:
    linear-gradient(to right, var(--card) 22px, rgba(255, 255, 255, 0)),
    linear-gradient(to left, var(--card) 22px, rgba(255, 255, 255, 0)),
    radial-gradient(farthest-side at 0 50%, rgba(20, 24, 31, 0.14), rgba(20, 24, 31, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(20, 24, 31, 0.14), rgba(20, 24, 31, 0));
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 34px 100%, 34px 100%, 11px 100%, 11px 100%;
  background-attachment: local, local, scroll, scroll;
}

.table-responsive > table,
.table-wrap > table {
  background: transparent;
}

/* Barra rápida de salto por chips en oferta_detalle */
.mobile-jump-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.35rem 0;
  margin: 0.35rem 0 0.85rem;
}
.mobile-jump-bar::-webkit-scrollbar {
  display: none;
}
.mobile-jump-prefix {
  font-size: 0.8rem;
  font-weight: 600;
  color: #667;
  white-space: nowrap;
  flex: none;
}
.jump-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.jump-chip:hover {
  background: #eef6ff;
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

[id^="sec-"] {
  scroll-margin-top: 4.5rem;
}

/* Acordeones móviles no destructivos creados en oferta_detalle */
details.mobile-accordion {
  padding: 0.8rem 1rem;
  margin: 0.85rem 0;
}
details.mobile-accordion > summary.mobile-accordion-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--fg);
  min-height: 36px;
}
details.mobile-accordion > summary.mobile-accordion-summary::-webkit-details-marker {
  display: none;
}
details.mobile-accordion > summary.mobile-accordion-summary::after {
  content: "▾";
  font-size: 0.95rem;
  color: #64748b;
  transition: transform 0.16s ease;
}
details.mobile-accordion[open] > summary.mobile-accordion-summary::after {
  transform: rotate(180deg);
}
details.mobile-accordion > .mobile-accordion-body {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}
details.mobile-accordion > .mobile-accordion-body > h2:first-child {
  font-size: 1rem;
  margin-top: 0;
}

@media (max-width: 768px) {
  html,
  body {
    max-width: 100vw;
    overflow-x: clip;
  }

  body.mobile-overlay-lock {
    overflow: hidden;
  }

  main {
    padding: 0.85rem 0.85rem 1.75rem;
  }

  .site-footer {
    padding-bottom: calc(5.2rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  h1 {
    font-size: 1.28rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  h2 {
    font-size: 1.06rem;
    margin-top: 1.25rem;
  }

  /* Cabecera compacta móvil: marca Ushay + Nueva corrida + ☰ Menú */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    flex-wrap: nowrap;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
  }
  .topbar .brand {
    margin-right: auto;
    font-size: 1rem;
    min-height: 44px;
  }
  .topbar .topbar-cta {
    order: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.35rem 0.68rem;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.28rem;
    min-height: 44px;
    padding: 0.4rem 0.72rem;
    background: rgba(255, 255, 255, 0.1);
    color: #e6e8ec;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .mobile-menu-btn[aria-expanded="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  /* Drawer desplegable con los 16 enlaces y sesión */
  .topbar-drawer {
    display: none;
    position: fixed;
    top: 53px;
    left: 0;
    right: 0;
    max-height: calc(100vh - 53px - 58px);
    max-height: calc(100dvh - 53px - 58px - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #181d27;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    padding: 0.55rem 0.8rem 1rem;
    flex-direction: column;
    gap: 0.15rem;
    box-shadow: 0 20px 38px rgba(0, 0, 0, 0.48);
    z-index: 905;
  }
  .topbar-drawer.is-open {
    display: flex;
  }
  .topbar-drawer .spacer {
    display: none;
  }
  .topbar-drawer > a,
  .topbar-admin-group > a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    color: #e6e8ec;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    order: 0;
  }
  .topbar-drawer > a:hover,
  .topbar-drawer > a:active,
  .topbar-admin-group > a:hover,
  .topbar-admin-group > a:active {
    background: rgba(255, 255, 255, 0.09);
    text-decoration: none;
  }
  .topbar-admin-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.45rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  .topbar-section-label {
    display: block;
    padding: 0.15rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
  }
  .topbar-user-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.55rem;
    padding: 0.65rem 0.75rem 0.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }
  .topbar-user-group .who {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: #e2e8f0;
    font-size: 0.92rem;
    font-weight: 600;
    order: 0;
  }
  .topbar-user-group form.inline {
    order: 0;
  }
  .topbar-user-group .link {
    min-height: 42px;
    padding: 0.4rem 0.85rem;
    background: rgba(207, 34, 46, 0.18);
    color: #ff8182;
    border: 1px solid rgba(207, 34, 46, 0.42);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
  }
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 22, 0.52);
    z-index: 890;
  }

  /* Barra inferior fija para pulgar (mobile-bottom-nav) */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    background: #14181f;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.24);
  }
  .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.14rem;
    min-height: 54px;
    padding: 0.32rem 0.2rem;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: #9aa3b2;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.15;
  }
  .mbn-item:hover {
    text-decoration: none;
    color: #e6e8ec;
  }
  .mbn-item.is-active,
  .mbn-item[aria-expanded="true"] {
    color: #ffffff;
    background: rgba(31, 111, 235, 0.22);
  }
  .mbn-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mbn-icon {
    font-size: 1.15rem;
    line-height: 1;
  }
  .mbn-label {
    white-space: nowrap;
  }

  /* Formularios táctiles sin auto-zoom iOS y botones cómodos */
  input,
  select,
  textarea {
    font-size: 16px !important;
    max-width: 100%;
  }

  button:not(.link):not(.linklike):not(.link-btn):not(.del):not(.mbn-item):not(.vig-chip):not(.vig-hdr-btn):not(.vig-hdr-close),
  .btn,
  .button {
    min-height: 42px;
  }

  .card {
    padding: 0.85rem 0.95rem;
  }
  .card.okline {
    flex-wrap: wrap;
    gap: 0.6rem;
  }
  .row {
    gap: 0.65rem;
  }
  .row label {
    flex: 1 1 100%;
  }
  .page-head {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  /* Tablas dúo táctiles con primera columna anclada */
  .table-responsive > table,
  .table-wrap > table {
    min-width: 560px;
  }
  table:not(.table-responsive table):not(.table-wrap table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  th,
  td {
    padding: 0.48rem 0.58rem;
  }
  .table-sticky-first th:first-child,
  .table-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--card);
    box-shadow: 1px 0 0 var(--line);
  }
  .table-sticky-first th:first-child {
    background: #eef1f5;
    z-index: 2;
  }

  /* Calendario legible en pantallas de 360px */
  .cal-etapa {
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
  }
  .cal-fecha {
    min-width: auto;
    font-size: 0.83rem;
  }
  .cal-nombre {
    flex: 1 1 100%;
    order: 3;
    font-size: 0.9rem;
  }

  .mobile-jump-bar {
    position: sticky;
    top: 53px;
    z-index: 800;
    background: rgba(245, 246, 248, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    margin: 0.2rem -0.85rem 0.75rem;
    padding: 0.42rem 0.85rem;
    border-bottom: 1px solid var(--line);
  }
  .jump-chip {
    min-height: 36px;
    padding: 0.35rem 0.75rem;
  }
  [id^="sec-"] {
    scroll-margin-top: 6.8rem;
  }
}

/* ==========================================================================
   Módulo M4-Frontend: Widget Flotante "Chat de Soporte Vigilante"
   ========================================================================== */

.vig-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.05rem;
  border-radius: 999px;
  background: #14181f;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 28px rgba(20, 24, 31, 0.34);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.vig-fab:hover {
  transform: translateY(-2px);
  background: #1d2330;
  box-shadow: 0 16px 34px rgba(20, 24, 31, 0.42);
}

.vig-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  background: #94a3b8;
}
.vig-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.24);
}
.vig-dot.offline {
  background: #94a3b8;
}

.vig-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #cf222e;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px #14181f;
}
.vig-badge-mobile {
  position: absolute;
  top: -6px;
  right: -11px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  font-size: 0.66rem;
}

.vig-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1190;
  background: rgba(10, 15, 25, 0.48);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.vig-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1200;
  width: 420px;
  max-width: calc(100vw - 2rem);
  height: min(680px, calc(100vh - 2rem));
  height: min(680px, calc(100dvh - 2rem));
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: vigPanelIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes vigPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.vig-sheet-handle {
  display: none;
}

.vig-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.95rem;
  background: #14181f;
  color: #e6e8ec;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: none;
}
.vig-header-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.vig-title {
  font-size: 0.98rem;
  font-weight: 700;
  white-space: nowrap;
}
.vig-status {
  font-size: 0.74rem;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  white-space: nowrap;
}
.vig-status.online {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}
.vig-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}
.vig-hdr-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.vig-hdr-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.vig-hdr-close {
  background: transparent;
  color: #cbd5e1;
  border: 0;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
}
.vig-hdr-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.vig-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem;
  background: #f6f8fa;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.vig-empty {
  margin: auto 0;
  text-align: center;
  padding: 1.5rem 1rem;
  color: #57606a;
}
.vig-empty-icon {
  font-size: 2rem;
  margin-bottom: 0.35rem;
}
.vig-empty-title {
  margin: 0 0 0.3rem;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--fg);
}
.vig-empty-sub {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.45;
}

.vig-msg {
  max-width: 92%;
  border-radius: 12px;
  padding: 0.62rem 0.82rem;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}
.vig-msg.user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.vig-msg.user p {
  margin: 0;
}
.vig-msg.user a {
  color: #dbeafe;
  text-decoration: underline;
}
.vig-msg.assistant {
  align-self: flex-start;
  width: 100%;
  max-width: 96%;
  background: #ffffff;
  color: var(--fg);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Tarjeta destacada de Alerta Forense Proactiva */
.vig-msg.is-proactive {
  border: 1.5px solid #cf222e;
  border-left: 5px solid #cf222e;
  background: #fffafa;
}
.vig-proactive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(207, 34, 46, 0.16);
}
.vig-proactive-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  background: #ffebe9;
  color: #a40e26;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
}
.vig-msg-time {
  font-size: 0.7rem;
  color: #64748b;
}

/* Razonamiento técnico plegable (SSE event: thought) */
details.vig-thought {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.32rem 0.55rem;
  margin-bottom: 0.48rem;
  font-size: 0.78rem;
  color: #475569;
}
details.vig-thought > summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.vig-thought-body {
  margin: 0.38rem 0 0.1rem;
  padding-top: 0.35rem;
  border-top: 1px dashed #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  font: 11.5px/1.42 ui-monospace, monospace;
  max-height: 180px;
  overflow-y: auto;
  color: #334155;
}

/* Píldoras compactas de tools en vivo (SSE event: tool_call) */
.vig-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.48rem;
}
.vig-tools:empty {
  display: none;
}
.vig-tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  padding: 0.16rem 0.52rem;
  border-radius: 999px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  color: #0550ae;
  font-size: 0.73rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vig-msg-content p {
  margin: 0.32rem 0;
}
.vig-msg-content p:first-child {
  margin-top: 0;
}
.vig-msg-content p:last-child {
  margin-bottom: 0;
}
.vig-msg-content h3,
.vig-msg-content h4 {
  margin: 0.55rem 0 0.25rem;
  font-size: 0.92rem;
  line-height: 1.3;
}
.vig-msg-content ul,
.vig-msg-content ol {
  margin: 0.32rem 0;
  padding-left: 1.25rem;
}
.vig-msg-content li {
  margin: 0.14rem 0;
}
.vig-code {
  margin: 0.42rem 0;
  padding: 0.55rem 0.65rem;
  border-radius: 7px;
  background: #0d1117;
  color: #e6edf3;
  font: 12px/1.42 ui-monospace, monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.vig-code code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.vig-file-link {
  display: inline-block;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0.04rem 0.32rem;
  color: #0969da;
}
.vig-msg-error {
  margin-top: 0.4rem;
  padding: 0.42rem 0.6rem;
  border-radius: 6px;
  background: #ffebe9;
  border: 1px solid #ff8182;
  color: #a40e26;
  font-size: 0.8rem;
  font-weight: 600;
}
.vig-streaming-cursor::after {
  content: "▍";
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  animation: blink 0.9s infinite;
}

/* Composer, chips rápidos y píldora de contexto */
.vig-composer {
  border-top: 1px solid var(--line);
  background: #ffffff;
  padding: 0.55rem 0.75rem 0.7rem;
  flex: none;
}
.vig-chips {
  display: flex;
  gap: 0.38rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.45rem;
}
.vig-chips::-webkit-scrollbar {
  display: none;
}
.vig-chip {
  flex: none;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.vig-chip:hover {
  background: #eef6ff;
  border-color: var(--accent);
  color: var(--accent);
}

.vig-ctx-bar {
  margin-bottom: 0.42rem;
}
.vig-ctx-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  margin: 0;
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  color: #0550ae;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  max-width: 100%;
}
.vig-ctx-pill.is-disabled {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}
.vig-ctx-pill input[type="checkbox"] {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}
.vig-ctx-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vig-form {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  margin: 0;
}
.vig-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  max-height: 120px;
  padding: 0.48rem 0.68rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: 0.9rem/1.4 system-ui, sans-serif;
  resize: none;
  background: #fbfcfe;
  color: var(--fg);
}
.vig-input:focus {
  outline: 2px solid rgba(31, 111, 235, 0.28);
  border-color: var(--accent);
  background: #ffffff;
}
.vig-btn-send,
.vig-btn-stop {
  flex: none;
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}
.vig-btn-stop {
  background: var(--err);
  color: #ffffff;
}

@media (max-width: 768px) {
  .vig-fab {
    display: none !important;
  }
  .vig-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    height: 88dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: vigSheetUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes vigSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .vig-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 0.42rem 0 0.1rem;
    background: #14181f;
    flex: none;
  }
  .vig-sheet-handle span {
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.3);
  }
  .vig-hdr-close {
    width: 38px;
    height: 38px;
  }
}



