/* TradeInvoice V9.4.0 — mobile layout and scrolling correction.
   This file is loaded after all theme styles so the mobile rules win consistently. */
@media (max-width: 900px) {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }
  /* Let the document scroll naturally on phones. The previous fixed 100dvh
     body + nested scroll pane caused the lower part of pages to feel clipped. */
  html,
  html body,
  html body[data-authenticated="1"] {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body[data-authenticated="1"] {
    position: static !important;
    min-height: 100dvh !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Compact, single-row business header. */
  html body > header.global-header {
    position: sticky !important;
    inset: 0 0 auto 0 !important;
    z-index: 1100 !important;
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 62px !important;
    min-height: 62px !important;
    max-height: 62px !important;
    margin: 0 !important;
    padding: 0 9px !important;
    overflow: visible !important;
  }

  html body .global-brand {
    display: flex !important;
    flex: 0 1 auto !important;
    align-items: center !important;
    min-width: 0 !important;
    max-width: 44vw !important;
    overflow: hidden !important;
    gap: 0 !important;
  }

  html body .global-brand img {
    display: block !important;
    width: clamp(118px, 36vw, 148px) !important;
    max-width: 100% !important;
    height: 43px !important;
    min-height: 0 !important;
    max-height: 43px !important;
    object-fit: contain !important;
    object-position: left center !important;
  }

  html body .brand-divider,
  html body .brand-descriptor,
  html body .business-chip {
    display: none !important;
  }

  html body .global-header-right {
    display: flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 5px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 56vw !important;
  }

  html body .sidebar-toggle {
    display: inline-grid !important;
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    font-size: 17px !important;
  }

  html body .global-search {
    display: flex !important;
    flex: 0 1 clamp(52px, 16vw, 70px) !important;
    width: clamp(52px, 16vw, 70px) !important;
    min-width: 52px !important;
    max-width: 70px !important;
    height: 34px !important;
    min-height: 34px !important;
    gap: 3px !important;
    padding: 0 5px !important;
    overflow: hidden !important;
  }

  html body .global-search .search-glyph {
    flex: 0 0 auto !important;
    font-size: 17px !important;
  }

  html body .global-search input {
    display: block !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 0 !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
    text-overflow: clip !important;
  }

  html body .global-search button {
    display: none !important;
  }

  html body .header-notification {
    display: grid !important;
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    height: 34px !important;
    font-size: 19px !important;
  }

  html body .header-user {
    display: flex !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  html body .header-user-trigger {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    min-width: 30px !important;
    padding: 0 !important;
  }

  html body .header-avatar {
    display: grid !important;
    flex: 0 0 30px !important;
    width: 30px !important;
    height: 30px !important;
  }

  html body .header-user-meta,
  html body .header-user-menu {
    display: none !important;
  }

  /* Mobile navigation stays a drawer; it must not consume page width. */
  html body > aside#appSidebar.app-sidebar {
    position: fixed !important;
    inset: 62px auto 0 0 !important;
    width: min(282px, 84vw) !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transform: translateX(-105%) !important;
    -webkit-overflow-scrolling: touch;
    z-index: 1090 !important;
  }

  html body.sidebar-open > aside#appSidebar.app-sidebar {
    transform: translateX(0) !important;
  }

  html body > .sidebar-backdrop {
    position: fixed !important;
    inset: 62px 0 0 !important;
    z-index: 1080 !important;
  }

  html body > .profile-drawer-backdrop {
    position: fixed !important;
    inset: 62px 0 0 !important;
    z-index: 1110 !important;
  }

  html body > aside#profileDropdown.header-user-dropdown {
    position: fixed !important;
    top: 68px !important;
    right: 8px !important;
    left: auto !important;
    width: min(310px, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 82px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    z-index: 1120 !important;
  }

  /* Main content is back in normal document flow and scrolls with the page. */
  html body[data-authenticated="1"] > main.app-main {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: calc(100svh - 62px) !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    overscroll-behavior: auto !important;
  }

  html body .app-page-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 14px 12px calc(30px + env(safe-area-inset-bottom, 0px)) !important;
    overflow: visible !important;
  }

  /* The empty ad placeholder was leaving a large blank band above the
     dashboard cards on mobile. Ads remain unchanged on desktop. */
  html body .app-page-container > .google-ad-slot,
  html body .app-page-container > .dashboard-ad {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
  }

  /* Keep cards, dashboard grids and long content inside the phone width. */
  html body .app-page-container > *,
  html body .app-main .row,
  html body .app-main [class*="col-"],
  html body .card,
  html body .metric-tile,
  html body .panel-card,
  html body .dashboard-intro,
  html body .dashboard-metrics {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  html body .app-main .row {
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  html body .app-main .row > [class*="col-"] {
    padding-right: 6px !important;
    padding-left: 6px !important;
  }

  html body .table-responsive {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  html body svg,
  html body canvas,
  html body img {
    max-width: 100%;
  }

  /* Public login, registration and OTP pages: no forced vertical centering,
     no ad gap, and natural scroll all the way to the submit button. */
  html body.auth-page {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  html body.auth-page > header.public-brand {
    position: relative !important;
    display: flex !important;
    width: 100% !important;
    height: 66px !important;
    min-height: 66px !important;
    max-height: 66px !important;
    padding: 6px 12px !important;
    overflow: hidden !important;
  }

  html body.auth-page > header.public-brand > a {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html body.auth-page > header.public-brand img {
    display: block !important;
    flex: 0 1 auto !important;
    width: clamp(132px, 44vw, 180px) !important;
    max-width: 58% !important;
    height: 46px !important;
    max-height: 46px !important;
    object-fit: contain !important;
  }

  html body.auth-page > header.public-brand span {
    display: block !important;
    flex: 0 1 105px !important;
    min-width: 0 !important;
    max-width: 105px !important;
    padding: 0 0 0 8px !important;
    border-left: 1px solid var(--v9-line) !important;
    font-size: clamp(7px, 2.1vw, 9px) !important;
    line-height: 1.25 !important;
    letter-spacing: .035em !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
  }

  html body.auth-page > main.public-main {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html body.auth-page > main.public-main > .app-page-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 auto !important;
    padding: 14px 12px calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    overflow: visible !important;
  }

  html body.auth-page .app-page-container > .google-ad-slot,
  html body.auth-page .app-page-container > .ad-slot {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  html body.auth-page .auth-card {
    display: block !important;
    width: 100% !important;
    max-width: 540px !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    padding: 18px 16px !important;
    overflow: visible !important;
  }

  html body.auth-page .auth-card h1,
  html body.auth-page .auth-card h2 {
    font-size: clamp(1.35rem, 5vw, 1.75rem) !important;
    line-height: 1.2 !important;
    overflow-wrap: anywhere !important;
  }

  html body.auth-page .auth-card p,
  html body.auth-page .auth-card .form-label {
    overflow-wrap: anywhere !important;
  }

  html body.auth-page .auth-card form,
  html body.auth-page .auth-card .form-control,
  html body.auth-page .auth-card .form-select,
  html body.auth-page .auth-card .btn {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  html body.auth-page .auth-card .btn {
    min-height: 48px !important;
    white-space: normal !important;
  }

  /* Give page sections breathing room without creating a fixed-height crop. */
  html body .dashboard-intro {
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    gap: 12px !important;
    margin-top: 0 !important;
  }

  html body .metric-tile {
    width: 100% !important;
    min-height: 94px !important;
    padding: 14px !important;
  }
}

@media (max-width: 380px) {
  html body > header.global-header {
    gap: 4px !important;
    padding-right: 7px !important;
    padding-left: 7px !important;
  }

  html body .global-brand img {
    width: 118px !important;
  }

  html body .global-header-right {
    gap: 4px !important;
  }

  html body .global-search {
    width: 54px !important;
    flex-basis: 54px !important;
    min-width: 54px !important;
    padding-right: 4px !important;
    padding-left: 4px !important;
  }

  html body .header-notification {
    flex-basis: 28px !important;
    width: 28px !important;
    min-width: 28px !important;
  }

  html body.auth-page .auth-card {
    padding: 16px 13px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .app-sidebar,
  html body .sidebar-backdrop {
    transition: none !important;
  }
}

/* V9.4.1: Keep the business overview heading visible on phone layouts. */
@media(max-width:600px){html body .dashboard-intro h1,html body .dashboard-intro h2{display:block!important;visibility:visible!important;opacity:1!important;max-height:none!important;overflow:visible!important;white-space:normal!important;}html body .dashboard-intro>div:first-child{display:block!important;width:100%!important;}html body .dashboard-intro .eyebrow{display:block!important;} }
