* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #25313c;
}

header {
    background: #1f4e78;
    color: white;
    padding: 18px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

header h1 {
    margin: 0;
    font-size: 24px;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
}

main {
    padding-top: 30px;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 30px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card h3 {
    margin-top: 0;
    color: #6c757d;
    font-size: 16px;
}

.importo {
    font-size: 30px;
    font-weight: bold;
    color: #1f4e78;
}

.verde {
    color: #198754;
}

.rosso {
    color: #dc3545;
}

@media (max-width: 700px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
}

.anno-selector {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.anno-selector form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.anno-selector select {
    padding: 8px 35px 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 16px;
    cursor: pointer;
}

.rate-table {
    margin-top: 25px;
}

/* ===== NAVIGAZIONE PRINCIPALE ===== */

.navigation-bar {
    background: #ffffff;
    border-bottom: 1px solid #dfe3e7;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.navigation {
    display: flex;
    gap: 10px;
    padding-top: 14px;
    padding-bottom: 14px;
    flex-wrap: wrap;
}

.nav-button {
    display: inline-block;
    padding: 10px 18px;
    background: #eef2f5;
    color: #34495e;
    text-decoration: none;
    border-radius: 7px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.nav-button:hover {
    background: #dce6ee;
}

.nav-button.active {
    background: #1f4e78;
    color: white;
}

.nav-button.disabled {
    color: #9aa3aa;
    cursor: default;
    background: #f5f6f7;
}

@media (max-width: 700px) {

    .navigation {
        gap: 7px;
    }

    .nav-button {
        padding: 9px 12px;
        font-size: 14px;
    }
}

/* ===== FORM ===== */

.form-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 7px;
    color: #34495e;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: inherit;
    font-size: 15px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1f4e78;
    box-shadow: 0 0 0 2px rgba(31, 78, 120, 0.12);
}

.checkbox-group {
    margin-top: 10px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.form-button {
    border: none;
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
}

.alert-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
    padding: 12px 15px;
    border-radius: 7px;
    margin-bottom: 20px;
}

@media (max-width: 700px) {

    .form-grid {
        grid-template-columns: 1fr;
    }

}

.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-family: inherit;
    font-size: 15px;
}

.form-group select:focus {
    outline: none;
    border-color: #1f4e78;
    box-shadow: 0 0 0 2px rgba(31, 78, 120, 0.12);
}

/* ===== TABELLA RATE ===== */

.rate-table {
    margin-top: 25px;
    width: 100%;
    overflow-x: auto;
}

.rate-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.rate-table thead {
    background: #eef2f5;
}

.rate-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 14px;
    color: #34495e;
    border-bottom: 2px solid #dce3e8;
    white-space: nowrap;
}

.rate-table td {
    padding: 15px 16px;
    border-bottom: 1px solid #e7ebee;
    vertical-align: middle;
}

.rate-table tbody tr:hover {
    background: #f8fafb;
}

.rate-table tbody tr:last-child td {
    border-bottom: none;
}

.rate-table th:nth-child(3),
.rate-table td:nth-child(3) {
    text-align: right;
}

.rate-table .badge {
    white-space: nowrap;
}

/* ===== AZIONI TABELLA ===== */

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.delete-form {
    display: inline;
    margin: 0;
}

.action-button {
    display: inline-block;
    padding: 7px 11px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.edit-button {
    background: #1f4e78;
    color: white;
}

.edit-button:hover {
    background: #163a5c;
}

.delete-button {
    background: #dc3545;
    color: white;
}

.delete-button:hover {
    background: #b02a37;
}

/* ===== SELETTORE GESTIONE ===== */

.gestione-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    background: white;
    padding: 12px 15px;
    border-radius: 10px;

    margin-bottom: 20px;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gestione-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gestione-form select {
    padding: 8px 35px 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;

    background: white;

    font-family: inherit;
    font-size: 15px;

    cursor: pointer;
}

.form-help {
    margin-top: 7px;
    margin-bottom: 0;

    color: #6c757d;
    font-size: 13px;
}


@media (max-width: 700px) {

    .gestione-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

}

/* Spazio tra intestazione/pulsante e selettore gestione */
.page-header {
    margin-bottom: 18px;
}

/* ===== RIEPILOGO GESTIONE ===== */

.riepilogo-section {
    margin*top: 40px;
    margin-bottom: 40px*
}

.riepilogo-title {
    background: #eef2f5;
    color: #1f4e78;
    padding: 12px 15px;
    border-radius: 7px;
    margin-bottom: 22px;
}

.riepilogo-dashboard {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
    .riepilogo-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .riepilogo-dashboard {
        grid-template-columns: 1fr;
    }
}

/* ===== DASHBOARD DINAMICA ===== */

.dashboard-secondaria {
    margin-top: 20px;
}

.dashboard-section {
    margin-top: 40px;
    margin-bottom: 40px;
}

.card-link {
    margin-top: 15px;
}

.card-link a {
    color: #1f4e78;
    font-weight: 600;
    text-decoration: none;
}

.card-link a:hover {
    text-decoration: underline;
}

/* ===== LOGIN ===== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f4f6f8;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #ffffff;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 5px;
}

.login-header h1 {
    margin: 8px 0;
    color: #1f4e78;
    font-size: 26px;
}

.login-header p {
    margin: 0;
    color: #6c757d;
}

.login-button {
    width: 100%;
    padding: 12px 18px;
    margin-top: 5px;
}

/* ===== CORREZIONE CAMPO PASSWORD LOGIN ===== */

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #ffffff;
    color: #25313c;
    font-family: inherit;
    font-size: 15px;
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    outline: none;
    border-color: #1f4e78;
    box-shadow: 0 0 0 2px rgba(31, 78, 120, 0.12);
}

/* ===== UTENTE / LOGOUT ===== */

.navigation {
    align-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    white-space: nowrap;
}

.user-name {
    color: #34495e;
    font-weight: 600;
}

.user-separator {
    color: #adb5bd;
}

.logout-form {
    margin: 0;
    padding: 0;
}

.logout-button {
    border: none;
    background: transparent;
    padding: 0;
    color: #dc3545;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.logout-button:hover {
    color: #b02a37;
    text-decoration: underline;
}

@media (max-width: 700px) {

    .user-menu {
        width: 100%;
        margin-left: 0;
        padding-top: 8px;
        border-top: 1px solid #e5e7e9;
    }

}