/* Phones and small tablets (Android and iPhone). Loaded last so it wins over the desktop layout.
   Keeps every page inside the screen width: no sideways scrolling, menu folded behind a button, compact top bar. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
img,video,canvas,svg{max-width:100%;height:auto}
.table-wrap,.table-responsive{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
:root{--pn-accent:#0c8b91;--pn-accent-dark:#5fd3d6;--pn-ink:#14213d}
.ux-table-bar{position:relative}

@media (max-width:760px){
  body{overflow-x:hidden}
  .layout{display:block}
  .main{min-width:0}
  /* top bar: title first, tools on one tidy row below */
  .topbar,.spatial-app .topbar{height:auto;flex-wrap:wrap;gap:8px;padding:12px 14px;margin:0 8px 10px}
  .topbar{align-items:center}
  .topbar-left{flex:1 1 0;min-width:0}
  .topbar-left h5{font-size:1.2rem;white-space:normal}
  .topbar-left .eyebrow{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar-right{flex:1 1 100%;justify-content:flex-start;flex-wrap:wrap;gap:8px}
  .kbd-hint,.clock-chip,.locale-chip,.user-chip,.theme-toggle .tt-text{display:none!important}
  .theme-toggle{min-height:36px;min-width:40px;justify-content:center}
  .user-menu{margin-left:auto}
  .user-menu-panel{right:0;left:auto;max-width:calc(100vw - 24px)}

  /* content: comfortable but not wasteful padding */
  .content,.container-fluid.content{padding:6px 10px 24px}
  .panel,.card,.spatial-app .panel{padding:14px;border-radius:18px}
  .page-header{flex-direction:column;align-items:flex-start;gap:10px}
  h1,.h1{font-size:1.5rem}
  h2,.h2{font-size:1.25rem}
  .d-flex{flex-wrap:wrap}
  .d-flex.flex-nowrap{flex-wrap:nowrap}
  .row>*{min-width:0}
  input,select,textarea,.form-control,.form-select{max-width:100%;font-size:16px}   /* 16px stops iPhone zooming into fields */
  .btn{min-height:38px}
  .ux-cols{position:static}
  .ux-cols-panel{left:0;right:0;min-width:0;max-height:60vh;overflow-y:auto}
  .ux-table-bar input[type=search]{max-width:none;flex:1 1 100%}
  .seg{display:flex;flex-wrap:wrap;max-width:100%}
  .pre,pre,code{white-space:pre-wrap;word-break:break-word}
  /* inside a sideways-scrolling table: dates, codes and amounts stay on one line; long text wraps at a readable width */
  .table-wrap th,.table-wrap td,.table-responsive th,.table-responsive td{white-space:nowrap}
  .table-wrap td.cell-long,.table-responsive td.cell-long{white-space:normal;min-width:13em;max-width:20em}
}
@media (max-width:760px){
  /* the patient search strip on every page: one compact block instead of a full screen */
  .patient-search-strip{padding:12px!important;gap:8px!important;margin-bottom:12px!important}
  .patient-search-copy strong,.patient-search-copy small{display:none!important}
  .patient-search-form{display:grid!important;grid-template-columns:1fr auto;gap:8px!important;width:100%}
  .patient-search-form #global-patient-search{grid-column:1 / -1}
  .patient-search-form .btn-outline-primary{display:none}
  .patient-search-form .form-control,.patient-search-form .btn{min-height:42px;padding-top:8px;padding-bottom:8px;width:100%}
}
@media (max-width:380px){
  .pub-nav,.pub-nav .container{flex-wrap:wrap;row-gap:8px}
  .pub-nav nav{flex-wrap:wrap;gap:8px;min-width:0}
  .content,.container-fluid.content{padding-left:6px;padding-right:6px}
  .panel,.card,.spatial-app .panel{padding:12px}
}

/* ---------------------------------------------------------------------------------------------------------------
   Phones: steady, smooth pages (no sideways spill, nothing cut off, no jumping while tapping or scrolling)
   --------------------------------------------------------------------------------------------------------------- */
