.mobile-only, .mobile-nav-icon, .mobile-phase-tabs, .mobile-phase-actions, .mobile-collection-filters { display: none; }
.mobile-menu-backdrop[hidden] { display: none; }

@media screen and (max-width: 1080px) {
  html { scroll-padding-top: 124px; }
  .shell { display: block; min-width: 0; }
  .workspace { min-width: 0; min-height: 100dvh; }
  .mobile-only { display: inline-flex; }
  .mobile-nav-icon { display: block; }
  .desktop-nav-glyph { display: none; }
  .topbar { position: sticky; top: 0; z-index: 32; min-height: 60px; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); background: #fff; }
  .topbar-spacer, .topbar .status-pill { display: none; }
  .topbar .mobile-workspace-title { align-items: center; font-size: 16px; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
  .topbar .btn { min-height: 44px; }
  #mobileMenuOpen { width: 44px; padding: 8px; }
  .mobile-menu-backdrop { position: fixed; inset: 0; z-index: 80; border: 0; background: rgb(18 24 32 / 40%); }
  .shell .side-rail { position: fixed; inset: 0 auto 0 0; z-index: 81; width: min(340px, calc(100vw - 36px)); max-width: none; height: 100vh; height: 100dvh; display: block; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; transform: translateX(-105%); visibility: hidden; padding: max(14px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); border-right: 1px solid var(--line); border-top: 0; background: #fff; }
  .mobile-menu-open .side-rail { visibility: visible; transform: none; }
  .mobile-menu-open .workspace { pointer-events: none; }
  .mobile-menu-close { float: right; width: 44px; height: 44px; margin-bottom: 8px; padding: 10px; }
  .side-rail .rail-brand { display: flex; clear: both; margin-bottom: 12px; }
  .side-rail .rail-brand strong, .side-rail .user-card div { display: block; }
  .side-rail .rail-footer { display: block; }
  .side-rail .nav-section { display: block; margin: 16px 0; }
  .side-rail .nav-section-title { display: block; font-size: 12px; }
  .side-rail .nav-list { display: grid; gap: 4px; }
  .side-rail .nav-link, .side-rail .nav-group-toggle { display: flex; flex-direction: row; justify-content: flex-start; width: 100%; min-width: 0; height: auto; min-height: 46px; padding: 10px 12px; gap: 10px; font-size: 14px; }
  .side-rail .nav-label { display: block; white-space: normal; }
  .side-rail .nav-link:not(.nav-child-link) span.nav-label { display: block; }
  .side-rail .nav-group-list { position: static; display: grid; grid-template-columns: minmax(0, 1fr); width: auto; max-height: none; overflow: visible; padding: 4px 0 4px 26px; border: 0; box-shadow: none; background: transparent; }
  .side-rail details:not([open]) > .nav-group-list { display: none; }
  .side-rail .nav-child-link { height: auto; min-height: 44px; padding: 8px; font-size: 13px; }
  .module-host { min-width: 0; padding: 0 max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); overflow: visible; }
  .module-host input:not([type=checkbox]):not([type=radio]), .module-host select, .module-host textarea { font-size: 16px; min-height: 44px; max-width: 100%; min-width: 0; }
  .module-host button, .module-host .btn { min-height: 44px; }
  .module-host input[type=checkbox], .module-host input[type=radio] { width: 20px; height: 20px; }
  .module-host .check-row, .module-host .old-record-toggle { min-height: 44px; }
  .mobile-phase-hidden { display: none !important; }
  .mobile-phase-tabs { display: flex; position: sticky; top: 60px; top: calc(60px + env(safe-area-inset-top)); z-index: 25; gap: 2px; padding: 8px 0; margin-bottom: 8px; background: #f4f7fa; }
  .mobile-phase-tabs button { flex: 1 1 0; min-width: 0; padding: 8px 3px; min-height: 44px; font-size: 12px; line-height: 1.2; font-weight: 650; color: #44566d; border: 1px solid var(--line); background: #fff; border-radius: 6px; white-space: normal; }
  .mobile-phase-tabs button[aria-pressed=true] { color: #fff; background: #245cf0; border-color: #245cf0; }
  .mobile-phase-tabs button:focus-visible { outline: 2px solid #172f70; outline-offset: 2px; }
  .mobile-phase-actions:not(:empty) { display: flex; gap: 8px; position: sticky; bottom: 0; z-index: 24; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
  .mobile-phase-actions > button { flex: 1; }
  .module-host :is(.delivery-v2, .challan-v2, .collections-v3, .financial-desk) { padding: 0; display: block; height: auto; min-height: 0; }
  .module-host :is(.delivery-workbench, .challan-workbench, .collection-v3-layout, .financial-workbench) { display: block; height: auto; min-height: 0; }
  .module-host :is(.delivery-form-panel, .delivery-list-panel, .delivery-side-stack, .challan-header-card, .challan-entry-panel, .challan-records-panel, .collection-v3-workbench, .collection-v3-pending) { width: 100%; min-width: 0; height: auto; min-height: 0; max-height: none; padding: 12px 0; border: 0; border-radius: 0; box-shadow: none; }
  .module-host :is(.delivery-detail-panel, .delivery-settings-panel) { padding: 12px 0; border: 0; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--line); }
  .module-host :is(.module-toolbar, .challan-panel-head) { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 12px; }
  .module-host :is(.delivery-v2, .challan-v2, .collections-v3, .financial-desk) h2 { font-size: 18px; line-height: 1.25; }
  .module-host :is(.delivery-v2, .challan-v2, .collections-v3, .financial-desk) .eyebrow { display: none; }
  .delivery-editor-head { display: grid; grid-template-columns: minmax(0, 1fr) 82px; gap: 10px; margin: 0; }
  .delivery-editor-head .receipt-lookup-grid { grid-column: 1; grid-row: 1; display: grid; gap: 10px; }
  .delivery-editor-title { display: none; }
  .receipt-no-box { grid-column: 2; grid-row: 1; min-width: 0; width: auto; height: auto; padding: 10px 6px; align-self: start; }
  .delivery-v2 .inline-field { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 5px; }
  .delivery-v2 .inline-field > span, .delivery-v2 .amount-box label { font-size: 12px; line-height: 1.3; }
  .delivery-v2 .delivery-entry-split { display: flex; flex-direction: column-reverse; gap: 16px; margin-top: 12px; }
  .delivery-entry-split .receipt-entry-grid, .delivery-entry-split .charge-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .delivery-entry-split .charge-grid > h3, .delivery-entry-split .receipt-total-box { grid-column: 1 / -1; }
  .delivery-entry-split .amount-box { display: grid; grid-column: auto; grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .delivery-entry-split .readonly-box { min-width: 0; overflow-wrap: anywhere; height: auto; min-height: 40px; }
  .delivery-v2.delivery-desktop-parity .delivery-payment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
  .delivery-payment-grid .delivery-received-in-field, .delivery-payment-grid .delivery-wide-field { grid-column: 1 / -1; }
  .delivery-v2 .delivery-form-footer { display: grid; position: sticky; bottom: 0; z-index: 20; background: #fff; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); gap: 8px; margin-top: 16px; }
  .delivery-form-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .delivery-form-summary .chip:nth-child(-n+3) { display: none; }
  .delivery-form-actions { display: flex; justify-content: flex-end; }
  .delivery-old-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .delivery-old-actions button { width: 100%; min-width: 44px; height: 44px; }
  .delivery-v2 .delivery-row-list { max-height: none; height: auto; min-height: 180px; overflow: visible; }
  .delivery-v2 .delivery-old-suggestions { max-height: 40dvh; }
  .delivery-old-filter-row { grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); }
  .challan-desktop-parity .challan-header-grid, .challan-desktop-parity .challan-old-strip { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .challan-desktop-parity .challan-entry-grid, .challan-desktop-parity .challan-footer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .challan-entry-grid .challan-line-field { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 5px; }
  .challan-entry-grid .is-wide { grid-column: 1 / -1; }
  .challan-header-card .challan-header-actions { display: none; }
  .challan-desktop-parity .challan-header-grid { padding-top: 0; }
  .challan-v2 .challan-table-host { min-height: 160px; max-height: none; height: auto; overflow: auto; }
  .challan-record-table { min-width: 880px; }
  .challan-v2 .challan-summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .challan-v2 .challan-bottom-bar { position: sticky; inset: auto; bottom: 0; z-index: 20; display: block; width: auto; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); margin: 12px 0 0; background: #fff; }
  .challan-bottom-bar .button-row { display: flex; flex-wrap: wrap; margin-top: 8px; }
  .challan-bottom-bar .button-row > button { flex: 1 1 120px; }
  .challan-v2 .challan-status-line { white-space: normal; }
  .mobile-collection-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 12px 0; }
  .collection-v3-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .collection-v3-topline { display: block; }
  .collection-v3-form, .collection-v3-bank { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .collection-v3-form .collection-v3-destination, .collection-v3-bank .collection-v3-control:last-child { grid-column: 1 / -1; }
  .collection-v3-control span { font-size: 12px; min-height: 0; }
  .collection-v3-loaded { padding: 12px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
  .collection-v3-entry { padding: 0; border: 0; border-radius: 0; }
  .collection-v3-stage { display: block; margin-top: 12px; border: 0; }
  .collection-v3-stage-table { min-height: 80px; height: auto; max-height: none; overflow: auto; }
  .collection-v3-grid-head { display: none; }
  .collection-v3-grid-row { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 8px 0; }
  .collection-v3-grid-row > * { text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .collection-v3-grid-row > :nth-child(n+3):nth-child(-n+6)::before { display: block; font-size: 12px; color: #44566d; margin-bottom: 4px; }
  .collection-v3-grid-row > :nth-child(3)::before { content: 'Receipt'; }
  .collection-v3-grid-row > :nth-child(4)::before { content: 'Office received'; }
  .collection-v3-grid-row > :nth-child(5)::before { content: 'Discount / Farak'; }
  .collection-v3-grid-row > :nth-child(6)::before { content: 'Balance'; }
  .collection-v3-grid-row .collection-v3-row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .collection-v3-row-actions button { min-width: 44px; height: 44px; }
  .collection-v3-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }
  .collection-v3-savebar { position: sticky; bottom: 0; z-index: 20; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); display: grid; gap: 8px; background: #fff; }
  .collection-v3-savebar .button-row { display: flex; justify-content: flex-end; }
  .collection-v3-pending-list { max-height: none; height: auto; min-height: 120px; overflow: visible; }
  .collection-v3-pending-head .tab-strip { display: none; }
  .collection-v3-pending-head { display: block; }
  .collection-v3-pending-row { grid-template-columns: 60px minmax(0, 1fr) 100px; gap: 8px; padding: 12px 0; }
  .collection-v3-pending-row strong, .collection-v3-pending-row small { white-space: normal; overflow-wrap: anywhere; }
  .collection-v3-history-action { grid-column: 3; }
  .financial-desk .financial-entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .financial-entry-grid .financial-combo, .financial-entry-grid .financial-narration, .financial-entry-grid .financial-actions { grid-column: 1 / -1; }
  .financial-desk .financial-filters, .financial-desk .financial-entry, .financial-desk .financial-register { min-width: 0; padding: 12px 0; border: 0; border-radius: 0; }
  .financial-desk .financial-workbench { border: 0; border-radius: 0; }
  .financial-desk .financial-filters { display: grid; }
  .financial-desk .financial-grid-scroll { min-height: 180px; height: auto; max-height: none; }
  .financial-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .financial-actions .btn { flex: 1 1 100px; }
  .financial-desk .financial-combo-list { max-height: 40dvh; }
  .financial-dialog, .delivery-history-dialog, .delivery-confirm-dialog, .app-modal { width: min(100%, 540px); max-height: calc(100dvh - 32px); overflow: auto; }
}

@media print {
  .mobile-only, .mobile-phase-tabs, .mobile-phase-actions, .mobile-menu-backdrop { display: none !important; }
}
