/* Jiaxin ERP / V2.4.3 mobile refinement
   Single opt-in layer for touch screens. No desktop layout or business logic changes.
   Uses appearance palette rather than hard-coded theme colors. */
@media screen and (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { max-width: 100%; }
  :where(button, a, input, select, textarea) { -webkit-tap-highlight-color: transparent; }
  :where(input, select, textarea) { font-size: 16px !important; }
  :where(.jx-mobile-body, .ws-body, .jx-designer-page, .mg-body, .ai-management-page, .bp-body, .hr-body) :focus-visible {
    outline: 2px solid var(--jx-ui-accent,#3274cf); outline-offset: 3px;
  }

  /* Employee landing: clear hierarchy, touch-friendly search, generous but compact cards. */
  body.jx-mobile-body { overflow-x: clip; background:var(--jx-ui-bg,#f5f7fb); }
  .jx-mobile-body .jx-phone-shell { max-width:560px; padding: 0 14px calc(45px + env(safe-area-inset-bottom,0px)); }
  .jx-mobile-body .mobile-header { position:sticky; top:0; z-index:18; margin:0 -14px; padding: max(12px,env(safe-area-inset-top,0px)) 18px 12px; min-height:62px; box-sizing:border-box; background:var(--jx-ui-surface,#fff); backdrop-filter:none; -webkit-backdrop-filter:none; border-bottom:1px solid var(--jx-ui-border,#e1e8f2); }
  .jx-mobile-body .mobile-brand { font-size:15px; letter-spacing:-.02em; }
  .jx-mobile-body .mobile-brand small { font-size:9px; letter-spacing:.1em; }
  .jx-mobile-body .mobile-tools .btn { display:flex;align-items:center;justify-content:center; min-height:42px; padding:9px 13px; background:var(--jx-ui-soft,#f1f5fb); border:1px solid var(--jx-ui-border,#dfe6f0); color:var(--jx-ui-text,#263e59); border-radius:12px; font-size:12px; }
  .jx-mobile-body .mobile-hero { position:relative; isolation:isolate; overflow:hidden; margin:18px 0 15px; padding:28px 22px 27px; border-radius:22px; background:linear-gradient(135deg,color-mix(in srgb,var(--jx-ui-accent,#3177d7) 11%,var(--jx-ui-surface,#fff)),var(--jx-ui-surface,#fff) 68%); border:1px solid var(--jx-ui-border,#dfe9f4); box-shadow:0 8px 26px #1b35520a; }
  .jx-mobile-body .mobile-hero::after { content:''; position:absolute; z-index:-1; width:180px; height:180px; right:-70px; top:-80px; border-radius:50%; background:radial-gradient(circle,color-mix(in srgb,var(--jx-ui-accent,#3075cd) 21%,transparent),transparent 72%); pointer-events:none; }
  .jx-mobile-body .mobile-hero h1 { margin:12px 0 9px; font-size:clamp(25px,7vw,33px); letter-spacing:-.035em; }
  .jx-mobile-body .mobile-welcome { max-width:330px; line-height:1.7; }
  .jx-mobile-body .mobile-page-section { padding:20px 17px 23px; border-radius:20px; box-shadow:0 7px 26px #1b385e08; }
  .jx-mobile-body .mobile-section-head { margin-bottom:17px; }
  .jx-mobile-body .mobile-section-head h2 { font-size:19px; margin:7px 0 4px; }
  .jx-mobile-body .mobile-section-head p { font-size:12px; }
  .jx-mobile-body .mobile-search { margin:15px 0 13px; }
  .jx-mobile-body .mobile-search-control { position:relative; display:flex; align-items:center; gap:8px; min-width:0; border:1px solid var(--jx-ui-border,#dce5ef); border-radius:13px; background:var(--jx-ui-surface,#fff); padding:0 10px 0 13px; transition:border-color .18s, box-shadow .18s; }
  .jx-mobile-body .mobile-search-control:focus-within { border-color:var(--jx-ui-accent,#3778c9); box-shadow:0 0 0 3px color-mix(in srgb,var(--jx-ui-accent,#3778c9) 10%,transparent); }
  .jx-mobile-body .mobile-search-control svg { flex:none; color:var(--jx-ui-muted,#8190a4); }
  .jx-mobile-body .mobile-search-control input { flex:1; min-width:0; min-height:46px; padding:10px 0; border:0!important; outline:0!important; box-shadow:none!important; background:transparent; }
  .jx-mobile-body .mobile-search-control input::-webkit-search-cancel-button { display:none; }
  .jx-mobile-body .mobile-search-control button { min-height:32px; padding:5px 8px; border:0; border-radius:8px; background:var(--jx-ui-soft,#edf4fd); color:var(--jx-ui-accent,#3778c9); font-size:12px; }
  .jx-mobile-body .mobile-search-control button[hidden] { display:none!important; }
  .jx-mobile-body .mobile-modules { gap:8px; padding:3px 1px 10px; margin:5px 0 4px; scrollbar-width:none; scroll-snap-type:x proximity; -webkit-overflow-scrolling:touch; }
  .jx-mobile-body .mobile-modules::-webkit-scrollbar { display:none; }
  .jx-mobile-body .mobile-modules button { min-height:40px; padding:9px 16px; font-weight:650; font-size:12px; scroll-snap-align:start; transition:background .16s,color .16s,transform .16s; }
  .jx-mobile-body .mobile-list-meta { margin:11px 0 10px; font-size:11px; font-weight:600; color:var(--jx-ui-muted,#73869b); }
  .jx-mobile-body .mobile-forms, .jx-mobile-body .mobile-record-list { gap:10px; }
  .jx-mobile-body .mobile-form-link, .jx-mobile-body .mobile-record-card { min-height:75px; border-radius:14px; padding:15px 14px; box-shadow:0 2px 8px #142d4906; transition:background .16s,border-color .16s,transform .16s; }
  .jx-mobile-body .mobile-form-link:active, .jx-mobile-body .mobile-record-card:active { transform:scale(.989); }
  .jx-mobile-body .mobile-form-link strong, .jx-mobile-body .mobile-record-card strong { font-size:14px; font-weight:700; }
  .jx-mobile-body .mobile-form-link small, .jx-mobile-body .mobile-record-card small { font-size:11px; margin-top:5px; }
  .jx-mobile-body .mobile-footer { flex-wrap:wrap; gap:10px; margin-top:22px; }
  .jx-mobile-body .mobile-footer .btn { min-height:44px; border-radius:11px; }
  .jx-mobile-body .mobile-back { display:inline-flex; align-items:center; justify-content:center; min-height:42px; margin-bottom:10px; border:1px solid var(--jx-ui-border,#dfe7ef); border-radius:11px; font-weight:650; }
  .jx-mobile-body .mobile-form-head { margin:9px 0 19px; }
  .jx-mobile-body .mobile-form-records { margin-top:21px; padding-top:22px; scroll-margin-top:92px; }
  .jx-mobile-body .mobile-detail-section .mobile-back { margin-bottom:14px; }
  .jx-mobile-body .mobile-detail-fields { gap:17px; }
  .jx-mobile-body .mobile-detail-field label { margin-bottom:9px; font-size:13px; }
  .jx-mobile-body .mobile-detail-field input, .jx-mobile-body .mobile-detail-field select, .jx-mobile-body .mobile-detail-field textarea { min-height:49px; border-radius:12px; padding:12px 13px; }
  .jx-mobile-body .mobile-detail-field .mobile-readonly { min-height:43px; padding:13px 14px; border:1px solid var(--jx-ui-border,#e6ecf2); border-radius:12px; }
  .jx-mobile-body .mobile-detail-actions { position:relative; margin-top:22px; }
  .jx-mobile-body .mobile-detail-actions button { min-height:50px; border-radius:13px; }
  .jx-mobile-body .mobile-image-thumb { display:inline-flex; align-items:center; justify-content:center; padding:5px; width:112px; height:102px; border-radius:13px; border:1px solid var(--jx-ui-border,#dce5ef); background:var(--jx-ui-soft,#f1f5fb); color:var(--jx-ui-muted,#73869b); }
  .jx-mobile-body .mobile-image-thumb img { width:100%; height:100%; border-radius:9px; object-fit:cover; }

  /* Main ERP on a phone: readable toolbars, usable scrollers, dialogs within viewport. */
  .ws-body .ws-header { height:auto; min-height:60px; padding:10px 12px; gap:8px; flex-wrap:wrap; }
  .ws-body .ws-header-left { min-width:0; flex:1 1 155px; gap:7px; }
  .ws-body .ws-header-right { gap:7px; max-width:100%; flex:0 1 auto; }
  .ws-body .ws-brand-breadcrumb { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .ws-body .ws-content { padding:17px 12px calc(46px + env(safe-area-inset-bottom,0px)); }
  .ws-body .ws-title-row { flex-wrap:wrap; gap:10px; margin-bottom:18px; }
  .ws-body .ws-title-row h1 { font-size:21px; }
  .ws-body .ws-record-toolbar { padding:12px 10px; gap:10px; }
  .ws-body .ws-record-top, .ws-body .ws-record-action-cluster { gap:7px; flex-wrap:wrap; min-width:0; max-width:100%; }
  .ws-body .ws-record-toolbar button, .ws-body .ws-record-toolbar select { min-height:40px; border-radius:10px; }
  .ws-body .ws-custom-grid, .ws-body .ws-grid-scroll, .ws-body .ws-record-table-scroll { overflow-x:auto; max-width:100%; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; }
  .ws-body .ws-stats-compact { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
  .ws-body .ws-stats-compact .ws-stat { min-width:0; padding:12px; }
  .ws-body .ws-stats-compact .ws-stat:last-child:nth-child(odd) { grid-column:1 / -1; }
  .ws-body .ws-stat strong { overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
  .ws-body .ws-modal-layer { padding:12px; align-items:center; justify-content:center; }
  .ws-body .ws-modal-layer .ws-modal { position:relative!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; transform:none!important; width:min(100%,540px)!important; max-width:100%!important; max-height:calc(100dvh - 24px)!important; border-radius:18px!important; margin:auto!important; }
  .ws-body .ws-modal-body { overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .ws-body .ws-modal-footer { padding-bottom:max(12px,env(safe-area-inset-bottom,0px)); }

  /* Designer: no viewport-locked panels; hierarchy remains available on narrow screens. */
  body.jx-designer-page:not(.ai-management-page) { height:auto!important; min-height:100dvh; overflow-y:auto!important; }
  .jx-designer-page:not(.ai-management-page) .topbar { height:auto; min-height:65px; padding:10px 12px; gap:10px; flex-wrap:wrap; }
  .jx-designer-page:not(.ai-management-page) .topbar .brand { flex:1 1 145px; min-width:0; }
  .jx-designer-page:not(.ai-management-page) .topbar h1 { font-size:15px; }
  .jx-designer-page:not(.ai-management-page) .topbar .nav { display:flex; gap:7px; flex-wrap:wrap; }
  .jx-designer-page:not(.ai-management-page) .topbar .nav .btn { min-height:40px; border-radius:10px; }
  .jx-designer-page:not(.ai-management-page) .main-grid { display:flex!important; flex-direction:column; height:auto!important; min-height:0!important; padding:10px; gap:10px; }
  .jx-designer-page:not(.ai-management-page) .main-grid>.panel { width:100%; min-width:0; height:auto!important; min-height:0!important; flex:none; border-radius:15px; }
  .jx-designer-page:not(.ai-management-page) .main-grid>.panel .palette { max-height:205px; overflow-y:auto; }
  .jx-designer-page:not(.ai-management-page) .main-grid>.panel .palette-grid { gap:8px; }
  .jx-designer-page:not(.ai-management-page) .jx-canvas-toolbar { gap:8px; flex-wrap:wrap; }
  .jx-designer-page:not(.ai-management-page) .jx-canvas-actions { flex-wrap:wrap; gap:7px; }
  .jx-designer-page:not(.ai-management-page) .main-grid>.panel:has(#canvas) { min-height:300px!important; }
  .jx-designer-page:not(.ai-management-page) .main-grid>.panel:has(#canvas) #canvas { min-height:230px; }

  /* Organization, permissions, and shared business dialogs. */
  .mg-body .mg-shell { padding:12px 12px calc(40px + env(safe-area-inset-bottom,0px)); }
  .mg-body .mg-header { gap:9px; padding-bottom:13px; }
  .mg-body .mg-links { display:flex; width:100%; overflow-x:auto; flex-wrap:nowrap; gap:6px; scrollbar-width:none; -webkit-overflow-scrolling:touch; }
  .mg-body .mg-links::-webkit-scrollbar { display:none; }
  .mg-body .mg-links a { white-space:nowrap; flex:none; min-height:40px; display:flex; align-items:center; justify-content:center; padding:8px 12px; border-radius:10px; }
  .mg-body .mg-heading { padding:16px 0 13px; }
  .mg-body .mg-heading h1 { font-size:22px; }
  .mg-body .mg-grid { gap:12px; }
  .mg-body .mg-panel { padding:16px 13px; border-radius:15px; }
  .mg-body .mg-actions { flex-wrap:wrap; gap:8px; }
  .mg-body .mg-actions :is(button,a) { min-height:42px; }
  .jx-access-root .jx-access-matrix-scroll { max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; }
  .jx-access-root .jx-access-field-row label { min-height:39px; }
  .bp-body .bp-content { padding:18px 13px 32px; }
  .bp-body .bp-top { padding:10px 12px; height:auto; min-height:60px; }
  .bp-body .bp-overlay { padding:10px; }
  .bp-body .bp-dialog { width:100%; max-height:calc(100dvh - 20px); border-radius:17px; }
  .bp-body .bp-form { -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }
  .hr-body .hr-content { padding:18px 13px calc(38px + env(safe-area-inset-bottom,0px)); }
  .hr-body .hr-topbar { height:auto; min-height:60px; padding:9px 12px; gap:8px; }
  .ai-management-page .ai-manage-shell { max-width:100%; padding:8px; }
  .ai-management-page .ai-main-inner { padding:20px 13px calc(45px + env(safe-area-inset-bottom,0px)); }
  .ai-management-page .ai-setting-card, .ai-management-page .ai-model-library { max-width:100%; min-width:0; }
  .ai-management-page .ai-menu { -webkit-overflow-scrolling:touch; }
  .ai-management-page .ai-config-grid { grid-template-columns:minmax(0,1fr); }

  /* Shared record-entry page on mobile. */
  .worker-wrap { padding:14px 12px calc(45px + env(safe-area-inset-bottom,0px)); }
  .worker-nav { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:15px; }
  .worker-nav a { display:inline-flex; align-items:center; min-height:42px; padding:9px 12px; border:1px solid var(--jx-ui-border,#e0e8f1); background:var(--jx-ui-surface,#fff); border-radius:11px; text-decoration:none; }
  .worker-card { padding:20px 15px; border-radius:18px; }
  .worker-card .form-field input:not([type=checkbox]):not([type=radio]), .worker-card .form-field select, .worker-card .form-field textarea { min-height:47px; border-radius:11px; }
  .worker-card button[type=submit] { min-height:48px; border-radius:12px; }
}
@media screen and (max-width:390px){
  .jx-mobile-body .jx-phone-shell { padding-left:10px; padding-right:10px; }
  .jx-mobile-body .mobile-header { margin-left:-10px; margin-right:-10px; }
  .jx-mobile-body .mobile-hero { padding:23px 18px; }
  .jx-mobile-body .mobile-page-section { padding:18px 13px; }
  .ws-body .ws-header { padding:9px 10px; }
  .jx-designer-page:not(.ai-management-page) .topbar .nav { width:100%; }
}
@media(prefers-reduced-motion:reduce){
  .jx-mobile-body .mobile-form-link, .jx-mobile-body .mobile-record-card, .jx-mobile-body .mobile-search-control, .jx-mobile-body .mobile-modules button { transition:none!important; }
  .jx-mobile-body .mobile-form-link:active, .jx-mobile-body .mobile-record-card:active { transform:none!important; }
}

/* Details and form actions start high on the screen; the welcome hero belongs to browse only. */
.jx-mobile-body[data-mobile-mode="form"] .mobile-hero,
.jx-mobile-body[data-mobile-mode="detail"] .mobile-hero { display:none!important; }
@media screen and (max-width:768px) {
  .jx-mobile-body[data-mobile-mode="detail"] .mobile-page-section,
  .jx-mobile-body[data-mobile-mode="form"] .mobile-page-section { margin-top:17px; }
}

/* AI assistant on phones: always within safe screen bounds, never draggable offscreen. */
@media screen and (max-width:560px){
  body .ai-launcher{right:14px!important;bottom:calc(14px + env(safe-area-inset-bottom,0px))!important;width:54px;height:54px;border-radius:17px;}
  body .ai-float{position:fixed!important;left:8px!important;right:8px!important;top:calc(8px + env(safe-area-inset-top,0px))!important;bottom:calc(8px + env(safe-area-inset-bottom,0px))!important;width:auto!important;height:auto!important;min-height:0!important;max-height:none!important;border-radius:18px!important;}
  body .ai-float-header{touch-action:auto;cursor:default;}
  body .ai-resize{display:none!important;}
  body .ai-float-compose{margin:0 10px calc(10px + env(safe-area-inset-bottom,0px))!important;}
  body .ai-float-answer{-webkit-overflow-scrolling:touch;overscroll-behavior-y:contain;}
}

/* Mobile navigation should lock the page behind the open drawer. */
@media screen and (max-width:800px){
 .ws-body.ws-drawer-open{overflow:hidden!important;}
 .ws-body .ws-sidebar.open{overscroll-behavior:contain;-webkit-overflow-scrolling:touch;}
}

/* Employee mobile header: three identical icon buttons, no squeezed labels. */
@media(max-width:800px){
  .jx-mobile-body .mobile-header{gap:8px;min-width:0}
  .jx-mobile-body .mobile-brand{flex:1 1 auto;min-width:0}
  .jx-mobile-body .mobile-brand>span:last-child{min-width:0}
  .jx-mobile-body .mobile-tools{display:flex;align-items:center;gap:7px;flex:0 0 auto;min-width:0}
  .jx-mobile-body .mobile-tools :is(.jx-appearance>summary,.mobile-account-link,#jx-pwa-install .jx-pwa-action){
    box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;
    width:39px;height:39px;min-width:39px;min-height:39px;max-width:39px;
    padding:0!important;border-radius:12px;gap:0;margin:0;line-height:1;
    border:1px solid var(--jx-ui-border,#dfe6f0);
    background:var(--jx-ui-soft,#f3f7fc);color:var(--jx-ui-text,#24466e);
    box-shadow:none;transform:none;
  }
  .jx-mobile-body .mobile-tools :is(.jx-appearance>summary,.mobile-account-link,#jx-pwa-install .jx-pwa-action):hover{
    transform:none;box-shadow:none;
  }
  .jx-mobile-body .mobile-tools .mobile-account-link span,
  .jx-mobile-body .mobile-tools .jx-appearance>summary span,
  .jx-mobile-body .mobile-tools #jx-pwa-install .jx-pwa-action span{display:none!important}
  .jx-mobile-body .mobile-tools svg{flex:none;width:19px;height:19px}
  .jx-mobile-body .mobile-tools .jx-appearance{margin:0;flex:none}
  .jx-mobile-body .mobile-tools #jx-pwa-install{margin:0;flex:none}
  .jx-mobile-body .mobile-tools .jx-appearance-popup{right:0}
  .jx-mobile-body .mobile-tools :is(.jx-appearance>summary,.mobile-account-link,#jx-pwa-install .jx-pwa-action):focus-visible{
    outline:2px solid var(--jx-ui-accent,#256bd7);outline-offset:3px;
  }
}
@media(max-width:350px){
  .jx-mobile-body .mobile-brand small{display:none}
  .jx-mobile-body .mobile-tools{gap:5px}
  .jx-mobile-body .mobile-tools :is(.jx-appearance>summary,.mobile-account-link,#jx-pwa-install .jx-pwa-action){width:36px;min-width:36px;max-width:36px;height:36px;min-height:36px}
}
@media(max-width:800px){
  .jx-mobile-body .mobile-tools .jx-appearance{order:1}
  .jx-mobile-body .mobile-tools #jx-pwa-install{order:2}
  .jx-mobile-body .mobile-tools .mobile-account-link{order:3}
}

/* V2.8.9 · Employee header: one calm row, without a pinned glass layer. */
@media screen and (max-width:800px){
  .jx-mobile-body .mobile-header{
    position:relative!important;top:auto!important;z-index:4;
    display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;
    gap:8px;min-height:58px;padding:10px 12px;margin-bottom:0;
    background:var(--jx-ui-surface,#fff);
    backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
  }
  .jx-mobile-body .mobile-brand{flex:1 1 auto;min-width:0;gap:8px;white-space:nowrap;font-size:clamp(12px,3.7vw,15px)}
  .jx-mobile-body .mobile-brand>span:last-child{overflow:hidden;text-overflow:ellipsis;min-width:0}
  .jx-mobile-body .mobile-brand small{display:none!important}
  .jx-mobile-body .mobile-brand .brand-mark{width:36px;height:36px;min-width:36px;flex:none}
  .jx-mobile-body .mobile-tools{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex:0 0 auto;min-width:0;flex-wrap:nowrap}
  .jx-mobile-body .mobile-tools :is(.jx-appearance>summary,.mobile-account-link,#jx-pwa-install .jx-pwa-action){width:38px!important;min-width:38px!important;max-width:38px!important;height:38px!important;min-height:38px!important}
  .ws-body .ws-header{position:relative!important;top:auto!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
  .ws-body #mobile-entry-button{display:none!important}
}
@media screen and (max-width:350px){
  .jx-mobile-body .mobile-header{padding:9px 8px;gap:5px}
  .jx-mobile-body .mobile-tools{gap:4px}
  .jx-mobile-body .mobile-tools :is(.jx-appearance>summary,.mobile-account-link,#jx-pwa-install .jx-pwa-action){width:35px!important;min-width:35px!important;max-width:35px!important;height:35px!important;min-height:35px!important}
  .jx-mobile-body .mobile-brand .brand-mark{width:34px;height:34px;min-width:34px}
}

/* Keep the existing version badge in the welcome card; remove only the salary shortcut. */
.jx-mobile-body .mobile-welcome-meta{display:flex;justify-content:flex-end;min-height:14px;}
.jx-mobile-body .mobile-welcome-version{font-size:10px;font-weight:650;letter-spacing:.04em;color:var(--jx-ui-muted,#6f8299);}
/* Keep the same solid, unblurred navigation header as form pages. */
@media screen and (max-width:800px){
  body.jx-mobile-body .mobile-header{background:var(--jx-ui-surface,#fff)!important;background-image:none!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;filter:none!important;opacity:1!important;}
}
