.mobile-navigation,.mobile-only,.mobile-focused-tabs,.mobile-ortho-status{display:none}
@media screen and (max-width:1024px), screen and (max-width:1366px) and (pointer:coarse){
  html{scroll-padding-bottom:145px}
  .shell,.shell.sidebar-collapsed{min-width:0;display:block;grid-template-columns:none;--sidebar-size:0px;--rail-size:0px}
  .shell .sidebar{position:fixed;inset:0 auto 0 0;width:min(300px,85vw);transform:translateX(-101%);visibility:hidden;padding:20px;overflow-y:auto}
  .shell .sidebar.open{transform:none;visibility:visible}.sidebar.open .nav-label,.sidebar.open .brand-copy,.sidebar.open .nav-group{display:block}
  .sidebar.open .sidebar-mobile-head{display:flex}.shell .workspace{margin-left:0;width:100%}
  .workspace{min-width:0;padding-bottom:calc(80px + env(safe-area-inset-bottom,0px))}
  .workspace.mobile-has-context{padding-bottom:calc(130px + env(safe-area-inset-bottom,0px))}
  .workspace .content{padding:14px 10px 24px;min-width:0}
  .mobile-navigation{display:block;position:fixed;inset:auto 0 0;z-index:80;padding-bottom:env(safe-area-inset-bottom,0px);background:#173d48;box-shadow:0 -4px 20px #173d4815}
  .mobile-primary{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));padding:5px 4px;gap:2px}
  .mobile-primary button{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:3px;min-height:53px;padding:5px 1px;border:0;border-radius:10px;color:#d3e4e7;background:transparent;font-size:11px;font-weight:550;white-space:nowrap}
  .mobile-primary button.active{background:#ffffff19;color:#fff;box-shadow:inset 0 3px #62d2d3}
  .mobile-primary svg{width:20px;height:20px}.mobile-more-icon{font-size:20px;line-height:20px;letter-spacing:2px}
  .shell .mobile-primary .nav-label{display:block}
  .mobile-context:empty{display:none}
  .mobile-context{background:#fff;border-top:1px solid #d1e2e7;padding:3px 6px}
  .mobile-context nav{display:flex!important;flex-wrap:nowrap!important;overflow-x:auto;scrollbar-width:thin;gap:3px;margin:0!important;padding:0!important;background:#fff!important;border:0!important;border-radius:0!important;max-width:100%}
  .mobile-context nav button{flex:0 0 auto;min-height:42px;font-size:12px;padding:8px 12px;white-space:nowrap;border:0;border-radius:8px;background:transparent;color:#536b76}
  .mobile-context nav button.active,.mobile-context nav button[aria-current=page]{color:#087f8c;background:#e5f3f4;font-weight:700}
  .mobile-context svg,.mobile-context .tab-icon{display:none}
  .mobile-navigation.keyboard-open{display:none}
  .workspace.mobile-keyboard-open{padding-bottom:20px}
  .mobile-only,.mobile-focused-tabs{display:block}
  .desktop-payment-label{display:none}
  .patient-focus>.mobile-focused-tabs{display:none}
  .topbar{padding:9px 10px;gap:6px;min-width:0}.topbar-context{min-width:0}.topbar-title{display:block!important;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:43vw}
  .topbar .effects-toggle,.topbar .environment-tag,.topbar .topbar-age,.topbar .breadcrumb-divider,.topbar .sidebar-toggle{display:none}
  .topbar-actions{gap:2px}.topbar button{min-width:36px;min-height:40px}.account-menu summary{min-height:40px}
  .page-head{gap:8px;margin-bottom:14px}.page-head h1,h1{font-size:23px}.page-head p{font-size:12px}.page-head .eyebrow{display:none}
  .card{border-radius:12px}.card-head,.card-body{padding:12px}.card-head{flex-wrap:wrap;gap:8px}.card-head h2{font-size:16px}
  .content .stack{gap:12px}.content .actions{gap:6px;flex-wrap:wrap}.content button.small{min-height:40px}
  .content .form-grid,.content .equal-cols,.content .cards.three{grid-template-columns:minmax(0,1fr)}
  .content input,.content select,.content textarea{max-width:100%;font-size:16px}
  .content .table-wrap{max-width:100%}.content .table-wrap table{max-width:none}
  .content .patient-focus-heading{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;padding:10px}.patient-focus-heading h2{font-size:19px}.patient-focus-heading .focus-code{font-size:11px}
  .patient-focus-heading .payment-patient-title{grid-column:1/-1;grid-row:1;min-width:0}.patient-focus-heading .focus-code{display:none}
  /* One name row per patient. The complete record remains in the ficha. */
  .patient-directory-scroll{max-height:none;overflow:visible;scrollbar-gutter:auto}
  .patient-directory-scroll table,.ortho-patients-table{min-width:0!important;width:100%;table-layout:fixed}
  .patient-directory-scroll thead,.patient-directory-scroll td:not(:first-child),.patient-directory-scroll td:first-child .avatar,.patient-directory-scroll td:first-child .sub,.patient-directory-scroll td:first-child .birthday-badge{display:none}
  .patient-directory-scroll td:first-child{min-width:0!important;padding:0 12px}.patient-directory-scroll td:first-child .flex{display:block}
  .patient-directory-scroll [data-action=patient]{width:100%;min-height:52px;text-align:left;white-space:normal;font-size:14px;line-height:1.4;padding:10px 0}
  .ortho-patients-table thead,.ortho-patients-table td:not(:first-child),.ortho-patients-table td:first-child>small{display:none}
  .ortho-patients-table td:first-child{padding:10px 12px;min-width:0}.ortho-patients-table [data-action=ortho-patient]{min-height:32px;white-space:normal;text-align:left;font-size:14px}
  .mobile-ortho-status{display:flex;flex-wrap:wrap;gap:4px;margin-top:5px}.mobile-ortho-status .pill{font-size:10px;padding:3px 6px}.mobile-ortho-status small{font-size:11px}
  /* Four compact columns. All edit/payment controls stay in their original row. */
  .cp-workspace,.oq-workspace{padding:0;min-height:0!important}
  .cp-ledger .ledger-scroll{min-height:0;max-height:none;height:auto}
  .cp-ledger .cp-grid{grid-template-columns:98px minmax(50px,1fr) 52px 58px;gap:5px}
  .cp-ledger .cp-detail,.cp-ledger .cp-actions{grid-column:auto;grid-row:auto}
  .cp-ledger .cp-table thead,.oq-finance .oq-table thead{display:table-header-group}
  .cp-ledger .cp-attention{padding:10px 6px;overflow:visible}.cp-ledger .cp-columns{padding:9px 6px;font-size:10px}
  .cp-ledger .cp-row .cp-attention input{font-size:12px!important;padding:4px 2px;height:36px;min-height:36px}
  .cp-ledger .cp-row .cp-attention textarea{font-size:12px!important;min-height:58px;height:58px;padding:5px}
  .cp-attention .cp-mobile-label,.cp-attention .record-reference,.cp-attention .treatment-summary,.cp-date>small{display:none!important}
  .cp-ledger .cp-actions{display:flex;flex-direction:column;align-items:center;gap:4px}.cp-ledger .cp-actions button{font-size:10px!important;padding:4px 2px!important;min-height:36px;white-space:normal}
  .cp-side,.oq-side{position:relative!important;top:auto!important;right:auto!important;left:auto!important;width:100%!important;max-height:none!important;margin:8px 0 0;padding:12px!important;box-shadow:none}
  .cp-side input,.cp-side select,.cp-side textarea,.oq-side input,.oq-side textarea{font-size:16px!important}
  .cp-clinical-grid,.cp-payment-fields,.cp-side .extra-payment{display:grid!important;grid-template-columns:minmax(0,1fr)!important}
  .oq-finance .oq-table{min-width:0!important;table-layout:fixed;width:100%}.oq-table th:nth-child(1),.oq-row>th{display:none}
  .oq-table th:nth-child(2){width:86px}.oq-table th:nth-child(4){width:52px}.oq-table th:nth-child(5){width:60px}
  .oq-finance .oq-table thead th{font-size:10px;padding:9px 4px}.oq-finance .oq-row>td{padding:9px 3px;width:auto!important;min-width:0!important}
  .oq-row>td>label{font-size:0}.oq-finance .oq-row>td>label>input{font-size:11px;padding:4px 2px;min-height:36px}.oq-finance .oq-row>td>label>textarea{font-size:12px;padding:5px;min-height:58px;height:58px}
  .oq-finance .oq-table thead{display:block;width:100%}
  .oq-table thead tr,.oq-finance .oq-table .oq-row,.oq-finance .oq-table .oq-row.oq-selected{display:grid;grid-template-columns:98px minmax(50px,1fr) 52px 60px}
  .oq-finance .oq-table .oq-row>td>label{font-size:0}
  .oq-row input[type=number]{appearance:textfield;-moz-appearance:textfield}.oq-row input::-webkit-inner-spin-button,.oq-row input::-webkit-outer-spin-button{appearance:none;margin:0}
  .oq-finance .oq-table .oq-row>td{grid-column:auto;grid-row:auto}
  .oq-table thead th{width:auto!important}.oq-table .oq-row>td:last-child{display:contents}
  .oq-payment-summary{display:flex;flex-direction:column;align-items:center;gap:4px;padding:9px 2px;min-width:0}
  .oq-payment-summary button{font-size:10px!important;padding:4px!important;min-height:36px;white-space:normal}
  .oq-finance .oq-table .oq-row .oq-side{grid-column:1/-1}
  .oq-finance .oq-row>td>label>input,.oq-finance .oq-row>td>label>textarea{font-size:12px!important}
  .oq-metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:12px}.oq-metrics>div{min-width:0}.oq-metrics strong{font-size:20px}.oq-metrics small{font-size:11px}
  .oq-heading,.oq-toolbar{padding:12px;flex-wrap:wrap}.oq-heading h3,.oq-toolbar h3{font-size:17px}.oq-plan-note,.oq-footnote{font-size:11px;padding:10px}
  .oq-movements{overflow-x:auto;max-width:100%}.oq-movements table{min-width:580px}
  /* Charts occupy a full readable row; summary metrics remain compact. */
  .insight-grid,.report-group .equal-cols{grid-template-columns:minmax(0,1fr)}.insight-card{padding:13px;border-radius:12px}.insight-title{font-size:15px}.insight-desc,.insight-note{font-size:12px;line-height:1.45}
  .f2-totals{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.f2-totals>div{min-width:0;padding:10px}.f2-totals strong{font-size:21px}.report-group-head{flex-wrap:wrap}.report-group{min-width:0;padding:12px;scroll-margin-top:76px}
  .insight-bar-line{grid-template-columns:minmax(0,1fr) 6rem}.insight-bar-heading{gap:5px}.insight-bar-label,.insight-bar-share,.insight-bar-value{font-size:12px}.insight-details{overflow-x:auto}
  .enh-control-dates{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.enh-control-date{min-width:0;padding:10px}.enh-control-date input{min-width:0}
  dialog{max-width:calc(100vw - 16px)!important;max-height:calc(100dvh - 24px);margin:auto}.modal-content{padding:14px}
  .sidebar{z-index:100}.sidebar-backdrop{z-index:99}
  #toast,.c2-update{bottom:calc(134px + env(safe-area-inset-bottom,0px));z-index:90;max-width:calc(100vw - 24px);font-size:12px}
}
@media screen and (min-width:751px) and (max-width:1024px), screen and (min-width:1025px) and (max-width:1366px) and (pointer:coarse){
  .cp-ledger .cp-grid,.oq-table thead tr,.oq-finance .oq-table .oq-row,.oq-finance .oq-table .oq-row.oq-selected{grid-template-columns:140px minmax(160px,1fr) 100px 100px;gap:8px}
  .cp-ledger .cp-row .cp-attention input,.cp-ledger .cp-row .cp-attention textarea,.oq-finance .oq-row>td>label>input,.oq-finance .oq-row>td>label>textarea{font-size:16px!important}
  .mobile-primary button{font-size:13px}
}
@media print{.mobile-navigation,.mobile-only,.mobile-focused-tabs{display:none!important}}
