/* Final device layer for every public, customer and Owner page.
   Desktop retains its existing scale. Keep zoom enabled in every viewport tag. */
@media (max-width: 1024px), (pointer: coarse) {
  body {
    --s2e-body: 17px; --s2e-label: 16px; --s2e-caption: 13px;
    --s2e-title: 32px; --s2e-section: 26px; --s2e-subheading: 21px;
    --s2e-button-height: 44px; --s2e-button-text: 16px; --s2e-button-padding: 14px;
    font-size: 17px !important; line-height: 1.6;
  }
  *, *::before, *::after { box-sizing: border-box; }
  body, main, section, article, nav, form, fieldset, div { min-width: 0; }
  body { width: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body :is(p, li, dd) { font-size: var(--s2e-body) !important; line-height: 1.65 !important; }
  body :is(label, legend, dt, th, td) { font-size: 16px !important; line-height: 1.5 !important; }
  body small { font-size: 13px !important; line-height: 1.5 !important; }
  body :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) {
    min-width: 0; max-width: 100%; min-height: 44px !important;
    font-family: inherit; font-size: 16px !important; line-height: 1.5 !important;
  }
  body textarea { min-height: 112px !important; }
  body :is(button:not(.project-photo-trigger), input[type=submit], input[type=button],
    .button, .btn, .workspace-button, .project-primary, .project-secondary,
    .portal-signout, .standard-login, .qa-choice, .member-suggestion-button,
    .trade-project-button, .public-nav-dropdown > summary, .owner-account-menu > summary) {
    height: auto !important; min-height: 44px !important;
    font-size: 16px !important; line-height: 24px !important;
    padding: 10px 14px !important; max-width: 100%;
    white-space: normal; overflow-wrap: anywhere;
  }
  body .project-question-help button {
    width: 44px !important; min-width: 44px !important; padding: 8px !important;
  }
  body :is(.project-photo-arrow, .project-close, .policy-dialog-close) {
    width: 44px !important; min-width: 44px !important; padding: 8px !important;
  }
  body :is(input[type=checkbox], input[type=radio]) {
    flex-shrink: 0; width: 20px; height: 20px; accent-color: #087c69;
  }
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) { min-height: 44px; align-items: center; }
  body :is(h1, h2, h3, p, dd, label, legend, a, summary) { overflow-wrap: anywhere; }
  body.owner-portal h1 { font-size: clamp(28px, 4vw, 36px) !important; }
  body:not(.home-page):not(.owner-portal):not(.portal-page) h1 {
    font-size: clamp(32px, 5vw, 44px) !important; line-height: 1.18 !important;
  }
  body.owner-portal :is(.finance-shell, dialog) button:not(.finance-tool) {
    min-height: 44px !important; font-size: 16px !important;
    line-height: 24px !important; padding: 10px 14px !important;
  }
  body.owner-portal .workspace-picker select {
    height: auto !important; min-height: 44px !important; font-size: 16px !important;
    padding: 10px 30px 10px 12px !important;
  }
  body .owner-portal-header :is(.dashboard-menu, .owner-account-menu > .owner-identity) {
    min-height: 44px !important; font-size: 16px !important; padding: 10px 12px !important;
  }
  body .owner-portal-header .owner-identity strong { font-size: 16px; line-height: 24px; }
  body :is(.standard-nav, .dashboard-nav) > a,
  body .owner-portal-header :is(.dashboard-lead-menu > summary, .owner-account-options a, .dashboard-lead-options a),
  body :is(.public-nav-dropdown > summary, .public-nav-dropdown-links a, .trade-account-links a) {
    min-height: 44px !important; height: auto !important; font-size: 16px !important;
    line-height: 24px !important; padding-block: 10px !important;
  }
  body :is(.owner-page-back, .portal-page-back, .public-page-back) {
    min-height: 44px !important; font-size: 15px !important; line-height: 24px !important;
  }
  body.owner-portal :is(.contact-back,.lead-detail-back,.owner-project-back,#finance-back,#back-employees,#back-to-writing) {
    min-height: 44px !important; font-size: 15px !important;
  }
  body :is(.filter-bar, .lead-toolbar-main, .contact-toolbar, .workspace-toolbar,
    .form-actions, .dialog-actions, .user-dialog-footer, .workspace-steps) { flex-wrap: wrap; gap: 12px; }
  body dialog {
    width: min(860px, calc(100vw - 24px)); max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
    margin: auto; padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  body :is(.project-question-help [role=tooltip], .project-help-tooltip) {
    max-width: min(320px, calc(100vw - 48px)); font-size: 16px; line-height: 1.5;
  }
  .device-table-scroll { max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .device-table-scroll:focus-visible { outline: 3px solid #168a73; outline-offset: 2px; }
  .device-table-hint { color: #455d70; margin: 8px 0 !important; font-size: 14px !important; }
  .standard-footer .footer-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: 16px; }
  .standard-footer .footer-social a { width: 44px; min-height: 44px; }
  input[type=date], input[type=datetime-local], input[type=time] { display: block; width: 100%; min-width: 0; }
  input::-webkit-date-and-time-value { min-width: 0; text-align: left; }
  :is(a, button, summary, input, select, textarea):focus-visible { outline: 3px solid #168a73; outline-offset: 3px; }
}
@media (max-width: 1024px) {
  body :is(.intro, .vision-inner, .split, .founder-grid, .scopewise-intro, .partner-hero-grid,
    .partner-benefits, .early-grid, .program-intro, .program-collaboration-grid, .program-opportunity) {
    grid-template-columns: minmax(0, 1fr); gap: 28px;
  }
  body :is(.dashboard-shell, .finance-shell, .portal-content) {
    width: calc(100% - 40px); max-width: 1160px; margin-inline: auto;
  }
  body :is(.dashboard-stats, .stat-grid, .workspace-actions, .workspace-account,
    .workspace-plans, .workspace-packs, .feature-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body :is(.ai-publisher, .lead-management, .finance-grid, .workspace-two, .company-settings-grid) {
    grid-template-columns: minmax(0, 1fr); gap: 24px;
  }
  .standard-header .standard-header-inner { height: auto; min-height: 82px; }
  body.portal-page .standard-header .standard-header-inner {
    height: auto; min-height: 82px; flex-wrap: wrap; padding-block: 12px;
  }
  body.portal-page .standard-header .standard-nav { top: 100%; max-height: calc(100dvh - 160px); }
  .standard-header .standard-nav { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .standard-footer .standard-footer-inner { align-items: flex-start; gap: 24px; }
}
@media (max-width: 640px) {
  body :is(.shell, .dashboard-shell, .finance-shell, .portal-content) { width: calc(100% - 32px); }
  body :is(.dashboard-shell, .finance-shell, .portal-content) { padding-top: 24px; }
  body :is(.dashboard-stats, .stat-grid, .workspace-actions, .workspace-account, .workspace-plans,
    .workspace-packs, .feature-grid, .form-grid, .field-row, .project-field-row, .project-questions,
    .ai-field-grid, .lead-fields, .employee-summary, .employee-filters, .user-form-grid,
    .onboarding-project-grid, .project-lists, .project-navigation, .minutes-fields) {
    grid-template-columns: minmax(0, 1fr); gap: 16px;
  }
  body .project-checks { grid-template-columns: minmax(0, 1fr); }
  body :is(.dashboard-title, .finance-heading, .updates-heading, .workspace-heading,
    .project-card-top, .project-create-heading, .user-dialog-header) {
    flex-direction: column; align-items: flex-start; gap: 16px;
  }
  body :is(.portal-card, .workspace-card, .finance-card, .form-card, .signup-card) { padding: 20px; }
  body .owner-portal-header {
    grid-template-columns: minmax(0, 1fr) auto; height: auto; min-height: 76px;
    gap: 8px 16px; padding: 12px 16px;
  }
  body .owner-portal-header .dashboard-logo { width: 154px; }
  body .owner-portal-header .owner-actions { grid-column: 1 / -1; grid-row: 2; }
  body .owner-portal-header .owner-identity strong { max-width: 220px; }
  body .owner-portal-header .dashboard-nav { max-height: calc(100dvh - 144px); }
  body.portal-page .standard-header .standard-header-inner { min-height: 70px; }
  body .standard-header .standard-logo { max-width: 180px; }
  body .portal-user { flex-basis: 100%; max-width: 100%; }
  .standard-footer .standard-footer-inner { flex-direction: column; }
  .standard-footer :is(.footer-brand, .footer-links) { flex: none; }
  .standard-footer .footer-links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
  body .bank-review-table .form-grid, body .bank-row .form-grid { grid-template-columns: minmax(0, 1fr); }
  body .filter-bar label { flex: 1 1 100%; min-width: 0; }
  body .search-list-mode .lead-card-head > div:first-child { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
@media print {
  .device-table-hint { display: none !important; }
  .device-table-scroll { overflow: visible; max-width: none; }
}
@media (max-width: 1024px), (pointer: coarse) {
  body :is(.settings-tool, .finance-tool, .company-settings-links a, .workspace-actions a) strong {
    font-size: 17px !important; line-height: 1.5 !important;
  }
}
@media (max-width: 1024px) {
  body :is(.dashboard-title, .beta-title, .beta-title-actions, .finance-heading, .panel-heading) {
    flex-wrap: wrap; min-width: 0; max-width: 100%;
  }
  body .internal-badge { white-space: normal; max-width: 100%; }
}
/* Long roadmap titles/actions must also wrap on wider landscape screens. */
body .beta-title, body .beta-title-actions { flex-wrap: wrap; min-width: 0; max-width: 100%; }

/* Content-sized footer rows avoid flex-basis becoming vertical space on Safari.
   Keep this after page-specific footer rules so every public page agrees. */
body .standard-footer { height: auto; min-height: 0; padding-block: 40px; }
body .standard-footer .standard-footer-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-auto-rows: max-content; align-content: start; align-items: center;
  gap: 20px 32px; height: auto; min-height: 0;
  width: min(1180px, calc(100% - 48px)); max-width: none;
}
body .standard-footer :is(.footer-brand, .footer-social, .footer-links) {
  flex: none; height: auto; min-height: 0; margin: 0;
}
body .standard-footer .footer-social { justify-content: flex-start; }
body .standard-footer .footer-social a { width: 44px; min-height: 44px; }
body .standard-footer .footer-links {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap;
  justify-content: flex-start; align-content: start; gap: 4px 24px;
  padding-top: 16px; border-top: 1px solid #ffffff26;
}
body .standard-footer .footer-links a {
  display: inline-flex; align-items: center; min-height: 44px;
  padding-block: 8px; font-size: 16px; line-height: 1.5;
  overflow-wrap: anywhere;
}
@media (max-width: 1024px) {
  .public-dropdown-header .standard-menu { display: block; }
  .standard-header.public-dropdown-header .standard-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    margin: 0; padding: 20px; background: #fff; flex-direction: column;
    align-items: stretch; gap: 8px; overflow-y: auto;
    max-height: calc(100dvh - 82px); box-shadow: 0 18px 40px #06172824;
  }
  .standard-header.public-dropdown-header .standard-nav.open { display: flex; }
  .public-dropdown-header .public-nav-dropdown { width: 100%; }
  .public-dropdown-header .public-nav-dropdown > summary { justify-content: space-between; }
  .public-dropdown-header .public-nav-dropdown-links {
    position: static; width: 100%; margin-top: 8px; box-shadow: none;
  }
  body .standard-footer .footer-links {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: max-content; align-items: start; gap: 4px 24px;
  }
}
@media (max-width: 640px) {
  body .standard-footer {
    padding-top: 32px; padding-bottom: max(88px, env(safe-area-inset-bottom));
  }
  body .standard-footer .standard-footer-inner {
    width: calc(100% - 40px); grid-template-columns: minmax(0, 1fr); gap: 16px;
  }
  body .standard-footer .footer-links { grid-template-columns: minmax(0, 1fr); }
  .standard-header.public-dropdown-header .standard-nav { max-height: calc(100dvh - 70px); }
}
