* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #020617;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Quando o login está visível, centraliza */
body:not(.dashboard-active) {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
}

/* Quando dashboard está ativo, remove limite de largura */
body.dashboard-active .container.dashboard-fullscreen {
    max-width: 100%;
}

/* Quando o dashboard está visível, o container ocupa toda a tela */
body.dashboard-active .container.dashboard-fullscreen {
    max-width: 100%;
    height: 100vh;
    padding: 0;
}

.login-container {
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.dashboard-container {
    width: 100%;
    height: 100vh;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.login-container h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

.btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 40%, #4c1d95 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #ef4444;
    color: white;
    padding: 8px 20px;
    width: auto;
}

.btn-secondary:hover {
    background: #d32f2f;
}

.error-message {
    color: #f44336;
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    min-height: 20px;
}

.switch-form {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.switch-form a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.switch-form a:hover {
    text-decoration: underline;
}

.dashboard-container header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    padding-right: 0;
    border-bottom: 2px solid rgba(148, 163, 184, 0.2);
    width: 100%;
}

.dashboard-container header #logoutBtn {
    position: fixed;
    top: 2rem;
    right: 2rem;
    margin: 0;
    z-index: 1000;
}

.dashboard-container h1 {
    color: #e5e7eb;
    font-size: 2rem;
    letter-spacing: 0.02em;
    margin: 0;
    flex: 1;
}

.dashboard-main main {
    width: 100%;
    max-width: 100%;
}

.welcome-message {
    text-align: left;
    padding: 16px 0 8px;
}

.welcome-message h2 {
    color: #e5e7eb;
    margin-bottom: 10px;
    font-size: 1.8em;
}

.welcome-message p {
    color: #9ca3af;
    font-size: 1.1em;
}

#userName {
    color: #a855f7;
}

@media (max-width: 600px) {
    .login-container,
    .dashboard-container {
        padding: 30px 20px;
    }
}

/* Seção de Empresas */
.empresas-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #020617;
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
    width: 100%;
    max-width: 100%;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    margin: 0;
    color: #e5e7eb;
}

.filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
}

.select-periodo {
    padding: 0.5rem 1rem;
    border: 1px solid #374151;
    border-radius: 999px;
    font-size: 0.9rem;
    background: #020617;
    color: #e5e7eb;
    cursor: pointer;
    min-width: 150px;
}

.input-dias {
    padding: 0.5rem 1rem;
    border: 1px solid #374151;
    border-radius: 999px;
    font-size: 0.9rem;
    width: 120px;
    text-align: center;
}

