:root {
    --gold: #d4af37;
    --dark-bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --accent: #3b82f6;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--dark-bg);
    color: var(--text);
    margin: 0;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
nav {
    width: 250px;
    background: #020617;
    padding: 20px;
    border-right: 1px solid #334155;
    position: fixed;
    height: 100vh;
    box-sizing: border-box;
}

nav h2 {
    color: var(--gold);
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 30px;
}

nav a {
    display: block;
    color: var(--text);
    text-decoration: none;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    transition: 0.3s;
    cursor: pointer;
}

nav a:hover {
    background: var(--gold);
    color: black;
}

/* Main Content */
main {
    margin-left: 250px;
    padding: 30px;
    width: calc(100% - 250px);
    box-sizing: border-box;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    border-top: 4px solid var(--gold);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Grid System */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

/* Forms */
label {
    display: block;
    margin-top: 15px;
    font-size: 0.85rem;
    color: #94a3b8;
}

input, select {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    border-radius: 8px;
    box-sizing: border-box;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-gold {
    background: var(--gold);
    color: black;
}

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 12px;
    color: #94a3b8;
    border-bottom: 1px solid #334155;
    text-align: left;
}

td {
    padding: 12px;
    border-bottom: 1px solid #1e293b;
}

/* Utils */
.hidden {
    display: none !important;
}

#login-overlay {
    position: fixed;
    inset: 0;
    background: var(--dark-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* =========================================
   📱 RESPONSIVE DESIGN (MOBILE & PWA LWSi) - V3 ULTRA SLIM
   ========================================= */

@media screen and (max-width: 768px) {
    
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    /* PIÙ ARIA IN FONDO (Aumentato padding-bottom a 100px) */
    main {
        margin-left: 0 !important;
        padding: 15px !important;
        padding-bottom: 100px !important; 
        width: 100% !important;
    }

    /* BARRA MENU ULTRA-SLIM E ALLINEATA */
    #nav-bar:not(.hidden) {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        height: auto;
        display: flex !important;
        flex-direction: row;
        align-items: center; /* Centra tutto perfettamente */
        overflow-x: auto; 
        padding: 0; /* Rimosso padding extra */
        background: #0f172a;
        border-top: 1px solid #334155;
        z-index: 9999;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.5);
    }
    
    #nav-bar h2 { display: none; }
    
    #nav-bar a:not(.hidden) {
        flex: 0 0 auto;
        display: inline-flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 5px 10px;
        font-size: 0.6rem; 
        min-width: 70px;
        height: 55px; /* ALTEZZA FISSA SNELLA */
        margin: 0 !important; /* AZZERA TUTTI I MARGINI */
        box-sizing: border-box;
    }
    
    #nav-bar a i { 
        margin-bottom: 3px; 
        font-size: 1.1rem; 
    }

    /* FIX ALLINEAMENTO LOGOUT */
    #logoutBtn { 
        border-left: 1px solid #334155; 
        margin: 0 !important; /* Forza la sovrascrittura dei 50px dell'HTML */
    }

    /* RESTO DEL LAYOUT RESPONSIVE */
    .grid, [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .card { width: 100% !important; padding: 15px !important; box-sizing: border-box !important; }
    [style*="width: 380px"], [style*="width: 500px"], [style*="width: 350px"], [style*="width: 420px"] { width: 95% !important; max-width: 95vw !important; }
    table { display: block; overflow-x: auto; white-space: nowrap; width: 100%; }
    .header-bar { flex-direction: column; gap: 15px; align-items: stretch !important; }
    input, select, textarea { width: 100% !important; box-sizing: border-box !important; }

    .card div[style*="display: flex"], .card div[style*="display:flex"] {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    .card div[style*="display:flex"] > button, .card div[style*="display: flex"] > button { 
        width: 100% !important; 
        margin: 0 !important;
    }
}

.login-footer {
    margin-top: 35px;
    padding-top: 20px;
    border-top: 1px solid #1f2937;
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.5;
}
