/* New mobile controls are inert on desktop; layout overrides stay scoped. */
.mobile-only { display: none; }
.mobile-more-sheet:not([open]) { display: none; }
@media (min-width: 761px) { .mobile-only { display: none !important; } }
@media (max-width: 760px) {
  .mobile-only { display: flex; }
  .mobile-only[hidden] { display: none !important; }
  html { scroll-padding-top: 72px; scroll-padding-bottom: 90px; }
  body { background: #101827; }
  #app { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .mobile-shell-ready #app > .tabs { display: none; }
  .topbar { position: sticky; top: 0; z-index: 100; }
  .mobile-page-heading { margin: 0; padding: 20px 16px 12px; font-size: 27px; letter-spacing: -.7px; color: #f8fafc; }
  #app > .view { padding: 0 12px 20px; }
  #app > .view > div[style*="padding:16px 20px"] { padding: 12px 0 !important; }
  .mobile-bottom-nav { position: fixed; z-index: 150000; bottom: calc(10px + env(safe-area-inset-bottom)); left: 12px; right: 12px; gap: 4px; padding: 7px; background: #192235; border: 1px solid #37445b; border-radius: 24px; box-shadow: 0 8px 28px #0006; }
  .mobile-nav-item { flex: 1; min-width: 0; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 0; border-radius: 17px; background: transparent; color: #aab8cb; font: 600 10px var(--font-body); cursor: pointer; }
  .mobile-nav-item svg { width: 22px; height: 22px; }
  .mobile-nav-item[aria-current="page"] { background: #353168; color: #c8bfff; }
  .mobile-more-sheet { position: fixed; inset: auto 12px calc(16px + env(safe-area-inset-bottom)); margin: 0 auto; width: calc(100% - 24px); max-width: 520px; max-height: 80dvh; overflow: auto; padding: 16px; border: 1px solid #46516b; border-radius: 24px; color: var(--text); background: #192235; }
  .mobile-more-sheet[open] { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
  .mobile-more-sheet::backdrop { background: #020617bb; }
  .mobile-more-sheet .mobile-nav-item { min-height: 84px; font-size: 13px; background: #253047; }
  .mobile-sheet-close { grid-column: 1/-1; justify-self: end; min-height: 44px; padding: 8px 16px; background: #303c53; color: #fff; border: 0; border-radius: 12px; }
  .mobile-filter-toggle, .mobile-columns-toggle, .mobile-task-details { min-height: 44px; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--border); border-radius: 12px; background: #253147; color: #c7d2fe; cursor: pointer; }
  #boardFilterBar { border: 0; border-radius: 16px; background: transparent; padding: 0; }
  #boardFilterBar .srch { order: -1; margin: 0 !important; width: 100%; border-radius: 16px; min-height: 48px; }
  #boardFilterBar:not(.mobile-filters-open) > .fsel { display: none; }
  #boardFilterBar > #btnNew { flex: 1; }
  #boardFilterBar .mobile-filter-toggle { flex: 1; }
  #dashGrid { gap: 10px; padding: 16px 0; }
  #dashGrid .dash-card { min-width: 0; min-height: 92px; padding: 15px; border-radius: 18px; background: #1c273a; }
  #dashGrid .dash-label { font-size: 11px; }
  #dashGrid .dash-val { font-size: 28px; }
  #boardWrap { padding: 0 !important; }
  .group-hdr { flex-wrap: wrap; padding: 12px; gap: 8px; }
  .g-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .g-meta { flex-basis: 100%; flex-wrap: wrap; order: 5; }
  .g-meta button { min-height: 36px; }
  .group-hdr > .seg-bar { display: none; }
  .g-body-inner > .mobile-columns-toggle { margin: 8px; min-height: 36px; font-size: 11px; }
  .g-body-inner:not(.mobile-columns-open) > .col-hdr { display: none; }
  .g-body-inner .trow.mobile-card-ready { grid-template-columns: 34px minmax(0,1fr) !important; border-radius: 14px; margin: 8px 0; background: #172235; }
  .g-body-inner .mobile-card-ready > .td:first-child { grid-column: 1; grid-row: 1; padding: 8px; }
  .g-body-inner .trow.mobile-card-ready > .td:nth-child(2) { grid-column: 2; grid-row: 1; padding: 14px 10px; }
  .g-body-inner .mobile-card-ready > .td:nth-child(n+3) { grid-column: 1/-1; }
  .g-body-inner .mobile-card-ready:not(.mobile-task-expanded) > .td:nth-child(n+3):not([data-mobile-field="status"]):not([data-mobile-field="date"]) { display: none; }
  .g-body-inner .mobile-card-ready > .td[data-mobile-field="status"], .g-body-inner .mobile-card-ready > .td[data-mobile-field="date"] { padding: 8px 12px !important; }
  .g-body-inner .mobile-card-ready .tname { font-size: 15px; line-height: 1.5; }
  .mobile-task-details { grid-column: 1/-1; background: transparent; border: 0; border-radius: 0; font-size: 12px; }
  .g-body-inner > .sum-row { display: none; }
  #toolsShell { padding: 0; }
  #toolsShell .tools-layout { grid-template-columns: 52px minmax(0,1fr); gap: 8px; position: relative; }
  #toolsNav { position: sticky; top: 64px; max-height: calc(100dvh - 158px); padding: 4px; gap: 6px; border-radius: 16px; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none; }
  #toolsNav::-webkit-scrollbar { display: none; }
  #toolsNav button[data-tool] { width: 44px; min-height: 44px; padding: 5px; display: flex; align-items: center; justify-content: center; }
  #toolsNav button[data-tool] > span { flex: 0 0 32px; }
  #toolsNav button[data-tool] > b, #toolsNav button[data-tool] > em { display: none; }
  #toolsNav .mobile-tools-expand { min-height: 44px; width: 44px; padding: 3px; display: flex; align-items: center; justify-content: center; color: #b7c8e0; font-size: 9px; }
  #toolsNav .mobile-tools-expand > span { background: transparent; font-size: 9px; width: auto; }
  #toolsShell .mobile-tools-expanded #toolsNav { width: min(290px, calc(100vw - 30px)); z-index: 105; box-shadow: 12px 8px 36px #0009; }
  #toolsShell .mobile-tools-expanded #toolsNav button[data-tool] { width: 100%; justify-content: flex-start; gap: 12px; }
  #toolsShell .mobile-tools-expanded #toolsNav button[data-tool] > b { display: block; font-size: 12px; }
  #toolsWorkspace { min-width: 0; }
  #toolsWorkspace .tool-panel { padding: 14px 10px; border-radius: 16px; }
  #toolsWorkspace .tool-panel-head { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  #toolsWorkspace h2 { font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
  #toolsWorkspace .tool-grid, #toolsWorkspace .compliance-layout, #toolsWorkspace .bmi-dashboard { grid-template-columns: minmax(0,1fr); }
  #toolsWorkspace .tool-subcard, #toolsWorkspace .bmi-dashboard { padding: 10px; }
  #toolsWorkspace .tool-clear-btn { min-height: 36px; }
  #toolsWorkspace input:not([type="checkbox"]):not([type="radio"]), #toolsWorkspace select { width: 100%; min-width: 0; }
  .restored-shell { padding: 8px 0; }
  .timer-floating { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .weekly-col { min-height: 120px; }
  .study-list-card { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; padding: 16px; }
  .study-list-main, .study-list-actions { grid-column: 1/-1; min-width: 0; }
  .study-card-mark { display: none; }
  .study-list-actions { flex-wrap: wrap; }
  .study-stat span { font-size: 9px; }
  .view, .restored-shell, .studies-page { min-width: 0; }
  .toolbar { padding: 12px; gap: 8px; }
  .toolbar > .fsel, .toolbar > .srch { flex: 1 1 140px; min-width: 0; max-width: 100%; }
  .toolbar > .srch { flex-basis: 100%; }
  .topbar-right .settings-btn:not([style*="display: none"]):not([style*="display:none"]) { display: inline-flex !important; margin-right: 0 !important; align-items: center; justify-content: center; }
  .topbar-right button { min-width: 44px; min-height: 44px; }
  .entity-chip { overflow: hidden; }
  .entity-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabs { scroll-padding: 12px; }
  .tab { min-height: 44px; }
  .btn-p, .btn-t, .m-nav-btn, .fs, .fi, .fsel, .srch { min-height: 44px; }
  input, select, textarea, .fi, .fs, .fta, .fsel, .srch { font-size: 16px; max-width: 100%; }
  .screen { overflow-y: auto; padding: 16px 0; }
  .auth-box { margin: auto; padding: 28px 22px; flex-shrink: 0; }
  .overlay { padding: 8px; }
  .modal { padding: 18px; max-width: 100% !important; max-height: calc(100dvh - 16px); }
  .study-modal { padding: 0; width: 100%; max-height: calc(100dvh - 16px); }
  .study-modal form, .study-modal-head { padding: 16px; }
  .f2, .f3, .study-form-grid, .signature-form-list > div { grid-template-columns: minmax(0, 1fr); }
  .fg, .study-form-field { min-width: 0; }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  #boardWrap { padding: 12px !important; }
  .g-body-inner { width: 100%; min-width: 0; }
  .g-body-inner > .col-hdr { display: flex; overflow-x: auto; }
  .g-body-inner > .col-hdr > .ch { flex: 0 0 auto; min-width: 72px; min-height: 44px; }
  .col-resize-handle { display: none; }
  .g-body-inner .trow { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; margin: 10px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
  .g-body-inner .trow > .td { min-width: 0; min-height: 48px; flex-wrap: wrap; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); }
  .g-body-inner .trow > .td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .g-body-inner .tname { white-space: normal; overflow-wrap: anywhere; }
  .g-body-inner .td[data-mobile-label]::before { content: attr(data-mobile-label); display: block; width: 100%; color: var(--text-muted); font-size: 11px; font-weight: 600; }
  .g-body-inner .sum-row { display: flex; flex-wrap: wrap; gap: 8px; }
  .month-hdr, .weekly-visits-heading, .study-head-actions, .study-workspace-actions, .study-row-actions { flex-wrap: wrap; gap: 10px; }
  .m-nav { width: 100%; justify-content: space-between; gap: 8px; }
  .m-title { min-width: 0; flex: 1; font-size: 16px; text-align: center; overflow-wrap: anywhere; }
  .m-nav-btn { flex-shrink: 0; padding: 7px 10px; }
  .weekly-grid, .subject-visit-week { grid-template-columns: minmax(0, 1fr); }
  #schedGrid.visit-planner { overflow: visible; }
  #schedGrid .sched-cal-grid { grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 10px; }
  #schedGrid .sched-cal-head { display: none; }
  #schedGrid .sched-cal-cell { min-height: 84px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
  #schedGrid .sched-cal-cell::before { content: attr(data-mobile-date); display: block; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; }
  #schedGrid .sched-chip { white-space: normal; min-height: 44px; padding: 10px; }
  .sched-day-add { opacity: 1; min-width: 44px; min-height: 44px; }
  .sched-list-item { flex-wrap: wrap; }
  .studies-page { padding: 18px 12px 32px; }
  .study-home-tabs, .study-workspace-tabs, .lab-subtabs { max-width: 100%; overflow-x: auto; }
  .study-home-tabs button, .study-workspace-tabs button, .lab-subtabs button { flex-shrink: 0; min-height: 44px; }
  .study-table-wrap, .vp-table-scroll { max-width: 100%; overscroll-behavior-x: contain; }
  .study-table td, .study-table th { padding: 12px; }
  .study-table button { min-height: 44px; }
  .study-list-card .study-stat { display: block; text-align: left; border-left: 0; }
  .study-list-actions, .study-modal-actions { flex-wrap: wrap; }
  .study-modal-actions button { flex: 1; min-height: 44px; }
  .notif-panel { width: min(380px, calc(100vw - 16px)); right: 8px; max-height: calc(100dvh - 72px); }
}
