html, body {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.flash {
  padding: 12px;
  margin: 10px;
  border-radius: 6px;
  font-weight: bold;
}

.flash.success {
  background: #d4edda;
  color: #155724;
}

.flash.error {
  background: #f8d7da;
  color: #721c24;
}

.btn-logout {
    flex-shrink: 0; /* O botão NUNCA deve diminuir ou sumir */
    padding: 8px 12px;
    position: relative !important; /* Sobrescreve o absolute para alinhar no header */
    top: auto !important;
    right: auto !important;
    background-color: #ef4444;
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-logout:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Garante que o container pai permita o posicionamento absoluto */
.home-page, .page {
    position: relative;
}

.ordenacao-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #cbd5e1;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

.ordenacao-grupo {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ordenacao-label {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
}

.radio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.radio-inline {
    display: flex;
    gap: 20px;
}

.ordenacao-grupo label {
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ordenacao-grupo input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Header Principal */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo{
    height: 45px;
    width: auto;
    object-fit: contain;
    /* display: none; */
}

.btn-menu {
    background: none;
    border: none;
    font-size: 22px;
    color: #334155;
    cursor: pointer;
    padding: 5px;
}

.header-titles{
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-titles h1 {
    font-size: 1.3rem;
    letter-spacing: 1px;
    margin: 0;
    line-height: 1;
    color: #1e293b;
}

.header-titles span {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    flex-direction: column;
    text-align: right;
    line-height: 1.2;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 12px;
    color: #64748b;
}

/* Ajuste do seu Botão de Logout para caber no Header */

/* Menu Lateral (Drawer) */
.side-menu {
    position: fixed;
    top: 0;
    left: -300px; /* Escondido */
    width: 300px;
    height: 100%;
    z-index: 1100;
    transition: all 0.3s ease;
    visibility: hidden;
}

.side-menu.open {
    left: 0;
    visibility: visible;
}

.side-menu.open .side-menu-overlay {
    display: block;
}

/* Garante que o overlay (fundo escuro) também siga a visibilidade */
.side-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: none; /* Começa escondido */
    z-index: 1099;
}

.side-menu-content {
    width: 100%;
    height: 100%;
    background: #64748b;
    color: white;
    padding: 20px;
    position: relative;
    z-index: 1102;
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #334155;
    padding-bottom: 15px;
}

#menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.menu-list {
    list-style: none;
    padding: 0;
}

.menu-list li a {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #fff;
    text-decoration: none;
    padding: 12px 15px;
    border-radius: 8px;
    transition: 0.2s;
}

.menu-list li a:hover {
    background: #334155;
}

/* --- AJUSTES PARA MOBILE (CABECALHO) --- */

@media (max-width: 650px) {
    .main-header {
        padding: 0 10px; /* Reduz a folga lateral para ganhar espaço */
        height: 80px;    /* Aumentamos levemente a altura para acomodar as linhas */
    }

    .header-spacer {
        height: 80px;    /* Acompanha a altura do header */
    }

    .header-logo {
        height: 35px;    /* Logo ligeiramente menor no mobile */
    }

    .header-titles h1 {
        font-size: 1.1rem;
        letter-spacing: 0.5px;
    }

    .header-right {
        gap: 8px; /* Cola o perfil mais perto do botão de sair */
    }

    .user-profile {
        max-width: 110px; /* Limita a largura para forçar a quebra de linha */
    }

    .user-name {
        white-space: normal;    /* PERMITE QUEBRA DE LINHA */
        font-size: 11px;        /* Fonte menor para caber melhor */
        line-height: 1.1;       /* Linhas mais próximas */
        text-align: right;
        overflow: visible;      /* Garante que o texto apareça */
        text-overflow: clip;    /* Remove as reticências (...) */
    }

    .user-email {
        display: none; /* Oculta o email no mobile para economizar espaço vertical */
    }

    .btn-logout {
        padding: 6px 10px; /* Botão mais compacto */
        font-size: 11px;
        gap: 4px;
    }

    .btn-logout i {
        font-size: 12px;
    }
}

/* Ajuste extra para celulares muito pequenos */
@media (max-width: 380px) {
    .header-logo {
        display: none; /* Em telas minúsculas, removemos o logo para o botão não fugir */
    }
    
    .user-profile {
        max-width: 90px;
    }
}