:root {
    --primary: #b71c1c;
    --primary-gradient: linear-gradient(135deg, #b71c1c 0%, #8a0b0b 100%);
    --secondary: #ff5252;
    --bg-color: #f4f7fa;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 10px 30px rgba(0,0,0,0.08);
    --radius: 16px;
    --success-bg: #d4edda;
    --success-text: #155724;
    --error-bg: #f8d7da;
    --error-text: #721c24;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header Moderno (Ajustado para não sobrepor) --- */
header {
    background: var(--primary-gradient);
    color: white;
    /* Aumentei o ultimo valor (bottom) para 80px para dar espaço ao card */
    padding: 40px 24px 80px; 
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    text-align: left;
    position: relative;
    z-index: 1;
}

header h1 { 
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem; 
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

header p { opacity: 0.9; font-size: 0.95rem; font-weight: 400; }

/* --- Containers --- */
.container {
    flex: 1;
    padding: 0 20px 20px;
    max-width: 600px;
    margin: -40px auto 0; /* Puxa o conteúdo um pouco pra cima */
    width: 100%;
    position: relative;
    z-index: 2;
}

/* Container específico para calculadoras */
.calc-container {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    text-align: center;
    /* REMOVIDO o margin-top negativo extra que causava o bug */
    margin-top: 0; 
}

/* --- Menu (Mantido) --- */
#install-btn { display: none; background: #10b981; color: white; border: none; padding: 16px; border-radius: var(--radius); width: 100%; margin-bottom: 20px; font-family: 'Poppins', sans-serif; font-weight: 600; cursor: pointer; box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3); align-items: center; justify-content: center; gap: 10px; transition: transform 0.2s; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
#install-btn:active { transform: scale(0.98); }

.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.menu-item { background: var(--card-bg); border-radius: var(--radius); padding: 24px 16px; text-decoration: none; color: var(--text-main); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); border: 1px solid rgba(255,255,255,0.5); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); text-align: center; height: 140px; position: relative; overflow: hidden; }
.menu-item:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.menu-item:active { transform: scale(0.98); }
.icon-box { width: 50px; height: 50px; background: #fff0f0; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; transition: background 0.3s; }
.menu-item i { color: var(--primary); stroke-width: 2.5px; }
.menu-item span { font-weight: 600; font-size: 0.85rem; line-height: 1.3; color: var(--text-main); }
.menu-item small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }
.menu-item.ava .icon-box { background: #fff3e0; } .menu-item.ava i { color: #f57c00; }
.menu-item.sei .icon-box { background: #e3f2fd; } .menu-item.sei i { color: #1976d2; }
.menu-item.sae .icon-box { background: #f3e5f5; } .menu-item.sae i { color: #9c27b0; }

footer { text-align: center; padding: 30px 20px; font-size: 0.75rem; color: var(--text-muted); margin-top: auto; }
footer a { color: var(--primary); text-decoration: none; }

@media (min-width: 600px) {
    .menu-grid { grid-template-columns: repeat(3, 1fr); }
    header { text-align: center; padding-bottom: 80px; } /* Ajuste Desktop */
    .container { margin-top: -50px; }
}

/* --- Elementos da Calculadora --- */

/* Botão de Ajuda */
.btn-help-link {
    background: none; border: none; color: var(--primary); font-size: 0.85rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 20px; padding: 8px 12px; border-radius: 8px; background-color: #fff0f0; transition: background 0.2s;
}
.btn-help-link:hover { background-color: #ffe0e0; }

.input-group { text-align: left; margin-bottom: 15px; }
.input-group label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text-main); font-size: 0.9rem; }
.input-group input { width: 100%; padding: 14px; border: 1px solid #e5e7eb; border-radius: 10px; font-size: 16px; box-sizing: border-box; background-color: #f9fafb; transition: border-color 0.2s; }
.input-group input:focus { outline: none; border-color: var(--primary); background-color: white; }

.btn-calc, .btn-simular, .btn-back { width: 100%; padding: 14px; border: none; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 10px; font-family: 'Inter', sans-serif; transition: opacity 0.2s; }
.btn-calc { background-color: var(--primary); color: white; }
.btn-simular { background-color: #ffb74d; color: #4e342e; }
.btn-back { background: transparent; color: var(--text-muted); margin-top: 20px; font-size: 0.9rem; }
.btn-calc:active, .btn-simular:active { opacity: 0.8; }

#resultado { margin-top: 20px; padding: 15px; border-radius: 10px; display: none; line-height: 1.5; }
.aprovado { background-color: var(--success-bg); color: var(--success-text); border: 1px solid #c3e6cb; }
.reprovado { background-color: var(--error-bg); color: var(--error-text); border: 1px solid #f5c6cb; }

/* --- MODAL (POPUP) --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px); }
.modal-content { background: white; width: 100%; max-width: 500px; border-radius: 20px; padding: 24px; position: relative; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0,0,0,0.2); animation: slideUp 0.3s ease-out; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-header h3 { font-size: 1.1rem; color: var(--text-main); font-weight: 700; }
.close-modal { background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; line-height: 1; }
.modal-body p { margin-bottom: 8px; font-weight: 600; color: var(--primary); font-size: 0.9rem; margin-top: 12px; }
.tutorial-img { width: 100%; border-radius: 8px; border: 1px solid #eee; margin-bottom: 5px; }


/* Botão de Instalar (PWA) */
#install-btn {
    display: none; /* Começa oculto, o JS torna visível se for instalável */
    background: #10b981; /* Verde */
    color: white;
    border: none;
    padding: 16px;
    border-radius: var(--radius);
    width: 100%;
    margin-bottom: 20px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
    align-items: center; /* Alinha ícone e texto */
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s;
    animation: pulse 2s infinite;
}

/* Animação de pulso suave */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

#install-btn:active { transform: scale(0.98); }