/* Mobile compatibility layer. Loaded last; desktop behavior is intentionally untouched. */
@media (max-width: 768px) {
  html { max-width: 100%; overflow-x: hidden; scrollbar-gutter: auto; }
  body { max-width: 100%; overflow-x: hidden; }
  button, [role="button"], input, select, textarea { touch-action: manipulation; }
  input, select, textarea { max-width: 100%; font-size: 16px; }
  .notification { left: 12px !important; right: 12px !important; top: 68px !important; max-width: none !important; text-align: center; }
  .header-content { min-height: 64px; padding: .75rem 1rem; }
  .dashboard-container { display: block; min-height: 100dvh; padding-top: 64px; }
  .dashboard-sidebar { inset: auto 0 0 0; top: auto; bottom: 0; width: 100%; height: calc(72px + env(safe-area-inset-bottom)); padding: 5px 6px max(5px, env(safe-area-inset-bottom)); display: flex; align-items: stretch; overflow: visible; border: 0; box-shadow: 0 -4px 20px rgba(26,35,50,.2); z-index: 1200; }
  .dashboard-sidebar .sidebar-user { display: none; }
  .dashboard-sidebar .sidebar-nav { flex: 1 1 auto; min-width: 0; height: 100%; flex-direction: row; gap: 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity; }
  .dashboard-sidebar .sidebar-nav::-webkit-scrollbar { display: none; }
  .dashboard-sidebar .sidebar-nav-item { flex: 0 0 66px; min-width: 66px; min-height: 60px; padding: 5px 3px; flex-direction: column; justify-content: center; gap: 3px; border-radius: 10px; line-height: 1.05; text-align: center; scroll-snap-align: center; }
  .dashboard-sidebar .sidebar-nav-item > span:not(#requestsBadge) { display: block; max-width: 62px; font-size: .58rem; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: normal; }
  .dashboard-sidebar .sidebar-nav-icon { width: 21px; height: 21px; padding: 0; }
  .dashboard-sidebar #requestsBadge { top: 2px; right: 8px; }
  .dashboard-sidebar .sidebar-logout { flex: 0 0 auto; margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 2px; }
  .dashboard-sidebar .btn-subscribe, .dashboard-sidebar .btn-logout { width: 44px; min-width: 44px; height: 60px; min-height: 44px; margin: 0 !important; padding: 0 !important; border-radius: 10px; }
  .dashboard-sidebar .btn-subscribe span, .dashboard-sidebar .btn-logout span { display: none; }
  .rail-tooltip { display: none !important; }
  .dashboard-main { width: 100%; margin-left: 0; padding: 1.25rem .85rem calc(94px + env(safe-area-inset-bottom)); }
  .dashboard-header { margin-bottom: 1.25rem; }
  .dashboard-title { font-size: clamp(1.75rem, 8vw, 2.2rem); overflow-wrap: anywhere; }
  .dashboard-subtitle { font-size: 1rem; line-height: 1.45; }
  .dashboard-section { min-width: 0; padding: 1.1rem; margin-bottom: 1rem; border-width: 2px; }
  .section-header { align-items: stretch; gap: .75rem; margin-bottom: 1.25rem; }
  .section-header > button, .section-header > a { align-self: flex-start; min-height: 44px; }
  .cards-grid, #searchResults.cards-grid, .queue-sittings-grid, .family-grid, .hv-file-grid, .medical-history-grid { grid-template-columns: minmax(0, 1fr); }
  .card-actions, .family-card-actions, .form-actions { flex-wrap: wrap; }
  .card-actions > *, .family-card-actions > * { min-height: 44px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-height: 92dvh; border-width: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px rgba(26,35,50,.25); }
  .modal-header, .modal-body, .modal-footer { padding: 1rem; }
  .modal-close { width: 44px; height: 44px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer > * { flex: 1 1 130px; min-height: 44px; }
  /* Patient search stays visible without covering the result list. */
  #searchView .dashboard-section { overflow: visible; }
  #searchView .search-dock { position: sticky; inset: auto; top: 64px; z-index: 80; width: auto; max-width: none; margin: 0 -.35rem 1rem; padding: .5rem; flex-direction: column; gap: .45rem; border-radius: 18px; background: rgba(255,248,240,.94); box-shadow: 0 8px 24px rgba(26,35,50,.12); backdrop-filter: blur(16px); }
  #searchView .search-dock .search-bar { order: 1; width: 100%; margin: 0; padding: .35rem; flex-direction: row; flex-wrap: nowrap; align-items: center; border-radius: 14px; }
  #searchView .search-input { flex: 1 1 auto; min-width: 0; min-height: 44px; }
  #searchView .search-select { width: 100%; min-height: 44px; }
  #searchView .btn-search { flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; }
  #searchView .search-dock .emg-trigger { order: 2; width: 100%; max-width: none; min-height: 54px; margin: 0; padding: .45rem .75rem; gap: .55rem; transform: none; border-radius: 14px; }
  #searchView .search-dock .emg-trigger:hover { transform: none; }
  #searchView .search-dock .emg-trigger-icon { width: 36px; height: 36px; }
  #searchView .search-dock .emg-icon-3d { width: 42px; height: 42px; }
  #searchView .search-dock .emg-trigger-text strong { font-size: .9rem; }
  #searchView .search-dock .emg-trigger-text span { font-size: .72rem; }
  #searchResults.cards-grid { padding-top: 2.5rem; padding-bottom: 1rem; }
  .search-suggest { position: fixed; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); max-height: min(45dvh, 320px); }
  .appt-table-wrap, #queueList, .admin-table-container, .clinic-appointments-table, .ph-card:has(.ph-table), .hv-doc-panel:has(.hv-vitals-table), .vc-card:has(.vc-vitals-table) { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .appt-table, .queue-list-table, .admin-table-container .data-table, .ph-table, .hv-vitals-table, .vc-vitals-table { min-width: 620px; }
  .queue-control-panel, .patient-queue-display, .patient-position-card { padding: 1.15rem; border-radius: 18px; }
  .queue-header, .queue-start-head { flex-direction: column; align-items: stretch; gap: 1rem; }
  .queue-header-actions { display: grid; grid-template-columns: 1fr; gap: .65rem; }
  .queue-header-actions .btn-action { width: 100%; min-height: 44px; justify-content: center; }
  .queue-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .queue-stats .stat-item { min-width: 0; padding: 1rem .5rem; }
  .queue-stats .stat-value { font-size: 1.8rem; }
  .queue-actions { grid-template-columns: 1fr; }
  .btn-queue { min-height: 52px; padding: .9rem 1rem; }
  .current-patient-card { padding: 1.25rem; }
  .current-patient-name { font-size: 1.7rem; overflow-wrap: anywhere; }
  .patient-queue-info { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .patient-queue-info-item { min-width: 0; padding: 1rem .5rem; }
  .queue-dial-btn { width: 170px; height: 170px; }
  .call-settings-row, .call-lang-picker { max-width: 100%; }
  .call-lang-menu { width: min(240px, calc(100vw - 32px)); }
  .queue-date-input { width: 100%; max-width: none; }
  .time-inline, .range-row, .day-time-row, .exception-adder { align-items: stretch; }
  .time-inline input, .range-row input, .range-row select, .day-time-row input, .exception-adder input { min-height: 44px; }
  .rule-row, .vacation-item { align-items: flex-start; flex-wrap: wrap; }
  .rule-row > span, .vacation-item > span { flex: 1 1 180px; overflow-wrap: anywhere; }
  .rule-row > button, .vacation-item > button { min-height: 44px; }
  .clinic-bar, .physical-context-controls, .vcs-time-row { width: 100%; }
  .clinic-bar select, .physical-context-controls select { min-width: 0; max-width: 100%; }
  .vcs-head, .emg-head { align-items: flex-start; flex-wrap: wrap; }
  .vcs-head-text, .emg-head-text { flex-basis: calc(100% - 66px); }
  .vcs-switch, .emg-switch { margin-left: auto; }
  .instant-avail-card { padding: 1rem; }
  .instant-avail-body { min-width: 0; width: 100%; }
  .instant-avail-fee { width: 100%; flex-wrap: wrap; }
  .emg-time-row { flex-wrap: wrap; }
  .emg-time-field { flex: 1 1 130px; }
  .emg-time-field input { width: 100%; }
  .emg-flow { min-height: 100dvh; }
  .emg-flow-top { padding-top: max(.75rem, env(safe-area-inset-top)); }
  .emg-flow-body { padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
  .emg-doc-card { align-items: flex-start; flex-wrap: wrap; }
  .emg-doc-info { flex: 1 1 calc(100% - 72px); }
  .emg-doc-req { width: 100%; min-height: 44px; }
  .emg-queue-panel { position: fixed; top: 64px; left: 12px; right: 12px; width: auto; max-height: calc(100dvh - 84px); overflow-y: auto; }
  .profile-switcher { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .75rem; scrollbar-width: none; }
  .profile-switcher::-webkit-scrollbar { display: none; }
  .profile-pill { flex: 0 0 auto; min-height: 44px; }
  .hv-connect-card { padding: 1rem; }
  #vaultView .hv-upload-row { align-items: stretch; flex-direction: column; }
  #vaultView .hv-upload-row .btn-action, .hv-folder-btn { width: 100%; min-height: 44px; justify-content: center; }
  .hv-vital-add { grid-template-columns: 1fr 1fr; }
  .hv-vital-add > * { min-width: 0; }
  .profile-header-card { padding: 1.1rem; }
  .profile-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
  .profile-stat { min-width: 0; padding: .7rem .35rem; }
  .profile-stat-number { font-size: 1.35rem; }
  .profile-stat-label { font-size: .65rem; overflow-wrap: anywhere; }
  #profileView .dashboard-section { padding: 1rem; }
  .emergency-contact-card { padding: 1rem; }
  .pp-overlay { padding: 0; align-items: flex-end; }
  .pp-modal { max-height: 94dvh; overflow-y: auto; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .pp-head, .pp-body { padding: 1rem; }
  .pp-steps { overflow-x: auto; padding-bottom: .25rem; }
  .pp-step { flex: 0 0 auto; }
  .pp-rx-item, .pp-clinic-head, .pp-myorder-head { align-items: flex-start; flex-wrap: wrap; }
  .pp-actions, .ph-order-actions { flex-wrap: wrap; }
  .pp-actions > *, .ph-order-actions > * { min-height: 44px; }
  .ph-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ph-tabs::-webkit-scrollbar { display: none; }
  .ph-tab { flex: 0 0 auto; min-height: 44px; }
  .ph-form-grid { grid-template-columns: 1fr 1fr; }
  .ph-field-name, .ph-field-submit { grid-column: 1 / -1; }
  .ph-profit-grid { grid-template-columns: 1fr 1fr; }
  .family-card-actions { flex-direction: column; }
  #familyModal .form-row { grid-template-columns: 1fr; }
  /* Clinic keeps its existing bottom rail; restore subscription as a header action. */
  body .clinic-sidebar .clinic-sidebar-footer .btn-subscribe { display: flex !important; position: fixed; top: 10px; right: 60px; z-index: 204; width: 40px; height: 40px; min-height: 40px; margin: 0 !important; padding: 0 !important; align-items: center; justify-content: center; border-radius: 50%; font-size: 0 !important; box-shadow: 0 2px 10px rgba(23,32,51,.12); }
  body .clinic-sidebar .clinic-sidebar-footer .btn-subscribe::before { content: "★"; font-size: 18px; line-height: 1; }
  .clinic-view-header, .clinic-filter-group { flex-wrap: wrap; }
  .clinic-filter-group, .clinic-filter-group select { width: 100%; }
  .cqb-head, .cqb-actions, .appointment-card { min-width: 0; flex-wrap: wrap; }
  /* Admin navigation becomes a horizontally scrollable phone rail. */
  .admin-sidebar { position: fixed; inset: auto 0 0; width: 100%; height: calc(72px + env(safe-area-inset-bottom)); padding: 5px 6px max(5px, env(safe-area-inset-bottom)); flex-direction: row; overflow: visible; border: 0; box-shadow: 0 -4px 20px rgba(26,35,50,.2); z-index: 1200; }
  .admin-sidebar-header { position: fixed; top: 0; left: 0; z-index: 202; padding: 15px 16px; border: 0; }
  .admin-logo-icon { width: 28px; height: 28px; }
  .admin-logo-text { font-size: 1.15rem; }
  .admin-sidebar-nav { flex: 1; min-width: 0; height: 100%; padding: 0; flex-direction: row; gap: 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity; }
  .admin-sidebar-nav::-webkit-scrollbar { display: none; }
  .admin-nav-item { flex: 0 0 68px; min-width: 68px; min-height: 60px; padding: 5px 3px; flex-direction: column; justify-content: center; gap: 3px; border: 0; border-radius: 10px; font-size: .59rem; line-height: 1.05; text-align: center; scroll-snap-align: center; }
  .admin-nav-item:hover { transform: none; }
  .admin-nav-icon { width: 21px; height: 21px; }
  .admin-sidebar-footer { position: static; flex: 0 0 46px; padding: 0; border: 0; }
  .admin-user-info { display: none; }
  .admin-btn-logout { position: fixed; top: 10px; right: 12px; z-index: 203; width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 0; background: #fff; color: var(--color-navy); }
  .admin-main-content { width: 100%; margin: 0; padding: 82px .85rem calc(94px + env(safe-area-inset-bottom)); }
  .admin-view-header { gap: 1rem; margin-bottom: 1.5rem; }
  .admin-view-header > div { min-width: 0; max-width: 100%; }
  .admin-view-title { font-size: 1.85rem; overflow-wrap: anywhere; }
  .admin-filter-group { flex-direction: column; gap: .5rem; }
  .admin-stats-grid, .admin-content-grid, .admin-analytics-grid { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .admin-content-card, .admin-table-container { min-width: 0; }
  .admin-card-header, .admin-card-body, .admin-analytics-card { padding: 1rem; }
  .admin-table-container { overflow-x: auto; }
  .admin-table-container > div, #articleReviewList, #articleReviewDetail, #agentDetailBody { min-width: 0; overflow-x: auto; }
  #articleReviewView .admin-view-header > div:last-child { width: 100%; flex-wrap: wrap; }
  #articleReviewView .admin-view-header button { flex: 1 1 120px; min-height: 44px; }
  /* Agent and subscription pages. */
  .agent-main { padding: 5.5rem 1rem 3rem; }
  .panel, .profile-card { width: 100%; max-width: 100%; margin: 1rem auto; padding: 1.35rem; box-shadow: 5px 5px 0 var(--color-navy); }
  .auth-actions { flex-wrap: wrap; }
  .auth-actions .btn { flex: 1 1 150px; min-height: 44px; }
  .dash-hero { gap: 1rem; }
  .referral-card { width: 100%; min-width: 0; }
  .referral-code { overflow-wrap: anywhere; }
  .tabbar { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
  .tabbar .tab, .tabbar .etab { flex: 0 0 auto; min-height: 44px; }
  .tree-container { padding: 1rem; }

  /* Subscription keeps its desktop rail untouched and becomes a phone rail here. */
  body.agent-body { padding-left: 0 !important; }
  .subscribe-rail { position: fixed !important; inset: auto 0 0 !important; width: 100% !important; height: calc(72px + env(safe-area-inset-bottom)) !important; padding: 5px 6px max(5px, env(safe-area-inset-bottom)) !important; overflow: visible !important; }
  .subscribe-rail .sidebar-nav-item { padding: 5px 3px !important; gap: 3px !important; }
  .subscribe-rail .sidebar-nav-item > span { display: block; }
  .subscribe-rail ~ .agent-main { padding-bottom: calc(98px + env(safe-area-inset-bottom)); }
  .subscribe-rail ~ .footer { margin-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .plans { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .plan-card { min-width: 0; padding: 1.15rem; }
  .plan-price { font-size: 1.9rem; overflow-wrap: anywhere; }
  .mode-row { flex-direction: column; }
  .mode-card { width: 100%; }

  /* Live consultation: scroll the two work areas instead of locking the viewport. */
  .vc-body { width: 100%; height: auto; min-height: 100dvh; overflow-x: hidden; overflow-y: auto; }
  .vc-console, .vc-console.solo { width: 100%; height: auto; min-height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; overflow: visible; }
  .vc-stage { min-width: 0; min-height: 56dvh; overflow: hidden; }
  .vc-console.solo .vc-stage { min-height: 100dvh; }
  .vc-workspace { width: 100%; height: auto; min-height: 100dvh; overflow: visible; }
  .vc-ws-scroll { flex: 0 1 auto; overflow: visible; padding: 16px 12px 8px; }
  .vc-ws-footer { position: sticky; bottom: 0; z-index: 25; padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .vc-ctxbar { gap: 8px; padding: max(12px, env(safe-area-inset-top)) 12px; flex-wrap: wrap; }
  .vc-live { font-size: .72rem; }
  .vc-ctx-name { max-width: 100%; font-size: .86rem; overflow-wrap: anywhere; }
  #vcLocal { left: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); width: 96px; height: 68px; }
  .vc-local-tag { left: 17px; bottom: calc(83px + env(safe-area-inset-bottom)); }
  .vc-controls { padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); gap: 8px; }
  .vc-cluster { gap: 7px; }
  .vc-ctrl { width: 46px; height: 46px; flex: 0 0 46px; }
  .vc-end { height: 46px; padding: 0 15px; }
  .vc-banner { top: 82px; width: calc(100% - 24px); text-align: center; white-space: normal; }
  .vc-patient-note { bottom: calc(82px + env(safe-area-inset-bottom)); width: calc(100% - 150px); text-align: center; }
  .vc-overlay { min-height: 100%; padding: 20px 14px; }
  .vc-overlay-actions { width: 100%; flex-wrap: wrap; justify-content: center; }
  .vc-overlay-actions > * { flex: 1 1 130px; min-height: 44px; }
  .vc-card-head, .rx-head, .rx-tools, .vault-item, .med { min-width: 0; }
  .rx-head { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .rx-tools { width: 100%; flex-wrap: wrap; }
  .rx-tools .tool-btn { flex: 1 1 120px; min-height: 44px; justify-content: center; }
  .vault-item, .med { align-items: flex-start; flex-wrap: wrap; }
  .vault-view { margin-left: 45px; min-height: 40px; display: inline-flex; align-items: center; }
  .med-del { margin-left: auto; min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
  .quick > * { flex: 1 1 140px; min-height: 44px; justify-content: center; }
  .pop { left: 12px !important; right: 12px !important; top: auto !important; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .menu { left: 0; right: 0; width: auto; max-width: calc(100vw - 24px); }
  .suggests { left: 0; right: 0; width: auto; max-height: min(42dvh, 280px); }
  .vc-end-overlay, .vc-save-overlay { align-items: flex-end; padding: 0; }
  .vc-sheet, .vc-save-card { width: 100%; max-width: none; max-height: 94dvh; border-radius: 18px 18px 0 0; }
  .vc-sheet-head, .vc-sheet-body, .vc-sheet-foot, .vc-save-card { padding-left: 16px; padding-right: 16px; }
  .vc-sheet-foot, .intake-photo-actions, .vc-save-actions { flex-wrap: wrap; }
  .intake-photo-actions > *, .vc-save-actions > * { flex: 1 1 140px; min-height: 44px; justify-content: center; }
  .vc-toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; transform: translateY(20px); justify-content: center; }
  .vc-toast.show { transform: translateY(0); }

  /* Waiting-room queue display becomes a vertically scrollable phone board. */
  html:has(.qd-wrap), body:has(.qd-wrap) { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  .qd-wrap { height: auto; min-height: 100dvh; padding: max(14px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom)); gap: 14px; }
  .qd-header { align-items: flex-start; gap: 10px; padding-bottom: 12px; }
  .qd-brand { min-width: 0; flex-wrap: wrap; gap: 7px; }
  .qd-brand img { width: 30px; height: 30px; }
  .qd-scope { flex-basis: 100%; overflow-wrap: anywhere; }
  .qd-clock { flex: 0 0 auto; font-size: 1rem; }
  .qd-stage, .qd-mode-split { flex: 0 0 auto; width: 100%; min-height: 0; flex-direction: column; gap: 12px; }
  .qd-spotlight { flex: none; width: 100%; min-height: 48dvh; padding: 28px 14px; border-radius: 18px; }
  .qd-now-label { font-size: .9rem; letter-spacing: 3px; }
  .qd-hero-token { font-size: clamp(72px, 30vw, 130px); }
  .qd-hero-meta { gap: 6px; font-size: clamp(18px, 6vw, 28px); }
  .qd-hero-next { font-size: 1rem; line-height: 1.45; }
  .qd-rail { flex: none; width: 100%; overflow: visible; gap: 10px; }
  .qd-room-row { flex: none; min-height: 96px; padding: 14px; gap: 10px; }
  .qd-room-name { font-size: 1.05rem; }
  .qd-room-doctor { font-size: .8rem; }
  .qd-room-tokens { gap: 14px; }
  .qd-mini-token { font-size: 2rem; }
  .qd-mini-next { font-size: 1.35rem; }
  .qd-mode-grid .qd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(150px, auto); gap: 10px; }
  .qd-cell { min-width: 0; padding: 14px 8px; }
  .qd-cell-token { font-size: clamp(42px, 14vw, 64px); }
  .qd-cell-room, .qd-cell-doctor { max-width: 100%; overflow-wrap: anywhere; text-align: center; }
  .qd-empty { position: fixed; padding: 24px; }
  .qd-reconnect { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); transform: none; text-align: center; }

  /* Authentication, legal pages, homepage footer, and pre-call safeguards. */
  body:has(.signin-card) { min-height: 100dvh; align-items: flex-start; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .signin-card { max-width: 34rem; margin: auto; border-radius: 14px; }
  .signin-right { min-width: 0; padding: 1.35rem 1.1rem; }
  .signin-form { gap: 1rem; }
  .field-input, .btn-google, .btn-submit { min-height: 44px; font-size: 16px; }
  .auth-main { padding: 5.5rem 12px 2rem; }
  .auth-container { width: 100%; max-width: 36rem; }
  .auth-card { width: 100%; min-width: 0; padding: 1.25rem; }
  .auth-title { font-size: clamp(1.8rem, 9vw, 2.5rem); }
  .auth-form .form-row { grid-template-columns: minmax(0, 1fr); }
  .radio-group { flex-wrap: wrap; }
  .legal { width: 100%; margin-top: 5.5rem; padding: 0 1rem; overflow-wrap: anywhere; }
  .legal h1 { font-size: clamp(2rem, 11vw, 3.2rem); }
  .legal .intro { padding-left: .9rem; font-size: 1.05rem; }
  .legal-nav { min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
  .footer-content, .footer-main, .footer-bottom, .footer-links { min-width: 0; flex-wrap: wrap; }
  .footer-bottom > *, .footer-links a { overflow-wrap: anywhere; }
  .footer-home .footer-cta { align-items: flex-start; }
  .pc-body { min-height: 100dvh; }
  .pc-wrap { width: 100%; max-width: 640px; padding: max(16px, env(safe-area-inset-top)) 12px max(32px, env(safe-area-inset-bottom)); }
  .pc-card { width: 100%; min-width: 0; }
  .pc-head, .pc-body-pad { padding-left: 16px; padding-right: 16px; }
  .pc-appt, .pc-status { align-items: flex-start; }
  .pc-appt-meta, .pc-status-txt { min-width: 0; overflow-wrap: anywhere; }
  .pc-actions { flex-wrap: wrap; }
  .pc-actions > * { flex: 1 1 130px; min-height: 48px; }
  .pc-toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); text-align: center; transform: translateY(20px); }
  .pc-toast.show { transform: translateY(0); }
}

@media (max-width: 430px) {
  .dashboard-main, .admin-main-content { padding-left: .65rem; padding-right: .65rem; }
  .dashboard-section, .queue-control-panel, .patient-queue-display, .patient-position-card { padding: .9rem; }
  .queue-stats, .patient-queue-info, .hv-vital-add, .ph-form-grid, .ph-profit-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-stats { grid-template-columns: minmax(0, 1fr); }
  .profile-stat { display: flex; align-items: center; justify-content: space-between; gap: .75rem; text-align: left; }
  .profile-stat-label { font-size: .75rem; }
  .queue-dial-btn { width: 148px; height: 148px; }
  .time-inline, .range-row, .day-time-row, .exception-adder, .vcs-time-row, .emg-time-row { flex-direction: column; }
  .time-inline > *, .range-row > *, .day-time-row > *, .exception-adder > *, .vcs-time-row > *, .emg-time-row > * { width: 100%; max-width: none; }
  .emg-flow-body { padding-left: .75rem; padding-right: .75rem; }
  .emg-doc-card { padding: .85rem; }
  .modal-footer, .vc-sheet-foot, .intake-photo-actions, .vc-save-actions { flex-direction: column; }
  .modal-footer > *, .vc-sheet-foot > *, .intake-photo-actions > *, .vc-save-actions > * { width: 100%; flex: 0 0 auto; }
  .plans { grid-template-columns: minmax(0, 1fr); }
  .mode-row { flex-direction: column; }
  .plan-card { padding: 1rem; }
  .vc-card-body { padding-left: 10px; padding-right: 10px; }
  .vit-grid { grid-template-columns: minmax(0, 1fr); }
  .vault-view { width: 100%; margin-left: 0; justify-content: center; }
  .med { padding: 9px; }
  .qd-mode-grid .qd-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(145px, auto); }
  .qd-spotlight { min-height: 44dvh; }
  .qd-room-row { align-items: flex-start; flex-direction: column; }
  .qd-room-tokens { width: 100%; justify-content: space-between; }
  .pc-appt, .pc-status { padding: 13px; gap: 10px; }
  .pc-head, .pc-body-pad { padding-left: 13px; padding-right: 13px; }
  .footer-home .footer-cta-button { width: 100%; justify-content: center; }
}

@media (max-width: 360px) {
  .vc-controls { gap: 6px; }
  .vc-cluster { gap: 5px; }
  .vc-ctrl { width: 43px; height: 43px; flex-basis: 43px; }
  .vc-end { width: 46px; height: 43px; padding: 0; justify-content: center; }
  .vc-end #endLabel { display: none; }
  .dashboard-sidebar .sidebar-nav-item, .admin-nav-item { flex-basis: 62px; min-width: 62px; }
}