/* Clara — composição responsiva final
   Esta camada é carregada por último e só reorganiza os layouts já existentes. */

@media (pointer: coarse) {
  .auth-view :is(button, .back-link, .password-toggle),
  .app :is(.btn, .icon-btn, .profile-switcher button, .sidebar nav button, .panel-link),
  .app :is(.alerts-head button, .alert-item),
  .landing-v4 :is(button, .btn, .landing-header nav a, .footer-contacts a) {
    min-height: 44px;
  }

  .auth-view :is(input, select),
  .app :is(input, select) {
    min-height: 48px;
  }
}

/* Tablet: o shell vira uma barra de navegação tátil sem perder nenhuma rota. */
@media (max-width: 1024px) {
  .app > main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  .app .sidebar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .app .sidebar nav {
    scroll-padding-inline: 8px;
    scroll-snap-type: x proximity;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .app .sidebar nav button {
    min-width: 82px;
    min-height: 60px;
    scroll-snap-align: center;
  }

  .app .main-content {
    padding-inline: clamp(22px, 4vw, 42px);
  }

  .landing-v4 .context-story {
    min-height: 180svh;
  }

  .landing-v4 .product-story {
    min-height: 220svh;
  }

  .landing-v4 .product-demo--full {
    max-width: 820px;
  }
}

/* Celular: composição própria, com conteúdo e ações antes da decoração. */
@media (max-width: 760px) {
  /* Login */
  .auth-view {
    min-height: 100svh;
  }

  .auth-view .auth-brand {
    min-height: 156px;
    padding: 20px clamp(20px, 6vw, 30px) 18px;
  }

  .auth-view .auth-brand > .logo {
    font-size: 24px;
  }

  .auth-view .brand-copy {
    margin-top: auto;
  }

  .auth-view .brand-copy h1 {
    max-width: none;
    font-size: clamp(27px, 7.4vw, 34px);
    line-height: .98;
    letter-spacing: -.055em;
  }

  .auth-view .brand-copy h1 .slogan-line {
    display: inline;
  }

  .auth-view .brand-copy h1 .slogan-line + .slogan-line::before {
    content: " ";
  }

  .auth-view .brand-copy h1 .slogan-logo {
    display: block;
    margin-top: 3px;
  }

  .auth-view .brand-copy p {
    display: none;
  }

  .auth-view .auth-panel {
    align-items: flex-start;
    min-height: calc(100svh - 156px);
    padding: 26px clamp(20px, 6vw, 30px) calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .auth-view .auth-box {
    width: min(100%, 480px);
    margin-inline: auto;
  }

  .auth-view .auth-box h2 {
    font-size: clamp(25px, 7vw, 31px);
    margin-bottom: 6px;
  }

  .auth-view .auth-box > p {
    margin-bottom: 22px;
  }

  .auth-view .auth-box label {
    margin-bottom: 14px;
  }

  .auth-view .auth-box :is(input, select) {
    min-height: 50px;
    font-size: 16px;
  }

  .auth-view .auth-box .btn.primary {
    min-height: 50px;
  }

  .auth-view .auth-switch {
    margin-top: 18px;
  }

  /* Dashboard */
  .app .topbar {
    gap: 12px;
    padding: 14px clamp(16px, 4.8vw, 24px);
  }

  .app .topbar-left {
    min-width: 0;
  }

  .app .topbar-left h1 {
    font-size: clamp(17px, 4.8vw, 20px);
  }

  .app .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px 46px;
    width: 100%;
    gap: 8px;
  }

  .app .profile-switcher {
    width: 100%;
    min-width: 0;
    height: 48px;
  }

  .app .profile-switcher button {
    min-width: 0;
    min-height: 44px;
    padding-inline: 8px;
  }

  .app .top-actions > .icon-btn {
    width: 46px;
    height: 46px;
  }

  .app .main-content {
    padding: 20px clamp(16px, 4.8vw, 24px) 32px;
  }

  .app .page-title {
    gap: 12px;
    margin-bottom: 18px;
  }

  .app .page-title h2 {
    font-size: clamp(23px, 7vw, 29px);
  }

  .app .page-title :is(select, .btn) {
    min-height: 46px;
  }

  .app .dashboard-grid,
  .app .business-dashboard-grid {
    gap: 14px;
  }

  .app #page-dashboard :is(.panel, .business-panel) {
    padding: clamp(17px, 4.5vw, 22px);
  }

  .app.personal-mode #page-dashboard > .stats-grid,
  .app.business-mode #page-dashboard > .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }

  .app.personal-mode #page-dashboard > .stats-grid > .stat-card.balance,
  .app.business-mode #page-dashboard > .stats-grid > .stat-card:nth-child(2) {
    grid-column: 1 / -1;
    min-height: 120px;
  }

  .app.personal-mode #page-dashboard > .stats-grid > .stat-card:nth-child(4) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    min-height: 94px;
  }

  .app.personal-mode #page-dashboard > .stats-grid > .stat-card:nth-child(4) .stat-head {
    grid-column: 1;
  }

  .app.personal-mode #page-dashboard > .stats-grid > .stat-card:nth-child(4) strong {
    grid-column: 2;
    grid-row: 1 / 3;
    margin: 0 0 0 12px;
  }

  .app.personal-mode #page-dashboard > .stats-grid > .stat-card:nth-child(4) > small {
    grid-column: 1;
  }

  .app #page-dashboard > .stats-grid > .stat-card {
    min-width: 0;
    min-height: 106px;
    padding: 17px;
  }

  .app #page-dashboard > .stats-grid .stat-card strong {
    overflow-wrap: anywhere;
    font-size: clamp(20px, 5.7vw, 26px);
    line-height: 1.05;
  }

  .app #page-dashboard > .stats-grid .stat-card.balance strong,
  .app.business-mode #page-dashboard > .stats-grid > .stat-card:nth-child(2) strong {
    font-size: clamp(27px, 8vw, 36px);
  }

  .app #page-dashboard > .stats-grid .stat-card > span:last-child {
    line-height: 1.25;
  }

  .app.personal-mode #page-dashboard .pie-layout {
    grid-template-columns: minmax(118px, .82fr) minmax(0, 1.18fr);
    align-items: center;
    gap: 14px;
  }

  .app.personal-mode #page-dashboard .pie-wrap {
    width: min(132px, 100%);
    aspect-ratio: 1;
    margin-inline: auto;
  }

  .app.personal-mode #page-dashboard .pie-legend {
    min-width: 0;
  }

  .app .empty-state {
    min-height: 180px;
    padding: 28px 18px;
  }

  .app .alerts-panel {
    top: 76px;
    max-height: calc(100svh - 96px - env(safe-area-inset-bottom, 0px));
  }

  .app .alerts-head button {
    display: grid;
    width: 44px;
    min-width: 44px;
    padding: 0;
    place-items: center;
  }

  .app .empty-state .btn,
  .app #page-dashboard .panel-link,
  .app #page-dashboard .insight-action {
    min-height: 44px;
  }

  .app .sidebar nav button {
    min-width: 76px;
    padding-inline: 10px;
    font-size: 10px;
  }

  /* Landing */
  .landing-v4 .landing-header {
    min-height: 68px;
    padding-inline: clamp(16px, 4.8vw, 24px);
  }

  .landing-v4 .landing-header-actions {
    gap: 5px;
  }

  .landing-v4 .landing-header .landing-theme-toggle {
    width: 44px;
    min-width: 44px;
  }

  .landing-v4 .landing-header .btn.primary {
    min-height: 44px;
    padding-inline: 14px;
    font-size: 12px;
  }

  .landing-v4 .landing-hero {
    min-height: auto;
    gap: 34px;
    padding: 58px clamp(16px, 4.8vw, 24px) 72px;
  }

  .landing-v4 .landing-hero-copy h1 {
    font-size: clamp(43px, 13vw, 62px);
  }

  .landing-v4 .landing-hero-copy > p {
    max-width: 34ch;
    font-size: 16px;
  }

  .landing-v4 .landing-actions {
    gap: 10px;
  }

  .landing-v4 .landing-actions :is(.btn, a) {
    min-height: 48px;
  }

  .landing-v4 .hero-product {
    transform: none;
  }

  .landing-v4 .product-demo--hero {
    min-height: 392px;
  }

  .landing-v4 .product-demo--hero .demo-sidebar {
    width: 46px;
  }

  .landing-v4 .context-story {
    min-height: 160svh;
  }

  .landing-v4 .context-sticky {
    min-height: 100svh;
    padding-block: 78px 36px;
  }

  .landing-v4 .context-shell {
    min-height: 354px;
  }

  .landing-v4 .context-switch span {
    font-size: 11px;
  }

  .landing-v4 .context-copy p {
    font-size: 14px;
  }

  .landing-v4 .context-cta {
    min-height: 44px;
  }

  .landing-v4 .organization-flow {
    padding-block: 84px;
  }

  .landing-v4 .flow-diagram article {
    min-height: 150px;
  }

  .landing-v4 .product-story {
    min-height: 192svh;
  }

  .landing-v4 .product-story-sticky {
    min-height: 100svh;
    padding-block: 74px 30px;
  }

  .landing-v4 .product-focus-list span {
    min-height: 38px;
    font-size: 9px;
    line-height: 1.3;
  }

  .landing-v4 .product-demo--full {
    min-height: 570px;
  }

  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-topbar small,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-title small,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-kpis small,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-kpis span,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-insight small,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-panels small {
    font-size: 7px;
    line-height: 1.3;
  }

  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-title b {
    font-size: 13px;
  }

  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-title em,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-profile-switch i {
    font-size: 8px;
  }

  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-kpis strong {
    font-size: clamp(11px, 3.4vw, 14px);
  }

  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-insight b,
  .landing-v4 :is(.product-demo--hero, .product-demo--full) .demo-panels b,
  .landing-v4 .product-demo--full .demo-activity b {
    font-size: 8px;
  }

  .landing-v4 .product-demo--full .demo-activity {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .landing-v4 .product-demo--full .demo-activity article:nth-child(2) {
    display: block;
  }

  .landing-v4 .product-demo--full .demo-activity :is(p, strong, span) {
    font-size: 7px;
  }

  .landing-v4 .automation-story {
    min-height: 930px;
    padding-block: 92px 78px;
  }

  .landing-v4 .automation-network {
    gap: 16px;
    margin-top: 42px;
  }

  .landing-v4 .automation-network article {
    min-height: 78px;
  }

  .landing-v4 .slogan-story {
    min-height: 120svh;
  }

  .landing-v4 .landing-final-cta {
    min-height: 72svh;
    padding-block: 84px;
  }
}

