/* Legacy portal mobile contract extracted from styles.css during R214. New mobile UI belongs in tokenized assets. */
/* PRE-QA R189: single client profile tablet/mobile contract, no duplicated responsive layers. */
@media (max-width: 1100px) {
  body.portal-page #profile-section,
  body.portal-page .portal-profile-section {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow-x: hidden !important;
  }

  body.portal-page #portal-profile-dashboard > aside.portal-sidebar,
  body.portal-page #portal-profile-dashboard .portal-sidebar {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.portal-page #portal-profile-dashboard > main.portal-main,
  body.portal-page #portal-profile-dashboard .portal-main {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: block !important;
    overflow: hidden !important;
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    background: var(--surface) !important;
  }

  body.portal-page #portal-profile-dashboard .mobile-top {
    display: block !important;
    padding: 10px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--line) !important;
    border-radius: 0 !important;
    background: var(--surface) !important;
  }

  body.portal-page #portal-profile-dashboard .mobile-profile-row {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) 38px 38px !important;
    gap: 8px !important;
    align-items: center !important;
    min-width: 0 !important;
  }

  body.portal-page #portal-profile-dashboard .mobile-profile-row .avatar-large {
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
    font-size: 22px !important;
  }

  body.portal-page #portal-profile-dashboard .mobile-profile-row h1 {
    margin: 0 !important;
    max-width: 100% !important;
    color: var(--ink) !important;
    font-size: 17px !important;
    line-height: 1.12 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
  }

  body.portal-page #portal-profile-dashboard .mobile-profile-row .profile-pills {
    min-width: 0 !important;
    margin-top: 4px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
  }

  body.portal-page #portal-profile-dashboard .mobile-profile-row .pill {
    max-width: 100% !important;
    min-height: 22px !important;
    padding: 0 7px !important;
    border: 1px solid var(--line) !important;
    background: var(--surface-soft) !important;
    color: var(--muted) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 11px !important;
    line-height: 20px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-notification-bell,
  body.portal-page #portal-profile-dashboard .portal-mobile-logout {
    color: var(--ink) !important;
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
  }

  body.portal-page #portal-profile-dashboard .portal-header {
    display: block !important;
    min-height: 0 !important;
    padding: 10px !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--line) !important;
  }

  body.portal-page #portal-profile-dashboard .portal-header-copy,
  body.portal-page #portal-profile-dashboard #portal-document-preview {
    display: none !important;
  }

  body.portal-page #portal-profile-dashboard .portal-header-loyalty-card {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 72px !important;
    gap: 6px 10px !important;
    min-height: 0 !important;
    padding: 10px !important;
    border-radius: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-header-loyalty-card .portal-qr-mark {
    width: 72px !important;
    height: 72px !important;
    margin: 0 !important;
  }

  body.portal-page #portal-profile-dashboard .portal-tabs {
    display: none !important;
  }

  body.portal-page #portal-profile-dashboard .portal-overview-grid,
  body.portal-page #portal-profile-dashboard .document-grid,
  body.portal-page #portal-profile-dashboard .portal-settings-grid,
  body.portal-page #portal-profile-dashboard .portal-channel-preferences-grid {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin: 0 !important;
  }

  body.portal-page #portal-profile-dashboard .level-grid {
    grid-template-columns: repeat(3, minmax(104px, 1fr)) !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 2px !important;
    scrollbar-width: thin !important;
  }

  body.portal-page #portal-profile-dashboard .level-item {
    min-width: 104px !important;
    padding: 10px 8px !important;
    border-radius: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .level-item span {
    display: block !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    line-height: 1.25 !important;
  }

  body.portal-page #portal-profile-dashboard :where(.card,.panel-card,.portal-aside-card,.portal-settings-card,.level-card,.stat-card) {
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 10px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
  }

  body.portal-page #portal-profile-dashboard .portal-workspace-head,
  body.portal-page #portal-profile-dashboard .portal-document-status-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-workspace-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-workspace-tabs button {
    min-width: 0 !important;
    min-height: 34px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-profile-case-preview {
    margin-top: 10px !important;
    padding: 12px !important;
    border-radius: 8px !important;
    background: var(--surface) !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-head {
    grid-template-columns: 40px minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: start !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-device {
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
    font-size: 16px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-head h3 {
    margin: 1px 0 !important;
    font-size: 16px !important;
    line-height: 1.18 !important;
    overflow-wrap: anywhere !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-head p {
    display: -webkit-box !important;
    margin: 0 !important;
    overflow: hidden !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-head .portal-case-status-pill {
    grid-column: 2 !important;
    justify-self: start !important;
    max-width: 100% !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-top: 10px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-meta span {
    padding: 8px !important;
    border-radius: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-progress {
    grid-template-columns: repeat(7, minmax(22px, 1fr)) !important;
    gap: 4px !important;
    margin: 12px 0 !important;
    padding-top: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-progress::before,
  body.portal-page #portal-profile-dashboard .profile-case-preview-progress > i,
  body.portal-page #portal-profile-dashboard .profile-case-preview-progress > progress.portal-progress-profile {
    top: 19px !important;
    height: 3px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-progress span {
    width: 24px !important;
    height: 24px !important;
    font-size: 10px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-grid article {
    padding: 10px !important;
    border-radius: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-top: 10px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-actions .btn {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 38px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-row {
    grid-template-columns: 38px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 9px !important;
    align-items: start !important;
  }

  body.portal-page #portal-profile-dashboard .portal-device-thumb {
    grid-column: 1 !important;
    grid-row: 1 / span 5 !important;
    width: 38px !important;
    height: 38px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-main,
  body.portal-page #portal-profile-dashboard .portal-status-pill,
  body.portal-page #portal-profile-dashboard .portal-case-mini-code,
  body.portal-page #portal-profile-dashboard .portal-case-mini-money,
  body.portal-page #portal-profile-dashboard .portal-case-mini-action {
    grid-column: 2 !important;
    min-width: 0 !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-main :where(b,span,small) {
    overflow-wrap: anywhere !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-code,
  body.portal-page #portal-profile-dashboard .portal-case-mini-money {
    grid-row: 3 !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-code {
    justify-self: start !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-money {
    justify-self: end !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-action {
    grid-row: 4 !important;
    width: calc(50% - 4px) !important;
    min-height: 34px !important;
    justify-self: start !important;
    padding: 0 8px !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-chat-action {
    justify-self: end !important;
  }

  body.portal-page .app-mobile-nav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 95 !important;
    min-height: calc(64px + env(safe-area-inset-bottom)) !important;
    height: auto !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
    border-top: 1px solid var(--line) !important;
    background: var(--surface) !important;
  }

  body.portal-page .app-mobile-nav :where(button,a) {
    min-width: 0 !important;
    width: 100% !important;
    min-height: 50px !important;
    padding: 0 2px !important;
    display: grid !important;
    grid-template-rows: 22px auto !important;
    place-items: center !important;
    gap: 2px !important;
    border-radius: 8px !important;
    white-space: normal !important;
  }
}

@media (max-width: 520px) {
  body.portal-page #portal-profile-dashboard .portal-header-loyalty-card {
    grid-template-columns: 1fr !important;
  }

  body.portal-page #portal-profile-dashboard .portal-header-loyalty-card .portal-qr-mark {
    width: 86px !important;
    height: 86px !important;
    justify-self: start !important;
  }

  body.portal-page #portal-profile-dashboard .level-grid {
    grid-template-columns: 1fr !important;
    overflow: visible !important;
    padding-bottom: 0 !important;
  }

  body.portal-page #portal-profile-dashboard .level-item {
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr) !important;
    align-items: center !important;
    min-width: 0 !important;
    text-align: left !important;
    gap: 8px !important;
  }

  body.portal-page #portal-profile-dashboard .profile-case-preview-meta,
  body.portal-page #portal-profile-dashboard .profile-case-preview-actions {
    grid-template-columns: 1fr !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-mini-action {
    width: 100% !important;
    justify-self: stretch !important;
  }

  body.portal-page #portal-profile-dashboard .portal-case-chat-action {
    grid-row: 5 !important;
    justify-self: stretch !important;
  }
}

/* PRE-QA R190: client profile mobile chrome is state-driven, not visible on the login screen. */
body.portal-page #profile-section .app-mobile-nav[hidden] {
  display: none !important;
}

/* R300: one mobile owner for the client-profile bottom navigation. */
@media (max-width: 760px) {
  body.portal-page .app-mobile-nav {
    align-items: stretch !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain !important;
    scrollbar-width: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  body.portal-page .app-mobile-nav::-webkit-scrollbar {
    display: none !important;
  }

  body.portal-page .app-mobile-nav button,
  body.portal-page .app-mobile-nav a {
    min-width: 0 !important;
    width: 100% !important;
    min-height: 50px !important;
    display: grid !important;
    grid-template-rows: 22px auto !important;
    justify-items: center !important;
    align-content: center !important;
    gap: 2px !important;
    padding: 0 2px !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--muted) !important;
    font-size: 12px !important;
    font-weight: 750 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    white-space: normal !important;
  }

  body.portal-page .app-mobile-nav button.is-active:not(.mobile-nav-action),
  body.portal-page .app-mobile-nav button.active:not(.mobile-nav-action) {
    border-color: color-mix(in srgb, var(--primary) 22%, var(--line)) !important;
    background: color-mix(in srgb, var(--primary) 8%, var(--surface)) !important;
    color: var(--primary) !important;
  }

  body.portal-page .app-mobile-nav button.mobile-nav-action {
    border-color: var(--line) !important;
    border-radius: 12px !important;
    background: var(--surface) !important;
    color: var(--primary) !important;
    font-weight: 800 !important;
  }

  body.portal-page .app-mobile-nav button.mobile-nav-action.is-primary {
    border-color: var(--primary) !important;
    background: var(--primary) !important;
    color: #fff !important;
  }

  body.portal-page .app-mobile-nav svg {
    width: 20px !important;
    height: 20px !important;
  }
}

@media (max-width: 720px) {
  body.portal-page.portal-profile-authenticated .cookie-banner {
    bottom: calc(78px + env(safe-area-inset-bottom)) !important;
    max-height: min(42vh, 320px);
    overflow: auto;
  }
}
