:root {
    --bg-dark: #121212;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-1: #4CAF50;
    --accent-2: #2E7D32;
    --border-color: #333;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
}

.app-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.header { text-align: center; margin-bottom: 2rem; }
.logo { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 0.5rem; }
h1 { font-weight: 800; font-size: 2.2rem; }
h1 span { color: var(--accent-1); }
.header p { color: var(--text-muted); }

.upload-area {
    background: #1e1e1e;
    border: 2px dashed #444;
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    transition: var(--transition);
    cursor: pointer;
    max-width: 700px;
    margin: 0 auto;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent-1);
    background: #252525;
}

.upload-icon { color: var(--accent-1); margin-bottom: 1rem; }
.file-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.hidden { display: none !important; }

#loading { text-align: center; padding: 3rem; }
.spinner {
    width: 40px; height: 40px; border: 3px solid #333;
    border-top-color: var(--accent-1); border-radius: 50%;
    margin: 0 auto 1rem; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.btn-primary {
    background: var(--accent-1); color: #fff; border: none;
    padding: 0.5rem 1rem; border-radius: 0.3rem; font-weight: 600; cursor: pointer; transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-2); }

/* Tabela Excel Style */
.table-responsive { width: 100%; overflow-x: auto; border: 1px solid var(--border-color); }
.excel-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: left; }
.excel-table th, .excel-table td { padding: 8px 10px; border: 1px solid #444; }
.excel-table th { background-color: #000; color: #fff; font-weight: 600; border-bottom: 2px solid var(--accent-1); white-space: nowrap; position: sticky; top: 0; z-index: 10; }
.excel-table td { color: #f1f1f1; white-space: normal; max-width: 500px; word-break: break-word; }

/* Status da Classificação */
.status-tag {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.75rem; font-weight: bold;
}
.status-nao-classificado { background: #d32f2f; color: white; }
.status-classificado { background: #388E3C; color: white; }

/* Cards de Resumo */
.summary-cards {
    display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.card {
    background: #1e1e1e; border-left: 4px solid var(--accent-1); padding: 1rem 1.5rem; border-radius: 0.5rem; flex: 1; min-width: 200px;
}
.card h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.card p { font-size: 1.8rem; font-weight: 800; margin: 0; }
.card.danger { border-left-color: #d32f2f; }
.card.danger p { color: #ef5350; }

/* Painel de Controle de Agrupamento Dinâmico */
.grouping-control-panel {
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid #333;
    border-radius: 0.8rem;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.grouping-title-area {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.grouping-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.group-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.group-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-1);
    color: var(--text-main);
    transform: translateY(-1px);
}

.group-pill.active {
    background: var(--accent-2);
    border-color: var(--accent-1);
    color: #fff;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}

.group-pill.active::before {
    content: "✓";
    font-weight: bold;
    color: #a5d6a7;
}

/* Rodapé de Tabela (Total Geral) */
.excel-table tfoot tr {
    background-color: #0b0b0b;
    border-top: 2px solid #555;
}

.excel-table tfoot td {
    padding: 12px 10px;
    font-size: 0.95rem;
    border: 1px solid #444;
}

/* Estilos do Modal de Depuração */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
}

.modal-content.glass {
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    width: 90%;
    max-width: 850px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    position: relative;
}

.close-modal {
    position: absolute;
    top: 1rem; right: 1.5rem;
    font-size: 1.8rem; font-weight: bold; color: var(--text-muted);
    cursor: pointer; transition: var(--transition);
}
.close-modal:hover { color: #f44336; }

.modal-header { margin-bottom: 1.5rem; border-bottom: 1px solid #444; padding-bottom: 1rem; }
.modal-header h2 { font-size: 1.5rem; font-weight: 800; color: var(--text-main); }
.modal-header p { font-size: 0.85rem; color: var(--text-muted); }

.debug-row-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #333;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}
.debug-row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.8rem;
}
.debug-grid-item strong { color: var(--text-muted); display: block; font-size: 0.75rem; margin-bottom: 2px; }
.debug-grid-item span { color: #fff; font-weight: 600; }

.debug-table-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid #333;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    overflow: hidden;
}
.debug-table-header {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.8rem 1rem;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}
.debug-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
}
.debug-badge.passed { background: #2E7D32; color: #fff; }
.debug-badge.failed { background: #c62828; color: #fff; }

.debug-filter-list { padding: 0.8rem 1rem; }
.debug-filter-item {
    padding: 0.8rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid #666;
    margin-bottom: 0.8rem;
    font-size: 0.8rem;
}
.debug-filter-item:last-child { margin-bottom: 0; }
.debug-filter-item.passed { border-left-color: var(--accent-1); }
.debug-filter-item.failed { border-left-color: #f44336; }

.debug-filter-title { font-weight: bold; color: var(--text-main); margin-bottom: 0.4rem; }
.debug-code-box {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    background: #000;
    padding: 0.5rem;
    border-radius: 3px;
    margin-top: 0.4rem;
    color: #a5d6a7;
    white-space: pre-wrap;
    word-break: break-all;
}
.debug-error-box {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid #f44336;
    color: #ff8a80;
    padding: 0.5rem;
    border-radius: 3px;
    margin-top: 0.4rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}
.debug-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
}
.debug-status-indicator.passed { color: var(--accent-1); }
.debug-status-indicator.failed { color: #f44336; }

/* Status da tabela de simulação clicável */
.status-clickable {
    cursor: pointer;
    transition: transform 0.1s ease;
}
.status-clickable:hover {
    transform: scale(1.05);
    filter: brightness(1.15);
}

/* Estilos da Tela de Login Premium */
.login-wrapper {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 50%, #1e1e1e 0%, var(--bg-dark) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.login-wrapper.fade-out {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.login-card.glass {
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.5rem;
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    text-align: center;
}

.login-logo {
    margin-bottom: 2.5rem;
}
.login-logo svg {
    filter: drop-shadow(0 0 15px rgba(76, 175, 80, 0.3));
    margin-bottom: 1rem;
}
.login-logo h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.3rem;
    letter-spacing: -0.5px;
}
.login-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}
.input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-wrapper {
    position: relative;
    width: 100%;
}
.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: var(--transition);
}

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 0.5rem;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.input-wrapper input:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
    background: rgba(0, 0, 0, 0.4);
}
.input-wrapper input:focus + .input-icon,
.input-wrapper input:focus ~ .input-icon {
    color: var(--accent-1);
}

.btn-login {
    width: 100%;
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.login-error-msg {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid #f44336;
    color: #ff8a80;
    font-size: 0.8rem;
    padding: 0.6rem;
    border-radius: 0.5rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.shake-element {
    animation: shake 0.4s ease;
}

/* Transicao para revelar a app com blur */
.app-wrapper {
    transition: filter 0.5s ease;
}
.app-wrapper.hidden {
    display: none !important;
}

/* Destaque do Fornecedor no Modal */
.debug-fornecedor-card {
    background: rgba(76, 175, 80, 0.08);
    border-left: 5px solid var(--accent-1);
    border-radius: 0.5rem;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.15);
    border-left-width: 5px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.debug-fornecedor-icon {
    background: rgba(76, 175, 80, 0.15);
    border-radius: 50%;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-1);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.2);
    flex-shrink: 0;
}

.debug-fornecedor-info {
    display: flex;
    flex-direction: column;
}

.debug-fornecedor-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.debug-fornecedor-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}


