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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    /* Impede vazamento de fundo no mobile ao rolar (bounce iOS/Android) */
    background-color: var(--bg-darkest);
    min-height: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-base);
    color: var(--text-primary);
    background-color: var(--bg-darkest);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* NÃO usar 100vh aqui — no iOS Safari 100vh é a viewport MÁXIMA
       (URL bar oculta) e cria espaço extra ao rolar quando a URL bar
       aparece/some. O html já tem min-height:100% (com bg) que cobre
       o bounce. Deixar o body fluir com o conteúdo. */
}

/* ==================================================
   Impede o iOS Safari de dar ZOOM ao focar inputs.
   Regra: font-size >= 16px em qualquer input/textarea/select
   focável. Aplicado só no mobile pra não afetar tipografia
   compacta do desktop.
   ================================================== */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    textarea,
    select,
    [contenteditable="true"] {
        font-size: 16px !important;
    }
}

/* ==================================================
   iOS Safari: URL bar contrai/expande no scroll da window,
   criando gap entre a URL bar e o header (position: fixed).
   Solução: mover o scroll pro body — assim a window nunca
   scrolla, o Safari NÃO retrai a URL bar, ela fica sempre
   do mesmo tamanho, e header/bottom-nav ficam colados.
   Padrão usado por Instagram/Twitter mobile.
   ================================================== */
@media (max-width: 900px) {
    html {
        height: 100%;
        overflow: hidden;
    }
    body {
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    /* Enquanto a sidebar mobile está aberta, trava o scroll do body pra o
       dedo do usuário só scrollar dentro da sidebar (impede scroll chaining
       em Safari antigo / Android antigo que ignoram overscroll-behavior). */
    body.sidebar-open {
        overflow: hidden;
    }
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

ul, ol {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    outline: none;
    transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

input::placeholder {
    color: var(--text-muted);
}

table {
    border-collapse: collapse;
    width: 100%;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

::selection {
    background: var(--primary);
    color: var(--bg-darkest);
}
