/* Configuração de Variáveis e Cores da Identidade Visual */
:root {
    --primary-green: #18452B; /* Verde escuro profundo */
    --accent-pink: #F29CBE;   /* Rosa claro */
    --bg-light: #f4f6f8;      /* Cinza super claro para o fundo */
    --text-dark: #333333;     /* Cor principal da fonte */
    
    /* Tipografia */
    --font-heading: 'Roc Grotesk Variable', 'Satoshi', system-ui, sans-serif;
    --font-text: 'Satoshi', system-ui, sans-serif;
}

/* Reset Básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-text);
    background-color: var(--bg-light);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
}

/* ---------------------------------
   CABEÇALHO (HEADER)
--------------------------------- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-green);
    color: #ffffff;
    padding: 0 2rem;
    height: 70px;
    min-height: 70px;
    flex: 0 0 70px;        /* nunca encolher — impede compressão pelo flex container do #dashboard-screen */
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Marca oficial (imagens PNG extraídas do manual) ------------------------ */
.brand-logo {
    display: block;
    width: auto;
    height: auto;
    -webkit-user-drag: none;
    user-select: none;
}
.brand-logo-header  { height: 44px; }      /* no header verde (branca) */
.brand-logo-login   { height: 68px; margin: 0 auto 14px; }  /* no card de login (verde) */

/* Placeholder Logo Benassi Flores (LEGADO — mantido caso algum lugar ainda use) */
.logo-text {
    font-size: 1.6rem;
    font-style: italic;
    font-weight: 500;
    letter-spacing: -0.5px;
    color: var(--accent-pink); /* 'Flores' em Rosa */
}

.logo-text span {
    font-weight: 900;
    color: #ffffff; /* 'Benassi' em Branco */
}

/* ---------------------------------
   NAVEGAÇÃO CENTRAL (ABAS)
--------------------------------- */
.main-nav {
    display: flex;
    gap: 0.5rem;
    height: 100%;
}

.tab-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-family: var(--font-text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0 1.5rem;
    height: 100%;
    opacity: 0.7;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.ativa {
    opacity: 1;
    color: var(--accent-pink);
    border-bottom-color: var(--accent-pink);
}

/* Sub-nav dentro de CARRINHOS */
.car-subnav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    padding: 0 16px;
    background: var(--bg-card, #fff);
}
.car-subtab {
    padding: 12px 20px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.car-subtab:hover { color: var(--text-primary, #222); }
.car-subtab.ativa {
    color: var(--accent-pink, #F29CBE);
    border-bottom-color: var(--accent-pink, #F29CBE);
}
.car-panel { display: none; }
.car-panel.ativa { display: block; }

/* Acompanhamento — resumo */
.acomp-summary {
    padding: 16px;
    display: flex;
    gap: 16px;
}
.acomp-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
}
.acomp-stat-danger .acomp-stat-num {
    font-size: 28px;
    font-weight: 800;
    color: #dc2626;
}
.acomp-stat-danger .acomp-stat-label {
    font-size: 0.88rem;
    color: #991b1b;
    font-weight: 600;
}
/* Badge de dias perdido */
.dias-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
}
.dias-badge.dias-ok { background: #dcfce7; color: #166534; }
.dias-badge.dias-warn { background: #fef9c3; color: #854d0e; }
.dias-badge.dias-danger { background: #fef2f2; color: #dc2626; }

/* ---------------------------------
   MENU DO USUÁRIO
--------------------------------- */
.user-menu {
    position: relative;
    cursor: pointer;
    padding-bottom: 15px;
    margin-bottom: -15px;
    display: flex;
    align-items: center;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #ffffff;
    min-width: 180px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.1);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    z-index: 1000; /* Assegura que fique por cima */
}

.dropdown-content a {
    color: var(--text-dark);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-content a:hover {
    background-color: var(--bg-light);
    color: var(--primary-green);
    font-weight: 500;
}

/* Mostra o dropdown ao passar o mouse */
.user-menu:hover .dropdown-content {
    display: block;
}

/* ---------------------------------
   ÁREA DE CONTEÚDO PRINCIPAL
--------------------------------- */
.content-area {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
    /* Somente o scroll HORIZONTAL é bloqueado no nível da página — vertical
       segue funcionando normalmente. Formularios longos (config) continuam
       podendo rolar quando necessário. */
    overflow-x: hidden;
}

.tab-content {
    display: none; /* Oculta todas as abas por padrão */
    animation: fadeIn 0.3s ease-out;
}

.tab-content.ativa {
    display: block; /* Mostra a aba ativa */
}

/* Container/wrapper da tabela: altura calculada em JS (fit-viewport dinâmico)
   e escrita como custom property abaixo. O valor é atualizado no load e a
   cada resize. Fallback = calc antigo caso o JS não rode. */
.datagrid-container[data-fit-viewport],
.datagrid-wrapper[data-fit-viewport] {
    max-height: var(--fit-viewport-h, calc(100vh - 380px)) !important;
}

.tab-content h2 {
    color: var(--primary-green);
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

.tab-content p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* ---------------------------------
   PLACEHOLDER TABELA (EXCEL)
--------------------------------- */
.table-placeholder {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
    width: 100%;
    height: 65vh;
    overflow: auto; /* Habilita scroll para o conteúdo interno */
    position: relative;
}

/* Div larga e alta para simular linhas e colunas no fundo via gradiente */
.scroll-content-simulator {
    height: 1500px;
    width: 2500px;
    background: 
        repeating-linear-gradient(0deg, transparent, transparent 39px, #eaeaea 39px, #eaeaea 40px),
        repeating-linear-gradient(90deg, transparent, transparent 149px, #eaeaea 149px, #eaeaea 150px);
    background-color: #ffffff;
}

/* Animação suave na transição de abas */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------
   LOGIN SCREEN
--------------------------------- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--primary-green);
    width: 100%;
}

.login-box {
    background: #ffffff;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box .logo-text {
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-box .logo-text span {
    color: var(--primary-green);
}

.login-box p {
    color: #666;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

#login-form,
#change-password-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#login-form input,
#change-password-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: var(--font-text);
    font-size: 1rem;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

#login-form input:focus,
#change-password-form input:focus {
    border-color: var(--primary-green);
}

/* Botão dentro dos forms de auth ocupa a linha inteira */
#login-form .login-btn,
#change-password-form .login-btn {
    width: 100%;
}

.login-btn {
    padding: 14px;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.3s;
    position: relative;
}

.login-btn:hover {
    background-color: #1e4533;
}

.login-btn:disabled {
    background-color: #a5d6b4;
    cursor: not-allowed;
    color: transparent; /* Oculta texto durante o loading */
}

/* Spinner Animation */
.login-btn.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-msg {
    color: red;
    font-size: 0.85rem;
    margin-top: 1rem;
    min-height: 1.2em;
}

/* ---------------------------------
   COMPONENTES ESTRUTURAIS NOVOS
--------------------------------- */

/* Password Wrapper (Olhinho) */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrapper input {
    width: 100%;
    padding-right: 40px !important;
}
.password-wrapper .toggle-password {
    position: absolute;
    right: 12px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #666;
    padding: 0;
    outline: none;
}

/* Sub Tabs (Importação) */
.sub-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #ddd;
}
.sub-tab-btn {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
}
.sub-tab-btn:hover {
    color: var(--primary-green);
}
.sub-tab-btn.ativa {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
}
.sub-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}
.sub-tab-content.ativa {
    display: block;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #ccc;
    padding: 3rem;
    text-align: center;
    border-radius: 8px;
    color: #666;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-green);
    background: #f0fdf4;
    cursor: pointer;
}

/* =========================================================================
   Aba: Importação de Pedidos — redesign
   ========================================================================= */

.import-tab { padding-bottom: 32px; }

/* Hero */
.import-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 30px 32px;
    margin-bottom: 26px;
    border-radius: 14px;
    background:
        radial-gradient(140% 100% at 100% 0%, rgba(242,156,190,0.20) 0%, transparent 55%),
        linear-gradient(135deg, #18452B 0%, #204b34 60%, #0f3020 100%);
    color: #fff;
    box-shadow: 0 10px 24px rgba(24,69,43,0.18);
    position: relative;
    overflow: hidden;
}
.import-hero::after {
    content: '';
    position: absolute;
    right: -60px; bottom: -60px;
    width: 220px; height: 220px;
    border-radius: 50%;
    background: rgba(242,156,190,0.10);
    pointer-events: none;
}
.import-hero-text { position: relative; z-index: 1; max-width: 780px; }
.import-hero h2 {
    margin: 0 0 10px 0;
    color: #ffffff;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    font-family: var(--font-heading);
    text-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
/* Selector com especificidade extra para vencer .tab-content p (cor #666). */
.import-hero p.import-hero-sub {
    margin: 0;
    color: #f5efe8;                     /* creme suave, alto contraste no verde */
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.55;
    opacity: 1;
    text-shadow: 0 1px 6px rgba(0,0,0,0.35);
}

/* Sub-nav (cards) */
.import-sub-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    border: 0;
    margin-bottom: 22px;
    padding: 0;
}
.import-tab-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid rgba(24,69,43,0.22);      /* verde bem esmaecido, opacidade maior */
    border-radius: 12px;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
    transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s, background 0.14s;
    color: #333;
    border-bottom: 1.5px solid rgba(24,69,43,0.22) !important; /* override sub-tab-btn default */
    font: inherit;
}
.import-tab-btn:hover {
    border-color: var(--primary-green);
    background: #f6faf7;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(24,69,43,0.08);
    color: #222;
}
.import-tab-btn.ativa {
    background: linear-gradient(135deg, #18452B 0%, #22593a 100%);
    border-color: #18452B !important;
    color: #fff;
    box-shadow: 0 8px 22px rgba(24,69,43,0.28);
}
.import-tab-btn.ativa .itb-desc { color: rgba(255,255,255,0.78); }
/* Mantém a caixa branca no estado ativo para as logos ficarem legíveis
   sobre o fundo verde do card. */
.import-tab-btn.ativa .itb-icon {
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.20), 0 4px 8px rgba(0,0,0,0.18);
}
.import-tab-btn .itb-icon {
    font-size: 22px; line-height: 1;
    background: #ffffff;
    padding: 6px;
    border-radius: 10px;
    flex-shrink: 0;
    transition: background 0.14s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.import-tab-btn .itb-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.import-tab-btn .itb-title {
    font-size: 14px; font-weight: 700; letter-spacing: 0.2px;
}
.import-tab-btn .itb-desc {
    font-size: 11.5px; color: #667;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Cards de conteúdo */
.import-card {
    background: #fff;
    border: 1px solid #e8ebe9;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.import-card-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: center;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px dashed #e5e7eb;
}
.import-card-header .ich-icon {
    font-size: 28px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.05);
    padding: 10px;
    border-radius: 14px;
    line-height: 0;
    width: 84px;
    height: 84px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.import-card-header h3 {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    color: var(--primary-green);
    font-family: var(--font-heading);
    letter-spacing: 0.2px;
}
.import-card-header p {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 640px;
}
.import-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.import-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: #f2f5f2;
    color: var(--primary-green);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    border: 1px solid rgba(24,69,43,0.12);
    font-family: 'Courier New', monospace;
}
.import-chip.import-chip-hint {
    background: #fff3f7;
    color: #b83567;
    border-color: rgba(242,156,190,0.5);
    font-family: inherit;
    letter-spacing: normal;
    font-weight: 600;
    font-size: 11.5px;
}
.import-chip.import-chip-hint code {
    background: rgba(242,156,190,0.2);
    padding: 1px 5px; border-radius: 4px;
    font-size: 10.5px; margin: 0 3px;
}

/* Upload area modernizada */
.upload-area-modern {
    margin-top: 0;
    padding: 34px 20px;
    border: 2px dashed #cfd6d1;
    background: linear-gradient(180deg, #fbfcfb 0%, #f6f9f6 100%);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.upload-area-modern:hover,
.upload-area-modern.dragover {
    border-color: var(--primary-green);
    background: linear-gradient(180deg, #f0fbf3 0%, #e6f5ec 100%);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(24,69,43,0.12);
}
.upload-area-modern .ua-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 4px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.08));
}
.upload-area-modern .ua-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-green);
    letter-spacing: 0.2px;
}
.upload-area-modern .ua-hint {
    font-size: 12.5px;
    color: #667;
    max-width: 520px;
    text-align: center;
    line-height: 1.5;
}

/* Ajustes responsivos */
@media (max-width: 780px) {
    .import-hero { flex-direction: column; align-items: flex-start; }
    .import-card-header {
        grid-template-columns: auto 1fr;
    }
    .import-chips { grid-column: 1 / -1; justify-content: flex-start; }
    .page-hero { flex-direction: column; align-items: flex-start; }
    .page-hero-tag { align-self: flex-start; }
}

/* =========================================================================
   Hero compacto reutilizável (Romaneio, Conferência, Histórico, Fatura)
   ========================================================================= */
.page-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    margin-bottom: 20px;
    border-radius: 12px;
    background:
        radial-gradient(120% 100% at 100% 0%, rgba(242,156,190,0.18) 0%, transparent 55%),
        linear-gradient(135deg, #18452B 0%, #204b34 60%, #0f3020 100%);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(24,69,43,0.14);
    position: relative;
    overflow: hidden;
}
.page-hero::after {
    content: '';
    position: absolute;
    right: -70px; top: -70px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(242,156,190,0.10);
    pointer-events: none;
}
.page-hero-text { position: relative; z-index: 1; min-width: 0; }
/* Aumenta a especificidade p/ vencer .tab-content h2 e .tab-content p */
.page-hero .page-hero-text h2 {
    margin: 0 0 4px 0;
    color: #ffffff;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: 0.25px;
    font-family: var(--font-heading);
    text-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.page-hero p.page-hero-sub {
    margin: 0;
    color: #f5efe8;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    opacity: 1;
    max-width: 720px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.page-hero-tag {
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.28);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    z-index: 1;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    flex-shrink: 0;
}

/* =========================================================================
   Sub-nav polido — pastilha verde no ativo, hover suave sem "flash pinkado"
   ========================================================================= */
.sub-nav-polished {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 18px;
    padding: 4px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}
/* Reset defensivo p/ evitar borda inferior do .sub-tab-btn e cor herdada
   piscando durante o hover. Usamos apenas background-color (sem gradiente)
   para o hover não brigar com a transição do estado ativo. */
.sub-nav-polished .sub-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: 0 !important;
    border-bottom: 0 !important;
    background: transparent;
    background-color: transparent;
    color: #4a5157;
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    outline: none;
    cursor: pointer;
}
/* Hover só entra em quem NÃO está ativo — evita o "efeito estranho" ao
   passar o mouse por cima da aba já selecionada. */
.sub-nav-polished .sub-tab-btn:not(.ativa):hover {
    background-color: #eef3ef;
    color: var(--primary-green);
}
.sub-nav-polished .sub-tab-btn:not(.ativa):hover .stb-dot {
    background: var(--primary-green);
}
.sub-nav-polished .sub-tab-btn.ativa,
.sub-nav-polished .sub-tab-btn.ativa:hover {
    background: #18452B;      /* cor sólida — sem gradiente para transicionar */
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(24,69,43,0.22);
    cursor: default;
}
.sub-nav-polished .sub-tab-btn.ativa .stb-dot {
    background: var(--accent-pink);
    box-shadow: 0 0 0 2px rgba(242,156,190,0.22);
}
.sub-nav-polished .stb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b8c0c4;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

/* Logos de marca (Hortifruti / Prezunic) usados no lugar dos emojis.
   Todas ocupam 100% da caixa contêiner com margem interna e preservam
   proporção, para máxima nitidez. */
.brand-icon {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    image-rendering: -webkit-optimize-contrast;
}
/* Sub-nav card: caixa 52px → logo até 44px */
.import-tab-btn .itb-icon .brand-icon {
    width: 44px;
    height: 44px;
}
/* Header do card de conteúdo: caixa 84px → logo 68px */
.import-card-header .ich-icon .brand-icon {
    width: 68px;
    height: 68px;
}
/* Upload zone: bem maior para dar destaque no drop area */
.upload-area-modern .ua-icon { line-height: 0; display: flex; justify-content: center; }
.upload-area-modern .ua-icon .brand-icon-lg {
    width: 96px;
    height: 96px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
}

/* Formulário de Digitação Manual */
.manual-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-top: 1rem;
}
.manual-form > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.manual-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}
.manual-form input, .manual-form select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* DataGrid / Tabela (Planilha Gigante)
   -----------------------------------------------------------
   Enquadra a tabela dentro do viewport visível:
   - overflow: auto → scroll horizontal E vertical acontecem
     DENTRO do container (nunca empurram a página para baixo).
   - height calculado subtraindo o header sticky + hero + sub-nav +
     toolbar + margens, para o rodapé da tabela nunca ficar abaixo
     da dobra. `dvh` respeita a UI dinâmica do browser mobile;
     fallback para `vh` em navegadores antigos.
*/
.datagrid-container {
    overflow: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-top: 1rem;
    /* Container fixo dentro da janela: nunca ultrapassa a viewport,
       independente do tamanho da tela ou do zoom. Scroll horizontal + vertical
       acontece SEMPRE dentro daqui. Uso `dvh` (dynamic viewport height) para
       cobrir barras de nav mobile; fallback `vh` para navegadores antigos.
       O 380px cobre header + padding + hero + sub-nav + toolbar do Romaneio. */
    max-height: calc(100vh - 380px);
    max-height: calc(100dvh - 380px);
    max-width: 100%;
    scrollbar-gutter: stable both-edges;
}
/* Cabeçalho fixo enquanto o corpo da tabela rola verticalmente dentro
   do container. Como a tabela usa position:sticky no thead th (mais adiante),
   basta garantir que o container tenha overflow controlado. */
.datagrid-table {
    border-collapse: collapse;
    min-width: 2500px; /* Largura gigante para caber todas filiais */
}
.datagrid-table th, .datagrid-table td {
    padding: 8px 10px;
    border: 1px solid #8a8a8a; /* Borda mais escura, estilo Excel impresso */
    text-align: left;
    font-size: 0.85rem;
    white-space: nowrap;
}
.datagrid-table th {
    background-color: #f1f3f4;
    color: #333;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Coluna DESCRIÇÃO: largura controlada com quebra de texto */
.datagrid-table th.col-descricao,
.datagrid-table td.col-descricao {
    max-width: 180px;
    min-width: 120px;
    white-space: normal;
    word-break: break-word;
    text-align: left;
}

/* Colunas descritivas (4–12) mais estreitas com quebra de texto nos headers */
.datagrid-table thead th:nth-child(n+4):nth-child(-n+12) {
    white-space: normal;
    word-break: break-word;
    max-width: 80px;
    min-width: 55px;
    font-size: 0.78rem;
    padding: 6px 4px;
    text-align: center;
}
.datagrid-table tbody td:nth-child(n+4):nth-child(-n+12) {
    max-width: 80px;
    min-width: 55px;
    padding: 6px 4px;
    text-align: center;
    font-size: 0.82rem;
}

/* Coloração das 9 colunas informativas do ROMANEIO GERAL (apenas neste grid).
   nth-child é 1-indexed e conta com NAO MEXER (1) e PREZUNIC (2) que estão hidden:
     4 QTDE POR CX          → amarelo
     5 QTDE MINIMA CAMADA   → azul claro dessaturado
     6 PEDIDO EM CAMADA     → cinza
     7 RESTO ANTERIOR       → lilás
     8 COMPRAS INTER        → verde
     9 SOBRAS               → off-white / cinza muito claro
    10 PREÇO LEILÃO         → azul claro
    11 VALOR LKP            → verde
    12 PRECO                → azul marinho (texto branco)
*/
#sub-romaneio-geral .datagrid-table thead th:nth-child(4),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(4) {
    background-color: #FFF3B0; /* amarelo (QTDE POR CX) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(5),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(5) {
    background-color: #DDE9F1; /* azul claro dessaturado (QTDE MINIMA CAMADA) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(6),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(6) {
    background-color: #DDDDDD; /* cinza (PEDIDO EM CAMADA) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(7),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(7) {
    background-color: #D5B0E5; /* lilás (RESTO ANTERIOR) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(8),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(8),
#sub-romaneio-geral .datagrid-table thead th:nth-child(11),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(11) {
    background-color: #A9D5A0; /* verde (COMPRAS INTER e VALOR LKP) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(9),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(9) {
    background-color: #F5F5F5; /* cinza muito claro (SOBRAS) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(10),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(10) {
    background-color: #B0D4F1; /* azul claro (PREÇO LEILÃO) */
}
#sub-romaneio-geral .datagrid-table thead th:nth-child(12),
#sub-romaneio-geral .datagrid-table tbody td:nth-child(12) {
    background-color: #1A365D; /* azul marinho (PRECO) */
    color: #ffffff;
}
/* Mantém hover suave mesmo com background colorido nas colunas informativas */
#sub-romaneio-geral .datagrid-table tbody tr:hover td:nth-child(n+4):nth-child(-n+12) {
    filter: brightness(1.05);
}

