* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
    /* Evita a barra de rolagem horizontal chata */
}

body {
    font-family: 'Public Sans', sans-serif;
    margin: 0;
    background: #f6f7f8;
    color: #222;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: white;
    border-bottom: 1px solid #ddd;
}

.logo {
    font-weight: 700;
    font-size: 20px;
    color: #1a4060;
}

.help {
    background: #1a4060;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80vh;
}

.login-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 900px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.left {
    background: #1a4060;
    color: white;
    padding: 40px;
}

.left h1 {
    margin-bottom: 20px;
}

.right {
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.right h2 {
    margin-bottom: 20px;
}

input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

button {
    background: #1a4060;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: #16324a;
}

footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: #666;
}

/*CSS do Dashboard*/

/* --- ADIÇÕES PARA O DASHBOARD --- */

/* Ajustes na topbar para acomodar o perfil do usuário */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-text {
    text-align: right;
}

.user-text p {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.user-text span {
    font-size: 12px;
    color: #666;
}

.avatar {
    background: #eef2f6;
    color: #1a4060;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dcdfe3;
}

/* Layout Principal (Sidebar + Conteúdo) */
.dashboard-layout {
    display: flex;
    height: calc(100vh - 75px);
    /* Desconta o tamanho da topbar */
    overflow: hidden;
}

/* Menu Lateral */
.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid #ddd;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-title {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    text-decoration: none;
    color: #555;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.sidebar a:hover {
    background: #f0f4f8;
}

.sidebar a.active {
    background: #1a4060;
    color: white;
    box-shadow: 0 4px 10px rgba(26, 64, 96, 0.2);
}

/* Área Central */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h1 {
    margin: 0 0 5px 0;
    font-size: 28px;
    color: #1a4060;
}

.page-header p {
    margin: 0;
    color: #666;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a4060;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    transition: 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: #122d45;
    transform: translateY(-2px);
}

/* Cards de Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.stat-icon {
    background: #eef2f6;
    color: #1a4060;
    padding: 8px;
    border-radius: 8px;
    display: flex;
}

.stat-card h3 {
    margin: 0;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card p {
    margin: 5px 0 0;
    font-size: 32px;
    font-weight: 900;
    color: #111;
}

/* Tabela de Ofícios */
.table-section {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
}

.table-header h3 {
    margin: 0;
    color: #111;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
}

th {
    background: #f9fafb;
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
}

td {
    color: #374151;
    font-size: 14px;
}

/* Badges de Status */
.status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status.pendente {
    background: #fef3c7;
    color: #b45309;
}

.status.aprovado {
    background: #d1fae5;
    color: #047857;
}

.status.rejeitado {
    background: #fee2e2;
    color: #b91c1c;
}

/* --- Estilos para o Formulário de Novo Ofício --- */

.card-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
    display: block;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #1a4060;
}

/* Área de seleção de itens (Estilo SIGAM) */
.item-selector {
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
    border: 1px dashed #cbd5e1;
    margin-bottom: 30px;
}

.item-selector-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.btn-toggle {
    padding: 0 15px;
    height: 48px;
    border: 1.5px solid #1a4060;
    color: #1a4060;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-toggle:hover {
    background: #f1f5f9;
}

/* Customização para a Tabela de Itens dentro do Ofício */
#tabela_itens {
    width: 100%;
    margin-top: 15px;
    border-collapse: collapse;
}

#tabela_itens th {
    text-align: left;
    background: #f1f5f9;
    padding: 12px;
    font-size: 0.85rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#tabela_itens td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.badge-novo {
    font-size: 10px;
    background: #fef3c7;
    color: #d97706;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 8px;
}

/* Ajustes de responsividade para o formulário */
@media (max-width: 768px) {

    .form-row,
    .item-selector-row {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }
}

/* --- Novo Ofício - Classes Customizadas --- */

/* Estrutura do Card de Formulário */
.oficio-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.oficio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 25px;
}

/* Campos de Texto e Área de Descrição */
.oficio-label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
    color: #334155;
}

.oficio-input,
.oficio-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
}

.oficio-textarea {
    resize: vertical;
}

/* Seção de Anexo de Arquivo */
.anexo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-upload {
    padding: 10px 20px;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    transition: background-color 0.2s;
}

.btn-upload:hover {
    background-color: #cbd5e1;
}

.file-status {
    font-size: 14px;
    color: #64748b;
    font-style: italic;
}

.anexo-hint {
    color: #94a3b8;
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
}

/* Seletor de Itens e Estoque */
.estoque-label-caps {
    font-size: 11px;
    font-weight: bold;
    color: #64748b;
    text-transform: uppercase;
}

.btn-toggle-outline {
    padding: 12px;
    border: 1.5px solid #1a4060;
    color: #1a4060;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-toggle-outline:hover {
    background-color: #f1f5f9;
}

/* Rodapé de Ações */
.oficio-actions {
    margin-top: 40px;
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    border-top: 1px solid #f1f5f9;
    padding-top: 20px;
}

.btn-cancel {
    padding: 12px 25px;
    text-decoration: none;
    color: #64748b;
    font-weight: 600;
    transition: color 0.2s;
}

.btn-cancel:hover {
    color: #334155;
}

.btn-submit-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 35px;
}

