/*
 * Mobile responsiveness fixes — loaded LAST (after customer-current-n.css).
 * Every rule lives inside a max-width media query so desktop is untouched,
 * except the WCAG contrast fix in section 3a, which applies at all widths.
 * One section per screen; see commit messages "UI: <screen>".
 */

/* ── 1. Header mobile menu (≤900px) ──────────────────────────────────────
 * Root cause: lot4b-home.css makes #nav position:absolute with a white
 * background, while customer-current-n.css paints its links #f8fafc, so the
 * menu rendered white-on-white below the dark band. Keep the menu in flow
 * inside the dark .lot4b-header-bottom band and give every target 48px.
 */
@media (max-width: 900px) {
  /* Header action buttons: 48px tall touch targets */
  html body #header.lot4b-header .lot4b-header-actions .menu {
    display: inline-grid !important;
    place-items: center !important;
    width: 48px !important;
    min-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    color: #0F172A !important;
    font-size: 24px !important;
    line-height: 1 !important;
  }
  html body #header.lot4b-header .lot4b-header-actions :is(.bell-button, .lang, .market-country-trigger, .is-user-avatar) {
    min-height: 48px !important;
    min-width: 44px !important;
  }
  html body #header.lot4b-header .lot4b-header-actions :is(.menu, .bell-button, .lang, .market-country-trigger, .is-user-avatar):focus-visible {
    outline: 3px solid #1D4ED8 !important;
    outline-offset: 2px !important;
  }

  /* Search row: 48px controls, 16px input text (no iOS zoom) */
  html body #header.lot4b-header .lot4b-header-search input {
    min-height: 48px !important;
    font-size: 16px !important;
  }
  html body #header.lot4b-header .lot4b-header-search .lot4b-picker-trigger {
    min-height: 44px !important;
  }
  html body #header.lot4b-header .lot4b-header-search .lot4b-search-button {
    min-width: 48px !important;
    min-height: 48px !important;
  }

  /* Open menu: in normal flow, dark background, readable links */
  html body #header.lot4b-header #nav {
    position: static !important;
    inset: auto !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: transparent !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  html body #header.lot4b-header #nav a {
    min-height: 48px !important;
    padding: 10px 14px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    color: #F8FAFC !important;            /* ≈17:1 on #0F172A */
    border: 1px solid rgba(255, 255, 255, 0.10) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10) !important;
    font-size: 14px !important;
    overflow-wrap: anywhere !important;
  }
  html body #header.lot4b-header #nav a:hover {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #FFFFFF !important;
  }
  html body #header.lot4b-header #nav :is(a.active, a[aria-current="page"]) {
    background: #1D4ED8 !important;     /* white on #1D4ED8 ≈ 6.7:1 */
    border-color: #1D4ED8 !important;
    color: #FFFFFF !important;
  }
  html body #header.lot4b-header #nav a:focus-visible {
    outline: 3px solid #93C5FD !important;
    outline-offset: 2px !important;
  }
  html body #header.lot4b-header #nav .mobile-account {
    grid-column: 1 / -1 !important;
    justify-content: center !important;
    font-weight: 800 !important;
  }

  /* Post-offer / post-need buttons under the menu */
  html body #header.lot4b-header .lot4b-post-actions .btn {
    min-height: 48px !important;
  }
}

/* Very narrow phones: one link per row */
@media (max-width: 360px) {
  html body #header.lot4b-header #nav {
    grid-template-columns: 1fr !important;
  }
}

/* ── 2. Customer record tables: Offers, Needs, Interests (≤760px) ────────
 * Root cause: customer-modern.css turns rows with [data-customer-record]
 * into grid cards, but customer-current-n.css (loaded later, same
 * specificity) forces td{height:58px;padding:12px 16px} and
 * td.lot4b-product-td{width:22%;max-width:230px}. The title cell shrank to
 * ~32px (letters stacked vertically) and every cell overflowed its 58px box.
 * The scroll wrapper (.density-table-scroll) is already added by
 * responsive-tables.js, so no JS change is needed.
 */
