:root {
    --font-sans: 'Inter', sans-serif;
    --font-brand: 'Outfit', sans-serif;
    
    /* PALETTE PROFESSIONALE / MINIMALISTA */
    --bg-body: #f8fafc; /* slate-50 */
    --bg-content: #ffffff; /* white */
    --border-color: #e2e8f0; /* slate-200 */
    --text-primary: #1e293b; /* slate-800 */
    --text-secondary: #64748b; /* slate-500 */
    --text-primary: #1e293b; /* slate-800 */
    --text-secondary: #64748b; /* slate-500 */
    
    /* THEME UPDATE: SIDEBAR ALIGNED (Deep Dark & Lilac) */
    --brand-primary: #0B0E14; /* Match Sidebar BG */
    --brand-accent: #D8B4FE; /* Match Sidebar Accent (Lilac) */
    --brand-primary-light: #F3E8FF; /* purple-50 */
    --brand-hover: #1F2937; /* Match Sidebar Hover */
    
    /* AGGIUNTO: Colori per la sidebar scura (Nuovo Design) */
    --sidebar-bg: #111827; /* gray-900 (Deep Dark) */
    --sidebar-accent: #D8B4FE; /* purple-300 (Lilac) */
    --sidebar-accent-hover: #C084FC; /* purple-400 */
    --sidebar-text: #9ca3af; /* gray-400 */
    --sidebar-text-hover: #f3f4f6; /* gray-100 */
    --sidebar-border: #374151; /* gray-700 */
    
    --brand-gradient: linear-gradient(135deg, var(--brand-primary) 0%, #2563eb 100%); /* Blue gradient */

    /* Ombre discrete */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --success: #10b981;
    --error: #ef4444;
    --info: var(--brand-primary);
}
* { font-family: var(--font-sans); box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }
body {
    background: #1E1E1E; /* Dark Grey */
    color: var(--text-primary);
}

/* --- UTILITY CLASSES (CRITICAL) --- */
.hidden { display: none !important; }
.block { display: block; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.p-4 { padding: 1rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-gray-500 { color: #6b7280; }
.text-gray-900 { color: #111827; }
.whitespace-nowrap { white-space: nowrap; }
.overflow-hidden { overflow: hidden; }

.main-layout { display: flex; height: 100vh; overflow: hidden; }
.main-layout.top-nav-layout { flex-direction: column; }

/* --- LOADING OVERLAY (Fixed) --- */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    border: 1px solid var(--border-color);
}

/* --- DRAG & DROP ZONE --- */
/* Optimized for GPU rendering */
.upload-zone {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    padding: 4rem 2rem; 
    border: 2px dashed #CBD5E1; 
    border-radius: 8px; 
    background: #F8FAFC; 
    cursor: pointer; 
    transition: all 0.2s;
    contain: layout paint;
}
.upload-zone:hover { border-color: var(--brand-accent); background: #fdfaff; /* Very light lilac */ }
.upload-zone.dragover { border-color: var(--brand-accent); background: var(--brand-primary-light); }

/* ============================================================
   TOPBAR — PREMIUM HORIZONTAL NAVIGATION (Warm & Bright)
   ============================================================ */
#topbar-container {
    flex-shrink: 0;
    width: 100%;
    z-index: 50;
}

.topbar {
    width: 100%;
    height: 70px;
    background-color: #1E1E1E; /* Dark Grey */
    color: #E2E8F0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* --- LEFT: Logo & Brand --- */
.topbar-left {
    display: flex;
    align-items: center;
    min-width: 200px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo-container:hover { opacity: 0.8; }

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px; /* Slightly squarish but soft */
    object-fit: cover;
    border: 1px solid rgba(255, 255, 227, 0.1); /* Very subtle inset effect */
    background: #6D8196; /* Base color in case image is missing */
}

.brand-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 600; /* Slightly lighter weight for elegance */
    font-size: 1.3rem; /* Tiny bit bigger for prominence */
    color: #FFFFE3; /* Ink wash Cream */
    letter-spacing: -0.01em;
}

/* --- CENTER: Navigation --- */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(203, 203, 203, 0.15); /* Subtle Ink wash Light Grey (#CBCBCB) */
    padding: 0.35rem;
    border-radius: 12px;
    border: 1px solid rgba(203, 203, 203, 0.25);
}

.nav-divider {
    width: 1px;
    height: 1.5rem;
    background-color: rgba(203, 203, 203, 0.3);
    margin: 0 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    color: #CBCBCB; /* Ink wash Light Grey */
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    color: #FFFFE3; /* Ink wash Cream */
    background-color: rgba(109, 129, 150, 0.4); /* Ink wash Blue-Grey (#6D8196) */
}

.nav-item.active {
    background-color: rgba(109, 129, 150, 0.6); /* Stronger Ink wash Blue-Grey */
    color: #FFFFE3; /* Ink wash Cream */
    font-weight: 600;
}

/* Bottom active indicator */
.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px; /* Align with bottom */
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 3px;
    background-color: #FFFFE3; /* Ink wash Cream indicator */
    border-radius: 3px 3px 0 0;
    box-shadow: 0 -2px 8px rgba(255, 255, 227, 0.4);
}

.nav-icon {
    width: 1.1rem;
    height: 1.1rem;
    opacity: 0.8;
    transition: color 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.nav-item:hover .nav-icon { color: #FFFFE3; opacity: 1; filter: none; }
.nav-item.active .nav-icon { color: #FFFFE3; opacity: 1; filter: none; }

/* --- RIGHT: Controls & User --- */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem; /* Reduced gap to bring them closer */
    min-width: 200px;
    justify-content: flex-end;
}

.privacy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #CBCBCB; /* Ink wash Light Grey */
    cursor: pointer;
    transition: all 0.2s ease;
}

.privacy-btn:hover {
    color: #FFFFE3; /* Ink wash Cream */
    background: rgba(109, 129, 150, 0.2); /* Ink wash Blue-Grey */
    border-color: rgba(109, 129, 150, 0.4);
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem 0.4rem 0.4rem;
    border-radius: 12px; /* Smooth rounded rectangle */
    background: rgba(255, 255, 255, 0.08); /* Always visible light card */
    border: 1px solid rgba(255, 255, 255, 0.05); /* Very subtle border */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.user-profile-btn:hover {
    background: rgba(255, 255, 255, 0.12); /* Slightly brighter on hover */
    border-color: rgba(255, 255, 255, 0.1);
}

.avatar-icon-container {
    width: 32px;
    height: 32px;
    border-radius: 10px; /* Soft squarish avatar */
    background: #6D8196; /* Slate Blue background */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFE3; /* Cream icon */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); /* Soft drop shadow */
}

.avatar-icon {
    width: 1rem;
    height: 1rem;
}

.user-details-compact .name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #FFFFE3; /* Ink wash Cream */
    line-height: 1;
}



/* --- GLOBAL LOADER --- */
#global-loader {
    position: fixed;
    inset: 0; /* top: 0; right: 0; bottom: 0; left: 0; */
    background-color: #1E1E1E; /* Dark Background matching the app */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
    visibility: visible;
}

#global-loader.hidden-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: none; /* Fully remove from flow */
}

#global-loader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.loader-logo-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    /* Rimosso il filter animato che causa lag, usiamo un glow statico */
    filter: drop-shadow(0 0 15px rgba(216, 180, 254, 0.4));
    animation: logo-pulse 1.5s infinite ease-in-out;
    will-change: transform, opacity;
}

