:root {
    --primary-color: #4a90e2;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --bg-color: #f4f7f6;
    --text-color: #333;
    --card-bg: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

/* Login Section */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--bg-color);
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.login-card p {
    color: #666;
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.user-badge {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

#user-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

#btn-login-google {
    background-color: white;
    color: #757575;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

#btn-login-google:hover {
    background-color: #f8f9fa;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    opacity: 1;
}

.btn-logout-link {
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
    font-size: 0.85rem;
}

.main-header {
    text-align: center;
    margin-bottom: 30px;
}

.main-header h1 {
    font-weight: 700;
    color: #2c3e50;
    font-size: 1.8rem;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 50px;
}

/* Hide header in app container if main-header used */
#app-container header:not(.main-header) {
    display: none;
}

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.summary-card.total { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.summary-card.daily { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.summary-card.monthly { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.summary-card.yearly { background: linear-gradient(135deg, #e67e22, #d35400); }
.summary-card.income { background: linear-gradient(135deg, #1abc9c, #16a085); }
.summary-card.monthly-income { background: linear-gradient(135deg, #1abc9c, #16a085); }
.summary-card.balance { background: linear-gradient(135deg, #34495e, #2c3e50); }
.summary-card.monthly-balance { background: linear-gradient(135deg, #8e44ad, #7d3c98); }

.section-title {
    margin-top: 40px;
    margin-bottom: 15px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 5px;
}

.section-title h2 {
    font-size: 1.3rem;
    color: #2c3e50;
}

.summary-card h3 {
    font-size: 0.9rem;
    font-weight: 400;
    margin-bottom: 5px;
    opacity: 0.9;
}

.summary-card p {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.action-bar button {
    flex: 1;
    min-width: 160px;
    white-space: nowrap;
}

/* Banner */
.banner {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Archive Section */
.archive-section {
    margin-top: 50px;
    margin-bottom: 50px;
}

.archive-section h2 {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.btn-pdf {
    background-color: #f39c12;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.btn-pdf:hover {
    background-color: #e67e22;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-danger {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
    font-size: 0.9rem;
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-success { background-color: var(--success-color); color: white; }
.btn-danger { background-color: var(--danger-color); color: white; }

.btn-primary:hover, .btn-secondary:hover, .btn-success:hover, .btn-danger:hover {
    opacity: 0.9;
}

/* Table Container */
.table-container {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll on very small screens */
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f8f9fa;
    color: #555;
    font-weight: 600;
}

.btn-delete {
    padding: 5px 10px;
    background-color: #fff1f0;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-delete:hover {
    background-color: var(--danger-color);
    color: white;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease-out;
}

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

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

.close-modal, .close-modal-income {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #888;
}

.close-modal:hover, .close-modal-income:hover { color: #333; }

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* Form Styling */
.record-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    position: relative;
    border: 1px solid #ddd;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #666;
}

.form-group input, .form-group select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

#btn-add-row {
    width: 100%;
    margin-top: 10px;
    margin-bottom: 10px;
}

.btn-remove-row {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    .container { padding: 10px; }
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .action-bar {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main-header h1 { font-size: 1.4rem; }
    .summary-grid { grid-template-columns: 1fr; }
    
    .action-bar {
        flex-direction: column;
    }
    
    .action-bar button {
        width: 100%;
        min-width: 100%;
    }

    .summary-card p { font-size: 1.3rem; }
    
    .modal-content {
        width: 95%;
        margin: 10px auto;
    }

    .record-row {
        grid-template-columns: 1fr;
    }

    .modal-footer button {
        width: 100%;
    }
}