.status.aprovado {
    background: #dcfce7;
    color: #16a34a;
}

.status.rejeitado {
    background: #fee2e2;
    color: #ef4444;
}

.status.pendente {
    background: #fef3c7;
    color: #d97706;
}

/* --- RESPONSIVIDADE (MOBILE FIRST) --- */

@media (max-width: 1024px) {
    .login-box {
        width: 95%;
        /* Login ocupa quase toda a tela em tablets */
    }
}

@media (max-width: 768px) {

    /* Topbar compacta */
    .topbar {
        padding: 15px 20px;
    }

    .user-text {
        display: none;
        /* Esconde o nome longo para sobrar espaço */
    }

    /* Transforma o Layout em coluna */
    .dashboard-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    /* Sidebar vira um menu horizontal ou lista no topo */
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #ddd;
        padding: 15px;
    }

    .sidebar a {
        padding: 10px;
    }

    /* Área principal ganha respiro */
    .main-content {
        padding: 20px;
    }

    /* Login: Empilha as duas colunas */
    .login-box {
        grid-template-columns: 1fr;
        height: auto;
    }

    .left {
        padding: 30px;
        text-align: center;
    }

    /* Tabelas: Permite rolar pro lado se for muito grande */
    .table-section {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
        /* Garante que a tabela não esmague os dados */
    }

    /* Grid de estatísticas (Cards) em uma coluna só */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Formulários: Coloca um campo embaixo do outro */
    .oficio-grid,
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .btn-primary {
        width: 100%;
        /* Botão de ação ocupa a largura toda no celular */
        justify-content: center;
    }
}

/* --- RELATÓRIOS COMPLEMENTS --- */
.tab-container {
    display: flex;
    gap: 20px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
    padding: 0 20px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 15px 20px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: 0.3s;
}

.active-tab {
    color: #1a4060;
    border-bottom: 2px solid #1a4060;
}

.btn-link {
    color: #1a4060;
    font-weight: bold;
    text-decoration: none;
    font-size: 0.9rem;
}

.icon-success {
    color: #059669;
    background: #d1fae5;
}

.icon-danger {
    color: #ef4444;
    background: #fee2e2;
}

.text-bold {
    font-weight: bold;
}

.text-center {
    text-align: center;
    padding: 20px;
}

.text-muted {
    color: #64748b;
}

.text-small {
    font-size: 0.85rem;
}

.badge-small {
    font-size: 10px !important;
}

.text-truncate-custom {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botão de Impressão */
.btn-print {
    background: #1e293b !important;
}

/* Ajuste de tabela para Mobile */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

@media print {

    .sidebar,
    .topbar,
    .btn-print,
    .tab-container,
    .btn-link,
    .nav-links,
    .sidebar-footer {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .tab-content {
        display: block !important;
        margin-bottom: 40px;
    }

    .stat-card {
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    table {
        font-size: 10pt;
    }
}

/* --- DASHBOARD & GENERAL REFINEMENTS --- */
.stat-link {
    text-decoration: none;
    color: inherit;
}

.stat-card.clickable {
    transition: transform 0.2s;
    cursor: pointer;
}

.stat-card.clickable:hover {
    transform: scale(1.02);
}

.icon-success {
    color: #059669 !important;
    background: #d1fae5 !important;
}

.icon-warning {
    color: #d97706 !important;
    background: #fef3c7 !important;
}

.text-id {
    font-weight: bold;
    color: #1a4060;
}

.btn-table-action {
    color: #1a4060;
    font-weight: bold;
    text-decoration: none;
}

.btn-table-analyze {
    color: #059669;
    font-weight: bold;
    text-decoration: none;
}

/* --- ALERTA DE ESTOQUE CRÍTICO --- */
.alert-container {
    margin-bottom: 25px;
    animation: slideIn 0.4s ease-out;
}

.alert-box-critical {
    background: #fff1f2;
    border-left: 5px solid #e11d48;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #9f1239;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.alert-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.alert-item {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #fecdd3;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-alert {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background: #e11d48;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 700;
    transition: 0.2s;
}

.btn-alert:hover {
    background: #9f1239;
}

/* --- RESPONSIVIDADE ADICIONAL --- */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .alert-items-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-qtd-tabela {
    cursor: text;
    background-color: #ffffff;
    transition: border-color 0.2s;
}

.input-qtd-tabela:focus {
    outline: none;
    border-color: #059669;
    /* Fica verde quando você clica para digitar */
    background-color: #f0fdf4;
}

.input-qtd-real {
    border: 2px solid #cbd5e1;
    transition: all 0.2s ease;
    outline: none;
}

.input-qtd-real:focus {
    border-color: #059669;
    /* Borda fica verde ao clicar */
    background-color: #f0fdf4;
    /* Fundo muda levemente ao clicar */
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}


/* Estilos dos botões de filtro */
.btn-filter {
    padding: 6px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid #e2e8f0;
    color: #64748b;
    transition: all 0.2s ease;
}

.btn-filter.active {
    background: #1a4060;
    color: white !important;
    border-color: #1a4060 !important;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(26, 64, 96, 0.2);
}

.btn-filter:hover:not(.active) {
    background: #f1f5f9;
    color: #1a4060;
    border-color: #cbd5e1;
}

.table-responsive {
    overflow-x: auto;
}