/* Login Required Message */
.cfm-login-required {
    background: #fff;
    border: 2px solid #2271b1;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    margin: 40px auto;
}

.cfm-login-required p {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
}

.cfm-login-button {
    display: inline-block;
    background: #2271b1;
    color: #fff !important;
    padding: 12px 30px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.3s ease;
}

.cfm-login-button:hover {
    background: #135e96;
}

/* Frontend Form Container */
.cfm-frontend-form-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 700px;
    margin: 20px auto;
    padding: 30px;
}

.cfm-form-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #2271b1;
}

.cfm-form-header h2 {
    color: #2271b1;
    margin: 0 0 10px 0;
    font-size: 28px;
}

.cfm-form-description {
    color: #666;
    margin: 0;
    font-size: 16px;
}

/* Frontend Form Styles */
.cfm-frontend-form {
    margin-top: 20px;
}

.cfm-form-row {
    margin-bottom: 20px;
}

.cfm-form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.cfm-form-row input[type="text"],
.cfm-form-row input[type="number"],
.cfm-form-row input[type="date"],
.cfm-form-row select,
.cfm-form-row textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.cfm-form-row input:focus,
.cfm-form-row select:focus,
.cfm-form-row textarea:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.cfm-form-row textarea {
    resize: vertical;
    font-family: inherit;
}

.cfm-field-note {
    display: block;
    margin-top: 6px;
    color: #666;
    font-size: 13px;
    font-style: italic;
}

/* Form Actions */
.cfm-form-actions {
    margin-top: 30px;
    text-align: center;
}

.cfm-submit-button {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 14px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.cfm-submit-button:hover {
    background: #135e96;
}

.cfm-submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.cfm-spinner {
    animation: spin 1s linear infinite;
    font-size: 18px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Messages */
#cfm-frontend-income-message,
#cfm-frontend-expense-message {
    margin-top: 20px;
}

.cfm-success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

.cfm-error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

/* Frontend Dashboard */
.cfm-frontend-dashboard {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 30px;
    max-width: 1200px;
    margin: 20px auto;
}

.cfm-dashboard-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #2271b1;
}

.cfm-dashboard-header h2 {
    color: #2271b1;
    margin: 0 0 10px 0;
    font-size: 32px;
    font-weight: 700;
}

.cfm-dashboard-subtitle {
    color: #666;
    margin: 0;
    font-size: 16px;
}

/* Quick Stats Bar - Frontend Improved */
.cfm-quick-stats-front {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
    padding: 0;
}

.quick-stat-box {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

.quick-stat-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-color: #2271b1;
}

.quick-stat-box .stat-icon {
    font-size: 42px;
    line-height: 1;
    flex-shrink: 0;
}

.quick-stat-box .stat-content {
    flex: 1;
}

.quick-stat-box .stat-number {
    font-size: 28px;
    font-weight: 800;
    color: #2271b1;
    line-height: 1.2;
    margin-bottom: 5px;
}

.quick-stat-box .stat-text {
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 5px;
    font-weight: 600;
}

.quick-stat-box.healthy .stat-number {
    color: #00a32a;
}

.quick-stat-box.warning .stat-number {
    color: #dba617;
}

.quick-stat-box.danger .stat-number {
    color: #d63638;
}

/* Stats Container */
.cfm-stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.cfm-stat-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
}

.cfm-stat-section h3 {
    color: #2271b1;
    margin: 0 0 20px 0;
    font-size: 20px;
    text-align: center;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 2px solid #2271b1;
}

.cfm-stat-section.prev-month {
    opacity: 0.85;
}

.cfm-stat-section.prev-month h3 {
    color: #666;
}

.cfm-stat-section.ytd {
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
}

.cfm-stat-section.ytd h3 {
    color: #1565c0;
    border-bottom-color: #1565c0;
}

.cfm-stat-grid {
    display: grid;
    gap: 12px;
}

.cfm-stat-item {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #ddd;
    transition: all 0.3s ease;
}

