/* ============================================================
   EVP Portal — Mobile app shell (<768px)
   Pages opt in by setting ViewBag.MobileAppShell = true, which adds
   .mobile-appshell to <body> and renders _MobileTabbar.cshtml.
   Visual language follows the shipped /PPO/Add mobile wizard:
   purple primary #6f5bd3, #fbfaff canvas, 14px-radius cards,
   fixed bottom bars with safe-area padding.
   ============================================================ */

:root {
  --mas-primary: #6f5bd3;
  --mas-primary-light: rgba(111, 91, 211, .10);
  --mas-border-strong: rgba(111, 91, 211, .22);
  --mas-border: rgba(111, 91, 211, .14);
  --mas-text: #1f2450;
  --mas-muted: #8f88b7;
  --mas-tabbar-h: 68px;
}

/* Mobile-only chrome stays hidden on desktop */
.m-tabbar,
.m-home {
  display: none;
}

@media (max-width: 767.98px) {

  /* ---------- Shell swap: hide desktop chrome, free the canvas ---------- */
  body.mobile-appshell {
    background: #fbfaff;
  }

  /* The rail and the sidebar are two separate elements, and the backdrop belongs
     to the sidebar's off-canvas mode — hiding the rail alone leaves the menu
     itself on the page, which is what it did.
     The sidebar and its backdrop are only hidden while the drawer is closed.
     Anything that opens the drawer through the topbar's toggle also has app.js
     lock body scroll; hiding the drawer outright would leave the page
     scroll-locked with nothing on screen to close. */
  body.mobile-appshell .app-topbar,
  body.mobile-appshell .color-line,
  body.mobile-appshell .app-rail,
  html:not(.sidebar-enable) body.mobile-appshell .sidenav-menu,
  html:not(.sidebar-enable) body.mobile-appshell #custom-backdrop {
    display: none !important;
  }

  body.mobile-appshell .page-content {
    margin: 0 !important;
    padding: 0 0 calc(var(--mas-tabbar-h) + env(safe-area-inset-bottom, 0px)) !important;
    min-height: 100vh !important;
  }

  body.mobile-appshell .page-content > .page-container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 12px 14px 0 !important;
  }

  [data-bs-theme="dark"] body.mobile-appshell,
  html.ew-theme-dark body.mobile-appshell {
    background: #16141f;
  }

  /* On the dashboard the desktop widgets give way to the super-app home;
     modal wrappers stay untouched so announcement popups keep working. */
  body.mobile-appshell #dashboardHome .dh-welcome,
  body.mobile-appshell #dashboardHome .dh-ann,
  body.mobile-appshell #dashboardHome #performanceCard,
  body.mobile-appshell #dashboardHome #summaryGrid,
  body.mobile-appshell #dashboardHome .dh-main,
  body.mobile-appshell #dashboardHome .dh-agent {
    display: none !important;
  }

  /* PPO approval bulk bar must sit above the tab bar */
  body.mobile-appshell .ppoa-bulkbar {
    bottom: calc(var(--mas-tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px) !important;
  }

  /* ---------- Bottom tab bar ---------- */
  body.mobile-appshell .m-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--mas-border);
    box-shadow: 0 -8px 24px rgba(111, 91, 211, .10);
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-tabbar,
  html.ew-theme-dark body.mobile-appshell .m-tabbar {
    background: #211d30;
  }

  .m-tabbar .m-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0 2px;
    border: 0;
    background: none;
    color: var(--mas-muted);
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
    position: relative;
  }

  .m-tabbar .m-tab i {
    font-size: 21px;
    line-height: 1;
  }

  .m-tabbar .m-tab.active {
    color: var(--mas-primary);
  }

  .m-tabbar .m-tab-cta {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: 0;
    background: none;
    color: var(--mas-primary);
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
    /* "Find Document" stays on one line under the centre button. */
    white-space: nowrap;
  }

  .m-tabbar .m-tab-cta .cta-circle {
    width: 46px;
    height: 46px;
    margin-top: -20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #6f5bd3, #9b8cf0);
    color: #fff;
    font-size: 24px;
    box-shadow: 0 10px 24px rgba(111, 91, 211, .45);
    border: 3px solid #fff;
  }

  [data-bs-theme="dark"] .m-tabbar .m-tab-cta .cta-circle,
  html.ew-theme-dark .m-tabbar .m-tab-cta .cta-circle {
    border-color: #211d30;
  }

  .m-tabbar .m-tab .m-tab-dot {
    position: absolute;
    top: 2px;
    left: calc(50% + 6px);
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    display: grid;
    place-items: center;
  }

  /* ---------- Super-app home (Dashboard) ---------- */
  body.mobile-appshell .m-home {
    display: block;
  }

  .m-home .m-home-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 2px 12px;
  }

  .m-home .m-home-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6f5bd3, #9b8cf0);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    flex: 0 0 auto;
  }

  .m-home .m-home-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  .m-home .m-home-title h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--mas-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .m-home .m-home-title p {
    margin: 1px 0 0;
    font-size: 12px;
    color: var(--mas-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .m-home .m-home-bell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1.5px solid var(--mas-border-strong);
    background: #fff;
    color: var(--mas-primary);
    font-size: 17px;
    flex: 0 0 auto;
    position: relative;
  }

  [data-bs-theme="dark"] .m-home .m-home-bell,
  html.ew-theme-dark .m-home .m-home-bell {
    background: #211d30;
  }

  /* Supplier group button: green while a group is picked, in both themes. */
  .m-home .m-home-bell.m-home-group.is-selected,
  [data-bs-theme="dark"] .m-home .m-home-bell.m-home-group.is-selected,
  html.ew-theme-dark .m-home .m-home-bell.m-home-group.is-selected {
    border-color: #16a34a;
    background: #16a34a;
    color: #fff;
  }

  .m-home .m-home-bell .m-tab-dot {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: grid;
    place-items: center;
  }

  /* Hero */
  .m-home .m-hero {
    padding: 15px 16px 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #6f5bd3 0%, #9b8cf0 100%);
    color: #fff;
    margin-bottom: 12px;
  }

  .m-home .m-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .m-home .m-hero-top h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
  }

  .m-home .m-hero-top .m-hero-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    font-size: 10.5px;
    font-weight: 700;
  }

  .m-home .m-hero-links {
    display: flex;
    gap: 8px;
    margin-top: 13px;
  }

  .m-home .m-hero-link {
    flex: 1;
    padding: 10px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .14);
    text-decoration: none;
    color: #fff;
    text-align: center;
  }

  .m-home .m-hero-link i {
    font-size: 18px;
    line-height: 1;
  }

  .m-home .m-hero-link span {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
    opacity: .9;
  }

  .m-home .m-hero-link.is-alert {
    background: rgba(255, 255, 255, .92);
    color: var(--mas-primary);
  }

  /* Service sections */
  .m-home .m-svc-section {
    margin-bottom: 14px;
    padding: 14px 10px 4px;
    border: 1px solid var(--mas-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(111, 91, 211, .05);
  }

  [data-bs-theme="dark"] .m-home .m-svc-section,
  html.ew-theme-dark .m-home .m-svc-section {
    background: #211d30;
  }

  .m-home .m-svc-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 6px 4px;
  }

  .m-home .m-svc-head h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--mas-primary);
  }

  .m-home .m-svc-head span {
    font-size: 11px;
    font-weight: 700;
    color: var(--mas-muted);
  }

  .m-home .m-svc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .m-home .m-svc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 2px 12px;
    border: 0;
    background: none;
    text-decoration: none;
    color: var(--mas-text);
    text-align: center;
    position: relative;
    cursor: pointer;
  }

  .m-home .m-svc .m-svc-ico {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--mas-primary-light);
    color: var(--mas-primary);
    font-size: 20px;
  }

  .m-home .m-svc b {
    font-size: 10.5px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--mas-text);
  }

  [data-bs-theme="dark"] .m-home .m-svc b,
  html.ew-theme-dark .m-home .m-svc b,
  [data-bs-theme="dark"] .m-home .m-home-title h1,
  html.ew-theme-dark .m-home .m-home-title h1 {
    color: #e7e3f7;
  }

  .m-home .m-svc.is-teal .m-svc-ico { background: rgba(2, 192, 206, .12); color: #059aa5; }
  .m-home .m-svc.is-amber .m-svc-ico { background: #fef3c7; color: #b45309; }
  .m-home .m-svc.is-green .m-svc-ico { background: #d1fae5; color: #15803d; }
  .m-home .m-svc.is-rose .m-svc-ico { background: #ffe4e6; color: #be185d; }

  [data-bs-theme="dark"] .m-home .m-svc .m-svc-ico,
  html.ew-theme-dark .m-home .m-svc .m-svc-ico { background: rgba(111, 91, 211, .2); }
  [data-bs-theme="dark"] .m-home .m-svc.is-teal .m-svc-ico,
  html.ew-theme-dark .m-home .m-svc.is-teal .m-svc-ico { background: rgba(2, 192, 206, .18); color: #4dd4dd; }
  [data-bs-theme="dark"] .m-home .m-svc.is-amber .m-svc-ico,
  html.ew-theme-dark .m-home .m-svc.is-amber .m-svc-ico { background: rgba(245, 158, 11, .18); color: #fcd34d; }
  [data-bs-theme="dark"] .m-home .m-svc.is-green .m-svc-ico,
  html.ew-theme-dark .m-home .m-svc.is-green .m-svc-ico { background: rgba(21, 128, 61, .2); color: #86efac; }
  [data-bs-theme="dark"] .m-home .m-svc.is-rose .m-svc-ico,
  html.ew-theme-dark .m-home .m-svc.is-rose .m-svc-ico { background: rgba(190, 24, 93, .2); color: #f9a8d4; }
}

/* ============================================================
   Mobile listing kit (shared)
   The pieces the phone listings have in common, in the look of the
   PPO list: filter chips, the search / dropdown / action controls, and
   the document card. A page keeps its desktop table (hidden on a phone
   with .m-phone-hide) and draws these cards from the same rows.
   ============================================================ */

/* Phone-only blocks; a shell turns them on below. */
.m-phone-only {
  display: none;
}

@media (max-width: 767.98px) {
  body.mobile-appshell .m-phone-only {
    display: block;
  }

  body.mobile-appshell .m-phone-hide {
    display: none !important;
  }

  /* ---------- Filter chips ---------- */
  body.mobile-appshell .m-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    margin-bottom: 10px;
    padding: 1px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-appshell .m-chips::-webkit-scrollbar {
    display: none;
  }

  body.mobile-appshell .m-chips-label {
    flex: 0 0 auto;
    min-width: 46px;
    color: var(--mas-muted);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  body.mobile-appshell .m-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--mas-border-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--mas-text);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
  }

  body.mobile-appshell .m-chip.is-active {
    border-color: var(--mas-primary);
    background: var(--mas-primary);
    color: #fff;
  }

  /* ---------- Listing: search, dropdown filters, actions ----------
     The PPO list's controls as shared classes, for listings that draw their
     own cards (.m-doc-card below) rather than restyling a table. */
  body.mobile-appshell .m-list-search,
  body.mobile-appshell .m-list-select {
    min-height: 46px;
    border: 1px solid #dbe1ea;
    border-radius: .8rem;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .03);
  }

  body.mobile-appshell .m-list-search {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: 0 0 8px;
    padding: 0 .95rem;
  }

  body.mobile-appshell .m-list-search i {
    color: #7c58d3;
    font-size: 1rem;
  }

  /* 16px keeps iOS from zooming the page when the field takes focus. */
  body.mobile-appshell .m-list-search input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #475569;
    font-size: 16px;
  }

  body.mobile-appshell .m-list-selects {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 8px;
  }

  body.mobile-appshell .m-list-select {
    width: 100%;
    padding: 0 2rem 0 .85rem;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
  }

  body.mobile-appshell .m-list-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  body.mobile-appshell .m-list-actions .dropdown {
    flex: 1 1 auto;
    min-width: 0;
  }

  body.mobile-appshell .m-list-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--mas-primary);
    border-radius: 12px;
    background: var(--mas-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
  }

  body.mobile-appshell .m-list-btn i {
    font-size: 17px;
  }

  /* How many documents are ticked. */
  body.mobile-appshell .m-list-btn b {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .25);
    font-size: 11px;
    font-weight: 800;
  }

  body.mobile-appshell .m-list-btn.m-list-btn-ghost {
    flex: 0 0 auto;
    width: auto;
    border-color: var(--mas-border-strong);
    background: #fff;
    color: var(--mas-primary);
  }

  body.mobile-appshell .m-list-actions .dropdown-menu {
    width: 100%;
    min-width: 230px;
    padding: 6px;
    border-radius: 14px;
  }

  body.mobile-appshell .m-list-actions .dropdown-item {
    padding: 9px 10px;
    border-radius: 9px;
    color: var(--mas-text);
    font-size: 13px;
    font-weight: 700;
    white-space: normal;
  }

  body.mobile-appshell .m-list-actions .dropdown-item small {
    display: block;
    color: var(--mas-muted);
    font-size: 11.5px;
    font-weight: 500;
  }

  /* ---------- Document card ---------- */
  body.mobile-appshell .m-doc-card {
    margin-bottom: 10px;
    padding: 12px 13px 9px;
    border: 1px solid var(--mas-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(111, 91, 211, .05);
  }

  body.mobile-appshell .m-doc-card.is-selected {
    border-color: var(--mas-primary);
    box-shadow: 0 0 0 3px var(--mas-primary-light);
  }

  body.mobile-appshell .m-doc-top {
    display: flex;
    align-items: center;
    gap: 9px;
  }

  body.mobile-appshell .m-doc-check {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0;
  }

  body.mobile-appshell .m-doc-no {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--mas-text);
    font-size: 14px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-appshell .m-doc-top .badge {
    flex: 0 0 auto;
  }

  body.mobile-appshell .m-doc-sup {
    margin: 5px 0 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
  }

  body.mobile-appshell .m-doc-meta {
    display: flex;
    align-items: flex-start;
    gap: 4px 14px;
    color: #64748b;
    font-size: 12px;
  }

  body.mobile-appshell .m-doc-meta i {
    margin-right: 4px;
    color: var(--mas-primary);
    font-size: 14px;
    vertical-align: -2px;
  }

  body.mobile-appshell .m-doc-store {
    flex: 1 1 0;
    min-width: 0;
  }

  body.mobile-appshell .m-doc-date {
    flex: 0 0 auto;
    margin-left: auto;
    white-space: nowrap;
  }

  body.mobile-appshell .m-doc-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    margin-top: 9px;
    padding-top: 7px;
    border-top: 1px solid var(--mas-border);
  }

  body.mobile-appshell .m-doc-type {
    flex: 0 0 auto;
    padding: 3px 9px;
    border-radius: 8px;
    background: var(--mas-primary-light);
    color: var(--mas-primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .03em;
  }

  body.mobile-appshell .m-doc-amt {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--mas-text);
    font-size: 14px;
    font-weight: 800;
    text-align: right;
  }

  body.mobile-appshell .m-doc-pdf {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: var(--mas-primary-light);
    color: var(--mas-primary);
    font-size: 12px;
    font-weight: 800;
  }

  /* Extra label / value lines, for listings whose columns vary. */
  body.mobile-appshell .m-doc-facts {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--mas-border);
  }

  body.mobile-appshell .m-doc-facts > div {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    font-size: 12px;
  }

  body.mobile-appshell .m-doc-facts > div > span:first-child {
    flex: 0 0 auto;
    max-width: 45%;
    color: var(--mas-muted);
    font-weight: 600;
  }

  body.mobile-appshell .m-doc-facts > div > span:last-child,
  body.mobile-appshell .m-doc-facts > div > button {
    min-width: 0;
    color: #374151;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
  }

  /* A value that opens a linked document. */
  body.mobile-appshell .m-doc-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--mas-primary) !important;
    text-decoration: underline;
  }

  body.mobile-appshell .m-doc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 9px;
  }

  body.mobile-appshell .m-doc-actions .m-doc-pdf {
    flex: 1 1 0;
    justify-content: center;
    min-height: 38px;
    white-space: nowrap;
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-doc-facts {
    border-top-color: var(--highdmin-border-color);
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-doc-facts > div > span:last-child {
    color: var(--highdmin-body-color);
  }

  body.mobile-appshell .m-list-empty {
    padding: 34px 16px;
    border: 1px dashed var(--mas-border-strong);
    border-radius: 14px;
    background: #fff;
    color: var(--mas-muted);
    font-size: 13px;
    text-align: center;
  }

  body.mobile-appshell .m-list-empty strong {
    display: block;
    margin-bottom: 4px;
    color: var(--mas-text);
    font-size: 14px;
  }

  body.mobile-appshell .m-list-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 4px 0 8px;
    color: var(--mas-muted);
    font-size: 12px;
  }

  body.mobile-appshell .m-list-more {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--mas-border-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--mas-primary);
    font-size: 13px;
    font-weight: 800;
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-list-search,
  [data-bs-theme="dark"] body.mobile-appshell .m-list-select,
  [data-bs-theme="dark"] body.mobile-appshell .m-list-btn.m-list-btn-ghost,
  [data-bs-theme="dark"] body.mobile-appshell .m-doc-card,
  [data-bs-theme="dark"] body.mobile-appshell .m-list-empty,
  [data-bs-theme="dark"] body.mobile-appshell .m-list-more {
    border-color: var(--highdmin-border-color);
    background-color: var(--highdmin-secondary-bg);
    box-shadow: none;
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-list-search input,
  [data-bs-theme="dark"] body.mobile-appshell .m-list-select,
  [data-bs-theme="dark"] body.mobile-appshell .m-doc-no,
  [data-bs-theme="dark"] body.mobile-appshell .m-doc-sup,
  [data-bs-theme="dark"] body.mobile-appshell .m-doc-amt,
  [data-bs-theme="dark"] body.mobile-appshell .m-list-empty strong {
    color: var(--highdmin-body-color);
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-doc-meta {
    color: var(--highdmin-secondary-color);
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-doc-foot {
    border-top-color: var(--highdmin-border-color);
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-chip:not(.is-active) {
    border-color: var(--highdmin-border-color);
    background: var(--highdmin-secondary-bg);
    color: var(--highdmin-body-color);
  }
}

/* ============================================================
   Mobile sheet select (shared)
   A dropdown that opens as a sheet from the bottom of the screen on
   a phone. js/mobile-sheet-select.js lays a see-through button (the
   cover) over a <select> and builds the sheet; see that file.
   ============================================================ */

/* Off on desktop: the select is used directly there. */
.m-sheet-cover {
  display: none;
}

/* The wrapper the script adds around a select must not change the desktop
   layout it was dropped into, so it only becomes a box on a phone. */
.m-sheet-wrap {
  display: contents;
}

@media (max-width: 767.98px) {
  body.mobile-appshell .m-sheet-wrap {
    display: block;
    min-width: 0;
  }

  body.mobile-appshell .m-sheet-host {
    position: relative;
  }

  /* Above the select, including Bootstrap's focused input-group layer. */
  body.mobile-appshell .m-sheet-cover {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 6;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
  }
}

/* The sheet is only ever opened from a cover, so these need no width guard.
   It sits above the tab bar (1040), Bootstrap modals (1055) and the pages' own
   pop-ups (the Messages "new conversation" form is 1080), since a dropdown
   inside one of those opens the sheet over it. */
.m-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1094;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  transition: opacity .2s ease;
}

.m-sheet-backdrop.is-open {
  opacity: 1;
}

.m-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1095;
  display: flex;
  flex-direction: column;
  max-height: 72vh;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: #fff;
  box-shadow: 0 -10px 40px rgba(31, 36, 80, .18);
  transform: translateY(100%);
  transition: transform .22s ease;
}

.m-sheet.is-open {
  transform: none;
}

.m-sheet[hidden],
.m-sheet-backdrop[hidden],
.m-sheet-search[hidden] {
  display: none;
}

.m-sheet-grip {
  flex: 0 0 auto;
  width: 40px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 4px;
  background: rgba(111, 91, 211, .22);
}

.m-sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 8px;
}

.m-sheet-title {
  min-width: 0;
  overflow: hidden;
  color: #1f2450;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-sheet-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(111, 91, 211, .10);
  color: #6f5bd3;
  font-size: 19px;
}

/* 16px keeps iOS from zooming the page when the field takes focus. */
.m-sheet-search {
  flex: 0 0 auto;
  min-height: 44px;
  margin-bottom: 6px;
  padding: 0 14px;
  border: 1px solid #dbe1ea;
  border-radius: 12px;
  outline: 0;
  background: #fbfaff;
  color: #1f2450;
  font-size: 16px;
}

.m-sheet-options {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.m-sheet-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #1f2450;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}

.m-sheet-option.is-selected {
  background: rgba(111, 91, 211, .10);
  color: #6f5bd3;
  font-weight: 800;
}

.m-sheet-option i {
  flex: 0 0 auto;
  font-size: 20px;
}

.m-sheet-option:disabled {
  color: #9ca3af;
}

.m-sheet-none {
  padding: 22px 12px;
  color: #8f88b7;
  font-size: 13px;
  text-align: center;
}

[data-bs-theme="dark"] .m-sheet {
  background: #211d30;
}

[data-bs-theme="dark"] .m-sheet-title,
[data-bs-theme="dark"] .m-sheet-option {
  color: #e7e3f7;
}

[data-bs-theme="dark"] .m-sheet-option.is-selected {
  color: #a78bfa;
}

[data-bs-theme="dark"] .m-sheet-search {
  border-color: rgba(255, 255, 255, .14);
  background: #16141f;
  color: #e7e3f7;
}

@media (prefers-reduced-motion: reduce) {
  .m-sheet,
  .m-sheet-backdrop {
    transition: none;
  }
}

/* ============================================================
   Mobile sub-page header (shared)
   Pages that opt into the app shell lose the desktop topbar on
   phones, so each sub-page carries its own back bar.
   ============================================================ */

.m-subhead {
  display: none;
}

@media (max-width: 767.98px) {
  body.mobile-appshell .m-subhead {
    display: block;
    position: sticky;
    top: 0;
    z-index: 30;
    /* Full-bleed over the .page-container's 12px/14px padding */
    margin: -12px -14px 12px;
    padding: 14px 16px 10px;
    background: #fbfaff;
  }

  [data-bs-theme="dark"] body.mobile-appshell .m-subhead,
  html.ew-theme-dark body.mobile-appshell .m-subhead {
    background: #16141f;
  }
}

/* The row's own styling is not width-scoped: .m-subhead is display:none until a
   shell turns it on, so these are inert everywhere else — and the FreshOps shell,
   which shows the bar at any width, reuses them instead of keeping a second copy. */
.m-subhead .m-subhead-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.m-subhead .m-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--mas-border-strong);
  background: #fff;
  color: var(--mas-primary);
  font-size: 17px;
  flex: 0 0 auto;
  text-decoration: none;
}

