/* OROX Mobile Compact V1.
   Sizing-only overrides for working views. Dashboard and Smart POS are excluded;
   reuse the existing mobile density tokens instead of introducing another mode. */
@media (max-width:680px) {
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView) {
    min-width:0;
    max-width:100%;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.hero,.card,.panel,.section-card,.metric,.section-stack,.toolbar,.table-wrap,.card-body,.section-content) {
    min-width:0;
    max-width:100%;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView) > .hero {
    gap:7px;
    margin-bottom:9px;
    padding:10px 11px;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.section-stack,.module-summary-block,.reports-v2) {
    gap:min(var(--orox-mobile-list-gap,8px),9px);
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.card-head,.section-title) {
    min-height:0;
    gap:8px;
    padding:9px 11px;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    .card-body {
    padding:min(var(--orox-mobile-card-padding,12px),12px);
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.metric,.profile-kpi,.health-tile,.recon-item) {
    min-width:0;
    padding:min(var(--orox-mobile-card-padding,11px),11px);
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    .metric {
    min-height:78px;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    .metric b {
    margin-top:5px;
    font-size:clamp(16px,4.7vw,21px);
    line-height:1.3;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.metric b,.metric strong,.profile-kpi b,.profile-kpi strong,.recon-item strong,.health-tile b,.money,.cell-sub) {
    min-width:0;
    max-width:100%;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.section-stack,.inline-metrics,.recon-grid,.metrics,.profile-grid) {
    min-width:0;
    gap:min(var(--orox-mobile-list-gap,8px),8px);
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.table-wrap,.section-content) {
    min-height:0;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    .empty {
    padding:20px 11px;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.toolbar,.filters,.tabs,.accounting-tabs,.module-workspace-tabs,.orox-mobile-chips) {
    min-width:0;
    max-width:100%;
    flex-wrap:wrap;
    gap:7px;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.tabs,.orox-mobile-chips) {
    overflow-x:visible;
    white-space:normal;
    scroll-snap-type:none;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.tabs .tab,.orox-mobile-chips .orox-filter-chip) {
    min-width:0;
    max-width:100%;
    min-height:44px;
    flex:1 1 136px;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.toolbar,.filters) > * {
    min-width:0;
    max-width:100%;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.form-field,.form-grid,.report-filters,.reports-v2-filter-grid,.supplier-mobile-filters) {
    min-width:0;
    max-width:100%;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(input:not([type=checkbox]):not([type=radio]),select,textarea,.searchable-combobox-input) {
    min-width:0;
    max-width:100%;
    font-size:16px;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.action-row,.quick,.reports-v2-filter-actions) .btn {
    min-width:0;
    min-height:44px;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.orox-mobile-chart,.reports-v2-chart-card,.executive-card) {
    min-width:0;
    max-width:100%;
  }
  :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)), #inventoryView, #contextView)
    :is(.orox-mobile-chart,.reports-v2-chart-card) :is(svg,canvas) {
    max-width:100%;
  }

  /* Product list keeps its approved single wide image/card layout; only spacing shrinks. */
  #inventoryView .product-card-phase4 .product-body {
    gap:min(var(--orox-mobile-list-gap,7px),7px);
    padding:min(var(--orox-mobile-card-padding,10px),10px);
  }
  #inventoryView .product-grid {
    gap:min(var(--orox-mobile-list-gap,8px),8px)!important;
  }
  html[data-orox-mobile-density="compact"] #inventoryView .product-card-phase4 .product-body {
    gap:4px;
    padding:7px 8px;
  }
  #inventoryView .product-card-phase4 :is(.product-title,.product-list-code,.product-list-subline,.stock-chip) {
    min-width:0;
    max-width:100%;
    overflow-wrap:anywhere;
  }
  #inventoryView .inventory-stock-toolbar {
    gap:7px;
  }
  #inventoryView .inventory-stock-toolbar > * {
    min-width:0;
    max-width:100%;
  }

  /* Reuse the existing native two-cell table cards; 320px stays one column. */
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    .orox-native-rollout-view table.orox-native-list-table tr {
    gap:min(var(--orox-mobile-list-gap,7px),7px);
    padding:min(var(--orox-mobile-card-padding,10px),10px);
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    .orox-native-rollout-view table.orox-native-list-table td {
    min-width:0;
    overflow-wrap:anywhere;
  }

  /* Reports: preserve the category/list visuals while reducing tall filters and KPI blocks. */
  #moduleView:not(.pos-mobile-view) .reports-v2 {
    gap:10px;
  }
  #moduleView:not(.pos-mobile-view) .reports-v2-hero {
    padding:12px;
  }
  #moduleView:not(.pos-mobile-view) .reports-v2-category-card {
    min-width:0;
    padding:11px;
  }
  #moduleView:not(.pos-mobile-view) .reports-v2-report-card {
    min-width:0;
    min-height:100px;
    padding:10px;
    gap:6px;
  }
  #moduleView:not(.pos-mobile-view) :is(.reports-v2-viewer,.custom-report-builder) {
    padding:11px;
  }
  #moduleView:not(.pos-mobile-view) :is(.reports-v2-totals,.reports-v2-filter-grid) > * {
    min-width:0;
    overflow-wrap:anywhere;
  }

  /* Administration has its own approved cards; change dimensions, not navigation. */
  .platform-admin :is(.platform-kpi,.platform-role-card,.platform-limit-row,.platform-check-grid span) {
    min-width:0;
    padding:10px;
    overflow-wrap:anywhere;
  }
  .platform-admin :is(.platform-admin-head,.platform-tenant-page-head) {
    gap:9px;
    padding:11px;
  }
  .platform-admin :is(.platform-filter-grid,.platform-usage-filters,.platform-warning-filters,.platform-timeline-filters) > * {
    min-width:0;
    max-width:100%;
  }

  /* Signup/onboarding already have their own grids and phone group. Trim gaps only. */
  #signup .signup-grid,
  #moduleView:has(.orox-onboard-v2-panel) :is(.wizard-panel-body,.orox-onboard-v2-panel) {
    gap:8px;
  }
  #signup .signup-card .signup-step {
    gap:8px;
  }
}

