/* V0.1.31 — campos e controles em telas pequenas. Regras de negócio preservadas. */
@media screen and (max-width:760px), screen and (pointer:coarse){
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea,
  .company-select,.topbar .company-select{font-size:16px}
}
@media screen and (max-width:760px){
  .content,.workspace,#page,.panel,.panel-body,.modal-body,.modal-form,
  .row,.row>*,.toolbar>*,.nfse,.nfse-grid>*{min-width:0;max-width:100%}
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea{
    box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:44px;
  }
  /* Safari: impedir que o valor nativo imponha uma largura maior que o campo. */
  input[type=date],input[type=time],input[type=datetime-local]{
    -webkit-appearance:none;appearance:none;display:block;width:100%;min-width:0;max-width:100%;
    min-height:44px;text-align:left;
  }
  input::-webkit-date-and-time-value{min-width:0;text-align:left}
  input::-webkit-datetime-edit{min-width:0;padding:0}
  input::-webkit-datetime-edit-fields-wrapper{min-width:0;padding:0}
  input[type=file]{overflow:hidden}
  label{min-width:0;overflow-wrap:anywhere}
  .toolbar{display:grid;grid-template-columns:minmax(0,1fr);align-items:end;gap:12px}
  .toolbar label,.toolbar label.grow{min-width:0;width:100%;margin:0}
  .toolbar .btn{width:100%;height:auto;min-height:44px}
  .toolbar .error{margin:0}
  .row>*{width:100%;flex-basis:auto}
  .btn{min-width:0;max-width:100%;min-height:44px;white-space:normal;overflow-wrap:normal;word-break:normal;text-align:center;height:auto}
  .btn.small,.page-head .btn{min-height:44px;white-space:normal}
  .actions{flex-wrap:wrap;max-width:100%;gap:8px}
  .page-head{flex-direction:column;align-items:stretch}
  .page-head>div,.page-head>.actions{min-width:0;max-width:100%}
  .page-head>.btn{align-self:flex-start}
  .page-head>.actions{justify-content:flex-start}
  .panel-head{flex-direction:column;align-items:stretch;gap:12px}
  .panel-head>div,.panel-head>h2{min-width:0;overflow-wrap:anywhere}
  .panel-head>.btn{align-self:flex-start}
  .panel-head .actions{justify-content:flex-start}
  .panel-head .actions>.btn{flex:1 1 140px}
  .summary-list li{gap:12px;flex-wrap:wrap}
  .summary-list li>span{flex:1 1 120px;min-width:0;overflow-wrap:anywhere}
  .summary-list li>strong{min-width:0;max-width:100%;overflow-wrap:anywhere;text-align:right}
  .summary-list li>.actions{width:100%;justify-content:flex-start}
  .summary-list .actions>.btn{flex:1 1 85px}
  .search-item{flex-wrap:wrap;min-width:0}
  .search-item>div{flex:1 1 160px;min-width:0;overflow-wrap:anywhere}
  .search-item .btn{margin-left:0}
  .topbar .top-left{flex:1;min-width:0;max-width:none}
  .top-left>div:not(.header-brand){min-width:0;flex:1}
  .topbar .company-select{max-width:100%;min-width:0;width:100%;text-overflow:ellipsis}
  .topbar .menu-toggle,.topbar .account{flex-shrink:0}
  .topbar .account .btn{padding:8px}
  .topbar .header-brand{flex:0 0 64px}
  dialog{width:calc(100% - 24px);max-width:640px;max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);margin:auto;overflow:auto;overscroll-behavior:contain}
  .modal-head{gap:12px}
  .modal-head h2{min-width:0;overflow-wrap:anywhere}
  .modal-head>.btn{flex-shrink:0;width:44px}
  .modal-body{padding:4px 16px 20px}
  .modal-foot{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .modal-foot .btn{width:100%;margin:0;min-height:44px}
  .grade-row{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-bottom:20px}
  .grade-row>label:first-child{grid-column:1/-1}
  .grade-row .step{grid-column:1}
  .grade-row>.btn{grid-column:2;justify-self:end;width:44px}
  .grade-row label{min-width:0}
  .nfse .nfse-grid,.nfse .nfse-filters,.nfse .nfse-actions,.nfse .nfse-diagnostic li{grid-template-columns:minmax(0,1fr)}
  .nfse .nfse-grid label{grid-template-rows:auto 44px}
  .nfse .nfse-full{grid-column:auto}
  .nfse .nfse-full label{grid-template-rows:auto auto}
  .nfse .nfse-filters{padding:16px}
  .nfse .nfse-filters input{min-width:0;max-width:100%}
  .nfse .nfse-actions{width:100%}
  .calendar-navigation{min-width:0;width:100%}
  .calendar-navigation h2{flex-basis:100%;margin:6px 0 0;overflow-wrap:anywhere}
  .calendar-navigation .btn{min-width:44px}
  .tabs{max-width:100%;overscroll-behavior-x:contain}
  .notice,.hint,.record,.doctor-card h3{overflow-wrap:anywhere}
  /* Manter tabelas e calendários largos em suas áreas de rolagem. */
  .table-wrap,.calendar-scroll,.billing-scroll,.finance-table,.cash-table,.requests-scroll{min-width:0;max-width:100%;overscroll-behavior-x:contain}
  .nfse-actions .btn,.billing-detail-actions .btn{max-width:100%}
  html:has(dialog[open]),body:has(dialog[open]){overflow:hidden;overscroll-behavior:none}
}

