@media (max-width: 782px) {
  body.serhill-portal-app-active {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
    background: #f4f6f8;
  }

  body.serhill-portal-app-active .serhill-mobile-portal-nav,
  body.serhill-portal-app-active .sp-mobile-portal-nav,
  body.serhill-portal-app-active .sp-dashboard-nav,
  body.serhill-portal-app-active .site-footer {
    display: none !important;
  }

  body.serhill-portal-app-active .portal-page {
    min-height: calc(100dvh - 78px);
    padding-bottom: 24px;
  }

  body.serhill-portal-app-active .portal-page .sp-dashboard {
    width: 100%;
    max-width: none;
    margin-top: 112px;
  }

  .sp-app-view {
    width: 100%;
    min-height: calc(100dvh - 190px);
    padding: 0 16px 28px;
  }

  .sp-app-view[hidden] { display: none !important; }

  .sp-app-view-head {
    margin: 0 -16px 18px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid #dce2e8;
    background: #fff;
  }

  .sp-app-view-head span {
    display: block;
    margin-bottom: 6px;
    color: #276b9a;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .16em;
  }

  .sp-app-view-head h1 {
    margin: 0;
    color: #111d28;
    font-size: clamp(24px, 7vw, 32px);
    line-height: 1.08;
  }

  .sp-app-view-content > * {
    margin-top: 0 !important;
    margin-bottom: 16px !important;
  }

  .sp-app-view-content .sp-account-head {
    display: grid;
    gap: 14px;
    padding: 22px 20px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(145deg, #152535, #1c3c58);
    color: #fff;
  }

  .sp-app-view-content .sp-account-head h1,
  .sp-app-view-content .sp-account-head p,
  .sp-app-view-content .sp-account-head span,
  .sp-app-view-content .sp-account-head a { color: inherit; }

  .sp-app-view-content .sp-card,
  .sp-app-view-content .sp-coach-section,
  .sp-app-view-content .sp-progress,
  .sp-app-view-content .sp-documents,
  .sp-app-view-content .sp-chat-panel {
    width: 100%;
    padding: 20px !important;
    border: 1px solid #dce2e8;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(17, 29, 40, .05);
  }

  .sp-app-view-content h2 {
    font-size: clamp(27px, 8vw, 38px);
    line-height: 1.08;
  }

  .sp-app-view-content .sp-form,
  .sp-app-view-content .sp-form-grid {
    min-width: 0;
  }

  .sp-app-view-content input,
  .sp-app-view-content select,
  .sp-app-view-content textarea,
  .sp-app-view-content button {
    max-width: 100%;
  }

  .sp-app-bottom-nav {
    position: fixed;
    z-index: 10050;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 8px 5px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,.12);
    background: rgba(17, 29, 41, .97);
    box-shadow: 0 -12px 34px rgba(9, 18, 27, .2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .sp-app-bottom-nav button {
    display: flex;
    min-width: 0;
    min-height: 56px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    padding: 4px 2px;
    border: 0;
    border-radius: 12px;
    color: #aeb9c3;
    background: transparent;
  }

  .sp-app-bottom-nav button span { font-size: 22px; line-height: 1; }
  .sp-app-bottom-nav button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .sp-app-bottom-nav button b { overflow: hidden; max-width: 100%; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
  .sp-app-bottom-nav button.is-active { color: #fff; background: #205d89; }

  body.sp-app-messages-open .sp-app-bottom-nav { transform: translateY(100%); }
  body.sp-app-messages-open .sp-app-view[data-app-view="messages"] { padding-bottom: 12px; }
}

/* Shared Portal Platform components. These primitives are role-neutral. */
.sp-ui-screen { box-sizing: border-box; }
.sp-ui-card { border: 1px solid #dce2e8; border-radius: 18px; background: #fff; }
.sp-ui-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 18px; border: 0; border-radius: 12px; background: #205d89; color: #fff; font-weight: 700; }
.sp-ui-form input,.sp-ui-form select,.sp-ui-form textarea { width: 100%; }
.sp-ui-workout-card,.sp-ui-program-card { border: 1px solid #dce2e8; border-radius: 16px; background: #fff; }
.sp-ui-toast { position: fixed; z-index: 10150; top: 98px; right: 16px; left: 16px; padding: 13px 16px; border-radius: 12px; background: #152535; color: #fff; opacity: 0; transform: translateY(-12px); transition: .2s ease; box-shadow: 0 12px 30px rgba(9,18,27,.22); }
.sp-ui-toast.is-visible { opacity: 1; transform: translateY(0); }
.sp-ui-toast.is-success { background: #276b4b; }
.sp-ui-toast.is-error { background: #8a3030; }
.sp-ui-modal { position: fixed; z-index: 10200; inset: 0; display: grid; place-items: end center; }
.sp-ui-modal-backdrop { position: absolute; inset: 0; background: rgba(9,18,27,.58); }
.sp-ui-modal-dialog { position: relative; width: min(100%,640px); max-height: 88dvh; overflow: auto; padding: 20px; border-radius: 22px 22px 0 0; background: #fff; }
.sp-ui-modal-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sp-ui-modal-dialog > header h2 { margin: 0; }
.sp-ui-modal-dialog > header button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #eef2f5; font-size: 26px; }
.is-loading { position: relative; pointer-events: none; opacity: .62; }
.is-loading::after { content: ""; position: absolute; z-index: 2; top: 50%; left: 50%; width: 24px; height: 24px; margin: -12px; border: 3px solid rgba(32,93,137,.2); border-top-color: #205d89; border-radius: 50%; animation: sp-ui-spin .7s linear infinite; }
@keyframes sp-ui-spin { to { transform: rotate(360deg); } }

@media (max-width: 782px) {
  .sp-dashboard-overview > header,
  .sp-dashboard-quick-actions > span,
  .sp-module-actions > span {
    display: block;
    margin-bottom: 12px;
    color: #276b9a;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
  }
  .sp-dashboard-overview h2 { margin: 0 0 16px; font-size: 27px; }
  .sp-dashboard-priority-grid,.sp-module-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .sp-dashboard-priority-card,.sp-module-summary-grid > article,.sp-nutrition-tool-card { display: flex; min-height: 128px; align-items: flex-start; justify-content: flex-start; flex-direction: column; gap: 7px; padding: 16px; color: #142333; text-align: left; }
  .sp-dashboard-priority-card span,.sp-module-summary-grid article span { color: #667482; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
  .sp-dashboard-priority-card strong,.sp-module-summary-grid article strong,.sp-nutrition-tool-card strong { font-size: 19px; line-height: 1.15; }
  .sp-dashboard-priority-card small,.sp-module-summary-grid article small,.sp-nutrition-tool-card small { color: #687685; font-size: 12px; line-height: 1.35; }
  .sp-dashboard-quick-actions,.sp-module-actions { margin: 18px 0; padding: 18px; border-radius: 18px; background: #152535; }
  .sp-dashboard-quick-actions > div,.sp-module-actions > div { display: flex; flex-wrap: wrap; gap: 8px; }
  .sp-dashboard-quick-actions button,.sp-module-actions button { min-height: 42px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.2); border-radius: 11px; background: transparent; color: #fff; font-weight: 700; }
  .sp-module-switcher { display: flex; gap: 7px; overflow-x: auto; margin: 0 0 16px; padding: 3px 0 8px; scrollbar-width: none; }
  .sp-module-switcher::-webkit-scrollbar { display: none; }
  .sp-module-switcher button { flex: 0 0 auto; min-height: 40px; padding: 8px 13px; border: 1px solid #d6dfe6; border-radius: 999px; background: #fff; color: #344555; font-weight: 700; }
  .sp-module-switcher button.is-active { border-color: #205d89; background: #205d89; color: #fff; }
  .sp-module-state[hidden],.sp-module-tool[hidden] { display: none !important; }
  .sp-module-empty { padding: 22px; border: 1px dashed #cbd6df; border-radius: 16px; background: #fff; }
  .sp-module-empty strong { font-size: 18px; }
  .sp-training-landing,.sp-nutrition-landing { margin-bottom: 18px; }
  .sp-nutrition-tool-card { width: 100%; border: 1px solid #dce2e8; }
  .sp-module-tool { scroll-margin-top: 120px; }
}

/* v0.35.0 workspace stabilization and billing center */
@media (max-width: 782px) {
  body.serhill-portal-app-active .sp-mobile-portal-menu-wrap,
  body.serhill-portal-app-active .sp-mobile-portal-menu-toggle,
  body.serhill-portal-app-active .sp-mobile-portal-menu-panel,
  body.serhill-portal-app-active .sp-mobile-portal-source-nav {
    display: none !important;
  }

  body.serhill-portal-app-active .portal-page .sp-dashboard {
    margin-top: 96px;
  }

  .sp-app-view-head {
    padding-top: 18px;
    padding-bottom: 15px;
  }

  .sp-app-view-content h2 {
    font-size: clamp(24px, 7vw, 34px);
  }

  .sp-payment-request-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .sp-payment-request-center {
    scroll-margin-top: 104px;
  }

  .sp-payment-center-summary {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    margin: 0 0 14px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #edf4f9;
    color: #174f7a;
  }

  .sp-payment-center-summary strong { font-size: 22px; }
  .sp-payment-center-summary span { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

  .sp-payment-request-list { display: grid; gap: 10px; margin-top: 12px; }
  .sp-payment-request-row {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid #dce2e8;
    border-radius: 14px;
    background: #fff;
  }
  .sp-payment-request-row > div { display: grid; gap: 3px; }
  .sp-payment-request-row small { color: #687685; }
  .sp-payment-request-row strong { color: #142333; font-size: 17px; }
  .sp-payment-request-row > b { width: max-content; padding: 5px 9px; border-radius: 999px; background: #edf4f9; color: #174f7a; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
  .sp-payment-request-row[data-payment-status="cancelled"] > b { background: #f4eeee; color: #7c4141; }
  .sp-payment-request-row[data-payment-status="paid"] > b,
  .sp-payment-request-row[data-payment-status="paid_offline"] > b { background: #eaf5ef; color: #276b4b; }
  .sp-payment-request-actions { display: flex; flex-wrap: wrap; gap: 7px; }
  .sp-payment-request-actions button {
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid #ccd7df;
    border-radius: 9px;
    background: #fff;
    color: #24435e;
    font-weight: 700;
  }

  .sp-dashboard-priority-card,
  .sp-module-summary-grid > article,
  .sp-nutrition-tool-card {
    min-height: 112px;
  }

  .sp-module-actions {
    position: sticky;
    top: 96px;
    z-index: 20;
  }
}

@media (max-width: 480px) {
  .sp-payment-request-fields { grid-template-columns: 1fr; }
}

/* v0.35.2: purchased-product visibility and delivery actions. */
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-ui-card,
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-card,
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-resource-list > div {
  background:#fff;
  color:#17212b;
}
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-card p,
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-resource-list small,
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-resource-list p {
  color:#667281;
}
.serhill-portal-app-active .sp-app-view[data-app-view="products"] .sp-link {
  color:#2f668f;
}
.sp-product-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
.sp-product-action{display:inline-flex;align-items:center;justify-content:center;min-height:42px;padding:9px 14px;border:1px solid #2f668f;text-decoration:none}
.sp-product-download{background:#2f668f;color:#fff!important}
.sp-product-file-unavailable{display:block;max-width:260px;color:#8b3131;font-size:13px;font-weight:700;line-height:1.35}
.sp-purchase-activation{color:#17212b!important;background:#edf5fa!important;border:1px solid #b9cfdd!important;border-left:4px solid #2f668f!important}
@media(max-width:700px){.sp-product-actions{justify-content:flex-start}.sp-product-action{width:100%}.sp-product-file-unavailable{max-width:none}}
