/* Final responsive safeguards shared by the portal and every application. */
html,
body.has-itft-shell {
  max-width: 100%;
  overflow-x: hidden;
}

body.has-itft-shell :where(img, canvas, svg, video, iframe) {
  max-width: 100%;
}

body.has-itft-shell :where(.card, .tool-card, .panel, .form-card, .content, main, section) {
  min-width: 0;
}

body.has-itft-shell :where(.table-wrap, .table-container) {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

body.has-itft-shell :where(.actions, .action-row, .toolbar, .section-row, .result-bar, .link-row) {
  flex-wrap: wrap;
}

body.has-itft-shell :where(input, select, textarea, button) {
  max-width: 100%;
}

/* Allow long labels, legal wording and identifiers to wrap safely. */
body.has-itft-shell :where(h1, h2, h3, h4, h5, h6, p, li, label, legend, summary, a, button, th, td, output) {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}

body.has-itft-shell :where(h1, h2, h3, h4, h5, h6) {
  height: auto;
  overflow: visible;
  text-wrap: balance;
}

body.has-itft-shell :where(button, .btn, .button, .small, .badge, .tool-badge) {
  height: auto;
  white-space: normal;
  text-align: center;
}

body.has-itft-shell :where(.grid, .tool-grid, .content-grid, .form-grid, .filters, .method, .contact, .details-grid, .guides, .parties, .privacy-grid, .discovery-grid, .status-grid, .corner-list, .flag-grid, .conditional-grid, .totals-preview, .level-grid, .preview-head, .preview-parties) > * {
  min-width: 0;
}

body.has-itft-shell :where(.section-heading, .section-head, .header-row, .invoice-top, .card-top) > * {
  min-width: 0;
}

/* PINT-AE uses an eyebrow and heading inside the same wrapper. Keep them on
   separate lines at every width so the eyebrow can never collide with h2. */
body.itft-pint-ae-validator .section-heading > div {
  display: grid;
  gap: 7px;
}

body.itft-pint-ae-validator .section-heading :where(.eyebrow, h2) {
  display: block;
  margin: 0;
}

body.itft-pint-ae-validator .section-heading {
  align-items: start;
}

body.itft-pint-ae-validator .panel {
  overflow: hidden;
}

@media (max-width: 640px) {
  body.has-itft-shell :where(.grid, .tool-grid, .content-grid, .form-grid, .form-grid.three, .form-grid.four, .filters, .method, .contact, .details-grid, .guides, .parties, .privacy-grid, .discovery-grid, .status-grid, .corner-list, .flag-grid, .conditional-grid, .totals-preview, .level-grid, .preview-head, .preview-parties, .locked-values, .meta-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.has-itft-shell :where(.span-2, .span-3, .span-4, .full) {
    grid-column: auto !important;
  }

  body.has-itft-shell :where(.section-heading, .section-head, .header-row, .invoice-top) {
    align-items: flex-start;
    flex-direction: column;
  }

  body.has-itft-shell :where(.actions, .action-row, .toolbar, .result-bar) {
    align-items: stretch;
    flex-direction: column;
  }

  body.has-itft-shell :where(.actions, .action-row, .toolbar, .result-bar) > :where(button, .btn, .button, a) {
    width: 100%;
  }

  body.has-itft-shell :where(.report-bar, .toolbar, .action-row, .section-row) {
    gap: 10px;
  }

  body.has-itft-shell :where(.card, .tool-card, .panel, .form-card) {
    height: auto !important;
    max-height: none;
  }

  body.has-itft-shell :where(.table-wrap, .table-container, .table-scroll) {
    border-radius: 10px;
  }

  .itft-shell-brand__text span {
    font-size: 0.78rem;
  }

  .itft-shell-nav a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
  }

  .itft-export__menu {
    position: fixed;
    top: 62px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 82px);
    overflow-y: auto;
  }
}

@media (max-width: 420px) {
  .itft-shell-brand__mark {
    width: 31px;
    height: 31px;
  }

  .itft-export summary {
    padding-inline: 9px;
    font-size: 0.78rem;
  }
}
