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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

.header {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.login-form, .main-app {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tabs {
    display: flex;
    margin-bottom: 30px;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 15px;
    padding: 8px;
    backdrop-filter: blur(10px);
    overflow-x: auto;
    gap: 5px;
}

.tab {
    flex: 1;
    min-width: 120px;
    padding: 15px 20px;
    text-align: center;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
}

.tab:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 25px;
}

.form-group.flex-2 {
    flex: 2;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

input, select, textarea {
    width: 100%;
    padding: 15px 18px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: white;
    transform: translateY(-1px);
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 10px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    padding: 8px 16px;
    font-size: 14px;
}

.btn-success {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
    padding: 8px 16px;
    font-size: 14px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    margin: 2px;
}

.card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.12);
}

.card h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 700;
}

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

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

.search-box input {
    padding-right: 45px;
    margin: 0;
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #999;
}

.scrollable-list {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.scrollable-list::-webkit-scrollbar {
    width: 6px;
}

.scrollable-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.scrollable-list::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    border-radius: 15px;
    margin-bottom: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.list-item:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    background: rgba(255, 255, 255, 0.9);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

.stat-card.expenses {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.stat-card.collected {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.stat-card.balance {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.stat-card.total-owed {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

.stat-card.total-advance {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-label {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
}

.stat-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    opacity: 0.3;
}

.payments-list {
    display: grid;
    gap: 15px;
}

.payment-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 20px;
    align-items: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.payment-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    background: rgba(255, 255, 255, 0.9);
}

.payment-info h4 {
    margin-bottom: 5px;
    color: #333;
}

.payment-info p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.payment-status {
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    min-width: 120px;
}

.status-paid {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.status-pending {
    background: linear-gradient(135deg, #f8d7da 0%, #f1aeb5 100%);
    color: #721c24;
}

.status-overpaid {
    background: linear-gradient(135deg, #cce5ff 0%, #99d6ff 100%);
    color: #0066cc;
}

.payment-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.quick-payment {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.quick-payment input {
    width: 100px;
    padding: 8px 12px;
    margin: 0;
    font-size: 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.summary-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 25px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}

.summary-card h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
    font-weight: 700;
}

.summary-card p {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.summary-card p:last-child {
    border-bottom: none;
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid rgba(102, 126, 234, 0.2);
}

.hidden {
    display: none !important;
}

.euro {
    color: #28a745;
    font-weight: bold;
}

.debt {
    color: #dc3545;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .login-form, .main-app {
        padding: 25px;
    }
    
    .tabs {
        flex-direction: column;
        gap: 8px;
    }
    
    .tab {
        min-width: auto;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group {
        min-width: auto;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .payment-item {
        grid-template-columns: 1fr;
        gap: 15px;
        text-align: center;
    }
    
    .payment-controls {
        align-items: center;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-payment {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .login-form, .main-app {
        padding: 20px;
    }
    
    .card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    button {
        padding: 12px 20px;
        font-size: 14px;
    }
}

.file-input {
    border: 2px dashed #ddd;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.expense-details {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: start;
}

.expense-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

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

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #667eea;
}

.receipt-preview {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.resident-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.resident-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
    background: rgba(255, 255, 255, 0.95);
}

.resident-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.resident-main {
    flex: 1;
}

.resident-name {
    color: #667eea;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.resident-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.resident-apartment,
.resident-phone {
    color: #666;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.resident-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

/* Responsive per le card residenti */
@media (max-width: 768px) {
    .resident-info {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .resident-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .resident-details {
        gap: 8px;
    }
}

/* Edit Resident Modal Styles */
.edit-resident-modal {
    max-width: 500px;
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.edit-resident-form {
    padding: 10px 0;
}

.edit-resident-form .form-group {
    margin-bottom: 25px;
}

.edit-resident-form label {
    color: #667eea;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.edit-resident-form input {
    border: 2px solid #e9ecef;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 16px;
    padding: 15px 20px;
}

.edit-resident-form input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid rgba(102, 126, 234, 0.1);
}

.modal-actions button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 25px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 140px;
    justify-content: center;
}

.modal-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.modal-actions .btn-success {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
}

.modal-actions .btn-success:hover {
    box-shadow: 0 8px 25px rgba(81, 207, 102, 0.4);
}

.modal-actions .btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
}

.modal-actions .btn-secondary:hover {
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

/* Success Toast */
.success-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(81, 207, 102, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-icon {
    font-size: 18px;
}

.toast-message {
    font-weight: 600;
    font-size: 14px;
}

/* Modal overlay enhancement */
.modal {
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive per la modale di modifica */
@media (max-width: 768px) {
    .edit-resident-modal {
        max-width: 90%;
        margin: 10% auto;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions button {
        min-width: auto;
        width: 100%;
    }
    
    .success-toast {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }
    
    .success-toast.show {
        transform: translateY(0);
    }
}