/* =====================================================================
   AKUNIA — TAMPILAN APLIKASI DI HP (layar penuh memanjang ke bawah)
   Aktif HANYA di lebar ≤ 640px. Tablet & PC tidak berubah.
   Muat SETELAH css/style.css.
   ===================================================================== */
#bottomNav{display:none;}

@media (max-width:640px){
  html,body{height:100%;overflow:hidden;overscroll-behavior:none;touch-action:manipulation;}
  body{-webkit-tap-highlight-color:transparent;}

  /* ---------- LOGIN: satu kolom, layar penuh ---------- */
  #loginScreen{position:fixed !important;inset:0;width:100%;height:100vh;height:100dvh;min-height:0 !important;
    overflow-y:auto;overflow-x:hidden;padding:0 !important;align-items:stretch !important;background:var(--surface);}
  .login-wrap{display:grid !important;grid-template-columns:minmax(0,1fr) !important;grid-template-rows:auto 1fr;
    width:100% !important;max-width:none !important;min-height:100%;margin:0 !important;
    border:0 !important;border-radius:0 !important;box-shadow:none !important;overflow:visible !important;}
  .login-brand{padding:calc(26px + env(safe-area-inset-top,0px)) 24px 30px !important;gap:14px !important;
    border-radius:0 0 28px 28px;min-width:0;}
  .login-brand .brand-mark svg{width:44px;height:44px;}
  .login-tagline h2{font-size:22px !important;line-height:1.2;}
  .login-tagline p{max-width:none !important;}
  .login-modules{display:none !important;}
  .login-form-side{min-width:0;padding:26px 24px calc(26px + env(safe-area-inset-bottom,0px)) !important;
    justify-content:flex-start !important;gap:18px !important;}
  .login-form-side h1{font-size:22px;}
  .login-form-side input{font-size:16px;}   /* cegah zoom otomatis iPhone */

  /* ---------- CANGKANG APLIKASI: mengisi seluruh layar ---------- */
  #appShell{position:fixed !important;inset:0 !important;width:100% !important;height:auto !important;}
  #mainArea{width:100% !important;height:100% !important;min-width:0;}

  #topbar{height:calc(54px + env(safe-area-inset-top,0px)) !important;
    padding:env(safe-area-inset-top,0px) 12px 0 !important;gap:10px !important;}
  .mobile-menu-btn{display:none !important;}          /* diganti tab "Menu" di bawah */
  #pageTitleBlock{min-width:0;flex:1;}
  #pageTitleBlock h1{font-size:16px !important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  #pageTitleBlock .crumb{display:none !important;}
  .topbar-spacer{display:none !important;}
  .company-chip{max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  .user-btn{padding:3px !important;}
  .user-btn .uname,.user-btn > svg{display:none !important;}
  .avatar{width:30px;height:30px;}
  .user-dd{min-width:min(220px,calc(100vw - 24px));}

  /* ---------- MENU SAMPING → LACI GESER ---------- */
  #sidebar{position:fixed !important;top:0 !important;bottom:0 !important;left:0 !important;
    width:280px !important;max-width:86vw;z-index:120 !important;
    padding-top:env(safe-area-inset-top,0px);box-shadow:none;
    transform:translateX(-102%) !important;transition:transform .28s cubic-bezier(.65,0,.35,1) !important;}
  #sidebar.mobile-open{transform:none !important;box-shadow:0 20px 50px -20px rgba(12,20,28,.6);}
  #sidebar .sb-toggle{display:none !important;}
  #sbBackdrop{display:block !important;position:fixed !important;inset:0;background:rgba(12,18,24,.5);
    z-index:110 !important;opacity:0;pointer-events:none;transition:opacity .2s ease;}
  #sbBackdrop.open{opacity:1;pointer-events:auto;}
  .sb-link{padding:11px 10px;}

  /* ---------- KONTEN ---------- */
  #content{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
    padding:12px 12px calc(84px + env(safe-area-inset-bottom,0px)) !important;}
  .page{gap:14px;}
  .page-head{align-items:flex-start;}
  .page-head h2{font-size:18px;}
  .page-actions{width:100%;}
  .page-actions .btn{flex:1 1 auto;}
  .card{border-radius:14px;}
  .card-pad{padding:14px;}
  .card-head{padding:12px 14px;flex-wrap:wrap;}
  .grid{gap:10px;}
  .grid-kpi{grid-template-columns:repeat(2,minmax(0,1fr));}
  .grid-2,.grid-3,.form-grid{grid-template-columns:1fr;}
  .kpi{padding:12px 14px;}
  .kpi .val{font-size:17px;overflow-wrap:anywhere;}
  .scroll-x{-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;}
  table.tbl{font-size:12.5px;}
  table.tbl thead th,table.tbl tbody td,table.tbl tfoot td{padding:8px 10px;}
  .toolbar{align-items:stretch;}
  .toolbar .search-box{flex:1 1 100%;}
  .search-box input{width:100%;min-width:0;}
  .tabs{max-width:100%;overflow-x:auto;scrollbar-width:none;}
  .tabs::-webkit-scrollbar{display:none;}
  .tab-btn{white-space:nowrap;flex:none;}
  .field input,.field select,.field textarea,.search-box input,
  .modal-body input,.modal-body select,.modal-body textarea,.jl-row input,.jl-row select{font-size:16px;}
  .btn{min-height:40px;}
  .btn svg,.btn .ic{width:18px;height:18px;max-width:18px;max-height:18px;flex:none;}  /* ikon tetap kecil walau tombol melebar */

  /* ---------- JENDELA (MODAL) ---------- */
  .modal-overlay{padding:0;align-items:flex-end;}
  .modal-box{max-width:100%;width:100%;max-height:92vh;max-height:92dvh;border-radius:18px 18px 0 0;}
  .modal-box.wide,.modal-box.xwide{max-width:100%;height:100vh;height:100dvh;max-height:none;border-radius:0;}
  .modal-box.wide .modal-head,.modal-box.xwide .modal-head{padding-top:calc(14px + env(safe-area-inset-top,0px));}
  .modal-box.wide .modal-body,.modal-box.xwide .modal-body{flex:1;min-height:0;}
  .modal-head{padding:14px 16px;}
  .modal-body{padding:14px 16px;}
  .modal-foot{padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px));flex-wrap:wrap;}
  .modal-foot .btn{flex:1 1 auto;}

  /* Baris jurnal / BOM ditumpuk */
  .jl-head:has(+ #jLines),.jl-head:has(+ #ijLines){display:none;}
  .jl-row:has(input){grid-template-columns:1fr 1fr !important;padding:10px;
    border:1px solid var(--border);border-radius:var(--radius-s);background:var(--surface-alt);}
  .jl-row:has(input) > :first-child{grid-column:1 / -1;}
  .jl-row:has(input) > .jl-remove{grid-column:1 / -1;justify-self:end;width:auto;padding:0 10px;}
  .jl-head,.jl-row:not(:has(input)){grid-template-columns:minmax(0,1fr) 88px 88px;}
  .jl-head > :nth-child(4),.jl-row:not(:has(input)) > :nth-child(4){display:none;}

  /* ---------- BILAH NAVIGASI BAWAH ---------- */
  #bottomNav{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:90;background:var(--surface);
    border-top:1px solid var(--border);padding:6px 6px calc(6px + env(safe-area-inset-bottom,0px));
    box-shadow:0 -8px 24px -14px rgba(12,20,28,.35);}
  body.kb-open #bottomNav{display:none;}            /* sembunyi saat keyboard terbuka */
  body.kb-open #content{padding-bottom:20px !important;}
  #bottomNav button{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:3px;
    background:transparent;border:0;cursor:pointer;color:var(--text-faint);padding:6px 2px;border-radius:12px;
    font-family:var(--font-body);font-size:10.5px;font-weight:600;transition:color .15s ease,background .15s ease;}
  #bottomNav button svg{width:22px;height:22px;}
  #bottomNav button.active{color:var(--primary);background:var(--primary-soft);}
  #bottomNav button:active{transform:scale(.96);}
  .toast-wrap{left:12px !important;right:12px !important;bottom:calc(84px + env(safe-area-inset-bottom,0px)) !important;}
  .toast{min-width:0;width:100%;}
}
@media print{#bottomNav{display:none !important;}}
@media (max-width:640px) and (max-height:480px){
  #bottomNav button{flex-direction:row;justify-content:center;gap:6px;}
  #content{padding-bottom:calc(64px + env(safe-area-inset-bottom,0px)) !important;}
  .login-brand{display:none;}
}
