/* One workspace on desktop, tablet and phone. Keep all data and permissions shared. */
.mobile-filter-toggle{display:none}
.patient-meta{display:flex;flex-wrap:wrap;gap:3px 12px}
.workspace,.split>*,.page-heading>*,.patient-banner>*,.settings-grid>*{min-width:0}
.table-scroll{max-width:100%;overscroll-behavior-x:contain}

@media(max-width:720px){
  html{scroll-padding-top:75px;scroll-padding-bottom:100px}
  body{font-size:15px}
  .shell{min-height:100dvh;padding-bottom:calc(76px + env(safe-area-inset-bottom))}
  .sidebar{height:auto;min-height:60px;padding:12px max(16px,env(safe-area-inset-left));display:flex;justify-content:flex-start;flex-wrap:nowrap;backdrop-filter:none;-webkit-backdrop-filter:none;background:#fbfbfd}
  .brand{font-size:16px;margin:0;min-height:36px;white-space:normal}
  .brand-mark{width:32px;height:32px;border-radius:10px}
  .sidebar nav{position:fixed;left:0;right:0;bottom:0;top:auto;display:flex;justify-content:space-around;gap:0;padding:7px max(6px,env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom));background:#fbfbfdf5;border-top:1px solid #dedee7;box-shadow:0 -8px 30px #25344d08;backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);overflow:visible}
  nav a{flex:1;min-width:0;min-height:55px;padding:6px 2px;flex-direction:column;gap:4px;font-size:10px;border-radius:13px;line-height:1.4}
  nav a .ui-icon{display:block;width:21px;height:21px;stroke-width:1.7}
  nav a.active{background:#eaf2ff;color:#0068d4;box-shadow:none}
  nav i{position:absolute;top:2px;right:10%;font-size:9px;background:#0071e3;color:#fff}
  nav a.active i{background:#0071e3;color:#fff}
  header{height:auto;min-height:52px;gap:8px;flex-wrap:wrap;padding:4px 16px;border-bottom:1px solid #e8e8ee70}
  .breadcrumb-wrap{min-width:0;gap:8px;flex:1}
  .breadcrumb-home{display:inline;font-size:11px;white-space:nowrap}
  .breadcrumb-separator{display:inline}
  #breadcrumb{font-size:11px;overflow-wrap:anywhere}
  .header-right{gap:8px;flex-wrap:wrap;justify-content:flex-end}
  .user-chip{max-width:90px;font-size:11px}
  #user-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .user-avatar{display:none}
  .text-button{font-size:11px;min-height:44px;padding:8px 5px}
  main{padding:22px max(16px,env(safe-area-inset-right)) 24px;min-height:calc(100dvh - 260px)}
  footer{margin:0 16px;padding:18px 0;font-size:10px;line-height:1.8}
  .page-heading{flex-wrap:wrap;gap:14px;margin-bottom:22px}
  .page-heading h1{font-size:29px;letter-spacing:-1px}
  .page-heading p{font-size:12px}
  .page-heading .actions>button{font-size:13px;min-height:44px;padding:10px 16px}
  button,.download-button{min-height:44px}
  input,select,textarea,.toolbar input,.toolbar select,.patient-control-column select,.timeline-order-label select,.import-row textarea{font-size:16px;min-height:46px}
  input[type=checkbox]{min-height:20px;width:20px;height:20px}
  input[type=file]{font-size:14px}
  label{font-size:13px}
  .field-help{font-size:12px;line-height:1.8}
  .toolbar{gap:10px}
  .toolbar input{flex:1;min-width:0;width:calc(100% - 78px);border-radius:14px;padding:12px}
  #search-form{display:grid;grid-template-columns:minmax(0,1fr) 64px;align-items:center}
  #search-form input{width:100%;max-width:none;grid-column:1;grid-row:1}
  #search-form>[type=submit]{grid-column:2;grid-row:1;min-width:64px}
  #search-form .mobile-filter-toggle{grid-column:1;grid-row:2;justify-self:start}
  #search-form .count-label{grid-column:1/-1;grid-row:2;justify-self:end;text-align:right;max-width:calc(100% - 118px)}
  .toolbar>button{font-size:13px}
  .toolbar .mobile-filter-toggle{display:inline-flex;background:#edf3fc;border-color:#dce7f7;color:#35679f;min-height:44px;padding:10px 14px}
  .count-label{font-size:11px;white-space:normal}
  .dashboard-hero:before{width:100%;right:0}
  .dashboard-hero h1{font-size:37px}
  .hero-actions{flex-wrap:wrap}
  .hero-actions button,.hero-actions a{font-size:13px;min-height:44px;padding:10px 14px}
  .card{padding:18px 16px;border-radius:20px}
  .stat-number{font-size:35px}
  .stat-note{font-size:11px;line-height:1.7}
  .stat-icon{width:27px;height:27px}
  .panel-head{flex-wrap:wrap;gap:10px;padding:18px}
  .panel-head h2{font-size:16px}
  .panel-head small{font-size:11px}
  .panel-body{padding:18px}
  .quick-link b{font-size:14px}
  .quick-link small,.notice{font-size:12px}
  .first-import{flex-wrap:wrap}

  /* Retain one set of filters and controls, with cards below on small screens. */
  .panel:has(>.table-scroll>.patients-table){background:transparent;border:0;box-shadow:none;overflow:visible}
  .panel:has(>.table-scroll>.patients-table)>.table-scroll{overflow:visible}
  .patients-table{display:block;min-width:0;width:100%;border:0}
  .patients-table thead{display:none}
  .patients-table.filters-open thead{display:block;margin-bottom:16px;padding:16px;background:#fff;border:1px solid #e4e8f0;border-radius:18px}
  .patients-table thead tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 12px}
  .patients-table thead th{display:none;min-width:0;width:auto;padding:0;border:0;background:transparent;white-space:normal;font-size:12px}
  .patients-table thead .grade-column,.patients-table thead .patient-control-column{display:block}
  .patients-table thead .grade-column{grid-column:1/-1;display:flex;align-items:center;gap:10px;width:100%;min-width:0;padding:0}
  .patients-table thead .grade-column:after{content:'患者分级筛选';color:#73737d}
  .patients-table thead .patient-control-column:has(.patient-date-controls){grid-column:1/-1}
  .patient-date-controls{margin-top:8px}
  .patient-date-controls select{flex:1}
  .patients-table .patient-control-column select{width:100%;margin:8px 0 0;padding:10px 8px;border-radius:10px;font-size:16px}
  .patients-table tbody{display:grid;gap:14px}
  .patients-table tbody tr{display:grid;grid-template-columns:44px repeat(3,minmax(0,1fr));gap:14px 10px;padding:18px 16px;background:#fff;border:1px solid #e5e6ed;border-radius:20px;box-shadow:0 4px 16px #25344d04}
  .patients-table tbody td{display:block;width:auto;min-width:0;padding:0;border:0;font-size:14px;white-space:normal;overflow-wrap:anywhere}
  .patients-table tbody .grade-column{grid-column:1;grid-row:1;min-width:0;padding:0}
  .patient-grade{height:44px;width:44px;min-width:44px;padding:8px;border-radius:12px}
  .grade-swatch{height:14px;width:14px}
  .grade-option{height:44px;width:44px;min-width:44px}
  .grade-menu{max-height:calc(100dvh - 32px);overflow:auto}
  .patients-table tbody .patient-name-column{grid-column:2/-1;align-self:center}
  .patients-table .row-title{font-size:16px;line-height:1.6;display:inline-block}
  .patients-table td small{font-size:11px;margin-top:4px}
  .patients-table td[data-label]:before{content:attr(data-label);display:block;color:#858591;font-size:11px;margin-bottom:5px;line-height:1.5}
  .patients-table tbody .patient-sex{grid-column:1/2}
  .patients-table tbody .patient-age{grid-column:2/3}
  .patients-table tbody .patient-region{grid-column:3/-1}
  .patients-table tbody .patient-first-visit,.patients-table tbody .patient-last-pickup{grid-column:1/3}
  .patients-table tbody .patient-review,.patients-table tbody .patient-updated{grid-column:3/-1}
  .patients-table tbody .patient-actions-column{grid-column:1/-1;min-width:0;padding-top:12px;border-top:1px solid #f0f0f4}
  .patient-row-actions{display:flex;flex-direction:row;justify-content:space-between;gap:8px;align-items:center}
  .patient-row-actions>*{display:flex;justify-content:center;align-items:center;flex:1;min-height:44px;font-size:12px!important;border-radius:10px;background:#f4f7fc;padding:8px 4px!important;white-space:normal!important;text-align:center}
  .patient-row-actions a{background:#ecf3ff}
  .patient-category-buttons{gap:2px;padding-bottom:2px}
  .patient-category-buttons button{min-height:28px;width:28px;height:28px;font-size:10px}

  .back{font-size:12px;min-height:40px;margin-bottom:12px}
  .patient-banner{align-items:flex-start;gap:12px;width:100%}
  .avatar{width:44px;height:44px;border-radius:15px;font-size:22px}
  .patient-name-cell{gap:8px;align-items:flex-start}
  .patient-name-cell>span{font-size:25px;line-height:1.45;overflow-wrap:anywhere}
  .patient-name-cell>.patient-grade{flex-shrink:0;width:38px;min-width:38px}
  .patient-meta{font-size:12px;max-width:none;gap:4px 10px;margin-top:10px;line-height:1.8}
  .page-heading:has(.patient-banner){display:block}
  .page-heading:has(.patient-banner)>.actions{margin-top:18px;justify-content:flex-end}
  .tabs{width:100%;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;border-radius:18px;padding:5px;overflow:visible}
  .tabs button{font-size:12px;min-height:44px;padding:10px 6px;white-space:normal;border-radius:13px}
  .event-filters{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
  .event-filter-button{min-height:44px;padding:8px 4px;font-size:11px;white-space:normal;line-height:1.5;border-radius:11px}
  .timeline-filter-meta{gap:10px}
  .timeline-order-label{white-space:normal;font-size:12px;gap:8px}
  .timeline-order-label select{min-width:0;width:auto;margin:0;max-width:175px}
  .timeline{padding:0 18px}
  .event{padding:22px 0}
  .event-head time{font-size:14px}
  .event-head>.subtle{font-size:11px;overflow-wrap:anywhere}
  .tag{font-size:11px}
  .event-field{display:block;margin:16px 0;font-size:14px}
  .event-field>span:first-child{display:block;font-size:12px;color:#858591;margin-bottom:6px}
  .event-content{font-size:15px;line-height:1.95}
  .details-grid{gap:22px 16px}
  .details-grid .pre{font-size:14px}
  .detail-label{font-size:12px}
  .lab-images{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .lab-thumb img{height:130px}
  .lab-thumb span{font-size:11px}
  .task-table{display:block;min-width:0}
  .task-table thead{display:none}
  .task-table tbody{display:block}
  .task-table tr{display:block;padding:18px;border-bottom:1px solid #ededf2}
  .task-table tr:last-child{border:0}
  .task-table td{display:grid;grid-template-columns:64px minmax(0,1fr);align-items:start;gap:6px 12px;padding:8px 0;border:0;font-size:14px;overflow-wrap:anywhere}
  .task-table td:before{content:attr(data-label);color:#858591;font-size:12px;grid-row:1/3}
  .task-table td small{grid-column:2;font-size:11px;margin:0}
  .task-table td>*{justify-self:start}
  .task-table .task-actions button{font-size:13px;min-height:44px}
  .upload-area{padding:24px 16px}
  .upload-area .treatment-group-field select{max-width:100%}
  .import-row .grid-2{grid-template-columns:1fr;gap:0}
  .import-image-grid{grid-template-columns:1fr}
  .source-scroll{max-height:360px}
  .source-scroll table{min-width:600px}
  .sticky-action{bottom:calc(82px + env(safe-area-inset-bottom));padding:14px;gap:10px}
  .sticky-action .actions{display:grid;grid-template-columns:1fr 1fr}
  .sticky-action .actions button{padding:9px 10px;font-size:12px}
  .settings-grid table{min-width:440px}
  .auth{min-height:100dvh}
  .auth-story{min-height:220px;padding:24px}
  .auth-story-copy h2{font-size:26px}
  .auth-story-copy{padding-top:22px}
  .auth-entry{padding:30px 24px calc(54px + env(safe-area-inset-bottom))}
  .auth-brand{font-size:15px}
  .auth-panel input{font-size:16px;min-height:48px}
  .auth-panel button{font-size:15px;min-height:48px}
  dialog{width:calc(100% - 16px);max-width:600px;max-height:calc(100vh - 16px);max-height:calc(100dvh - 16px);border-radius:22px;overscroll-behavior:contain}
  .dialog-head{padding:14px 18px;gap:12px}
  .dialog-head h2{font-size:19px}
  .dialog-head .icon-button{width:44px;height:44px;min-width:44px}
  #modal-body{padding:20px 18px max(20px,env(safe-area-inset-bottom))}
  .grid-2,.pickup-fields{grid-template-columns:minmax(0,1fr)}
  .grid-2>.treatment-group-field{grid-column:auto}
  .form-actions{gap:10px}
  .form-actions button{font-size:14px;min-height:46px;flex:1}
  .toast{bottom:calc(88px + env(safe-area-inset-bottom));font-size:13px;border-radius:16px;max-width:calc(100vw - 32px);width:max-content;text-align:center}
}

@media(min-width:721px) and (max-width:1024px){
  .cards{grid-template-columns:repeat(2,minmax(0,1fr))}
  .sidebar{position:static}
  .patient-banner{align-items:flex-start}
  .patient-name-cell>span{overflow-wrap:anywhere}
  .page-heading:has(.patient-banner){flex-wrap:wrap}
  .page-heading:has(.patient-banner)>.actions{margin-left:auto}
  input,select,textarea{font-size:16px}
  .toolbar input,.toolbar select,.patients-table .patient-control-column select,.timeline-order-label select{font-size:16px;min-height:44px}
}

@media(max-width:360px){
  .header-right{width:100%;justify-content:flex-end}
  header{padding-top:10px}
  .patient-banner .avatar{display:none}
  .patient-category-buttons button{min-height:26px;width:26px;height:26px}
  .patients-table tbody tr{padding:16px 14px}
  .dashboard-hero h1{font-size:33px}
}
