/* Shared screen typography for the member and admin portals.
   Match the 13px main navigation; keep headings, totals and icon sizes intact.
   Explicit overrides also cover older pages and their late inline styles. */
@media screen {
  :root { --mx-portal-text-size: 13px; }

  body :is(.page-content, .ua-workspace, .modal-content, .mx-cp-member-dialog,
    .hff-review) {
    font-size: var(--mx-portal-text-size);
  }

  body :is(.page-content, .ua-workspace, .modal-content, .mx-cp-member-dialog,
    .hff-review) :is(
      p, li, td, th, small, label, legend, dt, dd, button, input, select,
      textarea, summary, caption, figcaption, code, pre,
      .help-block, .help-inline, .form-control, .control-label, .btn,
      .label, .badge, .caption-helper, .form-actions,
      .font-xs, .font-sm, .text-small, .small,
      .ua-eyebrow, .ua-identity > span, .ua-sandbox, .ua-sandbox > strong,
      .ua-tag, .ua-field > span, .ua-choice, .ua-choice strong,
      .ua-package > span, .ua-package em, .ua-metric > span,
      .ua-metric strong em, .ua-summary-line, .ua-summary-total,
      .ua-summary-total em, .ua-table td strong, .ua-pagination,
      .ua-note, .ua-quote-banner, .ua-links, .ua-footer,
      .ua-progress, .ua-required, .ua-test-identities span,
      .ua-country-wallets > div > span, .ua-country-wallets em,
      .ua-country-readonly, .ua-payer-balance, .ua-product-row > div > strong,
      .ua-product-heading h4,
      .ua-allocation-status, .ua-product-details,
      .ua-saved-beneficiaries span, .ua-saved-beneficiaries strong,
      .ua-bonus-preview-line, .ua-submitter > span, .ua-delete-blocked,
      .ua-checkout-price-meta, .ua-checkout-price-delivery,
      .ua-checkout-allocation, .mx-cp-member-picker > span,
      .hff-review-summary span, .hff-review-summary > div > strong,
      .mx-member-context > div > span, .mx-member-context-links > span,
      .mx-admin-kicker, .mx-settings-kicker, .mx-settings-sections > span,
      .mx-permission-code, .mx-modal-section, .mx-copy-status,
      .mx-mail-kicker, .mx-mail-role, .mx-mail-snippet, .mx-mail-pagination,
      .mx-mail-broadcast, .mx-mail-help, .mx-folder-note,
      .mx-welcome-tag, .mx-member-meta, .mx-member-meta strong,
      .mx-membership > span, .mx-quick-actions > a > span,
      .mx-quick-actions strong, .mx-metric > span, .mx-section-heading > span,
      .mx-wallet-row, .mx-lifetime span, .mx-update > span,
      .mx-binary-eyebrow, .mx-binary-root-package, .mx-binary-summary span,
      .mx-binary-legend, .mx-binary-level-label, .mx-binary-node-title,
      .mx-binary-node-package, .mx-binary-package, .mx-binary-node-number,
      .mx-binary-node-empty-label, [data-tree-zoom-label]
    ) {
    font-size: var(--mx-portal-text-size) !important;
  }

  /* Links normally follow their surrounding copy. Heading and metric links
     inherit their larger parent size instead of being reduced to body size. */
  body :is(.page-content, .ua-workspace, .modal-content, .mx-cp-member-dialog,
    .hff-review) a {
    font-size: max(var(--mx-portal-text-size), 1em) !important;
  }

  /* Larger labels may wrap; fixed-height single-line legacy buttons/fields
     retain enough space to show the whole line. */
  body :is(.page-content, .ua-workspace, .modal-content, .mx-cp-member-dialog,
    .hff-review) :is(.ua-field select, .form-control) {
    min-height: 38px;
  }

  /* Keep the fixed binary-tree rows and their connectors aligned. */
  body .page-content [data-mx-binary-tree] .mx-binary-node {
    gap: 4px;
  }
  body .page-content [data-mx-binary-tree] .mx-binary-node-package {
    white-space: normal;
    line-height: 1.1;
    overflow-wrap: anywhere;
  }
  body .page-content [data-mx-binary-tree] .mx-binary-node-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  /* Sign-in keeps its larger copy and controls; lift its small field labels. */
  body .clean-login :is(.ua-field, .ua-field > span, small) {
    font-size: var(--mx-portal-text-size) !important;
  }
  body .clean-login :is(.ua-field input, .ua-button) {
    font-size: 16px !important;
  }

  @media (max-width: 767px) {
    /* Avoid browser zoom on focus and preserve existing mobile field sizing. */
    body :is(.page-content, .ua-workspace, .modal-content, .mx-cp-member-dialog,
      .hff-review) :is(
        input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=submit]):not([type=button]),
        select, textarea
      ) {
      font-size: 16px !important;
      min-height: 48px;
    }
  }
}
