* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fff; /* ← Sfondo bianco pieno */
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.logo {
    font-size: 26px;
    font-weight: 700;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
}

/* Navigation Menu */
.navigation-menu {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px 25px;
    margin-bottom: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.nav-tabs {
    display: flex;
    gap: 15px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
    overflow-x: auto;
    flex-wrap: wrap;
}

.nav-tab {
    padding: 12px 20px;
    background: rgba(255,255,255,0.7);
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #4a5568;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-tab:hover {
    background: rgba(66, 153, 225, 0.1);
    border-color: #4299e1;
    color: #2d3748;
    transform: translateY(-2px);
}

.nav-tab.active {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    border-color: #3182ce;
    color: white;
    box-shadow: 0 4px 15px rgba(65, 153, 225, 0.3);
}

.nav-tab.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(65, 153, 225, 0.4);
}

/* Page Content */
.page-content {
    display: none;
}

.page-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.card h3 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

/* Dashboard Stats */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin: 15px 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.stat-label {
    color: #718096;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.entrate { 
    color: #38a169;
    background: linear-gradient(135deg, #68d391, #38a169);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.uscite { 
    color: #e53e3e;
    background: linear-gradient(135deg, #fc8181, #e53e3e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.saldo { 
    color: #3182ce;
    background: linear-gradient(135deg, #63b3ed, #3182ce);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(65, 153, 225, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(65, 153, 225, 0.4);
}

.btn-success { 
    background: linear-gradient(135deg, #48bb78, #38a169);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

.btn-danger { 
    background: linear-gradient(135deg, #f56565, #e53e3e);
    box-shadow: 0 4px 15px rgba(245, 101, 101, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(245, 101, 101, 0.4);
}

.btn-secondary { 
    background: linear-gradient(135deg, #a0aec0, #718096);
    box-shadow: 0 4px 15px rgba(160, 174, 192, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(160, 174, 192, 0.4);
}

/* Small buttons */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    text-transform: none;
    letter-spacing: normal;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: rgba(255,255,255,0.9);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 550px;
    margin: 20px auto;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlide 0.3s ease;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    position: relative;
}

/* Modal per visualizzazione transazioni - più largo */
.modal-content.transactions-modal {
    max-width: 95%;
    width: 95%;
    margin: 10px auto;
    padding: 20px;
}

/* Container scrollabile per tabelle nelle modal */
.modal-table-container {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 15px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h3 {
    color: #2d3748;
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.close {
    font-size: 28px;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.3s ease;
}

.close:hover {
    color: #e53e3e;
}

/* NUOVE REGOLE RESPONSIVE PER TABELLE */

/* Container principale per tabelle responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Migliora lo scroll su iOS */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
    background: white;
}

/* Table base styles (manteniamo quelle esistenti) */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0; /* Rimuovi margin che può creare problemi */
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none; /* Rimuovi box-shadow qui, lo mettiamo sul container */
    min-width: 700px; /* Larghezza minima per evitare compressione eccessiva */
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
    white-space: nowrap; /* Evita che il testo vada a capo */
}

.table th {
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    font-weight: 600;
    color: #2d3748;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
    position: sticky; /* Mantiene le intestazioni visibili durante lo scroll orizzontale */
    top: 0;
    z-index: 10;
}

.table tbody tr:hover {
    background: #f7fafc;
    transition: background 0.2s ease;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 50px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 450px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.login-title {
    text-align: center;
    margin-bottom: 40px;
    font-size: 32px;
    color: #2d3748;
    font-weight: 700;
}

/* Messages */
.error {
    background: linear-gradient(135deg, #fed7d7, #feb2b2);
    color: #c53030;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid #e53e3e;
}

.success {
    background: linear-gradient(135deg, #c6f6d5, #9ae6b4);
    color: #22543d;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid #38a169;
}

/* Utilities */
.hidden { 
    display: none !important; 
}

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

.flex {
    display: flex;
}

.gap-10 {
    gap: 10px;
}

.gap-15 {
    gap: 15px;
}

.mt-15 {
    margin-top: 15px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Action buttons container */
.actions-container {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Transaction type badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.badge-entrata {
    background: #c6f6d5;
    color: #22543d;
}

.badge-uscita {
    background: #fed7d7;
    color: #c53030;
}

/* Category management */
.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.8);
    transition: all 0.2s ease;
}

.category-item:hover {
    background: rgba(255,255,255,1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-item .category-info {
    flex: 1;
}

.category-item .category-actions {
    display: flex;
    gap: 8px;
}

/* Categories grid */
.categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Section headers */
.section-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.section-header h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pagination controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px 0;
    border-top: 2px solid #e2e8f0;
}

.pagination-info {
    color: #718096;
    font-size: 14px;
}

.pagination-buttons {
    display: flex;
    gap: 10px;
}

.pagination-buttons .btn {
    padding: 8px 16px;
    font-size: 12px;
}

.pagination-buttons .btn:disabled {
    background: #e2e8f0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pagination-buttons .btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Table actions column */
.table .actions-column {
    width: 120px;
    text-align: center;
    white-space: nowrap; /* Importante per i pulsanti azioni */
}

.table .actions-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

/* Main page controls */
.main-table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.main-table-controls .left-controls,
.main-table-controls .right-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.entries-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.entries-selector select {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
}

/* MEDIA QUERIES RESPONSIVE */

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 20px;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .actions-container {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
    
    .login-card {
        padding: 30px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .modal-content {
        margin: 10px auto;
        padding: 20px;
        width: 95%;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    /* TABELLE RESPONSIVE SU MOBILE */
    
    /* Riduci padding celle su mobile */
    .table th,
    .table td {
        padding: 8px 6px;
        font-size: 13px;
    }
    
    /* Riduci larghezza minima su mobile per permettere più compressione */
    .table {
        min-width: 600px;
    }
    
    /* Colonna azioni più stretta su mobile */
    .table .actions-column {
        width: 80px;
    }
    
    /* Pulsanti azioni più piccoli su mobile */
    .table .actions-buttons .btn {
        padding: 3px 6px;
        font-size: 11px;
    }
    
    .category-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .category-item .category-actions {
        align-self: flex-end;
    }
    
    /* Mobile responsive per navigation */
    .nav-tabs {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-tab {
        justify-content: center;
        width: 100%;
    }
    
    /* Controlli tabella responsive su mobile */
    .main-table-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .main-table-controls .left-controls,
    .main-table-controls .right-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Paginazione responsive */
    .pagination-controls {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .pagination-info {
        font-size: 12px;
    }
    
    .pagination-buttons .btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .logo {
        font-size: 18px;
    }
    
    .logo img {
        height: 36px !important;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .card {
        padding: 15px;
    }
    
    /* Tabelle ancora più compatte su schermi molto piccoli */
    .table {
        min-width: 500px;
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    .table .actions-column {
        width: 70px;
    }
    
    .table .actions-buttons {
        flex-direction: column;
        gap: 2px;
    }
    
    .table .actions-buttons .btn {
        padding: 2px 4px;
        font-size: 10px;
        min-width: auto;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* Badge più piccoli */
    .badge {
        padding: 4px 8px;
        font-size: 10px;
    }
}

/* INDICATORI SCROLL PER MIGLIORE UX */

/* Aggiungi un'ombra per indicare che si può scrollare orizzontalmente */
.table-responsive {
    position: relative;
}

.table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, rgba(255,255,255,0.8), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Su mobile, mostra sempre l'indicatore di scroll */
@media (max-width: 768px) {
    .table-responsive::after {
        opacity: 1;
    }
}

/* Migliora la scrollbar su Webkit browsers */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}