/*
 * SMART SYSTEMS display preference authority v1
 * Loaded after every feature/theme stylesheet. Theme presets own colors and
 * effects; the variables below remain owned by the user's display preferences.
 */
html body.ui-v19 {
  font-family:var(--app-font,"Segoe UI",Tahoma,Arial,sans-serif)!important;
  font-size:var(--app-font-size,14px)!important;
}

html body.ui-v19 :where(
  div,section,article,aside,header,footer,nav,main,
  h1,h2,h3,h4,h5,h6,p,span,strong,small,label,a,li,
  button,input,select,textarea,option,optgroup,table,thead,tbody,tfoot,tr,th,td
) {
  font-family:var(--app-font,"Segoe UI",Tahoma,Arial,sans-serif)!important;
}

html body.ui-v19 :where(.num,.numeric,.amount,.money,[data-number-format],code,pre) {
  font-family:"IBM Plex Mono",monospace!important;
}
html body.ui-v19 :where(.fa,.fas,.far,.fab,.fa-solid,.fa-regular) {
  font-family:"Font Awesome 6 Free"!important;
}
html body.ui-v19 .fa-brands { font-family:"Font Awesome 6 Brands"!important; }

/* عناصر الإدخال والجداول القديمة التي تضع مقاسًا ثابتًا أصبحت تتبع مقاس المستخدم. */
html body.ui-v19 :where(button,input,select,textarea,option,optgroup,label,th,td) {
  font-size:var(--app-font-size,14px)!important;
}
html body.ui-v19 :where(h1,.page-head h1) { font-size:calc(var(--app-font-size,14px) + 6px)!important; }
html body.ui-v19 h2 { font-size:calc(var(--app-font-size,14px) + 4px)!important; }
html body.ui-v19 h3 { font-size:calc(var(--app-font-size,14px) + 2px)!important; }

/* The Rewaa-inspired preset has a deliberate table/control scale. Keep the
   user's base font preference, but preserve the reference hierarchy. */
html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen :where(table th,.data-table th) {
  font-size:calc(12 / 16 * var(--app-font-size,16px))!important;
  line-height:1.35!important;
}
html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen :where(table td,.data-table td) {
  font-size:calc(14 / 16 * var(--app-font-size,16px))!important;
  line-height:1.45!important;
}
html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen #mainSidebar :where(.nav-item,.nav-group-label) {
  font-size:calc(14 / 16 * var(--app-font-size,16px))!important;
}
html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen :where(input[type="search"],.table-search input) {
  font-size:calc(14 / 16 * var(--app-font-size,16px))!important;
}
html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen :where(.page-head h1,.page-title) {
  font-size:calc(24 / 16 * var(--app-font-size,16px))!important;
}

/* عرض القائمة يبقى من تفضيل المستخدم حتى داخل طبقة اللابتوب/الدقة العالية. */
@media screen and (min-width:1181px) {
html body.ui-v19:not(.top-nav-mode):not(.launcher-nav-mode) #appScreen > #mainSidebar {
  width:var(--v19-sidebar-width)!important;
  flex-basis:var(--v19-sidebar-width)!important;
}
html body.ui-v19:not(.top-nav-mode):not(.launcher-nav-mode) #appScreen > .main {
  width:calc(100% - var(--v19-sidebar-width))!important;
}
}

/* A drawer is outside the phone layout: never reserve its desktop width. */
@media screen and (max-width:1180px) {
  html body.ui-v19.top-nav-mode #appScreen.active {
    display:flex!important;
    flex-direction:column!important;
  }
  html body.ui-v19 #appScreen > .main {
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin-inline:0!important;
    box-sizing:border-box!important;
    scrollbar-gutter:auto;
  }
  html body.ui-v19 #appScreen > #mainSidebar {
    width:min(82vw,300px)!important;
    max-width:100vw!important;
    position:fixed!important;
    inset:0 0 0 auto!important;
    transform:translateX(110%)!important;
    visibility:hidden!important;
  }
  html[dir="ltr"] body.ui-v19 #appScreen > #mainSidebar,
  html body.ui-v19 #appScreen.sidebar-left > #mainSidebar {
    inset:0 auto 0 0!important;
    transform:translateX(-110%)!important;
  }
  html body.ui-v19 #appScreen > #mainSidebar.mobile-open {
    transform:translateX(0)!important;
    visibility:visible!important;
  }
  html body.ui-v19 #appScreen .v197-workspace-viewport {
    min-width:0!important;
    max-width:100%!important;
    scrollbar-gutter:auto;
    padding-bottom:env(safe-area-inset-bottom,0px);
  }
  html body.ui-v19 #appScreen #page-settings > .settings-page-head {
    margin:0 0 12px!important;
    width:100%!important;
    min-width:0!important;
    position:relative!important;
  }
  /* The retail header lives inside the scrolling viewport, not directly in
     main. Negative desktop margins clipped the title and menu on phones. */
  html[data-v19-preset="retail-teal"] body.ui-v19:not(.top-nav-mode) #appScreen #retailShellHeader {
    grid-template-columns:44px minmax(0,1fr) auto;
    gap:8px;
    width:100%;
    min-width:0;
    margin:0 0 12px;
    padding:6px;
  }
  html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen #retailShellHeader .retail-shell-menu {
    display:inline-flex!important;
  }
  html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen #retailShellHeader button {
    min-width:44px;
    min-height:44px;
  }
  html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen #retailShellHeader .retail-shell-actions { gap:2px; }
  html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen #retailShellHeader .retail-shell-help span { display:none; }
  html[data-v19-preset="retail-teal"] body.ui-v19 #appScreen #retailShellTitle {
    font-size:calc(var(--app-font-size,14px) + 3px)!important;
    white-space:normal;
    overflow-wrap:anywhere;
  }
}