.loader-progress-bar {
    width: 200px;
    height: 4px;
    background-color: #1F2937;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.loader-progress-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 30%;
    background-color: #D8B4FE;
    border-radius: 999px;
    box-shadow: 0 0 10px #D8B4FE;
    /* Usiamo translateX invece di left per eliminare gli scatti */
    animation: progress-slide 1.2s infinite ease-in-out;
    will-change: transform;
}

@keyframes logo-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

@keyframes progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}


/* Riga 387 in style.css */
.main-content { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden;
    background-color: var(--bg-body);
}

/* Default container mode if inside top-nav layout */
.top-nav-layout .main-content {
    margin: 0.6rem; /* Equal inset on all 4 sides */
    width: calc(100% - 1.2rem);
    height: calc(100vh - 70px - 1.2rem); /* Account for topbar (70px) and margins */
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* Fallback if it's the old sidebar layout */
.main-layout:not(.top-nav-layout) .main-content {
    margin: 0.6rem 0.6rem 0.6rem 0; /* Inset container effect on right */
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.1);
}

.content-area { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 1.5rem 0; 
    scroll-behavior: auto; /* Smoother with heavy DOM */
    will-change: transform; /* Hardware acceleration */
}

/* Header "Frosted Glass" - Optimized to reduce repaint lag */
.header { 
    backdrop-filter: blur(8px); /* Slightly reduced for performance */
    -webkit-backdrop-filter: blur(8px); 
    background-color: rgba(255, 255, 255, 0.95); /* Increased opacity */
    border-bottom: 1px solid var(--border-color); 
    padding: 0.75rem 2rem; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    position: sticky; top: 0;
    will-change: transform;
}

