* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
}

a {
    color: inherit;
    text-decoration: none;
}

.header {
    background: #172554;
    color: white;
    padding: 22px 35px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: bold;
}

.subtitle {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 4px;
}

.header-badge {
    font-size: 13px;
    background: rgba(255, 255, 255, 0.12);
    padding: 6px 14px;
    border-radius: 20px;
}

.container {
    max-width: 1250px;
    margin: 30px auto;
    padding: 0 20px;
}

.welcome {
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 14px;
}

.welcome h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
}

.welcome p {
    margin: 0;
    color: #6b7280;
}

.breadcrumb {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 10px;
}

.breadcrumb a {
    color: #1d4ed8;
}

.status {
    padding: 18px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-weight: bold;
}

.status-ok {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.status-erro {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.status-icon {
    display: inline-flex;
    vertical-align: -4px;
    margin-right: 6px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 30px;
}

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

.stat-valor {
    font-size: 32px;
    font-weight: bold;
    color: #172554;
    line-height: 1.1;
}

.stat-valor-ok {
    color: #166534;
}

.stat-valor-neutro {
    color: #6b7280;
}

.stat-label {
    color: #6b7280;
    font-size: 14px;
    margin-top: 6px;
}

.section-title {
    font-size: 20px;
    margin: 0 0 15px 0;
}

.modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}

.module {
    background: white;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: 0.2s;
    display: block;
}

.module:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 16px rgba(0,0,0,0.12);
}

.module-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.module-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 7px;
    color: #1f2937;
}

.module-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.info {
    margin-top: 30px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.info-row:last-child {
    border-bottom: none;
}

.footer {
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    padding: 35px;
}

/* ==================== EMPRESAS ==================== */

.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.toolbar-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

input[type="text"],
input[type="date"],
input[type="password"],
input[type="file"],
select {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: #1d4ed8;
}

.btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.15s;
}

.btn-primary {
    background: #1d4ed8;
    color: white;
}

.btn-primary:hover {
    background: #1e40af;
}

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

thead {
    background: #f1f5f9;
}

th, td {
    text-align: left;
    padding: 13px 16px;
    font-size: 14px;
    border-bottom: 1px solid #eef0f3;
}

th {
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.03em;
}

tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.badge-ativa {
    background: #dcfce7;
    color: #166534;
}

.badge-inativa {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-pendente {
    background: #fef9c3;
    color: #854d0e;
}

.badge-processado {
    background: #dcfce7;
    color: #166534;
}

.badge-erro {
    background: #fee2e2;
    color: #991b1b;
}

.badge-cancelado {
    background: #f3f4f6;
    color: #6b7280;
}

/* Situacao fiscal da NFS-e (nfse_documentos.situacao - migration 011),
   distinta da situacao do documento no sistema (badges acima) - ver
   comentario em documentosFiscaisRepository.js. Tambem usadas para o
   badge de conferencia fiscal (documentos_fiscais.situacao_conferencia,
   migration 036). */
.badge-substituida {
    background: #ffedd5;
    color: #9a3412;
}

.badge-conferida {
    background: #dcfce7;
    color: #166534;
}

.badge-inconsistencia {
    background: #fee2e2;
    color: #991b1b;
}

.filtros-avancados {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e5e7eb;
}

.filtros-avancados.aberto {
    display: grid;
}

.filtros-avancados .form-field label {
    font-size: 12px;
}

.abas-papel {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.aba-papel {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
}

.aba-papel.ativa {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

.acoes {
    display: flex;
    gap: 8px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    font-size: 14px;
    color: #6b7280;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #6b7280;
}

/* Grade de classificação inline (tela "Classificação de Lançamentos" -
   cada linha da tabela vira um mini-formulário editável, sem modal). */
.tabela-scroll {
    overflow-x: auto;
    border-radius: 12px;
}

.input-linha,
.select-linha {
    width: 100%;
    min-width: 160px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.input-linha:focus,
.select-linha:focus {
    outline: none;
    border-color: #1d4ed8;
}

.input-estreita {
    min-width: 90px;
}

.col-descricao {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-valor {
    white-space: nowrap;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.aberto {
    display: flex;
}

.modal {
    background: white;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal h2 {
    margin-top: 0;
}

.modal-close-x {
    position: absolute;
    top: 18px;
    right: 20px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
}

.modal-close-x:hover {
    color: #111827;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 18px 0;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.form-field input,
.form-field select {
    width: 100%;
}

.form-erro {
    color: #991b1b;
    font-size: 13px;
    margin-top: 6px;
    display: none;
}

.modal-acoes {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #172554;
    color: white;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: 0.25s;
    z-index: 200;
}

.toast.mostrar {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-erro {
    background: #991b1b;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}
