/* v40: desktop alignment and resilient mobile portal layouts. */

.portal-menu-toggle,
.portal-menu-close,
.portal-menu-scrim {
  display: none;
}

/* Keep the Stripe status panel aligned to the combined plan-card width. */
.portal-main .billing-note {
  width: min(960px, 100%);
  max-width: 960px;
  margin-inline: auto;
}

/* The builder and history share one desktop row, then stack naturally. */
.campaign-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.portal-main .campaign-workspace > .campaign-builder,
.portal-main .campaign-workspace > .campaign-history {
  min-width: 0;
  margin: 0;
}
.campaign-workspace .glass-table {
  max-width: 100%;
}

@media (max-width: 1180px) {
  .campaign-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  html,
  body.portal-page,
  body.cp-auth-page {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* The business portal uses a real off-canvas menu on phones. */
  .portal-layout {
    display: block !important;
    min-width: 0;
  }
  .portal-main {
    grid-column: auto !important;
    width: 100%;
    min-width: 0;
  }
  .portal-main > header {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 64px;
    height: auto;
    padding: 10px 14px !important;
    gap: 11px;
    background: rgba(255, 252, 253, .96);
  }
  .portal-main > header > div:first-of-type {
    min-width: 0;
    flex: 1;
  }
  .portal-main > header > div:last-child {
    flex: 0 0 auto;
  }
  .portal-menu-toggle {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid rgba(126, 77, 98, .16);
    border-radius: 13px;
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 6px 18px rgba(72, 39, 55, .08);
    display: grid;
    align-content: center;
    gap: 4px;
  }
  .portal-menu-toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: #553244;
  }
  .portal-nav {
    display: flex !important;
    position: fixed !important;
    z-index: 80;
    inset: 0 auto 0 0 !important;
    width: min(310px, 86vw) !important;
    height: 100dvh;
    padding: 20px 14px !important;
    transform: translateX(-104%);
    transition: transform .18s ease !important;
    overflow-y: auto;
  }
  .portal-menu-open .portal-nav {
    transform: translateX(0);
  }
  .portal-menu-close {
    display: grid;
    position: absolute;
    z-index: 2;
    top: 13px;
    right: 12px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 12px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    place-items: center;
  }
  .portal-menu-scrim {
    display: block;
    position: fixed;
    z-index: 70;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(40, 22, 32, .48);
    opacity: 0;
    pointer-events: none;
  }
  .portal-menu-open .portal-menu-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  body.portal-nav-open {
    overflow: hidden;
  }
  .portal-nav .portal-brand {
    display: block;
    padding-right: 44px;
  }
  .portal-nav .portal-logo {
    display: block !important;
    width: 188px !important;
    height: 48px !important;
    margin: 0 7px 18px;
  }
  .portal-nav .studio-chip {
    display: flex;
    padding: 10px;
  }
  .portal-nav .studio-chip span,
  .portal-nav nav span,
  .portal-nav .nav-user b,
  .portal-nav .nav-user small {
    display: block !important;
  }
  .portal-nav nav {
    display: grid;
    width: 100%;
  }
  .portal-nav nav a {
    justify-content: flex-start !important;
    padding: 11px 12px;
  }
  .portal-nav .nav-user button {
    display: grid;
  }
  .portal-content {
    width: 100%;
    min-width: 0;
    padding: 16px 14px 42px !important;
  }
  .portal-content > *,
  .portal-content section,
  .portal-content article,
  .portal-content form,
  .portal-content div {
    min-width: 0;
  }

  /* Reports: no fixed desktop tracks or overlapping values on small screens. */
  .portal-main .report-head,
  .portal-main .report-filter,
  .portal-main .report-filter form {
    width: 100%;
    min-width: 0;
    align-items: stretch;
  }
  .portal-main .report-head {
    gap: 16px;
  }
  .portal-main .report-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .portal-main .report-actions > * {
    width: 100%;
    padding-inline: 8px;
  }
  .portal-main .report-filter {
    padding: 20px;
    gap: 20px;
  }
  .portal-main .report-filter > div {
    min-width: 0;
  }
  .portal-main .report-filter form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .portal-main .report-filter input,
  .portal-main .report-filter button {
    width: 100%;
  }
  .portal-main .report-summary-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .portal-main .report-lead,
  .portal-main .metric-card {
    min-height: 0;
    padding: 18px;
  }
  .portal-main .report-lead strong,
  .portal-main .metric-card strong {
    overflow-wrap: anywhere;
  }
  .portal-main .report-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }
  .portal-main .mini-metric {
    min-height: 76px;
    padding: 12px;
  }
  .portal-main .report-detail-grid {
    grid-template-columns: 1fr !important;
  }
  .portal-main .report-panel {
    padding: 20px;
  }

  /* Mobile Chrome/Edge: isolate the photo to the hero and use solid surfaces
     below it, avoiding the striped GPU-compositing artifact. */
  .cp-auth-page {
    background: #f2e7eb !important;
  }
  .cp-auth {
    display: flex !important;
    flex-direction: column;
    min-height: 100svh;
    padding: 0 !important;
    background: #f2e7eb !important;
  }
  .cp-auth-story {
    position: relative;
    min-height: 430px;
    padding: 36px 26px 72px !important;
    overflow: hidden;
    isolation: isolate;
    background:
      linear-gradient(180deg, rgba(53, 28, 41, .26), rgba(55, 29, 43, .76)),
      url('/static/portal-wallpaper.png') center / cover no-repeat;
  }
  .cp-auth-story img {
    width: min(250px, 75vw);
    margin-bottom: 48px;
  }
  .cp-auth-story h1 {
    max-width: 520px;
    font-size: clamp(39px, 12vw, 56px);
    line-height: 1.02;
  }
  .cp-auth-card {
    position: relative;
    z-index: 2;
    align-self: stretch;
    width: auto;
    max-width: none;
    margin: -42px 16px 28px !important;
    padding: 26px 22px !important;
    border-color: rgba(255, 255, 255, .94);
    background: #fffafb !important;
    box-shadow: 0 16px 36px rgba(66, 37, 51, .14) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .cp-auth-card input,
  .cp-auth-card select {
    background: #fff !important;
  }
}

@media (max-width: 410px) {
  .portal-main .report-actions {
    grid-template-columns: 1fr;
  }
  .portal-main .report-metric-grid {
    grid-template-columns: 1fr !important;
  }
  .cp-auth-story {
    min-height: 400px;
    padding-inline: 22px !important;
  }
  .cp-auth-card {
    margin-inline: 10px !important;
  }
}
