:root {
  --qc-layout-max: 1320px;
  --qc-layout-gutter: clamp(1rem, 2.4vw, 2.25rem);
  --qc-focus: #0b6b4b;
}

html {
  width: 100%;
  min-width: 320px;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

#root {
  min-height: 100vh;
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

img,
video,
canvas {
  height: auto;
}

button,
input,
select,
textarea {
  max-width: 100%;
  font: inherit;
}

button,
[role="button"],
a {
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--qc-focus);
  outline-offset: 3px;
}

/* Evita que grids e cartões criem overflow lateral em dispositivos estreitos. */
[class*="grid-cols-"],
[class*="flex"],
[class*="max-w-"] {
  min-width: 0;
}

[class~="container"] {
  width: 100%;
  max-width: var(--qc-layout-max);
  margin-inline: auto;
  padding-inline: var(--qc-layout-gutter);
}

[class*="overflow-x-auto"],
.overflow-x-auto,
.table-responsive {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

table {
  max-width: 100%;
}

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

[class*="prose"],
.prose {
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  html {
    scroll-padding-top: 1rem;
  }

  body {
    font-size: 16px;
  }

  /* Uma coluna reduz compressão em calculadoras, cartões e formulários. */
  [class*="grid-cols-2"],
  [class*="grid-cols-3"],
  [class*="grid-cols-4"],
  [class*="grid-cols-5"],
  [class*="grid-cols-6"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  [class*="flex-row"] {
    flex-wrap: wrap;
  }

  [class*="gap-8"],
  [class*="gap-10"],
  [class*="gap-12"] {
    gap: 1rem !important;
  }

  [class*="p-10"],
  [class*="p-12"],
  [class*="p-14"],
  [class*="p-16"],
  [class*="p-20"],
  [class*="p-24"] {
    padding: 1.25rem !important;
  }

  [class*="px-8"],
  [class*="px-10"],
  [class*="px-12"],
  [class*="px-14"] {
    padding-inline: 1rem !important;
  }

  [class*="py-12"],
  [class*="py-14"],
  [class*="py-16"],
  [class*="py-20"],
  [class*="py-24"] {
    padding-block: 2rem !important;
  }

  #root h1 {
    font-size: clamp(1.85rem, 8vw, 2.7rem);
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  #root h2 {
    font-size: clamp(1.35rem, 6vw, 2rem);
    line-height: 1.2;
  }

  #root h3 {
    line-height: 1.25;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  button,
  [role="button"] {
    min-height: 44px;
  }

  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  nav {
    max-width: 100%;
  }

  nav a {
    overflow-wrap: anywhere;
  }

  [role="dialog"],
  [data-radix-dialog-content] {
    max-width: calc(100vw - 1.5rem) !important;
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
  }

  [data-radix-popper-content-wrapper] {
    max-width: calc(100vw - 1.5rem);
  }

  .recharts-responsive-container {
    min-height: 220px;
  }

  a {
    overflow-wrap: anywhere;
  }
}

@media (min-width: 768px) and (max-width: 900px) {
  /* O breakpoint padrão do bundle abre a navegação em 768px, mas o cabeçalho
     ainda não tem largura suficiente para links, idioma e autenticação. */
  header nav.hidden.md\:flex {
    display: none !important;
  }

  header button.hidden.md\:flex {
    display: none !important;
  }

  header button.md\:hidden {
    display: grid !important;
  }
}

@media (min-width: 768px) and (max-width: 1279px) {
  [class~="container"] {
    padding-inline: 1.5rem;
  }
}

@media (min-width: 1536px) {
  [class~="container"] {
    max-width: 1440px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