@media (max-width: 760px) {
  /* Cards stand on their own: drop the outer table frame */
  html body .customer-console .account-content .table-wrap:has(> .density-table-scroll > .mobile-record-table),
  html body .customer-console .account-content .table-wrap:has(> .mobile-record-table) {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
  html body .customer-console .account-content .density-table-scroll:has(> .mobile-record-table) {
    overflow: visible !important;
    contain: none !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border: 0 !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table > tbody {
    display: grid !important;
    gap: 12px !important;
  }

  /* One card per record */
  html body .customer-console .account-content .ops-table.mobile-record-table > tbody > tr[data-customer-record] {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 4px 12px !important;
    padding: 14px !important;
    background: #FFFFFF !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 12px !important;
    box-shadow: none !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table > tbody > tr[data-customer-record]:hover {
    background: #FFFFFF !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table > tbody > tr[hidden] {
    display: none !important;
  }

  /* Cells: natural height, label above value */
  html body .customer-console .account-content .ops-table.mobile-record-table td {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 8px 0 !important;
    border: 0 !important;
    text-align: start !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td::before {
    content: attr(data-column-label);
    display: block;
    margin: 0;
    color: #64748B;            /* 4.76:1 on white */
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td > * {
    max-width: 100% !important;
  }

  /* Title row on top, full width */
  html body .customer-console .account-content .ops-table.mobile-record-table td.lot4b-product-td {
    grid-column: 1 / -1 !important;
    order: -3 !important;
    padding-top: 0 !important;
    padding-bottom: 10px !important;
    border-bottom: 1px solid #F1F5F9 !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td.lot4b-product-td::before {
    display: none;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td.lot4b-product-td :is(.lot4b-table-product-cell, .lot4b-table-product-info) {
    width: 100% !important;
    min-width: 0 !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td.lot4b-product-td .lot4b-title-link strong {
    font-size: 16px !important;
    line-height: 1.45 !important;
  }

  /* Reference number cell (Needs) sits above the title */
  html body .customer-console .account-content .ops-table.mobile-record-table td:has(> .lot4b-ref-link:only-child) {
    order: -4 !important;
    grid-column: 1 / -1 !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
  }

  /* Status right under the title, label and pill on one line */
  html body .customer-console .account-content .ops-table.mobile-record-table td:has(> :is(.status-pill, .buying-need-status)) {
    order: -2 !important;
    grid-column: 1 / -1 !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
  }

  /* Actions: last, full width, 48px buttons */
  html body .customer-console .account-content .ops-table.mobile-record-table td:last-child {
    order: 99 !important;
    grid-column: 1 / -1 !important;
    margin-top: 6px !important;
    padding-top: 12px !important;
    border-top: 1px solid #F1F5F9 !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td:last-child::before {
    display: none;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td:last-child .table-actions,
  html body .customer-console .account-content .ops-table.mobile-record-table td:last-child {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td:last-child .table-actions {
    display: flex !important;
    width: 100% !important;
  }
  html body .customer-console .account-content .ops-table.mobile-record-table td:last-child :is(.btn, button, a.btn) {
    flex: 1 1 120px !important;
    min-height: 48px !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
    margin: 0 !important;
  }

  /* Keep the deliberately hidden Category column hidden on My buying needs */
  html body .buying-needs-page .buying-needs-list .mobile-record-table tbody tr > td:nth-child(3) {
    display: none !important;
  }

  /* Tables that are NOT converted to cards: scroll sideways, sticky first column */
  html body .customer-console .account-content .density-table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  html body .customer-console .account-content .density-table-scroll > .ops-table:not(.mobile-record-table) {
    width: max-content !important;
    min-width: 640px !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }
  html body .customer-console .account-content .density-table-scroll > .ops-table:not(.mobile-record-table) :is(th, td) {
    white-space: nowrap !important;
  }
  html body .customer-console .account-content .density-table-scroll > .ops-table:not(.mobile-record-table) :is(th, td):first-child {
    position: sticky !important;
    inset-inline-start: 0 !important;
    z-index: 2 !important;
    min-width: 140px !important;
    max-width: 180px !important;
    white-space: normal !important;
    background: #FFFFFF !important;
    box-shadow: inset -1px 0 0 #E2E8F0 !important;
  }
  html[dir="rtl"] body .customer-console .account-content .density-table-scroll > .ops-table:not(.mobile-record-table) :is(th, td):first-child {
    box-shadow: inset 1px 0 0 #E2E8F0 !important;
  }
  html body .customer-console .account-content .density-table-scroll > .ops-table:not(.mobile-record-table) th:first-child {
    background: #F8FAFC !important;
    z-index: 3 !important;
  }
  html body .customer-console .account-content .density-table-scroll > .ops-table:not(.mobile-record-table) :is(.btn, button) {
    min-height: 48px !important;
  }

  /* Filters: stacked, full width, 48px controls */
  html body .customer-console .customer-record-summary .customer-record-stat {
    min-height: 48px !important;
  }
  html body .customer-console .customer-record-toolbar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    padding: 12px !important;
  }
  html body .customer-console .customer-record-toolbar label {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    flex: none !important;
  }
  html body .customer-console .customer-record-toolbar label:first-child,
  html body .customer-console .customer-record-toolbar .customer-record-actions,
  html body .customer-console .customer-record-toolbar [data-range-error] {
    grid-column: 1 / -1 !important;
  }
  html body .customer-console .customer-record-toolbar :is(input, select) {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    font-size: 16px !important;   /* prevents iOS zoom */
  }
  html body .customer-console .customer-record-toolbar .customer-record-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
  }
  html body .customer-console .customer-record-toolbar .btn[data-customer-clear] {
    flex: 1 1 140px !important;
    min-height: 48px !important;
    justify-content: center !important;
  }
}

/* Small phones: one filter per row so date pickers never clip */
@media (max-width: 520px) {
  html body .customer-console .customer-record-toolbar {
    grid-template-columns: 1fr !important;
  }
}

/* Very narrow phones: card data in one column */
@media (max-width: 340px) {
  html body .customer-console .account-content .ops-table.mobile-record-table > tbody > tr[data-customer-record] {
    grid-template-columns: 1fr !important;
  }
}

/* ── 3. Marketplace cards: home, Offers and Buying needs grids (≤600px) ───
 * Root cause: lot4b-home.css sets 1 column at ≤420px and then, a few lines
 * later in the same breakpoint, forces 2 columns again with 9–12px text.
 * Cards were ~150px wide, so quantities wrapped one letter per line. The
 * .is-sparse grids also used fixed 215–320px tracks.
 */
@media (max-width: 600px) {
  /* One card per row (also covers the .is-sparse variants) */
  html body #latest-listings .homepage-listings-grid,
  html body #latest-listings .homepage-listings-grid.is-sparse,
  html body #listings.grid,
  html body #listings.grid.is-sparse,
  html body #listings.cards.listings-grid.homepage-listings-grid.is-sparse,
  html body .listings-grid.homepage-listings-grid.is-sparse,
  html body .lot4b-home-needs-grid,
  html body .lot4b-home-needs-grid.is-sparse,
  html body #demand-grid.demand-grid,
  html body #demand-grid.demand-grid.is-sparse {
    grid-template-columns: minmax(0, 1fr) !important;
    justify-content: stretch !important;
    gap: 14px !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .card-body {
    padding: 14px !important;
  }

  /* Readable text: nothing below 13px */
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) :is(
    .lot4b-card-category, .record-number, .lot4b-card-views, .lot4b-partial-sale-pill,
    .lot4b-card-deadline, .lot4b-card-quantities dt, .lot4b-card-quantities dd,
    .lot4b-card-price small, .lot4b-compare-pill, .lot4b-offer-type-pill, .demand-wanted-badge,
    .lot4b-card-views > span, .lot4b-partial-sale-pill > span, .lot4b-offer-type-pill > span, .demand-wanted-badge > span
  ) {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .card-body h3 {
    min-height: 0 !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-price .price {
    font-size: 18px !important;
  }

  /* Meta row and deadline: wrap by words, never letter by letter */
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-meta {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-category {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html body .lot4b-need-card-v2 .lot4b-card-deadline {
    flex-wrap: wrap !important;
    white-space: normal !important;
  }

  /* Quantities: two columns, value under its label */
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-quantities {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-quantities > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    min-width: 0 !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-quantities dt {
    margin: 0 !important;
    white-space: normal !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-quantities dd {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-weight: 700 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  /* Footer: two equal 48px buttons side by side */
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-footer,
  html body .lot4b-need-card-v2 .lot4b-card-footer.demand-card-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-footer > :is(.btn, .card-actions) {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-footer :is(.lot4b-card-details, .lot4b-card-supply, .lot4b-compare-pill) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 48px !important;
    height: auto !important;
    padding: 8px 10px !important;
    font-size: 14px !important;
    line-height: 1.3 !important;
    text-align: center !important;
    white-space: normal !important;
  }
  html body .lot4b-offer-card-v2 .lot4b-card-footer .card-actions {
    display: flex !important;
    gap: 0 !important;
  }
  html body .lot4b-offer-card-v2 .lot4b-card-footer .lot4b-compare-pill input {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
  }

  /* Save (heart) button: 48px touch target */
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-heart-btn {
    min-width: 48px !important;
    min-height: 48px !important;
  }
  /* Need card header reserves room for the 48px heart (10px inset + 48px + 8px gap) so it no longer covers the category icon */
  html body .lot4b-need-card-v2 .lot4b-need-art {
    padding-inline-end: 66px !important;
  }
}

/* Narrow phones: footer buttons stack */
@media (max-width: 360px) {
  html body :is(.lot4b-offer-card-v2, .lot4b-need-card-v2) .lot4b-card-footer,
  html body .lot4b-need-card-v2 .lot4b-card-footer.demand-card-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* ── 3a. "عرض التفاصيل" button contrast (all widths) ─────────────────────
 * #4A7BAF with white text is ~4.4:1, just under WCAG AA (4.5:1). The
 * former hover shade #3D6998 gives ~5.6:1; hover darkens to #2F5680 (~7.7:1).
 */
html body .lot4b-need-card-v2 :is(.lot4b-card-footer, .demand-card-actions) .lot4b-card-details,
html body .customer-console .account-content .need-details-button {
  background: #3D6998 !important;
  background-color: #3D6998 !important;
  border-color: #3D6998 !important;
  color: #FFFFFF !important;
}
html body .lot4b-need-card-v2 :is(.lot4b-card-footer, .demand-card-actions) .lot4b-card-details:hover,
html body .customer-console .account-content .need-details-button:hover {
  background: #2F5680 !important;
  background-color: #2F5680 !important;
  border-color: #2F5680 !important;
}

/* ── 4. Account settings / profile (≤640px) ──────────────────────────────
 * Root cause: customer-account.css gives the role <label> flex:1 1 220px.
 * On mobile the form switches to a column, so that 220px basis became the
 * label's HEIGHT and pushed "حفظ نوع الحساب" ~230px down. Use a plain
 * one-column grid instead, with 48px controls.
 */
@media (max-width: 640px) {
  html body #profile-role-settings.profile-role-panel {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    height: auto !important;
    min-height: 0 !important;
  }
  html body #profile-role-settings .lot4b-role-panel-head h3 {
    margin: 0 !important;
  }
  html body #profile-role-settings .profile-role-form {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 12px !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
  }
  html body #profile-role-settings .profile-role-form > * {
    grid-column: 1 / -1 !important;
  }
  html body #profile-role-settings .profile-role-form label {
    display: block !important;
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
  }
  html body #profile-role-settings .profile-role-form select {
    box-sizing: border-box !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    font-size: 16px !important;
  }
  html body #profile-role-settings .profile-role-form :is(button[type="submit"], #profile-role-return) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: auto !important;
    min-height: 48px !important;
    padding: 10px 18px !important;
    margin: 0 !important;
    font-size: 14px !important;
    white-space: normal !important;
    text-align: center !important;
  }
  html body #profile-role-settings .profile-role-form .feedback:empty {
    display: none !important;
  }

  /* Rest of the profile page: 48px inputs, buttons and photo toggle */
  html body .customer-console .profile-account-layout :is(#profile-form, #avatar-form) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]), select) {
    min-height: 48px !important;
    font-size: 16px !important;
  }
  html body .customer-console .profile-account-layout :is(#profile-form, #avatar-form) textarea {
    font-size: 16px !important;
  }
  html body .customer-console .profile-account-layout :is(#profile-form, #avatar-form) .btn {
    min-height: 48px !important;
  }
  html body .customer-console .profile-account-layout .profile-photo-editor > summary {
    display: inline-flex !important;
    align-items: center !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
  }
}

/* ── 5. Customer console: touch-target and spacing sweep (≤760px) ────────
 * Remaining sub-48px targets found on the overview, the account drawer,
 * record tables and profile: .btn/.btn.small (40–44px), drawer links (40px),
 * drawer footer actions (31–34px), drawer close (34px), menu toggle (42px),
 * Excel export (30px) and block links in lists (22–47px).
 * Spacing: overview panels had margin:20px 0 inside a 20px grid gap, so
 * stacked cards were ~60px apart. Tighten to a consistent 16px rhythm.
 */
@media (max-width: 760px) {
  /* Buttons and form controls */
  html body .customer-console .account-content :is(.btn, .btn.small, .lot4b-excel-export-btn, [role="tab"]),
  html body .customer-console .account-content button:not([role="switch"]):not(.lot4b-card-heart-btn) {
    min-height: 48px !important;
  }
  html body .customer-console .account-content :is(.btn, .btn.small, .lot4b-excel-export-btn) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }
  html body .customer-console .account-content :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]), select) {
    min-height: 48px !important;
    box-sizing: border-box !important;
  }
  html body .customer-console .account-content details > summary {
    min-height: 48px !important;
    box-sizing: border-box !important;
  }

  /* Block links in lists and section heads */
  html body .customer-console .account-content :is(.account-attention a, .overview-links a, .account-tabs a, .section-head > a, .section-head .actions > a:not(.btn)) {
    display: flex !important;
    align-items: center !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
  }
  html body .customer-console .account-content .section-head > a {
    display: inline-flex !important;
  }

  /* Account bar and drawer */
  html body .customer-console .account-sidebar > .account-sidebar-brand {
    min-height: 48px !important;
  }
  html body .customer-console #account-sidebar-toggle.account-sidebar-toggle {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
  }
  html body .customer-console #account-drawer-close.account-drawer-close {
    width: 48px !important;
    height: 48px !important;
  }
  html body .customer-console .account-sidebar .account-hub-item {
    min-height: 48px !important;
    padding-block: 10px !important;
    font-size: 14px !important;
  }
  html body .customer-console .account-sidebar .account-sidebar-action,
  html body .customer-console .account-sidebar :is(#account-sidebar-refresh, #account-sidebar-language, #account-hub-logout) {
    height: auto !important;
    min-height: 48px !important;
    font-size: 14px !important;
  }
  html body .customer-console .account-sidebar .account-sidebar-action:focus-visible,
  html body .customer-console .account-sidebar .account-hub-item:focus-visible,
  html body .customer-console #account-drawer-close:focus-visible {
    outline: 3px solid #1D4ED8 !important;
    outline-offset: 2px !important;
  }

  /* Drawer group labels ("الشركة والحساب"): were 10px #94A3B8 (2.6:1) */
  html body .customer-console .account-sidebar .account-nav-group {
    color: #64748B !important;       /* 4.76:1 on white */
    font-size: 12px !important;
    font-weight: 700 !important;
  }

  /* Spacing: one 16px rhythm between stacked blocks */
  html body .customer-console .overview-heading {
    margin-bottom: 16px !important;
  }
  html body .customer-console :is(.account-attention, .overview-stats) {
    margin-bottom: 16px !important;
  }
  html body .customer-console .overview-grid,
  html body .customer-console .overview-side {
    gap: 16px !important;
  }
  html body .customer-console :is(.overview-grid, .overview-side) > .panel {
    margin: 0 !important;
  }
  html body .customer-console .account-content .section-head {
    margin-bottom: 12px !important;
  }
  html body .customer-console .account-content .overview-activity > a {
    padding-block: 12px !important;
  }
}

