:root {
    --bg-color: #0F172A;
    --sidebar-bg: rgba(15, 23, 42, 0.8);
    --card-bg: rgba(30, 41, 59, 0.6);
    --topbar-bg: rgba(15, 23, 42, 0.7);
    --text-color: #F8FAFC;
    --accent-color: #38BDF8;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --secondary-text: #94A3B8;
    --hover-bg: rgba(56, 189, 248, 0.1);
    --sidebar-width: 220px;
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

.hidden {
    display: none !important;
}

.impersonation-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #ca8a04;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent global horizontal scroll */
    position: relative;
    -webkit-overflow-scrolling: touch;
}

body {
    display: flex;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    text-decoration: none;
    color: var(--secondary-text);
    border-radius: 0.5rem;
    transition: var(--transition);
    margin-bottom: 0.3rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background-color: var(--hover-bg);
    color: var(--accent-color);
}

.sidebar-nav a i {
    width: 20px;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--secondary-text);
    font-size: 0.8rem;
    text-align: center;
}

/* Main Content Styling */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.top-bar {
    height: 70px;
    background-color: var(--topbar-bg);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.top-bar h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.report-hero {
    background: var(--card-bg);
    border-radius: 1.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.report-hero.compact {
    padding: 1.5rem 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.report-hero-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.report-info-main {
    flex: 1;
}

.report-header-line {
    display: flex;
    align-items: center;
}

.report-stats-grid {
    display: flex;
    gap: 2.5rem;
}

.stat-mini {
    display: flex;
    flex-direction: column;
}

.stat-mini-label {
    font-size: 0.7rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-mini-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
}

.action-buttons-compact {
    display: flex;
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .report-hero-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .report-stats-grid {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap; /* Allow wrapping on very small screens */
        gap: 0.5rem;
    }
}

.report-hero-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.report-title-area h2 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
    color: white;
}

.report-stats-strip {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--secondary-text);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary-text);
}

.content-body {
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.welcome-card {
    background: linear-gradient(135deg, #161D24 0%, #111419 100%);
    padding: 2rem 3rem;
    border-radius: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.welcome-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-color) 0%, transparent 70%);
    opacity: 0.1;
    pointer-events: none;
}

.welcome-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-color), #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.dashboard-layout {
    grid-template-columns: 350px 1fr;
    align-items: flex-start;
}

@media (max-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background-color: var(--card-bg);
    backdrop-filter: blur(12px);
    padding: 2rem;
    border-radius: 1.25rem;
    border: var(--glass-border);
    transition: var(--transition);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: rgba(56, 189, 248, 0.3);
    transform: translateY(-2px);
}

.card h3 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent-color);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.online {
    background-color: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-accent {
    color: var(--accent-color);
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mr-1 { margin-right: 1rem; }
.mr-2 { margin-right: 2rem; }
.ml-1 { margin-left: 1rem; }

.report-header-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #0EA5E9 0%, #38BDF8 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(56, 189, 248, 0.39);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #38BDF8 0%, #7DD3FC 100%);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.gap-05 {
    gap: 0.5rem;
}

.justify-end {
    justify-content: flex-end;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for modern browsers */
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overscroll-behavior: contain; /* Prevent scroll chaining to the background */
}

.modal {
    background: #1E293B; /* Solid background for better readability */
    width: 100%;
    max-width: 500px;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    max-height: 90dvh;
    min-height: 400px; /* Minimum height for desktop */
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    padding: 0 !important; /* Moved padding to children for better scroll behavior */
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 1rem;
        align-items: center; 
    }
    .modal {
        height: 92dvh; /* Increased height to use more screen space */
        max-height: 92dvh;
        border-radius: 1.5rem;
        margin: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    .modal-header { padding: 1.25rem !important; }
    .modal-header .btn-danger {
        padding: 0.6rem 0.8rem !important;
        min-width: 0;
    }
    .modal-body { 
        padding-left: 1.25rem !important;
        padding-right: 0.75rem !important;
        padding-bottom: 3rem !important;
        margin-right: 0 !important;
    }
    .modal-footer { 
        padding: 1rem 1.5rem 1.5rem 1.5rem !important;
        background: #1e293b; /* Solid footer background */
        border-top: 1px solid rgba(255,255,255,0.05);
        margin-top: auto; 
    }
}

.modal-body {
    flex: 1 1 auto; /* Using auto instead of 0 for correct intrinsic basis */
    overflow-y: auto;
    padding: 0 2rem 2rem 2rem; /* Added missing side and bottom padding */
    min-height: 0; /* Ensures the flex child can shrink */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; /* Prevent scroll chaining to the background */
}

/* Custom scrollbar for modal-body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

body.no-scroll {
    overflow: hidden !important;
    height: 100vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    flex-shrink: 0;
}

.modal-footer {
    padding: 1.5rem 2rem;
    flex-shrink: 0;
    background: #1E293B; /* Ensure solid background even on desktop */
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--secondary-text);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%; /* Prevent stretching */
    height: 44px;
    padding: 0 1rem;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    border: var(--glass-border);
    border-radius: 0.85rem;
    color: white;
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    box-sizing: border-box;
    display: block;
}