.input-dias:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.input-dias::-webkit-inner-spin-button,
.input-dias::-webkit-outer-spin-button {
    opacity: 1;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Card de Empresas Hoje */
.empresa-card {
    background: radial-gradient(circle at top left, #8b5cf6, #4c1d95 45%, #020617 100%);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.card-date {
    font-size: 0.9rem;
    opacity: 0.9;
}

.card-content {
    text-align: center;
}

.total-number {
    font-size: 3rem;
    font-weight: bold;
    margin: 1rem 0;
}

.card-description {
    margin: 0;
    font-size: 1rem;
    opacity: 0.9;
}

/* Lista de Empresas */
.empresas-list {
    margin-top: 1.5rem;
    width: 100%;
    max-width: 100%;
}

.empresas-list h3 {
    margin-bottom: 1rem;
    color: #e5e7eb;
}

.total-summary {
    background: #020617;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
}

.total-summary p {
    margin: 0;
    font-size: 1.1rem;
    color: #9ca3af;
}

.table-container {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

thead {
    background: #020617;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    font-weight: 600;
    color: #9ca3af;
}

td.total-cell {
    font-weight: 600;
    color: #a855f7;
    text-align: right;
}

tbody tr:hover {
    background: #020617;
}

/* Loading e Erro */
.loading-message {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

/* Responsivo */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filters {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .select-periodo,
    .input-dias {
        width: 100%;
    }
    
    .btn-small {
        width: 100%;
    }
    
    .total-number {
        font-size: 2rem;
    }
    
    table {
        font-size: 0.9rem;
    }
}

.download-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.btn-download {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-download:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.list-header h3 {
    margin: 0;
    color: #333;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.modal-close:hover {
    color: #000;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    border: 1px solid #c3e6cb;
}

@media (max-width: 768px) {
    .list-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons button {
        width: 100%;
    }
}

.acoes-cell {
    text-align: center;
    width: 120px;
}

.btn-download-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-download-small:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.data-cell {
    font-weight: 500;
}

.total-cell {
    font-weight: 600;
    color: #667eea;
    text-align: right;
}

@media (max-width: 768px) {
    .acoes-cell {
        width: auto;
    }
    
    .btn-download-small {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* Seção de Configuração de CNAEs */
.cnaes-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #020617;
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
    width: 100%;
    max-width: 100%;
}

.section-description {
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.cnaes-group {
    margin-bottom: 2rem;
}

.cnaes-group h3 {
    margin-bottom: 0.5rem;
    color: #e5e7eb;
}

.required {
    color: #e74c3c;
}

.optional {
    color: #9ca3af;
    font-size: 0.9em;
    font-weight: normal;
}

.help-text {
    font-size: 0.9em;
    color: #6b7280;
    margin-bottom: 1rem;
}

.cnaes-list {
    margin-bottom: 1rem;
}

.cnae-item {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.cnae-autocomplete-container {
    flex: 1;
    position: relative;
}

.cnae-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #374151;
    border-radius: 8px;
    background: #020617;
    color: #e5e7eb;
    font-size: 1rem;
}

.cnae-input:focus {
    outline: none;
    border-color: #667eea;
}

.natureza-juridica-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #374151;
    border-radius: 8px;
    background: #020617;
    color: #e5e7eb;
    font-size: 1rem;
    cursor: pointer;
}

.natureza-juridica-select:focus {
    outline: none;
    border-color: #667eea;
}

.natureza-juridica-select option {
    background: #020617;
    color: #e5e7eb;
}

.cnae-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.cnae-autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-bottom: 1px solid #374151;
    transition: background-color 0.2s;
}

.cnae-autocomplete-item:last-child {
    border-bottom: none;
}

.cnae-autocomplete-item:hover,
.cnae-autocomplete-item.selected {
    background-color: #374151;
}

.cnae-code {
    font-weight: 600;
    color: #667eea;
    font-size: 0.9rem;
}

.cnae-name {
    color: #d1d5db;
    font-size: 0.85rem;
    line-height: 1.4;
}

.cnae-autocomplete-loading {
    padding: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.9rem;
}

.btn-remove-cnae {
    width: 32px;
    height: 32px;
    border: none;
    background: #e74c3c;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.btn-remove-cnae:hover {
    background: #c0392b;
}

.btn-add-cnae {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-add-cnae:hover {
    background: #5568d3;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Seções de configuração */
.config-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.config-section h3 {
    color: #e5e7eb;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.config-section h4 {
    color: #d1d5db;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.config-section .form-group {
    margin-bottom: 1rem;
}

.config-section label {
    display: block;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.config-section input[type="text"],
.config-section input[type="number"],
.config-section input[type="date"],
.config-section select,
.config-section textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #374151;
    border-radius: 8px;
    background: #020617;
    color: #e5e7eb;
    font-size: 1rem;
}

.config-section input[type="text"]:focus,
.config-section input[type="number"]:focus,
.config-section input[type="date"]:focus,
.config-section select:focus,
.config-section textarea:focus {
    outline: none;
    border-color: #667eea;
}

.config-section textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.config-section input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

.config-section label input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Busca textual */
.busca-textual-list {
    margin-bottom: 1rem;
}

.busca-textual-item {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 1rem;
    padding: 1rem;
    background: #1e293b;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #374151;
    position: relative;
}

.busca-textual-item .form-group {
    margin-bottom: 0;
}

.busca-textual-item .btn-remove-cnae {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* Responsividade */
@media (max-width: 768px) {
    .busca-textual-item {
        grid-template-columns: 1fr;
    }
}

/* Layout com sidebar no dashboard */
.dashboard-layout {
    display: flex;
    height: 100vh;
    gap: 0;
}

.sidebar {
    width: 260px;
    background: #1f2937;
    color: #e5e7eb;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 0 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(156, 163, 175, 0.4);
}

.sidebar-logo-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e5e7eb;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.sidebar-link {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: none;
    text-decoration: none;
    display: block;
    color: inherit;
    background: transparent;
    color: #d1d5db;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.05s;
}

.sidebar-link:hover {
    background: rgba(55, 65, 81, 0.9);
    color: #ffffff;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.5);
}

.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 2rem;
    padding-right: 6rem; /* Espaço extra para o botão Sair fixo */
    background: #020617;
    width: 100%;
    max-width: 100%;
}

@media (max-width: 900px) {
    .dashboard-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        height: auto;
        padding: 1rem;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 0.5rem;
        flex: 1;
    }

    .sidebar-link {
        flex: 1;
        justify-content: center;
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    .dashboard-main {
        padding: 1rem;
    }
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    border: 1px solid #c3e6cb;
}

/* Estilos para lista de crons */
.crons-section {
    margin-top: 2rem;
}

.crons-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.cron-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #334155;
    border-radius: 16px;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.cron-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cron-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.cron-card:hover::before {
    opacity: 1;
}

.cron-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.cron-card-header h3 {
    color: #f1f5f9;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    word-break: break-word;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.cron-card-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.cron-card-descricao {
    color: #cbd5e1;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    word-break: break-word;
    min-height: 3rem;
    position: relative;
    z-index: 1;
}

.cron-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid #334155;
    position: relative;
    z-index: 1;
}

.cron-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    padding: 0.5rem 0;
}

.cron-info-label {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cron-info-item:first-child .cron-info-label::before {
    content: '📝';
    font-size: 0.85rem;
}

.cron-info-item:last-child .cron-info-label::before {
    content: '🔄';
    font-size: 0.85rem;
}

.cron-info-value {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.95rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px dashed #334155;
    border-radius: 16px;
    margin-top: 2rem;
}

.empty-state p {
    color: #94a3b8;
    font-size: 1.2rem;
    margin-bottom: 2rem;
    font-weight: 500;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-small.btn-secondary {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    color: #f1f5f9;
    border: none;
}

.btn-small.btn-secondary:hover {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(71, 85, 105, 0.3);
}

@media (max-width: 768px) {
    .crons-list {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .cron-card {
        padding: 1.5rem;
    }
    
    .cron-card-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .cron-card-header h3 {
        font-size: 1.3rem;
    }
    
    .cron-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .cron-card-actions .btn {
        flex: 1;
    }
}

