/* Final enterprise accessibility, interaction-state and dense-table layer. */

body.premium-ui .skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 1000;
  padding: 9px 13px;
  border: 1px solid var(--wx-primary-border);
  border-radius: var(--wx-radius-sm);
  color: #fff;
  background: var(--wx-primary);
  box-shadow: var(--wx-shadow-float);
  font-size: 13px;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--wx-duration-fast) var(--wx-ease);
}

body.premium-ui .skip-link:focus {
  outline: 2px solid #fff !important;
  outline-offset: 2px !important;
  transform: translateY(0);
}

body.premium-ui :where(button, a, input, select, textarea, summary, [tabindex], [role="button"]):focus-visible {
  outline: 2px solid rgba(53, 89, 199, 0.68) !important;
  outline-offset: 2px !important;
}

body.premium-ui :where(.table-wrap, .table-container, .auto-table-wrap)[data-a11y-table="true"]:focus-visible {
  outline-offset: 3px !important;
  box-shadow: var(--wx-focus) !important;
}

body.premium-ui :where(.table-wrap, .table-container, .auto-table-wrap)[data-overflowing="true"] {
  overscroll-behavior-inline: contain;
  background:
    linear-gradient(90deg, rgba(255,255,255,0), rgba(53,89,199,0.05) 100%) !important;
  scrollbar-gutter: stable;
}

body.premium-ui :where(.table-wrap, .table-container, .auto-table-wrap)[data-overflowing="true"]::-webkit-scrollbar {
  height: 9px;
}

body.premium-ui :where(.table-wrap, .table-container, .auto-table-wrap)[data-overflowing="true"]::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--wx-border-strong);
}

body.premium-ui :where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--wx-danger) !important;
  background: var(--wx-danger-soft) !important;
  box-shadow: 0 0 0 3px rgba(178, 59, 75, 0.12) !important;
}

body.premium-ui :where(button, input, select, textarea):disabled,
body.premium-ui [aria-disabled="true"] {
  color: var(--wx-text-faint) !important;
  background-color: var(--wx-surface-muted) !important;
}

body.premium-ui #content[aria-busy="true"] {
  cursor: progress;
}

body.premium-ui :where(.loading-state, .module-loading-card, [data-loading="true"]) {
  position: relative;
}

body.premium-ui :where(.loading-state, .module-loading-card, [data-loading="true"])::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--wx-primary);
  transform-origin: left;
  animation: ui-enterprise-loading 1.2s ease-in-out infinite;
}

body.premium-ui :where(.empty, .empty-state) {
  min-height: 144px;
  border: 1px dashed var(--wx-border-strong) !important;
  border-radius: var(--wx-radius-md) !important;
  background: var(--wx-surface-subtle) !important;
}

body.premium-ui :where(.error, .error-state, .module-error) {
  border-color: var(--wx-danger-border) !important;
  color: var(--wx-danger) !important;
  background: var(--wx-danger-soft) !important;
}

body.premium-ui #modal[aria-hidden="true"] {
  pointer-events: none;
}

body.premium-ui #modal[aria-hidden="false"] .modal-card {
  outline: none;
}

body.premium-ui .modal-head .close:focus-visible {
  color: var(--wx-primary) !important;
  background: var(--wx-primary-soft) !important;
}

body.premium-ui nav button[aria-current="page"] {
  font-weight: 500 !important;
}

body.premium-ui :where(.tag, .status-tag, .badge, .pill) {
  max-width: 100%;
  vertical-align: middle;
}

body.premium-ui :where(.money, [data-type="amount"], [data-type="quantity"], .numeric),
body.premium-ui :where(td, th):has(time) {
  font-variant-numeric: tabular-nums lining-nums;
}

@keyframes ui-enterprise-loading {
  0% { transform: scaleX(0.08); opacity: 0.45; }
  50% { transform: scaleX(0.7); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

@media (max-width: 640px) {
  body.premium-ui #content :where(.primary, .secondary, .outline, .danger-button, .ghost, button.link) {
    min-height: 40px !important;
  }

  body.premium-ui #content :where(.table-wrap, .table-container, .auto-table-wrap) button {
    min-height: 32px !important;
  }

  body.premium-ui .sidebar-toggle {
    width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
  }

  body.premium-ui aside summary,
  body.premium-ui aside nav button[data-page] {
    min-height: 40px !important;
  }

  body.premium-ui :where(.table-wrap, .table-container, .auto-table-wrap)[data-overflowing="true"] {
    border-radius: var(--wx-radius-sm) !important;
  }
}

@media (prefers-contrast: more) {
  body.premium-ui :where(.card, .stat, .table-wrap, .table-container, .auto-table-wrap, input, select, textarea) {
    border-color: var(--wx-border-strong) !important;
  }

  body.premium-ui :where(.tag, .status-tag, .badge, .pill) {
    border: 1px solid currentColor !important;
  }
}

@media (forced-colors: active) {
  body.premium-ui :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid Highlight !important;
  }

  body.premium-ui :where(.tag, .status-tag, .badge, .pill) {
    border: 1px solid CanvasText !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.premium-ui .skip-link { transition: none; }
  body.premium-ui :where(.loading-state, .module-loading-card, [data-loading="true"])::before { animation: none; }
}
