/* Base reset + typography + page enter + reduced motion */

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

html {
  scroll-behavior: smooth;
}

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

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--font-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--motion-medium) var(--ease-in-out),
    color var(--motion-medium) var(--ease-in-out);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: inherit;
}

/* Links de conteúdo (não menu) */
.content a:not(.btn):not(.pill):not(.menu-item):not(.tab) {
  color: var(--primary);
}

.content a:not(.btn):not(.pill):not(.menu-item):not(.tab):hover {
  color: var(--primary-hover);
}

/* SVG: nunca herdar tamanho intrínseco ~300x150 do browser */
svg {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.icon svg,
.icon-btn svg,
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--font-xl);
}

h2 {
  font-size: var(--font-lg);
}

p {
  margin: 0 0 var(--space-3);
  color: var(--text-secondary);
}

small,
.text-muted {
  color: var(--text-muted);
  font-size: var(--font-sm);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

html {
  overflow-x: hidden;
}

/* Content page enter — só opacity. `transform` no ancestral quebra
   Leaflet (tiles cinza) e drawers (translateX sobrescrito). */
.content > *:not(.drawer):not(.drawer-overlay):not(.modal):not(.modal-overlay) {
  animation: ti-page-enter var(--motion-medium) var(--ease-out) both;
}

@keyframes ti-page-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

  .content > *:not(.drawer):not(.drawer-overlay),
  .kpi-card,
  .card,
  .progress-fill,
  .menu-item,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}

[hidden] {
  display: none !important;
}

/* Utilities */
.flex {
  display: flex;
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-4 {
  margin-top: var(--space-4);
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-4 {
  margin-bottom: var(--space-4);
}
.w-full {
  width: 100%;
}
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
