/* BOSS Mobile 1.0 presentation. Shared data, actions, and permissions stay in each portal. */
html, body { max-width: 100%; }
body { overflow-x: clip; }
img, video, canvas { max-width: 100%; height: auto; }
main, .main, .content, #content, #bossV59Content, .page, .wrap { min-width: 0; max-width: 100%; }
.boss-msg-back, .boss-r18b-msg-back { display: none; }

@media (max-width: 1024px) {
  .grid, .grid4, .dash-grid, .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  main, .main, .content, #content, #bossV59Content {
    overflow-x: clip;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .nav-item, .bv59nav button, .nav button, .boss-fpu-menu-btn, .menu-btn, .mobile-bar button {
    min-height: 44px;
  }
  .boss-dispatch-layout {
    grid-template-columns: 1fr !important;
  }
  #bossV13R3Pipeline {
    display: grid !important;
    grid-template-columns: 1fr !important;
    overflow-x: hidden;
    gap: 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  #bossV13R3Pipeline > [data-boss-pipeline-stage] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .boss-msg-shell, .boss-r18b-msg-shell, .bos-chat-shell, .msg-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
    max-height: none !important;
  }
  .boss-msg-shell .boss-msg-main,
  .boss-r18b-msg-shell .boss-r18b-msg-main,
  .bos-chat-shell .bos-chat-main,
  .msg-layout .msg-pane {
    display: none;
  }
  .boss-msg-shell.is-thread .boss-msg-sidebar,
  .boss-r18b-msg-shell.is-thread .boss-r18b-msg-sidebar,
  .bos-chat-shell.is-thread .bos-chat-list,
  .msg-layout.thread-open .msg-list {
    display: none;
  }
  .boss-msg-shell.is-thread .boss-msg-main,
  .boss-r18b-msg-shell.is-thread .boss-r18b-msg-main,
  .bos-chat-shell.is-thread .bos-chat-main,
  .msg-layout.thread-open .msg-pane {
    display: flex;
  }
  .boss-msg-back, .boss-r18b-msg-back, .msg-back { display: inline-flex; min-height: 44px; align-items: center; }
  .modal, .boss-msg-modal, .boss-jp-panel, .boss-jp-sheet, [role="dialog"] {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
    box-sizing: border-box;
  }
  .boss-jp-sheet { padding: 0; }
  header, .boss-fpu-mobile-bar {
    padding-top: max(10px, env(safe-area-inset-top));
  }
}

@media (max-width: 932px) {
  header {
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    min-height: 0;
  }
  header h2 { font-size: 18px; }
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 100%;
  }
  #userEmail {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .content, .main, .wrap { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .card, .job, .boss-fpu-job {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  #content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  #content select,
  #content textarea,
  .main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  .main select,
  .main textarea,
  main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  main select,
  main textarea,
  form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  form select,
  form textarea {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    font-size: 16px;
    box-sizing: border-box;
  }
  #content button,
  .main button,
  main button,
  .card button,
  .boss-fpu-actions button,
  .boss-fpu-actions a,
  button.primary,
  a.btn {
    min-height: 44px;
  }
  #accept, #decline, #confirm, .approve, .decline {
    width: 100%;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
  }
  #content table.boss-mobile-record,
  .main table.boss-mobile-record,
  #bossV59Content table.boss-mobile-record {
    display: block;
    width: 100%;
    border-collapse: separate;
  }
  #content table.boss-mobile-record thead,
  .main table.boss-mobile-record thead,
  #bossV59Content table.boss-mobile-record thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  #content table.boss-mobile-record tr,
  .main table.boss-mobile-record tr,
  #bossV59Content table.boss-mobile-record tr {
    display: block;
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px solid #dce4ec;
    border-radius: 12px;
    background: #fff;
  }
  #content table.boss-mobile-record td,
  .main table.boss-mobile-record td,
  #bossV59Content table.boss-mobile-record td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    width: auto;
    border: 0;
    padding: 6px 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  #content table.boss-mobile-record td::before,
  .main table.boss-mobile-record td::before,
  #bossV59Content table.boss-mobile-record td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #667085;
    text-align: left;
    flex: 0 0 42%;
  }
  canvas[id*="sig" i], canvas[id*="Sign" i], .sig, .pad, canvas.sig {
    width: 100%;
    max-width: 100%;
    touch-action: none;
  }
  img, .boss-jp-photo, .tile img {
    max-width: 100%;
    object-fit: cover;
  }
  .boss-note-panel {
    position: fixed;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    top: calc(64px + env(safe-area-inset-top));
    width: auto;
    max-height: calc(100dvh - 88px - env(safe-area-inset-bottom));
  }
}
