/* Reset & base */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f5f6fa;
    margin: 0;
    color: #232425;
}

.header {
    position: fixed;
    top: 0; left: 0; width: 100vw;
    background: #2166af;
    color: #fff;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.header h1 {
    font-size: 1.13em;
    margin: 0;
    letter-spacing: 0.03em;
    font-weight: 600;
    text-align: center;
}

.card {
    margin: 70px auto 0 auto;
    max-width: 420px;
    width: 96vw;
    background: #fff;
    border-radius: 18px;
    padding: 1.2em 1.2em 1.6em 1.2em;
    box-shadow: 0 5px 20px 0 rgba(33,102,175,0.07);
    min-height: 400px;
    text-align: center;
}

.card h2 {
    margin-top: 0.2em;
    margin-bottom: 0.6em;
    text-align: center;
    font-size: 1.08em;
    font-weight: 500;
    color: #2166af;
}

.quote {
    background: #e7f1fc;
    border-left: 4px solid #2166af;
    padding: 0.8em 1em;
    margin-bottom: 1.1em;
    font-size: 0.98em;
    border-radius: 8px;
}

.instructions {
    display: block;
    text-align: right;
    color: #1a57a7;
    font-size: 0.97em;
    margin-bottom: 0.5em;
    text-decoration: none;
}

.profile {
    background: #f4faff;
    padding: 0.9em 0.7em 0.5em 0.7em;
    border-radius: 10px;
    margin-bottom: 1em;
    min-height: 38px;
    font-size: 1.01em;
    color: #437bbd;
}

.profile .label {
    font-weight: 500;
    margin-right: 4px;
}

.bmi-tag {
    font-size: 0.97em;
    border-radius: 7px;
    padding: 2px 8px;
    margin-left: 7px;
    color: #fff;
    background: #3fa675;
    font-weight: 500;
}
.bmi-obese { background:#d9303e;}
.bmi-over { background:#f09c28;}
.bmi-under { background:#3a8bf6;}
.bmi-norm { background:#3fa675;}
.week-tag {
    margin-left: 12px;
    font-size: 0.99em;
    color: #2166af;
    background: #e3ecf6;
    border-radius: 8px;
    padding: 2px 8px;
    font-weight: 500;
}

/* Progress bar gestazionale */
.progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 1em 0 1.3em 0;
    font-size: 1em;
}
.progress-bar {
    flex: 1;
    background: #e3ecf6;
    border-radius: 18px;
    height: 18px;
    margin: 0 6px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg,#4b92e3,#3fa675);
    width: 0;
    border-radius: 18px;
    transition: width 0.8s;
}

/* Bottoni principali */
.buttons {
    display: flex;
    gap: 10px;
    margin-top: 1.1em;
    justify-content: space-between;
}
.buttons button,
button {
    flex: 1;
    font-size: 1.11em;
    border-radius: 14px;
    padding: 0.8em 0.5em;
    border: none;
    background: #2166af;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 6px rgba(33,102,175,0.06);
}
.buttons button:first-child,
button.indietro {
    background: #e2e6ec;
    color: #215086;
}
.buttons button.stampa {
    background: #1b78e2;
    color: #fff;
}
button:active {
    background: #164775;
}
#openConfig {
    background: #e3ecf6;
    color: #2166af;
    font-size: 1.08em;
    max-width: 56px;
    padding: 0.8em 0.1em;
}

/* Tabelle pesi */
#tabellaPesi {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.99em;
    margin-top: 1.1em;
    margin-bottom: 1.2em;
    background: #f4f8fc;
    border-radius: 11px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(33,102,175,0.04);
}
#tabellaPesi th, #tabellaPesi td {
    text-align: center;
    padding: 0.49em 0.5em;
}
#tabellaPesi th {
    background: #d9e7fa;
    color: #1a407d;
    font-weight: 600;
    font-size: 0.97em;
}
#tabellaPesi td {
    background: #f4f8fc;
    border-bottom: 1px solid #e4eaf3;
    font-size: 1.01em;
}
#tabellaPesi tr:last-child td {
    border-bottom: none;
}
#tabellaPesi td:last-child {
    color: #cc3131;
    cursor: pointer;
    font-size: 1.22em;
    transition: background 0.1s;
}
#tabellaPesi td:last-child:hover {
    background: #fbe7e7;
    border-radius: 4px;
}

/* Modal migliorata e scrollabile anche su mobile */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(32,56,80,0.18);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.2s;
    overflow-y: auto;
}
.modal.hidden { display: none; }
.modal-content {
    background: #fff;
    border-radius: 18px;
    width: 97vw;
    max-width: 360px;
    padding: 1.1em 1em 1.6em 1em;
    box-shadow: 0 8px 30px rgba(33,102,175,0.10);
    margin: 4vh 0 4vh 0;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
}
.modal-content h2 {margin-top:0;}
.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 1.1em;
}
.modal-buttons button {
    flex: 1;
    border-radius: 11px;
    padding: 0.7em;
    border: none;
    font-size: 1em;
    font-weight: 500;
    background: #2166af;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}
.modal-buttons button#closeConfig {
    background: #c7c9d6;
    color: #12315e;
}
.modal-buttons button#resetConfig {
    background: #fff0e4;
    color: #c96b19;
    border: 1px solid #e3bc7e;
}
label, select, input {
    font-size: 1em;
    border-radius: 7px;
    border: 1px solid #cfd7df;
    padding: 0.55em 0.9em;
    margin-top: 0.2em;
    width: 100%;
    box-sizing: border-box;
    background: #f7fafc;
}
fieldset { border: none; margin: 0; padding: 0;}
.tooltip {
    cursor: help;
    font-size: 1.07em;
    margin-left: 4px;
    color: #4271b4;
    border-bottom: 1px dotted #4271b4;
    position: relative;
}
.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 30px; top: 5px;
    background: #2357a8;
    color: #fff;
    padding: 6px 9px;
    border-radius: 8px;
    font-size: 0.98em;
    white-space: pre-line;
    box-shadow: 0 2px 8px rgba(33,102,175,0.12);
    z-index: 2002;
    width: max-content;
    max-width: 240px;
}

/* Responsive */
@media (max-width: 600px) {
    .header { height: 46px;}
    .header h1 { font-size: 1em;}
    .card { margin-top: 54px; width: 99vw;}
    .modal-content {max-width:99vw;}
    .buttons button {font-size: 1.03em;}
    .modal-content {
        padding: 0.7em 0.4em 1em 0.4em;
        margin: 2vh 0 2vh 0;
        max-height: 99vh;
    }
}

@media (min-width: 1024px) {
    .card { max-width: 600px; }
}

.footer-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: #2166af;
    text-decoration: underline;
    font-size: 1em;
    font-style: italic;
}
