/* Empire mobile operating system
   Phone layouts are intentionally composed rather than scaled desktop canvases. */

@media (max-width: 720px) {
  :root {
    --mobile-edge: 10px;
    --mobile-nav-height: 68px;
    --mobile-touch: 44px;
  }

  html,
  body {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body.app-active {
    min-height: 100dvh;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }

  button,
  a,
  input,
  select,
  textarea,
  summary {
    touch-action: manipulation;
  }

  .app-shell,
  .main,
  .view,
  .workspace-page {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .app-shell {
    display: block !important;
  }

  .main {
    display: block !important;
  }

  /* Compact two-row application header */
  .topbar {
    position: sticky !important;
    z-index: 500 !important;
    top: 0;
    margin: 0 !important;
    min-height: 108px !important;
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr) auto !important;
    grid-template-areas:
      "brand heading actions"
      "search search search" !important;
    align-items: center !important;
    gap: 6px 8px !important;
    width: 100% !important;
    padding: 7px var(--mobile-edge) 9px !important;
    border-top-width: 3px !important;
    background: rgba(255, 255, 255, .98) !important;
    box-shadow: 0 4px 14px rgba(8, 38, 61, .12) !important;
  }

  .topbar-brand {
    grid-area: brand;
    width: 52px !important;
    min-width: 0 !important;
  }

  .topbar-brand img {
    width: 52px !important;
    height: 36px !important;
    object-fit: contain;
  }

  .page-heading {
    grid-area: heading;
    min-width: 0 !important;
  }

  .page-heading p {
    margin-bottom: 1px !important;
    font-size: 8px !important;
    line-height: 1 !important;
  }

  .page-heading h1 {
    overflow: hidden;
    margin: 0 !important;
    font-size: 18px !important;
    line-height: 1.08 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quick-actions {
    grid-area: actions;
    display: flex !important;
    gap: 5px !important;
  }

  .quick-actions .save-status {
    display: none !important;
  }

  .quick-actions button {
    min-width: 0 !important;
    min-height: 36px !important;
    padding: 6px 9px !important;
    font-size: 10px !important;
    white-space: nowrap;
  }

  .global-search-wrap {
    grid-area: search;
    width: 100% !important;
    min-width: 0 !important;
  }

  .global-search-wrap input {
    min-height: 40px !important;
    font-size: 16px !important;
  }

  .search-results {
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-height: min(58dvh, 440px) !important;
  }

  .view {
    padding: 8px !important;
    overflow-x: hidden !important;
  }

  .workspace-page {
    gap: 8px !important;
  }

  /* Bottom navigation: icons and labels remain tappable, with secondary tools swipeable. */
  .sidebar {
    position: fixed !important;
    z-index: 900 !important;
    inset: auto 0 0 0 !important;
    width: 100% !important;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)) !important;
    min-height: 0 !important;
    display: block !important;
    overflow: hidden !important;
    border: 0 !important;
    border-top: 1px solid #aebfcd !important;
    background: rgba(244, 248, 251, .98) !important;
    padding: 0 0 env(safe-area-inset-bottom) !important;
    box-shadow: 0 -5px 18px rgba(6, 31, 50, .16) !important;
  }

  .sidebar nav {
    width: 100% !important;
    height: var(--mobile-nav-height) !important;
    display: flex !important;
    align-items: stretch !important;
    gap: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .sidebar nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar nav button {
    flex: 0 0 72px !important;
    width: 72px !important;
    min-width: 72px !important;
    height: var(--mobile-nav-height) !important;
    min-height: var(--mobile-nav-height) !important;
    display: grid !important;
    grid-template-rows: 25px auto !important;
    place-items: center !important;
    align-content: center !important;
    gap: 3px !important;
    overflow: hidden !important;
    border: 0 !important;
    border-top: 3px solid transparent !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 5px 3px 7px !important;
    color: #29465c !important;
    font-size: 8px !important;
    line-height: 1.05 !important;
    text-align: center !important;
    scroll-snap-align: start;
  }

  .sidebar nav button img,
  .sidebar nav button svg,
  .sidebar nav button i {
    width: 22px !important;
    height: 22px !important;
    margin: 0 !important;
  }

  .sidebar nav button.active {
    border-top-color: #0878e8 !important;
    background: #e5f2ff !important;
    color: #075fb7 !important;
    box-shadow: none !important;
  }

  .sidebar .user-block,
  .sidebar > .brand,
  .sidebar .demo-help-button {
    display: none !important;
  }

  /* Shared toolbar and control language */
  .workspace-toolbar,
  .production-toolbar,
  .materials-workspace-toolbar,
  .logistics-toolbar {
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 9px !important;
  }

  .workspace-toolbar-title {
    min-width: 0 !important;
  }

  .workspace-toolbar-title strong {
    font-size: 16px !important;
  }

  .workspace-toolbar-title span {
    font-size: 10px !important;
  }

  .workspace-toolbar-actions,
  .production-toolbar-summary,
  .production-toolbar-controls,
  .inventory-toolbar-line,
  .logistics-toolbar > div {
    width: 100% !important;
    min-width: 0 !important;
  }

  .production-toolbar-controls,
  .inventory-toolbar-line {
    display: grid !important;
    gap: 7px !important;
  }

  .department-schedules,
  .queue-filters,
  .materials-department-tabs,
  .inventory-mode-tabs,
  .delivery-workspace-nav {
    width: 100% !important;
    min-width: 0 !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 3px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .department-schedules::-webkit-scrollbar,
  .queue-filters::-webkit-scrollbar,
  .materials-department-tabs::-webkit-scrollbar,
  .inventory-mode-tabs::-webkit-scrollbar,
  .delivery-workspace-nav::-webkit-scrollbar {
    display: none;
  }

  .department-schedules button,
  .queue-filters button,
  .materials-department-tabs button,
  .inventory-mode-tabs button,
  .delivery-workspace-nav button {
    flex: 0 0 auto !important;
    min-height: 40px !important;
    padding: 7px 11px !important;
    white-space: nowrap !important;
    scroll-snap-align: start;
  }

  .production-toolbar-summary {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: end !important;
    gap: 7px !important;
  }

  .job-sort-control,
  .job-sort-control select {
    width: 100% !important;
    min-width: 0 !important;
  }

  .job-sort-control select,
  .inventory-filter-strip select,
  .inventory-filter-strip input {
    min-height: 42px !important;
    font-size: 13px !important;
  }

  .workspace-record-count {
    min-width: 54px !important;
    min-height: 42px !important;
  }

  .inventory-filter-strip {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 7px !important;
    padding: 9px !important;
  }

  .inventory-filter-strip label,
  .inventory-filter-strip .inventory-clear-filters {
    width: 100% !important;
  }

  .inventory-section-head {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
  }

  .inventory-title-metrics {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 5px !important;
  }

  /* Home dashboard */
  .home-command-hero {
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 11px !important;
    padding: 14px !important;
  }

  .home-command-hero .home-command-greeting h2 {
    font-size: 19px !important;
  }

  .home-command-hero .home-priority-job,
  .home-command-hero .home-clear {
    width: 100% !important;
    min-width: 0 !important;
  }

  .home-dashboard-controls {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 7px !important;
    padding: 7px !important;
  }

  .home-command-strip {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 5px !important;
  }

  .home-command-tile {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 54px !important;
  }

  .home-command-grid,
  .home-support-grid,
  .home-side-stack {
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .home-task-row,
  .home-job-row,
  .home-queue-row {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 88px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 5px 9px !important;
    padding: 10px !important;
    text-align: left !important;
  }

  .home-task-row > strong,
  .home-job-row > strong,
  .home-queue-row > strong {
    grid-column: 1;
    align-self: start;
  }

  .home-task-row > span:not(.home-task-meta),
  .home-job-row > span:not(.home-job-due),
  .home-queue-row > span:not(:last-child) {
    grid-column: 1 / -1;
    min-width: 0 !important;
  }

  .home-task-row > em,
  .home-job-row > em,
  .home-queue-row > em {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .home-task-meta,
  .home-job-due,
  .home-queue-row > span:last-child {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  /* Production jobs become readable, tappable record cards. */
  .job-production-head,
  .quote-production-head,
  .customer-directory-column-head,
  .inventory-group-column-head {
    display: none !important;
  }

  .job-production-list,
  .quote-production-list {
    display: grid !important;
    gap: 7px !important;
  }

  .job-production-row {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 78px minmax(0, 1fr) auto auto auto !important;
    grid-template-areas:
      "number project project date date"
      "status status docs tech hours" !important;
    gap: 6px 7px !important;
    overflow: visible !important;
    border-left: 5px solid var(--job-status-color, #0878e8) !important;
    border-radius: 7px !important;
    padding: 9px !important;
  }

  .job-production-row > div {
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  .job-production-number { grid-area: number; }
  .job-production-project { grid-area: project; }
  .job-production-date { grid-area: date; justify-items: end; text-align: right; }
  .job-production-status { grid-area: status; }
  .job-production-docs { grid-area: docs; }
  .job-production-tech { grid-area: tech; align-self: center; justify-self: end; text-align: right; }
  .job-production-hours { grid-area: hours; align-self: center; justify-self: end; }

  .job-production-row .job-production-number strong {
    font-size: 14px !important;
    line-height: 1.1 !important;
  }

  .job-production-row .job-production-date strong {
    font-size: 11px !important;
    line-height: 1.1 !important;
  }

  .job-production-row .job-production-date em {
    font-size: 9px !important;
    line-height: 1.1 !important;
  }

  .job-production-project {
    display: grid !important;
    gap: 1px !important;
  }

  .job-production-row .job-production-project strong {
    display: block !important;
    overflow: hidden !important;
    font-size: 13px !important;
    line-height: 1.1 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .job-production-row .job-production-project b,
  .job-production-row .job-production-project span {
    display: block !important;
    overflow: hidden !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .job-production-project strong,
  .job-production-project b,
  .job-production-project span {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
  }

  .job-production-row .job-production-status .compact-select,
  .job-production-row .job-production-status .fab-status,
  .job-production-row .job-production-status select {
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 4px 24px 4px 8px !important;
    font-size: 10px !important;
  }

  .job-production-docs {
    align-self: center !important;
    display: flex !important;
    gap: 2px !important;
  }

  .job-production-docs .fab-doc-indicator {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 2px !important;
  }

  .job-production-docs .fab-doc-indicator span {
    font-size: 13px !important;
  }

  .job-production-docs .fab-doc-indicator small {
    font-size: 7px !important;
  }

  .job-production-tech {
    max-width: 72px !important;
  }

  .job-production-tech strong {
    display: block !important;
    overflow: hidden !important;
    font-size: 9px !important;
    line-height: 1.1 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .job-production-hours strong {
    font-size: 11px !important;
    line-height: 1 !important;
  }

  /* Quote list cards */
  .quote-production-row {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "quote date"
      "project project"
      "status total"
      "pdf pdf" !important;
    gap: 8px 10px !important;
    border-left: 5px solid var(--department-accent, #0878e8) !important;
    border-radius: 7px !important;
    padding: 10px !important;
  }

  .quote-production-row > div {
    min-width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  .quote-number-cell { grid-area: quote; }
  .quote-project-cell { grid-area: project; }
  .quote-date-cell { grid-area: date; text-align: right; }
  .quote-status-cell { grid-area: status; }
  .quote-pdf-cell { grid-area: pdf; }
  .quote-total-cell { grid-area: total; text-align: right; }

  .quote-project-cell strong,
  .quote-project-cell b,
  .quote-project-cell span {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
  }

  .quote-production-row .quote-status-select {
    width: 100% !important;
    min-width: 0 !important;
    height: 40px !important;
    min-height: 40px !important;
    font-size: 12px !important;
  }

  /* Customer directory cards */
  .customer-grouped-directory {
    gap: 8px !important;
    padding: 7px !important;
  }

  .customer-directory-group {
    width: 100% !important;
    min-width: 0 !important;
  }

  .customer-directory-row {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 5px 8px !important;
    padding: 10px !important;
  }

  .customer-directory-row > div {
    padding: 0 !important;
    border: 0 !important;
    white-space: normal !important;
  }

  .customer-directory-identity {
    grid-column: 1;
    grid-row: 1;
  }

  .customer-directory-action {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .customer-directory-action button {
    min-height: 40px !important;
  }

  .customer-directory-row > div:nth-child(2),
  .customer-directory-row > div:nth-child(3) {
    grid-column: 1 / -1;
    color: #496579;
    font-size: 11px;
  }

  .customer-directory-row > div:nth-child(4),
  .customer-directory-row > div:nth-child(5) {
    grid-row: 4;
    display: inline-flex !important;
    width: fit-content;
    border-radius: 12px !important;
    background: #edf5fb;
    padding: 4px 8px !important;
    font-size: 9px;
    font-weight: 800;
  }

  .customer-directory-row > div:nth-child(5) { grid-column: 2; }
  .customer-directory-row > div:nth-child(6),
  .customer-directory-row > div:nth-child(7),
  .customer-directory-row > div:nth-child(8) { display: none !important; }

  /* Inventory ledger cards retain stock, cost, and action context. */
  .inventory-material-group {
    width: 100% !important;
    min-width: 0 !important;
  }

  .inventory-group-row {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px 10px !important;
    padding: 10px !important;
  }

  .inventory-group-row > div {
    padding: 0 !important;
    border: 0 !important;
  }

  .inventory-group-item,
  .inventory-group-actions {
    grid-column: 1 / -1;
  }

  .inventory-group-item strong,
  .inventory-group-item span,
  .inventory-group-item small {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
  }

  .inventory-group-available,
  .inventory-group-cost {
    border-radius: 6px !important;
    background: #f0f6fa;
    padding: 7px !important;
  }

  .inventory-group-actions {
    justify-content: stretch !important;
  }

  .inventory-group-actions button {
    flex: 1 1 0;
    min-height: 40px !important;
    border-color: #b6cee0 !important;
    background: #f7fbfe !important;
  }

  /* Record workspaces */
  .record-header {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    gap: 8px !important;
    padding: 11px !important;
  }

  .record-header > div:nth-child(2) {
    grid-column: 1 / -1;
    min-width: 0 !important;
  }

  .record-header-actions {
    grid-column: 1 / -1;
    width: 100% !important;
    display: flex !important;
    gap: 5px !important;
    overflow-x: auto !important;
  }

  .record-header-actions button {
    flex: 0 0 auto;
    min-height: 40px !important;
  }

  .record-tabs {
    width: 100% !important;
    display: flex !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .record-tabs button {
    flex: 0 0 auto;
    min-height: 44px !important;
  }

  .job-command-center,
  .job-overview-metrics,
  .job-overview-grid,
  .job-document-chain,
  .job-readiness-stages,
  .content-grid,
  .record-grid,
  .metric-grid {
    grid-template-columns: 1fr !important;
  }

  .job-command-center {
    gap: 10px !important;
    padding: 12px !important;
  }

  /* Delivery calendar becomes a swipeable one-day viewport. */
  .logistics-toolbar .workspace-toolbar-title {
    min-width: 0 !important;
  }

  .delivery-workspace-nav {
    display: flex !important;
    border-radius: 7px !important;
  }

  .delivery-workspace-nav button {
    min-width: 128px !important;
    min-height: 48px !important;
  }

  .delivery-schedule-toolbar,
  .fleet-map-toolbar {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 9px !important;
  }

  .delivery-week-nav {
    width: 100% !important;
    justify-content: space-between !important;
  }

  .delivery-week-nav > div {
    min-width: 0 !important;
    flex: 1 1 auto;
  }

  .delivery-week-nav strong {
    font-size: 13px !important;
  }

  .delivery-schedule-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 5px !important;
  }

  .delivery-schedule-actions > span {
    min-width: 0 !important;
    justify-content: center;
    padding: 5px !important;
  }

  .delivery-schedule-actions .primary {
    grid-column: 1 / -1;
    min-height: 42px !important;
  }

  .delivery-schedule-driver-bar {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
  }

  .delivery-schedule-driver-chips {
    width: 100% !important;
  }

  .delivery-schedule-driver-chips button {
    min-height: 40px !important;
  }

  .delivery-calendar-primary-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 5px !important;
  }

  .delivery-calendar-primary-actions button {
    min-height: 40px !important;
    padding-inline: 5px !important;
  }

  .delivery-calendar-utilities {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 7px !important;
    padding: 8px !important;
  }

  .delivery-calendar-utilities > div {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
  }

  .delivery-calendar-utilities button {
    min-height: 40px !important;
  }

  .delivery-calendar-layout {
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 7px !important;
  }

  .delivery-unscheduled-list {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important;
    max-height: 236px;
    overflow-y: auto;
  }

  .delivery-week-calendar {
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    scroll-snap-type: x proximity;
  }

  .delivery-calendar-head,
  .delivery-calendar-body {
    --mobile-day-width: calc(100vw - 86px);
    width: calc(600vw - 466px) !important;
    min-width: calc(600vw - 466px) !important;
    grid-template-columns: 50px repeat(6, var(--mobile-day-width)) !important;
  }

  .delivery-calendar-time-head,
  .delivery-calendar-times {
    position: sticky !important;
    z-index: 25 !important;
    left: 0;
  }

  .delivery-calendar-head button,
  .delivery-calendar-day {
    scroll-snap-align: start;
  }

  .delivery-calendar-map-layout,
  .fleet-map-layout {
    grid-template-columns: 1fr !important;
  }

  .fleet-map-canvas,
  .delivery-calendar-map-layout .fleet-map-canvas {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 1 / 1;
  }

  /* Full-height mobile forms with one readable field per row. */
  dialog.form-dialog,
  .form-dialog {
    inset: 0 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  .form-dialog .dialog-header,
  .form-dialog > form > header {
    position: sticky !important;
    z-index: 20;
    top: 0;
    min-height: 58px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px !important;
    padding: 9px 10px !important;
  }

  .form-dialog .dialog-header h2,
  .form-dialog .dialog-title {
    overflow: hidden;
    font-size: 19px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form-dialog .dialog-header-controls {
    grid-column: 1 / -1;
    width: 100% !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
  }

  .form-dialog .dialog-header-controls .job-entry-department > div {
    min-width: max-content;
    grid-template-columns: repeat(4, minmax(94px, 1fr)) !important;
  }

  .form-dialog .dialog-body {
    padding: 9px !important;
    overflow-x: hidden !important;
  }

  .form-dialog .dialog-footer,
  .form-dialog > form > footer {
    position: sticky !important;
    z-index: 20;
    bottom: 0;
    gap: 6px !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
  }

  .form-dialog .dialog-footer button,
  .form-dialog > form > footer button {
    min-height: 42px !important;
  }

  .form-grid,
  .job-entry-grid,
  .job-group-grid,
  .source-entry-grid,
  .source-card-body,
  .quote-details-grid,
  .quote-document-grid,
  .line-entry-grid,
  .po-line-entry-grid,
  .po-vendor-grid,
  .purchase-job-details-grid,
  .invoice-delivery-grid,
  .new-delivery-schedule-grid,
  .universal-item-identity-grid,
  .universal-item-attributes-grid,
  .universal-item-units-grid,
  .universal-item-stock-grid,
  .material-count-entry-grid,
  .material-count-material-grid,
  .document-status-grid,
  .driver-proof-form,
  .email-compose-form {
    grid-template-columns: 1fr !important;
  }

  .form-dialog input,
  .form-dialog select,
  .form-dialog textarea,
  .source-control {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
    font-size: 16px !important;
  }

  .source-table-wrap,
  .table-scroll,
  .record-row-scroll {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* The guided tour remains readable without obscuring the entire phone. */
  .demo-tour-card {
    right: 8px !important;
    bottom: calc(var(--mobile-nav-height) + 8px) !important;
    left: 8px !important;
    max-height: min(62dvh, 540px) !important;
  }
}

@media (max-width: 420px) {
  .quick-actions .secondary {
    display: none !important;
  }

  .topbar {
    grid-template-columns: 52px minmax(0, 1fr) auto !important;
  }

  .home-command-strip,
  .inventory-title-metrics {
    grid-template-columns: 1fr 1fr !important;
  }

  .record-header h1,
  .record-header h2 {
    font-size: 18px !important;
  }
}