.cfm-stat-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.cfm-stat-item.income {
    border-left-color: #00a32a;
    background: linear-gradient(90deg, #e8f5e9 0%, #fff 100%);
}

.cfm-stat-item.expense {
    border-left-color: #d63638;
    background: linear-gradient(90deg, #ffebee 0%, #fff 100%);
}

.cfm-stat-item.balance.positive {
    border-left-color: #00a32a;
    background: linear-gradient(90deg, #e8f5e9 0%, #fff 100%);
}

.cfm-stat-item.balance.negative {
    border-left-color: #d63638;
    background: linear-gradient(90deg, #ffebee 0%, #fff 100%);
}

.stat-label {
    font-size: 14px;
    color: #666;
    font-weight: 600;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.cfm-stat-item.income .stat-value {
    color: #00a32a;
}

.cfm-stat-item.expense .stat-value {
    color: #d63638;
}

.cfm-stat-item.balance.positive .stat-value {
    color: #00a32a;
}

.cfm-stat-item.balance.negative .stat-value {
    color: #d63638;
}

/* Growth Badges */
.growth-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 12px;
    vertical-align: middle;
}

.growth-badge.positive {
    background: #e8f5e9;
    color: #00a32a;
}

.growth-badge.negative {
    background: #ffebee;
    color: #d63638;
}

/* Budget Allocation Section */
.cfm-budget-section {
    background: linear-gradient(135deg, #f0f6fc 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 2px solid #2271b1;
}

.cfm-budget-section h3 {
    color: #2271b1;
    margin: 0 0 25px 0;
    font-size: 24px;
    text-align: center;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 3px solid #2271b1;
}

.cfm-allocation-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.cfm-allocation-item {
    background: #fff;
    border-radius: 12px;
    padding: 25px 20px;
    text-align: center;
    border: 3px solid #e0e0e0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}

.cfm-allocation-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, transparent, currentColor, transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cfm-allocation-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.cfm-allocation-item:hover::before {
    opacity: 1;
}

.cfm-allocation-item.tithe {
    border-color: #9b59b6;
    color: #9b59b6;
}

.cfm-allocation-item.tithe:hover {
    background: linear-gradient(135deg, #f4ecf7 0%, #fff 100%);
}

.cfm-allocation-item.savings {
    border-color: #27ae60;
    color: #27ae60;
}

.cfm-allocation-item.savings:hover {
    background: linear-gradient(135deg, #e8f8f5 0%, #fff 100%);
}

.cfm-allocation-item.salaries {
    border-color: #3498db;
    color: #3498db;
}

.cfm-allocation-item.salaries:hover {
    background: linear-gradient(135deg, #ebf5fb 0%, #fff 100%);
}

.cfm-allocation-item.expendable {
    border-color: #e67e22;
    color: #e67e22;
}

.cfm-allocation-item.expendable:hover {
    background: linear-gradient(135deg, #fef5e7 0%, #fff 100%);
}

.cfm-allocation-item.emergency {
    border-color: #d63638;
    color: #d63638;
}

.cfm-allocation-item.emergency:hover {
    background: linear-gradient(135deg, #ffebee 0%, #fff 100%);
}

.allocation-icon {
    font-size: 56px;
    margin-bottom: 12px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.cfm-allocation-item:hover .allocation-icon {
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.allocation-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.allocation-name {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.allocation-percent {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    margin: 5px 0;
}

.allocation-amount {
    font-size: 24px;
    font-weight: 700;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 2px solid currentColor;
}

.cfm-allocation-item.tithe .allocation-amount {
    color: #9b59b6;
}

.cfm-allocation-item.savings .allocation-amount {
    color: #27ae60;
}

.cfm-allocation-item.salaries .allocation-amount {
    color: #3498db;
}

.cfm-allocation-item.expendable .allocation-amount {
    color: #e67e22;
}

.cfm-allocation-item.emergency .allocation-amount {
    color: #d63638;
}

.cfm-allocation-total {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #fff;
    border-radius: 10px;
    padding: 20px 30px;
    text-align: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.cfm-allocation-total strong {
    font-size: 28px;
    font-weight: 800;
}

/* Top Sources Section - Improved */
.cfm-top-sources-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

.top-items-card {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 2px solid #e0e0e0;
}

.top-items-card h3 {
    color: #2271b1;
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 3px solid #2271b1;
}

.top-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

.top-item:hover {
    background: #e3f2fd;
    transform: translateX(8px);
    border-color: #2271b1;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.15);
}

.item-rank {
    font-size: 28px;
    font-weight: 900;
    color: #2271b1;
    min-width: 50px;
    text-align: center;
    line-height: 1;
}

.item-info {
    flex: 1;
}

.item-name {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.item-count {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.item-amount {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
}

.item-amount.income {
    color: #00a32a;
}

.item-amount.expense {
    color: #d63638;
}

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-style: italic;
}

.cfm-dashboard-actions {
    text-align: center;
    margin-top: 30px;
}

.cfm-button {
    display: inline-block;
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #fff !important;
    padding: 15px 35px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
}

.cfm-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(34, 113, 177, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .cfm-frontend-form-container,
    .cfm-frontend-dashboard {
        padding: 20px;
        margin: 10px;
    }
    
    .cfm-quick-stats-front {
        grid-template-columns: 1fr;
    }
    
    .cfm-stats-container {
        grid-template-columns: 1fr;
    }
    
    .cfm-allocation-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cfm-top-sources-section {
        grid-template-columns: 1fr;
    }
    
    .cfm-form-header h2,
    .cfm-dashboard-header h2 {
        font-size: 24px;
    }
    
    .cfm-budget-section h3 {
        font-size: 20px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .allocation-icon {
        font-size: 42px;
    }
    
    .allocation-percent {
        font-size: 28px;
    }
    
    .allocation-amount {
        font-size: 20px;
    }
    
    .cfm-allocation-total {
        font-size: 16px;
        flex-direction: column;
        gap: 8px;
    }
    
    .cfm-allocation-total strong {
        font-size: 22px;
    }
    
    .quick-stat-box .stat-icon {
        font-size: 28px;
    }
    
    .quick-stat-box .stat-number {
        font-size: 20px;
    }
    
    .item-rank {
        font-size: 20px;
        min-width: 35px;
    }
    
    .item-name {
        font-size: 14px;
    }
    
    .item-amount {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .cfm-allocation-container {
        grid-template-columns: 1fr;
    }
    
    .cfm-budget-section {
        padding: 20px 15px;
    }
    
    .allocation-icon {
        font-size: 48px;
    }
    
    .top-item {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .item-rank {
        min-width: 100%;
    }
}