* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7fa;
    color: #1e293b;
}
.hub-topbar {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    color: white;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.hub-topbar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
}
.hub-topbar .user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}
.hub-topbar .user-menu a {
    color: white;
    text-decoration: none;
    opacity: 0.85;
}
.hub-topbar .user-menu a:hover { opacity: 1; }
.hub-container {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 24px;
}
.hub-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}
.hub-card h2 {
    margin: 0 0 18px;
    font-size: 18px;
    color: #1e3a5f;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-primary { background: #2c5282; color: white; }
.btn-primary:hover { background: #1e3a5f; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.input, select.input, textarea.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    background: white;
}
.input:focus { outline: 2px solid #2c5282; outline-offset: -1px; border-color: #2c5282; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #475569; }
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* Auth layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    padding: 20px;
}
.auth-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.auth-card h1 { margin: 0 0 8px; color: #1e3a5f; }
.auth-card .subtitle { color: #64748b; margin: 0 0 24px; font-size: 14px; }

/* Dashboard tile */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.tile {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: #1e293b;
    border: 2px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.tile-icon { font-size: 36px; }
.tile-image {
    /* Riempie la larghezza della tile e mantiene un quadrato; l'immagine
       viene scalata senza essere ritagliata (contain). Se l'immagine è
       più piccola dell'area, resta centrata e non viene mai ingrandita
       oltre la sua dimensione naturale grazie a max-width sull'area. */
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 160px;
    object-fit: contain;
    display: block;
}
.tile-name { font-weight: 700; font-size: 16px; }
.tile-level {
    font-size: 11px;
    text-transform: uppercase;
    padding: 2px 10px;
    border-radius: 12px;
    background: #e2e8f0;
    color: #475569;
}
.tile-level.admin { background: #fef3c7; color: #92400e; }
.tile-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Admin matrix table */
.matrix-table { width: 100%; border-collapse: collapse; }
.matrix-table th, .matrix-table td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.matrix-table th { background: #f8fafc; font-weight: 600; font-size: 13px; color: #475569; }
.matrix-table select { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