/* V0.1.41 — entrada guiada, login e modais sem expansão lateral. */
textarea{resize:none}
.setup-list{list-style:none;margin:0;padding:0;display:grid;gap:12px}
.setup-item{display:flex;align-items:center;justify-content:space-between;gap:16px;border-bottom:1px solid #e3e9ef;padding:12px 0}
.setup-item>div{min-width:0}.setup-item .hint{margin:8px 0 0}
.setup-state{display:inline-block;margin-left:10px;padding:4px 8px;font-size:12px;border-radius:8px;background:#fff2cf;color:#815e12}
.setup-state.done{background:#e1f4eb;color:#23694d}
.setup-doctors{display:grid;gap:16px}.setup-doctor{padding:16px;border:1px solid #e3e9ef;border-radius:12px;min-width:0}
.setup-doctor h3{margin:0;overflow-wrap:anywhere}
@media(max-width:760px){
 .login,.login-form,.login-form>div,.boot{min-width:0;max-width:100%;box-sizing:border-box}
 .login-form{padding:24px 16px}.login-form form{min-width:0}
 .setup-item{flex-direction:column;align-items:stretch}.setup-item .btn{align-self:flex-start}
 .setup-state{margin-left:0;margin-top:8px;display:table}
 .setup-doctor .actions .btn{flex:1 1 140px}
 .modal-body p,.modal-body strong,.notice,.error{overflow-wrap:anywhere}
 .doctor-card{min-width:0;max-width:100%}
}

.mobile-record-buttons{display:contents}
/* V0.1.46 — listas completas no mobile, dados e ações no mesmo registro. */
@media screen and (max-width:760px){
 .content{padding:20px 16px 28px}
 .content h1{font-size:24px;line-height:30px}
 .page-head{gap:12px;margin-bottom:20px}
 .page-head p{font-size:13px;line-height:20px;margin-bottom:0}
 .panel-head{padding:16px;gap:8px;flex-direction:row;flex-wrap:wrap;align-items:center}
 .panel-head h2{font-size:17px;line-height:23px;margin:0}
 .panel-head small{font-size:12px;line-height:18px}
 .panel-head>small{margin:0}
 .workspace .btn,dialog .btn{font-size:12px;min-height:40px;padding:8px 10px;overflow-wrap:normal;word-break:normal}
 .workspace .btn.small,dialog .btn.small{padding:6px 8px}
 .actions>.btn{flex-shrink:0;overflow-wrap:normal;word-break:normal}
 .panel-head .actions,.page-head>.actions,.record .actions,.clin-head .actions,.setup-doctor .actions,.billing-detail-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:8px}
 .panel-head .actions>.btn,.page-head>.actions>.btn,.record .actions>.btn,.clin-head .actions>.btn,.setup-doctor .actions>.btn,.billing-detail-actions>.btn{width:100%;min-width:0;margin:0}
 .toolbar{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:16px}
 .toolbar>label,.toolbar>.error,.toolbar>.hint,.toolbar>p{grid-column:1/-1}
 .toolbar .btn{min-height:40px;height:auto}
 .toolbar:has(>.btn:only-of-type)>.btn,.toolbar:has(>button:only-of-type)>button{grid-column:1/-1}
 .mobile-records-wrap{min-width:0;max-width:100%;max-height:480px;overflow:auto;overscroll-behavior:contain}
 table.mobile-records{display:block;width:100%;min-width:0;max-width:100%;white-space:normal;font-size:13px;border-collapse:separate}
 table.mobile-records>thead{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
 table.mobile-records>tbody,table.mobile-records>tfoot{display:grid;gap:12px;padding:12px}
 table.mobile-records>tbody>tr,table.mobile-records>tfoot>tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 12px;border:1px solid var(--line);border-radius:12px;padding:12px;background:white;min-width:0}
 table.mobile-records td{display:block;min-width:0;max-width:100%;padding:0;border:0;white-space:normal;overflow-wrap:anywhere;line-height:19px}
 table.mobile-records td::before{content:attr(data-mobile-label);display:block;font-size:10px;line-height:14px;font-weight:700;color:var(--muted);letter-spacing:.3px;margin-bottom:3px}
 table.mobile-records td>strong{font-size:13px;line-height:19px}
 table.mobile-records td small{font-size:12px;line-height:18px;max-width:100%;margin-top:2px;white-space:normal}
 table.mobile-records td[data-mobile-label=""]::before{display:none}
 table.mobile-records td.mobile-record-primary{grid-column:1/-1;order:-1}
 table.mobile-records td.mobile-record-primary>strong{font-size:14px;line-height:20px}
 table.mobile-records td.mobile-record-wide{grid-column:1/-1}
 table.mobile-records td.mobile-record-actions{grid-column:1/-1;order:1;padding-top:10px;border-top:1px solid var(--line)}
 table.mobile-records td.mobile-record-actions::before{display:none}
 table.mobile-records .actions,table.mobile-records .mobile-record-buttons{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;min-width:0;width:100%;max-width:100%;justify-content:stretch}
 table.mobile-records .actions>.btn,table.mobile-records .mobile-record-buttons>.btn{width:100%;min-width:0;max-width:100%;min-height:40px;margin:0;padding:6px 8px;white-space:normal;overflow-wrap:normal;word-break:normal;font-size:12px;line-height:17px}
 table.mobile-records td>.btn{width:auto;max-width:100%;white-space:normal;overflow-wrap:normal;word-break:normal;min-height:40px}
 .agenda-day-list,.day-consultations,.finance-table,.cash-table,.billing-scroll,.requests-scroll{min-width:0;max-width:100%;overscroll-behavior:contain}
 .agenda-day-list .mobile-records-wrap,.day-consultations .mobile-records-wrap,.finance-table .mobile-records-wrap,.cash-table .mobile-records-wrap{max-height:none;overflow:visible}
 .finance-table table.mobile-records th,.cash-table table.mobile-records th,.requests-scroll table.mobile-records th{position:static}
 .cash-period-table table.mobile-records,.requests-scroll table.mobile-records{min-width:0}
 .cash-period-table table.mobile-records td.cash-period-description{min-width:0;max-width:100%}
 .record{padding:16px;min-width:0}
 .record-head{flex-wrap:wrap;gap:8px}
 .record-head>div{min-width:0}
 .record pre,.print-preview{white-space:pre-wrap;overflow-wrap:anywhere;max-width:100%}
 .compact-info{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;min-width:0}
 .compact-info>div{min-width:0;overflow-wrap:anywhere}
 .doctor-card{padding:16px}
 .doctor-card .actions{grid-template-columns:repeat(2,minmax(0,1fr))}
 .doctor-card .actions>.btn{height:auto;min-height:40px;overflow-wrap:normal;word-break:normal}
 .summary-list li>.actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .summary-list .actions>.btn{min-width:0;width:100%}
 .modal-head{padding:16px;align-items:flex-start}
 .modal-head h2{font-size:18px;line-height:24px;margin:0}
 .modal-body{padding:0 16px 16px}
 .modal-foot{padding-top:12px;gap:8px}
 .modal-foot .btn{min-height:40px;overflow-wrap:normal;word-break:normal}
 .nfse .nfse-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .nfse .nfse-actions>.btn{width:100%;min-width:0;font-size:12px}
 .nfse .nfse-diagnostic li{gap:4px;min-width:0}
 .tabs{display:flex;flex-wrap:wrap;gap:6px;padding:12px;overflow:visible}
 .tabs>.tab{flex:1 1 110px;min-width:0;padding:8px;font-size:12px;white-space:normal;overflow-wrap:normal;word-break:normal}
}

@media screen and (max-width:760px){.request-mobile-hint{display:none}}

@media screen and (max-width:760px){
 .notice{padding:12px;font-size:13px;line-height:20px}
 .finance-mobile-hint{display:none}
 table.mobile-records td.mobile-record-primary{font-size:14px;font-weight:650;line-height:20px}
 table.mobile-records td.mobile-record-actions:empty{display:none}
 form[data-form="patient-search"],form[data-form="cid-search"]{grid-template-columns:minmax(0,1fr) 96px;align-items:end}
 form[data-form="patient-search"]>label,form[data-form="cid-search"]>label{grid-column:auto;font-size:12px}
 form[data-form="patient-search"]>button,form[data-form="cid-search"]>button{grid-column:auto!important}
}
