/* Base: reset, tipografia, campos, tabela, foco e barras de rolagem (DESIGN.md §3–§5). Depende de tokens.css. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  background: var(--background);
  color: var(--background-text);
  font-family: var(--font-sans);
}

body {
  min-width: 320px;
  background: var(--background);
  color: var(--background-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--missao-header);
  line-height: 1.35;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2,
h3 {
  font-size: 18px;
  font-weight: 600;
}

h4 {
  font-size: 14px;
  font-weight: 600;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
}

p {
  margin: 0 0 0.75rem;
  font-size: 14px;
}

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

/* Campos. :where() zera a especificidade do filtro de tipo, para o componentes.css
   continuar sobrescrevendo (ex.: padding da busca do cabeçalho). */
input:where(:not([type="checkbox"], [type="radio"])),
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: var(--altura-controle);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--raio-lg);
  background: var(--background-paper);
  color: var(--background-text);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}

input:where(:not([type="checkbox"], [type="radio"])):focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--primary-500);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger-500);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Caixa nativa por enquanto; a receita completa (marca com transição) entra no PR 3. */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary-500);
  cursor: pointer;
}

label {
  display: grid;
  gap: 6px;
  color: var(--background-text);
  font-size: 14px;
  font-weight: 500;
}

/* Foco: âmbar no claro, amarelo no escuro (--ring). */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Tabela */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 16px;
  vertical-align: top;
}

thead {
  background: var(--background-muted);
}

thead th {
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-top: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--background-muted);
}

th {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 400;
}

td {
  font-size: 14px;
}

/* Barras de rolagem: escondidas por padrão (a rolagem continua); aparecem só
   onde são necessárias. A cor está em scrollbar-color e no ::-webkit — mudar juntas. */
* {
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

.scrollbar-x-visible,
.tabela-rolagem,
.scrollbar-visible-local {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.scrollbar-x-visible::-webkit-scrollbar,
.tabela-rolagem::-webkit-scrollbar {
  display: block;
  height: 8px;
}

.scrollbar-visible-local::-webkit-scrollbar {
  display: block;
  width: 10px;
}

.scrollbar-x-visible::-webkit-scrollbar-thumb,
.tabela-rolagem::-webkit-scrollbar-thumb,
.scrollbar-visible-local::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

[hidden] {
  display: none !important;
}

.visualmente-oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
