html {
    zoom: 80%;
}

:root {
    --primary-color: #083D76; /* Nuova mality Blue */
    --primary-light: #125A9B;
    --primary-dark: #042A54;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --bg-color: #F3F4F6; /* Gray 100 */
    --sidebar-bg: #111827; /* Gray 900 */
    --sidebar-text: #D1D5DB;
    --sidebar-text-hover: #FFFFFF;
    --card-bg: #FFFFFF;
    --text-dark: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    display: flex;
    min-height: 125vh;
}

body.modal-open {
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 125vh;
}

.sidebar {
    width: 250px;
    height: 125vh; 
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
}

.sidebar-nav a, .sidebar-footer a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-nav a:hover, .sidebar-nav a.active, 
.sidebar-footer a:hover, .sidebar-footer a.active {
    background-color: rgba(255,255,255,0.1);
    color: var(--sidebar-text-hover);
    border-left: 4px solid var(--primary-color);
}

.sidebar-nav a i, .sidebar-footer a i {
    width: 20px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.8;
}

.sidebar-nav a:hover i, .sidebar-nav a.active i,
.sidebar-footer a:hover i, .sidebar-footer a.active i {
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Important for flex-shrink issues */
    margin-left: 250px; /* Offset for fixed sidebar */
}

.topbar {
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100% - 250px);
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    z-index: 1000;
    height: 70px;
}

.topbar .greeting {
    font-size: 1.05rem;
    color: var(--text-dark);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.action-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
}

.action-link:hover {
    color: var(--primary-color);
}

.action-link i {
    font-size: 1.1rem;
}

.action-link.logout {
    color: var(--danger-color);
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-md);
}

.action-link.logout:hover {
    background: var(--danger-color);
    color: white;
}

/* Page Content */
.page-content {
    padding: 2rem;
    margin-top: 70px; /* Offset for fixed topbar */
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.8rem;
    color: var(--text-dark);
}

/* Cards & Dashboards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.stat-card .title {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #F9FAFB;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

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

tr:hover td {
    background-color: var(--bg-color);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.nuovo { background-color: #DBEAFE; color: #1E40AF; }
.status-badge.qualificato { background-color: #D1FAE5; color: #065F46; }
.status-badge.qualificato-caldo { background-color: #FEF3C7; color: #92400E; } /* Orange - In lavorazione */
.status-badge.cliente { background-color: #F1F5F9; color: #475569; }
.status-badge.badge-danger { background-color: #FEE2E2; color: #991B1B; } /* Red - Rifiutato */

/* Client specific statuses */
.status-badge.preventivo-firmato { background-color: #E0E7FF; color: #3730A3; } /* Indigo */
.status-badge.lavori-in-corso { background-color: #FEF3C7; color: #92400E; } /* Amber */
.status-badge.fattura-emessa { background-color: #F5E6FF; color: #6B21A8; } /* Purple */
.status-badge.chiuso { background-color: #D1FAE5; color: #065F46; } /* Green */

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-outline { 
    background-color: transparent; 
    border: 1px solid var(--primary-color); 
    color: var(--primary-color); 
}
.btn-outline:hover { 
    background-color: var(--primary-color); 
    color: white; 
}
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-warning { background-color: var(--warning-color); color: white; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Massima priorità */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transform: translateY(-20px);
    transition: transform 0.3s;
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.modal-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.modal-body {
    padding: 1.5rem;
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.95rem; }
.form-control {
    width: 100%; padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit; font-size: 1rem;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-light); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* Responsive */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100vh; transform: translateX(-100%); z-index: 1500; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { width: 100%; }
    .mobile-menu-btn { display: block; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
}

.document-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: end;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    gap: 0.5rem;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.5rem;
    border-radius: var(--radius-md);
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.pagination-link:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: var(--bg-color);
}

.pagination-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-link.disabled {
    opacity: 0.5;
    pointer-events: none;
    background-color: #F9FAFB;
}

/* Filter Bar */
.filter-bar {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-end; /* Allinea i bottoni alla base degli input */
    gap: 1.5rem;
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group:first-child {
    flex: 1;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-bar .form-control {
    padding: 0.6rem 1rem;
    border-color: #E2E8F0;
    font-size: 0.9rem;
    height: 42px;
    width: 100%;
}

.filter-group select.form-control {
    min-width: 200px; /* Larghezza uniforme basata su Clienti */
}

.filter-bar .btn {
    height: 42px;
    padding: 0 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0; /* Assicura allineamento con input */
}
/* Export & Checkbox Layout */
.col-check { width: 40px; text-align: center; }
.form-check { transform: scale(1.1); cursor: pointer; }

.export-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.export-actions-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1E293B;
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    z-index: 999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255,255,255,0.1);
}

.export-actions-bar.active {
    transform: translateX(-50%) translateY(0);
}

.export-actions-bar .count-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: #94A3B8;
    border-right: 1px solid rgba(255,255,255,0.1);
    padding-right: 1.5rem;
}

.export-actions-bar .export-buttons {
    display: flex;
    gap: 0.75rem;
}

.export-actions-bar .btn-export {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.2s;
    border: none;
    cursor: pointer;
    color: white;
}

.export-actions-bar .btn-export:hover { opacity: 0.9; }
.export-actions-bar .btn-export.pdf { background: #E11D48; }
.export-actions-bar .btn-export.excel { background: #16A34A; }

.export-actions-bar .close-bar {
    margin-left: 0.5rem;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
}

.export-actions-bar .close-bar:hover { background: rgba(255,255,255,0.2); }

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 450px;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    border-left: 5px solid var(--primary-color);
}

.toast.removing {
    animation: toast-out 0.3s ease forwards;
}

.toast i {
    font-size: 1.25rem;
}

.toast.success {
    border-left-color: var(--success-color);
}
.toast.success i { color: var(--success-color); }

.toast.error {
    border-left-color: var(--danger-color);
}
.toast.error i { color: var(--danger-color); }

.toast.info {
    border-left-color: var(--primary-color);
}
.toast.info i { color: var(--primary-color); }

.toast-content {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark);
    line-height: 1.4;
}

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

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

/* Dashboard & Analytics Enhancements */
#dashboard-filters .form-control {
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
}

#dashboard-filters .form-control:hover {
    border-color: var(--primary-color);
}

.stat-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.stat-card .title {
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.stat-card .value {
    transition: color 0.3s ease;
}

/* Charts responsive containers */
canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 1024px) {
    .dashboard-grid[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