.btn-icon {
    width: 2.25rem; height: 2.25rem;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: var(--bg-body);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-icon i { width: 1.2rem; height: 1.2rem; }

.date-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
}

/* --- DASHBOARD NEW LAYOUT --- */
.dashboard-container {
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
}

.expanded-width {
    max-width: none !important; /* Force Full Width */
    width: 100%;
    padding: 0 2rem; /* Match header horizontal padding */
}

.animate-slide-in-up { animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes slideInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* WELCOME SECTION */
.welcome-section {
    margin-bottom: 1.5rem; /* Tighter spacing */
}
.welcome-text { margin-bottom: 1.5rem; }

.welcome-title {
    font-family: 'Outfit', sans-serif; /* Modern Sans-Serif */
    font-size: 2rem; /* Slightly smaller for dense look */
    font-weight: 700;
    color: #111827; 
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em; /* Tighter tracking */
}
.welcome-subtitle {
    font-family: 'Inter', sans-serif;
    color: #64748B;
    font-size: 0.95rem;
}

/* KPI GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 90px; /* Ensure uniform height */
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #D8B4FE;
}

.kpi-icon {
    width: 3rem; height: 3rem;
    border-radius: 8px;
    background: #F8FAFC;
    color: #64748B;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-card:hover .kpi-icon { background: #F3E8FF; color: #9333EA; }

.kpi-content {
    display: flex;
    flex-direction: column;
}
.kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}
.kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.kpi-trend {
    position: absolute;
    top: 0.75rem; right: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 0.25rem;
}
.kpi-trend.positive { color: #10B981; }
.status-ok { color: #10B981; font-size: 1rem; }

/* Privacy Badge */
.privacy-card { border-left: 4px solid #10B981; }


/* MAIN GRID */
.main-dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 2/3 Tools, 1/3 Activity */
    gap: 2rem;
}

.fluid-grid {
    grid-template-columns: 3fr 1fr; /* 3/4 content, 1/4 sidebar info on wide screens */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Outfit', sans-serif;
}
.btn-text-sm {
    background: none; border: none;
    color: var(--brand-primary);
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer;
}
.btn-text-sm:hover { text-decoration: underline; }

/* TOOLS GRID */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.expanded-tools {
    grid-template-columns: repeat(3, 1fr) !important; /* Denser Layout for tools */
}

.tool-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
    min-height: 180px;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: #D8B4FE;
}

.tool-card-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tool-icon-box {
    width: 3rem; height: 3rem;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    background: #F1F5F9;
    color: #475569;
    transition: background 0.3s;
}
.tool-card:hover .tool-icon-box { background: #111827; color: white; }

/* Special Themes for Icon Box */
.theme-blue:hover .tool-icon-box { background: #2563EB; }
.theme-lilac:hover .tool-icon-box { background: #9333EA; }
.theme-emerald:hover .tool-icon-box { background: #059669; }
.theme-gray:hover .tool-icon-box { background: #4B5563; }

.tool-meta h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.25rem;
    font-family: 'Outfit', sans-serif;
}
.tool-tag {
    font-size: 0.7rem;
    color: #64748B;
    background: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.tool-desc {
    font-size: 0.9rem;
    color: #64748B;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.tool-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #111827;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}
.tool-card:hover .tool-footer {
    opacity: 1;
    transform: translateX(0);
}

/* UPDATE CARDS (Static) */
.update-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}
.update-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #E2E8F0;
}
.update-card:hover { border-color: #9CA3AF; }

.update-date {
    font-size: 0.7rem; 
    font-weight: 600; 
    color: #64748B; 
    text-transform: uppercase;
    display: block; margin-bottom: 0.25rem;
}
.update-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
}
.update-card p {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
}


/* TIP CARD */
.tip-card {
    margin-top: 1.5rem;
    background: linear-gradient(135deg, #111827, #1F2937);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}
.tip-header {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 700;
    color: #D8B4FE;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.tip-header i { width: 1.1rem; height: 1.1rem; }
.tip-card p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #D1D5DB;
}

/* RESPONSIVE */
@media (max-width: 1280px) {
    .expanded-tools { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .main-dashboard-grid { grid-template-columns: 1fr; }
    .fluid-grid { grid-template-columns: 1fr; }
    .sidebar { width: 0; padding: 0; overflow: hidden; position: fixed; z-index: 50;}
    .sidebar.open { width: 260px; padding: 1.25rem; }
    .expanded-width { max-width: 100% !important; width: 100%; padding: 0 2rem; }
    .main-content { margin: 0; border-radius: 0; } /* Full width on mobile */
}

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .tools-grid { grid-template-columns: 1fr; }
    .expanded-tools { grid-template-columns: 1fr !important; }
}

/* --- MODERNIZED DATA TABLE --- */
.table-scroll-wrapper {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); /* Soft shadow */
    overflow-x: auto; /* Enable horizontal scroll */
    margin-top: 1.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse; /* Clean grid */
    table-layout: auto; /* Intelligent Column Widths */
    font-size: 0.9rem;
    text-align: left;
    font-family: 'Inter', sans-serif;
}

.data-table thead th {
    background-color: white; /* Clean minimalist header */
    color: #64748B; /* slate-500 */
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #F1F5F9; /* Stronger separation */
    border-right: 1px solid #F1F5F9; /* Vertical Separation */
    white-space: nowrap; /* Prevent wrapping */
    position: sticky; top: 0; z-index: 10;
}
.data-table thead th:last-child { border-right: none; }

.data-table tbody tr {
    border-bottom: 1px solid #F8FAFC; /* Very subtle separation */
    transition: all 0.2s ease;
}
.data-table tbody tr:last-child { border-bottom: none; }

.data-table tbody tr:hover { 
    background-color: #FDF9FF; /* Very faint purple tint */
}
.data-table tbody tr:hover td {
    color: #111827; /* Darker text on hover */
}

.data-table td {
    padding: 0.5rem 1rem;
    color: #334155; /* slate-700 */
    vertical-align: middle;
    border-right: 1px solid #F8FAFC; /* Vertical Separation */
    white-space: nowrap; /* Prevent wrapping */
    max-width: 300px; /* Prevent massive columns */
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-table td:last-child { 
    border-right: none; 
    text-align: center; /* Center Actions Column */
    width: 1%; /* Shrink to fit content */
    white-space: nowrap;
}
.data-table th:last-child {
    border-right: none;
    text-align: center; /* Center Actions Header */
    width: 1%; /* Shrink to fit content */
    white-space: nowrap;
}

/* Actions in Table - Minimalist Icon Style */
.view-report-btn {
    width: 1.75rem; height: 1.75rem;
    border-radius: 6px;
    color: #94A3B8; /* Slate-400 */
    background: transparent; /* Ghost Style */
    border: none; /* No Border */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.view-report-btn i {
    width: 1rem; height: 1rem;
}

/* Hover: View (Lilac) */
.view-report-btn.btn-icon-view:hover { 
    background: #F3E8FF; /* Lilac-100 */
    color: var(--brand-accent); /* Lilac */
    transform: scale(1.1);
}

/* Hover: Delete (Red) */
.view-report-btn.btn-icon-delete:hover {
    background: #FEF2F2; /* Red-50 */
    color: #EF4444; /* Red-500 */
    transform: scale(1.1);
}

/* --- COMPARA COLONNE REDESIGN --- */

/* 1. Editor-like Input Areas */
.input-editor-wrapper {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s ease;
    height: 100%;
}

.input-editor-wrapper:focus-within {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(216, 180, 254, 0.2);
}

.editor-header {
    background: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #64748B;
    font-weight: 500;
}

.editor-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.editor-label.source { color: #2563EB; } /* Blue for Source */
.editor-label.target { color: #9333EA; } /* Purple for Target */

.editor-textarea {
    flex-grow: 1;
    width: 100%;
    border: none;
    resize: none;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace; /* Monospace for data */
    font-size: 0.85rem;
    line-height: 1.6;
    color: #334155;
    background: #ffffff;
    outline: none;
    white-space: pre;
}
.editor-textarea::placeholder { color: #94A3B8; opacity: 0.7; }

/* 2. Comparison Results Styled */
.results-header-actions {
    display: flex;
    gap: 0.5rem;
    background: #F1F5F9;
    padding: 0.25rem;
    border-radius: 6px;
}

.filter-pill {
    padding: 0.4rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748B;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill:hover { color: #1E293B; }

.filter-pill.active {
    background: white;
    color: var(--brand-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* 3. Diff Table Specifics */
.diff-table-cell {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

/* Highlighted Diff */
mark.diff-highlight {
    background-color: #FEF08A; /* Yellow-200 */
    color: #854D0E; /* Yellow-800 */
    padding: 0.1em 0.2em;
    border-radius: 2px;
    font-weight: 600;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.match {
    background: #DCFCE7; /* Green-100 */
    color: #166534; /* Green-800 */
    border: 1px solid #BBF7D0;
}

.status-badge.mismatch {
    background: #FEE2E2; /* Red-100 */
    color: #991B1B; /* Red-800 */
    border: 1px solid #FECACA;
}

/* 4. Action Bar (Smart Actions) */
.smart-actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* 5. Layout Fixes */
.comparison-input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    height: auto;
    min-height: 500px;
}

@media (min-width: 1024px) {
    .comparison-input-grid {
        grid-template-columns: 1fr 1fr;
        height: 600px;
    }
}


/* --- COLUMN MANAGER MODAL GRID --- */
.col-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.col-card-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.col-card-option:hover {
    border-color: var(--brand-accent);
    background-color: var(--brand-primary-light);
}

.hidden-native-checkbox { display: none; }

.custom-checkbox-visual {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: white;
}

.col-card-option input:checked + .custom-checkbox-visual {
    background-color: var(--brand-primary); /* Dark BG */
    border-color: var(--brand-primary);
    color: var(--brand-accent); /* Lilac Check */
}

.icon-check {
    width: 1rem;
    height: 1rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--brand-accent); /* Explicit Lilac */
}

.col-card-option input:checked + .custom-checkbox-visual .icon-check {
    opacity: 1;
    transform: scale(1);
}

.col-label-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modals General */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}
.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    margin: 1rem;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column;
    max-height: 85vh;
}
.modal-backdrop.show .modal-content {
    transform: scale(1);
    opacity: 1;
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #F8FAFC;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    display: flex; justify-content: flex-end; gap: 0.75rem;
}

/* --- MISSING UTILITIES (Buttons & Search) --- */

/* Buttons */
.btn-primary {
    background-color: var(--brand-primary);
    color: var(--brand-accent); /* Lilac Text */
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid rgba(216, 180, 254, 0.2); /* Subtle Lilac Border */
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.btn-primary:hover:not(:disabled) {
    background-color: var(--brand-hover); /* Lighter Dark */
    color: white;
    border-color: var(--brand-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(216, 180, 254, 0.25); /* Lilac Glow */
}
.btn-primary:disabled {
    background-color: #94A3B8;
    color: #E2E8F0;
    border-color: transparent;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

.btn-secondary {
    background-color: white;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-secondary:hover:not(:disabled) {
    background-color: #F8FAFC;
    border-color: var(--brand-accent);
    color: var(--brand-primary);
}

/* Search Bar (Specific to Header) */
.search-bar-wrapper {
    position: relative;
    width: 350px; /* Default width */
}

.search-bar-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    width: 1rem; height: 1rem;
    pointer-events: none;
    transition: color 0.2s;
}

.search-bar-input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.25rem; /* Space for icon */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #F8FAFC;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: all 0.2s;
    outline: none;
}

.search-bar-input:focus {
    background: white;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(216, 180, 254, 0.2); /* Lilac Ring */
}
.search-bar-input:focus + .search-bar-icon,
.search-bar-wrapper:focus-within .search-bar-icon {
    color: var(--brand-accent); /* Icon lights up */
}

.search-bar-input:disabled {
    background: #F1F5F9;
    color: #94A3B8;
    cursor: not-allowed;
}

/* Input File Hidden */
input[type="file"].hidden { display: none; }

/* Responsive adjustments for Search */
@media (max-width: 768px) {
    .search-bar-wrapper { width: 100% !important; }
    .btn-label-responsive { display: none; }
}
/* --- NEW DASHBOARD REDESIGN --- */

.centered-dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%; /* Force height to container's height (which is 100vh approx) */
    max-height: 100vh; /* Prevent growth beyond viewport */
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    overflow: hidden !important; /* Disable scroll on home */
    min-height: 0; /* Override previous min-height */
}

.dashboard-hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}

.hero-date {
    font-size: 1.1rem;
    color: var(--brand-accent);
    font-weight: 500;
    margin-bottom: 1rem;
    text-transform: capitalize;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: #64748B;
    max-width: 600px;
    margin: 0 auto;
}

.dashboard-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    width: 100%;
    max-width: 1100px;
}


.feature-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content */
    text-align: center;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.1);
    border-color: var(--brand-accent);
}

.card-icon-wrapper {
    width: 4rem;
    height: 4rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    /* Generic background if glow classes miss */
    background: #F8FAFC; 
    color: var(--text-primary);
}

.card-icon-wrapper i {
    width: 2rem;
    height: 2rem;
}

/* Glow Variants */
.blue-glow {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.2) 100%);
    color: #2563EB;
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.15);
}

.purple-glow {
    background: linear-gradient(135deg, rgba(216, 180, 254, 0.1) 0%, rgba(216, 180, 254, 0.2) 100%);
    color: #9333EA;
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.15);
}

.orange-glow {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.1) 0%, rgba(251, 146, 60, 0.2) 100%);
    color: #EA580C;
    box-shadow: 0 0 15px rgba(234, 88, 12, 0.15);
}



.card-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.card-content p {
    font-size: 0.95rem;
    color: #64748B;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.card-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--brand-primary); /* Dark text */
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: transparent;
    transition: all 0.2s;
}

.feature-card:hover .card-cta {
    background: #F1F5F9;
    color: var(--brand-accent);
}

.feature-card:hover .card-cta i {
    transform: translateX(4px);
    transition: transform 0.2s;
}

.dashboard-footer {
    margin-top: 4rem;
    opacity: 0.8;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: #64748B;
}

.security-badge i {
    width: 1rem; height: 1rem;
    color: #10B981; /* Green check */
}

/* --- TOAST NOTIFICATIONS (New System) --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Allow clicks through empty space */
}

.toast {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    background: #111827; /* Deep Dark */
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #374151; /* Gray-700 */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 280px;
    max-width: 350px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto; /* Enable clicks on toast */
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex-grow: 1;
    line-height: 1.4;
}

.toast-close {
    background: transparent;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.toast-close i { width: 16px; height: 16px; }

/* Toast Variants */
.toast-success {
    border-left: 4px solid #10B981; /* Green */
}
.toast-success .toast-icon { color: #10B981; }

.toast-error {
    border-left: 4px solid #EF4444; /* Red */
}
.toast-error .toast-icon { color: #EF4444; }

.toast-info {
    border-left: 4px solid #D8B4FE; /* Lilac */
}
.toast-info .toast-icon { color: #D8B4FE; }

/* ============================================================
   REPORT VIEWER REDESIGN (Premium Dark/Grey Theme)
   ============================================================ */

/* --- HEADER REWORK --- */
.header {
    background-color: #ffffff; /* White background */
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1.5rem;
    position: relative; /* Added for absolute centering of search bar */
}

.header-text-wrapper h3 {
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
}

.header-text-wrapper p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

/* SEARCH BAR EXACTLY CENTERED */
.search-bar-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    display: flex;
    align-items: center;
}

.search-bar-icon {
    position: absolute;
    left: 1rem;
    color: #64748B;
    width: 1.1rem;
    height: 1.1rem;
    pointer-events: none;
}

.search-bar-input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.8rem;
    background: #F8FAFC;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.search-bar-input:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(216, 180, 254, 0.2);
}

.search-bar-input::placeholder { color: #64748B; }

/* ACTIONS GROUP */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.actions-group {
    display: flex;
    gap: 0.5rem;
}

/* UPLOAD ZONE WRAPPER */
.upload-zone-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px); /* Take up most of the remaining screen height */
    padding: 2rem;
}

/* PREMIUM UPLOAD ZONE */
.premium-upload {
    background: #FFFFFF;
    border: 2px dashed #CBD5E1;
    border-radius: 16px;
    padding: 5rem 3rem;
    transition: all 0.3s ease;
    text-align: center;
    max-width: 650px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.premium-upload:hover, .premium-upload.dragover {
    background: #F8FAFC;
    border-color: #94A3B8;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}
.premium-upload .upload-icon-wrapper {
    color: #64748B;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #F1F5F9;
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}
.premium-upload .upload-icon-wrapper i {
    width: 2.5rem;
    height: 2.5rem;
}
.premium-upload:hover .upload-icon-wrapper, .premium-upload.dragover .upload-icon-wrapper { 
    color: var(--brand-accent); 
    background: #F3E8FF;
}
.premium-upload h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 0.75rem;
}
.premium-upload p {
    color: #64748B;
    font-size: 1.05rem;
    margin-bottom: 2.5rem;
    line-height: 1.6;
    max-width: 450px;
}

.upload-button-wrapper {
    display: flex;
    justify-content: center;
}

.upload-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.75rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    background: #1E293B;
    color: #FFFFFF;
    transition: all 0.2s ease;
    border: none;
}
.upload-trigger-btn:hover {
    background: #0F172A;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.upload-trigger-btn i {
    width: 1.25rem;
    height: 1.25rem;
}

/* PREMIUM TABLE DESIGN */
/* TABLE CONTAINER & WRAPPER */
.table-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0; /* Let flexbox compress it if needed */
    width: 100%;
}

.premium-table-wrapper {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    margin-top: 1rem;
    overflow: hidden; /* Don't scroll the wrapper - only tbody scrolls */
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Base Table */
.report-premium-table {
    width: 100%;
    border-collapse: collapse;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

/* thead stays fixed at top */
.report-premium-table thead {
    flex-shrink: 0;
}

.report-premium-table thead tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Headers */
.report-premium-table thead th {
    background: #F8FAFC;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 1rem 1.25rem;
    border-bottom: 2px solid #E2E8F0;
    border-right: 1px solid #E2E8F0;
    white-space: nowrap;
    text-align: left;
}

.report-premium-table thead th:last-child {
    border-right: none;
    text-align: right;
}

/* tbody scrolls independently */
.report-premium-table tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.report-premium-table tbody::-webkit-scrollbar {
    width: 8px;
}
.report-premium-table tbody::-webkit-scrollbar-track {
    background: transparent;
}
.report-premium-table tbody::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 10px;
    border: 2px solid #FFFFFF;
}
.report-premium-table tbody::-webkit-scrollbar-thumb:hover {
    background-color: #94A3B8;
}

.report-premium-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Body Cells */
.report-premium-table tbody td {
    padding: 0.85rem 1.25rem;
    color: #334155;
    font-size: 0.9rem;
    border-bottom: 1px solid #E2E8F0; /* Darker bottom border for grid visibility */
    border-right: 1px solid #E2E8F0; /* Vertical structure */
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.report-premium-table tbody td:last-child {
    border-right: none;
}

/* Action Column Alignment */
.report-premium-table tbody td.action-cell {
    text-align: right;
    width: 6rem;
}

/* Row Hover and Striping */
.report-premium-table tbody tr:nth-child(even) { background-color: #FAFAF9; }
.report-premium-table tbody tr:hover td { background-color: #F8FAFC; }



/* PAGINATION STYLING */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-top: 1px solid #E2E8F0; /* Separator from table */
    border-radius: 0 0 12px 12px;
}

.pagination-info {
    color: #64748B;
    font-size: 0.85rem;
    font-weight: 500;
}

.pagination-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
}

.page-display {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    padding: 0 0.5rem;
    min-width: 3rem;
    text-align: center;
}


.pagination-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
    background: #FFFFFF;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-actions button:hover:not(:disabled) {
    background: #F8FAFC;
    color: #0F172A;
    border-color: #CBD5E1;
}

.pagination-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #F8FAFC;
}

/* MOBILE RESPONSIVE TWEAKS */
.mobile-controls-row {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

@media (max-width: 1024px) {
    .header-toolbar { flex-wrap: wrap; gap: 1rem; }
    .search-bar-wrapper { order: 3; max-width: 100%; flex-basis: 100%; }
}

@media (max-width: 768px) {
    .header-text-wrapper { display: none; }
    .mobile-controls-row { display: flex; }
    .btn-action .btn-text { display: none; }
    .btn-action { padding: 0; min-width: 0; }
    .header-actions { flex: 1; justify-content: space-between; }
    .hidden-mobile { display: none; }
}

/* Layout constraints to prevent body scroll and center table */
.report-viewer-root .content-area {
    overflow: hidden !important; /* Stop page from scrolling */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center horizontally */
    padding-bottom: 2rem; /* Increased bottom padding to precisely match the top spacing */
    flex-grow: 1;
    min-height: 0;
}

/* Override for pages that DO need to scroll the whole page */
.report-viewer-root .content-area.scrollable-content {
    overflow-y: auto !important;
    overflow-x: hidden;
    display: flex; /* Keep flex context */
    flex-direction: column;
    flex-grow: 1;
    height: 0; /* Let flex-grow handle height */
    min-height: 0;
}

/* Custom Container for Report Viewer */
.report-viewer-container {
    width: 100%;
    max-width: 98%; /* Centered beautifully instead of 98% wide */
    padding: 0;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0; /* Fill space flexibly */
}

/* Fix flexbox chain broken by animation wrapper */
.report-viewer-container > .animate-slide-in-up {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    width: 100%;
}

.report-viewer-bg {
    background-color: #F8FAFC !important; /* Soft white/light grey for contrast */
}

/* --- BUTTONS FOR DARK HEADER --- */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.btn-action i {
    width: 0.95rem;
    height: 0.95rem;
}

/* Primary Action Button (Dark on White) */
.btn-calcola {
    background: var(--brand-primary);
    color: white;
}
.btn-calcola:hover {
    background: var(--brand-hover);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Secondary Action Button (Outline on White) */
.btn-assenza {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-assenza:hover:not(:disabled) {
    background: #F8FAFC;
    color: var(--brand-primary);
    border-color: var(--brand-accent);
}
.btn-assenza:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #F1F5F9;
    color: #94A3B8;
    border-color: #E2E8F0;
}

/* Header Vertical Divider */
.header .nav-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--border-color);
}

/* ==========================================================================
   GLOBAL NOTIFICATION SYSTEM (Toasts & Popup Alerts)
   ========================================================================== */

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

/* Toast Item */
.toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
    transform: translateX(20px); /* Minimal move */
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(10px); opacity: 0; }

.toast-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 10px; flex-shrink: 0; }
.toast-success .toast-icon { color: #10B981; background: #ECFDF5; }
.toast-error .toast-icon { color: #EF4444; background: #FEF2F2; }
.toast-info .toast-icon { color: #3B82F6; background: #EFF6FF; }

.toast-message { font-family: var(--font-sans); font-size: 14px; font-weight: 600; color: #1E293B; margin: 0; flex-grow: 1; }
.toast-close { background: transparent; border: none; color: #94A3B8; cursor: pointer; padding: 4px; border-radius: 50%; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.toast-close:hover { background: #F1F5F9; color: #64748B; }

/* Popup Alerts (Centered Modals) */
.popup-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.15s ease;
    padding: 16px;
}

.popup-overlay.hidden { opacity: 0; pointer-events: none; }

.popup-card {
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    transform: scale(1);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.popup-overlay.hidden .popup-card { transform: scale(0.98) translateY(5px); }

.popup-alert .popup-body { padding: 32px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.popup-alert-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.popup-alert-icon i { width: 32px; height: 32px; }
.popup-alert-title { font-family: var(--font-brand); font-size: 20px; font-weight: 700; color: #0F172A; margin: 0; }
.popup-alert-message { font-size: 14px; color: #64748B; line-height: 1.6; margin: 0; }

.alert-success .popup-alert-icon { background: #ECFDF5; color: #10B981; }
.alert-error .popup-alert-icon { background: #FEF2F2; color: #EF4444; }
.alert-warning .popup-alert-icon { background: #FFFBEB; color: #F59E0B; }
.alert-info .popup-alert-icon { background: #EFF6FF; color: #3B82F6; }

.popup-footer { display: flex; gap: 12px; padding: 20px 24px; background: #F8FAFC; border-top: 1px solid #F1F5F9; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; }
.btn-popup-primary { flex: 1; padding: 12px; background: #0F172A; color: #FFF; border: none; border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s; }
.btn-popup-primary:hover { background: #1E293B; transform: translateY(-1px); }
.btn-popup-secondary { flex: 1; padding: 12px; background: #FFF; color: #64748B; border: 1px solid var(--border-color); border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s; }
.btn-popup-secondary:hover { background: #F1F5F9; color: #1E293B; }