@media (max-width:760px){
  /* 1. Grids may never grow wider than the screen: every column can shrink, and so can what is inside it */
  .desk,.dashboard-grid,.order-forms,.q-order,.signup-grid,.hero-grid,.branding-grid,.report-grid,.disposition,
  .devine-grid,.account-grid,.detail-grid{grid-template-columns:minmax(0,1fr)!important}
  .desk>*,.desk-main>*,.desk-side>*,.dashboard-grid>*,.order-forms>*,.report-grid>*,.detail-grid>*,.account-grid>*,
  .disposition>*,.q-order>*,.panel,.card,.kpi-card,form,fieldset,details,.row>*{min-width:0}
  .rx-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}
  .rx-grid>*{min-width:0}
  .detail-list{grid-template-columns:minmax(0,108px) minmax(0,1fr)!important}
  .kpi-5,.report-kpis,.claim-summary{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .board-counts{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .bed-grid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr))!important}
  .hbar{grid-template-columns:minmax(0,90px) minmax(0,1fr) auto}
  .hbar>:last-child:not(:nth-child(3)){display:none}
  /* long words, references and e-mail addresses break instead of pushing the box wider */
  .panel,.card,.desk,.detail-list dd,.badge,td.cell-long{overflow-wrap:anywhere}
  .badge{white-space:normal;text-align:left}
  .desk-side{position:static!important}
  /* side-by-side boxes on wide screens stack on phones */
  .desk-main .d-flex>details,.desk-main .d-flex>.panel{flex:1 1 100%}
  /* report tables scroll sideways only; the page itself does the up-and-down scrolling */
  .report-table{max-height:none!important;overflow-y:visible!important;overflow-x:auto}

  /* 2. No jumping: hover lifts and tilts stay on computers only */
  .spatial-app a.kpi-card,.spatial-app .mini-stat,.mini-stat,a.kpi-card,.panel,.card{transition:none!important}
  .spatial-app a.kpi-card:hover,.spatial-app .mini-stat:hover,.mini-stat:hover,a.kpi-card:hover,.panel:hover,.card:hover{transform:none!important}

  /* 3. Smooth scrolling on ordinary phones: a calm background that does not repaint or resize while scrolling */
  body.spatial-app{background:
      radial-gradient(120% 60% at 0% 0%,rgba(56,200,196,.30),transparent 60%),
      radial-gradient(120% 60% at 100% 100%,rgba(110,150,255,.26),transparent 60%),
      linear-gradient(160deg,#d3eaf2 0%,#e1ddf6 55%,#f4e6ee 100%)!important;background-attachment:scroll!important;min-height:100%}
  html[data-theme=dark] body.spatial-app{background:
      radial-gradient(120% 60% at 0% 0%,rgba(20,140,140,.22),transparent 60%),
      radial-gradient(120% 60% at 100% 100%,rgba(70,90,200,.20),transparent 60%),
      linear-gradient(160deg,#08121f 0%,#0d1428 55%,#160f22 100%)!important}
  body.spatial-app::before,body.spatial-app::after{display:none!important}
  /* frosted-glass blur is costly to redraw on phones; over this smooth background the panels look the same without it */
  .spatial-app .layout *:not(.pn-tabbar):not(.hb-panel){-webkit-backdrop-filter:none!important;backdrop-filter:none!important}
  .spatial-app .panel,.spatial-app .card,.spatial-app .topbar,.spatial-app .patient-search-strip,.spatial-app .kpi-card,.spatial-app .mini-stat{background-color:rgba(255,255,255,.84)}
  html[data-theme=dark] .spatial-app .panel,html[data-theme=dark] .spatial-app .card,html[data-theme=dark] .spatial-app .topbar,
  html[data-theme=dark] .spatial-app .patient-search-strip,html[data-theme=dark] .spatial-app .kpi-card,html[data-theme=dark] .spatial-app .mini-stat{background-color:rgba(19,29,46,.92)}
  /* loading shimmer stays still on phones */
  .ux-skeleton,.ux-skeleton *{animation:none!important}
}
@media (hover:none){
  a.kpi-card:hover,.mini-stat:hover,.spatial-app .mini-stat:hover,.spatial-app a.kpi-card:hover{transform:none!important}
}

/* Phones: everything you tap is at least about 40px tall (Apple and Google both ask for 44pt / 48dp touch areas) */
@media (max-width:760px){
  .btn,.btn-sm,.form-select-sm,.form-control-sm,select{min-height:40px}
  .form-control-sm,.form-select-sm{font-size:16px;padding-top:.45rem;padding-bottom:.45rem}
  .text-link,a.text-link{display:inline-flex;align-items:center;min-height:40px;padding:0 4px}
  .form-check{min-height:34px;display:flex;align-items:center;gap:10px;padding-left:0}
  .form-check .form-check-input{float:none;margin:0;width:22px;height:22px;flex:0 0 22px}
  .form-switch .form-check-input{width:42px;flex-basis:42px}
  details>summary{min-height:44px;display:flex;align-items:center;gap:6px;padding:8px 4px;cursor:pointer}
  .nav-pills .nav-link,.nav-tabs .nav-link,.seg a,.seg button,.pill-tabs a{min-height:40px;display:inline-flex;align-items:center}
  .btn-link.p-0{min-height:36px;padding:4px 6px!important}
}
@media (max-width:760px){
  input[type=checkbox].form-check-input,input[type=radio].form-check-input{width:22px;height:22px}
  input[type=checkbox].form-check-input[role=switch]{width:42px}
}
