/* AGH Ibérica — components/bundle.css del design system (refresh de octubre de 2026), sin la carga de Caladea
   (el panel no muestra documentos). No edites a mano: cópialo del design system; lo propio del panel va en panel.css. */
/* AGH Ibérica — componentes en CSS para cualquier herramienta o pantalla de AGH. Todos los valores salen de tokens.css.
   Refresh 2026-10: más minimalista. Un solo acento rojo por pantalla, líneas finas antes que tarjetas,
   estados como texto en color con icono (sin fondo) y menos mayúsculas. */
body { margin: 0; background: var(--paper); color: var(--text); font-family: var(--font-body); font-size: 16px; line-height: 24px; -webkit-font-smoothing: antialiased; }
.agh-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-4); }
.agh-stack { display: grid; gap: var(--space-3); padding: var(--space-4); }
h1, h2, h3, .agh-h1 { text-wrap: balance; }
p { text-wrap: pretty; }

/* Título de pantalla (display-l): uno por pantalla */
.agh-h1 { font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.1; color: var(--ink); margin: 0; }
@media (max-width: 640px) { .agh-h1 { font-size: 24px; line-height: 1.15; } }

/* Cuadradito de marca y etiquetas: con moderación */
.agh-sq { display: inline-flex; align-items: center; gap: var(--space-2); }
.agh-sq::before { content: ""; width: var(--brand-square); height: var(--brand-square); background: var(--red); flex: none; }
.agh-label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.agh-muted { color: var(--text-muted); }
/* Contorno del cuadrado del logo: estados vacíos, confirmaciones y cargas */
.agh-mark { display: block; width: 32px; height: 32px; border: 2px solid var(--red); border-radius: 8px; flex: none; }
.agh-mark-muted { border-color: var(--line-strong); }
@media (prefers-reduced-motion: no-preference) { .agh-mark-loading { animation: agh-breathe 1.6s ease-in-out infinite; } }
@keyframes agh-breathe { 50% { transform: scale(.88); opacity: .6; } }

/* Enlaces: tinta con subrayado suave */
.agh-link, .agh-stack a, .agh-row a:not([class]) { color: var(--link); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.agh-link:hover { text-decoration-color: currentColor; }

/* Foco común */
.agh-btn:focus-visible, .agh-field:focus-visible, .agh-review:focus-visible, .agh-drop:focus-visible, .agh-option:focus-visible, .agh-header a:focus-visible, .agh-table tbody tr:focus-visible, .agh-tab:focus-visible, .agh-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Barra superior: sobre paper, solo el logo y lo imprescindible */
.agh-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.agh-header-in { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--space-5); min-height: 72px; display: flex; align-items: center; gap: var(--space-4); }
.agh-header-brand { display: inline-flex; align-items: center; border-radius: var(--radius-sm); }
.agh-header-brand img { height: 26px; display: block; }
.agh-header-nav { display: flex; gap: var(--space-1); margin-left: auto; flex-wrap: wrap; align-items: center; }
.agh-header-user { width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--ink); display: grid; place-items: center; font-size: 12px; font-weight: 600; text-decoration: none; }
/* El logo va siempre sobre claro: en oscuro, sobre una placa blanca */
[data-theme="dark"] .agh-header-brand img { background: #FFFFFF; padding: 5px 8px; border-radius: var(--radius-sm); height: 20px; }
@media (max-width: 640px) { .agh-header-in { padding: 0 var(--space-4); } }

/* Botones: píldora; el rojo, solo para la acción principal (una por pantalla) */
.agh-btn { font: inherit; font-size: 14px; font-weight: 600; min-height: var(--control-h-compact); padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: transparent; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); text-decoration: none; white-space: nowrap; transition: background-color 150ms ease-out, border-color 150ms ease-out; }
@media (pointer: coarse) { .agh-btn { min-height: var(--control-h); } }
.agh-btn:hover { background: var(--hover); border-color: var(--ink); }
.agh-btn-primary { background: var(--red-dark); border-color: var(--red-dark); color: var(--on-red); }
.agh-btn-primary:hover { background: var(--red-press); border-color: var(--red-press); }
.agh-btn-ghost { border-color: transparent; color: var(--text); }
.agh-btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--ink); }
.agh-btn-danger { border-color: var(--error); color: var(--error); }
.agh-btn-danger:hover { background: var(--error-soft); border-color: var(--error); }
.agh-btn-sm { min-height: 32px; padding: 0 var(--space-3); font-size: 13px; }
@media (pointer: coarse) { .agh-btn-sm { min-height: var(--control-h); } }
.agh-btn-lg { min-height: var(--control-h); padding: 0 var(--space-5); font-size: 15px; }
.agh-btn[disabled] { opacity: .4; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .agh-btn { transition: none; } }