/* Pair short inputs only when the viewport can support two 44px touch fields.
   Grid auto placement keeps DOM/tab order; long text, ID lookups and notes span both. */
@media (min-width:360px) and (max-width:680px) {
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    #entityDialog:not(.pos-setup-dialog):not(.pos-shift-dialog):not(.quotation-v4-dialog)
    .dlg-body .form-grid:has(> .form-field) {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    #entityDialog:not(.pos-setup-dialog):not(.pos-shift-dialog):not(.quotation-v4-dialog)
    .dlg-body .form-grid:has(> .form-field) > * {
    min-width:0;
    max-width:100%;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    #entityDialog:not(.pos-setup-dialog):not(.pos-shift-dialog):not(.quotation-v4-dialog)
    .dlg-body .form-grid:has(> .form-field)
    > :is(.full,.form-field:has(textarea),.form-field:has(input[type=text]),.form-field:has(input[type=email]),.form-field:has(input[type=tel]),.form-field:has(input[type=file]),.form-field:has(input[type=search]),.form-field:has(.searchable-combobox),.form-field:has(select[data-searchable]),.form-field:has(select[name$="_id"])) {
    grid-column:1/-1!important;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    #entityDialog:not(.pos-setup-dialog):not(.pos-shift-dialog):not(.quotation-v4-dialog)
    .dlg-body .form-grid:has(> .form-field)
    > .form-field:has(input:is([name=sku],[name=model],[name=category],[name=unit],[name=reference],[name=code])) {
    grid-column:auto!important;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    #entityDialog:not(.pos-setup-dialog):not(.pos-shift-dialog):not(.quotation-v4-dialog)
    .dlg-body .form-grid:has(> .form-field) > :not(.form-field):not(.full) {
    grid-column:1/-1;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    :is(.reports-v2-filter-grid,.accounting-mobile-view .report-filters,.suppliers-mobile-filters,.supplier-mobile-filters) {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    :is(.reports-v2-filter-grid,.accounting-mobile-view .report-filters,.suppliers-mobile-filters,.supplier-mobile-filters)
    > :is(.full,.form-field:has(input[type=search]),.form-field:has(textarea)) {
    grid-column:1/-1;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    :is(.reports-v2-filter-grid,.accounting-mobile-view .report-filters,.suppliers-mobile-filters,.supplier-mobile-filters) > * {
    min-width:0;
    max-width:100%;
  }
  #moduleView:not(.pos-mobile-view) .reports-v2-totals,
  #moduleView:not(.pos-mobile-view) .reports-v2-filter-actions,
  .platform-admin :is(.platform-filter-grid,.platform-usage-filters,.platform-warning-filters,.platform-timeline-filters,.platform-tenant-quick-actions) {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:7px;
  }
  .platform-admin :is(.platform-filter-grid,.platform-usage-filters,.platform-warning-filters,.platform-timeline-filters) > :is(.full,.form-field:has(input[type=search]),.form-field:has(textarea)) {
    grid-column:1/-1;
  }
  .platform-admin .platform-tenant-quick-actions .btn {
    width:100%;
    min-width:0;
    min-height:44px;
    white-space:normal;
  }

  /* Native list cards show two labeled cells at 360px+; actions stay full width. */
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    .orox-native-rollout-view table.orox-native-list-table tr {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2))
    .orox-native-rollout-view table.orox-native-list-table td:has(.action-row) {
    grid-column:1/-1;
  }
}
@media (min-width:390px) and (max-width:680px) {
  .platform-admin .access-exception-fields {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .platform-admin .access-exception-fields > :is(.access-exception-note,.access-exception-warning) {
    grid-column:1/-1;
  }
}


/* Native filter sheets sit in document.body, outside #moduleView.
   Wrap their chips instead of leaving a second horizontally scrolling surface. */
@media (max-width:680px) {
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    .orox-mobile-sheet .orox-mobile-chips {
    flex-wrap:wrap;
    overflow-x:visible;
    scroll-snap-type:none;
    white-space:normal;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    .orox-mobile-sheet .orox-mobile-chips .orox-filter-chip {
    flex:1 1 136px;
    min-width:0;
    min-height:44px;
    max-width:100%;
    white-space:normal;
    overflow-wrap:anywhere;
  }
}
@media (min-width:390px) and (max-width:680px) {
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    .orox-mobile-sheet .orox-native-filter-sheet {
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:8px;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    .orox-mobile-sheet .orox-native-filter-sheet > .orox-mobile-field {
    min-width:0;
    max-width:100%;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2))
    .orox-mobile-sheet .orox-native-filter-sheet
    > :is(.orox-mobile-field:has(textarea),.orox-mobile-field:has(input[type=text]),.orox-mobile-field:has(input[type=search]),.orox-mobile-field:has(input[type=email]),.orox-mobile-field:has(input[type=tel])) {
    grid-column:1/-1;
  }
}

/* Quotation table/card switch: mobile cards were forced visible by an older
   !important rule even while table mode was selected. Honor the user's choice. */
@media (max-width:680px) {
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace[data-quote-display="table"] .quote-v4-cards {
    display:none!important;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace[data-quote-display="cards"] .quote-v4-table-wrap {
    display:none!important;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table-wrap {
    width:100%;
    min-width:0;
    max-width:100%;
    overflow-x:visible;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table {
    display:block;
    width:100%;
    min-width:0;
    max-width:100%;
    border-collapse:separate;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table thead {
    position:absolute;
    width:1px;
    height:1px;
    overflow:hidden;
    clip-path:inset(50%);
    white-space:nowrap;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table tbody {
    display:grid;
    min-width:0;
    width:100%;
    gap:8px;
    padding:8px;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table tr {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    width:100%;
    min-width:0;
    gap:8px;
    padding:10px;
    border:1px solid var(--line);
    border-radius:12px;
    background:var(--card);
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td {
    display:grid;
    gap:3px;
    width:100%;
    min-width:0;
    max-width:100%;
    padding:0;
    border:0;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td::before {
    content:var(--quote-mobile-cell-label);
    display:block;
    min-width:0;
    color:var(--muted);
    font-size:10px;
    font-weight:850;
    line-height:1.35;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(1) { --quote-mobile-cell-label:"رقم العرض"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(2) { --quote-mobile-cell-label:"العميل والعنوان"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(3) { --quote-mobile-cell-label:"الفرع"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(4) { --quote-mobile-cell-label:"الحالة"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(5) { --quote-mobile-cell-label:"الإجمالي"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(6) { --quote-mobile-cell-label:"صالح حتى"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(7) { --quote-mobile-cell-label:"المسؤول"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(8) { --quote-mobile-cell-label:"المتابعة القادمة"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(9) { --quote-mobile-cell-label:"إجراءات"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(1) { --quote-mobile-cell-label:"Quote number"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(2) { --quote-mobile-cell-label:"Customer and title"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(3) { --quote-mobile-cell-label:"Branch"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(4) { --quote-mobile-cell-label:"Status"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(5) { --quote-mobile-cell-label:"Total"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(6) { --quote-mobile-cell-label:"Valid until"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(7) { --quote-mobile-cell-label:"Owner"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(8) { --quote-mobile-cell-label:"Next follow-up"; }
  html[lang^="en"] #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:nth-child(9) { --quote-mobile-cell-label:"Actions"; }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table td:last-child {
    grid-column:1/-1;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table .quote-v4-amount {
    min-width:0;
    max-width:100%;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table .quote-v4-table-actions {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    min-width:0;
    gap:6px;
  }
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table .quote-v4-table-actions .btn {
    min-width:0;
    min-height:44px;
    width:100%;
    white-space:normal;
  }

  /* Invoice details: keep every tab visible on one compact row without horizontal scroll. */
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2)) .invoice-detail-mobile .invoice-detail-tabs {
    flex-wrap:nowrap;
    overflow-x:visible;
    min-width:0;
    max-width:100%;
  }
  body:not(:has(#dashboardView:not(.hidden))):not(:has(#moduleView.pos-mobile-view:not(.hidden))):not(:has(#moduleView:not(.hidden) .pos-workspace-v2)) .invoice-detail-mobile .invoice-detail-tabs button {
    flex:1 1 0;
    min-width:0;
    max-width:none;
    min-height:40px;
    white-space:nowrap;
    overflow-wrap:normal;
  }
}
@media (min-width:360px) and (max-width:680px) {
  #moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)) .quotation-v4-workspace .quote-v4-table tr {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}


/* Quotations only: Mobile Compact Premium refinement (list, editor and detail).
   Preserve desktop, document/Word layouts, all actions and existing colors. */
@media (max-width:680px) {
  /* List header and filters: trim large surfaces without hiding controls. */
  #moduleView:has(.quotation-v4-workspace) > .hero {
    padding:7px 9px;
    gap:5px;
  }
  #moduleView:has(.quotation-v4-workspace) > .hero h2 {
    font-size:16px;
    line-height:1.3;
  }
  #moduleView:has(.quotation-v4-workspace) > .hero p {
    margin-top:2px;
    font-size:10px;
    line-height:1.35;
  }
  #moduleView:has(.quotation-v4-workspace) > .hero .quick {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    width:100%;
    gap:5px;
  }
  #moduleView:has(.quotation-v4-workspace) #moduleActions {
    gap:6px;
  }
  #moduleView:has(.quotation-v4-workspace) #moduleActions .btn {
    min-width:0;
    min-height:38px;
    padding:6px 8px;
    font-size:11px;
    line-height:1.25;
  }
  #moduleView:has(.quotation-v4-workspace) #moduleFilters {
    padding:6px;
    margin-bottom:7px;
    min-height:0;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters {
    grid-template-columns:repeat(6,minmax(0,1fr));
    gap:5px;
    align-items:center;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters .quote-v4-search {
    grid-column:1/-1;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters :is(input,select),
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters .searchable-combobox {
    min-width:0;
    max-width:100%;
    min-height:38px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters .searchable-combobox :is(.searchable-combobox-input,.searchable-combobox-clear) {
    min-height:38px;
    height:38px;
    padding-block:5px;
  }
  /* Keep every filter visible, with the dates and clear action sharing one row. */
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters > :is(#quoteStatus,#quoteBranch,#quoteCustomer,#quoteOwner,.searchable-combobox) {
    grid-column:span 3;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters > .quote-v4-date {
    grid-column:span 2;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-date {
    min-width:0;
    min-height:38px;
    padding-inline:4px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters .quote-v4-date input {
    min-height:34px;
    padding:3px 0;
    font-size:12px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters > [data-quote-clear-filters] {
    grid-column:span 2;
    width:100%;
    min-height:38px;
    padding:5px 3px;
    font-size:10px;
    white-space:normal;
  }
  #moduleView:has(.quotation-v4-workspace) .quotation-v4-workspace {
    gap:8px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-metrics,
  #moduleView:has(.quotation-v4-workspace) .quote-v5-extra-metrics {
    gap:6px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-stat {
    min-height:49px;
    padding:6px 5px;
    gap:4px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-metrics {
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-stat-icon {
    width:22px;
    height:22px;
    flex-basis:22px;
    font-size:12px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-stat b {
    font-size:14px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-list-card-details {
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:5px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-list-card {
    padding:8px;
    gap:4px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-list-card-actions .btn {
    min-height:40px;
    padding:6px;
    font-size:11px;
  }

  /* Create / edit: reduce padding, not content or the existing form flow. */
  #entityDialog.quotation-v4-dialog .dlg-head {
    padding:7px 10px;
  }
  #entityDialog.quotation-v4-dialog .dlg-body {
    padding:7px 8px;
  }
  #entityDialog.quotation-v4-dialog .quotation-v5-editor,
  #entityDialog.quotation-v4-dialog .quote-v4-editor-main,
  #entityDialog.quotation-v4-dialog .quote-v4-editor-side {
    gap:6px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-panel {
    padding:7px 8px;
    border-radius:12px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-panel-title {
    gap:5px;
    margin-bottom:5px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-panel-title h4 {
    margin-bottom:2px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-panel-title small {
    line-height:1.35;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-panel-icon {
    width:26px;
    height:26px;
    flex-basis:26px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-fields {
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:4px 6px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-fields .form-field {
    min-width:0;
    gap:2px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-fields .form-field > span,
  #entityDialog.quotation-v4-dialog .quote-v4-line-fields .quote-line-field > span {
    font-size:10px;
    line-height:1.3;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-fields :is(input,select),
  #entityDialog.quotation-v4-dialog .quote-v4-line-fields :is(input:not([type=checkbox]),select),
  #entityDialog.quotation-v4-dialog .quote-v4-fields .searchable-combobox {
    min-width:0;
    max-width:100%;
    min-height:38px;
    height:38px;
    font-size:16px; /* iOS focus: no unwanted zoom */
  }
  #entityDialog.quotation-v4-dialog .quote-v4-fields .searchable-combobox :is(.searchable-combobox-input,.searchable-combobox-clear) {
    min-height:38px;
    height:38px;
    padding-block:5px;
  }
  #entityDialog.quotation-v4-dialog [name="quote_intro_text"] {
    height:56px;
    min-height:52px;
    resize:vertical;
  }
  #entityDialog.quotation-v4-dialog .quote-line-description textarea {
    height:48px;
    min-height:44px;
    resize:vertical;
  }
  #entityDialog.quotation-v4-dialog .quotation-builder-head {
    gap:6px;
    margin:0 0 7px;
  }
  #entityDialog.quotation-v4-dialog .quotation-builder-head [data-quote-line-add] {
    width:auto;
    min-height:36px;
    padding:5px 8px;
    font-size:11px;
    margin-inline-start:auto;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line {
    padding:6px;
    gap:4px;
    margin-bottom:6px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line-fields {
    gap:5px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line-thumb {
    width:30px;
    height:30px;
    flex-basis:30px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line-actions .btn {
    min-width:36px;
    min-height:36px;
    padding:5px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-quick-item,
  #entityDialog.quotation-v4-dialog .quote-v4-add-another {
    min-height:38px;
    padding:6px 9px;
    font-size:11px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-editor-main .quote-v4-panel-title {
    margin-bottom:5px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line-fields :is(.quote-line-price,.quote-line-discount,.quote-line-tax,.quote-line-optional) {
    grid-column:span 2;
  }
  #entityDialog.quotation-v4-dialog .quotation-builder-head {
    flex-direction:row;
    flex-wrap:wrap;
    align-items:center;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line-fields .quote-optional {
    min-height:38px;
    padding:4px 5px;
  }
  #entityDialog.quotation-v4-dialog .quote-v4-line-bottom {
    padding-top:4px;
    gap:4px;
  }
  #entityDialog.quotation-v4-dialog .dlg-foot {
    gap:6px;
    padding:5px 8px max(5px,env(safe-area-inset-bottom));
  }
  #entityDialog.quotation-v4-dialog .dlg-foot > .btn.primary,
  #entityDialog.quotation-v4-dialog .dlg-foot > .quote-v5-save-draft {
    flex:1 1 calc(50% - 3px);
    width:auto;
    min-width:0;
    min-height:38px;
    padding:5px;
    font-size:11px;
    line-height:1.3;
    white-space:normal;
  }
  #entityDialog.quotation-v4-dialog .quote-v5-save-totals {
    gap:3px;
    font-size:9px;
  }
  #entityDialog.quotation-v4-dialog .quote-v5-save-totals :is(span,strong) {
    padding-inline:4px;
  }

  /* Quote detail: compact summary, actions and tabs; never touch printed pages. */
  #entityDialog:has(.quote-v5-detail) .dlg-head {
    padding:8px 10px;
  }
  #entityDialog:has(.quote-v5-detail) .dlg-body {
    padding:9px;
  }
  #entityDialog .quote-v5-detail {
    gap:7px;
  }
  #entityDialog .quote-v5-detail .quotation-detail-head {
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:7px;
    padding:7px 9px;
    margin-bottom:0;
    min-height:0;
  }
  #entityDialog .quote-v5-detail .quotation-detail-head > div {
    min-width:0;
  }
  #entityDialog .quote-v5-detail .quotation-detail-head h3 {
    margin:4px 0 2px;
    font-size:15px;
    overflow-wrap:anywhere;
  }
  #entityDialog .quote-v5-detail .quotation-detail-head > div:last-child {
    gap:4px;
    justify-items:end;
  }
  #entityDialog .quote-v5-detail .quotation-detail-head > div:last-child > b {
    font-size:16px;
  }
  #entityDialog .quote-v5-detail .quote-v4-detail-meta {
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:4px;
    padding:7px;
    margin:0;
  }
  #entityDialog .quote-v5-detail .quote-v4-detail-meta span {
    min-width:0;
    font-size:10px;
    line-height:1.4;
  }
  #entityDialog .quote-v5-detail .quote-v7-quality-notice {
    padding:7px 9px;
    margin:0;
    gap:4px;
    line-height:1.4;
  }
  #entityDialog .quote-v5-detail .quotation-actions {
    display:grid;
    grid-template-columns:repeat(6,minmax(0,1fr));
    gap:4px;
    margin:0;
  }
  #entityDialog .quote-v5-detail .quotation-actions > .btn {
    grid-column:span 2;
    min-width:0;
    width:100%;
    min-height:38px;
    padding:4px 3px;
    font-size:10.5px;
    line-height:1.25;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  #entityDialog .quote-v5-detail .quotation-actions > .btn:nth-child(-n+2) {
    grid-column:span 3;
  }
  #entityDialog .quote-v5-detail .quote-v5-detail-tabs {
    gap:3px;
    padding:2px;
  }
  #entityDialog .quote-v5-detail .quote-v5-detail-tabs button {
    min-height:38px;
    padding:4px 3px;
    font-size:10px;
    line-height:1.3;
    overflow-wrap:anywhere;
  }
  #entityDialog .quote-v5-detail .quote-version-strip {
    margin:6px 0 8px;
  }
  #entityDialog .quote-v5-detail .quote-version {
    min-width:110px;
    padding:6px 8px;
  }
}
@media (max-width:680px) and (max-width:389px) {
  /* At narrow phone widths, date pickers retain enough room for native controls. */
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters > :is(#quoteStatus,#quoteBranch,#quoteCustomer,#quoteOwner,.searchable-combobox,.quote-v4-date) {
    grid-column:span 1;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-filters > [data-quote-clear-filters] {
    grid-column:1/-1;
    width:auto;
    justify-self:start;
    padding-inline:10px;
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-metrics {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #moduleView:has(.quotation-v4-workspace) .quote-v4-list-card-details {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #entityDialog.quotation-v4-dialog .quote-v4-fields {
    grid-template-columns:1fr;
  }
  #entityDialog .quote-v5-detail .quotation-actions > .btn {
    grid-column:span 3;
  }
}

/* Shared mobile controls reuse the existing native density and touch tokens.
   Dashboard, POS checkout and desktop are intentionally excluded. */
@media screen and (max-width:680px){
  html[data-orox-mobile-native-v2="1"] body:not(.platform-mode)
    :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)),#inventoryView,#contextView)
    :is(.toolbar > .btn,.filters > .btn,.tabs > .tab,.module-workspace-tabs > .tab){
      min-height:40px;font-size:13px;line-height:1.4;
      padding:7px 10px;white-space:normal;overflow-wrap:anywhere;
    }
  html[data-orox-mobile-native-v2="1"] body:not(.platform-mode)
    :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)),#inventoryView,#contextView)
    :is(.toolbar input,.toolbar select,.filters input,.filters select){
      min-width:0;max-width:100%;min-height:40px;font-size:16px;
    }
  html[data-orox-mobile-native-v2="1"] body:not(.platform-mode)
    :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)),#inventoryView,#contextView)
    :is(.card-head h3,.section-title h3){font-size:16px;line-height:1.4}
  html[data-orox-mobile-native-v2="1"] body:not(.platform-mode)
    :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)),#inventoryView,#contextView)
    :is(.card-body,.section-content){min-width:0;font-size:14px;line-height:1.45}
  html[data-orox-mobile-native-v2="1"] body:not(.platform-mode)
    :is(#moduleView:not(.pos-mobile-view):not(:has(.pos-workspace-v2)),#inventoryView,#contextView)
    :is(.badge,.status-chip){min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
}
