/* Ajustes para toque, telas estreitas e o aplicativo instalado. */
img { height: auto; }
.sidebar-close { display: none; }
.calendar-hint { display: none; }
.mobile-cell-label { display: none; }
.grid-two, .grid-three, .two-column, .form-grid { min-width: 0; }
.grid-two > *, .grid-three > *, .two-column > *, .form-grid > * { min-width: 0; }
.patient-summary > div, .page-head > div, .patient-head > div { min-width: 0; }
.patient-head h1, .patient-summary strong, .note-card__head strong { overflow-wrap: anywhere; }
.global-search { min-width: 0; }
.sidebar-brand img { flex-shrink: 0; }
.pwa-install img { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.pwa-install span { flex: 1; }

@media (max-width: 760px) {
  html { scroll-padding-top: 90px; }
  body.menu-open { overflow: hidden; }
  .shell { width: 100%; }
  .topbar { position: sticky; top: 0; z-index: 30; gap: 10px; padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar-left, .profile { flex-shrink: 0; }
  .profile .avatar { display: none; }
  .icon-btn, .btn, .btn--small, .nav-item, .auth-tabs button, .segmented button, .tabs a, .tabs button { min-height: 44px; }
  .icon-btn { min-width: 44px; width: 44px; }
  .btn, .btn--small { font-size: 13px; padding: 11px 14px; line-height: 1.4; white-space: normal; }
  .field > span { font-size: 13px; }
  .field input, .field select, .field textarea, .global-search input { font-size: 16px; min-height: 48px; }
  .field input[type=date], .field input[type=datetime-local] { appearance: none; -webkit-appearance: none; min-width: 0; }
  .field textarea { min-height: 130px; }
  .field small, .auth-help, .small { font-size: 12px; line-height: 1.6; }
  .global-search input { padding-left: 36px; min-height: 44px; }
  .global-search > svg { top: 13px; }
  .search-results { position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 16px; right: 16px; max-height: 55dvh; overflow: auto; }
  .search-results a { min-height: 48px; font-size: 15px; overflow-wrap: anywhere; }
  .sidebar { width: min(320px, calc(100vw - 44px)); padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom)); }
  .sidebar-brand { padding: 0 44px 0 4px; gap: 8px; margin-bottom: 25px; }
  .sidebar-brand .symbol { width: 32px; }
  .sidebar-brand .wordmark { width: min(142px, 100%); }
  .sidebar-close { display: grid; position: absolute; top: max(14px, env(safe-area-inset-top)); right: 10px; }
  .sidebar nav { gap: 4px; }
  .nav-item { font-size: 14px; padding: 13px 12px; }
  .sidebar-foot { margin-top: 20px; padding-inline: 4px; font-size: 12px; }
  .sidebar-foot strong { font-size: 14px; }
  .workspace-label { font-size: 10px; }
  .view { padding: 24px max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .page-head { gap: 18px; margin-bottom: 24px; }
  .page-head h1 { font-size: clamp(24px, 6vw, 30px); overflow-wrap: anywhere; }
  .page-head p { font-size: 14px; }
  .page-head > .actions { width: 100%; }
  .page-head > .actions > .btn { flex: 1 1 140px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { padding: 16px 12px; }
  .metric__label { font-size: 12px; align-items: flex-start; gap: 6px; }
  .metric__label svg { flex-shrink: 0; }
  .metric__value { font-size: clamp(21px, 5.8vw, 27px); }
  .metric__note { font-size: 11px; }
  .panel__head { flex-wrap: wrap; padding: 18px 16px; gap: 12px; }
  .panel__head h2 { font-size: 16px; }
  .panel__body { padding: 18px 16px; }
  .panel__head .actions { width: 100%; }
  .panel__head .btn { max-width: 100%; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; align-items: end; }
  .filters .field { min-width: 0; }
  .filters .field:has(input[type=search]), .filters > .btn { grid-column: 1 / -1; }
  .filters .field:has(input[type=search]) + .field { grid-column: 1 / -1; }
  .filters .field input, .filters .field select { padding: 12px 10px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .form-actions { position: sticky; bottom: 0; z-index: 4; flex-wrap: wrap; background: white; border-top: 1px solid var(--border); padding: 14px 0 max(12px, env(safe-area-inset-bottom)); margin-top: 12px; }
  .form-actions > .btn { flex: 1 1 120px; min-height: 48px; }
  .check { font-size: 14px; line-height: 1.6; }
  .check input { width: 20px; height: 20px; flex-shrink: 0; }
  .modal, .modal--wide { width: calc(100% - 16px); max-width: 640px; max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin: auto; overflow-y: auto; overscroll-behavior: contain; }
  .modal__head { padding: 12px 16px; }
  .modal__head h2 { font-size: 19px; overflow-wrap: anywhere; }
  .modal__body { padding: 20px 16px 0; }
  .modal__body > :last-child:not(form) { margin-bottom: 20px; }
  .modal__body > form { min-width: 0; }
  .details-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .details-list dt { font-size: 12px; }
  .details-list dd { font-size: 15px; }
  .patient-head { gap: 12px; }
  .patient-head .avatar { width: 44px; height: 44px; flex-shrink: 0; }
  .patient-head h1 { font-size: 24px; }
  .patient-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .patient-summary > div { padding: 14px; }
  .patient-summary small { font-size: 12px; }
  .patient-summary strong { font-size: 15px; }
  .patient-quick > .btn { flex: 1 1 140px; }
  .tabs { max-width: 100%; gap: 20px; padding-bottom: 2px; overscroll-behavior-x: contain; }
  .tabs a, .tabs button { font-size: 14px; }
  .subtabs { flex-wrap: wrap; }
  .subtabs > .btn { flex: 1 1 160px; }
  .record-text, .note-card .record-text { font-size: 15px; line-height: 1.8; }
  .notes-list { padding: 14px; }
  .note-card { padding: 16px; }
  .note-card__head .actions { width: 100%; }
  .note-card__head .actions .btn { flex: 1; }
  .pager { flex-wrap: wrap; font-size: 13px; padding: 16px; }
  .pager .actions { margin-left: auto; }
  .calendar-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .calendar-toolbar > .actions { display: grid; grid-template-columns: 44px minmax(64px, 1fr) 44px; gap: 10px; width: 100%; }
  .calendar-toolbar .field, .calendar-toolbar .segmented { grid-column: 1 / -1; min-width: 0; }
  .calendar-toolbar > .actions:nth-child(2) { grid-template-columns: minmax(0, 1fr); }
  .segmented button { flex: 1; font-size: 14px; }
  .calendar-scroll { max-width: 100%; max-height: 65dvh; overscroll-behavior: contain; }
  .calendar-hint { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
  .calendar td { height: 60px; }
  .calendar .time-label { font-size: 12px; }
  .calendar th { font-size: 12px; }
  .calendar-event { min-height: 48px; padding: 10px; font-size: 13px; overflow-wrap: anywhere; }
  .calendar-event small { font-size: 12px; }
  .slot-button { color: var(--green-dark); min-height: 60px; font-size: 13px; }
  .month-date button { min-width: 44px; min-height: 44px; }
  .chart { padding: 16px; }
  .chart-labels, .chart details { font-size: 12px; }
  .chart details summary { padding-block: 10px; }
  .billing-plan { padding: 20px 16px; }
  .billing-access { padding: 18px 16px; overflow-wrap: anywhere; }
  .billing-access .btn { width: 100%; }
  .billing-methods label { padding: 16px; }
  .auth-story { min-height: 0; padding: max(24px, env(safe-area-inset-top)) 24px 24px; gap: 20px; }
  .auth-story .wordmark { width: 180px; }
  .auth-story h1 { font-size: 25px; margin: 0; }
  .auth-story > a { margin: 0; }
  .auth-story > a:last-child { font-size: 12px; }
  .auth-content { padding: 28px 24px max(32px, env(safe-area-inset-bottom)); }
  .auth-tabs button { flex: 1; }
  .pwa-install { font-size: 14px; padding: 12px; min-height: 56px; }
  .pwa-guide { gap: 16px; font-size: 15px; }
  .pwa-guide .btn { width: 100%; }
  .toast { bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* As mesmas informações e ações da tabela, organizadas em cartões. */
@media (max-width: 640px) {
  .responsive-table, .responsive-table tbody { display: block; width: 100%; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .responsive-table tbody { padding: 14px; }
  .responsive-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr); border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--white); }
  .responsive-table tbody tr + tr { margin-top: 12px; }
  .table-wrap .responsive-table td { display: block; min-width: 0; padding: 9px 0; border: 0; font-size: 14px; overflow-wrap: anywhere; }
  .responsive-table td > .mobile-cell-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--muted); margin-bottom: 5px; }
  .responsive-table td:first-child { padding-top: 0; font-size: 16px; }
  .responsive-table td:first-child .table-link { display: inline-block; padding-block: 5px; }
  .responsive-table td small { font-size: 12px; overflow-wrap: anywhere; }
  .responsive-table td .actions { gap: 10px; }
  .responsive-table td .btn { width: 100%; }
  .responsive-table .badge { font-size: 12px; white-space: normal; }
}

@media (max-width: 360px) {
  .view { padding-inline: 12px; }
  .topbar { padding-inline: 12px; gap: 8px; }
  .metric { padding: 13px 10px; }
  .metric__label svg { display: none; }
  .details-list { grid-template-columns: minmax(0, 1fr); }
  .auth-content { padding-inline: 20px; }
}
