/* GableLink mobile layer (v2.16.0)
 * Loaded on every page. Everything here is scoped to phones and small tablets
 * (max-width: 820px), so the desktop layout is untouched.
 *  - No sideways scrolling: the page never gets wider than the screen
 *  - Top nav → slim app bar + slide-out menu + bottom tab bar
 *  - Tables → cards (gl-mobile.js labels each cell from its column header)
 *  - Charts, images, video and modals fit the screen
 *  - Inputs at 16px so iPhone doesn't zoom when you tap a field
 * Opt out on any element: data-mobile="keep" (leave layout alone),
 * on a table: data-mobile="table" (keep it a table, scroll inside its own box).
 */

/* ---------- elements injected by gl-mobile.js (hidden on desktop) ---------- */
.glm-burger, .glm-tabbar, .glm-drawer, .glm-scrim, .glm-install, .glm-mdbar, .glm-backbar, .glm-sectbtn { display: none; }

@media (max-width: 820px) {
  html { overflow-x: hidden; }
  @supports (overflow: clip) { html { overflow-x: clip; } }
  body { max-width: 100vw; overflow-x: clip; -webkit-text-size-adjust: 100%; }
  img, video, canvas, iframe, embed, object { max-width: 100% !important; }
  img, video { height: auto; }
  canvas { height: auto !important; }
  svg[viewBox]:not(.ic) { max-width: 100%; }
  pre, code { white-space: pre-wrap; word-break: break-word; }
  p, h1, h2, h3, h4, li, label, dd, dt { overflow-wrap: break-word; }

  /* iPhone zooms in on any field under 16px — stop that */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),
  select, textarea { font-size: 16px !important; }

  /* ---------- shared app nav (.nav-wrapper pages) ---------- */
  .nav-wrapper .subnav,
  .nav-wrapper .nav-company,
  .nav-wrapper .topnav-search,
  .nav-wrapper .user-info,
  .nav-wrapper .acct-caret { display: none !important; }
  .nav-wrapper .topnav { padding-left: 6px !important; padding-right: 10px !important; gap: 4px; padding-top: env(safe-area-inset-top); }
  .nav-wrapper .topnav-right { margin-left: auto; gap: 2px !important; flex: 0 0 auto; }
  .nav-wrapper .topnav-icon-btn { width: 40px; height: 40px; }
  .nav-wrapper .nav-logo { margin-right: 0 !important; font-size: 18px !important; }
  .nav-wrapper .acct-menu { right: 0; left: auto; max-width: calc(100vw - 20px); }
  body.glm-has-tabbar { padding-bottom: calc(68px + env(safe-area-inset-bottom)) !important; }

  .glm-burger {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 42px; height: 42px; margin-right: 2px; border: 0; border-radius: 10px;
    background: transparent; color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .glm-burger:active { background: rgba(255,255,255,.1); }
  .glm-burger svg { width: 22px; height: 22px; }
  .glm-burger.glm-floating {
    position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 10px; z-index: 9000;
    background: #0F172A; box-shadow: 0 6px 20px rgba(15,23,42,.35);
  }

  /* ---------- slide-out menu ---------- */
  .glm-scrim {
    display: block; position: fixed; inset: 0; z-index: 2147482990; background: rgba(15,23,42,.5);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .glm-drawer {
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 2147482995;
    width: min(86vw, 340px); background: linear-gradient(180deg, #0F172A 0%, #13243F 100%); color: #fff;
    transform: translateX(-102%); transition: transform .26s cubic-bezier(.32,.72,0,1);
    box-shadow: 20px 0 50px rgba(0,0,0,.35); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
  }
  html.glm-open .glm-scrim { opacity: 1; pointer-events: auto; }
  html.glm-open .glm-drawer { transform: none; }
  html.glm-open, html.glm-open body { overflow: hidden !important; }

  .glm-dhead { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .glm-dhead .glm-brand { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
  .glm-dhead .glm-brand b { color: #A5B4FC; font-weight: 800; }
  .glm-dhead .glm-brand i { font-style: normal; color: #5EEAD4; }
  .glm-dhead .glm-co { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 1px; }
  .glm-dclose { margin-left: auto; width: 38px; height: 38px; border-radius: 10px; border: 0; background: rgba(255,255,255,.08); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
  .glm-dsearch { margin: 12px 14px 4px; position: relative; }
  .glm-dsearch input {
    width: 100%; box-sizing: border-box; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06); color: #fff; padding: 0 14px 0 40px; outline: none;
  }
  .glm-dsearch input::placeholder { color: rgba(255,255,255,.4); }
  .glm-dsearch svg { position: absolute; left: 13px; top: 13px; width: 18px; height: 18px; color: rgba(255,255,255,.45); }
  .glm-dbody { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 10px 16px; overscroll-behavior: contain; }
  .glm-dnew, .glm-dgroup > button.glm-dnew {
    display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 4px 10px; height: 46px; border-radius: 12px;
    background: linear-gradient(135deg, #4F46E5, #6366F1); color: #fff; font-weight: 700; font-size: 15px; border: 0; width: calc(100% - 8px);
    box-shadow: 0 8px 22px rgba(79,70,229,.45); cursor: pointer; padding: 0 12px; min-height: 46px;
  }
  .glm-ditem, .glm-dgroup > button {
    display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; min-height: 48px; padding: 10px 12px;
    border: 0; border-radius: 12px; background: transparent; color: rgba(255,255,255,.82); font: 600 15px/1.2 inherit;
    text-decoration: none; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .glm-ditem:active, .glm-dgroup > button:active { background: rgba(255,255,255,.07); }
  .glm-ditem.glm-active, .glm-dgroup.glm-active > button { background: rgba(99,102,241,.22); color: #fff; box-shadow: inset 3px 0 0 #818CF8; }
  .glm-ditem .glm-ic, .glm-dgroup > button .glm-ic { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: #A5B4FC; flex: 0 0 auto; }
  .glm-ic svg, .glm-ic .ic { width: 19px !important; height: 19px !important; }
  .glm-dgroup > button .glm-chev { margin-left: auto; transition: transform .2s; opacity: .55; font-size: 12px; }
  .glm-dgroup.glm-expanded > button .glm-chev { transform: rotate(180deg); }
  .glm-dsub { display: none; padding: 2px 0 6px 46px; }
  .glm-dgroup.glm-expanded .glm-dsub { display: block; }
  .glm-dsub a, .glm-dsub span {
    display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 10px; border-radius: 10px;
    color: rgba(255,255,255,.66); font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
  }
  .glm-dsub a:active { background: rgba(255,255,255,.07); color: #fff; }
  .glm-dsub .ic { width: 15px !important; height: 15px !important; opacity: .7; }
  .glm-dsub hr { border: 0; border-top: 1px solid rgba(255,255,255,.08); margin: 4px 10px; }
  .glm-dfoot { border-top: 1px solid rgba(255,255,255,.08); padding: 10px; }
  .glm-dfoot a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 12px; color: rgba(255,255,255,.75); text-decoration: none; font-size: 14px; font-weight: 600; cursor: pointer; }
  .glm-dfoot a.glm-out { color: #FCA5A5; }

  /* ---------- bottom tab bar ---------- */
  .glm-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 2147482980;
    background: rgba(255,255,255,.92); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid rgba(15,23,42,.08); box-shadow: 0 -6px 24px rgba(15,23,42,.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); font-family: 'Inter', system-ui, -apple-system, sans-serif;
  }
  .glm-tabbar a, .glm-tabbar button {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 50px; border: 0; background: transparent; color: #64748B; font: 600 10.5px/1 inherit; letter-spacing: .1px;
    text-decoration: none; border-radius: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; position: relative;
  }
  .glm-tabbar .glm-ic { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
  .glm-tabbar .glm-ic svg, .glm-tabbar .glm-ic .ic { width: 22px !important; height: 22px !important; }
  .glm-tabbar .glm-on { color: #4F46E5; }
  .glm-tabbar .glm-on::before { content: ''; position: absolute; top: -6px; width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: #4F46E5; }
  .glm-tabbar a:active, .glm-tabbar button:active { background: rgba(79,70,229,.08); }

  /* floating widgets sit above the tab bar */
  body.glm-has-tabbar #glHelpBtn { bottom: calc(80px + env(safe-area-inset-bottom)) !important; right: 14px !important; width: 50px !important; height: 50px !important; }
  body.glm-has-tabbar #glHelpPanel { bottom: calc(140px + env(safe-area-inset-bottom)) !important; right: 10px !important; left: 10px !important; width: auto !important; max-width: none !important; max-height: calc(100vh - 200px) !important; }
  body.glm-has-tabbar .glm-badge-lift { bottom: calc(70px + env(safe-area-inset-bottom)) !important; right: 8px !important; }

  /* ---------- tables → cards ---------- */
  table.glm-cards, table.glm-cards tbody, table.glm-cards tr, table.glm-cards td { display: block; width: auto !important; }
  table.glm-cards { border: 0 !important; background: transparent !important; box-shadow: none !important; }
  table.glm-cards thead, table.glm-cards colgroup { display: none !important; }
  table.glm-cards tfoot { display: block; }
  table.glm-cards tfoot tr { background: #F1F5F9 !important; }
  table.glm-cards tr {
    background: #fff; border: 1px solid #E2E8F0 !important; border-radius: 14px; margin: 0 0 10px; padding: 6px 14px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 14px rgba(15,23,42,.04); position: relative;
  }
  table.glm-cards tr:empty { display: none; }
  table.glm-cards td, table.glm-cards tfoot th {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px; text-align: right !important;
    padding: 8px 0 !important; border: 0 !important; border-bottom: 1px solid #F1F5F9 !important; white-space: normal !important; min-height: 0;
  }
  table.glm-cards tr > td:last-child { border-bottom: 0 !important; }
  table.glm-cards td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 48%; text-align: left; color: #64748B; font-size: 12px;
    font-weight: 600; letter-spacing: .2px; text-transform: none;
  }
  table.glm-cards td:not([data-label])::before, table.glm-cards td[data-label=""]::before { display: none; }
  table.glm-cards td:not([data-label]), table.glm-cards td[data-label=""] { justify-content: flex-start; text-align: left !important; }
  table.glm-cards td.glm-title { font-size: 15px; font-weight: 700; color: #0F172A; justify-content: flex-start; text-align: left !important; padding-top: 10px !important; }
  table.glm-cards td.glm-title::before { display: none; }
  table.glm-cards td > * { max-width: 100%; }
  table.glm-cards td[colspan] { justify-content: center; text-align: center !important; }
  table.glm-cards input, table.glm-cards select { max-width: 60%; }
  .glm-tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border-radius: 12px; }
  .glm-tscroll > table { min-width: 100%; width: max-content !important; }
  .glm-tscroll > table th, .glm-tscroll > table td { white-space: nowrap !important; overflow-wrap: normal !important; }
  .glm-tscroll > table th:first-child, .glm-tscroll > table td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 1px 0 0 #E2E8F0; }

  /* ---------- modals / overlays ---------- */
  .modal, .modal-box, .modal-content, .modal-dialog, [role="dialog"] { max-width: calc(100vw - 20px) !important; box-sizing: border-box; }
  .modal-overlay, .modal-backdrop { padding: 10px !important; align-items: flex-end !important; }
  .modal-overlay > .modal, .modal-overlay > div { max-height: calc(100vh - 20px - env(safe-area-inset-top)); overflow-y: auto; -webkit-overflow-scrolling: touch; border-radius: 18px 18px 14px 14px !important; }
  .modal-actions { flex-wrap: wrap; gap: 8px; }
  .modal-actions > button, .modal-actions > a { flex: 1 1 auto; min-height: 44px; }

  /* ---------- master–detail pages (Jobs, Leads): list first, detail full-screen ---------- */
  .glm-md { display: block !important; height: auto !important; overflow: visible !important; }
  .glm-md > .glm-md-list { width: auto !important; height: auto !important; border-right: 0 !important; overflow: visible !important; }
  .glm-md > .glm-md-detail { display: none !important; }
  html.glm-detail-open .glm-md > .glm-md-detail {
    display: flex !important; flex-direction: column; position: fixed !important; inset: 0; z-index: 2147482982;
    width: auto !important; height: auto !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch;
    background: #fff; padding-bottom: env(safe-area-inset-bottom); animation: glmIn .26s cubic-bezier(.32,.72,0,1);
  }
  @keyframes glmIn { from { transform: translateX(24%); opacity: .3; } to { transform: none; opacity: 1; } }
  html.glm-detail-open, html.glm-detail-open body { overflow: hidden !important; }
  .glm-backbar { display: none; }
  html.glm-detail-open .glm-backbar {
    display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 20; flex: 0 0 auto;
    min-height: 54px; padding: env(safe-area-inset-top) 10px 0 4px; box-sizing: border-box;
    background: rgba(255,255,255,.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid #E2E8F0;
  }
  .glm-backbar button { display: inline-flex; align-items: center; gap: 2px; height: 42px; padding: 0 12px 0 6px; border: 0; border-radius: 10px; background: transparent; color: #4F46E5; font: 600 16px Inter, system-ui, sans-serif; cursor: pointer; }
  .glm-backbar button:active { background: #EEF2FF; }
  .glm-backbar svg { width: 24px; height: 24px; }
  .glm-backbar .glm-bt { font: 700 15px Inter, system-ui, sans-serif; color: #0F172A; margin-left: auto; margin-right: 12px; opacity: .55; }
  .glm-mdbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border-bottom: 1px solid #E2E8F0; }
  .glm-fbtn {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #E2E8F0;
    background: #fff; color: #0F172A; font: 600 14px Inter, system-ui, sans-serif; cursor: pointer; box-shadow: 0 1px 2px rgba(15,23,42,.05);
  }
  .glm-fbtn svg { width: 17px; height: 17px; color: #4F46E5; }
  .glm-fbtn .glm-fn { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #4F46E5; color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
  .glm-fbtn .glm-fn:empty { display: none; }
  html.glm-filters-open .glm-fbtn { background: #EEF2FF; border-color: #C7D2FE; color: #3730A3; }
  .glm-filters { display: none !important; width: auto !important; max-height: none !important; border-right: 0 !important; border-bottom: 1px solid #E2E8F0 !important; }
  html.glm-filters-open .glm-filters { display: flex !important; }

  /* ---------- side section menus (Admin) → tap-to-open picker ---------- */
  .glm-sect-host { display: block !important; height: auto !important; overflow: visible !important; }
  .glm-sect-host > :not(.glm-sect) { height: auto !important; overflow: visible !important; padding: 16px 12px 24px !important; }
  .glm-sect { width: auto !important; max-height: none !important; overflow: visible !important; border-right: 0 !important; border-bottom: 1px solid #E2E8F0 !important; padding: 10px 12px !important; position: sticky; top: 0; z-index: 40; }
  .glm-sect:not(.glm-sect-open) > :not(.glm-sectbtn) { display: none !important; }
  .glm-sect.glm-sect-open { max-height: 70vh !important; overflow-y: auto !important; box-shadow: 0 18px 40px rgba(15,23,42,.18); }
  .glm-sectbtn {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid #E2E8F0;
    background: #F8FAFC; color: #0F172A; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; margin-bottom: 0;
  }
  .glm-sect.glm-sect-open .glm-sectbtn { margin-bottom: 8px; }
  .glm-sectbtn small { font-weight: 600; color: #64748B; font-size: 12px; }
  .glm-sectbtn .glm-chev { margin-left: auto; color: #64748B; transition: transform .2s; }
  .glm-sect.glm-sect-open .glm-sectbtn .glm-chev { transform: rotate(180deg); }
  .glm-sect a, .glm-sect [onclick] { min-height: 44px; box-sizing: border-box; }

  /* ---------- install-to-home-screen card ---------- */
  .glm-install {
    display: flex; align-items: center; gap: 12px; position: fixed; left: 10px; right: 10px; z-index: 2147482985;
    bottom: calc(12px + env(safe-area-inset-bottom)); padding: 12px 12px 12px 14px; border-radius: 16px;
    background: #0F172A; color: #fff; box-shadow: 0 18px 50px rgba(15,23,42,.45); font-family: 'Inter', system-ui, sans-serif;
    transform: translateY(150%); transition: transform .35s cubic-bezier(.32,.72,0,1);
  }
  body.glm-has-tabbar .glm-install { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .glm-install.glm-show { transform: none; }
  body.glm-install-on #glHelpBtn, body.glm-install-on .glm-badge-lift { opacity: 0; pointer-events: none; }
  .glm-install img { width: 42px; height: 42px; border-radius: 10px; flex: 0 0 auto; }
  .glm-install .glm-it { flex: 1; font-size: 13px; line-height: 1.35; color: rgba(255,255,255,.75); }
  .glm-install .glm-it b { display: block; color: #fff; font-size: 14px; margin-bottom: 1px; }
  .glm-install .glm-it svg { width: 14px; height: 14px; vertical-align: -2px; }
  .glm-install .glm-go { border: 0; border-radius: 10px; background: #4F46E5; color: #fff; font-weight: 700; font-size: 14px; padding: 0 14px; height: 38px; cursor: pointer; flex: 0 0 auto; }
  .glm-install .glm-x { border: 0; background: transparent; color: rgba(255,255,255,.5); font-size: 22px; width: 30px; height: 30px; cursor: pointer; flex: 0 0 auto; }
}

/* installed app: respect the notch / home bar */
@media (display-mode: standalone) {
  body { -webkit-user-select: none; user-select: none; }
  input, textarea, [contenteditable], p, td, .selectable { -webkit-user-select: text; user-select: text; }
}

/* small phones: tighten generic page padding */
@media (max-width: 420px) {
  .main-content, .page, .content, .container, main { padding-left: 12px !important; padding-right: 12px !important; }
}

/* v2.21.1 desktop: pages run the full browser width, and tab strips wrap instead of scrolling sideways */
@media (min-width: 821px) {
  .jb-tabs, .pr-tabs, .detail-tabs, .tabbar { flex-wrap: wrap; overflow-x: visible; }
  .pr-tabs { width: auto; max-width: 100%; }
}

/* v2.38.1 — get the bottom bar, install card and help bubble out of the way of the camera, sheets and dialogs */
body.glc-open .glm-tabbar, body.glc-open .glm-install, body.glc-open #glHelpBtn, body.glc-open #glHelpPanel,
body.jc-open .glm-tabbar, body.jc-open .glm-install, body.jc-open #glHelpBtn,
body:has(.pr-modal.show) .glm-tabbar, body:has(.pr-modal.show) #glHelpBtn,
body:has(.glf-mask) .glm-tabbar, body:has(.glf-mask) #glHelpBtn { display: none !important; }
