/* One scroll body and reachable actions for phone-sized agent profile dialogs. */
@media (max-width: 768px) {
  #agent-details-modal {
    inset: auto;
    top: var(--agent-viewport-top, 0px);
    left: var(--agent-viewport-left, 0px);
    width: var(--agent-viewport-width, 100vw);
    height: var(--agent-viewport-height, 100dvh);
    box-sizing: border-box;
    padding: max(8px, env(safe-area-inset-top)) 8px calc(max(12px, env(safe-area-inset-bottom)) + 28px);
    align-items: stretch;
    overflow: hidden;
  }
  #agent-details-modal > .agent-details-card {
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: 100% !important;
    height: 100%;
    max-height: 100% !important;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden !important;
    transform: none !important;
  }
  #agent-details-modal .details-modal-header {
    flex: 0 0 auto;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }
  #agent-details-modal .details-modal-title { min-width: 0; }
  #agent-details-modal .details-modal-title h2 { font-size: 20px !important; overflow-wrap: anywhere; }
  #agent-details-modal .modal-close-btn { flex: 0 0 40px; width: 40px; height: 40px; font-size: 24px; }
  #agent-details-modal .agent-details-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y pinch-zoom;
    padding: 0 4px 16px 0;
  }
  #agent-details-modal .agent-details-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 16px !important; }
  #agent-details-modal .agent-details-grid > div { min-width: 0; grid-column: auto !important; }
  #agent-details-modal p { overflow-wrap: anywhere; }
  #agent-details-modal .agent-commission-list { max-height: none !important; height: auto !important; overflow: visible !important; }
  #agent-details-modal .agent-commission-list thead { position: static !important; }
  #agent-details-modal .agent-commission-list th,
  #agent-details-modal .agent-commission-list td { padding: 10px 8px !important; font-size: 12px !important; white-space: normal; overflow-wrap: anywhere; }
  #agent-details-modal .agent-profile-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px !important;
    margin-top: 0 !important;
    padding-top: 12px !important;
    padding-bottom: 4px;
    background: #12132c;
  }
  #agent-details-modal .agent-profile-actions button { min-height: 44px; min-width: 0; white-space: normal; }
  #cloud-agent-profile-dialog[open] {
    position: fixed;
    inset: auto;
    top: calc(var(--agent-viewport-top, 0px) + 12px);
    left: calc(var(--agent-viewport-left, 0px) + 8px);
    margin: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: calc(var(--agent-viewport-width, 100vw) - 16px) !important;
    max-width: calc(var(--agent-viewport-width, 100vw) - 16px) !important;
    height: calc(var(--agent-viewport-height, 100dvh) - 24px);
    max-height: calc(var(--agent-viewport-height, 100dvh) - 24px) !important;
    padding: 16px !important;
    overflow: hidden !important;
  }
  #cloud-agent-profile-dialog > h2 { font-size: 20px; margin: 0 0 8px; overflow-wrap: anywhere; }
  #cloud-agent-profile-dialog > p { font-size: 13px; margin: 6px 0; }
  #cloud-agent-profile-form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
  #cloud-agent-profile-form .agent-profile-fields { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding: 0 4px 12px 0; }
  #cloud-agent-profile-form .agent-profile-fields > div:first-child { grid-template-columns: minmax(0, 1fr) !important; }
  #cloud-agent-profile-form input,
  #cloud-agent-profile-form select,
  #cloud-agent-profile-form textarea { font-size: 16px; box-sizing: border-box; max-width: 100%; }
  #cloud-agent-profile-form .agent-profile-actions { display: flex; flex: 0 0 auto; gap: 10px; padding: 12px 0 max(4px, env(safe-area-inset-bottom)); border-top: 1px solid #454b60; }
  #cloud-agent-profile-form .agent-profile-actions button { flex: 1; min-height: 44px; }
}
