
    :root {
        --primary: #1a73e8;
        --secondary: #1557b0;
        --accent: #28a745;
        --bg: #f0f2f5;
        --sidebar: #1c2b36;
        --text-light: #f8f9fa;
        --white: #ffffff;
    }

    body {
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        margin: 0;
        display: flex;
        height: 100vh;
        background-color: var(--bg);
        overflow: hidden;
    }

    /* Sidebar Retrátil */
    .sidebar {
        width: 260px;
        background-color: var(--sidebar);
        color: var(--text-light);
        display: flex;
        flex-direction: column;
        transition: width 0.3s;
        flex-shrink: 0;
    }

    .sidebar.collapsed { width: 60px; }
    .sidebar.collapsed .menu-text, .sidebar.collapsed h2, .sidebar.collapsed small, .sidebar.collapsed .footer-text { display: none; }

    .sidebar-header {
        padding: 15px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: rgba(0,0,0,0.2);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        height: 60px;
    }

    .btn-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        cursor: pointer;
        width: 30px;
    }

    .sidebar-menu { flex: 1; padding: 10px 0; overflow-x: hidden; }

    .menu-item {
        padding: 15px 20px;
        cursor: pointer;
        display: flex;
        align-items: center;
        transition: 0.2s;
        border-left: 4px solid transparent;
        white-space: nowrap;
    }

    .menu-item:hover { background: rgba(255,255,255,0.1); }
    .menu-item.active { background: rgba(255,255,255,0.15); border-left-color: var(--primary); font-weight: bold; }

    /* Área Principal e Conteúdo Centralizado */
    .main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

    .top-bar {
        background: var(--white);
        padding: 10px 30px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        height: 60px;
    }

    .tab-container { 
        background: var(--white); 
        border-radius: 8px; 
        box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
        max-width: 1200px;
        margin: 0 auto;
        width: 95%;
    }

    .tab-header { display: flex; background: #f8f9fa; border-bottom: 1px solid #ddd; }
    
    .tab-link { 
        padding: 15px 25px; 
        cursor: pointer; 
        border: none; 
        background: none; 
        font-weight: 600; 
        color: #666; 
        font-size: 0.95rem; 
    }

    .tab-link.active { color: var(--primary); border-bottom: 3px solid var(--primary); background: white; }

    .tab-content { padding: 30px; display: none; }
    .tab-content.active { display: block; }

    .form-grid {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 15px;
        margin-bottom: 20px;
    }

    .field-group { display: flex; flex-direction: column; }
    .field-group label { font-size: 0.9rem; margin-bottom: 6px; color: #444; font-weight: 600; }
    
    .field-group input, .field-group select, .field-group textarea {
        padding: 10px 12px;
        border: 1px solid #bbb;
        border-radius: 6px;
        font-size: 1rem;
        height: 42px;
        box-sizing: border-box;
        transition: border-color 0.2s;
    }
    .field-group textarea { height: auto; }
    .field-group input:focus { border-color: var(--primary); outline: none; }

    .crud-buttons {
        margin-top: 25px;
        display: flex;
        gap: 10px;
        background: #f1f1f1;
        padding: 15px;
        border-radius: 8px;
        justify-content: center;
        border-top: 1px solid #ddd;
    }

    .btn { 
        padding: 10px 20px; 
        border: none; 
        border-radius: 6px; 
        cursor: pointer; 
        font-weight: bold; 
        font-size: 0.9rem; 
        transition: 0.2s;
    }

    .btn-save { background: var(--accent); color: white; }
    .btn-new { background: var(--primary); color: white; }
    .btn-delete { background: #dc3545; color: white; }
    .btn-nav { background: #6c757d; color: white; }
    .btn:hover { opacity: 0.9; transform: translateY(-1px); }

    .col-2 { grid-column: span 2; }
    .col-3 { grid-column: span 3; }
    .col-4 { grid-column: span 4; }
    .col-8 { grid-column: span 8; }
    .col-9 { grid-column: span 9; }
    .col-12 { grid-column: span 12; }

    #info-emitente { font-size: 0.85rem; color: #555; text-align: right; line-height: 1.3; }

    .content-section { display: none; padding: 30px; animation: fadeIn 0.3s ease; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }



/* Classe para alinhar números à direita */
.input-numeric {
    text-align: right;
    font-family: 'Courier New', Courier, monospace; 
    font-weight: bold;
} 

/* Compacta APENAS a aba de Dados do Emitente */
#cfg-geral input, 
#cfg-geral select {
    height: 32px !important;
    padding: 4px 8px !important;
    font-size: 0.85rem !important;
}

#cfg-geral .field-group label {
    font-size: 0.75rem !important;
    margin-bottom: 2px !important;
}

#cfg-geral .form-grid {
    gap: 8px !important;
}

/* Mantém o scroll de segurança na área de conteúdo das configurações */
#sec-config .tab-main-content {
    max-height: 70vh; 
    overflow-y: auto;
}




