/* Base Styles */
:root {
    --navy-blue: #0b1f3c; /* Darker navy for a modern premium feel */
    --navy-light: #16365f;
    --gold: #d4af37;
    --gold-hover: #b48e24;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-menu: #cbd5e1;
    --bg-main: #f1f5f9;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: #333;
    overflow: hidden; /* App feels like a desktop app */
}

/* ========================================= */
/* LOGIN OVERLAY                             */
/* ========================================= */
.auth-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--navy-blue) 0%, #000000 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 400px;
    text-align: center;
    color: var(--white);
    animation: fadeIn 0.8s ease-out;
}

.auth-header .auth-logo {
    width: 100px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.3));
}

.auth-header h2 {
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 5px;
    font-size: 1.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 14px 14px 14px 45px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    background: var(--gold-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(212, 175, 55, 0.3);
}

.error-msg {
    margin-top: 15px;
    color: #ef4444;
    font-size: 0.85rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ========================================= */
/* MAIN DASHBOARD LAYOUT                     */
/* ========================================= */
.layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background-color: var(--navy-blue);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header img {
    height: 40px;
}

.brand {
    color: var(--gold);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 1px;
}

.user-info {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.avatar {
    width: 40px;
    height: 40px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.details {
    display: flex;
    flex-direction: column;
}

.badge {
    font-size: 11px;
    background: var(--gold);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    width: fit-content;
    margin-bottom: 4px;
}

#user-email {
    color: var(--text-primary);
    font-size: 0.85rem;
    opacity: 0.9;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    padding: 15px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-menu);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    margin: 4px 12px;
    border-radius: 8px;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: var(--navy-light);
    color: var(--gold);
    font-weight: 500;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.btn-logout {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-menu);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    overflow: hidden;
}

.topbar {
    height: 70px;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 10;
}

.page-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--navy-blue);
}

.topbar-actions .notifications {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--navy-blue);
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}

.topbar-actions .notifications:hover {
    background: #e2e8f0;
}

.notifications .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid white;
}

.notifications-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0,0,0,0.05);
    z-index: 1000;
    overflow: hidden;
}

.dropdown-header {
    padding: 15px;
    background: var(--navy-blue);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.notifications-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    transition: 0.2s;
    cursor: pointer;
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item .notif-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--navy-blue);
    margin-bottom: 4px;
}

.notification-item .notif-desc {
    font-size: 0.8rem;
    color: #64748b;
}

.notification-item .notif-date {
    font-size: 0.75rem;
    color: #ef4444;
    font-weight: 600;
    margin-top: 5px;
}

.no-notifications {
    padding: 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* SEARCH RESULTS REFINEMENT */
.results-container {
    margin-bottom: 120px; /* Aumentato per staccare dal fondo */
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

#view-ricerca {
    padding-bottom: 200px; /* Spazio extra per scroll */
}

.views-container {
    flex: 1;
    position: relative;
    overflow: auto;
}

.view {
    padding: 30px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.page-signature {
    text-align: center;
    margin-top: auto;
    padding-top: 60px;
    padding-bottom: 20px;
    color: #94a3b8;
    font-size: 0.75rem;
    border-top: 1px solid #f1f5f9;
}

.app-iframe {
+    width: 100%;
+    height: 100%;
+    border: none;
+    display: block;
+    background: #fff;
+}

#view-genera-verbale.active-view {
    display: flex !important;
    flex-direction: column;
    height: calc(100vh - 70px); /* Adjust based on header height */
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

@media (max-width: 1024px) {
    #view-genera-verbale.active-view {
        height: 100%;
        position: fixed;
        top: 70px; /* Header height */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        background: white;
    }
}

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(11, 31, 60, 0.1);
    color: var(--navy-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
}

.card-icon.warning {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold-hover);
}

.card-icon.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.card-data h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 5px;
}

.big-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--navy-blue);
}

