:root {
    --blue: #1F5C7A;
    --blue-dark: #123B4F;
    --green: #2E8B67;
    --alert: #E2704B;
    --bg: #F2F7F6;
    --border: #DCE6E3;
    --text: #1A2B2E;
    --text-muted: #5C7772;
    --card-bg: #FFFFFF;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Poppins', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--blue); }

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--blue-dark);
    color: #fff;
    padding: 14px 18px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar .brand {
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar .brand .accent { color: var(--green); }

.topbar-sair {
    color: #C7DAD6;
    text-decoration: none;
    font-size: 13px;
}

main {
    flex: 1;
    min-width: 0;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 16px 96px;
}

@media (min-width: 720px) {
    main { padding: 32px 24px 48px; }
}

h1 { font-size: 21px; margin: 0 0 4px; }
.subtitle { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-valor { font-size: 26px; font-weight: 700; }

.stat-comparativo { font-size: 13px; font-weight: 600; }
.stat-comparativo.up { color: var(--alert); }
.stat-comparativo.down { color: var(--green); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

th {
    background: #EAF2F0;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFDFC; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--green);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
}

.btn-secondary {
    background: transparent;
    color: var(--blue-dark);
    border: 1px solid var(--border);
}

.btn-perigo {
    background: transparent;
    color: var(--alert);
    border: 1px solid var(--alert);
}

.btn-bloco { width: 100%; }

form .campo { margin-bottom: 16px; }

form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

form input, form select, form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    background: #fff;
}

form input[type=number] { font-variant-numeric: tabular-nums; }

.linha { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .linha { grid-template-columns: 1fr; } }

.selecao-usuario {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.selecao-usuario button {
    padding: 16px;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.selecao-usuario button.selecionado {
    border-color: var(--green);
    background: #EAF6F0;
    color: var(--green);
}

.selecao-forma {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 480px) {
    .selecao-forma { grid-template-columns: repeat(2, 1fr); }
}

.selecao-forma button {
    padding: 12px 6px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.selecao-forma button.selecionado {
    border-color: var(--blue);
    background: #E6F0F5;
    color: var(--blue);
}

.valor-input {
    font-size: 32px !important;
    font-weight: 700;
    text-align: center;
    padding: 16px !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.progresso-barra {
    height: 10px;
    border-radius: 6px;
    background: #E4EDEA;
    overflow: hidden;
}

.progresso-barra-fill {
    height: 100%;
    background: var(--green);
    border-radius: 6px;
}

.caixinha-card { display: flex; flex-direction: column; gap: 10px; }
.caixinha-card-topo { display: flex; justify-content: space-between; align-items: baseline; }
.caixinha-card-nome { font-weight: 600; font-size: 15px; }
.caixinha-card-valores { font-size: 13px; color: var(--text-muted); }
.caixinha-concluida { opacity: 0.6; }

.filtros-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filtros-bar select, .filtros-bar input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* NAVEGAÇÃO INFERIOR — mobile, fixa, sempre visível dentro do PWA standalone */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 40;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10.5px;
    padding: 4px 8px;
    border-radius: 8px;
    flex: 1;
    text-align: center;
}

.bottom-nav a.active { color: var(--green); font-weight: 600; }
.bottom-nav a svg, .bottom-nav a i { width: 20px; height: 20px; }

.bottom-nav .nav-fab {
    background: var(--green);
    color: #fff !important;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -18px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.bottom-nav .nav-fab span { display: none; }

@media (min-width: 720px) {
    .bottom-nav { display: none; }
    main { padding-bottom: 48px; }
}

.desktop-nav {
    display: none;
}

@media (min-width: 720px) {
    .desktop-nav {
        display: flex;
        gap: 4px;
    }
    .desktop-nav a {
        color: #C7DAD6;
        text-decoration: none;
        font-size: 13.5px;
        font-weight: 500;
        padding: 8px 12px;
        border-radius: 6px;
    }
    .desktop-nav a.active, .desktop-nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
}

.alerta {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alerta-erro { background: #FBE9E3; color: #A3401E; }
.alerta-sucesso { background: #E1F3E9; color: #1F6B47; }

@media print {
    .bottom-nav, .topbar, .no-print { display: none !important; }
    body { background: #fff; }
    main { padding: 0; max-width: 100%; }
    .card { border: 1px solid #ccc; page-break-inside: avoid; }
}