/* Campos */
.agh-field-wrap { display: grid; gap: 6px; }
.agh-field-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.agh-field-help { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.agh-field { font: inherit; font-size: 16px; min-height: var(--control-h); padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); box-sizing: border-box; width: 100%; }
.agh-field:hover { border-color: var(--line-strong); }
.agh-field:focus-visible { outline-offset: 1px; border-color: transparent; }
textarea.agh-field { padding: var(--space-3); line-height: 22px; min-height: 120px; resize: vertical; }
.agh-field-error, .agh-field[aria-invalid="true"] { border-color: var(--error); }
.agh-field-msg-error { font-size: 13px; line-height: 18px; color: var(--error); }
/* Buscador: sin borde en reposo */
.agh-search { position: relative; display: block; }
.agh-search .agh-field { min-height: 36px; font-size: 14px; padding-left: 34px; border-color: transparent; background: var(--hover); }
.agh-search .agh-field:hover { border-color: var(--line); }
.agh-search::before { content: ""; position: absolute; left: 12px; top: 50%; width: 10px; height: 10px; margin-top: -7px; border: 1.5px solid var(--text-muted); border-radius: 50%; pointer-events: none; }
.agh-search::after { content: ""; position: absolute; left: 22px; top: 50%; width: 5px; height: 1.5px; margin-top: 3px; background: var(--text-muted); transform: rotate(45deg); pointer-events: none; }

/* Subida de archivos */
.agh-drop { border: 1px dashed var(--line-strong); border-radius: var(--radius-md); padding: var(--space-6) var(--space-5); display: grid; justify-items: center; gap: var(--space-1); text-align: center; color: var(--text-muted); font-size: 14px; cursor: pointer; }
.agh-drop:hover, .agh-drop-over { border-color: var(--ink); background: var(--hover); }
.agh-drop strong { color: var(--ink); }
.agh-drop-compact { padding: var(--space-4); }
.agh-drop-icon { width: 20px; height: 20px; border: 1.5px solid var(--ink); border-radius: 5px; margin-bottom: var(--space-1); }
.agh-files { list-style: none; margin: 0; padding: 0; display: grid; }
.agh-file { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }

/* Secciones separadas por líneas: la estructura por defecto */
.agh-section { padding: var(--space-5) 0; border-top: 1px solid var(--line); display: grid; gap: var(--space-3); }
.agh-section:first-child { border-top: 0; padding-top: 0; }
.agh-section-title { font-size: 15px; line-height: 22px; font-weight: 600; color: var(--ink); margin: 0; }

/* Panel: solo cuando un bloque debe ir aparte */
.agh-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-5); display: grid; gap: var(--space-3); }
.agh-panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.agh-panel-relief { background: var(--beige); border-color: transparent; }

/* Estado: icono y palabra en color, sin fondo */
.agh-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; line-height: 20px; white-space: nowrap; color: var(--neutral); }
.agh-badge-pending { color: var(--warning); }
.agh-badge-success { color: var(--success); }
.agh-badge-neutral { color: var(--neutral); }
.agh-badge-info { color: var(--info); }
.agh-badge-error { color: var(--error); }
.agh-badge-locked { color: var(--text-muted); }