@media (max-width: 440px) {
  .auth-view .auth-brand {
    min-height: 144px;
  }

  .auth-view .auth-panel {
    min-height: calc(100svh - 144px);
    padding-top: 22px;
  }

  .app .topbar {
    padding-inline: 16px;
  }

  .app .main-content {
    padding-inline: 16px;
  }

  .app #page-dashboard > .stats-grid > .stat-card {
    padding: 15px;
  }

  .app #page-dashboard > .stats-grid .stat-card strong {
    font-size: clamp(18px, 5.6vw, 24px);
  }

  .app.personal-mode #page-dashboard .pie-layout {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
  }

  .landing-v4 .landing-header .landing-login {
    display: none;
  }

  .landing-v4 .landing-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .landing-v4 .landing-actions :is(.btn, a) {
    width: 100%;
  }

  .landing-v4 .product-demo--hero {
    min-height: 378px;
  }

  .landing-v4 .product-demo--hero .demo-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .landing-v4 .product-demo--hero .demo-kpis article:first-child {
    grid-column: 1 / -1;
  }

  .landing-v4 .context-story {
    min-height: 152svh;
  }

  .landing-v4 .product-story {
    min-height: 184svh;
  }

  .landing-v4 .product-focus-list {
    gap: 5px;
  }

  .landing-v4 .product-focus-list span {
    padding-inline: 7px;
    font-size: 8px;
  }

  .landing-v4 .product-demo--full .demo-sidebar {
    width: 44px;
  }

  .landing-v4 .automation-story {
    min-height: 880px;
  }
}

@media (max-width: 760px) and (max-height: 700px) {
  .auth-view .auth-brand {
    min-height: 124px;
  }

  .auth-view .auth-panel {
    min-height: calc(100svh - 124px);
  }

  .landing-v4 .context-heading p,
  .landing-v4 .product-story-copy > p {
    display: none;
  }
}

/* A narrativa permanece compreensível sem deslocamentos ou cenas presas. */
@media (prefers-reduced-motion: reduce) {
  .landing-v4 .hero-product {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 760px) {
  .landing-v4 :is(.context-story, .product-story, .slogan-story) {
    min-height: auto;
  }

  .landing-v4 :is(.context-sticky, .product-story-sticky) {
    position: relative;
    min-height: auto;
  }
}
