/* Mobile cloud dashboard — fixed bottom tab bar + no horizontal page scroll. */

:root {
  --nav-tabbar-height: 0px;
}

/* —— Bottom tab bar (structure always present; visible only on small screens) —— */
.nav-tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4500; /* above page chrome; below .slt-modal-overlay (5000) */
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(6, 7, 10, 0.94);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.nav-tabbar[hidden] {
  display: none !important;
}

.nav-tabbar__inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 0.1rem;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 0.3rem 0.3rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
}

.nav-tabbar__link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  min-width: 0;
  min-height: 2.85rem;
  padding: 0.2rem 0.15rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.48);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-tabbar__link.is-active,
.nav-tabbar__link[aria-current='page'] {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-tabbar__icon {
  display: inline-flex;
  width: 1.3rem;
  height: 1.3rem;
}

.nav-tabbar__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.nav-tabbar__label {
  font-family: var(--font-meta, ui-sans-serif, system-ui, sans-serif);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.nav-mobile__eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--font-meta);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

/* Never let the document scroll sideways on any viewport */
html,
body {
  overflow-x: clip;
  max-width: 100%;
}

#app,
.cloud-main,
.account-wrapper,
.docs-shell,
.docs-body {
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

/* Keep the shared dashboard column (same as status / --layout-max).
   Do not set max-width: 100% here — that made developers/providers full-bleed on desktop. */
.cloud-page {
  min-width: 0;
  overflow-x: clip;
}

/* Scrollable regions may scroll internally — not the page */
.cloud-table-wrap,
.activity-requests__table-wrap,
.model-credits-table-wrap,
.slt-payout-manage__table-wrap,
.admin-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media screen and (max-width: 768px) {
  body.has-nav-tabbar {
    --nav-tabbar-height: calc(3.75rem + env(safe-area-inset-bottom, 0px));
    --cloud-header-offset: clamp(4.1rem, 11vw, 4.85rem);
  }

  body.has-nav-tabbar.has-nav-balance {
    --cloud-header-offset: calc(clamp(4.1rem, 11vw, 4.85rem) + var(--nav-balance-height, 2.55rem));
  }

  body.has-nav-tabbar .nav-tabbar:not([hidden]) {
    display: block !important;
  }

  body.menu-locked .nav-tabbar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .site-header.nav-open {
    z-index: 4600;
  }

  /* Compact top chrome */
  .site-header {
    padding: 0.5rem 0.7rem 0;
  }

  .nav-float {
    grid-template-columns: 1fr auto;
    gap: 0.45rem;
    border-radius: 0.9rem;
    padding: 0.35rem 0.4rem 0.35rem 0.8rem;
  }

  .nav-links {
    display: none !important;
  }

  .nav-menu-btn {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .nav-balance {
    width: 100%;
    max-width: 100%;
    border-radius: 0.8rem;
    margin-top: 0.3rem;
  }

  .nav-balance__panel {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 0.35rem 0.45rem;
  }

  .nav-balance__role {
    display: none;
  }

  .nav-balance__metrics {
    gap: 0.65rem;
    min-width: 0;
  }

  .nav-balance__metric {
    min-width: 0;
  }

  .nav-balance__value {
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-mobile nav {
    justify-content: flex-end;
    gap: 0.1rem;
    padding: 5rem 1.15rem calc(5.75rem + env(safe-area-inset-bottom, 0px));
  }

  .nav-mobile-link,
  .nav-mobile-signout {
    font-size: 1.45rem;
    font-weight: 400;
    letter-spacing: -0.03em;
    padding: 0.5rem 0;
    color: rgba(255, 255, 255, 0.72);
  }

  .nav-mobile-link.is-active {
    color: #fff;
  }

  /* —— Pages —— */
  .cloud-page,
  .account-wrapper {
    padding-left: max(0.8rem, env(safe-area-inset-left));
    padding-right: max(0.8rem, env(safe-area-inset-right));
    padding-bottom: calc(var(--nav-tabbar-height) + 1.1rem);
  }

  .cloud-page__header {
    margin-bottom: 1rem;
  }

  .cloud-page__header h1 {
    font-size: clamp(1.45rem, 6.5vw, 1.8rem);
    margin-bottom: 0.35rem;
  }

  .cloud-page__lead {
    font-size: 0.875rem;
    line-height: 1.45;
  }

  .cloud-page__meta {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    overflow-wrap: anywhere;
  }

  .cloud-page .eyebrow {
    margin-bottom: 0.35rem;
    font-size: 0.68rem;
  }

  .cloud-dashboard-grid,
  .cloud-grid,
  .account-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
  }

  .cloud-card,
  .account-card,
  .cloud-card--full,
  .cloud-card--paired {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0.95rem 0.9rem 1rem;
    border-radius: 0.85rem;
  }

  .cloud-card--paired {
    min-height: 0;
  }

  .cloud-card h2,
  .account-card h2 {
    font-size: 1.02rem;
  }

  .cloud-card__hint {
    font-size: 0.78rem;
    margin-bottom: 0.65rem;
    overflow-wrap: anywhere;
  }

  .cloud-card__head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .cloud-card__head .cloud-actions {
    width: 100%;
    margin-top: 0;
  }

  .cloud-card__head .cloud-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .cloud-actions {
    gap: 0.45rem;
    margin-top: 0.7rem;
    max-width: 100%;
  }

  .cloud-actions > .btn {
    min-height: 2.55rem;
  }

  .cloud-stat {
    font-size: 1.55rem;
  }

  .cloud-input,
  .account-input,
  select.cloud-input,
  textarea.cloud-input {
    max-width: 100%;
  }

  /* Tables: scroll inside the wrap only — never grow the page */
  .cloud-table-wrap.cloud-keys-table-wrap,
  .cloud-table-wrap.cloud-usage-table-wrap,
  #acct-mgmt-keys-card .cloud-keys-table-wrap {
    min-height: 0;
    max-height: min(20rem, 48vh);
    max-width: 100%;
    overflow-x: auto;
  }

  table.cloud-keys-table,
  table.cloud-usage-table,
  table.cloud-table,
  .activity-requests__table {
    width: 100%;
    max-width: none;
  }

  /* Prefer compact columns over forced min-widths that spill the page */
  .cloud-keys-table {
    table-layout: fixed;
  }

  .cloud-keys-table .cloud-keys-table__col-name,
  .cloud-keys-table td.cloud-keys-table__name {
    width: 38%;
  }

  .cloud-keys-table .cloud-keys-table__col-actions,
  .cloud-keys-table td.cloud-keys-table__actions-cell {
    width: 2.75rem;
    text-align: right;
    vertical-align: middle;
  }

  .cloud-keys-table__actions,
  .cloud-keys-table__menu {
    display: inline-flex;
    justify-content: flex-end;
    width: 100%;
  }

  .activity-requests__actions,
  .activity-requests__menu {
    display: inline-flex;
    justify-content: flex-end;
    width: 100%;
  }

  .activity-requests__table-wrap {
    max-width: 100%;
  }

  .activity-requests__table {
    min-width: 0;
  }

  .credits-card,
  .credits-card__main,
  .credits-card__body,
  .credits-card__content {
    max-width: 100%;
    min-width: 0;
  }

  /* Expand-chart control is desktop-only; chart keeps the desktop overlay placement. */
  .credits-card__fullscreen {
    display: none !important;
  }

  .credits-card__chart {
    max-width: 100%;
  }

  .credits-card__chart-toggle {
    display: none !important;
  }

  /* Activity table: scroll horizontally instead of crushing columns */
  .activity-requests__table {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
    font-size: 0.75rem;
  }

  .activity-requests__table th,
  .activity-requests__table td {
    padding: 0.32rem 0.45rem;
  }

  .activity-requests.is-open .activity-requests__panel {
    max-height: min(52dvh, 28rem);
  }

  .activity-requests__table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  /* Model catalog — capped height with in-grid “show more” */
  .dev-model-catalog__header,
  .dev-model-catalog__tools,
  .dev-desired-model__row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    max-width: 100%;
  }

  .dev-model-catalog__search,
  .dev-model-catalog__search input,
  .dev-desired-model__field,
  .pricing-catalog__grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .pricing-catalog__grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .pricing-catalog__more {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.55rem;
    margin: 0.15rem 0 0;
    padding: 0.55rem 0.85rem;
    border: 1px dashed rgba(255, 255, 255, 0.16);
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.78);
    font: inherit;
    font-size: 0.84rem;
    cursor: pointer;
  }

  .pricing-catalog__more:hover,
  .pricing-catalog__more:focus-visible {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    outline: none;
  }

  /* Looking-for-a-model: drop unused vertical space */
  #slt-desired-model-card {
    padding-top: 0.85rem;
    padding-bottom: 0.9rem;
  }

  #slt-desired-model-card .cloud-card__hint {
    margin-bottom: 0.45rem;
  }

  .dev-desired-model {
    gap: 0.45rem;
  }

  .dev-desired-model__row {
    gap: 0.45rem;
  }

  /* flex-basis 16rem is a width on desktop; in a column it becomes a tall empty field */
  .dev-desired-model__field {
    flex: 0 0 auto;
    width: 100%;
  }

  #slt-desired-model-go {
    width: 100%;
    flex: 0 0 auto;
    justify-content: center;
  }

  /* Quick try is desktop-oriented */
  #slt-quick-test-card {
    display: none !important;
  }

  .cloud-quick-test,
  .cloud-snippet-block,
  .cloud-snippet-block pre {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
  }

  .cloud-snippet-block pre {
    white-space: pre;
  }

  /* Account */
  .cloud-checkbox-row,
  .cloud-radio-row {
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0;
    max-width: 100%;
  }

  /* Modals: keep centered in the visible viewport (avoid off-screen bottom sheets) */
  .slt-modal-overlay {
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top, 0px))
      max(0.75rem, env(safe-area-inset-right, 0px))
      calc(0.85rem + var(--nav-tabbar-height, 0px))
      max(0.75rem, env(safe-area-inset-left, 0px));
  }

  .slt-modal-overlay .slt-modal {
    width: 100%;
    max-width: 100%;
    max-height: min(82dvh, 40rem);
  }

  .slt-modal-overlay .modal-content {
    border-radius: 1rem;
    max-height: min(82dvh, 40rem);
    max-width: 100%;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    overflow-x: clip;
  }

  .acct-tutorials-modal {
    width: 100%;
    max-width: 100%;
  }

  /* Docs */
  .docs-shell,
  .docs-body {
    padding-bottom: calc(var(--nav-tabbar-height) + 0.75rem);
  }

  .docs-sidebar {
    position: sticky;
    top: var(--cloud-header-offset, 4.25rem);
    z-index: 5;
    max-width: 100%;
    margin: 0;
    padding: 0.55rem 0 0.65rem;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
  }

  .docs-nav__list {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .docs-nav__link {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .docs-main {
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
  }

  .docs-main pre,
  .docs-main code {
    max-width: 100%;
    overflow-x: auto;
  }

  /* Providers */
  .cloud-machines-fleet-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    max-width: 100%;
  }

  .cloud-machines-fleet-bar .cloud-actions,
  .cloud-machines-fleet-bar .cloud-actions--inline {
    width: 100%;
    flex-wrap: wrap;
  }

  .cloud-machines-fleet-bar .btn {
    flex: 1 1 auto;
  }

  #slt-machine-modal .slt-modal,
  #slt-machine-modal .modal-content,
  #slt-machine-modal .cloud-machine-logs-overlay {
    width: 100%;
    max-width: 100%;
  }

  /* Machine modal gets its own padding/tab layout in app-providers.css */
  #slt-machine-modal.slt-modal-overlay {
    align-items: stretch;
    justify-content: flex-start;
  }

  /* Token / offers */
  .offers-stage,
  .offers-showcase,
  .grants-layout {
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
  }

  /* Footer sits above tab bar; keep it from spilling */
  body.has-nav-tabbar #site-footer-root {
    max-width: 100%;
    overflow-x: clip;
    padding-bottom: var(--nav-tabbar-height);
  }

  /* Charts / canvases must shrink with the card */
  .credits-card__chart canvas,
  .credits-chart,
  .credits-chart svg,
  [data-credits-chart],
  .activity-chart-controls-host {
    max-width: 100% !important;
    min-width: 0;
  }

  .activity-chart-controls-host {
    overflow-x: auto;
  }
}

@media screen and (max-width: 420px) {
  .nav-tabbar__label {
    font-size: 0.55rem;
  }

  .nav-balance__label {
    display: none;
  }

  .cloud-page__header h1 {
    font-size: 1.4rem;
  }
}