/* Pestañas: texto subrayado */
.agh-tabs { display: flex; gap: var(--space-4); border-bottom: 1px solid var(--line); overflow-x: auto; }
.agh-tab { font: inherit; font-size: 14px; font-weight: 500; min-height: 40px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.agh-tab:hover { color: var(--ink); }
.agh-tab[aria-pressed="true"], .agh-tab[aria-selected="true"], .agh-tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.agh-tab-count { color: var(--text-muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* Menú lateral: las secciones de una pantalla de configuración o administración, agrupadas por para qué sirven.
   El elemento activo, en tinta sobre neutral-soft (el rojo queda para la acción principal). Iconos de línea del sistema (assets/Iconos). */
.agh-with-sidenav { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-7); align-items: start; }
.agh-with-sidenav > * { min-width: 0; }
.agh-sidenav { position: sticky; top: var(--space-5); display: grid; gap: var(--space-5); }
.agh-sidenav-group { display: grid; gap: var(--space-2); }
.agh-sidenav-title { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 0 var(--space-3); }
.agh-sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.agh-sidenav-item { display: grid; grid-template-columns: 22px 1fr; column-gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); text-decoration: none; color: var(--text); transition: background-color 150ms ease-out; }
.agh-sidenav-item:hover { background: var(--hover); color: var(--ink); }
.agh-sidenav-item[aria-current="page"] { background: var(--neutral-soft); color: var(--ink); }
.agh-sidenav-icon { height: 22px; display: grid; place-items: center; color: var(--text-muted); }
.agh-sidenav-item:hover .agh-sidenav-icon, .agh-sidenav-item[aria-current="page"] .agh-sidenav-icon { color: var(--ink); }
.agh-sidenav-name { font-size: 15px; line-height: 22px; font-weight: 500; }
.agh-sidenav-item[aria-current="page"] .agh-sidenav-name { font-weight: 600; }
@media (max-width: 960px) {
  /* Estrecho: el menú pasa arriba como una fila desplazable, sin títulos de grupo */
  .agh-with-sidenav { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .agh-sidenav { position: static; display: flex; gap: var(--space-1); overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: var(--space-2); }
  .agh-sidenav-group { display: contents; }
  .agh-sidenav-title { display: none; }
  .agh-sidenav ul { display: flex; gap: var(--space-1); }
  .agh-sidenav-item { white-space: nowrap; }
}

/* Menú de acciones: un botón «⋯» (agh-btn-icon) que abre una lista flotante de acciones secundarias */
.agh-btn-icon { width: 36px; padding: 0; }
@media (pointer: coarse) { .agh-btn-icon { width: var(--control-h); } }
.agh-btn-icon svg { width: 16px; height: 16px; fill: currentColor; }
.agh-btn-icon[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.agh-menu { position: fixed; z-index: 5; min-width: 200px; display: grid; padding: var(--space-1); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-overlay); }
.agh-menu-item { display: flex; align-items: center; gap: var(--space-2); font: inherit; font-size: 14px; line-height: 20px; text-align: left; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); cursor: pointer; }
@media (pointer: coarse) { .agh-menu-item { min-height: var(--control-h); } }
.agh-menu-item:hover:not(:disabled) { background: var(--hover); }
.agh-menu-item-danger { color: var(--error); }
.agh-menu-item:disabled { color: var(--text-muted); cursor: not-allowed; }
.agh-menu-icon { width: 18px; height: 18px; flex: none; display: grid; place-items: center; }

/* Iconos de línea (assets/Iconos): rejilla de 20, trazo de 1.5 en el color del texto y extremos redondeados.
   Van en línea (<svg class="agh-icon">) para heredar el color; siempre acompañan a un texto y llevan aria-hidden. */
.agh-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.agh-menu-icon .agh-icon { width: 18px; height: 18px; }
.agh-sidenav-item:focus-visible, .agh-menu-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { .agh-sidenav-item { transition: none; } }

/* Pasos */
.agh-steps { display: flex; gap: var(--space-2); list-style: none; margin: 0; padding: 0; counter-reset: s; flex-wrap: wrap; }
.agh-step { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--text-muted); padding-right: var(--space-4); }
.agh-step::before { counter-increment: s; content: counter(s); width: 20px; height: 20px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.agh-step-done { color: var(--text); }
.agh-step-done::before { content: "✓"; background: var(--ink); border-color: var(--ink); color: var(--paper); }
.agh-step-current { color: var(--ink); font-weight: 600; }
.agh-step-current::before { border-color: var(--ink); color: var(--ink); }
/* Variante en una línea: «Paso 2 de 3 · Revisar» */
.agh-steps-text { margin: 0; font-size: 13px; line-height: 18px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Línea de tiempo: seguimiento de un registro */
.agh-timeline { list-style: none; margin: 0; padding: 0; display: grid; font-size: 14px; line-height: 20px; }
.agh-timeline li { position: relative; display: grid; grid-template-columns: 12px 1fr; gap: var(--space-3); padding-bottom: var(--space-4); color: var(--text-muted); }
.agh-timeline li:last-child { padding-bottom: 0; }
.agh-timeline li::before { content: ""; width: 8px; height: 8px; margin: 6px 0 0 2px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--paper); box-sizing: border-box; }
.agh-timeline li:not(:last-child)::after { content: ""; position: absolute; left: 5.5px; top: 16px; bottom: 2px; width: 1px; background: var(--line); }
.agh-timeline .agh-timeline-done { color: var(--ink); }
.agh-timeline .agh-timeline-done::before { background: var(--ink); border-color: var(--ink); }
.agh-timeline .agh-timeline-current { color: var(--ink); font-weight: 600; }
.agh-timeline .agh-timeline-current::before { background: var(--red); border-color: var(--red); }
.agh-timeline .agh-timeline-failed { color: var(--error); }
.agh-timeline .agh-timeline-failed::before { background: var(--error); border-color: var(--error); }
.agh-timeline small { display: block; font-size: 13px; font-weight: 400; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Cifra clave con barra */
.agh-meter { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-5); align-items: end; padding: var(--space-5); background: var(--beige); border-radius: var(--radius-md); }
.agh-meter-num { font-family: var(--font-display); font-size: 64px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.agh-meter-num small { font-size: 20px; color: var(--text-muted); }
.agh-meter-bar { grid-column: 1 / -1; height: 6px; background: var(--surface); border-radius: var(--radius-pill); overflow: hidden; }
.agh-meter-bar > span { display: block; height: 100%; background: var(--red); }

/* Tarjeta de revisión: propuesta frente a original */
.agh-review { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: var(--space-4) var(--space-5); display: grid; gap: var(--space-3); }
.agh-review-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.agh-review-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.agh-review-col { min-width: 0; }
.agh-review-col p { margin: var(--space-1) 0 0; font-size: 14px; line-height: 21px; color: var(--text); }
.agh-review-why { font-size: 13px; line-height: 19px; color: var(--text-muted); border-top: 1px solid var(--line); padding-top: var(--space-3); }
.agh-review-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.agh-review-accepted { border-color: var(--success); }
.agh-review-rejected { background: var(--paper); }
.agh-review-rejected .agh-review-col-new p { text-decoration: line-through; color: var(--text-muted); }
ins.agh-add { background: var(--diff-add); text-decoration: underline; text-decoration-color: var(--success); text-underline-offset: 3px; color: var(--ink); }
del.agh-del { background: var(--diff-del); color: var(--text-muted); }
@media (max-width: 640px) { .agh-review-cols { grid-template-columns: 1fr; } }

/* Avisos */
.agh-notice { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--ink); font-size: 14px; line-height: 20px; }
.agh-notice-icon { font-weight: 700; color: var(--warning); }
.agh-notice-error { background: var(--error-soft); }
.agh-notice-error .agh-notice-icon { color: var(--error); }
.agh-notice-info { background: var(--neutral-soft); }
.agh-notice-info .agh-notice-icon { color: var(--text-muted); }
.agh-notice-success { background: var(--success-soft); }
.agh-notice-success .agh-notice-icon { color: var(--success); }

/* Opción seleccionable */
.agh-option { display: grid; gap: 2px; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: transparent; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.agh-option:hover { border-color: var(--line-strong); }
.agh-option-title { font-weight: 600; color: var(--ink); }
.agh-option-meta { font-size: 13px; color: var(--text-muted); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.agh-option-selected, .agh-option[aria-pressed="true"] { border-color: var(--ink); }

/* Tabla: solo líneas entre filas */
.agh-table-wrap { overflow-x: auto; }
.agh-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.agh-table th { text-align: left; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--text-muted); padding: var(--space-3) var(--space-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.agh-table td { padding: var(--space-4) var(--space-2); border-bottom: 1px solid var(--line); color: var(--text); vertical-align: middle; }
.agh-table tbody tr:hover { background: var(--hover); }
.agh-table .agh-num { text-align: right; font-variant-numeric: tabular-nums; }
.agh-table td strong { color: var(--ink); font-weight: 500; }

/* Estado vacío: sin fondo, el cuadrado del logo y una sola acción */
.agh-empty { display: grid; justify-items: center; gap: var(--space-3); text-align: center; padding: var(--space-8) var(--space-5); color: var(--text-muted); font-size: 14px; }
.agh-empty strong { color: var(--ink); font-size: 16px; line-height: 24px; }
.agh-empty .agh-drop-icon, .agh-empty .agh-mark { width: 32px; height: 32px; border: 2px solid var(--red); border-radius: 8px; margin-bottom: var(--space-2); }

/* Diálogo (<dialog> nativo): atrapa el foco y se cierra con Escape */
.agh-dialog { width: min(30rem, calc(100% - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--text); box-shadow: var(--shadow-overlay); }
.agh-dialog::backdrop { background: rgba(22, 21, 20, .4); }
.agh-dialog-body { padding: var(--space-5) var(--space-5) var(--space-4); display: grid; gap: var(--space-3); }
.agh-dialog-body h2 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 600; color: var(--ink); }
.agh-dialog-body p { margin: 0; font-size: 15px; }
.agh-dialog-foot { display: flex; flex-wrap: wrap-reverse; gap: var(--space-2); justify-content: flex-end; padding: 0 var(--space-5) var(--space-5); }
@media (max-width: 640px) { .agh-dialog-foot .agh-btn { flex: 1; } }

/* Hoja de documento AGH */
.agh-doc { background: var(--doc-paper); color: var(--doc-ink); font-family: var(--font-doc); font-size: 11px; line-height: 1.45; padding: 36px 40px; border: 1px solid var(--line); border-top: 4px solid var(--doc-red); box-shadow: var(--shadow-card); max-width: 560px; }
.agh-doc-logo { height: 26px; display: block; margin: 0 0 18px auto; }
.agh-doc-name { font-size: 22px; font-weight: 700; color: var(--doc-red); margin: 0; }
.agh-doc-role { font-weight: 700; margin: 2px 0 12px; font-size: 13px; }
.agh-doc-section { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; font-weight: 700; font-size: 13px; margin: 14px 0 6px; }
.agh-doc-section::before, .agh-doc-section::after { content: ""; height: 2px; background: var(--doc-red); }
.agh-doc ul { margin: 2px 0; padding-left: 16px; }
.agh-doc-muted { color: var(--doc-muted); }
.agh-doc-hl { background: var(--diff-add); outline: 1px dashed var(--success); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
