/* Shared screen constraints; printed clinical documents keep their own layout. */
@media screen {
  :root{--hd-space:16px;--hd-control-height:40px}
  .control-study{padding:16px;border-bottom:1px solid #dce6f1;overflow-wrap:anywhere}
  .control-study:last-child{border-bottom:0}
  body.hd-admin-history .list{border:0;border-radius:0;overflow:visible}
  body.hd-admin-history .row{padding:18px 15px;grid-template-columns:1.15fr 1.4fr 1fr max-content;gap:20px;min-width:0}
  body.hd-admin-history .row>div{min-width:0;overflow-wrap:anywhere}
  body.hd-admin-history .history-study{display:block;font-size:14px;line-height:1.4;margin-top:7px}
  @media(max-width:760px){body.hd-admin-history .row{grid-template-columns:1fr;gap:12px}body.hd-admin-history .row button{justify-self:start}}
  #doctors .row{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}
  #doctors .row>div{min-width:0}
  #doctors .doctor-actions{display:flex;flex-wrap:wrap;gap:8px;width:100%;min-width:0;align-items:center}
  #doctors .doctor-actions .button{flex:1 1 120px;min-width:0;white-space:normal;text-align:center;line-height:1.3;padding:10px 8px}
  #doctors .doctor-actions strong{flex:0 0 100%;text-align:right}
  .control-appointment>b,.control-appointment>small{display:block}
  .control-appointment>small{margin:6px 0 10px;color:#587295}
  .control-appointment>div{font-size:13px;line-height:1.6;margin-top:4px;color:#587295}
  .control-study-title,.control-study-sections{display:grid;grid-template-columns:1fr 1.2fr;gap:20px}
  .control-study-title b,.control-study-title small{display:block}
  .control-study-title small{margin-top:4px;color:#587295}
  .control-study-sections{margin-top:14px;font-size:13px;color:#587295;line-height:1.6}
  .control-study-sections strong{font-size:inherit;color:#29476e}
  .control-study h3{font-size:14px;margin:12px 0 6px;color:#193962}
  .control-study-cancel{margin-top:12px;padding:12px;background:#fff3f3;border-radius:8px;font-size:13px}
  @media(max-width:700px){.control-study-title,.control-study-sections{grid-template-columns:1fr;gap:10px}}
  .sent-study .sent-order{display:block;margin-top:7px;font-weight:700;line-height:1.35}
  .study.sent-study .row-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px!important;width:240px;max-width:100%}
  .study.sent-study .row-actions button{width:100%;min-height:40px;margin:0;padding:9px 10px;line-height:18px;font-size:13px;white-space:normal}
  .study.sent-study>div{line-height:1.35}
  .study.sent-study small{display:block;margin-top:4px}
  @media(min-width:1101px){.study.sent-study{grid-template-columns:minmax(0,1.1fr) minmax(0,1.4fr) minmax(0,1fr) 240px!important;gap:16px}}
  header .hd-admin-back,.hd-admission-back,header .header-actions #back.hd-admission-back{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;flex-shrink:0;
    min-height:var(--hd-control-height)!important;padding:10px 14px!important;border:1px solid #0874e8!important;
    border-radius:8px!important;background:#0874e8!important;color:#fff!important;
    font-family:inherit!important;font-size:14px!important;font-weight:600!important;line-height:18px!important;text-decoration:none}
  [data-admin-counters] .metric b{min-height:32px;line-height:32px;font-variant-numeric:tabular-nums}
  [data-admin-counters]:not([data-ready]) .metric b{visibility:hidden}
  .study>.badge{display:flex;align-items:center;justify-content:center;text-align:center}
  header .status .online-dot{color:#3bc98b!important;font-size:16px;line-height:1;margin-right:5px}
  #dashboard .summary{gap:16px!important}
  @media(min-width:1000px){#dashboard .summary{grid-template-columns:repeat(4,minmax(0,1fr))!important}}
  @media(min-width:600px) and (max-width:999px){#dashboard .summary{grid-template-columns:repeat(2,minmax(0,1fr))!important}}
  /* One spacing scale for portal controls; clinical print layouts are excluded. */
  header .header-actions,.hero .session{gap:8px!important;align-items:center;flex-wrap:wrap}
  header .header-actions button,header .header-actions a,.hero .session button,.hero .session a,
  header .header-actions .status,.hero .session>span,header .logout,.study-head #logout{
    min-height:var(--hd-control-height);margin:0!important;padding:10px 13px!important;
    border:1px solid #cad9e9!important;border-radius:8px!important;
    background:#fff!important;color:#46617f!important;font-family:inherit!important;
    font-size:13px!important;font-weight:400!important;line-height:18px!important;
    display:inline-flex;align-items:center;justify-content:center;text-align:center;text-decoration:none;white-space:nowrap;flex-shrink:0;
  }
  .back-menu,button#back,a#back,button#home,a#home,.history-home{
    min-height:var(--hd-control-height);padding:10px 14px!important;border-radius:8px!important;
    font-family:inherit!important;font-size:14px!important;font-weight:600!important;line-height:20px!important;
    display:inline-flex;align-items:center;justify-content:center;text-align:center;text-decoration:none;
  }
  header .header-actions #back,header .header-actions #home{font-size:13px!important;font-weight:400!important;line-height:18px!important}
  .hd-admission-back,header .header-actions #back.hd-admission-back{font-size:14px!important;font-weight:600!important;line-height:18px!important}
  .card>.head,.panel>.head{gap:16px;flex-wrap:wrap;margin-bottom:16px}
  form>.grid+button,form>.two+button,form>.form-grid+button,
  form>label+button,form>textarea+button,form>input+button{margin-top:16px!important}
  form>.grid+button+button,form>.two+button+button{margin-top:16px!important}
  .card form>.grid,.panel form>.form-grid{row-gap:16px}
  .card form>.message,.panel form>.message{margin-top:12px}
  .home-actions{gap:16px!important}
  .home-actions button{border-radius:8px!important;padding:16px!important;line-height:1.4}
  *,*::before,*::after{box-sizing:border-box}
  .study>div,.row>div,.grid>*,.two>*,.history-patient,.history-record{min-width:0}
  .study b,.row b,.history-meta{overflow-wrap:anywhere}
  dialog{max-width:calc(100vw - 24px);max-height:calc(100dvh - 32px);overflow:auto}
  @media(pointer:coarse){:root{--hd-control-height:44px}button,.button,input,select{min-height:44px}}
  @media(max-width:1100px){
    .study{grid-template-columns:1fr!important}
    .study .actions{max-width:100%;width:100%}
    .history-filters,.filters{min-width:0}
  }
  @media(max-width:820px){
    .history-filters{grid-template-columns:repeat(2,minmax(0,1fr))!important}
    .grid,.two,.people{grid-template-columns:minmax(0,1fr)!important}
    .hero,.brand,.header-actions,.session{flex-wrap:wrap;min-width:0}
    .hero h1,.brand h1{white-space:normal!important}
    .history-filters,.filters{grid-template-columns:repeat(2,minmax(0,1fr))!important}
    .history-filters input,.filters input{width:100%;min-width:0}
    .recent article{grid-template-columns:minmax(0,1fr)!important;gap:12px}
    input,select,textarea{max-width:100%;font-size:16px!important}
    .paper,.receipt{max-width:100%}
    .sheet{width:100%!important;height:auto!important;padding:0 10px}
    .copy{height:auto!important;min-height:0!important;overflow:visible!important;padding:16px!important}
    .copy .top{gap:10px}
    .copy .logo{width:120px;max-width:40%}
    .copy .hospital{overflow-wrap:anywhere}
    .copy .details{grid-template-columns:minmax(0,1fr)!important;gap:10px}
    .copy .bottom{margin-top:16px;gap:12px;align-items:flex-start}
    .copy .access{min-width:0;overflow-wrap:anywhere}
    .copy .order.tall{height:auto;min-height:45px}
  }
  @media(max-width:480px){
    .history-filters,.filters{grid-template-columns:minmax(0,1fr)!important}
    .history-actions,.study-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}
    .row-actions{flex-wrap:wrap}
  }
}
