/* Vista de archivos de gob.pe dentro del cuadro de vista previa (ver-archivo.php): Excel como tabla y tarjetas. */
@font-face { font-family: 'Montserrat'; font-weight: 500; font-display: swap; src: url('../../assets/fonts/montserrat-500.woff') format('woff'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-display: swap; src: url('../../assets/fonts/montserrat-700.woff') format('woff'); }

:root { --verde: #1F6B43; --verde-claro: #E3F4EA; --tinta: #26313a; --suave: #5A646C; --linea: #dfe5ea; --fondo: #f4f6f8; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body.vis { font: 500 14px/1.45 'Montserrat', system-ui, 'Segoe UI', Arial, sans-serif; color: var(--tinta); background: var(--fondo); min-height: 100vh; }

/* Barra de arriba del Excel */
.vis-barra { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--linea); }
.vis-barra__nombre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.vis-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--c); color: #fff; font-weight: 700; font-size: .75rem; letter-spacing: .02em; }

.vis-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1.5px solid var(--verde); color: var(--verde); background: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.vis-btn:hover { background: var(--verde-claro); }
.vis-btn--main { background: var(--verde); color: #fff; }
.vis-btn--main:hover { background: #18583A; }

/* Pestañas de las hojas */
.vis-pestanas { display: flex; gap: 6px; padding: 10px 14px 0; overflow-x: auto; background: var(--fondo); }
.vis-pestana { flex: none; padding: 8px 14px; border: 1px solid var(--linea); border-bottom: 0; border-radius: 10px 10px 0 0; background: #e9edf0; color: var(--suave); font: inherit; font-weight: 700; cursor: pointer; }
.vis-pestana.is-on { background: #fff; color: var(--verde); }

/* Hoja */
.vis-hoja { padding: 14px; }
.vis-hoja__titulo { margin: 0 0 4px; font-size: 1.05rem; line-height: 1.3; color: var(--verde); text-align: center; }
.vis-hoja__sub { margin: 0 0 6px; color: var(--suave); text-align: center; }
.vis-tabla { margin-top: 10px; overflow: auto; max-height: calc(100vh - 150px); background: #fff; border: 1px solid var(--linea); border-radius: 12px; }
.vis-tabla table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: .84rem; }
.vis-tabla th { position: sticky; top: 0; z-index: 1; background: var(--verde); color: #fff; text-align: left; font-weight: 700; padding: 10px 12px; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.18); }
.vis-tabla td { padding: 9px 12px; border-top: 1px solid var(--linea); border-right: 1px solid #eef1f4; vertical-align: top; white-space: nowrap; }
.vis-tabla td.largo { white-space: normal; min-width: 320px; max-width: 520px; }
.vis-tabla tbody tr:nth-child(even) td { background: #f8faf9; }
.vis-tabla tbody tr:hover td { background: var(--verde-claro); }
.vis-pie, .vis-vacio { margin: 10px 2px 0; color: var(--suave); font-size: .82rem; }

/* Tarjeta (Word, ZIP, error) */
.vis-tarjeta { margin: 40px auto; max-width: 440px; padding: 28px 24px; text-align: center; background: #fff; border: 1px solid var(--linea); border-radius: 16px; box-shadow: 0 10px 30px rgba(20, 40, 30, .08); }
.vis-tarjeta__ic { width: 74px; height: 88px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 10px; background: var(--c); color: #fff; font-weight: 700; font-size: 1rem; letter-spacing: .03em; position: relative; }
.vis-tarjeta__ic::after { content: ''; position: absolute; top: 0; right: 0; border-width: 0 18px 18px 0; border-style: solid; border-color: var(--fondo) var(--fondo) rgba(255,255,255,.35) rgba(255,255,255,.35); border-radius: 0 10px 0 4px; }
.vis-tarjeta__nombre { margin: 0; font-weight: 700; font-size: 1rem; word-break: break-word; }
.vis-tarjeta__meta { margin: 4px 0 0; color: var(--suave); font-size: .85rem; }
.vis-tarjeta__msg { margin: 14px 0 18px; color: var(--suave); }
.vis-tarjeta--error .vis-tarjeta__msg { color: #8a3a12; }
.vis-tarjeta__btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

@media (max-width: 560px) {
  .vis-barra { padding: 8px 10px; }
  .vis-barra .vis-btn { width: 100%; }
  .vis-hoja { padding: 10px; }
  .vis-tarjeta { margin: 20px 12px; }
}

/* =====================================================================
   Excel tal cual: cuadrícula con letras y números, como al abrirlo en Excel
   ===================================================================== */
/* Letras libres con las mismas medidas que las de Office, para que el texto ocupe lo mismo en cualquier equipo
   (Carlito = Calibri, Arimo = Arial, Archivo Narrow para Aptos Narrow / Arial Narrow). Licencia OFL en fuentes/. */
@font-face { font-family: 'XL Carlito'; font-weight: 400; font-display: swap; src: url('fuentes/carlito-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'XL Carlito'; font-weight: 700; font-display: swap; src: url('fuentes/carlito-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'XL Arimo'; font-weight: 400; font-display: swap; src: url('fuentes/arimo-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'XL Arimo'; font-weight: 700; font-display: swap; src: url('fuentes/arimo-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'XL Narrow'; font-weight: 400; font-display: swap; src: url('fuentes/archivo-narrow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'XL Narrow'; font-weight: 700; font-display: swap; src: url('fuentes/archivo-narrow-latin-700-normal.woff2') format('woff2'); }
body.vis--excel { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: #fff; }
.vis--excel .vis-barra { position: static; flex: none; }
.xl-zoom { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--linea); border-radius: 10px; background: #f6f8f7; }
.xl-zoom button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; font: 700 1.1rem/1 system-ui, sans-serif; color: var(--tinta); cursor: pointer; }
.xl-zoom button:hover { background: #e3ebe6; }
.xl-zoom output { min-width: 48px; text-align: center; font-size: .8rem; font-weight: 700; color: var(--suave); }
.xl-libro { flex: 1; min-height: 0; position: relative; background: #fff; }
.xl-area { position: absolute; inset: 0; overflow: auto; }
.xl-area[hidden] { display: none; }
.xl-aviso { position: sticky; left: 0; margin: 0; padding: 8px 12px; background: #fff6de; color: #7a4b00; font: 600 13px/1.4 'Montserrat', system-ui, sans-serif; border-bottom: 1px solid #f0dca8; }

table.xl { border-collapse: collapse; table-layout: fixed; background: #fff; color: #000; line-height: 1.2; }
table.xl td { border: 0; padding: 1px 3px; overflow: hidden; white-space: nowrap; vertical-align: bottom; text-overflow: clip;
  box-shadow: inset -1px -1px 0 #e1e1e1; }
table.xl.xl--sinrejilla td { box-shadow: none; }
table.xl td.xl-r { box-shadow: none; }
table.xl td.xl-i { text-align: left; }
table.xl td.xl-d { text-align: right; }
table.xl td.xl-c { text-align: center; }
/* Texto que se extiende sobre las celdas vacías de la derecha (como en Excel) */
table.xl td.xl-ov { overflow: visible; position: relative; z-index: 1; }
table.xl td.xl-ov > span { position: relative; z-index: 1; }

/* Encabezados de columnas (A, B, C…) y de filas (1, 2, 3…) */
table.xl thead th { position: sticky; top: 0; z-index: 4; height: 22px; padding: 0 2px; background: #f3f3f3; color: #444; border: 1px solid #d4d4d4;
  border-top: 0; font: 400 12px/22px 'Segoe UI', Arial, sans-serif; text-align: center; overflow: hidden; }
table.xl tbody th { position: sticky; left: 0; z-index: 3; padding: 0 4px; background: #f3f3f3; color: #444; border: 1px solid #d4d4d4; border-left: 0;
  font: 400 12px/1 'Segoe UI', Arial, sans-serif; text-align: center; vertical-align: middle; }
table.xl thead th.xl-esq { left: 0; z-index: 5; background: #e9e9e9; }
/* Filas inmovilizadas en el archivo: quedan fijas al bajar */
table.xl tr.xl-fija td, table.xl tr.xl-fija th { position: sticky; z-index: 2; background-clip: padding-box; }
table.xl tr.xl-fija td:not(.xl-r) { background-color: #fff; }
table.xl tr.xl-fija th { z-index: 4; }

/* Pestañas de hojas abajo, como en Excel */
.xl-pestanas { flex: none; display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; background: #f3f3f3; border-top: 1px solid #d4d4d4; }
.xl-pestanas .vis-pestana { margin: 0; padding: 7px 16px; border: 0; border-radius: 0 0 8px 8px; background: transparent; color: #444; font: 600 13px/1.2 'Segoe UI', Arial, sans-serif; }
.xl-pestanas .vis-pestana.is-on { background: #fff; color: #1d7a45; box-shadow: inset 0 -3px 0 #1d7a45; }
@media (max-width: 560px) {
  .vis--excel .vis-barra { gap: 8px; }
  .vis--excel .vis-barra__nombre { flex: 1 1 calc(100% - 80px); }
  .vis--excel .vis-barra .vis-btn { width: auto; flex: 1; min-height: 36px; padding: 6px 12px; }
  .xl-zoom { order: 3; }
}
