/* Ajustes gerais para evitar estouro de largura em telas pequenas */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f3f7f3;
    color: #222;
    margin: 0;
    line-height: 1.5;
}

header {
    background-color: #2f6b45;
    color: white;
    padding: 14px 10px;
    text-align: center;
}

header img {
    width: 55px;
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

header h1 {
    color: white;
    font-size: 1.8rem;
    margin: 8px 0;
}

header p {
    margin: 6px 0 0;
}

/* Base mobile-first: menu em duas colunas para facilitar o toque */
nav {
    background-color: #e4eee7;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

nav a {
    color: #204b31;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    border: 1px solid #b7cbbb;
    padding: 10px 6px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-wrap: anywhere;
}

main {
    width: calc(100% - 20px);
    max-width: 900px;
    margin: 10px auto;
    background-color: white;
    padding: 12px;
    border: 1px solid #ccc;
    overflow-wrap: anywhere;
}

h1, h2, h3 {
    color: #2f6b45;
}

h2 {
    font-size: 1.35rem;
}

.caixa {
    border: 1px solid #bbb;
    padding: 12px;
    margin-bottom: 16px;
    background-color: #fafafa;
}

.aviso {
    background-color: #fff4cc;
    border: 1px solid #d6b84b;
    padding: 12px;
    margin: 15px 0;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 12px;
    border: 1px solid #aaa;
}

legend {
    padding: 0 5px;
    font-weight: bold;
}

label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}

input, select, textarea {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 10px;
    margin-top: 4px;
    border: 1px solid #777;
    background-color: white;
    font: inherit;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input[type="radio"], input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-height: 20px;
    margin: 0;
    flex: 0 0 auto;
}

.opcao {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 6px 0;
}

.opcao label {
    display: inline;
    font-weight: normal;
    margin: 0;
}

button, .botao {
    display: block;
    width: 100%;
    min-height: 44px;
    background-color: #2f6b45;
    color: white;
    padding: 10px 14px;
    border: 1px solid #204b31;
    text-decoration: none;
    text-align: center;
    margin-top: 12px;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
}

/* Tabelas continuam utilizáveis no celular com rolagem horizontal */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th, td {
    border: 1px solid #aaa;
    padding: 8px;
    text-align: left;
    white-space: nowrap;
}

th {
    background-color: #e4eee7;
}

.alta {
    font-weight: bold;
    color: #a40000;
}

.media {
    font-weight: bold;
    color: #8a6500;
}

.baixa {
    font-weight: bold;
    color: #256137;
}

footer {
    text-align: center;
    padding: 15px 10px;
    color: #555;
}

/* Telas muito estreitas: menu em uma coluna */
@media (max-width: 360px) {
    nav {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.55rem;
    }
}

/* Tablet e desktop: volta para um layout mais aberto */
@media (min-width: 700px) {
    header {
        padding: 18px;
    }

    nav {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0;
        padding: 10px;
    }

    nav a {
        border: 0;
        min-height: 0;
        padding: 6px 10px;
    }

    main {
        width: 85%;
        margin: 20px auto;
        padding: 20px;
    }

    .caixa {
        padding: 15px;
        margin-bottom: 18px;
    }

    button, .botao {
        display: inline-block;
        width: auto;
    }

    table {
        display: table;
        overflow-x: visible;
    }

    th, td {
        white-space: normal;
    }
}

/* Somente complementos funcionais; o CSS acima é o original do protótipo. */
[hidden] { display: none !important; }
nav button { margin: 0; padding: 10px 6px; background: transparent; color: #204b31; border: 1px solid #b7cbbb; }
.sessao { text-align: center; font-size: 0.85rem; margin: 8px 10px; }
.field-error { display: block; color: #a40000; font-size: 0.85rem; margin-top: 4px; }
.field-error:empty { display: none; }
[aria-invalid="true"] { border-color: #a40000; }
.feedback.erro { border-color: #a40000; }
.feedback.sucesso { background: #e4eee7; border-color: #2f6b45; }
form > fieldset + fieldset { margin-top: 12px; }
form + .caixa { margin-top: 18px; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.table-action, td small { display: block; }
.history-item { border-top: 1px solid #bbb; padding: 12px 0; }
.history-item p { white-space: pre-wrap; }
.score-card { position: sticky; top: 0; z-index: 2; }
.score-card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.score-card p { margin: 4px 0; font-size: 0.85rem; }
.score-card progress { width: 100%; height: 6px; }
.score-card small { display: block; }
.score-card details { font-size: 0.85rem; }
.score-card dl { display: grid; grid-template-columns: 1fr 1fr; margin: 6px 0; }
.score-card dd { margin: 0; }
header { position: relative; }
.weather-widget { font-size: 0.75rem; padding: 8px; margin: 10px 0 0 auto; max-width: 300px; text-align: left; background: #e4eee7; color: #222; border: 1px solid #b7cbbb; }
.weather-widget p { margin: 3px 0; }
.weather-main { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.weather-main strong { font-size: 1rem; }
.weather-controls { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.weather-controls select { width: auto; flex: 1; }
.weather-controls select, .weather-controls button { min-height: 32px; padding: 3px 6px; margin: 0; font-size: 0.7rem; }
.weather-widget a { color: #204b31; }
@media (min-width: 1000px) {
    header { min-height: 155px; }
    .weather-widget { position: absolute; top: 8px; right: 12px; max-width: 260px; margin: 0; }
}
@media (min-width: 700px) {
    nav button { border: 0; width: auto; padding: 6px 10px; min-height: 0; }
}