/* Estilo para a Div Expansível de Impostos */
.tax-panel {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.tax-header {
    background: #f1f1f1;
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: #444;
    border-bottom: 1px solid #ddd;
}

.tax-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 15px;
}

.tax-content.open {
    max-height: 500px; /* Altura suficiente para o formulário */
    padding: 15px;
}

.tax-form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 10px;
}

/* Compacta os campos dentro do painel de impostos */
.tax-panel input, .tax-panel select {
    height: 32px !important;
    font-size: 0.85rem !important;
    padding: 4px 8px !important;
}




.btn-ajuda { background: var(--primary); color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-weight: bold; font-size: 14px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: 0.2s; margin-left: 8px; }
.btn-ajuda:hover { background-color: #1557b0; }



/* ============================================================
   RESPONSIVO MOBILE DEFINITIVO - NFeMax
   ============================================================ */
@media (max-width: 768px) {
    body {
        flex-direction: column !important;
        overflow: auto !important; /* Libera o movimento da tela */
        height: auto !important;
    }

    /* 1. Sidebar vira cabeçalho fixo */
    .sidebar {
        width: 100% !important;
        height: auto !important;
        position: sticky;
        top: 0;
        z-index: 9999;
        flex-direction: column !important;
    }

    /* 2. Controle do Menu (Toggle) */
    /* Quando a sidebar está 'collapsed', o menu some no mobile */
    .sidebar.collapsed .sidebar-menu {
        display: none !important;
    }

    /* Quando você clica no botão, ela perde o 'collapsed' e mostra isso: */
    .sidebar-menu {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        background: var(--sidebar);
        max-height: 80vh;
        overflow-y: auto;
    }

    .menu-item {
        padding: 15px 20px !important;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .menu-text, .sidebar h2, .sidebar small {
        display: inline !important; /* Garante que o texto apareça no mobile */
    }

    /* 3. Ajuste de Campos (Grids) */
    .main-content {
        width: 100% !important;
        overflow: visible !important;
    }

    .form-grid, .tax-form-grid {
        display: block !important; /* Empilha os campos um embaixo do outro */
    }

    .field-group {
        width: 100% !important;
        margin-bottom: 15px !important;
        grid-column: span 12 !important; /* Força ocupação total */
    }

    .field-group input, .field-group select, .field-group textarea {
        width: 100% !important;
        height: 48px !important; /* Maior para facilitar o toque */
        font-size: 16px !important; /* Evita zoom automático no iPhone */
    }

    /* 4. Abas e Containers */
    .tab-container {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .tab-header {
        overflow-x: auto;
        white-space: nowrap;
        display: flex !important;
        -webkit-overflow-scrolling: touch;
    }

    .tab-link {
        padding: 12px 15px !important;
        flex: 0 0 auto;
    }

    .tab-content {
        padding: 15px !important;
    }

    /* 5. Rodapé de Totais e Botões */
    .crud-buttons {
        flex-wrap: wrap !important;
        position: sticky;
        bottom: 0;
        z-index: 999;
    }

    .btn {
        flex: 1 1 45% !important; /* Botões dois a dois no mobile */
        margin-bottom: 5px;
    }

    /* Barra de totais do rodapé do pedido */
    section#sec-pedidos div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }
    
    section#sec-pedidos .field-group[style*="width: 100px"] {
        width: 31% !important; /* Três totais por linha no celular */
        margin-bottom: 5px;
    }
}
