/* Shared mobile ergonomics. Desktop and print layouts keep their existing rules. */
.mobile-quick-nav,.mobile-menu-backdrop,.mobile-drawer-close{display:none}
@media screen and (max-width:760px){
  :root{--mobile-nav-height:66px}
  html{scroll-padding-top:122px;scroll-padding-bottom:90px}
  body{font-size:15px;-webkit-text-size-adjust:100%}
  body.mobile-overlay-open{overflow:hidden}
  .main{min-width:0;padding-bottom:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom,0px))}
  .topbar{grid-template-columns:minmax(0,1fr) auto!important;grid-template-areas:"left install" "branch branch"!important;gap:8px!important;padding:8px 14px!important;padding-top:max(8px,env(safe-area-inset-top,0px))!important}
  .topbar .top-left{align-items:center;gap:10px}
  .topbar h1{font-size:19px!important;line-height:1.25!important}
  .topbar #todayLabel,.topbar #roleBadge,.topbar #userName,.topbar #avatar{display:none!important}
  .topbar #activeBranchWrap{gap:8px!important}
  .topbar #activeBranchWrap .active-branch-label{font-size:12px;white-space:nowrap}
  .topbar #activeBranch{min-height:44px;border:1px solid var(--line);border-radius:10px;background:#fff;padding:7px 10px;font-size:14px}
  .page{padding:16px 14px 28px!important}
  .page .section-head h2{font-size:22px;line-height:1.25}
  .page .section-head p{font-size:14px;line-height:1.5}
  .page .section-head{gap:12px}
  .panel{padding:14px;border-radius:16px;min-width:0}
  button,.action,.text-btn,.icon-btn{min-height:44px;touch-action:manipulation}
  button{max-width:100%;white-space:normal;line-height:1.3}
  .icon-btn{width:44px;height:44px;min-width:44px}
  .action{padding:10px 12px}
  #appShell #page-products #productRows button,
  #appShell #page-orders #orderRows button,
  #appShell #page-purchases #purchaseRows button{min-height:44px!important}
  #appShell #page-branches #branchRows button{min-height:44px!important}
  :is(input,select,textarea):not([type=checkbox]):not([type=radio]):not([type=hidden]){font-size:16px;min-height:44px;max-width:100%;min-width:0}
  .page input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=range]),.page select{border:1px solid var(--line);border-radius:10px;padding:10px;background:#fff}
  input[type=checkbox],input[type=radio]{width:20px!important;height:20px!important;min-width:20px;min-height:20px;accent-color:var(--primary);flex-shrink:0}
  label:has(input[type=checkbox]),label:has(input[type=radio]){display:flex!important;align-items:center;gap:10px;min-height:44px;line-height:1.4}
  .field label{font-size:13px;color:#536173}
  .field small,.muted{line-height:1.5}
  textarea{min-height:96px;resize:vertical}
  :is(button,input,select,textarea,[role=button]):focus-visible{outline:3px solid #42aa94;outline-offset:2px}
  .toolbar,.panel-head,.form-actions{flex-wrap:wrap;min-width:0;gap:10px}
  .toolbar>*{min-width:0;max-width:100%}
  .form-actions>button{flex:1 1 130px}
  .hero-card{padding:20px;border-radius:18px}
  .hero-card h2{font-size:23px!important;line-height:1.3}
  .hero-card p{font-size:14px;line-height:1.5}
  .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px}
  .stat{padding:14px;min-width:0}
  .stat strong{font-size:20px;overflow-wrap:anywhere}
  .table-wrap{max-width:100%;min-width:0;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
  .mobile-scroll-table{border:1px solid var(--line);border-radius:12px}
  .mobile-scroll-table::before{content:"Geser tabel ke samping ↔";display:block;padding:9px 10px;font-size:12px;color:#536173;background:#f5f8f7;position:sticky;left:0}
  /* Preserve optical column relationships without squeezing diopters into 30px inputs. */
  #modal .medical-rx-table-wrap{display:block;width:100%;max-width:100%;overflow-x:auto!important;overscroll-behavior-x:contain;border:1px solid var(--line);border-radius:10px}
  #modal .medical-rx-table{table-layout:fixed!important;min-width:360px!important;width:100%!important}
  #modal .medical-rx-table:has(thead tr>:nth-child(5)){min-width:620px!important}
  #modal .medical-rx-table th,#modal .medical-rx-table td{padding:7px 5px!important;font-size:12px!important;white-space:normal;word-break:normal;overflow-wrap:normal}
  #modal .medical-rx-table thead th::after{content:none!important}
  #modal .medical-rx-table input{min-width:70px!important;font-size:16px!important;padding:8px 4px!important;min-height:44px!important;border:1px solid #c8d5d0;border-radius:8px}
  #modal .medical-rx-table th:first-child{width:60px!important;position:sticky;left:0;background:#f3f8f6;z-index:1}
  /* Keep long administration records readable without horizontal panning. */
  table.mobile-record-list{display:block!important;min-width:0!important;width:100%!important;max-width:100%!important}
  table.mobile-record-list>thead{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip-path:inset(50%)}
  table.mobile-record-list>tbody{display:grid!important;width:100%;gap:12px}
  table.mobile-record-list>tbody>tr{display:grid!important;grid-template-columns:minmax(0,1fr)!important;width:100%;min-width:0;padding:12px;border:1px solid var(--line);border-radius:12px;background:#fff;gap:10px}
  table.mobile-record-list>tbody>tr>td{display:block!important;grid-column:1/-1!important;padding:0!important;border:0!important;white-space:normal!important;overflow-wrap:anywhere;min-width:0}
  table.mobile-record-list>tbody>tr>td[data-mobile-label]::before{content:attr(data-mobile-label)!important;display:block!important;color:#536173;font-size:11px;font-weight:700;letter-spacing:.03em;text-transform:uppercase;margin-bottom:4px}
  table.mobile-record-list>tbody>tr>td[colspan]::before{display:none!important}
  table.mobile-record-list button{margin-top:3px}
  .mobile-quick-nav:not([hidden]){display:flex;position:fixed;bottom:0;left:0;right:0;z-index:25;flex-direction:row;gap:4px;background:#fff;border-top:1px solid var(--line);padding:6px 8px calc(6px + env(safe-area-inset-bottom,0px));box-shadow:0 -4px 18px #18212f0a;min-height:var(--mobile-nav-height)}
  .mobile-quick-nav button{display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:0;min-height:54px;border:0;border-radius:12px;background:transparent;color:#52655f;font-size:11px;font-weight:600;padding:5px}
  .mobile-quick-nav button[hidden]{display:none}
  .mobile-quick-nav button.active{background:#e8f5f1;color:#0f594b}
  .mobile-quick-nav svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .mobile-editing .mobile-quick-nav{display:none!important}
  .mobile-menu-backdrop:not([hidden]){display:block;position:fixed;inset:0;z-index:35;border:0;max-width:none;background:#071a14a6;border-radius:0;backdrop-filter:blur(2px)}
  #sidebar{z-index:40!important;width:min(88vw,330px);height:100vh;height:100dvh;padding:16px 12px;padding-top:max(16px,env(safe-area-inset-top,0px));padding-bottom:max(16px,env(safe-area-inset-bottom,0px));overflow:hidden}
  #sidebar .brand{flex-shrink:0;padding:4px 8px 16px;gap:10px}
  #sidebar #nav{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:4px 4px 12px;scrollbar-width:thin}
  #sidebar .nav-item,#sidebar .nav-group-toggle{min-height:48px;font-size:14px}
  #sidebar .nav-group-title{min-width:0}
  #sidebar .nav-group-title>span{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.35}
  #sidebar .sidebar-footer{flex-shrink:0;padding:10px 4px 0}
  .mobile-drawer-close:not([hidden]){display:grid;place-items:center;flex-shrink:0;margin-left:auto;width:44px;height:44px;border:1px solid #ffffff38;border-radius:12px;background:#ffffff12;color:white;font-size:28px;padding:0}
  /* Independent dialog scroll prevents the page beneath from moving. */
  #modal.open{z-index:60;align-items:stretch!important;padding:0!important;overflow:hidden!important}
  #modal .modal-card,#modal .modal-card.modal-wide{display:flex!important;flex-direction:column;width:100%!important;max-width:100%!important;height:100vh!important;height:100dvh!important;max-height:100dvh!important;min-height:0!important;margin:0!important;border-radius:0!important;padding:0!important;overflow:hidden!important}
  #modal .modal-head{flex-shrink:0;position:relative;top:auto!important;min-height:64px;padding:12px 14px!important;padding-top:max(12px,env(safe-area-inset-top,0px))!important;border-bottom:1px solid var(--line);background:#fff;z-index:1;gap:12px}
  #modal .modal-head h3{font-size:18px;line-height:1.3;overflow-wrap:anywhere}
  #modal #modalBody{flex:1 1 auto;min-height:0!important;max-height:none!important;overflow-y:auto!important;overscroll-behavior:contain;padding:16px 14px calc(24px + env(safe-area-inset-bottom,0px))!important}
  #modal .form-actions{padding:12px 0 0;background:#fff}
  .toast{bottom:calc(80px + env(safe-area-inset-bottom,0px))!important;left:14px!important;right:14px!important;max-width:none!important;line-height:1.5;overflow-wrap:anywhere}
  .mobile-editing .toast{bottom:16px!important}
}
@media screen and (min-width:761px) and (max-width:1024px){
  #appShell .page button,#modal button{min-height:44px!important;line-height:1.3}
  #appShell .page input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
  #appShell .page select,#appShell .page textarea{min-height:44px!important;font-size:16px;min-width:0;max-width:100%}
  .page .toolbar{flex-wrap:wrap;align-items:stretch;gap:10px;min-width:0}
  .page .toolbar input,.page .toolbar select{min-width:0!important;max-width:100%;flex:1 1 180px;width:auto}
  .page .toolbar button{min-height:44px;max-width:100%;white-space:normal}
  .page .section-head,.page .panel-head{flex-wrap:wrap;min-width:0}
}
@media (prefers-reduced-motion:reduce){.sidebar,.toast,.product-card{transition:none!important;scroll-behavior:auto!important}}
@media print{.mobile-quick-nav,.mobile-menu-backdrop,.mobile-drawer-close{display:none!important}}
