/* Final shared layout rules: compact controls can grow when their text wraps. */
*, *::before, *::after { box-sizing: border-box; }
fieldset, legend, dl, dt, dd { min-width: 0; }
fieldset { max-width: 100%; }
dd { overflow-wrap: anywhere; }
body :is(button:not(.standard-menu):not(.dashboard-menu), input[type="submit"],
  input[type="button"], input[type="reset"], .button, .btn, .workspace-button,
  .project-primary, .project-secondary, .project-status-button, .portal-signout,
  .qa-choice, .member-suggestion-button, .trade-project-button) {
  height: auto !important;
  min-height: var(--s2e-button-height, 32px) !important;
  padding-top: 5px !important;
  padding-bottom: 5px !important;
  white-space: normal;
  overflow-wrap: anywhere;
  flex-shrink: 0;
}
body .project-photo-trigger {
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  border-radius: 7px !important;
  display: block !important;
}
body .owner-account-menu > .owner-identity {
  height: auto !important;
  min-height: 32px !important;
  padding-block: 6px !important;
}
dialog {
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
}
:is(.lead-table-wrap, .users-table-wrap, .suggestion-table-scroll,
  .member-suggestion-table-scroll, .trade-credit-table-wrap, .bar-chart) {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
:is(.dialog-actions, .user-confirm-actions, .user-dialog-footer > div,
  .project-photo-meta, .workspace-steps, .workspace-faq-tabs, .ai-steps) {
  flex-wrap: wrap;
}
@media (max-width: 960px), (pointer: coarse) {
  body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select, textarea) {
    font-size: 16px !important;
  }
}
@media (max-width: 960px) {
  body[data-portal="trade"] .trade-account-links {
    position: static;
    width: 100%;
    max-width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }
  body[data-portal="trade"] .trade-account-menu {
    flex: 1;
    min-width: 0;
  }
  body[data-portal="trade"] .portal-user {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  body[data-portal="trade"] .standard-header .standard-nav {
    padding-bottom: 22px;
    max-height: calc(100vh - 82px);
    max-height: calc(100dvh - 82px);
    overscroll-behavior: contain;
  }
  .standard-header .standard-nav > a,
  body[data-portal="trade"] .trade-account-links > a {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
  .standard-header .standard-header-inner { gap: 18px; }
  .portal-page .standard-header .standard-header-inner {
    height: 82px;
    min-height: 82px;
  }
}
@media (max-width: 880px) {
  .dashboard-header { gap: 14px; }
  .dashboard-nav .dashboard-lead-options {
    position: static;
    min-width: 0;
    margin-top: 8px;
    box-shadow: none;
  }
}
@media (max-width: 768px) {
  :is(.dashboard-title, .user-dialog-header, .project-photo-heading,
    .policy-dialog-foot) { flex-wrap: wrap; }
  :is(.dialog-actions, .user-confirm-actions, .user-dialog-footer > div) {
    gap: 10px;
    max-width: 100%;
  }
  .home-page .hero-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 280px);
    max-width: 100%;
    justify-items: start;
  }
  body.home-page .hero-actions .button {
    height: auto !important;
    min-height: var(--s2e-button-height) !important;
    white-space: normal;
  }
}
@media (max-width: 640px) {
  .portal-page .standard-header .standard-header-inner {
    height: 70px;
    min-height: 70px;
  }
  body[data-portal="trade"] .standard-header .standard-nav {
    max-height: calc(100vh - 70px);
    max-height: calc(100dvh - 70px);
  }
  .portal-user-copy { min-width: 0; }
  .portal-user-copy :is(strong, small) { overflow-wrap: anywhere; }
  .dashboard-title { align-items: flex-start; gap: 16px; }
  .policy-dialog-head { gap: 10px; }
  .workspace-account, .workspace-actions { overflow-wrap: anywhere; }
}
@media (max-width: 390px) {
  .dashboard-header { padding-inline: 14px; }
  .dashboard-logo { width: 154px; }
  .portal-card, .dialog-inner, .user-confirm-content { padding: 18px; }
}
@media (max-height: 500px) {
  dialog {
    max-height: calc(100vh - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
  }
  .policy-dialog-content {
    max-height: calc(100vh - 150px);
    max-height: calc(100dvh - 150px);
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Source audit: keep native controls and content within their grid/flex tracks. */
label, output, figure { min-width: 0; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select, textarea { min-width: 0; max-width: 100%; }
input[type="date"], input[type="datetime-local"], input[type="time"] {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
input::-webkit-date-and-time-value { min-width: 0; text-align: left; }
input::-webkit-datetime-edit { min-width: 0; padding: 0; }
legend { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
:is(.portal-content, .portal-main, .dashboard-shell, .legal-article)
  :is(p, dt, dd, li, h1, h2, h3, .status-message) { overflow-wrap: anywhere; }
#json-output { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.estimate-cost-table-wrap { min-width: 0; max-width: 100%; overflow-x: auto; }
:is(.managed-update-actions, .draft-actions, .publish-success > div,
  .ai-actions, .lead-actions, .project-create-heading, .projects-heading,
  .project-list-heading, .project-card-top, .owner-project-photo-head,
  .estimate-terms-heading, .checkout-section-heading, .update-section-heading,
  .update-section-heading > div, .managed-update-head, .dashboard-update-pagination) {
  flex-wrap: wrap;
}
@media (max-width: 960px) {
  .standard-header .standard-nav a {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
@media (max-width: 640px) {
  :is(.form-actions, .lead-actions, .managed-update-actions, .draft-actions,
    .publish-success > div, .ai-actions) { gap: 10px; }
  .project-review-group > summary small { white-space: normal; }
  .internal-badge { max-width: 100%; white-space: normal; }
}
/* Touch controls keep a full tap area; desktop retains its compact spacing. */
@media (pointer: coarse) {
  body :is(button:not(.project-photo-trigger), input[type="submit"],
    input[type="button"], input[type="reset"], .button, .btn, .workspace-button,
    .project-primary, .project-secondary, .project-status-button, .portal-signout,
    .qa-choice, .member-suggestion-button, .trade-project-button,
    .standard-menu, .dashboard-menu, .owner-account-menu > .owner-identity) {
    min-height: 44px !important;
  }
  .standard-menu, .dashboard-menu, .policy-dialog-close { min-width: 44px; }
  .policy-dialog-close { min-height: 44px !important; }
}

/* Wide data stays readable within its own scroll region instead of tiny columns. */
.member-suggestion-table{min-width:640px}
.suggestion-admin-table{min-width:720px}
.trade-credit-table{min-width:420px}