[data-bs-theme="dark"] .m-subhead .m-iconbtn,
html.ew-theme-dark .m-subhead .m-iconbtn {
  background: #211d30;
}

.m-subhead .m-subhead-title {
  flex: 1 1 auto;
  min-width: 0;
}

.m-subhead .m-subhead-title h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--mas-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-subhead .m-subhead-title p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--mas-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-bs-theme="dark"] .m-subhead .m-subhead-title h1,
html.ew-theme-dark .m-subhead .m-subhead-title h1 {
  color: #e7e3f7;
}

.m-subhead .m-subhead-spacer {
  width: 38px;
  flex: 0 0 auto;
}

/* ============================================================
   Me / Settings page (/Profile/Me)
   Phone-first, but readable on desktop too where the normal
   topbar is still present and .m-subhead stays hidden.
   ============================================================ */

.m-settings {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 24px;
}

.m-settings .m-set-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #6f5bd3 0%, #9b8cf0 100%);
  color: #fff;
}

.m-settings .m-set-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .22);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.m-settings .m-set-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.m-settings .m-set-id {
  flex: 1 1 auto;
  min-width: 0;
}

.m-settings .m-set-id h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-settings .m-set-id p {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, .85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-settings .m-set-id .m-set-role {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.m-settings .m-set-group {
  margin-bottom: 14px;
  padding: 4px 0;
  border: 1px solid var(--mas-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(111, 91, 211, .05);
  overflow: hidden;
}

[data-bs-theme="dark"] .m-settings .m-set-group,
html.ew-theme-dark .m-settings .m-set-group {
  background: #211d30;
}

.m-settings .m-set-group-title {
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--mas-primary);
}

.m-settings .m-set-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--mas-border);
  background: none;
  color: var(--mas-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.m-settings .m-set-item:first-of-type {
  border-top: 0;
}

.m-settings .m-set-item:active {
  background: var(--mas-primary-light);
}

.m-settings .m-set-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--mas-primary-light);
  color: var(--mas-primary);
  font-size: 19px;
}

