/* Shared layout safety layer: loaded last so every module follows one CTA system. */
html,body{max-width:100%;overflow-x:hidden}
:where(p,span,strong,small,h1,h2,h3,h4,h5,h6,td,th,label){word-break:normal;overflow-wrap:break-word;hyphens:none}
:where(main,.view,.panel,.card,form,fieldset,.operations-grid>*,.security-grid>*,.form-grid>*,.eyes>*){min-width:0}
:where(button,.primary,.quiet){max-width:100%;line-height:1.25;overflow-wrap:break-word;word-break:normal;hyphens:none}
:where(.primary):hover{color:#fff}
.hero .primary:hover{background:#fff;color:var(--brand);box-shadow:0 10px 24px #0003;transform:translateY(-1px)}
:where(.actions,.card-actions,.rx-actions,.toolbar,.page-title,.panel-title,.modal-title,.calendar-toolbar){flex-wrap:wrap}
:where(.actions,.card-actions,.rx-actions){row-gap:8px}
:where(.page-title,.panel-title,.hero)>div{min-width:0}
:where(.page-title,.panel-title,.hero) h2,:where(.page-title,.panel-title,.hero) h3{overflow-wrap:break-word;word-break:normal}
.page-title>div:last-child,.panel-title>div:last-child{min-width:0}
.toolbar{align-items:end}.toolbar>*{min-width:0}
.toolbar label{flex:1 1 220px}.toolbar>button{flex:0 1 auto}
.card{gap:14px}.card>*,.appt-row>*{min-width:0}.card-actions{justify-content:flex-end}
.card-actions button{flex:0 1 auto;white-space:normal}
.badge{max-width:100%;white-space:normal;text-align:center;overflow-wrap:break-word;word-break:normal}
.clinical-tabs,.productivity-tabs,.timeline-filters,.role-switcher{max-width:100%;scrollbar-width:thin}
.clinical-tabs button,.productivity-tabs button{flex:0 0 auto}
dialog{max-height:calc(100dvh - 24px);overflow-y:auto;overscroll-behavior:contain}
dialog form{max-width:100%}
.room-card>header{position:static!important;inset:auto!important;z-index:auto!important;width:auto!important;height:auto!important;min-height:0!important;box-shadow:none!important}
.room-patient>*,.staff-row>*,.surgery-card>*,.transaction-row>*,.clinical-row>*{min-width:0;overflow-wrap:break-word;word-break:normal}
.surgery-card button,.staff-row button{white-space:normal}
.global-results{max-width:calc(100vw - 24px)}
.patient-banner{gap:14px;flex-wrap:wrap}.patient-banner>div:last-child{display:flex;flex-wrap:wrap;gap:7px}.patient-banner .risk{margin-left:0}
.care-next button{flex:0 0 auto}.patient-quick-actions button{width:100%;min-width:0}
.mrn-chip{white-space:nowrap}.patient-actions{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-items:stretch;gap:5px;margin-top:8px}.patient-actions button{width:100%;min-height:42px!important;margin:0!important;padding:7px 6px!important;white-space:normal;font-size:11px;line-height:1.15}.patient-actions .primary:hover{color:#fff}#patients table{width:100%;min-width:0;table-layout:fixed}#patients th:nth-child(1){width:9%}#patients th:nth-child(2){width:13%}#patients th:nth-child(3){width:7%}#patients th:nth-child(4){width:12%}#patients th:nth-child(5){width:12%}#patients th:nth-child(6){width:12%}#patients th:nth-child(7){width:35%}#patients th,#patients td{padding-inline:7px;overflow-wrap:break-word;word-break:normal}#patient-rows td:nth-child(2) small{display:block;margin-top:3px;color:var(--muted)}#patient-rows td:nth-child(6){white-space:nowrap}.edit-patient-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 15px}#patient-edit-dialog{width:min(840px,calc(100% - 24px))}#patient-edit-dialog .modal-title{align-items:flex-start}
.care-coordinator .care-actions{grid-template-columns:repeat(3,minmax(240px,1fr))}.care-coordinator .care-action{gap:14px;min-height:92px;padding:14px}.care-coordinator .care-action span{min-width:0}.care-coordinator .care-action b,.care-coordinator .care-action small{display:block}.care-coordinator .care-action>strong{flex:0 0 auto;white-space:nowrap}
.task-card>*{min-width:0}.task-card strong,.task-card small{overflow-wrap:break-word;word-break:normal}

@media(max-width:1100px){
  .card{grid-template-columns:90px minmax(0,1fr)}
  .card-actions{grid-column:1/-1;justify-content:flex-start;margin-top:4px}
  .surgery-card{grid-template-columns:minmax(0,1fr) 145px}.surgery-card button{width:100%}
  .transaction-row{grid-template-columns:1fr 1fr}.transaction-row time{text-align:right}
  .care-coordinator .care-actions{grid-template-columns:repeat(2,minmax(240px,1fr))}
}
@media(max-width:900px){
  header{gap:9px;padding-inline:16px}header>div:nth-child(2) p{display:none}.user{gap:8px}
  main{padding-left:24px;padding-right:24px}
  .panel{padding:19px}
  .care-next{align-items:flex-start}.care-next button{flex-basis:auto}
  .appt-row{grid-template-columns:75px minmax(0,1fr) auto}.appt-row .badge{justify-self:start}
}
@media(max-width:700px){
  .hero{align-items:stretch;flex-direction:column}.hero>button{width:100%}
  .page-title,.panel-title{align-items:stretch;flex-direction:column}
  .page-title>button,.page-title>.actions,.panel-title>button{width:100%}
  .page-title>.actions button{flex:1 1 160px}
  .actions>button{flex:1 1 150px}
  .card{grid-template-columns:1fr}.card-actions{grid-column:auto}.card-actions button{flex:1 1 145px}
  #patients table{min-width:0}.patient-actions{min-width:0}
  .appt-row{grid-template-columns:1fr}.appt-row button{display:inline-flex}.appt-row .badge{justify-self:start}
  .surgery-card,.transaction-row,.staff-row{grid-template-columns:1fr}
  .transaction-row time{text-align:left}
  .timeline-toolbar{align-items:stretch}.timeline-filters{overflow-x:auto;flex-wrap:nowrap;padding-bottom:5px}.timeline-filter{flex:0 0 auto}
  .task-summary{grid-template-columns:1fr}
}
@media(max-width:580px){
  header{height:72px;padding:8px 12px}.mark{width:40px;height:40px;border-radius:11px}header h1{max-width:145px;font-size:13px;line-height:1.2}.user{margin-left:auto}.user button{min-height:36px!important;padding:7px 9px!important;font-size:10px}.user strong,.user .live{display:none}
  aside{display:block;position:fixed;inset:72px 0 auto;width:100%;height:58px;padding:6px 8px;overflow-x:auto;overflow-y:hidden;z-index:6}aside nav{display:flex;width:max-content;gap:5px}aside nav button{width:auto;min-width:48px;min-height:44px;margin:0;padding:8px 11px}aside nav button:hover{transform:none}
  main{padding:150px 14px 34px}
  .panel{padding:15px;margin-top:16px;border-radius:13px}
  dialog{width:calc(100% - 18px)}dialog form{padding:20px 16px}
  .actions{align-items:stretch;flex-direction:column-reverse}.actions>button{width:100%;flex-basis:auto}
  .care-next{align-items:stretch}.care-next button{width:100%}
  .patient-quick-actions{grid-template-columns:1fr!important}
  .credential-password-row{align-items:stretch;flex-direction:column}.credential-password-row button{width:100%}
  .edit-patient-grid{grid-template-columns:1fr}
  .care-coordinator .care-actions{grid-template-columns:1fr}
}
@media(max-width:1350px){
  #patients .table-wrap{overflow:visible;background:transparent;border:0;box-shadow:none;padding:0}
  #patients table,#patients tbody{display:block;width:100%}#patients thead{display:none}
  #patients tr{display:grid;grid-template-columns:110px minmax(130px,1.25fr) 75px 125px minmax(100px,1fr) 115px;align-items:center;gap:8px 12px;margin-bottom:12px;padding:15px;border:1px solid #dce5e1;border-radius:14px;background:#fff;box-shadow:0 7px 20px #213a300d}
  #patients td{display:block;padding:2px 0;border:0;white-space:normal!important}
  #patients td:last-child{grid-column:1/-1;margin-top:7px;padding-top:10px;border-top:1px solid #e3e8e5}
  .patient-actions{grid-template-columns:repeat(5,minmax(0,1fr))}.patient-actions button{font-size:10px;padding-inline:4px!important}
}
@media(max-width:850px) and (min-width:521px){
  #patients tr{grid-template-columns:110px minmax(0,1fr) 110px;align-items:start}
  #patients td:nth-child(1){grid-row:1/3}#patients td:nth-child(2){grid-column:2/4}#patients td:nth-child(5){grid-column:2/3}#patients td:nth-child(6){grid-column:3/4;text-align:right}
  #patients td:last-child{grid-column:1/-1}
}
@media(max-width:520px){
  #patients tr{grid-template-columns:1fr 1fr}#patients td:nth-child(1){grid-row:auto}#patients td:nth-child(2),#patients td:nth-child(5),#patients td:nth-child(6){grid-column:auto;text-align:left}#patients td:last-child{grid-column:1/-1}
  .patient-actions{grid-template-columns:1fr 1fr}.patient-actions .primary{grid-column:1/-1}
}
