/* PEARL PROJECT — mobile layout (v17.8.43). Everything is scoped to phones (<=720px). */
#mobileBar,#mobileBackdrop{display:none}

@media (max-width:720px){
  html,body{overflow-x:hidden}
  body{-webkit-text-size-adjust:100%}
  /* 16px inputs stop iOS from zooming in on focus */
  input,select,textarea{font-size:16px!important}
  /* comfortable touch targets for form fields and main buttons only (chat/HR micro-buttons stay small) */
  select,textarea,input:not([type=checkbox]):not([type=radio]){min-height:40px}
  .primary,.modal-head .iconbtn,.view-options button,.login-card button{min-height:40px}

  /* ---- top app bar ---- */
  #mobileBar{display:flex;align-items:center;gap:8px;position:fixed;top:0;left:0;right:0;height:56px;
    padding:0 8px calc(0px) 8px;padding-top:env(safe-area-inset-top);box-sizing:content-box;
    background:#14223a;color:#fff;z-index:900;box-shadow:0 2px 10px rgba(0,0,0,.18)}
  #mobileBar button{border:0;background:none;color:#fff;width:44px;height:44px;min-height:44px;border-radius:10px;
    display:flex;align-items:center;justify-content:center;position:relative;flex-shrink:0}
  #mobileBar button:active{background:rgba(255,255,255,.12)}
  .mb-burger{display:grid;gap:4px}.mb-burger i{display:block;width:20px;height:2px;background:#fff;border-radius:2px}
  #mobileMenuDot{position:absolute;top:9px;right:9px;width:9px;height:9px;border-radius:50%;background:#ef4444;border:2px solid #14223a}
  #mobileMenuDot[hidden]{display:none}
  .mb-title{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.15}
  .mb-brand{font-size:10px;letter-spacing:1.4px;color:#5ca3ff;font-weight:700}
  #mobileTitle{font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #mobileAddBtn{font-size:26px;font-weight:300;background:#2f6fed!important;width:40px!important;height:40px!important;min-height:40px!important}
  #mobileAddBtn[hidden]{display:none}

  /* ---- sidebar becomes a slide-out drawer ---- */
  #app{display:block!important;padding-top:calc(56px + env(safe-area-inset-top))}
  #app .sidebar{position:fixed!important;top:0;bottom:0;left:0;width:84vw;max-width:310px;min-width:0;height:100dvh;
    min-height:0;padding:18px 14px calc(18px + env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain;
    transform:translateX(-105%);transition:transform .22s ease;z-index:1000;display:flex;flex-direction:column}
  body.nav-open #app .sidebar{transform:none;box-shadow:6px 0 30px rgba(0,0,0,.35)}
  #app .sidebar .tiny{display:block;padding:6px 10px 14px}
  #app .sidebar .sidebar-footer{display:block;position:static;margin-top:auto;padding-top:14px}
  #app .sidebar nav{display:grid!important;overflow:visible;margin-top:10px;gap:4px}
  #app .sidebar nav button{white-space:normal;padding:12px 14px;font-size:15px}
  #app .sidebar .navsmall{display:block;width:100%;padding:12px 14px;font-size:15px}
  #mobileBackdrop{display:block;position:fixed;inset:0;background:rgba(10,20,35,.45);z-index:950;opacity:0;pointer-events:none;transition:opacity .2s}
  body.nav-open #mobileBackdrop{opacity:1;pointer-events:auto}
  body.nav-open{overflow:hidden}

  /* ---- page ---- */
  #app main{padding:0 12px calc(24px + env(safe-area-inset-bottom));height:auto;overflow:visible}
  main>header{padding:14px 0 10px!important;flex-wrap:wrap}
  main>header .eyebrow{display:none}
  main>header h1{font-size:20px;margin:0}
  main>header #addBtn{display:none}
  #content{min-width:0}
  /* wide diagrams keep their own min-width and scroll sideways */
  .org-modern,.org-depts-wrap,#content :is(div,section):has(> .org-depts){overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
  #content img,#content video,#content canvas,#content svg{max-width:100%}
  /* any table scrolls sideways inside its own box instead of stretching the page */
  #content :is(div,section,article,details,form):has(> table){overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
  #content .norm584-table{display:block;overflow-x:auto;max-width:100%;-webkit-overflow-scrolling:touch}
  /* the chat page has its own "+" (attach); the new-task button is not needed there */
  body.on-chat-page #mobileAddBtn{display:none}
  #content table{font-size:13px}
  #content th,#content td{white-space:nowrap}
  /* grids collapse to one column */
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .report-grid,.form-grid,.pc-shell,.pc-grid,.hr-doc-layout{grid-template-columns:minmax(0,1fr)!important}
  .board{grid-template-columns:minmax(0,1fr)!important}
  .view-options,.people-controls-top,.filters,.toolbar,.report-filter{flex-wrap:wrap}
  .report-filter select,.report-filter input{flex:1 1 140px;max-width:100%}
  /* gantt / wide charts: horizontal scroll */
  .gantt,.gantt-wrap,.gantt-chart,[class*="gantt"]{overflow-x:auto;-webkit-overflow-scrolling:touch}

  /* ---- dialogs: full screen ---- */
  .modal-backdrop{padding:0!important;align-items:stretch!important;z-index:1100!important}
  .toast{z-index:1000002!important}
  .modal-backdrop .modal{width:100vw!important;max-width:100vw!important;height:100dvh;max-height:100dvh!important;
    border-radius:0!important;margin:0!important;padding:0 14px calc(18px + env(safe-area-inset-bottom))!important;overflow-y:auto}
  .modal-head{position:sticky;top:0;background:#fff;z-index:5;padding:12px 0 10px;margin:0 0 6px;border-bottom:1px solid #e5eaf1}
  .modal-head h2{font-size:17px}
  .modal-head .iconbtn{width:44px;height:44px}
  .modal .primary,.modal button.primary{min-height:46px}
  .hr-dialog{width:100%!important;max-width:100%!important}

  /* ---- toast above the home indicator ---- */
  .toast{left:12px!important;right:12px!important;bottom:calc(14px + env(safe-area-inset-bottom))!important;max-width:none!important}

  /* ---- price calculator ---- */
  .pc-shell,.pc-shell *{max-width:100%}
  .pc-banner,.pc-intro{flex-direction:column;padding:16px!important}
  .pc-intro h2{font-size:20px!important}
  .pc-shell .pc-summary{position:static!important}

  /* ---- HR ---- */
  .hr-shell .hr-tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .hr-shell .hr-toolbar,.hr-shell .hr-tabs{flex-wrap:wrap;gap:6px}

  /* ---- chat: list OR conversation, full height ---- */
  .on-chat-page main>header{display:none!important}
  .on-chat-page #app main{padding:0!important}
  .on-chat-page .chat-layout{grid-template-columns:minmax(0,1fr)!important;height:calc(100dvh - 56px - env(safe-area-inset-top))!important;
    min-height:0!important;border-radius:0!important;margin:0!important;border:0!important}
  .on-chat-page .chat-sidebar{padding:12px 10px}
  .on-chat-page .chat-sidebar-title small,.on-chat-page .chat-contact-time{display:initial}
  .on-chat-page .chat-contact{padding:10px 8px;gap:10px}
  .on-chat-page .chat-contact b{font-size:14px}
  .on-chat-page .chat-contact small{font-size:12px}
  .on-chat-page .chat-sidebar .chat-avatar{width:40px;height:40px}
  body.on-chat-page:not(.chat-thread-open) .chat-main{display:none!important}
  body.on-chat-page.chat-thread-open .chat-sidebar{display:none!important}
  #mobileChatBack{border:0;background:#eef3fb;color:#1d3c6e;width:40px;height:40px;min-height:40px;border-radius:50%;
    font-size:20px;flex-shrink:0;margin-right:8px;display:inline-flex;align-items:center;justify-content:center}
  .on-chat-page .chat-header{display:flex;align-items:center;padding:0 10px!important}
  .on-chat-page .chat-main .chat-compose{padding:6px 8px calc(6px + env(safe-area-inset-bottom))!important}
  .on-chat-page .chat-main .chat-messages{bottom:128px!important}
  .on-chat-page .chat-main .pearl-topic-nav{padding:0 8px}
  .on-chat-page .chat-main .pearl-topic-nav .pearl-topic-caption{display:none}
}

@media (min-width:721px){
  #mobileChatBack{display:none}
}
