:root {
    --verde: #2e7d32;
    --verde-escuro: #1b5e20;
    --vermelho: #c62828;
    --amarelo: #f9a825;
    --cinza-bg: #f4f6f4;
    --cinza-borda: #d9dfd9;
    --texto: #1c1c1c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--cinza-bg);
    color: var(--texto);
}

.app-header {
    background: var(--verde);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header__brand { font-weight: 600; font-size: 1.05rem; }

.app-nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--verde-escuro);
    width: 220px;
    padding: 0.5rem 0;
}

.app-nav--open { display: flex; }

.app-nav a {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
}

.app-nav a:hover { background: rgba(255,255,255,0.1); }

.app-nav__toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.app-main {
    padding: 1rem;
    max-width: 1100px;
    margin: 0 auto;
}

.flash-container { margin-bottom: 1rem; }
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.flash--sucesso { background: #e8f5e9; color: var(--verde-escuro); border: 1px solid #a5d6a7; }
.flash--erro { background: #ffebee; color: var(--vermelho); border: 1px solid #ef9a9a; }

.card {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}

.grid-resumo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat { text-align: center; }
.stat__valor { font-size: 1.8rem; font-weight: 700; }
.stat__label { font-size: 0.8rem; color: #666; }
.stat--alerta .stat__valor { color: var(--vermelho); }

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--cinza-borda);
    font-size: 0.9rem;
}

th { background: #eef3ee; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge--ativo, .badge--pago { background: #e8f5e9; color: var(--verde-escuro); }
.badge--inadimplente, .badge--atrasado { background: #ffebee; color: var(--vermelho); }
.badge--pendente, .badge--incompleto { background: #fff8e1; color: #f57f17; }
.badge--suspenso, .badge--inativo, .badge--cancelado { background: #eceff1; color: #455a64; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    background: var(--verde);
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn:hover { background: var(--verde-escuro); }
.btn--secundario { background: #607d8b; }
.btn--perigo { background: var(--vermelho); }
.btn--sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--cinza-borda);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--texto);
    background: white;
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 16px;
    cursor: pointer;
}

.form-group select::-ms-expand {
    display: none;
}

/* Mobile: navegacao vira drawer full-width, tabelas viram cards empilhados */
@media (max-width: 640px) {
    .app-nav { width: 100%; }

    table.responsive-stack, table.responsive-stack thead, table.responsive-stack tbody,
    table.responsive-stack th, table.responsive-stack td, table.responsive-stack tr {
        display: block;
    }
    table.responsive-stack thead { display: none; }
    table.responsive-stack tr {
        margin-bottom: 0.75rem;
        background: white;
        border-radius: 8px;
        padding: 0.5rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }
    table.responsive-stack td {
        border: none;
        padding: 0.35rem 0.5rem;
        display: flex;
        justify-content: space-between;
    }
    table.responsive-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        margin-right: 1rem;
    }
}

@media (min-width: 641px) {
    .app-nav { display: flex; flex-direction: row; position: static; background: none; width: auto; padding: 0; }
    .app-nav a { padding: 0.4rem 0.9rem; }
    .app-nav__toggle { display: none; }
}
