/* ============================================================
   NEODATO 3.0.0 — EXPEDIENTE (compartido)
   Estructura común de /diputado/{id} y /proyecto/{boletin}:
   carátula tipo carpeta, cifras, índice de folios y folios numerados.
   Depende de tokens.css y chrome.css. Prefijo .ex-
   ============================================================ */

[hidden] { display: none !important; }

main.ex { width: 100%; position: relative; z-index: 1; flex: 1; }
.ex-wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
nav.breadcrumbs { max-width: 1200px; padding: 0 24px; margin: 24px auto 0; }
.ex-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── ESTADOS DE CARGA / ERROR ───────────────────────── */
.ex-estado-pagina { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 96px 16px; }
.ex-estado-pagina h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; color: var(--ink); }
.ex-estado-pagina p { color: var(--text-secondary); font-size: 0.95rem; max-width: 440px; }
.ex-spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--bronze); animation: ex-giro 0.8s linear infinite; }
@keyframes ex-giro { to { transform: rotate(360deg); } }

/* ── CARÁTULA ───────────────────────────────────────── */
.ex-caratula { margin-top: 28px; }
.ex-pestana {
    display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 22px;
    background: var(--paper-strong); border-radius: 12px 12px 0 0;
    font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-soft);
}
.ex-pestana span { font-weight: 400; color: var(--text-secondary); letter-spacing: 0.04em; }
.ex-carpeta { position: relative; background: var(--paper-strong); border-radius: 0 28px 28px 28px; padding: 8px; }
.ex-carpeta-in {
    background: var(--paper-dim); border-radius: 22px; padding: 40px;
    display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start;
}
.ex-carpeta-in.con-foto { grid-template-columns: 200px minmax(0, 1fr) 300px; gap: 40px; }
.ex-foto {
    width: 200px; height: 240px; border-radius: 16px; background: #E9E6DE; overflow: hidden;
    display: flex; align-items: flex-end; justify-content: center;
}
.ex-foto { position: relative; }
.ex-foto img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.ex-foto-credito {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 10px 6px;
    font-family: var(--font-mono); font-size: 0.5625rem; letter-spacing: 0.02em; line-height: 1.3; color: #FFFFFF;
    background: linear-gradient(to bottom, rgba(11,11,10,0), rgba(11,11,10,0.6));
}
.ex-foto svg { width: 85%; height: auto; display: block; }
.ex-ident { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ex-eyebrow { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bronze-dark); }
.ex-h1 {
    font-family: var(--font-display); font-weight: 800; color: var(--ink);
    font-size: clamp(2.2rem, 1.3rem + 2.6vw, 3.75rem); line-height: 1.02; letter-spacing: -0.025em;
    overflow-wrap: anywhere;
}
.ex-h1.largo { font-size: clamp(1.55rem, 1.05rem + 1.7vw, 2.75rem); line-height: 1.12; letter-spacing: -0.02em; overflow-wrap: break-word; }
.ex-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.ex-chip {
    height: 32px; padding: 0 12px; border-radius: 999px; background: #FFFFFF; border: 1px solid rgba(11,11,10,0.10);
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; color: var(--text-primary); text-decoration: none;
    white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
a.ex-chip { transition: border-color var(--dur-base) var(--ease-out); }
a.ex-chip:hover { border-color: var(--bronze); color: var(--text-primary); }
.ex-chip.verde { background: var(--verde-botella-tint); color: var(--verde-botella); border-color: transparent; font-weight: 600; }
a.ex-chip.verde:hover { border-color: var(--verde-botella); color: var(--verde-botella); }
.ex-chip.etapa-chip { height: 32px; padding: 0 14px; font-size: 0.875rem; font-weight: 600; background: var(--etapa-bg, #F0EEE8); color: var(--etapa-fg, #5B5850); border-color: transparent; }
.ex-chip.etapa-chip.etapa-terminada { border-color: var(--border-strong); }
.ex-chip .ex-chip-extra { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }
.ex-meta { display: flex; gap: 6px 24px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); }
.ex-texto { font-size: 0.9375rem; line-height: 1.6; color: var(--text-secondary); max-width: 600px; }
.ex-texto strong { color: var(--text-primary); font-weight: 600; }

.ex-ley {
    display: flex; align-items: center; gap: 14px; max-width: 560px;
    background: var(--verde-botella-tint); border: 1px solid rgba(27,59,47,0.25); border-radius: 16px; padding: 14px 18px;
}
.ex-ley-icono { width: 36px; height: 36px; border-radius: 50%; background: var(--verde-botella); color: #FFFFFF; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ex-ley-nombre { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--verde-botella); }
.ex-ley-fecha { font-size: 0.8rem; color: var(--text-secondary); }

.ex-acciones { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ex-aviso {
    padding: 14px 16px; border-radius: 12px; background: #FFFFFF; border: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.4;
}
.ex-aviso::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--verde-botella); flex-shrink: 0; }
.ex-aviso strong { color: var(--text-primary); font-weight: 600; }
.ex-btn-neobot {
    height: 50px; border-radius: 999px; background: var(--verde-botella); color: #FFFFFF; text-decoration: none; white-space: nowrap;
    font-size: 0.875rem; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px;
    transition: background var(--dur-base) var(--ease-out);
}
.ex-btn-neobot:hover { background: var(--verde-botella-dark); color: #FFFFFF; }
.ex-sello-neobot {
    width: 28px; height: 28px; border-radius: 50%; background: var(--bronze-tint); color: var(--ink); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; text-align: center;
    font-family: var(--font-display); font-weight: 700; font-size: 9px; line-height: 0.9;
}
.ex-btn-fila { display: flex; gap: 10px; }
.ex-btn {
    flex: 1 1 0; min-width: 0; height: 46px; border-radius: 999px; border: 1px solid rgba(11,11,10,0.16); background: #FFFFFF;
    color: var(--text-primary); text-decoration: none; font-family: var(--font-sans); font-size: 0.875rem; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; white-space: nowrap; padding: 0 12px;
    transition: border-color var(--dur-base) var(--ease-out);
}
.ex-btn:hover { border-color: var(--bronze); color: var(--text-primary); }
.ex-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.ex-btn.pronto { border-style: dashed; border-color: rgba(11,11,10,0.22); color: var(--text-secondary); cursor: default; }
.ex-btn.pronto:hover { border-color: rgba(11,11,10,0.22); }
.ex-btn.pronto small { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bronze-dark); }
.ex-btn:focus-visible, .ex-btn-neobot:focus-visible, .ex-indice a:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }


/* ── CIFRAS ─────────────────────────────────────────── */
.ex-cifras { margin-top: 32px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ex-cifra { border: 1px solid var(--border); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow: hidden; background: #FFFFFF; }
.ex-cifra-t { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--verde-botella); }
.ex-cifra-v { font-family: var(--font-mono); font-weight: 500; font-size: clamp(1.9rem, 1.2rem + 1.4vw, 2.75rem); letter-spacing: -0.04em; line-height: 1; color: var(--ink); white-space: nowrap; }
.ex-cifra-s { font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.ex-barras { display: flex; flex-direction: column; gap: 6px; }
/* Si la etiqueta no cabe al lado de la barra, baja a la línea siguiente (no se sale de la tarjeta) */
.ex-barra { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; font-size: 0.75rem; color: var(--text-primary); min-width: 0; }
.ex-barra span { white-space: nowrap; }
.ex-barra i { display: block; height: 8px; border-radius: 999px; background: var(--verde-botella); flex: 0 0 auto; min-width: 4px; }
.ex-barra.ref { color: var(--text-secondary); }
.ex-barra.ref i { background: #D6D2C7; }

/* ── ÍNDICE DE FOLIOS (fijo al hacer scroll) ────────── */
.ex-indice {
    position: sticky; top: 68px; z-index: 20; margin-top: 40px;
    background: rgba(255,255,255,0.96); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border-top: 1px solid rgba(11,11,10,0.10); border-bottom: 1px solid rgba(11,11,10,0.10);
    display: flex; align-items: center; gap: 8px; height: 60px;
}
.ex-indice-links { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.ex-indice-links::-webkit-scrollbar { display: none; }
.ex-indice a {
    height: 40px; padding: 0 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
    text-decoration: none; font-size: 0.875rem; font-weight: 600; color: var(--text-primary); white-space: nowrap;
    transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.ex-indice a span { font-family: var(--font-mono); font-size: 11px; opacity: 0.7; }
.ex-indice a:hover { background: var(--paper-strong); color: var(--text-primary); }
.ex-indice a.activo { background: var(--ink); color: var(--text-on-ink); }
.ex-indice-nota { margin-left: auto; padding-left: 16px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }

/* ── FOLIOS ─────────────────────────────────────────── */
.ex-folio { padding-top: 64px; scroll-margin-top: 136px; }
.ex-folio.primero { padding-top: 56px; }
.ex-folio-h { display: flex; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.ex-folio-n { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--bronze-dark); }
.ex-folio-h h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 1.25rem + 0.9vw, 2.125rem); line-height: 1.15; color: var(--ink); }
.ex-folio-aux { margin-left: auto; font-size: 0.875rem; color: var(--text-secondary); }
.ex-cuerpo { margin-top: 24px; }
.ex-card { border: 1px solid var(--border); border-radius: 20px; padding: 28px; min-width: 0; background: #FFFFFF; }
.ex-grid-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ex-grid-par { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.ex-grid-par > div { min-width: 0; }
.ex-final { height: 96px; }

.ex-filas { display: flex; flex-direction: column; gap: 14px; }
.ex-fila { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--paper-strong); }
.ex-fila:last-child { border-bottom: none; padding-bottom: 0; }
.ex-fila > span:first-child { font-size: 0.9375rem; color: var(--text-secondary); }
.ex-fila > span:last-child { font-family: var(--font-mono); font-weight: 600; font-size: 1rem; color: var(--text-primary); text-align: right; }
.ex-fila a { color: var(--verde-botella); }
.ex-fila a:hover { color: var(--bronze-dark); }
.ex-fila small { font-family: var(--font-mono); font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }
.ex-rotulo { display: block; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--verde-botella); }
.ex-nota { font-size: 0.8125rem; line-height: 1.55; color: var(--text-secondary); }
.ex-nota strong { color: var(--text-primary); font-weight: 600; }
.ex-vacio { font-size: 0.875rem; color: var(--text-secondary); border: 1px dashed var(--border-strong); border-radius: 12px; padding: 14px 16px; }
.ex-estado-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.ex-estado-chip.abierto { background: var(--bronze-tint); color: var(--bronze-dark); }
.ex-estado-chip.ley { background: var(--verde-botella); color: #FFFFFF; }
.ex-estado-chip.archivado { background: #FBE7DF; color: #B8481F; }
.ex-estado-chip.terminada { background: #FFFFFF; color: var(--text-secondary); border: 1px solid var(--border-strong); }

/* Línea de tiempo vertical (historial, trayectoria) */
.ex-tl-item { display: flex; gap: 18px; }
.ex-tl-marca { display: flex; flex-direction: column; align-items: center; width: 14px; flex-shrink: 0; }
.ex-tl-punto { width: 12px; height: 12px; border-radius: 50%; background: var(--bronze); margin-top: 3px; flex-shrink: 0; box-sizing: border-box; }
.ex-tl-linea { flex: 1; width: 2px; background: var(--paper-strong); margin: 4px 0; }
.ex-tl-item:last-child .ex-tl-linea { display: none; }
.ex-tl-cuerpo { flex: 1; min-width: 0; padding-bottom: 20px; }
.ex-tl-fecha { font-family: var(--font-mono); font-size: 0.75rem; color: var(--bronze-dark); }
.ex-tl-titulo { margin-top: 4px; font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.ex-tl-desc { margin-top: 4px; font-size: 0.9375rem; line-height: 1.45; color: var(--text-primary); }
.ex-tl-sub { margin-top: 2px; font-size: 0.875rem; line-height: 1.45; color: var(--text-secondary); }

/* Filtros tipo píldora y paginación */
.ex-filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.ex-filtro {
    height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(11,11,10,0.12); background: #FFFFFF; cursor: pointer;
    font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600; color: var(--text-primary);
    display: inline-flex; align-items: center; gap: 8px; transition: all var(--dur-base) var(--ease-out);
}
.ex-filtro span { font-family: var(--font-mono); font-weight: 500; font-size: 0.75rem; color: var(--text-muted); }
.ex-filtro:hover { border-color: var(--bronze); }
.ex-filtro[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--text-on-ink); }
.ex-filtro[aria-pressed="true"] span { color: #C9C3B6; }
.ex-filtro:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }
.ex-pag { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 20px; }
.ex-pag button {
    height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: #FFFFFF; cursor: pointer;
    font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600; color: var(--text-primary);
}
.ex-pag button:hover:not([disabled]) { border-color: var(--bronze); }
.ex-pag button[disabled] { opacity: 0.4; cursor: not-allowed; }
.ex-pag span { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); }
.ex-cargando { opacity: 0.5; transition: opacity var(--dur-base) var(--ease-out); }

/* Chips de sentido de voto (neutros: sin rojo) */
.ex-voto { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.ex-voto.afirmativo { background: var(--verde-botella-tint); color: var(--verde-botella); }
.ex-voto.en_contra { background: var(--azul-voto-tint); color: var(--azul-voto); }
.ex-voto.abstencion { background: var(--bronze-tint); color: var(--bronze-dark); }
.ex-voto.no_vota, .ex-voto.dispensado { background: var(--paper-strong); color: var(--text-secondary); }

/* Modal genérico */
.ex-modal { position: fixed; inset: 0; z-index: 1100; background: rgba(11,11,10,0.5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.ex-modal[hidden] { display: none !important; }
.ex-modal-caja { position: relative; width: 100%; max-width: 680px; max-height: 85vh; overflow-y: auto; background: #FFFFFF; border-radius: 20px; box-shadow: var(--shadow-lg); }
.ex-modal-cab { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; background: #FFFFFF; border-bottom: 1px solid var(--border); }
.ex-modal-cab h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.ex-modal-cerrar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: #FFFFFF; font-size: 1.2rem; line-height: 1; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; }
.ex-modal-cerrar:hover { border-color: var(--bronze); color: var(--ink); }
.ex-modal-cuerpo { padding: 20px 24px 24px; }
body.ex-modal-abierto { overflow: hidden; }

/* Tablas de datos dentro de modales */
table.ex-tabla { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.ex-tabla th { text-align: left; font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding: 0 10px 10px; border-bottom: 1px solid var(--border-strong); }
table.ex-tabla td { padding: 11px 10px; border-bottom: 1px solid var(--border); }
table.ex-tabla tr:last-child td { border-bottom: none; }
table.ex-tabla .num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
table.ex-tabla tfoot td { font-family: var(--font-mono); font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: none; }

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 1280px) {
    .ex-cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .ex-carpeta-in, .ex-carpeta-in.con-foto { grid-template-columns: minmax(0, 1fr); gap: 28px; }
    .ex-carpeta-in.con-foto { grid-template-columns: 160px minmax(0, 1fr); }
    .ex-carpeta-in.con-foto .ex-acciones { grid-column: 1 / -1; }
    .ex-foto { width: 160px; height: 192px; }
    .ex-acciones { flex-direction: row; flex-wrap: wrap; }
    .ex-acciones .ex-aviso { flex: 1 1 100%; }
    .ex-acciones .ex-btn-neobot { flex: 1 1 280px; }
    .ex-acciones .ex-btn-fila { flex: 1 1 280px; }
    .ex-grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
    nav.breadcrumbs { padding: 0 20px; margin-top: 16px; }
    .ex-wrap { padding: 0 20px; }
    .ex-caratula { margin-top: 20px; }
    .ex-pestana { height: 36px; padding: 0 16px; font-size: 0.75rem; }
    .ex-carpeta { border-radius: 0 20px 20px 20px; padding: 6px; }
    .ex-carpeta-in { padding: 24px 20px; border-radius: 16px; }
    .ex-carpeta-in.con-foto { grid-template-columns: 88px minmax(0, 1fr); gap: 20px 16px; }
    .ex-foto { width: 88px; height: 106px; border-radius: 12px; }
    .ex-foto-credito { display: none; }
    .ex-chip .ex-chip-extra { display: none; }
    .ex-cifras { gap: 12px; margin-top: 20px; }
    .ex-cifra { padding: 18px; gap: 10px; border-radius: 16px; }
    .ex-cifra-t { font-size: 0.6875rem; letter-spacing: 0.08em; }
    .ex-indice { top: 64px; margin-top: 28px; height: 56px; margin-left: -20px; margin-right: -20px; padding: 0 12px; }
    .ex-indice-nota { display: none; }
    .ex-indice a { height: 36px; padding: 0 12px; }
    .ex-folio { padding-top: 48px; scroll-margin-top: 124px; }
    .ex-folio.primero { padding-top: 40px; }
    .ex-folio-aux { margin-left: 0; flex-basis: 100%; }
    .ex-cuerpo { margin-top: 18px; }
    .ex-card { padding: 20px; border-radius: 16px; }
    .ex-grid-par { grid-template-columns: minmax(0, 1fr); }
    .ex-final { height: 64px; }
    .ex-modal { padding: 12px; align-items: flex-end; }
    .ex-modal-caja { max-height: 88vh; border-radius: 16px; }
}
@media (max-width: 480px) {
    .ex-pestana span { display: none; }
    .ex-cifras { grid-template-columns: minmax(0, 1fr); }
    .ex-carpeta-in.con-foto { grid-template-columns: 72px minmax(0, 1fr); }
    .ex-foto { width: 72px; height: 88px; }
    .ex-acciones .ex-btn-neobot, .ex-acciones .ex-btn-fila { flex-basis: 100%; }
}
