*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primario: #1b3a6b;
  --azul: #1b3a6b;
  --azul-hover: #2a4e86;
  --gris: #6c757d;
  --fondo: #f8f9fa;
  --blanco: #ffffff;
  --borde: #dee2e6;
  --texto: #212529;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body { font-family: var(--font); background: var(--fondo); color: var(--texto); min-height: 100vh; display: flex; flex-direction: column; }

/* ── HEADER ── */
header { background: var(--color-primario); color: var(--blanco); padding: 1rem 2rem; box-sizing: border-box; }
.header-brand { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.header-logo-link { display: inline-flex; flex-shrink: 0; transition: opacity .15s, transform .15s; }
.header-logo-link:hover { opacity: .85; transform: scale(1.02); }
.header-logo { height: 54px; width: auto; display: block; }
.header-brand-text { display: flex; flex-direction: column; gap: .1rem; }
header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: .5px; line-height: 1.1; }
header p.subtitulo { font-size: .85rem; opacity: .8; margin-top: .1rem; }
nav { margin-top: .6rem; display: flex; gap: 1.2rem; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
nav::-webkit-scrollbar { display: none; width: 0; height: 0; }
nav a { color: rgba(255,255,255,.75); text-decoration: none; font-size: .9rem; padding-bottom: 2px; border-bottom: 2px solid transparent; transition: all .2s; flex-shrink: 0; white-space: nowrap; }
nav a:hover, nav a.activo { color: var(--blanco); border-bottom-color: var(--blanco); }
nav a.nav-pro-highlight { color: #1b3a6b !important; background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); padding: 3px 11px; border-radius: 999px; font-weight: 600; border: 1px solid #fbbf24; box-shadow: 0 2px 8px rgba(251,191,36,.35); margin-top: -2px; padding-bottom: 3px; transition: transform .2s, box-shadow .2s; }
nav a.nav-pro-highlight:hover { color: #78350f !important; border-bottom-color: transparent; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(251,191,36,.5); background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%); }
nav a.nav-pro-highlight .nav-pro-sparkle { display: inline-block; animation: nav-pro-shine 2.5s ease-in-out infinite; margin-right: 1px; }
@keyframes nav-pro-shine { 0%, 100% { opacity: .6; transform: scale(1); } 50% { opacity: 1; transform: scale(1.2) rotate(14deg); } }
@media (max-width: 600px) {
  .header-logo { height: 42px; }
  header h1 { font-size: 1.3rem; }
  header p.subtitulo { font-size: .78rem; }
}

/* ── LAYOUT ── */
.container { display: flex; flex: 1; max-width: 1200px; width: 100%; margin: 1.5rem auto; padding: 0 1rem; gap: 1.5rem; }

/* ── PANEL IZQUIERDO ── */
.sidebar { width: 280px; min-width: 220px; flex-shrink: 0; background: var(--blanco); border: 1px solid var(--borde); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.sidebar-header { padding: .8rem 1rem; background: var(--azul); color: var(--blanco); font-size: .85rem; font-weight: 600; }

.ley-tabs { display: flex; border-bottom: 1px solid var(--borde); }
.ley-tab { flex: 1; padding: .5rem .4rem; background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--gris); transition: all .15s; line-height: 1.25; }
.ley-tab:hover { background: var(--fondo); color: var(--azul); }
.ley-tab.activo { color: var(--azul); border-bottom-color: var(--azul); }
.ley-count { display: inline-block; font-size: .7rem; color: var(--gris); font-weight: 500; margin-left: .15rem; }
.ley-tab.activo .ley-count { color: var(--azul); }

.sidebar-filtro { padding: .5rem .75rem; border-bottom: 1px solid var(--borde); background: var(--fondo); }
.sidebar-filtro input { width: 100%; padding: .4rem .6rem; font-size: .82rem; border: 1px solid var(--borde); border-radius: 4px; font-family: var(--font); }
.sidebar-filtro input:focus { outline: 2px solid var(--azul); outline-offset: -1px; }

#lista-articulos { flex: 1; overflow-y: auto; max-height: calc(100vh - 320px); padding: .4rem 0; }
.art-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: .45rem 1rem; font-size: .85rem; cursor: pointer; color: var(--texto); border-left: 3px solid transparent; transition: all .1s; }
.art-item:hover { background: var(--fondo); color: var(--azul); }
.art-item.activo { background: #e8f0fb; color: var(--azul); border-left-color: var(--azul); font-weight: 600; }
.art-item-num { display: block; font-weight: 600; }
.art-item-enun { display: block; font-size: .72rem; color: var(--gris); font-variant: small-caps; text-transform: lowercase; letter-spacing: .3px; line-height: 1.2; margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-item.activo .art-item-enun { color: var(--azul); opacity: .75; }

.art-item-derogado { opacity: .55; }
.art-item-derogado .art-item-num { text-decoration: line-through; text-decoration-color: rgba(108,117,125,.5); }
.art-item-derogado .art-item-enun { font-style: italic; }
.art-item-derogado:hover { opacity: .85; }

.badge-derogado { display: inline-block; font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: .08rem .32rem; border-radius: 3px; background: #f8d7da; color: #842029; border: 1px solid #f1aeb5; vertical-align: middle; margin-left: .3rem; font-variant: normal; }
.badge-derogado-grande { font-size: .72rem; padding: .18rem .55rem; margin-left: .5rem; }

.contenido-derogado #articulo-body { opacity: .75; }

.art-group-header { display: flex; align-items: center; gap: .4rem; width: 100%; text-align: left; background: var(--fondo); border: none; border-top: 1px solid var(--borde); border-bottom: 1px solid var(--borde); padding: .5rem 1rem; font-size: .78rem; font-weight: 700; color: var(--gris); text-transform: uppercase; letter-spacing: .5px; cursor: pointer; }
.art-group-header:hover { color: var(--azul); }
.art-group-flecha { font-size: .6rem; color: var(--gris); }
.art-group-count { font-weight: 500; font-size: .7rem; margin-left: auto; }
.art-group-body { background: #fafbfc; }
.art-item-transitorio { padding-left: 1.5rem; }

/* ── PANEL DERECHO ── */
.content { flex: 1; background: var(--blanco); border: 1px solid var(--borde); border-radius: 6px; padding: 1.5rem 2rem; overflow-y: auto; }
.content-placeholder { color: var(--gris); font-size: .95rem; margin-top: 2rem; text-align: center; }

.art-header { margin-bottom: 1.2rem; border-bottom: 1px solid var(--borde); padding-bottom: .75rem; }
.art-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.art-header-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.reading-controls { display: inline-flex; gap: 2px; border: 1px solid var(--borde); border-radius: 18px; padding: 3px; background: var(--fondo); }
.reading-controls .rc-btn { border: none; background: transparent; width: 32px; height: 30px; border-radius: 14px; cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--gris); display: inline-flex; align-items: center; justify-content: center; transition: background .18s, color .18s, transform .12s; padding: 0; line-height: 1; }
.reading-controls .rc-btn:hover { background: var(--blanco); color: var(--azul); }
.reading-controls .rc-btn:active { transform: scale(.88); }
.reading-controls .rc-btn.rc-btn-activo { background: var(--azul); color: var(--blanco); }
.reading-controls .rc-btn.rc-btn-flash { animation: rcFlash .18s ease-out; }
@keyframes rcFlash { 0% { transform: scale(1); } 50% { transform: scale(1.15); background: var(--azul); color: var(--blanco); } 100% { transform: scale(1); } }
#articulo-titulo { font-size: 1.5rem; font-weight: 700; color: var(--azul); margin-bottom: .25rem; line-height: 1.2; }
.art-enunciado { font-variant: small-caps; text-transform: lowercase; color: var(--gris); font-size: 1rem; letter-spacing: .5px; margin-bottom: .4rem; font-weight: 500; }
.art-enunciado:empty { display: none; }
#articulo-body { font-size: .93rem; line-height: 1.7; transition: font-size .15s; text-align: justify; hyphens: auto; }
#articulo-body p { margin-bottom: 1rem; text-indent: 1.8em; }
#articulo-body p:first-child { text-indent: 0; }
#articulo-body h1, #articulo-body h2 { display: none; }
#articulo-body blockquote { color: var(--gris); font-size: .8rem; font-style: italic; border-left: 2px solid var(--borde); padding-left: .7rem; margin: .6rem 0; }
#articulo-body pre, #articulo-body code { background: transparent; font-family: inherit; font-size: inherit; white-space: pre-wrap; }
#articulo-body pre { padding: 0; margin: 0; }
#articulo-body.espaciado-aireado { line-height: 2.05; }
#articulo-body.espaciado-aireado p { margin-bottom: 1.6rem; }
.content.ancho-angosto #articulo-body { max-width: 62ch; margin-left: auto; margin-right: auto; }

/* Indice interno (TOC) del articulo — sticky al scroll */
.art-toc-wrap { position: -webkit-sticky; position: sticky; top: 0; z-index: 5; margin-bottom: 1.2rem; text-indent: 0; }
.art-toc { background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; transition: box-shadow .2s; }
.art-toc[open] { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.art-toc-summary { cursor: pointer; list-style: none; padding: .55rem .9rem; display: flex; align-items: center; gap: .6rem; font-size: .85rem; font-weight: 600; color: var(--azul); user-select: none; background: var(--fondo); }
.art-toc-summary::-webkit-details-marker { display: none; }
.art-toc-summary:hover { background: #e8f0fb; }
.art-toc-icon { font-size: 1rem; transition: transform .2s; }
.art-toc[open] .art-toc-icon { transform: rotate(90deg); }
.art-toc-count { margin-left: auto; color: var(--gris); font-size: .78rem; font-weight: 500; }
.art-toc[open] .art-toc-summary { border-bottom: 1px solid var(--borde); }
.art-toc-list { list-style: none; padding: .4rem 0; margin: 0; max-height: 55vh; overflow-y: auto; background: var(--blanco); }
.art-toc-list li { margin: 0; }
.art-toc-link { display: block; padding: .4rem .9rem .4rem 1.8rem; font-size: .82rem; color: var(--texto); text-decoration: none; border-left: 2px solid transparent; transition: all .12s; text-indent: 0; }
.art-toc-link:hover { background: var(--fondo); border-left-color: var(--azul); color: var(--azul); }
.art-toc-link.art-toc-activa { background: #e8f0fb; border-left-color: var(--azul); color: var(--azul); font-weight: 600; }
.art-toc-link strong { color: var(--azul); margin-right: .4rem; }
.art-toc-resumen { color: var(--gris); font-weight: normal; }

.art-seccion { scroll-margin-top: 20px; }
.art-seccion-flash { animation: seccionFlash 1.2s ease-out; }
@keyframes seccionFlash { 0% { background: rgba(255, 235, 59, .4); } 100% { background: transparent; } }

/* Boton flotante subir */
.content { position: relative; }
.art-btn-subir { position: sticky; bottom: 1rem; margin-left: calc(100% - 3rem); float: right; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--borde); background: var(--blanco); color: var(--azul); font-size: 1.2rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.1); opacity: 0; pointer-events: none; transition: opacity .2s, transform .15s; z-index: 10; }
.art-btn-subir.visible { opacity: 1; pointer-events: auto; }
.art-btn-subir:hover { background: var(--azul); color: var(--blanco); transform: translateY(-2px); }

.art-docs-panel { margin-top: 1.5rem; border-top: 1px solid var(--borde); padding-top: .5rem; }
.art-docs-toggle { width: 100%; display: flex; align-items: center; gap: .5rem; background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; padding: .6rem .9rem; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--azul); text-align: left; transition: all .15s; }
.art-docs-toggle:hover { background: #e8f0fb; border-color: var(--azul); }
.art-docs-flecha { font-size: .7rem; color: var(--azul); transition: transform .15s; min-width: 1rem; }
.art-docs-label { flex: 1; }
.art-docs-count { color: var(--gris); font-weight: 500; font-size: .82rem; }
.art-docs-filtros { display: flex; gap: .35rem; margin-top: .6rem; flex-wrap: wrap; }
.docs-filtro-chip { background: var(--fondo); border: 1px solid var(--borde); border-radius: 14px; padding: .25rem .7rem; font-size: .78rem; color: var(--gris); cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: .3rem; }
.docs-filtro-chip:hover { background: var(--blanco); color: var(--azul); border-color: var(--azul); }
.docs-filtro-chip.activo { background: var(--azul); color: var(--blanco); border-color: var(--azul); }
.chip-count { font-size: .7rem; opacity: .8; }

.art-docs-lista { margin-top: .6rem; display: flex; flex-direction: column; gap: .5rem; animation: docsFadeIn .25s ease-out; }
@keyframes docsFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.doc-rel-item { background: var(--blanco); border: 1px solid var(--borde); border-radius: 8px; padding: .7rem .9rem; font-size: .85rem; transition: border-color .15s, box-shadow .15s; }
.doc-rel-item:hover { border-color: var(--azul); box-shadow: 0 2px 6px rgba(26,58,92,.08); }
.doc-rel-head { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .3rem; }
.doc-rel-num { color: var(--azul); font-size: .9rem; }
.doc-rel-fecha { font-size: .78rem; color: var(--gris); }
.doc-rel-link { margin-left: auto; font-size: .78rem; color: var(--azul); text-decoration: none; padding: .15rem .5rem; border: 1px solid var(--azul); border-radius: 3px; }
.doc-rel-link:hover { background: var(--azul); color: var(--blanco); }
.doc-rel-materia { color: var(--texto); margin-bottom: .25rem; font-weight: 500; }
.doc-rel-criterio { color: var(--gris); font-size: .8rem; line-height: 1.5; font-style: italic; }
.doc-rel-item-clickeable { cursor: pointer; }
.doc-rel-item-clickeable:hover { background: #f0f6ff; transform: translateX(2px); }
.doc-rel-score { font-size: .7rem; color: var(--gris); margin-top: .3rem; font-style: italic; padding-left: .5rem; }

/* Vista de documento (A7) */
#documento-content { animation: docFadeIn .25s ease-out; }
@keyframes docFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.doc-back-btn { background: none; border: 1px solid var(--borde); color: var(--azul); padding: .35rem .7rem; border-radius: 6px; cursor: pointer; font-size: .85rem; margin-bottom: 1rem; transition: all .15s; }
.doc-back-btn:hover { background: var(--azul); color: var(--blanco); border-color: var(--azul); }
.doc-view-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; padding-bottom: .6rem; border-bottom: 1px solid var(--borde); }
.doc-view-head h2 { font-size: 1.4rem; color: var(--azul); margin: 0; flex: 1; min-width: 0; }
#doc-view-fecha { font-size: .82rem; color: var(--gris); }
.doc-view-materia { font-size: 1rem; color: var(--texto); margin: .6rem 0 .4rem; font-weight: 500; }
.doc-view-criterio { font-size: .88rem; color: var(--gris); font-style: italic; line-height: 1.6; padding: .7rem .9rem; background: var(--fondo); border-left: 3px solid var(--azul); border-radius: 4px; margin-bottom: 1rem; }
.doc-view-criterio:empty { display: none; }
.doc-view-url { display: inline-block; font-size: .82rem; color: var(--azul); text-decoration: none; padding: .25rem .7rem; border: 1px solid var(--azul); border-radius: 4px; margin-bottom: 1.2rem; }
.doc-view-url:hover { background: var(--azul); color: var(--blanco); }

.doc-section { margin-top: 1.5rem; }
.doc-section-titulo { font-size: .95rem; font-weight: 600; color: var(--azul); margin-bottom: .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--borde); }

.doc-citados-lista { display: flex; flex-wrap: wrap; gap: .4rem; }
.doc-cit-btn { background: var(--fondo); border: 1px solid var(--borde); border-radius: 16px; padding: .35rem .8rem; cursor: pointer; font-size: .82rem; color: var(--azul); display: inline-flex; gap: .35rem; align-items: center; transition: all .15s; }
.doc-cit-btn:hover { background: var(--azul); color: var(--blanco); border-color: var(--azul); transform: translateY(-1px); }
.doc-cit-btn .doc-cit-ley { font-weight: 700; font-size: .72rem; opacity: .75; }
.doc-cit-btn:hover .doc-cit-ley { opacity: 1; }

.doc-relacionados-lista { display: flex; flex-direction: column; gap: .5rem; }

@media (max-width: 700px) {
  .doc-view-head { flex-direction: column; align-items: flex-start; }
  .doc-view-head h2 { font-size: 1.2rem; }
  .doc-cit-btn { font-size: .78rem; padding: .3rem .65rem; }
}

.art-meta-footer { font-size: .75rem; color: var(--gris); margin-top: 1.2rem; padding-top: .75rem; border-top: 1px dashed var(--borde); line-height: 1.5; }
.art-meta-footer:empty { display: none; }
.art-meta-footer a { color: var(--gris); text-decoration: underline; }
.art-meta-footer a:hover { color: var(--azul); }

.btn-ver-bcn { display: inline-block; font-size: .75rem; padding: .3rem .7rem; border: 1px solid var(--azul); color: var(--azul); background: var(--blanco); border-radius: 999px; text-decoration: none; font-weight: 600; white-space: nowrap; transition: all .15s; }
.btn-ver-bcn:hover { background: var(--azul); color: var(--blanco); }

.art-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--borde); }
.art-nav button { padding: .4rem .9rem; background: var(--blanco); border: 1px solid var(--borde); border-radius: 4px; font-size: .85rem; color: var(--azul); cursor: pointer; font-weight: 500; transition: all .15s; }
.art-nav button:hover:not(:disabled) { background: var(--fondo); border-color: var(--azul); }
.art-nav button:disabled { opacity: .4; cursor: not-allowed; }
.art-pos { font-size: .78rem; color: var(--gris); }

.loading { color: var(--gris); font-style: italic; font-size: .9rem; }
.error-msg { color: #dc3545; font-size: .9rem; }

/* ── FOOTER ── */
footer { background: var(--color-primario); color: rgba(255,255,255,.7); font-size: .75rem; text-align: center; padding: 1.5rem 1rem; margin-top: auto; line-height: 1.7; display: flex; flex-direction: column; align-items: center; gap: .8rem; }
footer a { color: rgba(255,255,255,.85); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
footer a:hover { border-bottom-color: rgba(255,255,255,.85); }
.footer-watermark-link { display: inline-block; transition: opacity .15s, transform .15s; margin-bottom: .3rem; }
.footer-watermark-link:hover { opacity: 1; transform: scale(1.02); }
.footer-watermark { max-width: 260px; width: auto; height: auto; opacity: .92; display: block; }
.footer-watermark-link:hover .footer-watermark { opacity: 1; }
.footer-texts { max-width: 900px; }
.footer-autor { font-weight: 600; color: rgba(255,255,255,.95) !important; }
.footer-cobertura { display: inline-block; font-size: .72rem; color: rgba(255,255,255,.55); margin-top: .2rem; font-style: italic; }
.footer-email { color: rgba(255,255,255,.92) !important; font-weight: 500; }
.footer-email:hover { color: #fff !important; }

/* Powered by Claude — badge sitewide */
.footer-powered { display: inline-flex; align-items: center; gap: 6px; margin-top: .45rem; padding: 3px 11px; font-size: .75rem; color: rgba(255,255,255,.82) !important; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; text-decoration: none; transition: background .15s, border-color .15s; }
.footer-powered:hover { background: rgba(204,155,122,.18); border-color: rgba(204,155,122,.55); color: #fff !important; }
.footer-powered strong { font-weight: 600; color: #ffd0b0; }
.claude-dot { width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffd6b8, #cc9b7a 60%, #8b5a3c); box-shadow: 0 0 0 1px rgba(255,214,184,.25), 0 0 8px rgba(204,155,122,.4); }
.footer-copyright { display: inline-block; font-size: .7rem; color: rgba(255,255,255,.5); margin-top: .5rem; letter-spacing: .3px; }

/* ── STATS BANNER (entre tabs y newsletter) ── */
.stats-banner { max-width: 1200px; width: 100%; margin: .6rem auto 0; padding: 0 1rem; display: flex; align-items: center; justify-content: center; gap: .55rem; font-size: .85rem; color: var(--gris); font-weight: 500; letter-spacing: .1px; }
.stats-banner-icon { font-size: 1rem; opacity: .85; }
#stats-banner-text { color: var(--texto); }
#stats-banner-text strong { color: var(--azul); font-weight: 700; font-size: .95rem; }

/* ── NEWSLETTER BANNER (entre tabs y cuerpo) ── */
.newsletter-banner { max-width: 1200px; width: 100%; margin: .75rem auto 0; padding: 0 1rem; }
.newsletter-banner.oculto { display: none; }
.newsletter-content { background: var(--color-primario); border: 1px solid var(--color-primario); color: #fff; padding: .55rem .95rem; border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: .75rem; flex-wrap: wrap; position: relative; font-size: .82rem; }
.newsletter-icon { font-size: 1rem; }
.newsletter-text { max-width: 620px; line-height: 1.4; color: rgba(255,255,255,.9); }
.newsletter-btn { background: #fff; color: var(--color-primario); padding: .28rem .75rem; border-radius: 14px; text-decoration: none; font-weight: 600; font-size: .78rem; transition: transform .15s, box-shadow .15s; white-space: nowrap; }
.newsletter-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.newsletter-cerrar { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: rgba(255,255,255,.65); font-size: 1.15rem; cursor: pointer; padding: 0 .45rem; line-height: 1; border-radius: 50%; transition: background .15s, color .15s; }
.newsletter-cerrar:hover { color: #fff; background: rgba(255,255,255,.12); }

/* ── BOTON FLOTANTE SUBIR (site-wide) ── */
.btn-subir-global { position: fixed; bottom: 1.5rem; right: 1.5rem; width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--azul); color: #fff; font-size: 1.2rem; font-weight: 700; cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,.15); opacity: 0; pointer-events: none; transition: opacity .25s, transform .15s; z-index: 100; }
.btn-subir-global.visible { opacity: 1; pointer-events: auto; }
.btn-subir-global:hover { background: var(--azul-hover); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.2); }
@media (max-width: 700px) {
  .btn-subir-global { bottom: 1rem; right: 1rem; width: 40px; height: 40px; }
  .newsletter-content { font-size: .78rem; padding-right: 2rem; }
}

/* ── MAIN TABS ── */
.main-tabs { display: flex; background: var(--blanco); border-bottom: 2px solid var(--borde); max-width: 1200px; width: 100%; margin: 1rem auto 0; padding: 0 1rem; }
.main-tab { padding: .7rem 1.4rem; background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--gris); margin-bottom: -2px; transition: all .15s; }
.main-tab:hover { color: var(--azul); }
.main-tab.activo { color: var(--azul); border-bottom-color: var(--azul); }

/* ── CHATBOT ── */
.chat-wrapper { flex: 1; display: flex; flex-direction: column; gap: 1rem; max-width: 860px; margin: 0 auto; width: 100%; }
.chat-header { display: flex; flex-direction: column; gap: .6rem; }
.chat-header-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.chat-header h2 { font-size: 1.1rem; color: var(--azul); }
.chat-header-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }
.chat-nuevo-btn { background: var(--blanco); border: 1px solid var(--borde); color: var(--azul); padding: .35rem .7rem; border-radius: 14px; font-size: .78rem; cursor: pointer; transition: all .15s; font-weight: 500; }
.chat-nuevo-btn:hover { background: var(--azul); color: var(--blanco); border-color: var(--azul); }
.chat-modo-tabs { display: inline-flex; background: var(--fondo); border: 1px solid var(--borde); border-radius: 16px; padding: 2px; gap: 2px; }
.chat-modo-tab { background: transparent; border: none; padding: .3rem .8rem; border-radius: 14px; font-size: .8rem; font-weight: 500; cursor: pointer; color: var(--gris); transition: all .15s; }
.chat-modo-tab:hover { color: var(--azul); }
.chat-modo-tab.activo { background: var(--azul); color: var(--blanco); }
.chat-filtro { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--gris); }
.chat-filtro select { padding: .25rem .5rem; border: 1px solid var(--borde); border-radius: 4px; font-size: .82rem; background: var(--blanco); cursor: pointer; }

.chat-aviso { background: #fdf7e4; border: 1px solid #f5e7a8; border-radius: 6px; padding: .55rem .9rem; font-size: .78rem; color: #7a6400; line-height: 1.45; }

#chat-conversacion, #chat-tta-conversacion { display: flex; flex-direction: column; gap: .75rem; min-height: 160px; max-height: 55vh; overflow-y: auto; padding: .75rem .5rem; background: var(--fondo); border: 1px solid var(--borde); border-radius: 10px; }
#chat-conversacion:empty::before, #chat-tta-conversacion:empty::before { content: "Tu conversación aparecerá aquí."; color: var(--gris); font-size: .85rem; font-style: italic; align-self: center; margin-top: 2rem; }

.sugerencia-titulo { font-size: .78rem; color: var(--gris); margin-top: .5rem; margin-bottom: .3rem; }
.sugerencia-lista { list-style: none; display: flex; flex-direction: column; gap: .35rem; }
.sugerencia-item { font-size: .85rem; color: var(--azul); border: 1px solid var(--borde); padding: .5rem .8rem; border-radius: 10px; background: var(--blanco); cursor: pointer; transition: all .18s ease; position: relative; }
.sugerencia-item:hover { background: var(--azul); color: var(--blanco); border-color: var(--azul); transform: translateX(3px); box-shadow: 0 2px 8px rgba(26,58,92,.15); }
.sugerencia-item:hover::after { content: "↵"; position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); font-size: .9rem; opacity: .8; }
.sugerencia-item.sugerencia-click { animation: sugClick .3s ease-out; }
@keyframes sugClick { 0% { transform: scale(1); } 50% { transform: scale(.96); background: var(--azul-hover); } 100% { transform: scale(1); } }

.burbuja { padding: .9rem 1.15rem; border-radius: 8px; font-size: .9rem; line-height: 1.65; max-width: 100%; animation: burbujaIn .22s ease-out; }
.burbuja-usuario { background: var(--azul); color: var(--blanco); align-self: flex-end; max-width: 75%; border-radius: 16px 16px 4px 16px; box-shadow: 0 1px 3px rgba(26,58,92,.15); padding: .6rem 1rem; }
.burbuja-bot { background: var(--blanco); border: 1px solid var(--borde); align-self: flex-start; border-radius: 16px 16px 16px 4px; box-shadow: 0 1px 3px rgba(0,0,0,.04); max-width: 92%; }

/* Tipografía jerárquica dentro de la burbuja del bot */
.burbuja-bot h1, .burbuja-bot h2, .burbuja-bot h3, .burbuja-bot h4 {
  color: var(--azul); line-height: 1.3; margin: .9rem 0 .35rem;
}
.burbuja-bot h1 { font-size: 1.1rem; font-weight: 700; border-bottom: 1px solid var(--borde); padding-bottom: .25rem; }
.burbuja-bot h2 { font-size: 1.02rem; font-weight: 700; }
.burbuja-bot h3 { font-size: .95rem; font-weight: 600; }
.burbuja-bot h4 { font-size: .88rem; font-weight: 600; color: var(--azul-hover); }
.burbuja-bot h1:first-child, .burbuja-bot h2:first-child, .burbuja-bot h3:first-child { margin-top: 0; }

.burbuja-bot p { margin-bottom: .6rem; }
.burbuja-bot p:last-child { margin-bottom: 0; }
.burbuja-bot strong { color: var(--azul); font-weight: 600; }
.burbuja-bot em { color: var(--texto); }
.burbuja-bot ul, .burbuja-bot ol { margin: .4rem 0 .7rem 1.2rem; padding: 0; }
.burbuja-bot ul li, .burbuja-bot ol li { margin-bottom: .3rem; line-height: 1.55; }
.burbuja-bot ul li::marker { color: var(--azul); }
.burbuja-bot ol li::marker { color: var(--azul); font-weight: 600; }

.burbuja-bot blockquote { border-left: 3px solid var(--azul); background: var(--fondo); padding: .5rem .85rem; margin: .5rem 0; color: var(--texto); font-style: italic; border-radius: 0 4px 4px 0; }
.burbuja-bot blockquote p { margin-bottom: .3rem; }

.burbuja-bot code { background: #eef2f7; color: #0e2a47; padding: .1rem .35rem; border-radius: 3px; font-size: .85em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.burbuja-bot pre { background: #f4f7fb; border: 1px solid var(--borde); border-radius: 6px; padding: .7rem .9rem; overflow-x: auto; font-size: .82rem; margin: .6rem 0; }
.burbuja-bot pre code { background: transparent; padding: 0; }

.burbuja-bot table { border-collapse: collapse; width: 100%; margin: .6rem 0; font-size: .85rem; }
.burbuja-bot table th { background: var(--azul); color: var(--blanco); text-align: left; padding: .45rem .7rem; font-weight: 600; font-size: .82rem; }
.burbuja-bot table td { padding: .4rem .7rem; border: 1px solid var(--borde); vertical-align: top; }
.burbuja-bot table tr:nth-child(even) td { background: var(--fondo); }

.burbuja-bot hr { border: none; border-top: 1px dashed var(--borde); margin: .8rem 0; }
.burbuja-fadein { animation: burbujaFadeIn .35s ease-out; }
@keyframes burbujaIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes burbujaFadeIn { from { opacity: .5; } to { opacity: 1; } }

.thinking-wrap { display: flex; align-items: center; gap: .6rem; padding: .15rem 0; }
.typing-indicator { display: inline-flex; gap: 4px; align-items: center; }
.typing-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--azul); opacity: .4; animation: typingDot 1.3s ease-in-out infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .18s; }
.typing-indicator span:nth-child(3) { animation-delay: .36s; }
@keyframes typingDot { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.thinking-text { color: var(--gris); font-size: .86rem; font-style: italic; transition: opacity .2s ease; background: linear-gradient(90deg, var(--gris) 0%, var(--azul) 50%, var(--gris) 100%); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shimmer 2.4s linear infinite; }
.thinking-text.fade-out { opacity: 0; }
@keyframes shimmer { 0% { background-position: -200% center; } 100% { background-position: 200% center; } }

/* ── A9: Export card prominente + modal ── */
.export-card { margin-top: 1rem; padding: .85rem 1rem; background: linear-gradient(135deg, #eef4fb 0%, #dde8f5 100%); border: 1px solid #c7d6e9; border-radius: 10px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.export-card-text { display: flex; flex-direction: column; gap: .15rem; line-height: 1.3; }
.export-card-text strong { color: var(--azul); font-size: .92rem; font-weight: 700; }
.export-card-text span { font-size: .78rem; color: var(--gris); }
.export-card-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.export-card-dl { display: inline-flex; gap: .3rem; }
.export-btn-primary { background: var(--azul); color: #fff; border: none; border-radius: 999px; padding: .55rem 1.15rem; font-size: .85rem; font-weight: 700; cursor: pointer; transition: all .18s; font-family: inherit; display: inline-flex; align-items: center; gap: .45rem; box-shadow: 0 2px 6px rgba(27,58,107,.18); }
.export-btn-primary:hover { background: var(--azul-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(27,58,107,.28); }
.export-btn-primary:active { transform: scale(.97); }
.export-btn-icon { font-size: 1rem; }
.export-btn-secondary { background: var(--blanco); color: var(--azul); border: 1px solid #c7d6e9; border-radius: 999px; padding: .4rem .8rem; font-size: .76rem; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; }
.export-btn-secondary:hover { background: var(--azul); color: #fff; border-color: var(--azul); }
/* legacy classes (compat) */
.export-actions { margin-top: .9rem; padding-top: .75rem; border-top: 1px dashed var(--borde); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.export-label { font-size: .75rem; color: var(--gris); margin-right: .25rem; }
.export-btn { background: var(--blanco); border: 1px solid var(--borde); color: var(--azul); padding: .3rem .7rem; border-radius: 14px; font-size: .78rem; font-weight: 500; cursor: pointer; transition: all .15s; font-family: inherit; }
.export-btn:hover { background: var(--azul); color: #fff; border-color: var(--azul); }
@media (max-width: 600px) { .export-card { flex-direction: column; align-items: stretch; } .export-card-actions { justify-content: space-between; } }
.export-modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; animation: modalFade .2s ease-out; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.export-modal-card { background: #fff; border-radius: 12px; padding: 1.6rem 1.8rem 1.3rem; max-width: 440px; width: 100%; position: relative; box-shadow: 0 12px 40px rgba(0,0,0,.3); animation: modalSlide .22s ease-out; }
@keyframes modalSlide { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.export-modal-cerrar { position: absolute; top: .55rem; right: .7rem; background: transparent; border: none; font-size: 1.6rem; line-height: 1; color: var(--gris); cursor: pointer; padding: .2rem .5rem; }
.export-modal-cerrar:hover { color: var(--azul); }
.export-modal-card h3 { color: var(--azul); font-size: 1.1rem; margin-bottom: .35rem; }
.export-modal-sub { color: var(--gris); font-size: .85rem; margin-bottom: 1rem; line-height: 1.45; }
.export-modal-label { display: block; font-size: .78rem; color: var(--gris); font-weight: 600; margin-bottom: .3rem; letter-spacing: .3px; }
.export-modal-card input[type=email] { width: 100%; padding: .55rem .75rem; font-size: .92rem; border: 1px solid var(--borde); border-radius: 6px; font-family: inherit; margin-bottom: .8rem; }
.export-modal-card input[type=email]:focus { outline: 2px solid var(--azul); outline-offset: -1px; border-color: var(--azul); }
.export-modal-radios { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--texto); margin-bottom: 1rem; }
.export-modal-send { width: 100%; padding: .65rem; background: var(--azul); color: #fff; border: none; border-radius: 6px; font-size: .92rem; font-weight: 600; cursor: pointer; transition: background .15s; font-family: inherit; }
.export-modal-send:hover:not(:disabled) { background: var(--azul-hover); }
.export-modal-send:disabled { opacity: .6; cursor: wait; }
.export-modal-legal { font-size: .72rem; color: var(--gris); margin-top: .8rem; font-style: italic; line-height: 1.45; }
.export-ok { color: #0c6e2a; font-size: .85rem; margin-top: .6rem; }
.export-err { color: #842029; font-size: .85rem; margin-top: .6rem; }

.fuentes-bloque { margin-top: .9rem; border-top: 1px solid var(--borde); padding-top: .7rem; }
.fuentes-titulo { font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--gris); margin-bottom: .5rem; letter-spacing: .6px; }
.fuente-tarjeta { font-size: .82rem; margin-bottom: .55rem; padding: .5rem .7rem; background: var(--fondo); border: 1px solid var(--borde); border-radius: 6px; transition: border-color .15s, box-shadow .15s; cursor: pointer; }
.fuente-tarjeta:hover { border-color: var(--azul); box-shadow: 0 1px 4px rgba(26,58,92,.1); }
.fuente-head { display: flex; align-items: center; gap: .45rem; flex-wrap: nowrap; }
.fuente-num { color: var(--azul); white-space: nowrap; font-size: .85rem; }
.fuente-anio { color: var(--gris); font-size: .78rem; white-space: nowrap; }
.fuente-materia { margin-top: .3rem; color: var(--texto); font-size: .8rem; line-height: 1.45; }
.badge { display: inline-block; padding: .12rem .45rem; border-radius: 4px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; flex-shrink: 0; }
.badge-circular { background: #d1ecf1; color: #0c5460; }
.badge-oficio { background: #d4edda; color: #155724; }
.btn-ver-sii { font-size: .72rem; padding: .15rem .55rem; border: 1px solid var(--azul); color: var(--azul); border-radius: 12px; text-decoration: none; margin-left: auto; white-space: nowrap; flex-shrink: 0; transition: background .15s, color .15s; }
.btn-ver-sii:hover { background: var(--azul); color: var(--blanco); }

.chat-input-area { display: flex; gap: .5rem; align-items: flex-end; background: var(--blanco); border: 1px solid var(--borde); border-radius: 26px; padding: .4rem .45rem .4rem 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,.04); transition: border-color .15s, box-shadow .15s; }
.chat-input-area:focus-within { border-color: var(--azul); box-shadow: 0 1px 6px rgba(26,58,92,.15); }
.chat-input-area textarea { flex: 1; padding: .55rem 0; border: none; outline: none; background: transparent; font-family: var(--font); font-size: .92rem; resize: none; line-height: 1.4; max-height: 160px; overflow-y: auto; }
.chat-input-area button { flex-shrink: 0; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; background: var(--azul); color: var(--blanco); border: none; border-radius: 50%; cursor: pointer; transition: background .15s, transform .1s; }
.chat-input-area button:hover { background: var(--azul-hover); }
.chat-input-area button:active { transform: scale(.95); }
.chat-input-area button:disabled { opacity: .5; cursor: not-allowed; }
.chat-input-area button svg { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  .container { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; }
  #lista-articulos { max-height: 220px; }
  .chat-header { flex-direction: column; align-items: flex-start; }
  .burbuja-usuario { max-width: 90%; }
}

/* ═══ Panel Fallos TTA (A8) ═══ */
.fallos-wrapper { max-width: 1100px; margin: 0 auto; padding: 0 var(--spacing); }
.fallos-header h2 { margin: 0 0 6px; color: var(--color-primario); }
.fallos-sub { margin: 0 0 22px; color: #475569; }

.fallos-subtabs { display: flex; gap: 6px; border-bottom: 2px solid #e2e8f0; margin-bottom: 24px; flex-wrap: wrap; }
.fallos-subtab { background: transparent; border: none; padding: 10px 18px; cursor: pointer; font-size: 0.98em; color: #64748b; border-bottom: 3px solid transparent; transition: all 0.15s; margin-bottom: -2px; }
.fallos-subtab:hover { color: var(--color-primario); }
.fallos-subtab.activo { color: var(--color-primario); border-bottom-color: var(--color-primario); font-weight: 600; }

.fallos-filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.fallos-filtros select, .fallos-filtros input { padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95em; font-family: inherit; background: white; }
.fallos-filtros input[type="search"] { flex: 1; min-width: 220px; }

.fallos-lista { display: flex; flex-direction: column; gap: 14px; }
.fallo-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px 18px; transition: box-shadow 0.15s, border-color 0.15s; }
.fallo-card:hover { border-color: var(--color-primario); box-shadow: 0 4px 14px rgba(27, 58, 107, 0.08); }
.fallo-card-head {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--color-primario);
  color: #ffffff;
  padding: 8px 14px;
  margin: -16px -18px 10px -18px;
  border-radius: 7px 7px 0 0;
}
.fallo-tag { padding: 3px 10px; border-radius: 14px; font-size: 0.78em; font-weight: 700; letter-spacing: 0.3px; }
.tag-acoge { background: #dcfce7; color: #14532d; }
.tag-rechaza { background: #fee2e2; color: #7f1d1d; }
.tag-parcial { background: #fef3c7; color: #78350f; }
.tag-otro { background: #e2e8f0; color: #334155; }
.fallo-rit { font-family: ui-monospace, monospace; font-size: 0.92em; color: #ffffff; font-weight: 700; }
.fallo-fecha { margin-left: auto; color: #ffffff; font-size: 0.9em; font-weight: 600; }
.fallo-caratula { margin: 4px 0; font-size: 1.02em; }
.fallo-caratula a { color: var(--color-primario); text-decoration: none; }
.fallo-caratula a:hover { text-decoration: underline; }
.fallo-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.88em; color: #64748b; margin-bottom: 8px; }
.fallo-tribunal::before { content: "🏛 "; }
.fallo-materia::before { content: "📋 "; }
.fallo-extracto { font-size: 0.92em; color: #334155; line-height: 1.5; margin: 4px 0 0; }

.fallos-paginacion { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 22px 0 8px; }
.fallos-paginacion button { padding: 7px 14px; border: 1px solid #cbd5e1; background: white; border-radius: 6px; cursor: pointer; font-size: 0.92em; }
.fallos-paginacion button:disabled { opacity: 0.4; cursor: not-allowed; }
#fallos-pos { color: #64748b; font-size: 0.9em; }

/* Chat TTA */
.chat-tta-header { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.chat-tta-header select { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; min-width: 240px; }
#chat-tta-conversacion { min-height: 240px; max-height: 60vh; overflow-y: auto; padding: 10px; background: #f8fafc; border-radius: 8px; margin-bottom: 12px; }

/* Stats TTA */
.stats-tta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 24px; }
.trib-card { background: white; border: 1px solid #e2e8f0; border-left: 4px solid #94a3b8; border-radius: 8px; padding: 14px; }
.trib-card.semaforo-pro_contribuyente { border-left-color: #16a34a; }
.trib-card.semaforo-equilibrado { border-left-color: #eab308; }
.trib-card.semaforo-pro_fisco { border-left-color: #dc2626; }
.trib-card-head { font-size: 0.95em; margin-bottom: 8px; }
.trib-card-num { font-size: 1.8em; font-weight: 700; color: var(--color-primario); line-height: 1; }
.trib-card-num span { font-size: 0.5em; color: #64748b; margin-left: 6px; font-weight: 400; }
.trib-card-barras { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 10px 0 4px; background: #f1f5f9; }
.barra-acoge { background: #16a34a; }
.barra-parcial { background: #eab308; }
.barra-rechaza { background: #dc2626; }
.trib-card-lbl { display: flex; justify-content: space-between; font-size: 0.78em; color: #475569; margin-bottom: 8px; }
.trib-card-idx { font-size: 0.88em; color: #334155; }

.stats-tta-doble { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 18px; }
.stats-tta-doble h3 { margin: 0 0 10px; color: var(--color-primario); font-size: 1em; }
.bar-row { display: grid; grid-template-columns: 1fr 100px 36px; gap: 8px; align-items: center; padding: 3px 0; font-size: 0.88em; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #334155; }
.bar-track { background: #e2e8f0; border-radius: 4px; height: 8px; }
.bar-fill { background: var(--color-primario); height: 100%; border-radius: 4px; }
.bar-num { text-align: right; color: #64748b; font-size: 0.85em; }

.stats-tta-leyenda { font-size: 0.85em; color: #64748b; padding: 10px 14px; background: #f8fafc; border-radius: 6px; margin-top: 8px; }

.fuentes-details { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e2e8f0; }
.fuentes-details summary { cursor: pointer; color: var(--color-primario); font-size: 0.88em; }
.fuentes-list { margin: 6px 0 0; padding-left: 18px; font-size: 0.88em; }
.fuentes-list li { margin-bottom: 6px; }

/* Panel de Jurisprudencia TTA en vista de artículo */
.art-fallos-panel { margin-top: 20px; padding: 14px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.art-fallos-panel h3 { margin: 0 0 10px; font-size: 1em; color: var(--color-primario); }
.art-fallos-item { padding: 8px 10px; border-radius: 5px; margin-bottom: 5px; background: white; border: 1px solid #e2e8f0; font-size: 0.88em; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.art-fallos-item a { color: var(--color-primario); text-decoration: none; }
.art-fallos-item a:hover { text-decoration: underline; }

/* Página standalone de fallo */
.fallo-standalone { max-width: 900px; margin: 20px auto 40px; padding: 0 var(--spacing); }
.fallo-volver { display: inline-block; margin-bottom: 16px; color: var(--color-primario); text-decoration: none; font-size: 0.92em; }
.fallo-volver:hover { text-decoration: underline; }
.fallo-detalle { background: white; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; }
.fallo-detalle-head { display: flex; gap: 12px; align-items: center; padding: 12px 20px; background: var(--color-primario); color: white; flex-wrap: wrap; }
.fallo-detalle-head .fallo-rit, .fallo-detalle-head .fallo-fecha { color: white; font-weight: 700; }
.fallo-detalle h1 { padding: 20px 24px 8px; margin: 0; font-size: 1.4em; color: var(--color-primario); line-height: 1.3; }
.fallo-detalle-meta { padding: 6px 24px 18px; }
.fallo-detalle-meta p { margin: 6px 0; color: #334155; font-size: 0.95em; }
.fallo-detalle-seccion { padding: 18px 24px; border-top: 1px solid #e2e8f0; }
.fallo-detalle-seccion h2 { margin: 0 0 10px; font-size: 1.05em; color: var(--color-primario); }
.fallo-detalle-seccion p { margin: 0; color: #1e293b; line-height: 1.55; }
.fallo-detalle-link { padding: 18px 24px; border-top: 1px solid #e2e8f0; margin: 0; }
.fallo-detalle-link a { color: var(--color-primario); font-weight: 600; }
.fallo-detalle-aviso { padding: 12px 24px; background: #fef3c7; color: #78350f; font-size: 0.88em; margin: 0; border-top: 1px solid #e2e8f0; }

/* Tribunal detalle — overlay modal */
.trib-card { cursor: pointer; transition: transform 0.1s, box-shadow 0.15s; }
.trib-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(27,58,107,0.12); }
.trib-card-click { font-size: 0.75em; color: #64748b; margin-top: 6px; text-align: right; }

.trib-detalle-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); z-index: 9999; display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; }
.trib-detalle-panel { background: white; border-radius: 10px; max-width: 920px; width: 100%; padding: 24px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.trib-detalle-close { position: absolute; top: 10px; right: 14px; border: none; background: transparent; font-size: 28px; cursor: pointer; color: #64748b; line-height: 1; }
.trib-detalle-close:hover { color: #0f172a; }
.trib-detalle-body h2 { color: var(--color-primario); margin: 0 0 18px; }
.trib-detalle-seccion { margin-bottom: 22px; }
.trib-detalle-seccion h3 { margin: 0 0 10px; font-size: 1em; color: var(--color-primario); }

.chart-anual svg { width: 100%; height: auto; background: #f8fafc; border-radius: 6px; }
.chart-legend { display: flex; gap: 18px; justify-content: center; padding: 8px 0; font-size: 0.85em; color: #475569; }
.legend-sq { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

.trib-tabla { width: 100%; border-collapse: collapse; font-size: 0.88em; }
.trib-tabla th { text-align: left; padding: 8px 6px; border-bottom: 2px solid #cbd5e1; color: var(--color-primario); font-weight: 600; }
.trib-tabla td { padding: 7px 6px; border-bottom: 1px solid #e2e8f0; color: #1e293b; }
.trib-tabla td:first-child { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.trib-tabla td small { color: #94a3b8; font-size: 0.82em; }

/* Stats TTA extendido */
.stats-section-title { margin: 22px 0 10px; color: var(--color-primario); font-size: 1em; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
.stats-section-title small { color: #64748b; font-weight: 400; font-size: 0.85em; }

.stats-comparar-box { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; flex-wrap: wrap; }
#stats-comparar-select { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 260px; }
.cmp-chk { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px; cursor: pointer; font-size: 0.88em; }
.cmp-chk:has(input:checked) { background: #dbeafe; border-color: var(--color-primario); }
.cmp-chk-n { color: #64748b; font-size: 0.85em; }
.btn-primario { background: var(--color-primario); color: white; border: none; padding: 9px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.92em; }
.btn-primario:hover { background: #2a4e86; }

.cmp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.cmp-col { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; }
.cmp-col-head { font-weight: 600; color: var(--color-primario); font-size: 0.9em; margin-bottom: 6px; }
.cmp-col-total { font-size: 1.5em; font-weight: 700; color: var(--color-primario); line-height: 1; }
.cmp-col-total span { font-size: 0.5em; color: #64748b; margin-left: 6px; font-weight: 400; }
.cmp-bar-set { margin: 10px 0 8px; display: flex; flex-direction: column; gap: 4px; }
.cmp-bar-row { display: grid; grid-template-columns: 40px 1fr 38px; gap: 6px; align-items: center; font-size: 0.78em; }
.cmp-lbl { color: #475569; font-weight: 600; }
.cmp-bar { background: #f1f5f9; border-radius: 3px; height: 8px; overflow: hidden; }
.cmp-bar-fill { height: 100%; border-radius: 3px; }
.cmp-pct { text-align: right; color: #475569; font-size: 0.82em; }
.cmp-idx { font-size: 0.85em; color: #334155; }

.cmp-tabla { margin-top: 16px; font-size: 0.82em; }
.cmp-tabla td { padding: 5px 6px; }
.cmp-tabla td.muted { color: #cbd5e1; text-align: center; }
.cmp-tabla td em { color: #475569; }

.stats-materia-box { margin-bottom: 12px; }
.stats-materia-box select { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; width: 100%; max-width: 520px; font-size: 0.92em; font-family: inherit; }

.fallo-texto-details summary { cursor: pointer; color: var(--color-primario); font-weight: 600; padding: 4px 0; }
.fallo-texto-pre { white-space: pre-wrap; word-wrap: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82em; line-height: 1.55; color: #1e293b; background: #f8fafc; padding: 14px; border-radius: 6px; border: 1px solid #e2e8f0; max-height: 600px; overflow-y: auto; margin-top: 8px; }

.resumen-ia { background: #f0f7ff; border: 1px solid #c6dbfb; border-radius: 8px; padding: 14px 18px !important; }
.resumen-ia .resumen-corto { font-size: 1.05em; color: var(--color-primario); padding: 6px 0 10px; border-bottom: 1px dashed #c6dbfb; margin-bottom: 10px; }
.resumen-ia h3 { margin: 10px 0 4px; font-size: 0.92em; color: var(--color-primario); }
.resumen-ia p { color: #1e293b; line-height: 1.55; }
.arts-citados { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.arts-citados li a { display: inline-block; padding: 2px 8px; background: white; border: 1px solid #c6dbfb; border-radius: 4px; font-size: 0.82em; color: var(--color-primario); text-decoration: none; }
.arts-citados li a:hover { background: var(--color-primario); color: white; }

/* Newsletter gate modal */
.gate-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65); z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.gate-panel { background: white; border-radius: 12px; max-width: 440px; width: 100%; padding: 28px 26px 22px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.gate-close { position: absolute; top: 8px; right: 12px; border: none; background: transparent; font-size: 26px; cursor: pointer; color: #64748b; line-height: 1; }
.gate-close:hover { color: #0f172a; }
.gate-panel h2 { margin: 0 0 10px; font-size: 1.15em; color: var(--color-primario); }
.gate-msg { color: #334155; font-size: 0.92em; line-height: 1.5; margin: 0 0 14px; }
.gate-form { display: flex; gap: 8px; margin-bottom: 10px; }
.gate-form input { flex: 1; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95em; font-family: inherit; }
.gate-form input:focus { outline: 2px solid var(--color-primario); outline-offset: -1px; }
.gate-form button { white-space: nowrap; padding: 9px 14px; font-size: 0.9em; }
.gate-estado { font-size: 0.88em; padding: 4px 0; min-height: 1.4em; }
.gate-estado.loading { color: #64748b; }
.gate-estado.ok { color: #16a34a; }
.gate-estado.error { color: #dc2626; }
.gate-mini { font-size: 0.78em; color: #64748b; margin: 6px 0 0; }
.gate-mini a { color: var(--color-primario); }

.gate-teaser { background: #f0f7ff; border: 1px dashed #93c5fd; border-radius: 8px; padding: 18px; text-align: center; }
.gate-teaser p { margin: 0 0 10px; color: #334155; }
.gate-teaser .btn-primario { font-size: 0.92em; }

.cmp-emo { display: inline-block; margin-right: 6px; white-space: nowrap; font-size: 0.88em; }

/* Monetización footer — dormant por default */
.footer-apoyo { margin-left: 8px; }
.footer-apoyo-link { color: #fbbf24; text-decoration: none; font-weight: 600; }
.footer-apoyo-link:hover { text-decoration: underline; color: #fde68a; }
.footer-transparencia { margin-left: 8px; color: rgba(255,255,255,0.82); }
.footer-transparencia small { color: rgba(255,255,255,0.65); }

/* Texto de fallo TTA — legible como documento */
.fallo-texto-details summary { cursor: pointer; color: var(--color-primario); font-weight: 600; padding: 4px 0; margin-bottom: 8px; }
.fallo-texto-body {
  max-height: 720px; overflow-y: auto;
  background: #fafbfc; padding: 24px 32px; border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02em; line-height: 1.75;
  color: #1e293b; letter-spacing: 0.01em;
}
.fallo-texto-body p {
  margin: 0 0 14px; text-align: justify; hyphens: auto;
  text-indent: 1.8em;
}
.fallo-texto-body p:first-child,
.fallo-texto-body .fallo-h + p,
.fallo-texto-body .fallo-numeral,
.fallo-texto-body .fallo-que { text-indent: 0; }
.fallo-texto-body .fallo-h {
  margin: 28px 0 14px;
  font-size: 0.95em; font-family: var(--font);
  color: var(--color-primario); font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  border-bottom: 1px solid #cbd5e1; padding-bottom: 4px;
}
.fallo-texto-body .fallo-h:first-child { margin-top: 0; }
.fallo-texto-body .fallo-numeral {
  margin: 16px 0; text-align: justify; hyphens: auto;
}
.fallo-texto-body .fallo-ordinal {
  font-weight: 700; color: var(--color-primario);
  margin-right: 6px; font-family: var(--font);
  font-size: 0.92em; letter-spacing: 0.4px;
  text-transform: uppercase;
}
.fallo-texto-body .fallo-que {
  margin: 0 0 12px; text-align: justify; hyphens: auto;
  padding-left: 1em; border-left: 2px solid #e2e8f0;
}
.fallo-texto-body::-webkit-scrollbar { width: 8px; }
.fallo-texto-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.fallo-texto-body::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.chat-tta-vp { background: linear-gradient(135deg, #eef4fb 0%, #dde8f5 100%); border-left: 4px solid var(--color-primario); padding: 12px 16px; border-radius: 6px; font-size: 0.94em; color: #1e293b; line-height: 1.5; margin-bottom: 10px; }
.chat-tta-vp strong { color: var(--color-primario); }

/* Fallo detalle — cabecera mejorada + TOC */
.fallo-caratula-title { font-size: 1.35em; color: var(--color-primario); padding: 20px 26px 12px; margin: 0; font-family: var(--font); line-height: 1.3; border-bottom: 2px solid #e2e8f0; }
.fallo-detalle-meta { width: calc(100% - 52px); margin: 14px 26px 18px; border-collapse: collapse; font-size: 0.92em; }
.fallo-detalle-meta th { text-align: left; padding: 6px 14px 6px 0; color: #64748b; font-weight: 500; width: 150px; vertical-align: top; }
.fallo-detalle-meta td { padding: 6px 0; color: #1e293b; vertical-align: top; }
.fallo-detalle-meta td code { background: #f1f5f9; padding: 2px 8px; border-radius: 4px; font-size: 0.92em; color: #0f172a; font-family: ui-monospace, monospace; }

/* TOC del texto del fallo */
.fallo-toc { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px; padding: 12px 18px; margin: 0 0 18px; font-family: var(--font); font-size: 0.9em; }
.fallo-toc-head { font-weight: 700; color: var(--color-primario); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.85em; }
.fallo-toc ol { margin: 0; padding-left: 20px; }
.fallo-toc ol li { margin: 3px 0; }
.fallo-toc ol li a { color: var(--color-primario); text-decoration: none; }
.fallo-toc ol li a:hover { text-decoration: underline; }
.fallo-cuerpo { scroll-behavior: smooth; }
.fallo-cuerpo h3.fallo-h { scroll-margin-top: 20px; }

.fallo-caratula-wrap { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 0 26px; border-bottom: 2px solid #e2e8f0; margin-bottom: 14px; }
.fallo-caratula-wrap .fallo-caratula-title { padding: 20px 0 12px; border-bottom: none; flex: 1; min-width: 300px; margin: 0; }
.fallo-copy-toolbar { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 20px; }
.copy-btn { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 11px; font-size: 0.82em; cursor: pointer; color: #1e293b; font-family: var(--font); transition: all 0.15s; white-space: nowrap; }
.copy-btn:hover { background: var(--color-primario); color: white; border-color: var(--color-primario); }
.copy-btn.copied { background: #16a34a; color: white; border-color: #15803d; }
.copy-btn-combo { background: #dbeafe; border-color: #93c5fd; color: var(--color-primario); font-weight: 600; }
.copy-btn-combo:hover { background: var(--color-primario); color: white; }

/* Citas clickeables en respuestas chat */
.rit-link, .doc-ref-link { color: var(--color-primario); text-decoration: underline; text-decoration-style: dotted; }
.rit-link:hover, .doc-ref-link:hover { text-decoration-style: solid; background: #dbeafe; padding: 0 2px; border-radius: 3px; }

.badge-subrogante { display: inline-block; margin-left: 8px; padding: 2px 10px; background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; border-radius: 10px; font-size: 0.8em; font-weight: 600; cursor: help; }

.copy-btn-md { background: #f0fdf4; border-color: #86efac; color: #166534; text-decoration: none; }
.copy-btn-md:hover { background: #166534; color: white; border-color: #166534; }
.copy-btn-mail { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.copy-btn-mail:hover { background: #1e40af; color: white; border-color: #1e40af; }
.md-why-btn { background: transparent; border: none; color: #166534; cursor: pointer; font-size: .82em; text-decoration: underline; text-decoration-style: dotted; padding: 0 6px; font-family: inherit; }
.md-why-btn:hover { color: var(--color-primario); text-decoration-style: solid; }

/* Badge de usuario (tier/ola) junto al email en la nav */
.user-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72em; font-weight: 700; letter-spacing: .02em; vertical-align: middle; border: 1px solid transparent; white-space: nowrap; }
.user-badge-diamante { background: linear-gradient(135deg, #e0f2fe 0%, #cffafe 50%, #e0e7ff 100%); color: #0c4a6e; border-color: #67e8f9; box-shadow: 0 0 0 1px rgba(14,116,144,.15), 0 1px 2px rgba(14,116,144,.08); }
.user-badge-corporativo { background: linear-gradient(135deg, #1e293b 0%, #334155 100%); color: #e2e8f0; border-color: #475569; }
.user-badge-estudio { background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%); color: #1e293b; border-color: #94a3b8; }
.user-badge-founder { background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%); color: #7c2d12; border-color: #fdba74; }
.user-badge-early { background: #fef9c3; color: #713f12; border-color: #fde68a; }
.user-badge-amigos { background: #fce7f3; color: #831843; border-color: #f9a8d4; }
.user-badge-pro { background: #ecfccb; color: #365314; border-color: #bef264; }

/* Maletín Pro */
.maletin-badge { background: #fef3c7; color: #78350f; padding: 1px 7px; border-radius: 10px; font-size: .75em; margin-left: 4px; font-weight: 700; }
.maletin-toggle { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.maletin-toggle.in-maletin { background: #78350f; color: white; border-color: #78350f; }
.maletin-toggle:hover { background: #d97706; color: white; border-color: #d97706; }
.maletin-items { margin-top: 16px; max-height: 300px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 6px; }
.maletin-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #f1f5f9; }
.maletin-item:last-child { border-bottom: none; }
.maletin-item-info strong { display: block; font-size: .92em; color: #1e293b; }
.maletin-item-info small { color: #64748b; font-size: .8em; }
.maletin-item-quitar { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 1.2em; padding: 0 8px; }
.maletin-item-quitar:hover { color: #991b1b; }
#maletin-form textarea { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-family: inherit; font-size: .95em; box-sizing: border-box; resize: vertical; }
#maletin-form input[type="text"] { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 1em; box-sizing: border-box; }
#maletin-form label { margin-bottom: 10px; }

/* Jueces TTA (C5) */
.jueces-intro { background: #eff6ff; border-left: 3px solid #3b82f6; padding: 10px 14px; font-size: .9em; color: #334155; margin-bottom: 1rem; border-radius: 4px; }
.jueces-aviso { background: #fffbeb; border-left: 3px solid #f59e0b; padding: 10px 14px; font-size: .9em; color: #78350f; margin: 1rem 0; border-radius: 4px; }
.jueces-filtros { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: .55rem .7rem; margin-bottom: .8rem; }
.jueces-input { flex: 1 1 220px; min-width: 180px; padding: .4rem .7rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .88rem; background: white; font-family: inherit; }
.jueces-input:focus { outline: none; border-color: var(--color-primario); box-shadow: 0 0 0 3px rgba(27,58,107,.12); }
.jueces-select { padding: .4rem .55rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .85rem; background: white; font-family: inherit; cursor: pointer; max-width: 100%; }
.jueces-select:focus { outline: none; border-color: var(--color-primario); }
.jueces-count { margin-left: auto; font-size: .8rem; color: #64748b; font-variant-numeric: tabular-nums; padding: 0 .3rem; }
.jueces-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem; }
.juez-fallos-recientes { list-style: none; padding: 0; margin: .4rem 0; }
.juez-fallos-recientes li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .45rem .6rem; border-bottom: 1px solid #f1f5f9; font-size: .9rem; }
.juez-fallos-recientes li:last-child { border-bottom: none; }
.juez-fallos-recientes li:hover { background: #f8fafc; }
.juez-fallos-recientes a { color: #1e293b; text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.juez-fallos-recientes a:hover { color: var(--color-primario); text-decoration: underline; }
.juez-fallo-meta { display: inline-flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.juez-fallo-fecha { color: #64748b; font-size: .8rem; font-variant-numeric: tabular-nums; }
.juez-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1rem; cursor: pointer; transition: border-color .15s, transform .15s; }
.juez-card:hover { border-color: var(--color-primario); transform: translateY(-2px); }
.juez-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.juez-card-head strong { color: #1e293b; font-size: 1em; }
.juez-card-trib { font-size: .82em; color: #64748b; margin-bottom: .5rem; }
.juez-card-num { font-size: 1.5em; font-weight: 700; color: var(--color-primario); margin: .4rem 0; }
.juez-card-num span { font-size: .5em; color: #94a3b8; font-weight: 400; margin-left: 4px; }
.juez-card-barras { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: .6rem 0; background: #f1f5f9; }
.juez-card-lbl { display: flex; justify-content: space-between; font-size: .78em; color: #64748b; }
.juez-fallos-recientes { padding-left: 1.2rem; }
.juez-fallos-recientes li { margin-bottom: .4rem; font-size: .9em; }
.juez-meta-canonica { background: #f8fafc; border-left: 3px solid var(--color-primario); padding: 10px 14px; margin: 8px 0 16px; font-size: .92em; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.badge-estado { padding: 3px 10px; border-radius: 12px; font-size: .78em; font-weight: 600; }
.badge-titular { background: #dcfce7; color: #166534; }
.badge-subrog { background: #fef3c7; color: #78350f; }
.badge-ex { background: #e2e8f0; color: #475569; }
.badge-fallecido { background: #f3e8ff; color: #6b21a8; }
.juez-meta-trib { color: #475569; }
.juez-meta-periodo { color: #64748b; font-style: italic; font-size: .88em; }
.juez-meta-nota { flex-basis: 100%; color: #64748b; font-size: .88em; margin-top: 4px; }

/* B1 — Modal "Mándamelo por email" */
.enviar-mail-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; animation: enviarFadeIn .15s ease;
}
@keyframes enviarFadeIn { from { opacity: 0 } to { opacity: 1 } }
.enviar-mail-panel {
  background: white; border-radius: 10px; padding: 1.8rem 1.6rem;
  max-width: 440px; width: 100%; box-shadow: 0 20px 40px rgba(0,0,0,.25);
  position: relative;
}
.enviar-mail-panel h3 { color: var(--color-primario); margin: 0 0 .4rem; font-size: 1.2em; }
.enviar-mail-desc { color: #475569; font-size: .92em; margin: 0 0 1.2rem; }
.enviar-mail-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  font-size: 1.5em; color: #64748b; cursor: pointer; padding: 0; line-height: 1;
}
.enviar-mail-close:hover { color: #1e293b; }
#enviar-mail-form label { display: block; font-size: .9em; color: #334155; font-weight: 500; margin-bottom: .6rem; }
#enviar-mail-form input[type="email"] {
  display: block; width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid #cbd5e1; border-radius: 6px; font-size: 1em; font-family: inherit;
  box-sizing: border-box;
}
#enviar-mail-form input[type="email"]:focus { outline: 2px solid var(--color-primario); outline-offset: -1px; border-color: var(--color-primario); }
.enviar-mail-check { display: flex; gap: 8px; align-items: flex-start; margin-top: 1rem; font-size: .88em; line-height: 1.4; color: #475569; }
.enviar-mail-check input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.enviar-mail-check small { color: #64748b; display: block; font-size: .9em; }
.enviar-mail-error { color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; border-radius: 4px; padding: 8px 10px; margin-top: .8rem; font-size: .88em; }
.enviar-mail-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.3rem; }
.enviar-mail-cancel, .enviar-mail-submit {
  padding: 9px 18px; border-radius: 6px; font-weight: 600; font-size: .95em;
  cursor: pointer; border: 1px solid; font-family: inherit;
}
.enviar-mail-cancel { background: white; color: #475569; border-color: #cbd5e1; }
.enviar-mail-cancel:hover { background: #f1f5f9; }
.enviar-mail-submit { background: var(--color-primario); color: white; border-color: var(--color-primario); }
.enviar-mail-submit:hover:not(:disabled) { background: #2a4e86; }
.enviar-mail-submit:disabled { opacity: .6; cursor: not-allowed; }
.enviar-mail-privacy { font-size: .78em; color: #94a3b8; margin-top: 1rem; margin-bottom: 0; }
.enviar-mail-ok p { color: #166534; background: #f0fdf4; border-left: 3px solid #16a34a; padding: 12px 14px; margin: 0 0 1rem; border-radius: 4px; font-size: .95em; }

/* Doc view acciones row */
.doc-view-acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; }

/* ── MOBILE OVERFLOW FIX (2026-04-19) ── */
/* Evita que tabs largas empujen el viewport en mobile */
@media (max-width: 700px) {
  html, body { overflow-x: hidden; }
  .main-tabs {
    overflow-x: hidden;
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 0;
    padding: 0 .4rem;
  }
  .main-tabs::-webkit-scrollbar { display: none; }
  .main-tab {
    white-space: normal;
    flex: 1 1 50%;
    min-width: 0;
    font-size: .78rem;
    padding: .55rem .5rem;
    text-align: center;
    line-height: 1.2;
  }
  .fallos-subtabs {
    overflow-x: auto;
    overflow-y: hidden;     /* evita scroll vertical libre — solo horizontal */
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;    /* bloquea pan vertical en esta zona específica */
    overscroll-behavior-x: contain;
  }
  .fallos-subtabs::-webkit-scrollbar { display: none; }
  .fallos-subtab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: .9em;
  }
  /* ── Fix overflow paneles fallos: flex row → column + min-width 0 ── */
  .container { flex-direction: column; padding: 0 .75rem; gap: 1rem; }
  .panel-content, .panel-content > * { min-width: 0; max-width: 100%; }
  .fallos-wrapper {
    max-width: 100%;
    min-width: 0;
    width: 100%;
    padding: 0;
  }
  .fallos-header h2 { font-size: 1.15rem; line-height: 1.3; word-wrap: break-word; }
  .fallos-sub { font-size: .88rem; line-height: 1.4; }
  .fallos-subpanel { min-width: 0; max-width: 100%; overflow-x: hidden; }
  .fallos-filtros { flex-direction: column; align-items: stretch; }
  .fallos-filtros select,
  .fallos-filtros input { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
  .stats-comparar-box,
  .jueces-filtros { flex-direction: column; align-items: stretch; }
  .jueces-input,
  .jueces-select,
  #stats-comparar-select { max-width: 100%; width: 100%; min-width: 0; }
  .stats-tta-grid,
  .stats-tta-doble,
  .jueces-grid { grid-template-columns: 1fr; }
  table { font-size: .8rem; }
  pre, code { max-width: 100%; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
}
