/*
 * Utilidades u-*: una propiedad cada una (salvo los helpers de accesibilidad).
 * Viven en la penúltima capa: ganan a cualquier componente sin necesitar especificidad.
 */
@layer utilities {
  /* `hidden` siempre gana, aunque un componente declare display */
  [hidden] { display: none !important; }

  /* Accesibilidad */
  .u-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
  .u-sr-only-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }

  /* Números: cifras tabulares y ancho reservado (§3.4, regla no negociable) */
  .u-num, .c-qty, .c-money, td[data-type="number"], .c-kpi__value {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
  }

  /* Texto */
  .u-truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
  .u-nowrap { white-space: nowrap; }
  .u-break { overflow-wrap: anywhere; }
  .u-text-right { text-align: right; }
  .u-text-center { text-align: center; }
  .u-mono { font-family: var(--font-mono); }
  .u-strong { font-weight: var(--fw-medium); }
  .u-muted { color: var(--text-secondary); }
  .u-subtle { color: var(--text-tertiary); }
  .u-text-success { color: var(--success); }
  .u-text-warning { color: var(--warning); }
  .u-text-danger { color: var(--danger); }
  .u-text-info { color: var(--info); }
  .u-small { font: var(--type-help); }
  .u-caption { font: var(--type-caption); }
  .u-overline {
    font: var(--type-overline);
    letter-spacing: var(--tr-overline);
    text-transform: uppercase;
    color: var(--text-tertiary);
  }

  /* Espaciado puntual (la composición se hace con l-stack / l-cluster) */
  .u-mt-0 { margin-top: 0; }
  .u-mt-2 { margin-top: var(--sp-2); }
  .u-mt-4 { margin-top: var(--sp-4); }
  .u-mt-6 { margin-top: var(--sp-6); }
  .u-mb-2 { margin-bottom: var(--sp-2); }
  .u-mb-4 { margin-bottom: var(--sp-4); }
  .u-ml-auto { margin-left: auto; }
  .u-p-0 { padding: 0; }

  /* Flex */
  .u-grow { flex: 1 1 auto; min-width: 0; }
  .u-shrink-0 { flex-shrink: 0; }
  .u-w-full { width: 100%; }

  /* Visibilidad por punto de quiebre (móvil primero). md = 640 px, lg = 900 px */
  @media (max-width: 639.98px) {
    .u-hide-md-down { display: none !important; }
  }
  @media (min-width: 640px) {
    .u-hide-md-up { display: none !important; }
  }
  @media (max-width: 899.98px) {
    .u-hide-lg-down { display: none !important; }
  }
  @media (min-width: 900px) {
    .u-hide-lg-up { display: none !important; }
  }

  /* Solo impresión / nunca en impresión */
  .u-print-only { display: none !important; }

  /* Red de seguridad de movimiento reducido (§10.3). Las decisiones finas viven en cada componente */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 1ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 1ms !important;
      scroll-behavior: auto !important;
    }
  }
}