/* -------------------------------------------------------------------------
   Mesma paleta das 9 colunas informativas aplicada ao ROMANEIO HORTIFRUTI.
   O grid HORTIFRUTI usa a tabela #hortifruti-table (mesmo layout de colunas
   do GERAL). NAO MEXER (1) e HORTIFRUTI (2) ficam ocultas, então as cores
   começam a partir da coluna 4 igual ao GERAL.
------------------------------------------------------------------------- */
#hortifruti-table thead th:nth-child(4),
#hortifruti-table tbody td:nth-child(4) {
    background-color: #FFF3B0; /* amarelo (QTDE POR CX) */
}
#hortifruti-table thead th:nth-child(5),
#hortifruti-table tbody td:nth-child(5) {
    background-color: #DDE9F1; /* azul claro dessaturado (QTDE MINIMA CAMADA) */
}
#hortifruti-table thead th:nth-child(6),
#hortifruti-table tbody td:nth-child(6) {
    background-color: #DDDDDD; /* cinza (PEDIDO EM CAMADA) */
}
#hortifruti-table thead th:nth-child(7),
#hortifruti-table tbody td:nth-child(7) {
    background-color: #D5B0E5; /* lilás (RESTO ANTERIOR) */
}
#hortifruti-table thead th:nth-child(8),
#hortifruti-table tbody td:nth-child(8),
#hortifruti-table thead th:nth-child(11),
#hortifruti-table tbody td:nth-child(11) {
    background-color: #A9D5A0; /* verde (COMPRAS INTER e VALOR LKP) */
}
#hortifruti-table thead th:nth-child(9),
#hortifruti-table tbody td:nth-child(9) {
    background-color: #F5F5F5; /* cinza muito claro (SOBRAS) */
}
#hortifruti-table thead th:nth-child(10),
#hortifruti-table tbody td:nth-child(10) {
    background-color: #B0D4F1; /* azul claro (PREÇO LEILÃO) */
}
#hortifruti-table thead th:nth-child(12),
#hortifruti-table tbody td:nth-child(12) {
    background-color: #1A365D; /* azul marinho (PRECO) */
    color: #ffffff;
}
#hortifruti-table tbody tr:hover td:nth-child(n+4):nth-child(-n+12) {
    filter: brightness(1.05);
}

/* Colunas de loja com largura uniforme, texto quebrado e centralizado */
.datagrid-table thead th[data-store],
.datagrid-table tbody td[data-store] {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
}
.datagrid-table thead th[data-store] {
    padding: 6px 20px 6px 8px; /* right para caber o botão de filtro */
}

/* Header de loja com duas linhas: código em cima, nome embaixo */
.datagrid-table thead th .store-code {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #333;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(0,0,0,0.15);
    margin-bottom: 3px;
    text-align: center;
}
.datagrid-table thead th .store-name {
    display: block;
    text-align: center;
    font-weight: 600;
    white-space: normal;
    word-break: break-word;
    line-height: 1.15;
    min-height: 2.3em; /* reserva altura p/ 2 linhas, mantendo header alinhado */
}

