/* Shortgap responsive overlay — loaded after the production bundle. */
html,
body,
#root {
  max-width: 100%;
  min-width: 0;
}

body {
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.role-tabs:empty {
  display: none !important;
}

.exact-marketing-host,
.exact-marketing-frame {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100vh;
  min-height: 100dvh;
  border: 0;
}

@media (max-width: 900px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }

  .app-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    position: relative;
    z-index: 40;
    flex: 0 0 auto;
    min-height: 58px;
    height: 58px;
    padding: 0 12px;
  }

  .app-header .header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: auto !important;
    min-width: 44px;
    margin-left: auto;
  }

  .app-header .profile-menu {
    margin-left: auto;
  }

  .app-header .brand-logo,
  .app-header .header-brand {
    min-width: 0;
  }

  .app-header .brand-logo img,
  .app-header .header-brand img {
    width: auto;
    max-width: min(42vw, 168px);
    max-height: 38px;
  }

  .profile-trigger,
  .profile-signout,
  .profile-dropdown button,
  .role-tab,
  .workspace-sidebar button,
  .workspace-sidebar a,
  .credit-nav button,
  .credit-nav a,
  .form-actions button,
  .terms-action-row button,
  .terms-card-head button,
  .list-tools button,
  .dashboard-tabs button,
  .table-pagination button,
  .row-action-primary,
  .row-action-secondary,
  .sponsor-row-actions button,
  .sponsor-row-actions a,
  .application-reference-link,
  .table-link,
  .doc-icon-action,
  .modal-close-button,
  .decision-actions button,
  .decision-side button,
  .analysis-main button {
    min-height: 44px !important;
  }

  .app-shell button,
  .app-shell [role="button"] {
    min-height: 44px !important;
  }

  .doc-icon-action,
  .icon-button,
  .modal-close-button {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
  }

  .profile-trigger {
    min-width: 44px;
    padding: 4px 8px;
  }

  .profile-dropdown {
    position: fixed;
    top: 54px;
    right: 12px;
    left: 12px;
    z-index: 100;
    width: auto;
    max-width: none;
  }

  .role-tabs {
    flex: 0 0 auto;
    min-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-inline: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .role-tabs::-webkit-scrollbar,
  .workspace-sidebar::-webkit-scrollbar,
  .credit-nav::-webkit-scrollbar,
  .dashboard-tabs::-webkit-scrollbar {
    display: none;
  }

  .role-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sponsor-terms-alert {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: center;
    margin: 8px 12px;
    padding: 10px 12px;
  }

  .sponsor-terms-alert strong,
  .sponsor-terms-alert span {
    min-width: 0;
  }

  .sponsor-terms-alert strong {
    grid-column: 1;
  }

  .sponsor-terms-alert span {
    grid-column: 1;
    overflow-wrap: anywhere;
  }

  .sponsor-terms-alert button,
  .sponsor-terms-alert a {
    grid-column: 2;
    grid-row: 1 / 3;
    min-height: 44px;
    white-space: nowrap;
  }

  .workspace-container,
  .credit-workspace {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    height: auto !important;
    min-height: 0;
    overflow: hidden;
  }

  .workspace-sidebar,
  .credit-nav {
    display: flex !important;
    flex: 0 0 auto;
    flex-direction: row;
    gap: 8px;
    width: 100%;
    max-width: none;
    min-height: 60px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .workspace-sidebar > *,
  .credit-nav > * {
    flex: 0 0 auto;
  }

  .workspace-sidebar button,
  .workspace-sidebar a,
  .credit-nav button,
  .credit-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
  }

  .workspace-main,
  .credit-dashboard-main,
  .analysis-main {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 16px 12px max(28px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .page-header,
  .workspace-page-header,
  .dashboard-header,
  .analysis-top,
  .list-card-head,
  .terms-card-head,
  .card-header,
  .section-header {
    gap: 12px;
    align-items: flex-start;
  }

  .page-header > *,
  .workspace-page-header > *,
  .dashboard-header > *,
  .analysis-top > *,
  .list-card-head > *,
  .terms-card-head > * {
    min-width: 0;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  li,
  dd,
  td,
  th,
  label,
  span {
    overflow-wrap: anywhere;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 112px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }

  .checkbox-label,
  .radio-label,
  label:has(> input[type="checkbox"]),
  label:has(> input[type="radio"]) {
    min-height: 44px;
  }

  .form-grid,
  .application-grid,
  .details-grid,
  .profile-grid,
  .analysis-grid,
  .checklist-grid,
  .flag-grid,
  .rule-grid,
  .decision-grid,
  .document-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-field,
  .field,
  .card,
  .step-panel,
  .analysis-content,
  .decision-side,
  .ai-report,
  .score-hero,
  .dashboard-list-card,
  .sponsor-app-table-card,
  .terms-application-card {
    min-width: 0;
    max-width: 100%;
  }

  .form-actions,
  .terms-action-row,
  .decision-actions,
  .sponsor-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .form-actions button,
  .terms-action-row button,
  .decision-actions button {
    flex: 1 1 150px;
  }

  .steps-nav,
  .stepper,
  .progress-steps {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dashboard-tabs {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .dashboard-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .list-card-head,
  .list-tools {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .list-tools {
    gap: 8px;
  }

  .application-search-input,
  .status-filter-select {
    width: 100% !important;
    max-width: none !important;
  }

  .terms-summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .terms-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .terms-card-head {
    display: flex;
    flex-wrap: wrap;
  }

  .terms-card-head button,
  .terms-card-head a {
    min-height: 44px;
  }

  /* Turn data-heavy desktop tables into readable mobile cards. Labels are
     supplied by mobile-responsive.js so the production bundle stays intact. */
  .sponsor-app-table-card,
  .dashboard-list-card {
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .sponsor-app-table-card .app-table,
  .credit-app-table,
  .sponsor-app-table-card .app-table tbody,
  .credit-app-table tbody {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .sponsor-app-table-card .app-table thead,
  .credit-app-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .sponsor-app-table-card .app-table tbody tr,
  .credit-app-table tbody tr {
    display: block;
    width: 100%;
    margin: 0 0 12px;
    overflow: hidden;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(30, 45, 68, 0.06);
  }

  .sponsor-app-table-card .app-table tbody td,
  .credit-app-table tbody td {
    display: grid;
    grid-template-columns: minmax(104px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    min-height: 44px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    text-align: left !important;
    white-space: normal !important;
  }

  .sponsor-app-table-card .app-table tbody td:last-child,
  .credit-app-table tbody td:last-child {
    border-bottom: 0;
  }

  .sponsor-app-table-card .app-table tbody td::before,
  .credit-app-table tbody td::before {
    content: attr(data-label);
    color: #667085;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan])::before,
  .credit-app-table tbody td:not([colspan])::before {
    grid-column: 1;
    grid-row: 1;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan]) > *,
  .credit-app-table tbody td:not([colspan]) > * {
    grid-column: 2;
    min-width: 0;
    max-width: 100%;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan]) > br,
  .credit-app-table tbody td:not([colspan]) > br {
    display: none;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan]) > :nth-child(1),
  .credit-app-table tbody td:not([colspan]) > :nth-child(1) {
    grid-row: 1;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan]) > :nth-child(2),
  .credit-app-table tbody td:not([colspan]) > :nth-child(2) {
    grid-row: 2;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan]) > :nth-child(3),
  .credit-app-table tbody td:not([colspan]) > :nth-child(3) {
    grid-row: 2;
  }

  .sponsor-app-table-card .app-table tbody td:not([colspan]) > :nth-child(4),
  .credit-app-table tbody td:not([colspan]) > :nth-child(4) {
    grid-row: 3;
  }

  .sponsor-app-table-card .app-table tbody td[colspan],
  .credit-app-table tbody td[colspan] {
    display: block;
    padding: 24px 12px;
    text-align: center !important;
  }

  .sponsor-app-table-card .app-table tbody td[colspan]::before,
  .credit-app-table tbody td[colspan]::before {
    display: none;
  }

  .application-reference-link,
  .table-link {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding-block: 6px;
  }

  .sponsor-row-actions {
    align-items: center;
  }

  .table-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }

  .analysis-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px;
  }

  .analysis-main h1,
  .analysis-main h2,
  .analysis-main h3,
  .analysis-main h4,
  .analysis-main strong,
  .analysis-main span,
  .analysis-main p {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  .approval-matrix-head,
  .review-matrix-card .matrix-head {
    align-items: flex-start;
  }

  .approval-stage-track {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px 8px !important;
    width: 100%;
    padding-bottom: 0 !important;
    overflow: visible !important;
  }

  .approval-stage {
    min-width: 0 !important;
  }

  .analysis-content,
  .decision-side {
    width: 100%;
  }

  .score-hero,
  .ai-head,
  .ai-body {
    max-width: 100%;
  }

  .score-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-row,
  .checklist-row,
  .approval-row,
  .matrix-row {
    min-width: 0;
    max-width: 100%;
  }

  .document-row > *,
  .checklist-row > *,
  .approval-row > *,
  .matrix-row > * {
    min-width: 0;
  }

  .modal-overlay,
  .dialog-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .modal,
  .dialog,
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  .app-header .user-info,
  .app-header .profile-copy {
    display: none;
  }

  .page-header,
  .workspace-page-header,
  .dashboard-header,
  .analysis-top,
  .list-card-head,
  .terms-card-head,
  .card-header,
  .section-header {
    flex-direction: column;
  }

  .page-header > button,
  .page-header > a,
  .workspace-page-header > button,
  .workspace-page-header > a,
  .dashboard-header > button,
  .dashboard-header > a,
  .analysis-top > button,
  .analysis-top > a,
  .terms-card-head > button,
  .terms-card-head > a {
    width: 100%;
  }

  .form-grid,
  .application-grid,
  .details-grid,
  .profile-grid,
  .checklist-grid,
  .flag-grid,
  .rule-grid,
  .decision-grid,
  .document-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .score-hero,
  .ai-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .score-ring {
    align-self: center;
  }

  .approval-matrix-head,
  .review-matrix-card .matrix-head {
    display: flex;
    flex-direction: column;
  }

  .approval-stage-track {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .form-actions,
  .terms-action-row,
  .decision-actions {
    flex-direction: column;
  }

  .form-actions button,
  .terms-action-row button,
  .decision-actions button {
    flex: 0 0 auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .workspace-main,
  .credit-dashboard-main,
  .analysis-main {
    padding-inline: 10px;
  }

  .workspace-sidebar,
  .credit-nav {
    padding-inline: 10px;
  }

  .sponsor-terms-alert {
    grid-template-columns: minmax(0, 1fr);
  }

  .sponsor-terms-alert button,
  .sponsor-terms-alert a {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }

  .terms-summary-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .terms-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .score-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .sponsor-app-table-card .app-table tbody td,
  .credit-app-table tbody td {
    grid-template-columns: minmax(88px, 31%) minmax(0, 1fr);
    padding-inline: 10px;
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
  }

  .dashboard-tabs button {
    width: 100%;
  }
}

@media (max-width: 340px) {
  .dashboard-stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .sponsor-app-table-card .app-table tbody td,
  .credit-app-table tbody td {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .approval-stage-track {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
