/* UI UX Pro Max integration: shared interaction quality, existing brand tokens.
   Screen-only rules keep warehouse/print documents independent. */
@media screen {
  :root {
    --ui-focus: var(--tdf-focus, #175cd3);
    --ui-surface: var(--tdf-surface, #fff);
    --ui-border: var(--tdf-border, #d8e1db);
    --ui-ink: var(--tdf-text, #17221c);
    --ui-muted: var(--tdf-text-muted, #58645d);
    --ui-brand: var(--tdf-primary, #087a45);
    --ui-brand-hover: var(--tdf-hover, #056237);
    --ui-brand-soft: var(--tdf-soft, #eaf7f0);
    --ui-radius: var(--tdf-radius-md, 12px);
    --ui-scroll-clearance: 112px;
  }

  /* Dual-color focus remains visible on both pale and dark theme surfaces. */
  body:not(.issue-note-page) :is(a, button, input, select, textarea, summary, [tabindex]:not(main)):focus-visible {
    outline: 3px solid var(--ui-focus) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 3px #fff;
  }
  body:not(.issue-note-page) :is(a, button, input, select, textarea, summary, [tabindex], h1, h2, h3) {
    scroll-margin-block: var(--ui-scroll-clearance);
  }
  body:not(.issue-note-page) :is(button, .btn, summary, select) {
    touch-action: manipulation;
  }
  body:not(.issue-note-page) :is(button, .btn, summary):not(:disabled):not([aria-disabled="true"]) {
    cursor: pointer;
  }
  body:not(.issue-note-page) :is(button:disabled, [aria-disabled="true"]) {
    cursor: not-allowed;
  }
  body:not(.issue-note-page) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
    box-sizing: border-box;
    min-inline-size: 0;
    max-inline-size: 100%;
  }
  body:not(.issue-note-page) textarea { resize: vertical; }
  body:not(.issue-note-page) :is(h1, h2, h3, .line-name, .product-name, .cart-item-title, .customer-profile dd) {
    overflow-wrap: anywhere;
  }
  body:not(.issue-note-page) a { text-underline-offset: .2em; }
  body:not(.issue-note-page) :is(.price-strong, .product-price, .customer-money, .kpi strong, .sale-kpi-grid strong, .v14-money) {
    font-variant-numeric: tabular-nums;
  }

  .ui-skip-link {
    position: fixed;
    inset-block-start: 8px;
    inset-inline-start: 8px;
    z-index: 2147483647;
    transform: translateY(calc(-100% - 16px));
    padding: 12px 18px;
    border: 2px solid var(--ui-focus);
    border-radius: 8px;
    background: #fff;
    color: #17221c;
    font: 600 16px/1.5 'Segoe UI', system-ui, sans-serif;
  }
  .ui-skip-link:focus { transform: none; }

  /* Storefront: reinforce the existing theme and expose keyboard card focus. */
  .web-order .product-card {
    border-color: var(--ui-border);
  }
  .web-order .product-card:focus-within {
    border-color: var(--ui-brand);
  }
  .web-order :is(.product-info, .product-heading, .cart-item-title) { min-inline-size: 0; }
  .web-order .product-info h3 { line-height: 1.5 !important; }

  /* Admin keeps its dense tables; only toolbar/navigation groups can reflow. */
  .admin-body :is(.admin-title, .admin-top, .admin-filters) { gap: 12px; flex-wrap: wrap; }
  .admin-body :is(.admin-main, .admin-wrap, .admin-card, .admin-title > div) { min-inline-size: 0; }
  .admin-body .admin-title p { max-inline-size: 75ch; line-height: 1.6; }
  .admin-body .admin-nav-children a { overflow-wrap: anywhere; }

  /* Sale adopts the established brand roles instead of hard-coded ruby. */
  .sale-body .sale-top strong,
  .sale-body .sale-tabs button[aria-pressed="true"],
  .sale-body .sale-tabs a[aria-current="page"],
  .sale-body .sale-product-options > summary { color: var(--ui-brand); }
  .sale-body .sale-tabs { flex-wrap: wrap; }
  :is(.sale-body, .sale-login) .btn.primary {
    background: var(--ui-brand);
    border-color: var(--ui-brand);
    color: var(--tdf-on-primary, #fff);
  }
  :is(.sale-body, .sale-login) .btn.primary:hover:not(:disabled) {
    background: var(--ui-brand-hover);
  }
  .sale-body .sale-card { border-color: var(--ui-border); border-radius: var(--ui-radius); }
  .sale-body :is(.sale-top > div, .sale-order-actions > div, .sale-pair > *) { min-inline-size: 0; }
  .sale-body .sale-top > div { flex-wrap: wrap; }
  .sale-body .sale-selected { background: var(--ui-brand-soft); color: var(--ui-ink); }

  /* Customer account: legible secondary text on the existing warm surfaces. */
  .customer-portal :is(.customer-muted, .customer-result-count, .customer-profile dt, .customer-order-table small, .customer-footer) {
    color: var(--ui-muted);
  }
  .customer-portal :is(.customer-header nav, .customer-section-heading, .customer-pagination) { flex-wrap: wrap; }
  .customer-portal :is(.customer-header nav > *, .customer-card, .customer-account-grid > *) { min-inline-size: 0; }
  .customer-portal :is(.customer-money, .customer-stats strong) { font-variant-numeric: tabular-nums; }

  @media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .web-order .product-card { transition: border-color 160ms ease, box-shadow 160ms ease; }
  }
  @media (pointer: coarse), (max-width: 700.98px) {
    body:not(.issue-note-page) :is(.btn, .v14-button, .sale-tabs button, .customer-account-nav a, .admin-nav-children a) {
      min-block-size: 44px;
      box-sizing: border-box;
    }
    body:not(.issue-note-page) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
      font-size: max(16px, var(--ui-input, 16px)) !important;
    }
    .customer-portal .customer-pagination { gap: 12px; }
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
    body:not(.issue-note-page) *, body:not(.issue-note-page) *::before, body:not(.issue-note-page) *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
      scroll-behavior: auto !important;
    }
  }
  @media (forced-colors: active) {
    body:not(.issue-note-page) :is(a, button, input, select, textarea, summary, [tabindex]:not(main)):focus-visible {
      outline-color: Highlight !important;
      box-shadow: none;
    }
    .sale-body .sale-tabs button[aria-pressed="true"] { outline: 2px solid Highlight; }
  }
}
@media print {
  .ui-skip-link { display: none !important; }
}