/* Coloração dos headers de loja por região do HORTIFRUTI */
.datagrid-table thead th.store-region-rj {
    background-color: #B0D4F1; /* azul claro (RJ) */
}
.datagrid-table thead th.store-region-sp {
    background-color: #A9D5A0; /* verde (SP) */
}
/* Mantém o background da região mesmo quando o thead sticky sobrepõe */
.datagrid-table thead th.store-region-rj,
.datagrid-table thead th.store-region-sp { color: #1a1a1a; }

/* ============================================================
   Aba CONFIGURAÇÕES: layout com sidebar + painéis
   ============================================================ */
.config-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    margin-top: 1rem;
    align-items: start;
}
.config-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
    border-right: 1px solid #e2e2e2;
}
.config-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    padding: 12px 12px 4px;
    font-weight: 600;
}
.config-nav-btn {
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 14px;
    font-size: 0.92rem;
    color: #333;
    cursor: pointer;
    border-left: 3px solid transparent;
    font-family: var(--font-text);
}
.config-nav-btn:hover { background: #f1f8f4; color: var(--primary-green); }
.config-nav-btn.ativa {
    background: #eaf4ef;
    color: var(--primary-green);
    border-left-color: var(--primary-green);
    font-weight: 600;
}

.config-main { min-width: 0; padding-right: 4px; }
.config-panel { display: none; }
.config-panel.ativa { display: block; }

.config-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.config-panel-header h3 { margin: 0; color: var(--primary-green); font-size: 1.15rem; }

.cfg-help { font-size: 0.85rem; color: #666; margin: 6px 0 12px; }
.cfg-subtitle { margin-top: 24px; color: var(--primary-green); font-size: 1rem; }
.cfg-status { font-size: 0.85rem; margin-left: 8px; }

.cfg-input {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font: inherit;
    background: #fff;
}
.cfg-input:focus { outline: 2px solid var(--primary-green); outline-offset: -1px; }
.cfg-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
.filial-toggle {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
    width: fit-content;
    margin-top: 2px;
}
.filial-btn {
    border: none;
    background: #f5f5f5;
    color: #666;
    padding: 6px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.filial-btn.active {
    background: var(--primary-green, #256029);
    color: #fff;
}
.filial-btn:hover:not(.active) { background: #e8e8e8; }
.cfg-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 480px;
    margin-top: 8px;
}
.cfg-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: #444; }
.cfg-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cfg-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.cfg-btn-primary { width: auto; padding: 10px 20px; margin-top: 0; font-size: 0.9rem; }
.cfg-btn-danger {
    width: auto; padding: 10px 20px; margin-top: 0; font-size: 0.9rem;
    background-color: #d9534f;
}

.cfg-two-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 12px;
}
.cfg-card {
    background: #fafafa;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 16px 18px;
}
.cfg-card h4 { margin: 0 0 8px 0; color: var(--primary-green); font-size: 0.95rem; }

/* Tabelas de cadastros */
.config-table-wrap {
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    overflow: auto;
    max-height: 60vh;
}
.cfg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
}
.cfg-table th, .cfg-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}
.cfg-table thead th {
    background: var(--primary-green);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1;
    font-weight: 600;
}
.cfg-table tbody tr:hover { background: #f6faf7; }
.cfg-table .cfg-row-inactive td { color: #888; background: #f9f9f9; }
.cfg-table td.center, .cfg-table th.center { text-align: center; }
.cfg-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}
.cfg-badge.on  { background: #d3ecd6; color: #256029; }
.cfg-badge.off { background: #eee; color: #888; }
.cfg-mini-btn {
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.78rem;
}
.cfg-mini-btn:hover { background: #eaf4ef; border-color: var(--primary-green); color: var(--primary-green); }

/* Lista de perfis */
.cfg-list { list-style: none; padding: 0; margin: 8px 0 0; }
.cfg-list li {
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.cfg-list li:hover { background: #f1f8f4; }
.cfg-list li.ativa { background: #eaf4ef; border-color: var(--primary-green); color: var(--primary-green); font-weight: 600; }
.cfg-list li .cfg-badge { font-size: 0.68rem; }

.cfg-perf-layout .cfg-prof-list-card  { max-width: 340px; }
.cfg-perf-layout .cfg-prof-edit-card  { min-width: 0; }

/* Grid de permissões (checkboxes agrupadas) */
.cfg-perm-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.cfg-perm-group {
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 10px 12px;
}
.cfg-perm-group-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-green);
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}
.cfg-perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-size: 0.85rem;
}
.cfg-perm-item.state-inherited { color: #444; }
.cfg-perm-item.state-granted  { color: #256029; font-weight: 500; }
.cfg-perm-item.state-revoked  { color: #b04a4a; }
.cfg-perm-item .state-pill {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: #eee;
    color: #666;
}
.cfg-perm-item.state-granted  .state-pill { background: #d3ecd6; color: #256029; }
.cfg-perm-item.state-revoked  .state-pill { background: #f7d9d6; color: #b04a4a; }

.req { color: #d9534f; }

/* Modal genérico usado em Configurações (editar produto etc.) */
.cfg-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 10001;
}
.cfg-modal {
    background: #fff;
    border-radius: 8px;
    max-width: 780px; width: 92%;
    max-height: 90vh; overflow: auto;
    padding: 18px 22px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.cfg-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.cfg-modal-header h3 { margin: 0; color: var(--primary-green); }
.cfg-modal-close {
    background: transparent; border: none; font-size: 1.2rem; cursor: pointer; color: #888;
}
.cfg-modal-close:hover { color: #d9534f; }

/* --- Aba Conferência: seções de espelhos --- */
.conf-section {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    background: #fafafa;
}
.conf-section + .conf-section { margin-top: 1.25rem; }
.conf-section-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    letter-spacing: 1px;
    color: var(--primary-green, #1e4533);
    border-bottom: 2px solid var(--primary-green, #1e4533);
    padding-bottom: 0.4rem;
    text-transform: uppercase;
}
.conf-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.conf-buttons .conf-btn-primary {
    width: auto;
    padding: 12px 24px;
    font-size: 1rem;
    margin-top: 0;
}
.conf-buttons .conf-btn-secondary {
    width: auto;
    padding: 12px 24px;
    font-size: 1rem;
    margin-top: 0;
    background-color: #fff;
    color: var(--primary-green, #1e4533);
    border: 2px solid var(--primary-green, #1e4533);
}

/* ==== Conferência: lista de romaneios fechados ==== */
.conf-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 1rem 0 1.25rem 0;
}
.conf-filters input[type="text"] {
    flex: 1;
    max-width: 360px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}
.conf-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.conf-empty {
    padding: 32px 12px;
    text-align: center;
    color: #666;
    border: 1px dashed #d5d5d5;
    border-radius: 8px;
    background: #fafafa;
}
.conf-empty-error { color: #b02a37; border-color: #f1c4c9; background: #fdf3f4; }

.conf-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border: 1px solid #e2e2e2;
    border-radius: 10px;
    background: #fff;
    transition: box-shadow .15s ease, transform .05s ease;
}
.conf-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.conf-card-info { min-width: 0; flex: 1; }
.conf-card-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conf-card-meta {
    margin-top: 4px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.85rem;
    color: #666;
}
.conf-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.conf-badge-geral   { background: #e8f0eb; color: #1e4533; }
.conf-badge-horti   { background: #fff2d6; color: #7a4a00; }
.conf-card-date { color: #888; }

.conf-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.conf-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #d5d5d5;
    background: #fff;
    color: #333;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease, transform .05s ease;
}
.conf-icon-btn:hover  { background: #f2f6f3; border-color: #b7c9be; }
.conf-icon-btn:active { transform: scale(0.96); }
.conf-icon-btn:disabled { opacity: 0.5; cursor: default; }
.conf-icon-btn.conf-icon-primary {
    background: var(--primary-green, #1e4533);
    color: #fff;
    border-color: var(--primary-green, #1e4533);
}
.conf-icon-btn.conf-icon-primary:hover { background: #163826; }
.conf-icon-btn.conf-icon-rj,
.conf-icon-btn.conf-icon-sp {
    width: auto;
    padding: 0 10px;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}
.conf-icon-btn.conf-icon-rj { color: #14497a; border-color: #b8cde0; background: #eef4fa; }
.conf-icon-btn.conf-icon-rj:hover { background: #d9e6f3; }
.conf-icon-btn.conf-icon-sp { color: #7a3e14; border-color: #e0c5b8; background: #faf0ee; }
.conf-icon-btn.conf-icon-sp:hover { background: #f3d9d3; }

/* Modal Detalhar */
.conf-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.conf-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}
.conf-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    max-width: 92vw;
    max-height: 88vh;
    width: 1000px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.conf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e2e2;
    background: #fafafa;
}
.conf-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conf-modal-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.conf-modal-close:hover { background: #eee; color: #222; }
.conf-modal-body { overflow: auto; padding: 12px 14px; }

/* ================================================================
   Modal de SUCESSO (compra fechada, fatura enviada, etc.) — cabeçalho
   verde primário do ERP, ícone de check, cards de estatística e área
   opcional pra avisos amarelos. Substitui o alert() nativo do browser.
   ================================================================ */
.erp-success-modal .conf-modal-content { width: 480px; max-width: 92vw; }
.erp-success-modal .conf-modal-header {
    background: linear-gradient(135deg, var(--primary-green, #18452B) 0%, #22593a 100%);
    color: #fff;
    padding: 16px 20px;
    border-bottom: none;
}
.erp-success-modal .conf-modal-header h3 {
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 700;
}
.erp-success-modal .conf-modal-header .success-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    font-size: 1rem;
    color: #B0F0B0;
}
.erp-success-modal .conf-modal-close { color: #fff; }
.erp-success-modal .conf-modal-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.erp-success-modal .conf-modal-body {
    padding: 20px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.erp-success-name {
    font-size: 0.85rem;
    color: #7a8290;
    text-align: center;
    margin: 0;
}
.erp-success-name strong {
    display: block;
    font-size: 1.15rem;
    color: var(--primary-green, #18452B);
    margin-bottom: 2px;
    font-weight: 800;
    letter-spacing: 0.2px;
}
.erp-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.erp-stat-card {
    background: #f4f8f5;
    border: 1px solid #d6e3d9;
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
}
.erp-stat-card .val {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-green, #18452B);
    line-height: 1.1;
}
.erp-stat-card .lbl {
    display: block;
    font-size: 0.72rem;
    color: #6b7580;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    font-weight: 600;
}
.erp-info-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #eef5ff;
    border: 1px solid #cfe0f5;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #23507e;
}
.erp-info-line .info-ico { font-size: 1rem; }
.erp-info-line strong { color: #16406b; }
.erp-warning-block {
    background: #fff8e1;
    border: 1px solid #f3d98a;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: #6a4d0a;
}
.erp-warning-block .warn-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.erp-warning-block .warn-list {
    color: #7b5a12;
    line-height: 1.35;
    word-break: break-word;
}
.erp-success-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}
.erp-success-actions button {
    background: var(--primary-green, #18452B);
    color: #fff;
    border: none;
    padding: 9px 26px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(24,69,43,0.25);
    transition: filter 120ms ease;
}
.erp-success-actions button:hover { filter: brightness(1.1); }
.erp-success-actions button:focus { outline: 2px solid var(--accent-pink, #F29CBE); outline-offset: 2px; }

/* ================================================================
   Dialog genérico do ERP — substitui alert() / confirm() / prompt()
   nativos do browser. Herda o mesmo esqueleto do modal de sucesso
   e ganha variantes por severidade (info/success/warning/danger).
   ================================================================ */
.erp-dialog .conf-modal-content { width: 440px; max-width: 92vw; }
.erp-dialog .conf-modal-header {
    padding: 14px 18px;
    border-bottom: none;
    color: #fff;
}
.erp-dialog .conf-modal-header h3 {
    display: flex; align-items: center; gap: 10px;
    color: #fff; font-size: 1rem; font-weight: 700;
}
.erp-dialog .conf-modal-header .dialog-ico {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    font-size: 0.95rem;
    line-height: 1;
}
.erp-dialog .conf-modal-close { color: #fff; }
.erp-dialog .conf-modal-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.erp-dialog .conf-modal-body {
    padding: 18px 22px 20px;
    display: flex; flex-direction: column; gap: 14px;
}
.erp-dialog .dialog-msg {
    margin: 0;
    font-size: 0.92rem;
    color: #333;
    line-height: 1.45;
    white-space: pre-wrap;   /* preserva \n vindos das mensagens antigas */
}
.erp-dialog .dialog-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #cfd6dd;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
}
.erp-dialog .dialog-input:focus {
    outline: none;
    border-color: var(--primary-green, #18452B);
    box-shadow: 0 0 0 3px rgba(24,69,43,0.12);
}
.erp-dialog .dialog-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 2px;
}
.erp-dialog .dialog-btn {
    padding: 9px 22px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 120ms ease, background 120ms ease;
    font-family: inherit;
}
.erp-dialog .dialog-btn:hover { filter: brightness(1.08); }
.erp-dialog .dialog-btn:focus { outline: 2px solid var(--accent-pink, #F29CBE); outline-offset: 2px; }
.erp-dialog .dialog-btn-primary {
    background: var(--primary-green, #18452B);
    color: #fff;
    box-shadow: 0 2px 6px rgba(24,69,43,0.25);
}
.erp-dialog .dialog-btn-cancel {
    background: #f0f2f4;
    color: #4a5560;
    border: 1px solid #d9dde2;
}
.erp-dialog .dialog-btn-cancel:hover { background: #e6e9ec; filter: none; }
.erp-dialog .dialog-btn-danger {
    background: #c93838;
    color: #fff;
    box-shadow: 0 2px 6px rgba(201,56,56,0.28);
}

/* ---- Drop zone para upload de xlsx ---- */
.eans-drop-zone {
    border: 2px dashed var(--border-color, #d1d5db);
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bg-hover, #f9fafb);
}
.eans-drop-zone:hover,
.eans-drop-zone.dragover {
    border-color: var(--primary-green, #18452B);
    background: rgba(24,69,43,0.05);
}
.eans-drop-icon {
    font-size: 36px;
    margin-bottom: 8px;
}
.eans-drop-text {
    font-size: 0.9rem;
    color: var(--text-muted, #6b7280);
}
.eans-file-name {
    margin-top: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary-green, #18452B);
    background: rgba(34,197,94,0.1);
    display: inline-block;
    padding: 6px 14px;
    border-radius: 8px;
}

/* ---- Quarentena EAN: vinculação manual ---- */
.ean-q-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e5eaf0;
    border-radius: 10px;
    margin-bottom: 6px;
    background: #fafbfc;
}
.ean-q-info {
    flex: 0 0 auto;
    min-width: 200px;
    max-width: 300px;
}
.ean-q-desc {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ean-q-code {
    font-size: 0.75rem;
    color: #6a4d0a;
    background: #fff8e1;
    padding: 2px 6px;
    border-radius: 4px;
}
.ean-q-action {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ean-q-search-wrap {
    position: relative;
    flex: 1;
}
.ean-q-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d6dfe6;
    border-radius: 8px;
    font-size: 0.82rem;
    background: #fff;
}
.ean-q-search:focus {
    outline: 2px solid var(--primary-green, #18452B);
    outline-offset: 1px;
}
.ean-q-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d6dfe6;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 200px;
    overflow-y: auto;
    z-index: 20;
}
.ean-q-result-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    font-size: 0.8rem;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    color: #333;
    border-bottom: 1px solid #f0f2f5;
}
.ean-q-result-item:hover {
    background: #f0f7f3;
}
.ean-q-save {
    white-space: nowrap;
}

/* ---- Variantes de header por severidade ---- */
.erp-dialog--info    .conf-modal-header { background: linear-gradient(135deg, #2b6cb0 0%, #3b83c6 100%); }
.erp-dialog--success .conf-modal-header { background: linear-gradient(135deg, var(--primary-green, #18452B) 0%, #22593a 100%); }
.erp-dialog--success .dialog-ico { color: #B0F0B0; }
.erp-dialog--warning .conf-modal-header { background: linear-gradient(135deg, #b6820f 0%, #d59a20 100%); }
.erp-dialog--danger  .conf-modal-header { background: linear-gradient(135deg, #a52a2a 0%, #c93838 100%); }

.conf-detail-table-wrap { overflow: auto; max-height: 72vh; }
.conf-detail-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    font-size: 0.85rem;
}
.conf-detail-table th,
.conf-detail-table td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: center;
    white-space: nowrap;
}
.conf-detail-table thead th {
    position: sticky;
    top: 0;
    background: var(--primary-green, #1e4533);
    color: #fff;
    z-index: 1;
    font-weight: 700;
}
.conf-detail-desc { text-align: left !important; font-weight: 600; }
.conf-detail-table thead th:first-child { text-align: left; }
.conf-detail-total { font-weight: 700; background: #f7f7f7; }
.conf-detail-total-row td { background: #eaeaea; font-weight: 700; }

/* Modal Fechar Compra */
.close-form { display: flex; flex-direction: column; gap: 10px; }
.close-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: #444; }
.close-form input {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}
.close-form-hint { font-size: 0.78rem; color: #777; margin: 0; }
.close-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

/* Conferência: célula de data inline-editável */
.conf-date-cell { min-width: 120px; }
.conf-date-cell input[type="date"] {
    padding: 3px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.8rem;
    background: #fff;
    color: #222;
}
.conf-date-cell input[type="date"]:disabled {
    background: transparent;
    border-color: transparent;
    color: #444;
    cursor: default;
}
.conf-date-cell.saving { opacity: 0.6; }

/* ===== Fila de uploads (cards por arquivo) ===== */
.upload-queue {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}
.upload-queue:empty { display: none; }

.upload-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #d9d9d9;
    border-left: 4px solid #999;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.upload-card-uploading { border-left-color: #3b82f6; background: #f5f9ff; }
.upload-card-ok        { border-left-color: #1e4533; background: #f0fdf4; }
.upload-card-warn      { border-left-color: #b45309; background: #fff7ed; }
.upload-card-err       { border-left-color: #d9534f; background: #fef2f2; }
.upload-card-cancelled { border-left-color: #6b7280; background: #f3f4f6; }

.upload-card-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #333;
}
.upload-card-ok  .upload-card-icon { color: #1e4533; }
.upload-card-warn .upload-card-icon { color: #b45309; }
.upload-card-err .upload-card-icon { color: #d9534f; }

.upload-card-body { flex: 1; min-width: 0; }
.upload-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-card-status {
    font-size: 0.8rem;
    color: #555;
    margin-top: 2px;
}

.upload-card-progress {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}
.upload-card-progress-bar {
    height: 100%;
    background: #3b82f6;
    transition: width 0.25s ease;
}
.upload-card-ok  .upload-card-progress-bar { background: #1e4533; }
.upload-card-warn .upload-card-progress-bar { background: #b45309; }
.upload-card-err .upload-card-progress-bar,
.upload-card-cancelled .upload-card-progress-bar { background: #9ca3af; }

.upload-card-actions {
    display: flex;
    gap: 4px;
}
.upload-card-btn {
    background: transparent;
    border: 1px solid #d9d9d9;
    color: #555;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px 10px;
    border-radius: 4px;
    line-height: 1;
    min-width: 32px;
}
.upload-card-btn:hover { background: #f0f0f0; color: #222; border-color: #999; }
.upload-card-btn-danger { color: #d9534f; border-color: #f2b8b6; }
.upload-card-btn-danger:hover { background: #fef2f2; color: #a02620; border-color: #d9534f; }
.upload-card-btn-retry { color: #3b82f6; border-color: #93c5fd; }
.upload-card-btn-retry:hover { background: #eff6ff; color: #1d4ed8; border-color: #3b82f6; }

/* Spinner */
.upload-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #dbeafe;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: upload-spin 0.8s linear infinite;
}
@keyframes upload-spin {
    to { transform: rotate(360deg); }
}

/* ===== Quarentena de Importação ===== */
.quarantine-panel {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid #f0c674;
    background: #fffaf0;
    border-radius: 8px;
}
.quarantine-header h3 {
    margin: 0 0 4px 0;
    color: #7a4a00;
    font-size: 1.05rem;
}
.quarantine-hint { margin: 0 0 12px 0; font-size: 0.85rem; color: #7a4a00; }

.quarantine-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}
.quarantine-finish {
    padding: 8px 20px !important;
    margin-top: 0 !important;
    font-size: 0.9rem !important;
}
.quarantine-section { margin-top: 1rem; }
.quarantine-section h4 {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.quarantine-list { display: flex; flex-direction: column; gap: 8px; }
.quarantine-row {
    display: grid;
    grid-template-columns: 200px 1fr 130px auto;
    gap: 12px;
    align-items: start;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e2d3ae;
    border-radius: 6px;
    position: relative;
}
.quarantine-row.quarantine-done {
    background: #f0fdf4;
    border-color: #b7d7bc;
}
.quarantine-info { min-width: 0; }
.quarantine-key {
    font-weight: 700;
    font-size: 0.95rem;
    color: #222;
    word-break: break-all;
}
.quarantine-meta { font-size: 0.78rem; color: #666; margin-top: 4px; }
.quarantine-meta small { color: #999; }

.quarantine-picker { position: relative; }
.quarantine-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}
.quarantine-results {
    position: absolute;
    left: 0; right: 0; top: calc(100% + 2px);
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.quarantine-opt {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f0;
}
.quarantine-opt:hover,
.quarantine-opt.is-hover { background: #dcf3e0; color: #1b3a1b; font-weight: 600; }
.quarantine-opt:last-child { border-bottom: none; }
.quarantine-empty { padding: 10px; color: #888; text-align: center; font-size: 0.85rem; }

.quarantine-confirm {
    width: auto;
    padding: 7px 14px;
    margin-top: 0;
    font-size: 0.85rem;
}
.quarantine-status {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    color: #666;
    padding-top: 4px;
}
.quarantine-status.quarantine-ok { color: #256029; font-weight: 600; }
.quarantine-status.quarantine-err { color: #b02a37; }
.quarantine-unlink {
    width: auto;
    padding: 5px 12px;
    margin-top: 0;
    font-size: 0.8rem;
    background: #fff;
    color: #b02a37;
    border: 1px solid #b02a37;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.quarantine-unlink:hover { background: #b02a37; color: #fff; }
.quarantine-unlink:disabled { opacity: .5; cursor: not-allowed; }

.datagrid-table tbody tr:hover {
    background-color: #f1f8f4;
}

/* Oculta colunas 1 (NAO MEXER) e 2 (Código PREZUNIC) */
.datagrid-table th:nth-child(1), .datagrid-table td:nth-child(1),
.datagrid-table th:nth-child(2), .datagrid-table td:nth-child(2) {
    display: none;
}

/* Freeze Panes: Fixa apenas a coluna 3 (ATUAL) */
.datagrid-table th:nth-child(3), .datagrid-table td:nth-child(3) { 
    position: sticky; 
    left: 0; 
    z-index: 11; 
    background-color: #fff; 
    border-right: 2px solid #ccc;
}
.datagrid-table th:nth-child(3) { 
    background-color: #f1f3f4; 
    z-index: 12; 
}

.datagrid-footer {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
}
.datagrid-footer button {
    padding: 5px 12px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}
.datagrid-footer button:hover {
    background: #eee;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}
.toast {
    padding: 12px 20px;
    border-radius: 4px;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success { background-color: var(--primary-green); }
.toast.error { background-color: #d9534f; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Filtros por coluna (estilo Excel) --- */
.datagrid-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding-right: 22px;
}
/* Interseção linha topo × coluna DESCRIÇÃO fixa: precisa z-index maior */
.datagrid-table thead th:nth-child(3) {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 13;
    background-color: #f1f3f4;
}
.filter-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    padding: 4px;
    border-radius: 3px;
    opacity: 0.6;
}
.filter-btn:hover { opacity: 1; background: rgba(255,255,255,0.15); }
.filter-btn.active {
    opacity: 1;
    color: var(--accent-pink);
    background: rgba(255,255,255,0.2);
}

.filter-popup {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    width: 260px;
    padding: 8px;
    font-size: 0.85rem;
    color: var(--text-dark);
}
.filter-search {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 6px;
}
.filter-actions { padding: 4px 2px; border-bottom: 1px solid #eee; margin-bottom: 4px; }
.filter-actions label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.filter-list { max-height: 220px; overflow-y: auto; margin-bottom: 8px; }
.filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    cursor: pointer;
}
.filter-item:hover { background: #f4f6f8; }
.filter-item .cnt { margin-left: auto; color: #888; font-size: 0.75rem; }
.filter-footer {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    border-top: 1px solid #eee;
    padding-top: 6px;
}
.filter-footer button {
    padding: 5px 10px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}
.filter-footer .filter-ok {
    background: var(--primary-green);
    color: #fff;
    border-color: var(--primary-green);
}
.filter-footer .filter-clear { color: #d9534f; border-color: #f2b8b6; }

/* --- Toolbar do grid + toggle "só com pedido" --- */
.grid-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
}
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--primary-green);
    background: #fff;
    color: var(--primary-green);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}
.toolbar-btn:hover { background: #f0fdf4; }
.toolbar-btn.active {
    background: var(--primary-green);
    color: #fff;
}
.toolbar-btn .tb-icon { font-size: 1rem; line-height: 1; }

/* =========================================================================
   Toolbar moderna do Romaneio — cores semânticas por função
   ========================================================================= */
.grid-toolbar-modern {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.grid-toolbar-modern .toolbar-btn {
    padding: 9px 16px;
    border-width: 1.5px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    gap: 8px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.12s ease;
}
.grid-toolbar-modern .toolbar-btn:active { transform: translateY(1px); }
.grid-toolbar-modern .toolbar-btn .tb-icon {
    font-size: 1.05rem;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.08));
}

/* AZUL — informação/visão (ocultar lojas sem pedido) */
.grid-toolbar-modern .toolbar-btn.tb-info {
    border-color: #2f6bd4;
    background: #eaf2ff;
    color: #1e46a2;
}
.grid-toolbar-modern .toolbar-btn.tb-info:hover {
    background: #dbe8ff;
    box-shadow: 0 3px 8px rgba(47,107,212,0.18);
}
.grid-toolbar-modern .toolbar-btn.tb-info.active {
    background: #2f6bd4;
    color: #fff;
    border-color: #1e46a2;
    box-shadow: 0 4px 10px rgba(47,107,212,0.28);
}

/* ROXO/LILÁS — Modo SOBRA (combina com a paleta da coluna RESTO ANTERIOR) */
.grid-toolbar-modern .toolbar-btn.tb-purple {
    border-color: #7a3fbb;
    background: #f4ebff;
    color: #5b2896;
}
.grid-toolbar-modern .toolbar-btn.tb-purple:hover {
    background: #ebdbff;
    box-shadow: 0 3px 8px rgba(122,63,187,0.20);
}
.grid-toolbar-modern .toolbar-btn.tb-purple.active {
    background: #7a3fbb;
    color: #fff;
    border-color: #5b2896;
    box-shadow: 0 4px 10px rgba(122,63,187,0.32);
}

/* LARANJA — AJUSTE (atenção: precisa da ação do usuário) */
.grid-toolbar-modern .toolbar-btn.tb-warning {
    border-color: #e07a1c;
    background: #fff2e0;
    color: #9c4c07;
}
.grid-toolbar-modern .toolbar-btn.tb-warning:hover {
    background: #ffe5c8;
    box-shadow: 0 3px 8px rgba(224,122,28,0.22);
}
.grid-toolbar-modern .toolbar-btn.tb-warning.active {
    background: #e07a1c;
    color: #fff;
    border-color: #9c4c07;
    box-shadow: 0 4px 10px rgba(224,122,28,0.32);
}

/* CINZA NEUTRO — Limpar filtros (ação secundária, discreta) */
.grid-toolbar-modern .toolbar-btn.tb-neutral {
    border-color: #b8c0c4;
    background: #f2f4f5;
    color: #4a5157;
}
.grid-toolbar-modern .toolbar-btn.tb-neutral:hover {
    background: #e6eaec;
    color: #2b3033;
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

/* VERMELHO — Fechar compra (ação destrutiva/final, sempre em destaque) */
.grid-toolbar-modern .toolbar-btn.tb-danger {
    border-color: #b91c1c;
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 3px 8px rgba(220,38,38,0.22);
}
.grid-toolbar-modern .toolbar-btn.tb-danger:hover {
    background: #dc2626;
    border-color: #7f1d1d;
    box-shadow: 0 5px 12px rgba(220,38,38,0.35);
}
.col-hidden { display: none !important; }

/* ================================================================
   Navegação por teclado nas planilhas do ERP.
   Aplicada a QUALQUER célula que ganha a classe .cell-focused
   (romaneio geral, hortifruti e todas as faturas).
   ================================================================ */
.cell-focused {
    outline: 2px solid #18452B;
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px rgba(24,69,43,0.20);
    position: relative;
    z-index: 3;
}
.cell-focused.editable {
    outline-color: #22593a;
    box-shadow: inset 0 0 0 1px rgba(34,89,58,0.35), 0 0 0 2px rgba(34,89,58,0.14);
}

/* Realce da linha inteira quando qualquer célula dela está focada — permite
   ao operador ver claramente QUAL PRODUTO ele está editando, mesmo com a
   planilha rolada horizontalmente. */
.datagrid-table tbody tr.row-focused td,
.fatura-table tbody tr.row-focused td {
    background-color: #fef9e7 !important;   /* amarelo bem clarinho */
}
/* Reforço na coluna DESCRIÇÃO (a que fica congelada visualmente do lado
   esquerdo — sempre visível no scroll horizontal): borda pink Benassi
   pra "puxar o olho" ate' o produto correto. */
.datagrid-table tbody tr.row-focused td.col-descricao,
.datagrid-table tbody tr.row-focused td:nth-child(3),
.fatura-table tbody tr.row-focused td.col-descricao,
.fatura-table tbody tr.row-focused td:nth-child(2) {
    background-color: #fff4d6 !important;
    box-shadow: inset 4px 0 0 var(--accent-pink, #F29CBE);
    font-weight: 700;
    color: #18452B;
}
/* Coluna PREÇO (12ª) tem fundo azul-marinho com texto branco. Quando a linha
   é destacada (row-focused) o fundo vira amarelo claro, então precisamos
   forçar o texto para preto para continuar legível. */
#sub-romaneio-geral .datagrid-table tbody tr.row-focused td:nth-child(12),
#hortifruti-table tbody tr.row-focused td:nth-child(12) {
    color: #000 !important;
}
/* Mesma proteção quando a célula PREÇO é a que está focada individualmente
   (cell-focused sem row-focused, em caso de estilo futuro). */
#sub-romaneio-geral .datagrid-table tbody td.cell-focused:nth-child(12),
#hortifruti-table tbody td.cell-focused:nth-child(12) {
    color: #000 !important;
}
/* ================================================================
   Modo TELA CHEIA dos romaneios (Geral e Hortifruti).
   Aplicado quando a sub-aba ganha a classe .grid-fullscreen: o painel
   inteiro (toolbar + tabela) cobre a viewport, e a tabela recebe todo
   o espaço vertical disponível (sem os 380px reservados pro header).
   ================================================================ */
.sub-tab-content.grid-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: #fff;
    padding: 12px 16px 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: grid-fs-in 140ms ease-out;
}
@keyframes grid-fs-in {
    from { opacity: 0.4; transform: scale(0.995); }
    to   { opacity: 1;   transform: scale(1); }
}
.sub-tab-content.grid-fullscreen .grid-toolbar { flex: 0 0 auto; margin-bottom: 8px; }
.sub-tab-content.grid-fullscreen .datagrid-container {
    flex: 1 1 auto;
    max-height: none;
    margin-top: 0;
}
/* Botão fica com destaque quando ativo, e troca o ícone/label */
.fullscreen-btn[aria-pressed="true"] {
    background: #18452B;
    color: #fff;
    border-color: #18452B;
}
body.has-fullscreen-grid { overflow: hidden; }
.sub-tab-content.grid-fullscreen .datagrid-container {
    overflow: auto;
}
@media (max-width: 640px) {
    .fullscreen-btn .fs-label { display: none; }
}

/* ================================================================
   PRESENÇA (tracking colaborativo). Mostra quais outros usuários estão
   na mesma página e qual célula estão editando agora, pra evitar dois
   editando o mesmo campo ao mesmo tempo.
   ================================================================ */
.presence-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 12px;
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, #FFF3B0 0%, #FFE07A 100%);
    border: 1.5px solid #E7BC00;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #5A4700;
    max-width: max-content;
    min-height: 32px;
    box-shadow: 0 2px 8px rgba(231, 188, 0, 0.25);
    animation: presence-pulse 2.4s ease-in-out infinite;
}
.presence-bar:empty { display: none; }
@keyframes presence-pulse {
    0%,100% { box-shadow: 0 2px 8px rgba(231, 188, 0, 0.25); }
    50%     { box-shadow: 0 2px 14px rgba(231, 188, 0, 0.55); }
}
.presence-bar .presence-eye {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.6);
    border-radius: 50%;
    font-size: 13px;
    flex-shrink: 0;
}
.presence-bar .presence-label {
    color: #6b5200;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 0.72rem;
    margin-right: 2px;
}
.presence-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 6px;
    border-radius: 999px;
    background: #ffffff;
    border: 1.5px solid rgba(231, 188, 0, 0.55);
    color: #333;
    font-weight: 700;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.presence-chip .presence-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.9);
}
.presence-chip .presence-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.86rem;
}
.presence-chip .presence-what {
    color: #6c7480;
    font-weight: 500;
    font-size: 0.75rem;
    padding-left: 4px;
    border-left: 1px solid rgba(0,0,0,0.08);
    margin-left: 2px;
}


/* Célula sendo editada por outro usuário — outline colorido do lado do
   usuário responsável. O `--presence-color` é definido inline no JS. */
.presence-editing {
    position: relative;
    outline: 2px solid var(--presence-color, #666);
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px var(--presence-color, #666);
}
.presence-editing::after {
    content: attr(data-presence-name);
    position: absolute;
    top: -18px;
    left: -2px;
    background: var(--presence-color, #666);
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px 4px 4px 0;
    white-space: nowrap;
    z-index: 5;
    font-weight: 600;
    pointer-events: none;
    line-height: 1.3;
}

/* ================================================================
   INPUTS DE FILTRO/BUSCA — padrão global do ERP. Substitui o visual
   nativo do HTML por algo mais alinhado à identidade (verde + rosa,
   bordas suaves, foco destacado). Aplicado via .erp-input / .erp-field.
   Regra .erp-input se aplica a text, date, number e select genéricos.
   ================================================================ */
.erp-filter-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: 6px 0 14px;
}
.erp-field {
    display: inline-flex; align-items: center;
    background: #fff;
    border: 1.5px solid #d6dfe6;
    border-radius: 10px;
    padding: 0 10px 0 12px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    min-height: 38px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.erp-field:focus-within {
    border-color: var(--primary-green, #18452B);
    box-shadow: 0 0 0 3px rgba(24,69,43,0.12);
}
.erp-field .erp-field-ico {
    color: #8a97a4; font-size: 0.9rem; margin-right: 6px; line-height: 1;
}
.erp-field .erp-field-label {
    color: #6c7480;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-right: 8px;
}
.erp-field-search { min-width: 240px; flex: 1 1 240px; max-width: 380px; }
.erp-input {
    border: none;
    outline: none;
    background: transparent;
    padding: 6px 4px;
    font-size: 0.9rem;
    color: #222;
    font-family: inherit;
    min-width: 0;
    flex: 1 1 auto;
}
.erp-input::placeholder { color: #a0abb5; }
.erp-input-date {
    /* alarga um pouco pra caber dd/mm/aaaa sem cortar */
    min-width: 128px;
    color: #333;
    font-variant-numeric: tabular-nums;
}
/* Ícone de calendário do date picker fica mais suave */
.erp-input-date::-webkit-calendar-picker-indicator {
    filter: opacity(0.55);
    cursor: pointer;
}
.erp-input-date:hover::-webkit-calendar-picker-indicator { filter: opacity(0.85); }
.erp-input-select {
    background: transparent;
    border: none;
    outline: none;
    font: inherit;
    color: #222;
    padding: 6px 4px;
    cursor: pointer;
}

/* Tabela sortable (drag-and-drop) — usado na config de Clientes */
.cfg-table-sortable tbody tr {
    cursor: grab;
    transition: background 120ms ease, box-shadow 120ms ease;
}
.cfg-table-sortable tbody tr:active { cursor: grabbing; }
.cfg-table-sortable .drag-handle {
    color: #9aa4ad;
    font-size: 1rem;
    text-align: center;
    user-select: none;
    letter-spacing: -2px;
    padding-left: 6px;
    padding-right: 6px;
}
.cfg-table-sortable tbody tr:hover .drag-handle { color: var(--primary-green, #18452B); }
.cfg-table-sortable tbody tr.drag-source { opacity: 0.5; background: #eef5ff; }
.cfg-table-sortable tbody tr.drag-over {
    box-shadow: inset 0 3px 0 var(--primary-green, #18452B);
    background: #f4f8f5;
}

/* Botões inline compactos para tabelas de gestão (Usuários, etc.) */
.cfg-btn-mini {
    display: inline-flex; align-items: center;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #d6dfe6;
    background: #fff;
    color: #4a5560;
    cursor: pointer;
    margin-right: 4px;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.cfg-btn-mini:hover { background: #f4f8f5; border-color: var(--primary-green, #18452B); color: var(--primary-green, #18452B); }
.cfg-btn-mini:disabled { opacity: 0.45; cursor: not-allowed; }
.cfg-btn-mini-danger:hover:not(:disabled) { background: #fdecec; border-color: #c93838; color: #c93838; }

/* Painel "em construção" pra abas placeholder (ex.: COLETA) */
.placeholder-panel {
    background: #fff;
    border: 1.5px dashed #d6dfe6;
    border-radius: 12px;
    padding: 40px 28px;
    margin-top: 18px;
    text-align: center;
    color: #4a5560;
    max-width: 640px;
    margin-left: auto; margin-right: auto;
}
.placeholder-panel .placeholder-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    line-height: 1;
}
.placeholder-panel h3 {
    color: var(--primary-green, #18452B);
    font-size: 1.15rem;
    margin: 0 0 8px 0;
}
.placeholder-panel p { font-size: 0.9rem; line-height: 1.5; margin: 0; }
.placeholder-panel code {
    background: #f0f3f5;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #4a5560;
}

/* Aviso do estado de undo — pequenino, canto inferior esquerdo */
.undo-toast {
    position: fixed;
    left: 18px;
    bottom: 18px;
    padding: 8px 14px;
    background: #18452B;
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(24,69,43,0.28);
    z-index: 3000;
    animation: undoToastIn 0.15s ease-out;
    pointer-events: none;
}
@keyframes undoToastIn { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
/* col-user-hidden: ocultada manualmente pelo usuário via clique direito no header.
   Independente de .col-hidden (que é aplicada por toggles como "Só com pedido"). */
.col-user-hidden { display: none !important; }

/* Menu de contexto de colunas */
.colmenu {
    position: fixed;
    z-index: 10000;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    min-width: 220px;
    padding: 4px 0;
    font-size: 0.9rem;
    font-family: var(--font-text);
}
.colmenu button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 8px 14px;
    cursor: pointer;
    color: #222;
}
.colmenu button:hover { background: #f1f8f4; color: var(--primary-green); }
.colmenu .sep { height: 1px; background: #eee; margin: 4px 0; }
.colmenu .muted { color: #888; font-size: 0.8rem; padding: 6px 14px; }

/* --- Form de pedido manual --- */
.manual-form-v2 {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 720px;
    margin-top: 1rem;
}
.manual-form-v2 .mf-row label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: #444;
}
.manual-form-v2 .mf-row input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}
.mf-items {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    background: #fafafa;
}
.mf-items-header {
    display: grid;
    /* Qtd primeiro (fixo estreito), depois Produto (elástico), depois botão remover */
    grid-template-columns: 120px 1fr 40px;
    gap: 8px;
    font-size: 0.75rem;
    color: #6c7480;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    padding: 4px 4px 8px 4px;
    border-bottom: 1px solid #e5eaf0;
    margin-bottom: 8px;
}
.mf-item-row {
    display: grid;
    grid-template-columns: 120px 1fr 40px;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 6px;
}
.mf-product-cell { position: relative; }
.mf-qty-cell { min-width: 0; }
/* Inputs dentro do row usam o padrão .erp-input, mas o wrapper .erp-field
   precisa ocupar 100% do slot do grid pra sem "vazar" nem quebrar. */
.mf-item-row .erp-field { width: 100%; min-width: 0; }
.mf-item-row .erp-input.mf-qty { text-align: right; font-variant-numeric: tabular-nums; }
.mf-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 500;
    display: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.mf-suggest-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}
.mf-suggest-item:hover,
.mf-suggest-item.is-hover { background: #dcf3e0; color: #1b3a1b; font-weight: 600; }
.mf-remove {
    background: transparent;
    border: 1px solid #f2b8b6;
    color: #d9534f;
    border-radius: 4px;
    cursor: pointer;
    height: 32px;
}
.mf-remove:hover { background: #fff5f5; }
.mf-add-btn {
    background: transparent;
    border: 1px dashed #999;
    color: #444;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 4px;
}
.mf-add-btn:hover { border-color: var(--primary-green); color: var(--primary-green); }
.mf-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
#mf-status { font-size: 0.85rem; }

/* --- Botões toolbar variantes --- */
.toolbar-btn-danger {
    border-color: #d9534f;
    color: #d9534f;
}
.toolbar-btn-danger:hover { background: #fff5f5; }
.toolbar-btn-danger.active {
    background: #d9534f;
    color: #fff;
}

/* --- Histórico de Compras --- */
.hist-filters {
    /* Layout já vem via .erp-filter-bar (aplicada em conjunto no wrapper).
       Regras antigas (input[type=text|date], label) removidas pra não vencer
       .erp-input por maior especificidade. */
}
.hist-list-wrapper {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: auto;
    /* Historico + Conferencia tem filtros pequenos acima da tabela, offset menor */
    max-height: calc(100vh - 340px);
    max-height: calc(100dvh - 340px);
    max-width: 100%;
    scrollbar-gutter: stable;
}

/* Wrapper das tabelas da Fatura — mesmo comportamento das outras:
   scroll vertical + horizontal DENTRO do contêiner, sem empurrar a página. */
.datagrid-wrapper {
    overflow: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    max-height: calc(100vh - 400px);
    max-height: calc(100dvh - 400px);
    max-width: 100%;
    scrollbar-gutter: stable both-edges;
}

/* HORTI RJ / HORTI SP têm 3 elementos EXTRAS acima do wrapper que
   não existem no grid Prezunic:
     - .horti-inner-nav (visualizando: HORTI RJ | HORTI SP)  ~62px
     - ::before badge "FATURA HORTI RJ"                       ~34px
     - .fatura-toolbar (mesma do prezunic)                    ~50px
   Total ~90px a mais. Aumenta o offset para o wrapper caber na tela. */
.horti-inner-panel .datagrid-wrapper {
    max-height: calc(100vh - 490px);
    max-height: calc(100dvh - 490px);
}
.hist-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.hist-list-table th {
    background: var(--primary-green);
    color: #fff;
    text-align: left;
    padding: 10px 12px;
    font-weight: 500;
    font-size: 0.85rem;
}
.hist-list-table td {
    padding: 10px 12px;
    border-top: 1px solid #eee;
}
.hist-list-table tbody tr:hover { background: #f9fafb; }
.hist-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.hist-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1.5px solid #ccc;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
                box-shadow 0.15s ease, transform 0.15s ease;
}
.hist-btn:active { transform: translateY(1px); }
.hist-btn .hb-icon { flex-shrink: 0; }

/* Botão de exportar → verde forte da identidade, ícone claro */
.hist-btn.hist-export {
    border-color: #18452B;
    color: #ffffff;
    background: #18452B;
    box-shadow: 0 2px 6px rgba(24,69,43,0.18);
}
.hist-btn.hist-export:hover {
    background: #22593a;
    border-color: #22593a;
    box-shadow: 0 4px 10px rgba(24,69,43,0.28);
}

/* Botão de excluir → vermelho vívido, saturado, ícone bem definido */
.hist-btn.hist-delete {
    border-color: #dc2626;
    color: #ffffff;
    background: #ef4444;
    padding: 7px 10px;
    box-shadow: 0 2px 6px rgba(220,38,38,0.22);
}
.hist-btn.hist-delete:hover {
    background: #dc2626;
    border-color: #b91c1c;
    box-shadow: 0 4px 10px rgba(220,38,38,0.35);
}
.hist-btn.hist-delete .hb-icon { stroke-width: 2.4; }

/* Botão de "Detalhar" (Conferência) usando o SVG do olho */
.hist-btn.hist-btn-detail {
    padding: 8px 12px;
    border-color: #4a5157;
    color: #2b3033;
    background: #ffffff;
}
.hist-btn.hist-btn-detail:hover {
    background: #eef2f4;
    border-color: #2b3033;
    box-shadow: 0 3px 8px rgba(0,0,0,0.10);
}
.hist-btn.hist-btn-detail .hb-eye {
    display: block;
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
}

/* ================================================================
   Ampliação da listagem do Histórico + Conferência
   (tabelas .hist-list-table são compartilhadas entre as duas abas)
   ================================================================ */
.hist-list-table {
    font-size: 0.98rem;
}
.hist-list-table th {
    padding: 14px 16px;
    font-size: 0.9rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.hist-list-table td {
    padding: 14px 16px;
    vertical-align: middle;
}
.hist-list-table tbody tr {
    transition: background 0.15s;
}
/* Ícones dos botões de ação ligeiramente maiores em ambas as tabelas */
.hist-actions .hist-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    min-height: 38px;
    min-width: 40px;
    justify-content: center;
}
.hist-actions .hist-btn.hist-btn-primary,
.hist-actions .hist-btn.conf-icon-rj,
.hist-actions .hist-btn.conf-icon-sp {
    font-size: 0.95rem;
}

/* Conferência: variantes de botão dentro da tabela do histórico */
.hist-btn.hist-btn-primary {
    background: var(--primary-green, #1e4533);
    color: #fff;
    border-color: var(--primary-green, #1e4533);
}
.hist-btn.hist-btn-primary:hover { background: #163826; }
.hist-btn.conf-icon-rj {
    color: #14497a;
    border-color: #b8cde0;
    background: #eef4fa;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.hist-btn.conf-icon-rj:hover { background: #d9e6f3; }
.hist-btn.conf-icon-sp {
    color: #7a3e14;
    border-color: #e0c5b8;
    background: #faf0ee;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.hist-btn.conf-icon-sp:hover { background: #f3d9d3; }

/* Modo compacto: remove min-width gigante quando ocultamos a maior parte das colunas */
.datagrid-table.table-shrink { min-width: 0; width: auto; }

/* --- Produtos destacados: cor apenas na coluna DESCRIÇÃO --- */
.datagrid-table tbody tr.product-highlight-green td:nth-child(3) {
    background-color: #A9D5A0;
}
.datagrid-table tbody tr.product-highlight-green:hover td:nth-child(3) {
    background-color: #98C58F;
}
.datagrid-table tbody tr.product-highlight-pink td:nth-child(3) {
    background-color: #F9C5D8;
}
.datagrid-table tbody tr.product-highlight-pink:hover td:nth-child(3) {
    background-color: #F5AEC6;
}

/* --- Linha de totais no final do grid --- */
.datagrid-table tbody tr.totals-row td {
    background-color: #FFF3B0 !important;
    font-weight: 700;
    color: #3d3400;
    border-top: 2px solid #b58900;
}
.datagrid-table tbody tr.totals-row td:nth-child(3) {
    background-color: #FFF3B0 !important;
}
.datagrid-table tbody tr.totals-row:hover td {
    background-color: #FFE580 !important;
}

/* --- Color picker por célula --- */
.datagrid-table tbody td .cell-color-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid #999;
    border-radius: 50%;
    background: #fff;
    color: #666;
    font-size: 8px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.datagrid-table tbody tr:hover .cell-color-btn { opacity: 0.9; }
.cell-color-btn:hover { opacity: 1 !important; color: var(--primary-green); border-color: var(--primary-green); }
/* garante espaço à direita e posição relativa na coluna descrição */
.datagrid-table tbody td:nth-child(3) { position: sticky; padding-right: 26px; }

.cell-color-popup {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #999;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(5, 24px);
    gap: 6px;
}
.cell-color-swatch {
    width: 24px; height: 24px;
    border: 1px solid #aaa;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cell-color-swatch:hover { transform: scale(1.15); border-color: var(--primary-green); }

/* --- Cores por grupo de loja (headers) --- */
.datagrid-table thead th.store-group-prezunic       { background-color: #ADE0A5; color: #1a3d1a; }
.datagrid-table thead th.store-group-casa_do_arroz  { background-color: #C1E7EF; color: #143842; }
.datagrid-table thead th.store-group-prix           { background-color: #E88F4A; color: #2b1a08; }
.datagrid-table thead th.store-group-servi         { background-color: #CFCFCF; color: #222; }
.datagrid-table thead th.store-group-mercado_atlantico { background-color: #DFEEF7; color: #14344a; }
.datagrid-table thead th.store-group-almeida_e_rocha   { background-color: #E4E4E4; color: #222; }
.datagrid-table thead th.store-group-outros         { background-color: #EFEFEF; color: #333; }

/* Lojas individuais no grupo "outros" (baseado no print) */
.datagrid-table thead th.store-name-PIABETA         { background-color: #F5C29E; color: #3b1c04; }
.datagrid-table thead th.store-name-IMPERIAL        { background-color: #E093DE; color: #3b1146; }
.datagrid-table thead th.store-name-IDEAL           { background-color: #A9E0AC; color: #123a13; }
.datagrid-table thead th.store-name-BELOT           { background-color: #B5DEF8; color: #0d2a44; }

/* --- Sinalização de quantidade fora do múltiplo --- */
.datagrid-table tbody td.cell-mismatch {
    background-color: #F9C6C6;
    color: #7a1d1d;
    font-weight: 600;
}
.datagrid-table tbody tr:hover td.cell-mismatch {
    background-color: #F0A9A9;
}
.datagrid-table tbody tr.row-hidden { display: none; }

/* ============================================================
   FATURA
   ============================================================ */
.fatura-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    flex-wrap: wrap;
}
.fatura-toolbar label { display:flex; align-items:center; gap:8px; }

.fatura-table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 0;
}
.fatura-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 6px 8px;
    text-align: center;
    font-weight: 700;
    border: 1px solid #606060;
    white-space: nowrap;
}
/* Header linha 1: bege nas 3 primeiras + verde claro nas lojas + TOTAL/VALOR */
.fatura-table thead tr.header-row-1 th               { background: #F1DDBC; color:#3b2300; }
.fatura-table thead tr.header-row-1 th.col-descricao { background: #F1DDBC; }
.fatura-table thead tr.header-row-1 th.col-custo    { background: #F1DDBC; color:#3b2300; }
.fatura-table thead tr.header-row-1 th.col-branch,
.fatura-table thead tr.header-row-1 th[class*="col-branch-"] { background: #A9D5A0; color:#0f2b0f; }
.fatura-table thead tr.header-row-1 th.col-total    { background: #C6EFCE; color:#1b3a1b; }
.fatura-table thead tr.header-row-1 th.col-valor    { background: #92D050; color:#0f2b0f; }

/* Header linha 2: laranja claro no código/material + amarelo (texto vermelho) no NORMAL + bege nas lojas */
.fatura-table thead tr.header-row-2 th               { background: #FBD09E; color:#3b2300; font-weight:700; font-size:11px; }
.fatura-table thead tr.header-row-2 th.col-descricao { background: #FBD09E; }
.fatura-table thead tr.header-row-2 th.col-custo    { background: #FFFF00; color: #E00000; font-weight: 700; }
.fatura-table thead tr.header-row-2 th.col-branch,
.fatura-table thead tr.header-row-2 th[class*="col-branch-"] { background: #F1DDBC; color:#3b2300; font-family: 'Courier New', monospace; }
.fatura-table thead tr.header-row-2 th.col-total    { background: #C6EFCE; color:#1b3a1b; }
.fatura-table thead tr.header-row-2 th.col-valor    { background: #92D050; color:#0f2b0f; }

/* Corpo — bordas mais fortes */
.fatura-table tbody td {
    border: 1px solid #909090;
    padding: 3px 6px;
    text-align: center;
    background: #ffffff;
}
.fatura-table tbody td.col-descricao { text-align: left; font-weight: 600; }
.fatura-table tbody td.col-custo     { background: #FFFDE0; }
.fatura-table tbody td.col-total     { background: #E8F5E1; font-weight: 700; }
.fatura-table tbody td.col-valor     { background: #C4E4A9; font-weight: 700; }

/* Botão color-picker na célula de descrição (mesmo padrão do romaneio geral) */
.fatura-table tbody td.col-descricao { position: relative; padding-right: 24px; }
.fatura-table .fatura-cell-color-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid #bdbdbd;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    padding: 0;
    cursor: pointer;
    color: #666;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
}
.fatura-table .fatura-cell-color-btn:hover { background: #eee; }

.fatura-table tbody td.editable {
    cursor: cell;
}
.fatura-table tbody td.editable:hover {
    outline: 2px solid var(--primary-green);
    outline-offset: -2px;
}
.fatura-table input.cell-input {
    width: 100%;
    border: 0;
    padding: 2px;
    font: inherit;
    text-align: center;
    background: transparent;
}

.fatura-table tbody tr:nth-child(even) td { background: #fbfbfb; }
.fatura-table tbody tr:nth-child(even) td.col-custo  { background: #FFFCC7; }
.fatura-table tbody tr:nth-child(even) td.col-total  { background: #E0EFDA; }
.fatura-table tbody tr:nth-child(even) td.col-valor  { background: #BDDDA3; }

/* --- Layout HORTI RJ / SP (coluna qtd_minima + rótulo estático amarelo) --- */
.fatura-table thead tr.header-row-2 th.col-qmin  { background: #FFFF00; color: #E00000; font-weight: 700; }
.fatura-table thead tr.header-row-2 th.col-extra { background: #FFFF00; color: #3b2300; font-weight: 700; }
.fatura-table thead tr.header-row-1 th.col-branch-code { background: #F1DDBC; color:#3b2300; font-family: 'Courier New', monospace; }
.fatura-table tbody td.col-qmin  { background: #FFFDE0; text-align: center; font-weight: 700; }
.fatura-table tbody td.col-extra { background: #FFFDE0; }
.fatura-table tbody tr:nth-child(even) td.col-qmin  { background: #FFFCC7; }
.fatura-table tbody tr:nth-child(even) td.col-extra { background: #FFFCC7; }

/* Sub-nav interno da aba Hortifruti (HORTI RJ | HORTI SP) */
.horti-inner-panel { display: none; }
.horti-inner-panel.ativa { display: block; }
.horti-inner-nav {
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 2px solid var(--primary-green);
    padding: 4px 4px 0;
    margin-bottom: 12px;
    position: relative;
}
.horti-inner-nav::before {
    content: 'Visualizando:';
    font-size: 11px;
    font-weight: 700;
    color: #888;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding-right: 6px;
    align-self: center;
}
.horti-sub-btn {
    padding: 9px 22px;
    border: 2px solid #cfcfcf;
    border-bottom: none;
    background: #f2f2f2;
    color: #555;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.4px;
    position: relative;
    top: 2px;
    transition: background 0.15s, color 0.15s;
}
.horti-sub-btn:hover {
    background: #e6e6e6;
    color: #222;
}
.horti-sub-btn.ativa {
    background: var(--primary-green);
    color: #fff;
    border-color: var(--primary-green);
    box-shadow: 0 -2px 6px rgba(0,0,0,0.12);
    top: 0;
    padding: 11px 24px;
}
.horti-sub-btn.ativa::after {
    content: '●';
    margin-left: 8px;
    font-size: 10px;
    color: #fff;
    opacity: 0.9;
}

/* Badge de contexto que aparece acima da toolbar do painel ativo */
.horti-inner-panel.ativa::before {
    content: attr(data-title);
    display: inline-block;
    background: linear-gradient(90deg, var(--primary-green), #1f8a4a);
    color: #fff;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.fatura-table td.row-delete-cell button {
    background: none; border: 0; color: #b40707; cursor: pointer; font-size: 14px;
}

/* Config de e-mail */
.fatura-config-tabs { display:flex; gap:6px; padding:12px 0 8px; }
.cfg-scope-btn {
    padding: 6px 14px;
    border: 1px solid var(--primary-green);
    background: transparent;
    color: var(--primary-green);
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
}
.cfg-scope-btn.ativa { background: var(--primary-green); color: #fff; }

.fatura-config-form { max-width: 780px; padding: 8px 0 20px; }
.fatura-config-form .fec-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.fatura-config-form .fec-row.fec-inline { flex-direction: row; align-items: center; }
.fatura-config-form label { font-weight: 600; font-size: 13px; }
.fatura-config-form input[type=text], .fatura-config-form textarea, .fatura-config-form input[type=number] {
    padding: 8px 10px; border: 1px solid #cfcfcf; border-radius: 4px; font: inherit; width: 100%;
}
.fatura-config-form textarea { resize: vertical; font-family: 'Courier New', monospace; font-size: 12px; }
.fatura-config-form .fec-help { color:#666; font-size: 11px; }
.fatura-config-form .fec-help code { background:#eee; padding:1px 4px; border-radius:3px; }
.fec-actions { display:flex; gap:10px; align-items:center; flex-wrap:wrap; padding-top: 10px; }
.fec-smtp-warn { color:#a15c00; font-size: 12px; }

/* Modais */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-card {
    background: #fff; border-radius: 8px; max-width: 520px; width: 90%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-card.modal-lg { max-width: 720px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid #eee;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color:#666; }
.modal-body { padding: 16px 18px; }
.modal-actions { padding: 12px 18px; border-top: 1px solid #eee; display: flex; gap: 10px; justify-content: flex-end; }

.fcm-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.fcm-row label { font-weight: 600; font-size: 13px; }
.fcm-row input, .fcm-row textarea {
    padding: 8px 10px; border: 1px solid #cfcfcf; border-radius: 4px; font: inherit;
}
.fcm-preview {
    background: #f7f7f9; padding: 10px 12px; border-radius: 6px;
    font-size: 13px; line-height: 1.6;
}
.fcm-preview strong { color: var(--primary-green); }
.fcm-body-preview pre {
    background: #fff; padding: 8px 10px; border-radius: 4px; border: 1px solid #eee;
    white-space: pre-wrap; font-family: 'Courier New', monospace; font-size: 12px; margin-top: 6px;
    max-height: 200px; overflow: auto;
}
.fcm-warn { margin-top: 10px; color:#a15c00; font-size: 12px; }

/* Blindagem: garante que as 3 primeiras colunas (código/descrição/custo) SEMPRE
   apareçam, mesmo se alguma regra do romaneio (`.datagrid-table th:nth-child(...)`)
   tenta escondê-las por engano. */
.fatura-table th:nth-child(1), .fatura-table td:nth-child(1),
.fatura-table th:nth-child(2), .fatura-table td:nth-child(2),
.fatura-table th:nth-child(3), .fatura-table td:nth-child(3) {
    display: table-cell !important;
}

/* Coluna Descrição sempre ampla e legível */
.fatura-table th.col-descricao,
.fatura-table td.col-descricao {
    min-width: 280px;
    max-width: 340px;
    text-align: left;
    padding-left: 10px;
}
.fatura-table td.col-descricao { white-space: normal; }
.fatura-table th.col-codigo,
.fatura-table td.col-codigo { min-width: 90px; text-align: center; font-family: 'Courier New', monospace; }
.fatura-table th.col-custo,
.fatura-table td.col-custo   { min-width: 100px; }
.fatura-table th.col-total,
.fatura-table td.col-total   { min-width: 70px; }
.fatura-table th.col-valor,
.fatura-table td.col-valor   { min-width: 100px; }

.fatura-table thead th.col-hidden,
.fatura-table tbody td.col-hidden { display: none; }

/* Régua colapsável de colunas ocultas — só um summary aparece por padrão */
.fatura-hidden-cols { padding: 4px 0; font-size: 12px; color: #555; }
.fatura-hidden-cols details.hidden-cols-details { padding: 0; }
.fatura-hidden-cols details > summary {
    cursor: pointer;
    padding: 4px 8px;
    display: inline-block;
    border: 1px solid #d0d0d0;
    border-radius: 12px;
    background: #f4f4f4;
    user-select: none;
    list-style: revert; /* mantém a seta nativa */
}
.fatura-hidden-cols details > summary:hover { background: #ececec; }
.fatura-hidden-cols .hcd-count {
    display: inline-block;
    background: var(--primary-green);
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
    margin-right: 2px;
}
.fatura-hidden-cols .hcd-hint { color:#888; font-style: italic; }
.fatura-hidden-cols .hcd-chips { padding-top: 6px; }
.fatura-hidden-cols .chip {
    display: inline-block;
    background: #eee;
    padding: 2px 8px;
    margin: 0 4px 4px 0;
    border-radius: 10px;
    cursor: pointer;
}
.fatura-hidden-cols .chip:hover { background: #ddd; }

/* Estado ativo do botão de toggle (quando há colunas ocultas) */
.fatura-hide-toggle.toggle-active {
    background: #f0e6d0;
    border-color: #c99a00;
    color: #6a4900;
    font-weight: 600;
}

/* Context menu (clique direito no header da loja) */
.fatura-ctx-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    z-index: 1200;
    min-width: 180px;
    padding: 4px 0;
    font-size: 13px;
}
.fatura-ctx-menu button {
    display: block; width: 100%;
    background: none; border: 0;
    text-align: left; padding: 8px 14px;
    cursor: pointer;
}
.fatura-ctx-menu button:hover { background: #f5f5f5; }
.fatura-ctx-menu .ctx-sep { border-top: 1px solid #eee; margin: 4px 0; }
.fatura-ctx-menu .ctx-label { padding: 4px 14px; font-weight: 600; color:#555; font-size:11px; text-transform: uppercase; }

/* Tabelas de gestão (config → produtos/lojas) */
.fatura-mgmt-toolbar {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 10px; flex-wrap: wrap;
}
/* .search legado — mantido só como fallback. Padrão novo é .erp-field.
   Mantém `flex: 1` no wrapper pra ocupar espaço disponível. */
.fatura-mgmt-toolbar .erp-field-search { flex: 1; }
.fatura-mgmt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.fatura-mgmt-table th, .fatura-mgmt-table td {
    border: 1px solid #e5e5e5;
    padding: 6px 10px;
    text-align: left;
}
.fatura-mgmt-table thead th {
    background: #f0f0f0;
    font-weight: 700;
    position: sticky; top: 0;
}
.fatura-mgmt-table td.acoes { text-align: right; white-space: nowrap; }
.fatura-mgmt-table td.acoes button {
    background: none; border: 1px solid #cfcfcf; padding: 3px 8px; border-radius: 3px;
    cursor: pointer; margin-left: 4px; font-size: 12px;
}
.fatura-mgmt-table td.acoes button.danger { color:#b40707; border-color:#e0a0a0; }

/* Sub-nav interno da aba de Configurações da Fatura */
.fatura-config-inner-nav {
    display: flex; gap: 6px; margin: 14px 0 12px;
    border-bottom: 1px solid #e5e5e5;
}
.fatura-config-inner-nav button {
    background: transparent; border: 0;
    padding: 8px 16px; cursor: pointer; font-weight: 600;
    border-bottom: 3px solid transparent; color:#555;
}
.fatura-config-inner-nav button.ativa {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
}
.fatura-mgmt-panel { display: none; }
.fatura-mgmt-panel.ativa { display: block; }

/* Sub-abas da aba Devolução */
.dev-subnav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color, #ddd);
    margin-bottom: 16px;
    padding: 0 16px;
}
.dev-subtab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.dev-subtab:hover { color: var(--text-primary, #222); }
.dev-subtab.ativa {
    color: var(--primary-green, #1a6b3c);
    border-bottom-color: var(--primary-green, #1a6b3c);
}
.dev-panel { display: none; }
.dev-panel.ativa { display: block; }

/* Linha de totais no rodapé da Fatura */
.fatura-table tfoot tr.totals-row td {
    background: #E8F0E4;
    font-weight: 700;
    border-top: 2px solid var(--primary-green);
    position: sticky;
    bottom: 0;
    z-index: 2;
    color: #123a13;
}
.fatura-table tfoot tr.totals-row td.col-total { background: #B7DDA6; }
.fatura-table tfoot tr.totals-row td.col-valor { background: #7EBE55; color: #0a2010; font-size: 13px; }
.fatura-table tfoot tr.totals-row td.totals-label {
    text-align: right;
    color: var(--primary-green);
    letter-spacing: 0.02em;
    font-size: 12px;
}

/* ================= Loading overlay dentro da modal ================= */
.modal-card { position: relative; }
.modal-loading-overlay {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.94);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 18px; z-index: 5;
    border-radius: 8px;
    animation: modalOverlayFade .18s ease-out;
}
@keyframes modalOverlayFade { from { opacity: 0; } to { opacity: 1; } }

.spinner-ring {
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 4px solid #e0e0e0;
    border-top-color: var(--primary-green);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-loading-overlay .loading-title {
    font-size: 16px; font-weight: 700;
    color: var(--primary-green);
}
.modal-loading-overlay .loading-hint {
    font-size: 12px; color: #666; max-width: 320px; text-align: center;
    line-height: 1.4;
}
.modal-loading-overlay .loading-steps {
    display: flex; flex-direction: column; gap: 6px;
    margin-top: 6px; font-size: 13px; color: #555;
}
.modal-loading-overlay .step {
    display: flex; align-items: center; gap: 8px;
    padding-left: 22px; position: relative;
}
.modal-loading-overlay .step::before {
    content: '○'; position: absolute; left: 0; color: #aaa;
}
.modal-loading-overlay .step.done::before { content: '✓'; color: #2e7d32; }
.modal-loading-overlay .step.active::before {
    content: ''; width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid var(--primary-green); border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    left: 2px; top: 4px;
}

/* ================= Botão em estado loading (spinner inline) ================= */
.toolbar-btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
    position: relative;
    padding-right: 32px;
}
.toolbar-btn.is-loading::after {
    content: '';
    position: absolute; right: 10px; top: 50%;
    width: 14px; height: 14px; margin-top: -7px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: spin 0.7s linear infinite;
}

/* ================= Modal de resultado (sucesso/erro) ================= */
.result-backdrop {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    animation: modalOverlayFade .18s ease-out;
}
.result-card {
    background: #fff;
    border-radius: 12px;
    max-width: 520px; width: 90%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    overflow: hidden;
    animation: resultPop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes resultPop {
    0%   { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1);    opacity: 1; }
}
.result-card .result-icon {
    display: flex; align-items: center; justify-content: center;
    height: 80px;
    font-size: 42px; color: #fff;
}
.result-card.success .result-icon { background: #2e7d32; }
.result-card.warn    .result-icon { background: #ed8b00; }
.result-card.error   .result-icon { background: #c62828; }

.result-card .result-body { padding: 20px 22px 12px; }
.result-card h3 {
    margin: 0 0 10px 0; font-size: 20px;
    color: var(--text-dark); text-align: center;
}
.result-card .result-msg {
    text-align: center; color: #444; font-size: 14px; line-height: 1.5;
    margin-bottom: 14px;
}
.result-card .result-details {
    background: #f7f7f9; padding: 12px 14px; border-radius: 6px;
    font-size: 13px; line-height: 1.6; color: #333;
}
.result-card .result-details strong { color: var(--primary-green); }
.result-card .result-details .row { display: flex; justify-content: space-between; gap: 12px; }
.result-card .result-actions {
    padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px;
}

/* Cell alerts do Romaneio: PEDIDO EM CAMADA parcial e SOBRAS pos/neg */
.datagrid-table tbody td.cell-camada-parcial {
    color: #b45309;         /* âmbar escuro */
    font-weight: 700;
    background-color: #FFF3D6;
}
.datagrid-table tbody td.cell-sobras-neg {
    color: #b91c1c;         /* vermelho */
    font-weight: 700;
}
.datagrid-table tbody td.cell-sobras-pos {
    color: #15803d;         /* verde */
    font-weight: 700;
}

/* ===================================================================
 * Aba COLETA — segue identidade visual Benassi Flores
 * (verde escuro primário, rosa como acento sutil, Satoshi, cantos 8px)
 * =================================================================== */

/* --- Toolbar (filtros + refresh) --- */
.coleta-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 20px 24px 16px;
    flex-wrap: wrap;
}
.coleta-filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.ce-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-text);
    color: var(--primary-green);
}
.ce-field > span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #6b7d72;
}
.ce-field select,
.ce-field input[type=date] {
    padding: 10px 12px;
    border: 1.5px solid #d3dcd6;
    border-radius: 8px;
    background: #fff;
    font-family: var(--font-text);
    font-size: 14px;
    color: var(--text-dark);
    transition: border-color .15s, box-shadow .15s;
    min-width: 150px;
}
.ce-field select:hover,
.ce-field input[type=date]:hover { border-color: #a9beb2; }
.ce-field select:focus,
.ce-field input[type=date]:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(24, 69, 43, 0.12);
}

/* --- Botões (padrão da marca) --- */
.ce-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    font-family: var(--font-text);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    line-height: 1;
    transition: background-color .18s, border-color .18s, color .18s, transform .05s, box-shadow .18s;
    white-space: nowrap;
    user-select: none;
}
.ce-btn:active { transform: translateY(1px); }
.ce-btn .ce-ico { font-size: 15px; line-height: 1; }

.ce-primary {
    background: var(--primary-green);
    color: #fff;
    box-shadow: 0 1px 2px rgba(24, 69, 43, 0.2);
}
.ce-primary:hover { background: #1e5334; box-shadow: 0 3px 8px rgba(24, 69, 43, 0.25); }

.ce-outline {
    background: #fff;
    color: var(--primary-green);
    border-color: var(--primary-green);
}
.ce-outline:hover { background: var(--primary-green); color: #fff; }

.ce-ghost {
    background: transparent;
    color: var(--primary-green);
    border-color: transparent;
}
.ce-ghost:hover { background: rgba(24, 69, 43, 0.08); }

.ce-danger {
    background: #b91c1c;
    color: #fff;
    box-shadow: 0 1px 2px rgba(185, 28, 28, 0.2);
}
.ce-danger:hover { background: #991b1b; box-shadow: 0 3px 8px rgba(185, 28, 28, 0.25); }

/* --- Tabela --- */
.coleta-table-wrap {
    padding: 0 24px 24px;
    overflow-x: auto;
}
.coleta-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(24, 69, 43, 0.06);
    font-family: var(--font-text);
}
.coleta-table thead th {
    background: var(--primary-green);
    color: #fff;
    text-align: left;
    padding: 14px 16px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border: none;
}
.coleta-table thead th:first-child { border-top-left-radius: 10px; }
.coleta-table thead th:last-child  { border-top-right-radius: 10px; }
.coleta-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #eef1ef;
    font-size: 14px;
    color: var(--text-dark);
    vertical-align: middle;
}
.coleta-table tbody tr:last-child td { border-bottom: none; }
.coleta-table tbody tr { transition: background-color .12s; }
.coleta-table tbody tr:hover { background: #f7faf8; }
.coleta-empty {
    text-align: center;
    padding: 40px 20px !important;
    color: #8a9a91;
    font-style: italic;
}

/* --- Badge de status --- */
.coleta-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    line-height: 1.4;
    border: 1px solid transparent;
}
.cs-ok   { background: #dff5e6; color: #14603a; border-color: #b6e2c4; }
.cs-warn { background: #fff3d6; color: #7a5a10; border-color: #f5dda1; }
.cs-mut  { background: #eceeed; color: #4c5a54; border-color: #d6dbd8; }

/* --- Coluna de ações (Ver / Baixar / Excluir) --- */
.coleta-actions {
    display: inline-flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: nowrap;
}
.ca-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    background: #fff;
    font-family: var(--font-text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, transform .05s, box-shadow .15s;
    white-space: nowrap;
    line-height: 1;
}
.ca-btn:active { transform: translateY(1px); }
.ca-btn .ca-icon { font-size: 14px; line-height: 1; }

.ca-view {
    color: var(--primary-green);
    border-color: var(--primary-green);
    background: #fff;
}
.ca-view:hover { background: var(--primary-green); color: #fff; }

.ca-down {
    color: #fff;
    background: var(--primary-green);
    border-color: var(--primary-green);
    box-shadow: 0 1px 2px rgba(24, 69, 43, 0.15);
}
.ca-down:hover { background: #1e5334; box-shadow: 0 3px 8px rgba(24, 69, 43, 0.2); }

.ca-del {
    color: #b91c1c;
    border-color: #f0c4c4;
    background: #fff;
}
.ca-del:hover { background: #b91c1c; color: #fff; border-color: #b91c1c; }

/* Em telas estreitas: mantém só o ícone */
@media (max-width: 900px) {
    .ca-btn span:not(.ca-icon) { display: none; }
    .ca-btn { padding: 8px 10px; }
}

/* --- Detalhe (modal) --- */
.cd-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 24px;
    padding: 16px 20px;
    background: #f4f7f5;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
    color: var(--text-dark);
    border-left: 3px solid var(--primary-green);
}
.cd-info strong { color: var(--primary-green); font-weight: 700; }

/* Aviso dentro do modal de confirmação */
.ccm-warn {
    background: #fff3d6;
    border-left: 3px solid #d29a12;
    color: #7a5a10;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin: 12px 0 0;
}

/* --- Toast da aba --- */
.coleta-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-green);
    color: #fff;
    padding: 14px 22px;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(24, 69, 43, 0.35);
    z-index: 2000;
    font-family: var(--font-text);
    font-weight: 600;
    font-size: 14px;
    max-width: 90vw;
    text-align: center;
    animation: ce-toast-in .18s ease;
}
.coleta-toast.ce-toast-err { background: #b91c1c; box-shadow: 0 8px 28px rgba(185, 28, 28, 0.35); }
@keyframes ce-toast-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== Bulk selection / delete ========== */
.bulk-select-all,
.bulk-item {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-green, #18452B);
}
.bulk-del-btn {
    animation: bulk-fade-in .15s ease;
}
@keyframes bulk-fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
.bulk-del-btn .bulk-count {
    font-weight: 700;
}
