* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #eef3f1;
    margin: 0;
    color: #263238;
    overflow-x: hidden;
}

/* Banner de Atualização do PWA */
.pwa-update-banner {
    display: none;
    background: #1565c0;
    color: #ffffff;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.pwa-update-banner.visivel { display: flex; }
.pwa-update-banner button {
    width: auto;
    background: #ffffff;
    color: #1565c0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    border: none;
    cursor: pointer;
}
.pwa-update-banner button:hover { background: #e3f2fd; }

/* Cabeçalho Superior */
header {
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
    color: #fff;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: #ffffff;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
header h1 { margin: 0; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.user-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.btn-header {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    border: none;
    width: auto;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-header:hover { background: rgba(255, 255, 255, 0.28); }
.btn-sair { background: rgba(198, 40, 40, 0.78); }
.btn-instalar { background: #ffffff; color: #1b5e20; font-weight: 700; }
.btn-instalar:hover { background: #f1f8e9; }

/* Barra de Navegação (7 Abas) */
/* Barra de Navegação Responsiva (quebra linha automaticamente no celular) */
nav {
    background: #ffffff;
    border-bottom: 1px solid #d5e0dc;
    padding: 8px 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 8px;
    max-width: 1000px;
    margin: 12px auto 0 auto;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 6px;
    text-decoration: none;
    color: #455a64;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
    border: 1px solid transparent;
}
nav a span.nav-icon { font-size: 18px; margin-bottom: 3px; }
nav a:hover { background: #f1f8e9; color: #1b5e20; }
nav a.active {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: #a5d6a7;
}

/* Container e Cartões */
.container {
    max-width: 1000px;
    width: 100%;
    margin: 15px auto;
    padding: 0 12px;
}
.card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border: 1px solid #e0e8e5;
}
.card-edit { border: 2px solid #fbc02d; background: #fffde7; }
.card-baixa { border: 2px solid #2e7d32; background: #f1f8e9; }
.alerta-erro {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 13px;
}
.alerta-ok {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 13px;
}
h2 {
    margin: 0 0 14px 0;
    font-size: 17px;
    color: #1b5e20;
    border-bottom: 1px solid #eceff1;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Formulários */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    align-items: end;
}
label { display: block; font-size: 12px; font-weight: 600; color: #546e7a; margin-bottom: 4px; }
input, select, button {
    width: 100%;
    padding: 10px;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
input[type="file"] { padding: 7px; background: #fff; font-size: 13px; }
input:focus, select:focus { outline: none; border-color: #2e7d32; }
button {
    background: #2e7d32;
    color: #fff;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
button:hover { background: #1b5e20; }
.btn-cancelar {
    display: inline-block;
    text-align: center;
    background: #eceff1;
    color: #455a64;
    padding: 10px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-top: 6px;
    width: 100%;
}

/* Tabelas */
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid #eceff1; }
th { background: #f8faf9; color: #546e7a; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
tr.total-row { background: #f1f8e9; font-weight: bold; border-top: 2px solid #a5d6a7; }

/* Etiquetas e Botões de Ação */
.badge { padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: bold; display: inline-block; }
.importante { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.prio-alta { background: #ffebee; color: #c62828; }
.prio-media { background: #fff8e1; color: #f57f17; }
.prio-baixa { background: #e8f5e9; color: #2e7d32; }
.badge-parcial { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.badge-contrib { background: #e3f2fd; color: #1565c0; }
.badge-desp { background: #fce4ec; color: #ad1457; }
.alerta-estoque { background: #ffebee; }

.acoes-group { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-acao {
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.btn-ok { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.btn-edit { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.btn-del { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.btn-doc { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* Cards Estatísticos */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 15px; }
.stat-box { background: #f8faf9; border: 1px solid #e0e8e5; border-radius: 8px; padding: 14px; text-align: center; }
.stat-num { font-size: 20px; font-weight: bold; color: #1b5e20; }
.stat-label { font-size: 12px; color: #607d8b; margin-top: 4px; }

/* Status Online e Versão */
.online-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}
.dot-online { width: 8px; height: 8px; background: #2e7d32; border-radius: 50%; display: inline-block; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

.versao-bar {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eceff1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #78909c;
}
.btn-check-update {
    background: #f1f8e9;
    color: #1b5e20;
    border: 1px solid #c8e6c9;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    width: auto;
}
.btn-check-update:hover { background: #e8f5e9; }

/* Responsividade Mobile */
@media (max-width: 750px) {
    nav {
        grid-template-columns: repeat(3, 1fr);
        margin: 8px 12px 0 12px;
        padding: 8px;
    }
    nav a {
        padding: 8px 4px;
        font-size: 12px;
    }
    table.resp-table thead { display: none; }
    table.resp-table, table.resp-table tbody, table.resp-table tr, table.resp-table td { display: block; width: 100%; }
    table.resp-table tr {
        background: #ffffff;
        border: 1px solid #dce5e2;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 10px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    }
    table.resp-table td {
        border-bottom: 1px solid #f1f5f4;
        padding: 7px 4px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        gap: 10px;
    }
    table.resp-table td:last-child { border-bottom: none; padding-top: 10px; justify-content: flex-start; }
    table.resp-table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 12px;
        color: #607d8b;
        text-align: left;
        flex-shrink: 0;
    }
    .acoes-group { width: 100%; justify-content: flex-start; }
    .btn-acao { flex: 1; justify-content: center; padding: 8px 6px; font-size: 13px; }
}

/* Alinhamento perfeito entre header, nav, container e footer */
header, nav {
    max-width: 1160px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    border-radius: 0 0 10px 10px;
}
nav {
    margin-top: 6px;
    border-radius: 10px;
}
.container {
    max-width: 1160px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
}
@media (max-width: 1180px) {
    header, nav, .container {
        margin-left: 10px;
        margin-right: 10px;
        width: auto;
    }
}