/* Velia — ficha del expediente (rediseño 22/11/2026). Va con js/expedientes.js (VIEWS.expediente).
   · Cabecera tranquila: miga y «‹ n de N › ☆» arriba; título con su estado (TRAMITACIÓN / ARCHIVO) al lado; a la derecha,
     Escribir · Comunicar · Presentar (juntos), Editar y «Más» (cronómetro, carpeta, subasunto, archivar).
   · Cinco pestañas de grupo (Resumen · Plazos y agenda · Escritos y LexNET · Estrategia · Economía) y, debajo, sus
     subpestañas en un selector segmentado. Las direcciones #/expediente/ID/<pestaña> de siempre siguen valiendo.
   · Lo urgente no pierde visibilidad: si hay un plazo vencido o que vence hoy, el contador de «Plazos y agenda» sale en ROJO
     relleno; si vence en 3 días, en ámbar.
   La maquetación es común a los dos aspectos; el acabado «Tinta y oro», bajo :root[data-aspecto="sobrio"]. */

/* ---------- Cabecera ---------- */
.page-head.ficha-head { display: block; }
.ficha-f1 { display: flex; align-items: center; gap: 8px 16px; min-height: 32px; }
.ficha-miga { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ficha-nav { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.ficha-nav .iconbtn { position: relative; width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0; display: inline-grid; place-items: center; border-radius: 999px; line-height: 1; }
.ficha-nav .iconbtn:disabled { opacity: .35; cursor: default; }
.ficha-nav .iconbtn[onclick*="alternarFavorito"] { font-size: 16px !important; }
.ficha-pos { padding: 0 4px; font-size: 11.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ficha-sep { width: 1px; height: 16px; margin: 0 3px; background: var(--border); }
.ficha-espejo { display: inline-grid; transform: scaleX(-1); }
/* Texto solo para la guía en vivo y los lectores de pantalla (el ◀ ▶ que cita la guía) */
.ficha-oculto { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* El título ocupa todo el ancho; su estado va detrás, en la misma línea */
.page-head.ficha-head h1.ficha-titulo { margin: 4px 0 0; min-width: 0; overflow-wrap: anywhere; }
/* Datos del asunto a la izquierda y botones a la derecha, en la misma fila */
.ficha-f2 { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; }
.ficha-dur { white-space: nowrap; }
.page-head.ficha-head .ficha-f2 > p.ficha-meta { flex: 1 1 320px; min-width: 0; margin: 0; }
.page-head.ficha-head .ficha-acc { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.ficha-menus { display: inline-flex; flex-wrap: wrap; }
/* Escribir · Comunicar · Presentar: un solo grupo de botones */
.page-head.ficha-head .ficha-menus > .dd > .btn.dd-btn { border-radius: 0; margin-left: -1px; }
.page-head.ficha-head .ficha-menus > .dd:first-child > .btn.dd-btn { margin-left: 0; border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.page-head.ficha-head .ficha-menus > .dd:last-child > .btn.dd-btn { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.ficha-menus > .dd > .btn:hover, .ficha-menus > .dd.open > .btn, .ficha-menus > .dd > .btn:focus-visible { position: relative; z-index: 1; }
.ficha-menus .dd-pop { left: 0; right: auto; }
.ficha-mas .dd-pop { left: auto; right: 0; min-width: 240px; }
.ficha-mas .dd-pop button { display: flex; align-items: center; gap: 10px; }
.ficha-mas .dd-pop button > .ico-l { color: var(--muted); }
.ficha-mas .dd-btn > .ico-l { margin-right: 2px; }

/* Estado del expediente, junto al título y en pequeño */
.exp-estado-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid; border-radius: 999px; font-family: var(--font, inherit); font-size: 11px; font-style: normal; font-weight: 700; letter-spacing: .1em; line-height: 1.6; text-transform: uppercase; white-space: nowrap; text-decoration: none !important; -webkit-text-fill-color: currentColor; }
/* Dentro del título: centrado en la línea, sin heredar su tamaño ni su tipo */
h1 .exp-estado-pill { vertical-align: middle; position: relative; top: -.12em; margin-left: 4px; }
.exp-estado-pill.tram { background: rgba(46, 204, 113, .16); color: #3ddc84; border-color: rgba(61, 220, 132, .55); }
.exp-estado-pill.tram::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.exp-estado-pill.arch { background: rgba(150, 150, 170, .18); color: #b9bccb; border-color: rgba(185, 188, 203, .45); }
.exp-estado-pill:hover { filter: brightness(1.06); }

/* ---------- Pestañas de grupo ---------- */
.tabs.ficha-grupos { gap: 4px; margin-bottom: 0; container: fichagrupos / inline-size; }
.ficha-grupos a.ficha-g { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 14px; text-decoration: none; }
.ficha-g > .ico-l { opacity: .62; transition: opacity .15s, color .15s; }
.ficha-g:hover > .ico-l, .ficha-g.active > .ico-l { opacity: 1; }
.ficha-g.active > .ico-l { color: var(--accent); }
.ficha-grupos .ficha-g .c { margin-left: 0; min-width: 20px; padding: 0 6px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Subpestañas: selector segmentado discreto ---------- */
.ficha-subs { display: flex; flex-wrap: wrap; gap: 2px; width: fit-content; max-width: 100%; margin: 12px 0 18px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.ficha-subs a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background-color .15s, color .15s, box-shadow .15s; }
.ficha-subs a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.ficha-subs a.on { color: var(--text); background: var(--surface); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, .08); }
.ficha-subs .c { color: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Lo urgente (pestaña de grupo y subpestaña «Agenda y plazos»): rojo relleno si hay algo vencido o que vence hoy; ámbar si
   vence en 3 días. El texto toma el color del papel: contraste AA en los dos temas */
.tabs.ficha-grupos a.ficha-g .c.urg-bad, .ficha-subs a .c.urg-bad { padding: 0 6px; border: 1px solid var(--bad); border-radius: 999px; background: var(--bad); color: var(--surface); font-weight: 700; line-height: 17px; }
.tabs.ficha-grupos a.ficha-g .c.urg-warn, .ficha-subs a .c.urg-warn { padding: 0 6px; border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 999px; background: var(--warn-soft); color: color-mix(in srgb, var(--warn) 78%, var(--text)); font-weight: 700; line-height: 17px; }

/* ---------- Pestañas de grupo según el ancho de la ficha (pantalla, vista dividida o móvil): siempre caben las cinco,
   sin barra de desplazamiento. Con poco sitio, nombre corto («Plazos», «Escritos»); con muy poco, icono encima ---------- */
@container fichagrupos (max-width: 740px) {
  .tabs.ficha-grupos a.ficha-g { padding: 10px 10px; }
  .tabs.ficha-grupos a.ficha-g > .ico-l { display: none; }
}
@container fichagrupos (max-width: 610px) {
  .tabs.ficha-grupos a.ficha-g .fg-l { display: none; }
  .tabs.ficha-grupos a.ficha-g .fg-c { display: inline; }
}
@container fichagrupos (max-width: 450px) {
  .tabs.ficha-grupos a.ficha-g { position: relative; flex: 1 1 0; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; padding: 8px 2px 7px; font-size: 11.5px; text-align: center; }
  .tabs.ficha-grupos a.ficha-g > .ico-l { display: block; width: 19px; height: 19px; }
  .tabs.ficha-grupos a.ficha-g .c, .tabs.ficha-grupos a.ficha-g .c.urg-bad, .tabs.ficha-grupos a.ficha-g .c.urg-warn { position: absolute; top: 2px; left: calc(50% + 7px); min-width: 18px; padding: 0 5px; line-height: 15px; font-size: 10.5px; }
}
@container fichagrupos (max-width: 340px) {
  .tabs.ficha-grupos a.ficha-g { font-size: 10.5px; letter-spacing: -.01em; }
}

/* ---------- Móvil ---------- */
@media (max-width: 800px) {
  .ficha-f1 { align-items: flex-start; }
  .ficha-miga { white-space: normal; padding-top: 6px; }
  .ficha-nav .iconbtn { width: 40px; height: 40px; min-width: 40px; min-height: 40px; }
  .ficha-f2 { gap: 12px; }
  .page-head.ficha-head .ficha-f2 > p.ficha-meta { flex-basis: 100%; }
  .page-head.ficha-head .ficha-acc { position: relative; margin-left: 0; width: 100%; }
  /* Los desplegables ocupan el ancho de la fila de botones (no se salen por la derecha) */
  .page-head.ficha-head .ficha-acc .dd { position: static; }
  .page-head.ficha-head .ficha-acc .dd-pop { left: 0; right: 0; min-width: 0; top: calc(100% + 4px); }
  /* Los cinco botones en el mismo reparto (dos filas en un teléfono) */
  .ficha-menus { display: contents; }
  .page-head.ficha-head .ficha-menus > .dd > .btn.dd-btn { margin-left: 0; border-radius: 8px; }
  .ficha-subs { width: auto; margin: 10px 0 14px; }
  .ficha-subs a { min-height: 36px; padding: 6px 11px; }
}

/* ---------- Aspecto «Sobrio» · capa «Tinta y oro» ---------- */
:root[data-aspecto="sobrio"] .page-head.ficha-head { margin-bottom: 20px; }
:root[data-aspecto="sobrio"] .page-head.ficha-head .ficha-f2 > p.ficha-meta { font-size: 14px; }
:root[data-aspecto="sobrio"] .ficha-miga a { color: var(--text-2); }
:root[data-aspecto="sobrio"] .ficha-miga a:hover { color: var(--accent); }
:root[data-aspecto="sobrio"] .ficha-nav { border-color: var(--border); background: var(--surface); box-shadow: var(--sh-1); }
:root[data-aspecto="sobrio"] .ficha-nav .iconbtn:not(:disabled):hover { background: var(--hover); color: var(--text); }
:root[data-aspecto="sobrio"] .ficha-sep { background: var(--sb-linea); }
/* Botones de la cabecera: filete fino sobre el papel, sin sombra; ninguno compite con el título */
:root[data-aspecto="sobrio"] .page-head.ficha-head .ficha-acc .btn.btn:not(.primary) { padding: 7px 12px; background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: none; font-size: 13px; }
:root[data-aspecto="sobrio"] .page-head.ficha-head .ficha-acc .btn.btn:not(.primary):hover,
:root[data-aspecto="sobrio"] .page-head.ficha-head .ficha-acc .dd.open > .btn.btn:not(.primary) { background: var(--hover); border-color: var(--borde-campo); color: var(--text); }
:root[data-aspecto="sobrio"] .page-head.ficha-head .ficha-acc .btn .emo-l > .ico-l { color: var(--oro-texto, var(--accent)); }
:root[data-aspecto="sobrio"] .ficha-mas .dd-btn > .ico-l, :root[data-aspecto="sobrio"] .ficha-mas .dd-pop button > .ico-l { color: var(--oro-texto, var(--accent)); }
@media (max-width: 800px) { :root[data-aspecto="sobrio"] .page-head.ficha-head .ficha-acc .btn.btn:not(.primary) { padding: 6px 10px; } }
/* Pestañas de grupo: un poco más de cuerpo; la activa, con filete de oro y su icono en oro */
:root[data-aspecto="sobrio"] .ficha-grupos a.ficha-g { font-weight: 600; color: var(--text-2); }
:root[data-aspecto="sobrio"] .ficha-grupos a.ficha-g:hover { color: var(--text); }
:root[data-aspecto="sobrio"] .ficha-grupos a.ficha-g.active { color: var(--text); font-weight: 700; border-bottom-color: var(--oro); }
:root[data-aspecto="sobrio"] .ficha-g.active > .ico-l { color: var(--oro-texto, var(--accent)); }
:root[data-aspecto="sobrio"] .ficha-grupos .ficha-g .c:not(.urg-bad):not(.urg-warn) { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
/* Subpestañas: la elegida, hoja clara con el texto en tinta (de noche, en oro) */
:root[data-aspecto="sobrio"] .ficha-subs { background: var(--surface-2); border-color: var(--border); }
:root[data-aspecto="sobrio"] .ficha-subs a:hover { background: var(--hover); }
:root[data-aspecto="sobrio"] .ficha-subs a.on { background: var(--surface); color: var(--accent); box-shadow: 0 0 0 1px var(--border), var(--sh-1); }