/* Phone forms must not inherit desktop control heights with oversized padding.
   Keep native inputs at least 16px to avoid iOS focus zoom. */
@media screen and (max-width:760px) {
  /* Many enabled modules must not push the working screen below the fold. */
  html body.ui-v19.top-nav-mode #workspaceTopNavigation .workspace-top-groups {
    flex-wrap:nowrap;
    overflow-x:auto;
    overscroll-behavior-inline:contain;
    scrollbar-width:thin;
  }
  html body.ui-v19.top-nav-mode #workspaceTopNavigation .workspace-top-group {
    flex:0 0 auto;
    min-height:44px;
    white-space:nowrap;
  }
  html body.ui-v19.top-nav-mode #workspaceTopNavigation .workspace-top-menu {
    max-height:calc(100dvh - var(--workspace-top-navigation-height,112px) - 16px);
    overscroll-behavior:contain;
  }
  html body.ui-v19 #appScreen .v192-open-screens-label strong { display:none; }
  html body.ui-v19 #appScreen :is(.v192-screen-open,.v192-screen-close) { min-height:44px; }
  html body.ui-v19 #appScreen .v192-screen-close { width:44px;flex-shrink:0; }
  html body.ui-v19 #appScreen .page > .page-head {
    flex-wrap:wrap!important;
    align-items:stretch!important;
    gap:10px!important;
  }
  html body.ui-v19 #appScreen .page > .page-head > h1 {
    flex:1 0 100%!important;
    min-width:0!important;
    width:100%!important;
    white-space:normal!important;
    overflow-wrap:anywhere;
  }
  html body.ui-v19 #appScreen .page > .page-head > :is(div,form) {
    min-width:0!important;
    max-width:100%!important;
    flex-wrap:wrap!important;
  }
  html body.ui-v19 #appScreen .page > .page-head > .v19-page-actions {
    flex:1 1 100%!important;
    width:100%!important;
  }
  html body.ui-v19 #appScreen .page :is(select,textarea,input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"])) {
    min-height:44px!important;
    height:auto!important;
    padding-block:8px!important;
    font-size:max(16px,var(--app-font-size,14px))!important;
    line-height:1.5!important;
    box-sizing:border-box!important;
  }
  html body.ui-v19 #appScreen .page-head .v19-page-actions {
    display:flex!important;
    flex-wrap:wrap!important;
    gap:8px!important;
  }
  html body.ui-v19 #appScreen .page-head .v19-page-actions > button {
    flex:1 1 140px!important;
    min-width:0!important;
    width:auto!important;
    white-space:normal!important;
  }
  html body.ui-v19 #appScreen #settingsStickySaveBar,
  html body.ui-v19 #appScreen #settingsStickySaveBtn,
  html body.ui-v19 #appScreen .page > .table-search,
  html body.ui-v19 #appScreen .page > .table-search > input {
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    white-space:normal!important;
  }
  html body.ui-v19.erp-responsive-v20 :is(#salesInvoiceModal,#purchaseInvoiceModal,#salesReturnModal,#manualSalesReturnModal,#purchaseReturnModal,#quotationModal,#salesOrderModal,#purchaseOrderModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) {
    inset:0!important;
    padding:0!important;
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    overflow-y:auto!important;
    align-items:flex-start!important;
  }
  html body.ui-v19.erp-responsive-v20 :is(#salesInvoiceModal,#purchaseInvoiceModal,#salesReturnModal,#manualSalesReturnModal,#purchaseReturnModal,#quotationModal,#salesOrderModal,#purchaseOrderModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) > .modal-box {
    height:auto!important;
    min-height:100%!important;
    max-height:none!important;
    overflow:visible!important;
    padding:10px!important;
    box-sizing:border-box!important;
  }
  html body.ui-v19 #purchaseInvoiceModal#purchaseInvoiceModal#purchaseInvoiceModal .purchase-invoice-scroll-region {
    flex:0 0 auto!important;
    overflow:visible!important;
    scrollbar-gutter:auto!important;
  }
  html body.ui-v19 :is(#salesInvoiceModal,#purchaseInvoiceModal,#salesReturnModal,#manualSalesReturnModal,#purchaseReturnModal,#quotationModal,#salesOrderModal,#purchaseOrderModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) :is(.fs-sticky-header,.si-workspace-header,.fs-sticky-footer,.si-summary-dock) {
    position:relative!important;
    inset:auto!important;
    height:auto!important;
    max-height:none!important;
    overflow:visible!important;
    flex:0 0 auto!important;
    padding:10px 0!important;
  }
  html body.ui-v19.erp-responsive-v20 :is(#salesInvoiceModal,#purchaseInvoiceModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) :is(.si-meta-grid,.si-compact-fields) {
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    grid-template-rows:none!important;
    grid-auto-rows:auto!important;
    grid-auto-flow:row!important;
    align-items:start!important;
    gap:10px!important;
  }
  html body.ui-v19 :is(#salesInvoiceModal,#purchaseInvoiceModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) :is(.si-meta-field,.si-compact-fields > div) {
    min-width:0!important;
    height:auto!important;
    max-height:none!important;
    overflow:visible!important;
    padding:0!important;
  }
  html body.ui-v19 #purchaseInvoiceModal#purchaseInvoiceModal#purchaseInvoiceModal .si-compact-fields > div:first-child,
  html body.ui-v19 #salesInvoiceModal#salesInvoiceModal#salesInvoiceModal .si-customer-field {
    grid-column:1 / -1!important;
  }
  html body.ui-v19.erp-responsive-v20 #salesInvoiceModal#salesInvoiceModal#salesInvoiceModal .si-add-customer span {
    display:inline!important;
    width:auto!important;
    height:auto!important;
    max-width:none!important;
    max-height:none!important;
    font-size:14px!important;
    opacity:1!important;
    visibility:visible!important;
    clip-path:none!important;
  }
  html body.ui-v19 .modal-overlay.modal-overlay :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),select,textarea) {
    box-sizing:border-box!important;
    font-size:max(16px,var(--app-font-size,14px))!important;
    line-height:1.5!important;
    min-height:44px!important;
    height:auto!important;
    max-height:none!important;
    padding:8px 10px!important;
  }
  html body.ui-v19 :is(#salesInvoiceModal,#purchaseInvoiceModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),select) {
    box-sizing:border-box!important;
    font-size:max(16px,var(--app-font-size,14px))!important;
    min-height:44px!important;
    height:auto!important;
    max-height:none!important;
    padding:8px 10px!important;
    line-height:1.5!important;
  }
  html body.ui-v19 #purchaseInvoiceModal#purchaseInvoiceModal#purchaseInvoiceModal .fs-toggle-btn {
    width:auto!important;
    height:auto!important;
    min-height:44px!important;
    padding:8px 12px!important;
    font-size:14px!important;
    white-space:normal!important;
    overflow:visible!important;
  }
  html body.ui-v19.erp-responsive-v20 :is(#salesInvoiceModal,#purchaseInvoiceModal):not(#mobile-layout-guard):not(#mobile-layout-guard-2) .fs-sticky-footer .invoice-totals {
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
    font-size:14px!important;
  }
  html body.ui-v19.erp-responsive-v20 #salesInvoiceModal#salesInvoiceModal#salesInvoiceModal .si-titlebar {
    position:relative!important;
    inset:auto!important;
    display:flex!important;
    flex-wrap:wrap!important;
    height:auto!important;
    min-height:0!important;
    margin-bottom:12px!important;
  }
}

/* توضع القاعدة أخيرًا عمدًا لتتغلب على الزوايا الثابتة في الوحدات القديمة. */
html[data-v19-corners="square"] body.ui-v19 #appScreen :where(
  .card,.settings-card,.settings-sidebar,.role-sidebar,.dash-card,.kpi-card,.dashboard-widget,
  [class*="card"],[class*="panel"],[class*="box"],[class*="shell"],[class*="dialog"],[class*="menu"],[class*="tab"],
  .page-head,.sidebar,.table-wrap,.data-table-wrap,.pos-products,.pos-cart,.launcher-card,
  button,input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea
),
html[data-v19-corners="square"] body.ui-v19 .modal-overlay :where(
  .modal-box,.fullscreen-modal,.si-workspace,[class*="card"],[class*="panel"],[class*="box"],[class*="shell"],[class*="dialog"],
  button,input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea
) {
  border-radius:3px!important;
}