/* Table & Filter Styles */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.search-box {
    position: relative;
    width: 350px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 14px;
}

.filters-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.filters-bar select, .filters-bar input[type="date"] {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 13px;
    color: #444;
}

.filters-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters-group span {
    font-size: 13px;
    font-weight: 500;
    color: var(--navy-light);
}

.table-container {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

thead {
    background: var(--bg-main);
    border-bottom: 2px solid var(--border);
}

th {
    padding: 15px 20px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--navy-light);
    text-transform: uppercase;
}

td {
    padding: 15px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #f8fafc;
}

.badge.secondary { background: #e2e8f0; color: #475569; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.success { background: #dcfce7; color: #166534; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--navy-light);
    font-size: 1.1rem;
    transition: 0.2s;
    margin-right: 10px;
}

.btn-icon:hover {
    color: var(--gold-hover);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 300px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 2000;
    overflow: hidden;
    animation: slideInRight 0.5s ease-out;
}

.toast-header {
    padding: 10px 15px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toast-body {
    padding: 15px;
    font-size: 14px;
}

.toast.success { border-left: 4px solid #22c55e; }
.toast.error { border-left: 4px solid #ef4444; }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1500;
}

.modal-content {
    background: var(--white);
    width: 90%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.modal-header {
    padding: 20px 25px;
    background: var(--navy-blue);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 { font-size: 1.25rem; font-weight: 600; }

.close-modal {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.close-modal:hover { opacity: 1; }

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
}

.section h4 {
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 15px;
    color: var(--navy-light);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.sanction-flow-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

/* ========================================= */
/* PREMIUM PROCEDURE MANAGEMENT SYSTEM      */
/* ========================================= */
.modal-content {
    max-width: 1100px;
    width: 95%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    background: #fff;
    font-family: 'Inter', sans-serif;
}

.modal-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #f8fafc;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
}

.modal-header h2 span {
    color: var(--gold);
    opacity: 0.9;
}

.close-modal {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.close-modal:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

.modal-body {
    padding: 0;
    background: #f1f5f9;
}

.modal-layout {
    display: flex;
    height: 75vh;
}

/* Sidebar: Professional Timeline */
.procedure-sidebar {
    width: 280px;
    background: #1e293b;
    padding: 30px 20px;
    color: #94a3b8;
    border-right: 1px solid #334155;
    position: relative;
    overflow-y: auto;
}

.procedure-sidebar h3 {
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 30px;
    opacity: 0.7;
}

.timeline {
    position: relative;
    padding-left: 25px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: #334155;
}

.timeline-item {
    position: relative;
    margin-bottom: 35px;
    transition: all 0.3s ease;
}

.timeline-marker {
    position: absolute;
    left: -25px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #475569;
    border: 2px solid #1e293b;
    z-index: 2;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-item.completed .timeline-marker {
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.timeline-item.active .timeline-marker {
    background: #3b82f6;
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2);
    transform: scale(1.2);
}

.timeline-content h4 {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-item.completed .timeline-content h4 {
    color: #94a3b8;
}

.timeline-content p {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
}

.deadline-alert {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.deadline-alert.warning { background: #fef3c7; color: #92400e; }
.deadline-alert.danger { background: #fee2e2; color: #991b1b; }

/* Main Content Area */
.procedure-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}

.section-tabs {
    padding: 15px 30px 0;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 20px;
}

.tab-btn {
    padding: 12px 5px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #64748b;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #1e293b;
}

.tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.tab-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.tab-content .section {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    margin-bottom: 25px;
}

.tab-content .section h4 {
    margin-top: 0;
    font-family: 'Montserrat', sans-serif;
    color: #1e293b;
    font-size: 0.95rem;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: none;
    padding-bottom: 0;
}

.tab-content .section h4 i {
    color: #3b82f6;
    font-size: 1rem;
}

/* Forms Modernization */
.form-group label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: block;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    transition: all 0.2s ease;
    background: #fdfdfd;
}

.form-group input:focus, 
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: #fff;
}

/* Modal Footer */
.modal-footer {
    padding: 20px 30px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.save-actions {
    display: flex;
    gap: 12px;
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.generation-actions .btn-secondary {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 10px 18px;
    font-size: 0.85rem;
}

.generation-actions .btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Status Badges */
.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-notificato { background: #dbeafe; color: #1e40af; }
.status-pagato { background: #d1fae5; color: #065f46; }
.status-bozza { background: #f1f5f9; color: #475569; }
.status-ingiunto { background: #fef3c7; color: #92400e; }
.status-archiviato { background: #f3f4f6; color: #374151; }
.status-in_ruolo { background: #fae8ff; color: #86198f; }

/* Responsive tweaks */
@media (max-width: 900px) {
    .modal-layout { flex-direction: column; height: 90vh; }
    .procedure-sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #334155; }
}

/* ========================================= */
/* RECIDIVISM & SEARCH VIEW REDESIGN         */
/* ========================================= */
.search-hero {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

.search-card {
    background: #fff;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 700px;
    text-align: center;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 5px 10px;
    transition: all 0.3s ease;
}

.search-input-wrapper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: #fff;
}

.search-input-wrapper i {
    color: #64748b;
    margin: 0 15px;
    font-size: 1.2rem;
}

.search-card {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    border: 1px solid #edf2f7;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 5px;
    transition: all 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: #3182ce;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 15px;
    font-size: 1rem;
    color: #1e293b;
    outline: none;
}

.search-hint {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Offender Summary Grid */
.offender-summary-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    margin-bottom: 30px;
    align-items: stretch;
}

.offender-profile-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #edf2f7;
    display: flex;
    flex-direction: column;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    position: relative;
}

.profile-avatar {
    width: 50px;
    height: 50px;
    background: #ebf4ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3182ce;
    font-size: 1.3rem;
}

.profile-info {
    flex: 1;
}

.profile-info h3 {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    color: #2d3748;
    font-size: 1.15rem;
    font-weight: 700;
}

.cf-badge {
    display: inline-block;
    background: #ebf4ff;
    color: #3182ce;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid #bee3f8;
}

.profile-badges {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.profile-details-extra {
    margin: 15px 0;
    display: grid;
    gap: 8px;
    background: #f8fafc;
    padding: 15px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #4a5568;
    border: 1px solid #edf2f7;
}

.search-summary-header { border: 1px solid #e2e8f0; }
.search-summary-header h3 { font-family: 'Montserrat', sans-serif; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }

.person-section {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.person-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.08) !important;
}

.detail-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-line i {
    width: 20px;
    color: #3182ce;
}

.recidiva-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff5f5;
    color: #c53030;
    padding: 2px 10px;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    border-top: 1px solid #f7fafc;
    padding-top: 15px;
}

.stat-item { text-align: center; }
.stat-label { display: block; font-size: 0.6rem; color: #718096; text-transform: uppercase; margin-bottom: 4px; }
.stat-value { display: block; font-weight: 700; color: #2d3748; font-size: 0.85rem; }

/* Charts Layout */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.offender-chart-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #edf2f7;
    display: flex;
    flex-direction: column;
}

.offender-chart-card.mini { height: 220px; }
.offender-chart-card h4 { margin: 0 0 15px 0; font-family: 'Montserrat', sans-serif; font-size: 0.8rem; color: #4a5568; text-transform: uppercase; }
.chart-container { flex: 1; position: relative; min-height: 0; }

/* Expandable Table Row */
.expandable-tr { cursor: pointer; transition: background 0.2s; }
.expandable-tr:hover { background: #f7fafc !important; }
.expandable-tr.active { background: #ebf8ff !important; }

.chevron-btn {
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #a0aec0; transition: transform 0.3s;
}

.expandable-tr.active .chevron-btn { transform: rotate(180deg); color: #3182ce; }

.description-row { background: #f8fafc; display: none; }
.description-row.active { display: table-row; }

.narrative-box {
    background: #fff;
    border-left: 4px solid #3182ce;
    padding: 20px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    font-size: 0.9rem;
    line-height: 1.6;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.narrative-title {
    font-weight: 800; color: #3182ce;
    margin-bottom: 10px; display: block;
    text-transform: uppercase; font-size: 0.7rem; letter-spacing: 1px;
}

.section-title h3 { font-family: 'Montserrat', sans-serif; font-size: 1rem; color: #1e293b; margin-bottom: 20px; }

@media (max-width: 1200px) {
    .offender-summary-grid { grid-template-columns: 1fr; }
    .charts-row { grid-template-columns: 1fr; }
    .offender-chart-card.mini { height: 250px; }
}

/* Roles and Badges 6-level Hierarchy */
.role-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.badge-dev { background: #1e293b; color: #f8fafc; border: 1px solid #334155; }
.badge-gold { background: linear-gradient(135deg, #fbbf24, #d97706); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.badge-blue { background: #2563eb; color: #fff; }
.badge-indigo { background: #4f46e5; color: #fff; }
.badge-cyan { background: #0891b2; color: #fff; }
.badge-teal { background: #0d9488; color: #fff; }
.badge-gray { background: #64748b; color: #fff; }

/* Admin Hierarchy Tree Visualization */
.hierarchy-node {
    margin-left: 20px;
    padding: 8px 12px;
    border-left: 1.5px dashed #cbd5e1;
    position: relative;
    transition: all 0.2s ease;
}

.hierarchy-node::before {
    content: '';
    position: absolute;
    left: 0; top: 20px;
    width: 15px; border-top: 1.5px dashed #cbd5e1;
}

.hierarchy-node:hover {
    background: rgba(255,255,255,0.5);
    border-radius: 6px;
}

.cmd-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 5px;
}

/* Hierarchical Tree Styles */
.hierarchy-tree {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 10px;
    background: transparent;
}

.hierarchy-node {
    position: relative;
    margin-bottom: 2px;
}

.hierarchy-node.level-0 {
    margin-bottom: 20px;
    padding: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border-top: 4px solid var(--primary-color);
}

.hierarchy-node.level-0 > .cmd-item {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 15px;
}

.hierarchy-node.level-0 > .cmd-item .cmd-name {
    font-weight: 800;
    color: var(--primary-color);
    text-transform: uppercase;
    font-size: 0.95rem;
}

.hierarchy-node.level-0 > .node-children {
    padding: 10px;
}

/* Archive Grouping Row */
.comando-group-header {
    background: #f8fafc !important;
}

.comando-group-header td {
    padding: 15px 20px !important;
    border-top: 25px solid white !important; /* Space between groups */
    border-bottom: 2px solid var(--primary-color) !important;
}

.comando-group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    color: #1e293b;
    font-size: 1rem;
    text-transform: uppercase;
}

.comando-group-badge {
    background: var(--primary-color);
    color: white;
    padding: 3px 10px;
    font-size: 0.75rem;
    border-radius: 20px;
}

.hierarchy-node.level-0 > .cmd-item {
    background: #1e3a8a;
    color: white;
    padding: 8px 15px;
}

.hierarchy-node.level-0 > .cmd-item .cmd-name {
    color: white;
    font-size: 1rem;
}

.hierarchy-node.level-0 > .cmd-item .cmd-type-badge {
    background: rgba(255,255,255,0.2);
    color: white;
}

.hierarchy-node.level-0 > .cmd-item .btn-icon-sm {
    color: rgba(255,255,255,0.8);
}

.node-children {
    margin-left: 24px;
    border-left: 1px dashed #cbd5e1;
    padding-left: 12px;
    margin-top: 2px;
}

.cmd-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
    min-height: 32px;
}

.cmd-item:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(11, 31, 60, 0.08);
}

.hierarchy-node:not(.level-0)::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 16px;
    width: 12px;
    border-top: 1px dashed #cbd5e1;
}

.cmd-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.cmd-details {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cmd-name { 
    font-weight: 600; 
    color: #1e293b; 
    font-size: 0.85rem; 
}

.cmd-type-badge { 
    font-size: 0.6rem; 
    color: #475569; 
    background: #e2e8f0;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase; 
    letter-spacing: 0.01em;
    font-weight: 700; 
}

.cmd-actions {
    display: flex;
    gap: 4px;
}

.btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 4px;
    border-radius: 4px;
    color: #64748b;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

/* Admin Table (Excel Style) */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.85rem;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.admin-table thead {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.admin-table th {
    padding: 12px 15px;
    text-align: left;
    color: #475569;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.75rem;
}

.admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #1e293b;
}

.admin-table tr:hover {
    background-color: #f8fafc;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.font-bold {
    font-weight: 700;
    color: var(--navy-blue);
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: #94a3b8;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px dashed #e2e8f0;
    font-style: italic;
}

.btn-icon-sm.text-primary:hover { color: #2563eb; background: #eff6ff; }
.btn-icon-sm.text-info:hover { color: #0891b2; background: #ecfeff; }
.btn-icon-sm.text-success:hover { color: #16a34a; background: #f0fdf4; }
.btn-icon-sm.text-danger:hover { color: #dc2626; background: #fef2f2; }

.btn-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    font-size: 0.7rem;
    width: 20px;
}

.btn-toggle:hover {
    color: var(--primary-color);
}

.no-toggle {
    width: 20px;
    display: inline-block;
}

/* Admin Visibility Filter Dropdown (Archive View) */
#admin-visibility-filter select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 30px;
}

#admin-visibility-filter:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}
/* Hierarchical Management styles */
.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-info i {
    font-size: 1.1rem;
    color: #3b82f6;
}

.btn-view:hover {
    background: #f1f5f9;
    color: #1e293b !important;
    transform: translateY(-2px);
}

.comando-group-header {
    transition: background 0.2s ease;
}

.comando-group-header:hover {
    background: #e0f2fe !important;
}

/* Tooltip for disabled actions */
[disabled][title] {
    cursor: help !important;
}

/* Expandable Article in Recidiva Results */
.art-expander {
    display: inline-block;
    max-width: 500px;
    position: relative;
    font-size: 0.85rem;
}

.art-short {
    display: inline;
    color: #2d3748;
}

.art-full {
    display: none;
    color: #4a5568;
    line-height: 1.4;
}

.btn-expand-art {
    background: #edf2f7;
    border: none;
    cursor: pointer;
    color: #3182ce;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 5px;
    vertical-align: middle;
}

.btn-expand-art:hover {
    background: #e2e8f0;
    color: #2b6cb0;
    transform: scale(1.1);
}

.btn-expand-art i {
    font-size: 0.7rem;
}

.res-nome-cognome {
    text-transform: uppercase;
}
/* ========================================= */
/* DASHBOARD FLASH STYLES                    */
/* ========================================= */

.dashboard-header-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 25px;
    padding: 0 5px;
}

.view-mode-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 8px 15px;
    border-radius: 100px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.view-toggle-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--navy-light);
}

.toggle-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 80px;
    gap: 2px;
}

.toggle-group input[type="radio"] {
    display: none;
}

.toggle-group label {
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-radius: 60px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-group input[type="radio"]:checked + label {
    background: var(--navy-blue);
    color: white;
    box-shadow: 0 4px 10px rgba(11, 31, 60, 0.2);
}

.stat-card {
    position: relative;
    overflow: visible !important;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: var(--navy-blue);
    opacity: 0.1;
}

.stat-card .card-icon.info {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
}

.card-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    display: block;
    margin-top: 4px;
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 25px;
    margin-top: 25px;
}

.dashboard-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.02);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy-blue);
    letter-spacing: -0.02em;
}

.chart-wrapper {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaders-table-wrapper {
    overflow-x: auto;
}

.leaders-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.leaders-table th {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.75rem;
    padding-bottom: 12px;
}

.leaders-table td {
    background: #f8fafc;
    border: none;
    padding: 14px 18px;
    font-size: 0.9rem;
    color: var(--navy-blue);
    transition: all 0.2s;
}

.leaders-table tr td:first-child {
    border-radius: 10px 0 0 10px;
    font-weight: 600;
}

.leaders-table tr td:last-child {
    border-radius: 0 10px 10px 0;
}

.leaders-table tr:hover td {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.text-center { text-align: center; }
.text-right { text-align: right; }

/* Responsive adjustments */
@media (max-width: 1200px) {
    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }
}
/* Advanced Analytics View Styles */
#view-statistiche .table-container {
    padding: 24px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#view-statistiche .table-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
}

#view-statistiche h4 {
    font-size: 1rem;
    color: var(--navy-blue);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

#view-statistiche .big-number {
    font-size: 1.8rem;
    letter-spacing: -1px;
}

#view-statistiche .card-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
}

/* Filter Bar & Multi-select */
.custom-multi-select {
    position: relative;
    user-select: none;
    transition: all 0.2s ease;
}

.custom-multi-select:hover {
    border-color: var(--primary-color) !important;
    background: white !important;
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 10px;
}

.multi-select-item {
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.2s;
}

.multi-select-item:hover {
    background: #f1f5f9;
}

.multi-select-item.selected {
    background: #eff6ff;
    color: var(--primary-color);
    font-weight: 600;
}

.multi-select-item input {
    cursor: pointer;
}

.global-filters .form-control {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s;
}

.global-filters .form-control:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ========================================= */
/* MACRO SEZIONI GESTIONE ACCOUNT            */
/* ========================================= */
.admin-user-group {
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.admin-user-group:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.admin-user-group summary {
    padding: 14px 18px;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 12px;
    list-style: none;
    transition: background-color 0.2s ease;
}

.admin-user-group summary::-webkit-details-marker {
    display: none;
}

.admin-user-group summary:hover {
    background: #f1f5f9;
}

.admin-user-group summary i.fa-chevron-right {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.75rem;
    color: #94a3b8;
    width: 12px;
    text-align: center;
}

.admin-user-group[open] summary i.fa-chevron-right {
    transform: rotate(90deg);
}

.admin-user-group[open] summary {
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    color: #1e40af;
}

.admin-user-group summary i.fa-solid:not(.fa-chevron-right) {
    color: #1e40af;
    width: 20px;
    text-align: center;
}

.admin-user-group-content {
    padding: 0;
}

.admin-user-group-content .admin-table {
    margin: 0;
    border: none;
    border-radius: 0;
    width: 100% !important;
}

.admin-user-group-content .excel-style thead th {
    background: #f1f5f9;
    border-top: none;
}

.admin-user-count-badge {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: auto;
}

/* Info Tooltips */
.info-tooltip {
    position: relative;
    cursor: help;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.info-tooltip:hover {
    z-index: 2000;
}

.info-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 140%;
    right: 0;
    left: auto;
    background: #1e293b;
    color: #f8fafc;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: normal;
    width: 220px;
    z-index: 2000;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    pointer-events: none;
}

.info-tooltip:hover::before {
    content: '';
    position: absolute;
    top: 125%;
    right: 6px;
    left: auto;
    border: 6px solid transparent;
    border-bottom-color: #1e293b;
    z-index: 2000;
}

/* LightHouse Animated Logo */
.lighthouse-logo {
    width: 65px;
    height: 65px;
    margin: 0 auto;
    display: block;
    position: relative;
    overflow: visible;
}

.lighthouse-logo svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    perspective: 400px;
}

.light-beam {
    transform-origin: 50% 27px;
    animation: rotate-lighthouse-3d 6s linear infinite;
    transform-style: preserve-3d;
    filter: blur(2px);
}

.lantern-core {
    animation: pulse 2s ease-in-out infinite alternate;
}

@keyframes rotate-lighthouse-3d {
    0% { transform: rotateY(0deg); opacity: 0.1; }
    25% { transform: rotateY(90deg); opacity: 0.8; }
    50% { transform: rotateY(180deg); opacity: 0.1; }
    75% { transform: rotateY(270deg); opacity: 0.8; }
    100% { transform: rotateY(360deg); opacity: 0.1; }
}

@keyframes pulse {
    0% { r: 2.5; fill: #fbbf24; opacity: 0.7; }
    100% { r: 4; fill: #fef08a; opacity: 1; filter: drop-shadow(0 0 4px #fcd34d); }
}

/* Modal Ambito Operativo */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11, 31, 60, 0.85);
    display: none; /* Hidden by default */
    justify-content: center; align-items: center;
    z-index: 5000;
    backdrop-filter: blur(8px);
}

.modal-content.ambito-modal {
    background: white;
    width: 90%;
    max-width: 550px;
    padding: 35px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    text-align: center;
    border-top: 5px solid var(--primary-color);
}

.modal-content.ambito-modal h3 {
    margin-top: 0;
    color: var(--navy-blue);
    font-size: 1.5rem;
}

.modal-content.ambito-modal p {
    color: #64748b;
    margin-bottom: 25px;
}

.ambito-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.btn-ambito {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 10px;
    border: 2px solid #f1f5f9;
    border-radius: 12px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-ambito i {
    font-size: 1.5rem;
    color: #94a3b8;
}

.btn-ambito:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
    color: var(--primary-color);
}

.btn-ambito.selected {
    border-color: var(--primary-color);
    background: #eff6ff;
    color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.btn-ambito:hover i {
    color: var(--primary-color);
    transform: translateY(-3px);
}

.btn-ambito.selected i {
    color: var(--primary-color);
    transform: translateY(-3px) scale(1.1);
}

.ambito-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    justify-content: center;
}

.btn-cancel {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.85rem;
}

.btn-cancel:hover {
    color: #ef4444;
}

/* Custom Multi-select Dropdown for Ambiti Filter */
.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 5px;
    padding: 8px 0;
}

.multi-select-option {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.2s;
}

.multi-select-option:hover {
    background: #f1f5f9;
}

.multi-select-option input[type="checkbox"] {
    cursor: pointer;
}

/* ========================================= */
/* 📱 MOBILE & TABLET OPTIMIZATION (RIVA)     */
/* ========================================= */

@media (max-width: 1024px) {
    /* 1. LAYOUT RESET */
    body, html {
        overflow-y: auto !important; /* Permette lo scroll su mobile */
        height: auto !important;
    }

    .layout {
        display: block !important;
        min-height: 100vh;
        background: var(--bg-main);
    }

    /* Nascondi Sidebar Desktop su tutto ciò che non è Desktop */
    .sidebar { 
        display: none !important; 
    }

    /* 2. MOBILE HEADER & NAVIGATION */
    .mobile-header {
        display: flex;
        height: 60px;
        background: rgba(11, 31, 60, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 0 20px;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 1000;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .mobile-brand {
        display: flex;
        align-items: center;
    }

    .mobile-btn {
        background: rgba(255, 255, 255, 0.1);
        border: none;
        color: white;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1rem;
    }

    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(75px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-around;
        align-items: center;
        z-index: 9999;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.08);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .bottom-nav.nav-hidden {
        transform: translateY(110%);
    }

    /* FULLSCREEN MODE FOR GENERATORE */
    body.fullscreen-view .mobile-header,
    body.fullscreen-view .bottom-nav {
        display: none !important;
    }

    body.fullscreen-view .main-content {
        padding: 0 !important;
        margin: 0 !important;
        height: 100dvh !important;
        background: white;
    }

    body.fullscreen-view .view.active-view {
        height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    body.fullscreen-view iframe {
        height: 100dvh !important;
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #94a3b8;
        font-size: 0.65rem;
        font-weight: 600;
        gap: 5px;
        text-decoration: none;
        transition: all 0.3s ease;
    }

    .bottom-nav-item i { 
        font-size: 1.3rem; 
        transition: transform 0.3s ease;
    }
    
    .bottom-nav-item.active { 
        color: var(--navy-blue); 
    }
    
    .bottom-nav-item.active i {
        transform: translateY(-2px);
    }

    .center-fab { 
        position: relative; 
        top: -18px; 
    }
    
    .fab-circle {
        width: 60px;
        height: 60px;
        background: linear-gradient(135deg, var(--gold) 0%, var(--gold-hover) 100%);
        border-radius: 20px; /* Modern shape */
        display: flex;
        justify-content: center;
        align-items: center;
        color: white;
        font-size: 1.6rem;
        box-shadow: 0 10px 20px rgba(212, 175, 55, 0.4);
        border: 5px solid var(--white);
        transform: rotate(45deg);
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .fab-circle i {
        transform: rotate(-45deg) !important; /* Force rotation to stay a plus */
        display: inline-block;
    }

    /* 3. CONTENT ADAPTATION */
    .main-content {
        margin-left: 0 !important;
        padding: 15px !important;
        padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important; /* Space for bottom nav */
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .topbar {
        display: none !important; /* Usiamo mobile-header invece */
    }

    /* TABELLE -> CARDS (ARCHIVIO VERBALI) */
    .table-container {
        padding: 0;
        background: transparent;
        box-shadow: none;
        border: none;
    }

    #table-verbali, 
    #table-verbali thead, 
    #table-verbali tbody, 
    #table-verbali th, 
    #table-verbali td, 
    #table-verbali tr {
        display: block;
        width: 100%;
    }

    #table-verbali thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    #table-verbali tr {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        margin-bottom: 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.04);
        padding: 10px;
        position: relative;
    }

    #table-verbali td {
        border: none;
        border-bottom: 1px solid #f1f5f9;
        position: relative;
        padding: 12px 12px 12px 45% !important; 
        text-align: right !important;
        min-height: 48px; 
        display: flex;
        justify-content: flex-end;
        align-items: center;
        font-size: 0.9rem;
    }
    
    #table-verbali td:last-child {
        border-bottom: none;
        justify-content: center;
        gap: 15px;
        padding-left: 10px !important;
        background: #f8fafc;
        border-radius: 0 0 12px 12px;
        margin-top: 10px;
    }

    #table-verbali td::before {
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        width: 40%;
        font-weight: 700;
        color: #64748b;
        text-align: left;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    #table-verbali td:nth-child(1)::before { content: "Data"; }
    #table-verbali td:nth-child(2)::before { content: "N. Verbale"; }
    #table-verbali td:nth-child(3)::before { content: "Comando"; }
    #table-verbali td:nth-child(4)::before { content: "Trasgressore"; }
    #table-verbali td:nth-child(5)::before { content: "Norma Violata"; }
    #table-verbali td:nth-child(6)::before { content: "Ambito"; }
    #table-verbali td:nth-child(7)::before { content: "Stato"; }
    #table-verbali td:nth-child(8)::before { content: "Gestione"; }
    #table-verbali td:nth-child(9)::before { content: ""; display: none; }

    /* FILTERS OPTIMIZATION */
    .dashboard-header-controls {
        padding: 15px !important;
        margin-bottom: 20px !important;
    }

    .global-filters {
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px !important;
    }

    .filter-group {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* DASHBOARD CARDS */
    .dashboard-cards {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* MODALI FULL SCREEN */
    .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        padding: 25px 20px !important;
    }
}

@media (min-width: 1025px) {
    .mobile-only {
        display: none !important;
    }
}