/* ── Header alignment & mobile search (≤900px) ─────────────────────────
 * Root cause: an all-widths !important rule sets the header grid to
 * minmax(120px,168px) minmax(200px,1fr) auto, which beats the mobile grids
 * and pushes the actions (and the menu button) off-screen on narrow phones.
 * The search grid's button column was 40px while the button is a 48px touch
 * target, so it spilled out of the field; the pickers could not shrink.
 * Header gutter now matches .wrap (28px, 20px at ≤760px).
 */
@media (max-width: 900px) {
  html body #header.lot4b-header .lot4b-header-top {
    grid-template-columns: auto minmax(0, 1fr) !important;
    padding-inline: 28px !important;
  }
  html body #header.lot4b-header .lot4b-header-actions {
    min-width: 0 !important;
    justify-content: flex-end !important;
  }
  /* Keep the 48px touch target but put the glyph on the outer edge */
  html body #header.lot4b-header .lot4b-header-actions .menu {
    place-items: center end !important;
  }
  html body #header.lot4b-header .lot4b-header-search {
    grid-template-columns: minmax(0, 1fr) 130px 110px 48px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  html body #header.lot4b-header .lot4b-header-search .lot4b-search-button {
    width: 48px !important;
    height: 48px !important;
    justify-self: center !important;
    align-self: center !important;
  }
}
@media (max-width: 760px) {
  html body #header.lot4b-header .lot4b-header-top {
    padding-inline: 20px !important;
  }
}
@media (max-width: 520px) {
  html body #header.lot4b-header .lot4b-header-search {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px !important;
    column-gap: 4px !important;
  }
  html body #header.lot4b-header .lot4b-header-search :is(.lot4b-search-picker, .lot4b-picker-trigger) {
    min-width: 0 !important;
  }
  html body #header.lot4b-header .lot4b-header-search .lot4b-picker-trigger > span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

