/* RENOVA Fullscreen Embed V5 — full viewport, sem rolagem horizontal.
   Desktop: sidebar fixa + conteúdo ocupa todo o restante.
   Mobile: sidebar vira drawer suspenso e conteúdo ocupa 100% da tela. */

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overflow-x: hidden !important;
  overscroll-behavior: none;
  background: #050912;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
.auth-view,
.app-view,
.main-content,
.content-wrap,
.page {
  min-width: 0;
  max-width: 100%;
}

.auth-view,
.app-view {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden !important;
}

.auth-view {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.app-view {
  position: relative;
  overflow: hidden;
}

/* Desktop: não usar width:calc + margin; width:auto evita qualquer estouro horizontal. */
.main-content {
  width: auto !important;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin-left: var(--sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden !important;
}

body.sidebar-collapsed .main-content {
  width: auto !important;
  margin-left: 78px;
}

.sidebar {
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.topbar {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 0 0 var(--topbar);
}

.content-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

/* Impede cards/grids de criarem largura maior que a área útil. */
.content-wrap > *,
.page,
.metrics-grid,
.dashboard-grid,
.panel,
.metric-card,
.welcome-row,
.page-actions {
  min-width: 0;
  max-width: 100%;
}

.metrics-grid,
.dashboard-grid {
  width: 100%;
}

/* Mobile: tela inteira + sidebar suspensa. */
@media (max-width: 760px) {
  html,
  body,
  .app-view,
  .main-content {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    min-height: 0;
    margin-left: 0 !important;
    overflow: hidden;
    overflow-x: hidden !important;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 310px);
    max-width: 86vw;
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-102%);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 120;
  }

  .menu-open .sidebar {
    transform: translateX(0);
  }

  .mobile-backdrop {
    z-index: 110;
  }

  .topbar,
  .content-wrap {
    width: 100%;
    max-width: 100%;
  }

  .content-wrap {
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .modal-card {
    width: min(calc(100% - 20px), 680px);
    max-width: calc(100% - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
}

@media (max-width: 560px) {
  .content-wrap {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}


/* RENOVA desktop embed fill v20260913-1118 */
/* Em embeds desktop, o app preenche o viewport inteiro sem alterar o drawer mobile. */
@media (min-width: 761px) {
  html,
  body,
  .app-view {
    width: 100% !important;
    max-width: none !important;
  }

  .app-view {
    position: relative;
    left: 0;
    right: 0;
  }

  .sidebar {
    left: 0 !important;
  }

  .main-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--sidebar);
    width: auto !important;
    margin-left: 0 !important;
  }

  body.sidebar-collapsed .main-content {
    left: 78px;
    width: auto !important;
    margin-left: 0 !important;
  }

  .content-wrap {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}


/* RENOVA mobile readability v20260913-1125 */
@media (max-width: 760px) {
  body { font-size: 16px; }

  .topbar h1 { font-size: 1.12rem; }
  .topbar .eyebrow { font-size: .68rem; letter-spacing: .14em; }

  .welcome-row h2,
  .page-actions h2 { font-size: 1.55rem; line-height: 1.15; }

  .welcome-row p,
  .page-actions p { font-size: .95rem; line-height: 1.5; }

  .status-badge { font-size: .82rem; padding: 9px 12px; }

  .metric-card { min-height: 138px; padding: 18px; }
  .metric-card > span { font-size: .82rem; }
  .metric-card strong { font-size: 1.38rem; line-height: 1.15; }
  .metric-card small { font-size: .78rem; }

  .panel-head h3 { font-size: 1.12rem; }
  .panel-head .eyebrow { font-size: .7rem; }

  .transaction-main strong,
  .account-row strong { font-size: .92rem; }
  .transaction-main span,
  .account-row small { font-size: .8rem; }
  .transaction-row > b,
  .account-row > b { font-size: .88rem; }

  .ghost-btn,
  .primary-btn { font-size: .9rem; }

  .nav-item { min-height: 49px; }
  .nav-item b { font-size: .94rem; }
  .nav-item > span { font-size: 1.12rem; }

  .user-meta strong { font-size: .84rem; }
  .user-meta span { font-size: .74rem; }
}

@media (max-width: 420px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 132px; padding: 16px; }
  .metric-card strong { font-size: 1.25rem; }
}