.m-settings .m-set-item.is-teal .m-set-ico { background: rgba(2, 192, 206, .12); color: #059aa5; }
.m-settings .m-set-item.is-amber .m-set-ico { background: #fef3c7; color: #b45309; }

.m-settings .m-set-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.m-settings .m-set-copy b {
  display: block;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--mas-text);
}

.m-settings .m-set-copy small {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--mas-muted);
}

[data-bs-theme="dark"] .m-settings .m-set-copy b,
html.ew-theme-dark .m-settings .m-set-copy b {
  color: #e7e3f7;
}

.m-settings .m-set-chev {
  flex: 0 0 auto;
  color: var(--mas-muted);
  font-size: 18px;
}

.m-settings .m-set-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid rgba(220, 53, 69, .28);
  border-radius: 14px;
  background: rgba(220, 53, 69, .07);
  color: #dc3545;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.m-settings .m-set-logout i {
  font-size: 18px;
}

.m-settings .m-set-foot {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--mas-muted);
}

/* ============================================================
   FreshOps shell (shared /FreshOps link)
   The mobile app shell above is a phone treatment: everything it
   swaps lives inside a max-width:767.98px query, and above that the
   portal chrome comes back. A session that arrived through the
   shared link has to keep the shell at every width — the link gets
   opened on tablets and laptops, and the tab bar is the only
   navigation those sessions have. These rules are the same swap,
   unconditioned on width, plus a phone-width column so a desk
   browser gets the app rather than a stretched one.
   ============================================================ */

