:root{--blue:#0878c9;--red:#dc2626;--green:#16a34a;--orange:#f59e0b;--bg:#f4f7fb;--text:#172033;--muted:#64748b;--border:#e5e7eb}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:var(--text)}
img{max-width:100%;height:auto}
a{text-decoration:none;color:inherit}

.app{display:flex;min-height:100vh}
.sidebar{width:280px;background:#0f172a;color:white;position:fixed;top:0;bottom:0;left:0;padding:22px;overflow-y:auto;z-index:10}

.brand{display:flex;gap:12px;align-items:center;margin-bottom:28px}
.brand-logo{width:56px!important;height:56px!important;min-width:56px!important;max-width:56px!important;max-height:56px!important;border-radius:50%;background:white;object-fit:contain;display:block}
.brand strong{display:block;font-size:18px}
.brand span{display:block;color:#cbd5e1;font-size:12px}

nav a{display:block;padding:13px 14px;border-radius:14px;margin-bottom:8px;color:#e0f2fe}
nav a:hover{background:#1e293b}

.main{margin-left:280px;width:calc(100% - 280px);padding:24px}
.topbar{background:linear-gradient(135deg,#0878c9,#16a34a);color:white;border-radius:24px;padding:24px;margin-bottom:22px;box-shadow:0 16px 40px rgba(37,99,235,.20)}
.topbar h1{margin:0;font-size:28px}
.topbar p{margin:6px 0 0;color:#e0f2fe}

.cards{display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:22px}
.card{background:white;border:1px solid var(--border);border-radius:22px;padding:20px;box-shadow:0 12px 28px rgba(15,23,42,.06);border-top:4px solid var(--blue)}
.card span{display:block;color:var(--muted);font-size:14px}
.card strong{font-size:34px;margin-top:8px;display:block}
.card.danger{border-top-color:var(--red)}
.card.info{border-top-color:var(--green)}

.panel{background:white;border:1px solid var(--border);border-radius:24px;padding:22px;margin-bottom:22px;box-shadow:0 12px 28px rgba(15,23,42,.05)}
.panel.narrow{max-width:1000px}
.panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}

.table-wrap{overflow:auto}
table{width:100%;border-collapse:collapse}
th,td{padding:13px 10px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}
th{color:var(--muted);font-size:12px;text-transform:uppercase}

.btn,button{display:inline-block;background:var(--blue);color:white;border:0;border-radius:14px;padding:11px 16px;cursor:pointer;font-weight:bold;margin:2px}
.btn.small{padding:8px 11px;font-size:12px}
.btn.ghost{background:#e0ecff;color:#1d4ed8}
.btn.green{background:var(--green)}
.btn.red{background:var(--red)}
.btn.orange{background:var(--orange)}

.pill{display:inline-block;background:#eef2ff;color:#1e40af;padding:10px 14px;border-radius:999px;margin-left:10px;font-weight:bold}
.muted{color:var(--muted)}

.inline-form{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.inline-form input{flex:1;min-width:180px}

input,select,textarea{width:100%;border:1px solid var(--border);border-radius:14px;padding:12px 13px;background:white}
.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.form-grid textarea,.form-grid .full{grid-column:1/-1}
.form-grid label{font-weight:bold;margin-top:5px}
.form-grid button,.form-grid a{width:max-content}

.checkbox-line label{display:flex;gap:10px;align-items:center}
.checkbox-line input{width:auto}
.art39-box{display:none;background:#f8fafc;border:1px solid var(--border);border-radius:18px;padding:16px}

.thumb{width:54px;height:64px;object-fit:cover;border-radius:8px;border:1px solid var(--border)}
.preview-foto{width:160px;height:190px;object-fit:cover;border-radius:12px;border:1px solid var(--border)}

.badge{display:inline-block;padding:6px 10px;border-radius:999px;background:#eef2ff;color:#1e40af;font-size:12px;font-weight:bold}

.login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#0f172a,#0878c9);padding:20px}
.login-card{width:420px;max-width:calc(100% - 30px);background:white;border-radius:28px;padding:30px;box-shadow:0 30px 80px rgba(0,0,0,.25);text-align:center}
.login-logo{width:110px!important;height:110px!important;max-width:110px!important;max-height:110px!important;object-fit:contain;margin:0 auto 12px auto;display:block;border-radius:50%}
.login-card form{text-align:left;display:grid;gap:10px}
.alert{background:#fee2e2;color:#991b1b;padding:12px;border-radius:14px}

.news-item{background:#f8fafc;border:1px solid var(--border);border-radius:16px;padding:14px;margin-bottom:12px}
.news-item strong{font-size:18px}
.news-item small{color:var(--muted)}

/* ===== MENU CON SOTTOMENU FUNZIONANTE ===== */
.sidebar nav .submenu{
    margin-bottom:8px;
}

.sidebar nav .submenu-btn{
    display:block;
    width:100%;
    background:transparent;
    border:0;
    color:#e0f2fe;
    text-align:left;
    padding:13px 14px;
    border-radius:14px;
    cursor:pointer;
    font-weight:bold;
    font-size:14px;
    font-family:Arial,Helvetica,sans-serif;
    margin:0 0 8px 0;
}

.sidebar nav .submenu-btn:hover{
    background:#1e293b;
}

.sidebar nav .submenu-content{
    display:none;
    padding-left:10px;
    margin-top:-4px;
    margin-bottom:8px;
}

.sidebar nav .submenu:hover .submenu-content{
    display:block;
}

.sidebar nav .submenu-content a{
    display:block;
    padding:10px 12px;
    border-radius:12px;
    margin-bottom:4px;
    font-size:13px;
    color:#cbd5e1;
}

.sidebar nav .submenu-content a:hover{
    background:#1e293b;
    color:#fff;
}

/* MOBILE */
@media(max-width:1000px){
    .sidebar{position:relative;width:100%;bottom:auto}
    .app{display:block}
    .main{margin-left:0;width:100%}
    .cards{grid-template-columns:repeat(2,1fr)}
    .form-grid{grid-template-columns:1fr}
}

@media(max-width:650px){
    .main{padding:14px}
    .cards{grid-template-columns:1fr}
    .panel-head{display:block}
}
