* { box-sizing: border-box; }
body { font-family: Arial, sans-serif; background: #f4f6f9; margin: 0; padding: 20px; color: #333; }

/* CONTROLES DE TELA DE LOGIN E SISTEMA */
#tela_login { max-width: 400px; margin: 80px auto; background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; display: block; }
#tela_login img { max-height: 48px; margin-bottom: 20px; object-fit: contain; }
#tela_login h2 { margin: 0 0 20px 0; color: #0f172a; font-size: 20px; }
.login-group { text-align: left; margin-bottom: 15px; }
.login-group label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 5px; color: #64748b; }
.login-group input { width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 14px; box-sizing: border-box; }

.container { max-width: 1250px; margin: 0 auto; background: #fff; padding: 20px; border-radius: 6px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); display: none; }
.container.ativo { display: block; }

h1 { color: #1F4E78; font-size: 20px; border-bottom: 2px solid #1F4E78; padding-bottom: 8px; margin-top: 0; }
.header-main { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #1F4E78; padding-bottom: 10px; margin-bottom: 15px; }
.logo-area { display: flex; align-items: center; gap: 15px; }
.logo-area img { max-height: 32px; object-fit: contain; }
.logo-area h1 { margin: 0; font-size: 20px; color: #64748b; font-weight: 600; border-left: 2px solid #cbd5e1; padding-left: 15px; border-bottom: none; }

.tabs { display: flex; gap: 5px; margin-bottom: 15px; margin-top: 15px; flex-wrap: wrap; }
.tab-btn { padding: 8px 12px; background: #e2e8f0; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; color: #475569; font-size: 13px; }
.tab-btn.active { background: #1F4E78; color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; margin-bottom: 20px; }
th, td { border: 1px solid #cbd5e1; padding: 8px; text-align: left; font-size: 13px; }
th { background: #1F4E78; color: #fff; }

.form-group { display: flex; gap: 10px; margin-bottom: 15px; background: #f8fafc; padding: 12px; border-radius: 4px; border: 1px solid #e2e8f0; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 130px; }
label { font-size: 11px; font-weight: bold; color: #475569; }
input, select { padding: 6px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 13px; }

button.btn { padding: 8px 15px; background: #2563eb; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
button.btn:hover { background: #1d4ed8; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 20px; }
.kpi-card { background: #f8fafc; padding: 12px; border-radius: 4px; border-left: 4px solid #1F4E78; }
.kpi-card h4 { margin: 0 0 5px 0; font-size: 12px; color: #64748b; }
.kpi-card p { margin: 0; font-size: 16px; font-weight: bold; color: #1e293b; }

.relatorio-secao { margin-bottom: 25px; }
.relatorio-secao h4 { color: #1F4E78; border-bottom: 1px solid #cbd5e1; padding-bottom: 4px; margin-bottom: 10px; }

.btn-acao { padding: 4px 8px; border: none; border-radius: 3px; cursor: pointer; color: #fff; font-size: 11px; font-weight: bold; margin-right: 4px; }
.bg-verde { background: #16a34a; }
.bg-azul { background: #2563eb; }
.bg-amarelo { background: #eab308; color: #1e293b; }
.bg-vermelho { background: #dc2626; }

/* OTIMIZAÇÃO MOBILE / RESPONSIVO */
@media (max-width: 768px) {
    body { padding: 8px; }
    .container { padding: 12px; }
    .form-group { flex-direction: column; align-items: stretch; }
    .field { min-width: 100% !important; flex: none; }
    .form-group .btn { width: 100%; text-align: center; }
    .tab-btn { flex: 1 1 calc(50% - 4px); text-align: center; font-size: 12px; }
    .header-main { flex-direction: column; align-items: flex-start; gap: 12px; }
    table { font-size: 12px; }
    th, td { padding: 6px 8px; white-space: nowrap; }
}

@media print {
    body { background: #fff; padding: 0; }
    .container { box-shadow: none; padding: 0; max-width: 100%; }
    .tabs, .form-group, .btn, .btn-acao { display: none !important; }
    .tab-content { display: block !important; }
}
/* ===== CALENDÁRIO / AGENDA ===== */
.calendario-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
}
.calendario-grid .cal-header {
    background: #1F4E78;
    color: #fff;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    padding: 6px 2px;
}
.calendario-grid .cal-day {
    background: #fff;
    min-height: 52px;
    padding: 3px;
    font-size: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.15s;
}
.calendario-grid .cal-day:hover { background: #f1f5f9; }
.calendario-grid .cal-day.outro-mes { background: #f8fafc; color: #94a3b8; }
.calendario-grid .cal-day.hoje { outline: 2px solid #2563eb; outline-offset: -2px; z-index: 1; }
.calendario-grid .cal-day.selecionado { background: #dbeafe; }
.calendario-grid .cal-num {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}
.calendario-grid .cal-eventos {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.cal-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    vertical-align: middle;
}
.cal-dot.ferias { background: #16a34a; }
.cal-dot.aniversario { background: #db2777; }
.cal-dot.reajuste { background: #d97706; }
.cal-dot.outro { background: #64748b; }
.badge-tipo {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}
.badge-tipo.ferias { background: #16a34a; }
.badge-tipo.aniversario { background: #db2777; }
.badge-tipo.reajuste { background: #d97706; }
.badge-tipo.outro { background: #64748b; }

/* ===== NOTAS POR CONDOMÍNIO + MODAL ===== */
.notas-layout {
    display: flex;
    gap: 16px;
    align-items: stretch;
    min-height: 420px;
}
.notas-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}
.lista-condos-notas {
    max-height: 480px;
    overflow-y: auto;
}
.condo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
    margin-bottom: 3px;
    border: 1px solid transparent;
}
.condo-item:hover { background: #e2e8f0; }
.condo-item.ativo {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
    font-weight: 600;
}
.condo-item .badge-count {
    background: #cbd5e1;
    color: #334155;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}
.condo-item.ativo .badge-count {
    background: #2563eb;
    color: #fff;
}
.notas-main {
    flex: 1;
    min-width: 0;
}
.cards-notas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.nota-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    min-height: 140px;
}
.nota-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}
.nota-card .nc-titulo {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
    margin: 0 0 6px 0;
}
.nota-card .nc-meta {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 8px;
}
.nota-card .nc-texto {
    font-size: 12.5px;
    color: #475569;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
}
.nota-card .nc-acoes {
    margin-top: 10px;
    display: flex;
    gap: 6px;
}
.nota-vazia {
    grid-column: 1 / -1;
    text-align: center;
    color: #64748b;
    padding: 40px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-nota {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 820px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-nota-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
}
.modal-nota-header h3 {
    margin: 0;
    font-size: 17px;
    color: #1e293b;
}
.modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; color: #0f172a; }
.modal-nota-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
}
.modal-nota-body textarea {
    width: 100%;
    min-height: 280px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
}
.modal-nota-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 10px 10px;
}

@media (max-width: 768px) {
    .notas-layout { flex-direction: column; }
    .notas-sidebar { width: 100%; }
    .lista-condos-notas { max-height: 180px; }
    .modal-nota { max-height: 96vh; }
    .modal-nota-body textarea { min-height: 200px; }
}

/* ===== BANNER FATURAS DE CARTÃO (lado a lado, discreto) ===== */
#banner_faturas_cartao {
    margin-bottom: 14px;
}
.faturas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}
.fatura-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.fatura-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}
.fatura-card.fatura-zerada {
    background: #f8fafc;
    border-color: #e2e8f0;
    opacity: 0.85;
}
.fatura-card.fatura-urgente {
    background: #fef2f2;
    border-color: #fecaca;
}
.fatura-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.fatura-nome {
    font-weight: 600;
    font-size: 13px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fatura-dias {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}
.fatura-dias.hoje {
    color: #dc2626;
    font-weight: 700;
}
.fatura-dias.atrasado {
    color: #dc2626;
    font-weight: 600;
}
.fatura-card-mid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fatura-venc {
    font-size: 12px;
    color: #64748b;
}
.fatura-status {
    font-size: 12px;
    color: #475569;
}
.fatura-status.ok {
    color: #16a34a;
    font-weight: 600;
    font-size: 12px;
}
.fatura-status.pendente strong {
    color: #1e293b;
}
.fatura-card-bot {
    margin-top: 2px;
}
.btn-fatura {
    width: 100%;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #475569;
    cursor: pointer;
}
.btn-fatura:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.fatura-card.fatura-urgente .btn-fatura {
    background: #fff;
    border-color: #fca5a5;
    color: #b91c1c;
}
.fatura-card.fatura-zerada .btn-fatura {
    color: #94a3b8;
    border-color: #e2e8f0;
}

/* ===== CONFIG E-MAIL (Configurações) ===== */
.config-email-box {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}
.config-email-section {
    margin-bottom: 16px;
    padding-bottom: 4px;
}
.config-email-title {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 6px;
}
.config-email-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.config-email-grid .field {
    flex: 1 1 160px;
    min-width: 140px;
    max-width: 100%;
}
.config-email-textarea,
.assinatura-editor {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.assinatura-editor {
    min-height: 110px;
    outline: none;
}
.assinatura-editor:focus,
.config-email-textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.config-email-preview {
    margin-top: 6px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    min-height: 60px;
    max-width: 100%;
    overflow-x: auto;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.config-email-preview img {
    max-width: 180px;
    max-height: 64px;
    height: auto;
}
#tab5 .form-group {
    max-width: 100%;
}
#tab5 table {
    max-width: 100%;
}
@media (max-width: 768px) {
    .config-email-grid .field {
        flex: 1 1 100%;
        min-width: 100%;
    }
}

/* Configurações > Postos: e-mail não invade a coluna seguinte */
#tab5 table.tabela-postos { table-layout: fixed; width: 100%; }
#tab5 table.tabela-postos th:nth-child(1) { width: 24%; }
#tab5 table.tabela-postos th:nth-child(2) { width: 36%; }
#tab5 table.tabela-postos th:nth-child(3) { width: 40%; }
#tab5 #tabela_postos td { vertical-align: middle; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
#tab5 #tabela_postos td.posto-email { font-size: 12px; color: #475569; }
#tab5 #tabela_postos td.posto-acoes .btn-acao { margin: 2px 2px 2px 0; }