body.freshops-shell {
  background: #fbfaff;
}

[data-bs-theme="dark"] body.freshops-shell,
html.ew-theme-dark body.freshops-shell {
  background: #16141f;
}

body.freshops-shell .app-topbar,
body.freshops-shell .color-line,
body.freshops-shell .app-rail,
body.freshops-shell .sidenav-menu,
body.freshops-shell #custom-backdrop {
  display: none !important;
}

/* No tab bar in this shell, so nothing to reserve at the foot beyond the
   device's own safe area. */
body.freshops-shell .page-content {
  margin: 0 !important;
  padding: 0 0 env(safe-area-inset-bottom, 0px) !important;
  min-height: 100vh !important;
}

body.freshops-shell .page-content > .page-container {
  max-width: 560px !important;
  margin: 0 auto !important;
  padding: 12px 14px 0 !important;
}

/* The bar renders at every width here, so it carries its own layout rather than
   the width-scoped copy above. */
body.freshops-shell .m-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--mas-border);
  box-shadow: 0 -8px 24px rgba(111, 91, 211, .10);
}

[data-bs-theme="dark"] body.freshops-shell .m-tabbar,
html.ew-theme-dark body.freshops-shell .m-tabbar {
  background: #211d30;
}

body.freshops-shell .m-tabbar .m-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 2px;
  border: 0;
  background: none;
  color: var(--mas-muted);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  position: relative;
}

body.freshops-shell .m-tabbar .m-tab i {
  font-size: 21px;
  line-height: 1;
}

body.freshops-shell .m-tabbar .m-tab.active {
  color: var(--mas-primary);
}

/* The sub-page back bar (Me, My Profile, Change Password) is phone-scoped for the
   same reason as the rest; its inner styling is shared, so only the container. */
body.freshops-shell .m-subhead {
  display: block;
  position: sticky;
  top: 0;
  z-index: 30;
  margin: -12px -14px 12px;
  padding: 14px 16px 10px;
  background: #fbfaff;
}

[data-bs-theme="dark"] body.freshops-shell .m-subhead,
html.ew-theme-dark body.freshops-shell .m-subhead {
  background: #16141f;
}
