/* Phone-only presentation. Desktop tables, business rules and print layouts
   deliberately remain in their original stylesheets. */
.operations-phone-title, .operations-module-phone-title { display: none; }

@media screen and (max-width: 760px) {
  body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important; font-size: 15px; line-height: 1.45; }
  body .topbar { padding-block: max(10px, env(safe-area-inset-top)) 10px; gap: 8px; }
  body .topbar h1 { font-family: inherit !important; font-size: 18px; font-weight: 750; letter-spacing: -.025em; text-shadow: none; }
  body .topbar .brand p { display: none; }
  body .topbar .brand { text-align: left !important; align-items: flex-start !important; }
  body .user-strip { font-size: 12px; padding-block: 7px; }
  body main.container { margin-block: 12px 24px; padding-inline: 12px; }
  body main :is(h1,h2,h3,h4,strong,button,.button,.btn) { font-family: inherit !important; text-shadow: none !important; -webkit-text-stroke: 0 !important; }
  body main h2 { font-size: 22px; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 8px; }
  body main h3 { font-size: 18px; line-height: 1.3; margin: 0 0 8px; }
  body main h4 { font-size: 15px; line-height: 1.4; }
  body main p { margin-block: 8px 12px; }
  body main .muted { font-size: 14px; line-height: 1.45; }
  body main .eyebrow { font-size: 10px; letter-spacing: .07em; margin: 0 0 5px; }
  body main .card { padding: 16px; margin-bottom: 12px; border-radius: 14px; box-shadow: none !important; }
  body main .card .card { padding: 12px; }
  body main :is(.production-inventory-wide-card,.cbd-sku-form-card,.cbd-detail-page) { width: 100%; max-width: 100%; margin-inline: 0; transform: none; }
  body main :is(.section-header,.page-heading-row,.chemical-header) { display: flex; flex-direction: row; flex-wrap: wrap; height: auto; max-height: none; gap: 10px; margin-bottom: 12px; }
  body main :is(.section-header,.page-heading-row,.chemical-header) > div:first-child { min-width: 0; flex: 1 1 100%; }
  body main :is(.section-header,.page-heading-row,.chemical-header) > div:first-child { height: auto; min-height: 0; }
  body main :is(.section-header,.page-heading-row,.chemical-header) p:last-child { margin-bottom: 0; }

  /* Touchable, flat controls instead of tall raised pills. */
  body main :is(button,.button,.btn) { min-height: 44px; max-width: 100%; padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.35; font-weight: 650; white-space: normal; text-align: center; box-shadow: none !important; transform: none !important; letter-spacing: normal; }
  body main :is(button,.button,.btn)::after { box-shadow: none; }
  body main :is(.button-row,.form-actions,.button-stack,.login-secondary-action,.request-order-actions,.cbd-detail-toolbar) { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
  body main :is(.button-row,.form-actions,.login-secondary-action) > :is(a,button) { flex: 1 1 130px; margin: 0; }
  body main .login-secondary-action { margin-top: 12px; }
  body main .login-install-action .button { width: 100%; }
  body main .login-card form > button { width: 100%; margin-top: 8px; }
  body main :is(.link-button,.bottle-toggle) { min-height: 44px; padding: 8px 0; border-radius: 0; background: transparent !important; color: var(--accent) !important; box-shadow: none !important; }
  body main :is(.pill,.status-pill,.operations-module-status) { font-size: 11px; line-height: 1.3; padding: 4px 8px; letter-spacing: .02em; }
  body .page-back-button { width: 44px; height: 44px; padding: 8px; margin: 8px 12px 0; border-radius: 10px; box-shadow: none !important; }

  /* Horizontal category strips keep filters from filling the whole screen. */
  body main :is(.category-tabs,.filter-button-row,.cost-state-tabs,.cost-category-nav,.cbd-detail-tabs) { display: flex; flex-wrap: nowrap; gap: 8px; max-width: 100%; min-width: 0; overflow-x: auto; padding: 4px 2px 10px; margin-block: 12px; scrollbar-width: thin; overscroll-behavior-x: contain; }
  body main :is(.category-tabs,.filter-button-row,.cost-state-tabs,.cost-category-nav,.cbd-detail-tabs) > :is(a,button) { flex: 0 0 auto; min-height: 44px; padding: 10px 12px; border-radius: 10px; font-size: 13px; white-space: nowrap; box-shadow: none !important; }

  /* Compact, readable summaries. Explicit display overrides old flex layouts. */
  body main :is(.summary-grid,.dashboard-summary-grid,.cost-metrics) { display: grid !important; grid-template-columns: repeat(2,minmax(0,1fr)) !important; gap: 8px; margin-block: 12px; }
  body main .summary-card { width: auto; min-width: 0; min-height: 0; padding: 12px; border-radius: 12px; gap: 4px; box-shadow: none !important; overflow-wrap: break-word; }
  body main .summary-card > :is(span,.summary-label) { display: block; font-size: 11px; line-height: 1.35; font-weight: 650; letter-spacing: .02em; white-space: normal; word-break: normal; }
  body main .summary-card > strong, body main .cost-metrics strong { display: block; font-size: 23px; font-weight: 750; line-height: 1.2; letter-spacing: -.02em; margin-block: 3px; font-variant-numeric: tabular-nums; }
  body main .summary-card .summary-value-text { font-size: 17px; }
  body main .summary-card .summary-help { font-size: 12px; font-weight: 400; text-transform: none; margin-top: 4px; }
  body main .summary-card.money-summary-card { grid-column: 1 / -1; }
  body main .summary-card.money-summary-card > strong { font-size: 23px !important; }
  body main .dashboard-summary-grid > .summary-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  body main .cost-metrics > * { min-width: 0; }

  /* Short command-center header and useful list-style module tiles. */
  body main .operations-desktop-title, body main .operations-module-desktop-title, body main .operations-hero-description, body main .operations-hero .eyebrow { display: none; }
  body main .operations-phone-title, body main .operations-module-phone-title { display: inline; }
  body main :is(.operations-hero,.production-hero) { padding: 16px; background: var(--card); min-height: 0; }
  body main :is(.operations-hero,.production-hero) h2 { font-size: 24px; }
  body main .pwa-home-link { margin-top: 4px; }
  body main .production-state-pill { font-size: 12px; line-height: 1.4; padding: 6px 10px; margin: 6px 0 0; white-space: normal; }
  body main .operations-module-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; }
  body main .operations-module-card { display: grid; grid-template-columns: 40px minmax(0,1fr); grid-template-rows: auto auto auto; gap: 5px 12px; min-height: 0; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card) !important; box-shadow: none !important; text-align: left !important; align-items: start; }
  body main .operations-module-card:hover { transform: none !important; text-decoration: none; }
  body main .operations-module-card::before { display: none; }
  body main .operations-module-card .operations-module-icon { grid-column: 1; grid-row: 1 / 4; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; font-size: 23px; border-radius: 10px; margin: 0; }
  body main .operations-module-card .operations-module-icon { color: #17202c !important; -webkit-text-fill-color: #17202c !important; }
  body main .operations-module-card .operations-module-title { grid-column: 2; grid-row: 1; min-height: 0; margin: 0; font-size: 18px; line-height: 1.25; font-weight: 750; letter-spacing: -.02em; text-align: left !important; color: var(--text); }
  body main .operations-module-card .operations-module-title br { display: none; }
  body main .operations-module-card .operations-module-status { grid-column: 2; grid-row: 2; justify-self: start; margin: 0; font-size: 10px; }
  body main .operations-module-card small { grid-column: 2; grid-row: 3; font-size: 13px; line-height: 1.4; font-weight: 400; text-align: left !important; }
  body main :is(.production-tool-card,.production-calculator-card,.wet-goods-card,.cbd-component-builder,.nested-panel) { padding: 12px; min-width: 0; border-radius: 12px; box-shadow: none !important; }

  /* Forms stack predictably, including cost lines with inline desktop widths. */
  body main :is(.form-grid,.formulation-scan-grid,.wet-goods-grid,.production-schedule-grid,.cbd-compare-grid,.cbd-compare-picker,.cost-group-layout,.cost-line,.cogs-recipe-weight,.single-question-map-grid) { grid-template-columns: minmax(0,1fr) !important; gap: 12px; }
  body main :is(.grid,.form-grid) > * { min-width: 0; }
  body main label { font-size: 13px; font-weight: 650; margin-top: 8px; margin-bottom: 5px; }
  body main :is(input,select,textarea):not([type=checkbox]):not([type=radio]):not([type=hidden]) { min-height: 44px; width: 100%; min-width: 0 !important; max-width: 100%; font-size: 16px; line-height: 1.4; border-radius: 9px; padding: 10px 12px; }
  body main input[type=checkbox], body main input[type=radio] { width: 20px; height: 20px; flex-shrink: 0; }
  body main :is(.inline-check,.checkbox,.cost-checkbox) { min-height: 44px; }
  body main :is(.cogs-line,.cogs-recipe-weight) { padding: 12px; }
  body main .costing-page { min-width: 0; }
  body main :is(.vape-ratio-control,.vape-ratio-inputs,.search-form,.category-filter) { min-width: 0; max-width: 100%; }
  body main .vape-ratio-control { grid-template-columns: minmax(0,1fr); }
  body main .project-top-settings-panel { position: static; width: 100%; min-width: 0; max-width: 100%; padding: 12px; }

  /* Editable tables: a labeled card per item, not a clipped spreadsheet. */
  body main :is(.request-order-table-wrap,.cbd-component-entry-wrap) { width: 100%; min-width: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  body main table.pwa-entry-cards { display: block; width: 100%; min-width: 0 !important; border: 0; background: transparent; }
  body main .pwa-entry-cards > thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  body main .pwa-entry-cards > tbody { display: grid; gap: 12px; width: 100%; }
  body main .pwa-entry-cards > tbody > tr:not([hidden]):not(.is-hidden) { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
  body main .pwa-entry-cards > tbody > tr > td { display: block; width: 100% !important; min-width: 0 !important; max-width: 100% !important; padding: 0; border: 0; background: transparent; }
  body main .pwa-entry-cards td[data-mobile-label]::before { content: attr(data-mobile-label); display: block; margin: 0 0 5px; color: var(--text); font-size: 13px; font-weight: 650; letter-spacing: normal; }
  body main .pwa-entry-cards .cbd-remove-component { margin: 0; width: 100%; }
  body main .pwa-entry-cards input[readonly] { opacity: .75; }

  /* Existing inventory cards retain every field in a compact two-column grid. */
  body main .dashboard-table > tbody > tr[data-dashboard-item-row]:not([hidden]) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 12px; padding: 12px; border-radius: 12px; }
  body main .dashboard-table > tbody > tr[data-dashboard-item-row] > td { min-width: 0; width: auto; padding: 3px 0; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
  body main .dashboard-table > tbody > tr[data-dashboard-item-row] > td:is(:nth-child(1),:nth-child(2),:nth-child(6)) { grid-column: 1 / -1; }
  body main .dashboard-table td.chemical-cell > strong { font-size: 17px; }
  body main .dashboard-table .inline-reorder-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  body main :is(.bottle-list,.bottle-card) { min-width: 0; grid-template-columns: minmax(0,1fr); }
  body main .bottle-row > td::before { display: none; }

  /* Reporting tables keep all columns; swipe within them, never the page. */
  body main :is(.table-wrap,.production-batch-ledger,.cbd-detail-table-wrap,.cost-overview) { max-width: 100%; min-width: 0; overflow-x: auto; border-radius: 10px; box-shadow: none; overscroll-behavior-x: contain; }
  body main .pwa-scroll-region::before { content: 'Swipe table to see more columns →'; display: block; position: sticky; left: 0; padding: 8px 10px; font-size: 12px; line-height: 1.3; color: var(--muted); }
  body main table:not(.dashboard-table):not(.pwa-entry-cards) :is(th,td) { font-size: 13px; line-height: 1.4; padding: 10px; }
  body main table.pwa-wide-table { min-width: 760px; table-layout: auto; }
  body main .production-batch-table, body main .production-jar-table { min-width: 850px; table-layout: auto; }
  body main .focus-participants-table { min-width: 1200px; }

  /* CBD snapshots and survey charts use the available width without clipping. */
  body main :is(.cbd-snapshot-support-grid,.cbd-snapshot-table-featured .cbd-snapshot-rows,.focus-breakdown-grid,.focus-set-metric-grid) { grid-template-columns: minmax(0,1fr); gap: 12px; }
  body main .cbd-snapshot-table { padding: 12px; min-height: 0; margin-top: 12px; border-radius: 12px; gap: 10px; box-shadow: none; }
  body main .cbd-snapshot-table-header { flex-wrap: wrap; gap: 8px; }
  body main .cbd-snapshot-table-header h3 { font-size: 18px; margin-top: 8px; }
  body main .cbd-snapshot-open { font-size: 11px; white-space: normal; }
  body main .cbd-snapshot-line { padding: 8px; gap: 10px; border-radius: 8px; font-size: 14px; }
  body main :is(.focus-insight-card,.focus-breakdown-panel,.focus-comparison-section,.focus-set-metric-card) { min-width: 0; padding: 12px; border-radius: 12px; box-shadow: none; }
  body main .focus-bar-row { grid-template-columns: minmax(0,1fr) auto; gap: 5px 10px; }
  body main .focus-bar-row :is(.focus-bar-label,strong) { font-size: 13px; line-height: 1.4; }
  body main .focus-bar-track { height: 10px; }
  body main .focus-bar-chart { row-gap: 12px; }
  body main .pwa-entry-cards [hidden], body main .pwa-entry-cards tr.is-hidden { display: none !important; }
}