@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

textarea {
    height: auto;
    min-height: 80px;
    padding: 0.75rem 1.15rem;
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%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 1rem center;
    background-size: 1.25em;
    padding-right: 2.5rem !important;
    appearance: none;
}

select option {
    background-color: #111419;
    color: white;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

input[type="date"] {
    color-scheme: dark !important;
    display: flex;
    align-items: center;
    appearance: none;
    -webkit-appearance: none;
    min-width: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>') no-repeat;
    background-size: contain;
    width: 1.2rem;
    height: 1.2rem;
    filter: none !important;
    opacity: 0.8;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    background: var(--card-bg);
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 100%;
}

table {
    width: 100%;
    min-width: 450px; /* Force minimum width to allow scrolling on mobile instead of chopping */
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

td {
    font-size: 0.85rem;
}

th {
    color: var(--secondary-text);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.receipt-preview-container {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.receipt-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.receipt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(56, 189, 248, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: var(--transition);
    color: white;
    font-size: 0.8rem;
}

.receipt-preview-container:hover .receipt-overlay {
    opacity: 1;
}

.receipt-preview-container:hover .receipt-thumbnail {
    transform: scale(1.1);
}

.badge.archived {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-xs {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 0.4rem;
}

/* Expense List */
.expense-item {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.expense-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.category-icon {
    width: 40px;
    height: 40px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-radius: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.amount {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Login Page */
.auth-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    background: var(--card-bg);
    border-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Receipt Upload */
.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.05);
}

/* Mobile Styling */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 10px 25px rgba(56, 189, 248, 0.4);
    z-index: 1100;
    cursor: pointer;
    font-size: 1.5rem;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 50px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
        display: flex;
        flex-direction: column;
    }

    .top-bar {
        padding: 0 1rem;
    }

    .top-bar h1 {
        font-size: 1.1rem;
    }

    .mobile-toggle {
        display: flex;
    }

    .welcome-card {
        padding: 2rem;
    }

    .welcome-card h2 {
        font-size: 1.5rem;
    }

    .content-body {
        padding: 0.75rem; /* Reduced padding to give more space to children */
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .flex-col-mobile {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .flex-col-mobile > div {
        max-width: 100% !important;
    }
    
    .full-w-mobile {
        width: 100% !important;
    }
    
    /* Resize automatico per griglie (evita affiancamento sui form OCR etc) */
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Modal fluidi e adattabili */
    .modal {
        padding: 1rem;
        margin: 0.5rem;
        width: calc(100% - 1rem);
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .modal-overlay {
        padding: 0;
        display: flex;
        align-items: flex-start; /* Start from top on mobile to ensure visibility */
        padding-top: 1rem;
    }
    
    /* Pulsanti ottimizzati per il Touch (iPhone / Smartphone) */
    .btn {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        justify-content: center;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-sm {
        width: auto;
        padding: 0.8rem 1rem;
        font-size: 1rem;
        margin-bottom: 0;
    }
    
    .btn-xs {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
        width: auto;
        margin-bottom: 0;
    }
    
    /* Input più grandi per i tap */
    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    /* Extra compaction for OCR form specifically */
    #ocrForm .form-group {
        margin-bottom: 0.5rem;
    }

    #ocrForm input, #ocrForm select {
        padding: 0 0.75rem;
        height: 38px;
        width: 100% !important;
        box-sizing: border-box;
    }

    #ocrDate {
        /* Force no unusual padding on the date field specifically */
        min-width: 0;
        flex: 1;
    }
    
    /* Ridimensionamento bottoni di intestazione della report-hero compact */
    .action-buttons-compact {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }
    
    .action-buttons-compact .btn {
        width: 100%;
        margin-bottom: 0;
    }
    
    .action-buttons-compact .btn[title="Esporta PDF"] {
        grid-column: span 2;
    }
    
    /* Allinea la hero report per evitare che si sovrapponga a pulsanti troppo grandi */
    .report-hero-content {
        align-items: stretch;
        text-align: center;
    }
    
    .report-header-line {
        justify-content: center;
    }
    
    .report-stats-grid {
        justify-content: space-around;
        margin: 1rem 0;
        gap: 0.5rem;
    }

    /* Fix Dashboard specifically */
    #dashboardPage {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .report-hero.compact {
        padding: 1rem;
        margin: 0.5rem;
        width: calc(100% - 1rem); /* Force it to stay inside margins */
        box-sizing: border-box;
    }

    .card {
        padding: 0.75rem;
        margin: 0.5rem;
        width: calc(100% - 1rem);
        box-sizing: border-box;
        overflow: hidden; /* Ensure card itself doesn't grow */
    }

    .dashboard-header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden; /* Prevent title from pushing out */
    }

    .dashboard-header h3 {
        font-size: 1rem;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1; /* Title takes remaining space but can be cut */
        min-width: 0;
    }

    .dashboard-header .btn {
        flex-shrink: 0;
        width: auto !important;
        padding: 0.4rem 0.6rem !important; /* Even more compact */
        font-size: 0.8rem !important;
        margin: 0 !important;
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }

    .table-container {
        display: block;
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-top: 1rem;
        border-radius: 0.5rem;
    }

    table {
        min-width: 500px; /* Force minimum width to guarantee scrollability on mobile */
    }

    /* Mobile OCR Preview optimization */
    #ocrImagePreview {
        min-height: 100px !important;
        max-height: 180px;
        margin-bottom: 0.5rem;
    }

    #highlightedImg {
        max-height: 180px !important;
    }

    #ocrVerifyStep p {
        display: none; /* Hide instructions to save space */
    }

    /* Table compaction for mobile (DASHBOARD) */
    #fullExpensesTable th:nth-child(4), #fullExpensesTable td:nth-child(4), /* Categoria */
    #fullExpensesTable th:nth-child(5), #fullExpensesTable td:nth-child(5)  /* KM */ {
        display: none;
    }

    #fullExpensesTable td:nth-child(3) { /* Descrizione */
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Table compaction for mobile (TUTTE LE NOTE) */
    #allReportsTable th:nth-child(3), #allReportsTable td:nth-child(3) { /* Data Creazione */
        display: none;
    }
    
    #allReportsTable td:nth-child(2) { /* Titolo */
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table-container {
        margin-top: 0.5rem;
        padding: 0;
    }
}

/* Inline Editing */
.editable {
    cursor: pointer;
    transition: background 0.2s;
}

.editable:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.edit-input {
    width: 100%;
    background: #111419;
    border: 1px solid var(--accent-color);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    outline: none;
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.2);

}

/* Search Suggestions */
.search-container {
    position: relative;
    width: 100%;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    z-index: 2100;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin-top: 5px;
    backdrop-filter: blur(10px);
}

.search-suggestion-item {
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestion-item:hover {
    background: rgba(56, 189, 248, 0.1);
}

.search-suggestion-item .suggestion-name {
    font-weight: 600;
    color: var(--accent-color);
}

.search-suggestion-item .suggestion-address {
    font-size: 0.75rem;
    color: var(--secondary-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}