* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    /* Updated background gradient */
    background: linear-gradient(315deg, #003366 0%, #242124 74%);
    min-height: 100vh;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Kept as flex-start as per the original, but will center the container specifically */
    padding: 20px;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    /* Centering the container within the body */
    align-self: center; /* This will center it vertically if body is flex column, or horizontally if flex row */
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding-top: 20px;
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.4);
    font-weight: 700;
}

/* Updated styling for the main action buttons */
.app-switcher-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    justify-content: center;
}

.app-switcher-buttons .btn {
    flex: 1 1 45%; /* Takes up roughly 50% screen real-estate with gap */
    padding: 20px 25px;
    font-size: 1.2em;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    color: white;
    background: #4b5563; /* Default gray for inactive button */
    border-radius: 12px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease-in-out;
    border: none;
    cursor: pointer;
}

.app-switcher-buttons .btn-income-active {
    background: linear-gradient(45deg, #1e3a8a, #3b82f6); /* Gradient for active button */
}

.app-switcher-buttons .btn:hover {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

/* Authentication Section Styles */
.auth-section {
    display: flex; /* Keep this so it can be flex when not hidden */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    /* Removed background here, as body handles the full background now */
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    /* Centering content within the auth-card, including the Google button */
    display: flex; /* Added */
    flex-direction: column; /* Added */
    align-items: center; /* Added */
    text-align: center; /* Kept for text alignment */
    max-width: 400px;
    width: 100%;
}

.auth-card h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #333;
    font-weight: 700;
}

.auth-card p {
    margin-bottom: 25px;
    color: #666;
}

.auth-card input {
    width: calc(100% - 20px);
    padding: 15px 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1.1em;
}

.auth-card .auth-buttons {
    display: flex;
    gap: 15px;
    justify-content: center; /* Centering buttons within auth-buttons container */
    margin-top: 20px;
}

.auth-card .btn {
    flex: 1;
    font-size: 1.1em;
    padding: 15px 20px;
    justify-content: center;
}

.google-btn {
    background: linear-gradient(159deg, rgba(0,0,128,1) 0%, rgba(0,191,255,1) 100%); /* Google Blue */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 25px;
    font-size: 1.1em;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    /* The auth-card's flex properties will center this button now */
}

.google-btn:hover {
    background: #357ae8; /* Example hover color, adjust as needed */
    transform: translateY(-2px); /* Pop effect on hover */
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.auth-status {
    margin-top: 20px;
    color: #E74C3C; /* Error color */
    font-weight: 600;
}

.user-info {
    color: white;
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.user-info #userEmail {
    font-size: 1.1em;
    font-weight: 600;
}

/* Notification System Styles */
.notification-container {
    position: relative;
    display: inline-block;
}

.notification-bell {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 1.2em;
    position: relative;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.notification-bell:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    font-size: 0.7em;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    min-width: 320px;
    max-width: 400px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 10px;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
}

.notification-header h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.close-notifications {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-notifications:hover {
    color: #333;
}

.notification-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-notifications {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.notification-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item:last-child {
    border-bottom: none;
    border-radius: 0 0 10px 10px;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.notification-header strong {
    font-weight: 600;
    color: #333;
    flex: 1;
}

.notification-amount {
    font-weight: bold;
    color: #007bff;
}

.notification-status {
    font-size: 0.9em;
    font-weight: 500;
    margin-bottom: 3px;
}

.notification-date {
    font-size: 0.8em;
    color: #666;
}

/* Notification priority colors */
.notification-overdue .notification-status {
    color: #dc3545;
    font-weight: bold;
}

.notification-urgent .notification-status {
    color: #fd7e14;
    font-weight: bold;
}

.notification-upcoming .notification-status {
    color: #ffc107;
    font-weight: 500;
}

/* Notification highlight effect */
.notification-highlight {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    animation: highlightFade 3s ease-out;
}

@keyframes highlightFade {
    0% { 
        background-color: #fff3cd;
        border-color: #ffc107;
    }
    100% { 
        background-color: transparent;
        border-color: transparent;
    }
}

/* Sign Out Button - Smaller and distinctive */
#signOutBtn {
    padding: 6px 12px; /* Made smaller */
    font-size: 0.75em; /* Made smaller */
    background: #dc3545; /* Red, as it was */
    color: white;
    border-radius: 5px; /* Slightly less rounded */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Subtle shadow for distinction */
    transition: all 0.2s ease; /* Pop effect */
    /* Ensure it's not affected by .btn-small if it exists */
}

#signOutBtn:hover {
    background: #c82333;
    transform: translateY(-2px); /* Pop effect on hover */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.dashboard {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #34495E 0%, #2C3E50 100%); /* Darker, sophisticated gradient for stat cards */
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-card .stat-icon {
    margin-bottom: 10px;
}

.stat-card .stat-icon svg {
    width: 36px;
    height: 36px;
}

.stat-card h3 {
    font-size: 1em;
    margin-bottom: 8px;
    opacity: 0.95;
    font-weight: 600;
}

.stat-card .value {
    font-size: 2.2em;
    font-weight: 700;
}

/* Total Starting Loan Amount text */
.stat-card .small-text {
    font-size: 0.7em; /* Smaller font */
    opacity: 0.8;
    margin-top: 5px;
}

.actions {
    display: flex;
    gap: 25px;
    justify-content: center;
    margin-bottom: 40px;
}

.btn {
    padding: 18px 35px;
    border: none;
    border-radius: 10px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease; /* Pop effect transition */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(45deg, #27AE60, #229954); /* Vibrant green for primary button */
    color: white;
}

.btn-secondary {
    background: linear-gradient(45deg, #3498DB, #2980B9); /* Consistent blue for secondary button */
    color: white;
}

/* New button style for "Pay Interest Only" */
.btn-info {
    background: linear-gradient(45deg, #FFC107, #FFA000); /* Orange/Yellow gradient */
    color: #333;
}

.btn-info:hover {
    background: linear-gradient(45deg, #FFA000, #FFC107);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

.chart-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    height: 450px; /* Kept fixed height as per previous revert */
    display: flex; /* Added flexbox for centering chart content */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.chart-card h3 {
    text-align: center;
    margin-bottom: 25px;
    color: #333;
    font-size: 1.3em;
    font-weight: 600;
}

/* Fix for chart overflow when no data */
.chart-card canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensures the chart scales within its container */
}

.transactions {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.transactions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.transactions h3 {
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
}

.sort-controls label {
    font-size: 0.9em;
    color: #666;
    margin-right: 5px;
}

.sort-controls select {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
    font-size: 0.9em;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align items to the start for vertical alignment */
    padding: 18px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.3s ease; /* Pop effect transition */
    border-radius: 8px;
    margin-bottom: 8px;
    position: relative; /* For pin button positioning */
}

/* Alternating row colors */
.transaction-item:nth-child(even) {
    background-color: #e6f7ff; /* Very light blue */
}

/* Pinned loan color */
.transaction-item.pinned {
    background-color: #e6ffe6; /* Very light green */
    border-left: 5px solid #28a745; /* Green border for emphasis */
    padding-left: 13px; /* Adjust padding due to border */
}

.transaction-item:hover {
    background-color: #eef2f7;
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    transform: translateY(-3px); /* Pop effect on hover */
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1; /* Allow details to take available space */
    padding-left: 30px; /* Space for the pin icon */
    position: relative; /* For pin icon positioning */
}

.transaction-item-details strong {
    font-size: 1.1em;
    color: #333;
    display: flex;
    align-items: center;
    /* Removed gap from here, pin is now absolutely positioned */
}

.loan-interest-rate {
    font-size: 0.8em;
    color: #007bff; /* Blue for interest rate */
    font-weight: 500;
    margin-left: 5px;
}

.loan-current-amount {
    font-weight: 600;
    color: #dc3545; /* Red for current amount */
    font-size: 1.1em;
    margin-top: 5px; /* Space below name/date */
}

.loan-initial-amount {
    font-size: 0.7em; /* Smaller font for initial amount */
    color: #666;
    margin-left: 5px;
}

.transaction-date {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}

.transaction-item-actions {
    display: flex;
    flex-direction: column; /* Stack buttons by default */
    gap: 8px; /* Space between stacked buttons */
    align-items: flex-end; /* Align buttons to the right */
}

/* Pin button positioning */
.pin-btn {
    cursor: pointer;
    color: #7f8c8d; /* Grey for unpinned */
    transition: color 0.2s ease, transform 0.2s ease;
    font-size: 1.2em; /* Size of the pin icon */
    position: absolute; /* Absolute positioning relative to .transaction-item-details */
    left: 0; /* Align to the left of the details container */
    top: 5px; /* Adjust vertical position */
}

.pin-btn.pinned {
    color: #f39c12; /* Orange for pinned */
    transform: rotate(45deg); /* Visual cue for pinned */
}

.pin-btn:hover {
    transform: scale(1.2) rotate(45deg); /* Scale and rotate on hover */
}

.transaction-loan {
    color: #E74C3C;
    font-weight: bold;
    font-size: 1.1em;
}

.transaction-payment {
    color: #2ECC71;
    font-weight: bold;
    font-size: 1.1em;
}

.edit-btn, .delete-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    /* margin-left: 8px; Removed default margin-left */
    font-weight: 600;
    transition: all 0.2s ease; /* Pop effect transition */
}

.edit-btn {
    background: linear-gradient(45deg, #FFC300, #e0a800); /* Gradient for edit button */
    color: #333;
}

.edit-btn:hover {
    background: linear-gradient(45deg, #e0a800, #FFC300); /* Reverse gradient on hover */
    transform: translateY(-2px); /* Pop effect on hover */
}

.delete-btn {
    background: #C0392B;
    color: white;
}

.delete-btn:hover {
    background: #a93226;
    transform: translateY(-2px); /* Pop effect on hover */
}

.modal {
    display: none; /* Keep this as the default state for modals */
    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);
    /* REMOVED display: flex; FROM HERE - JS sets it */
    align-items: center; /* These will apply when display: flex is set by JS */
    justify-content: center; /* These will apply when display: flex is set by JS */
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: fadeIn 0.3s ease-out; /* Add fade-in animation */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    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: 1px solid #eee;
}

.modal-header h2 {
    color: #333;
    font-size: 1.8em;
    font-weight: 600;
}

.close {
    color: #777;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: #333;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: #555;
    font-size: 1.05em;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #34495E; /* Focus color from the new stat card gradient */
    box-shadow: 0 0 0 3px rgba(52, 73, 94, 0.2);
}

.frequency-group {
    display: flex;
    gap: 15px;
}

.frequency-group input, .frequency-group select {
    flex: 1;
}

.loan-detail {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    margin-bottom: 30px;
}

.loan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 2px solid #eee;
}

.loan-header h2 {
    font-size: 2.2em;
    font-weight: 700;
    color: #333;
}

.loan-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.payment-history {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.payment-history h3 {
    margin-bottom: 25px;
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
}

.payment-item {
    background: white;
    padding: 18px;
    border-radius: 10px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.2s ease; /* Pop effect transition */
}

.payment-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.back-btn {
    background: #7F8C8D;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease; /* Pop effect transition */
}

.back-btn:hover {
    background: #6C757D;
    transform: translateY(-2px);
}

.hidden {
    display: none !important; 
}

/* Define colors for payment status */
:root {
    --payment-due-color: #dc3545; /* Bootstrap Danger Red */
    --payment-paid-color: #28a745; /* Bootstrap Success Green */
    --payment-overdue-bg-color: #ffe6e6; /* Light red background for overdue items */
    /* You can add other custom properties if needed */
}

/* Style for the "This Month's Payment/Interest Due" indicator on loan cards */
.transaction-item .loan-current-amount::after {
    content: " (Due: $" attr(data-due-amount) ")";
    color: var(--payment-due-color);
    font-weight: bold;
    margin-left: 5px;
    font-size: 0.9em;
}

/* Style when the payment/interest is paid or $0 */
.transaction-item.paid .loan-current-amount::after,
.transaction-item.paid-zero .loan-current-amount::after {
    content: " (Paid)";
    color: var(--payment-paid-color);
}

.transaction-item.paid-zero .loan-current-amount::after {
    content: " (Paid/No Due)";
}

/* Style for the persistent due notification */
.due-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    cursor: pointer;
    font-size: 0.8em;
    color: var(--payment-due-color);
    font-weight: bold;
}

.due-indicator .dot {
    height: 10px;
    width: 10px;
    background-color: var(--payment-due-color);
    border-radius: 50%;
    display: inline-block;
    animation: breathe 1.5s ease-in-out infinite;
}

@keyframes breathe {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Style for overdue transaction items */
.transaction-item.overdue {
    background-color: var(--payment-overdue-bg-color) !important; /* Override alternating colors */
    border-left: 5px solid var(--payment-due-color); /* Red border for emphasis */
    padding-left: 13px; /* Adjust padding due to border */
}

/* Ensure pin buttons are visible (base style) - logic in JS controls interaction */
.pin-btn {
    /* ... existing styles ... */
    visibility: visible; /* Ensure it's visible by default if not hidden by class */
}

/* Optional: Style the frequency display on loan cards if added */
.loan-frequency {
    font-size: 0.75em;
    color: #7f8c8d; /* Muted gray */
    margin-top: 3px;
}

.loan-payment-day-small {
    font-size: 0.75em;
    color: #7f8c8d; /* Muted gray */
    margin-top: 2px;
}

/* Loan overdue and due styling */
.loan-overdue-list {
    margin-top: 8px;
    padding: 8px;
    background-color: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 5px;
}

.loan-overdue-list h4 {
    font-size: 0.8em;
    color: #c53030;
    margin-bottom: 5px;
    font-weight: 600;
}

.due-item {
    font-size: 0.75em;
    color: #c53030;
    margin-bottom: 2px;
}

.next-due-item {
    font-size: 0.8em;
    color: #3182ce;
    margin-top: 5px;
    font-weight: 500;
}

.loan-total-accrued-interest {
    font-size: 0.8em;
    color: #666;
    margin-top: 5px;
}

/* Ensure chart container maintains its intended behavior */
.chart-card canvas {
    max-width: 100%;
    max-height: 100%;
    /* Chart.js v4 handles responsiveness well, but explicit sizing might be needed depending on chart config */
    /* width: 100%; height: 100%; */ /* Uncomment if needed for specific chart sizing */
    object-fit: contain;
}

@media (max-width: 992px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Add Loan and Make Payment buttons should be placed vertically when opened from small screen like phone. */
    .actions {
        flex-direction: column;
        align-items: center;
    }
    /* Loan Detail Actions also stack */
    .loan-detail-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 20px;
    }

    .header h1 {
        font-size: 2.2em;
    }

    .btn {
        width: 100%;
        max-width: 300px; /* Ensure buttons don't exceed container width */
    }

    .modal-content {
        padding: 25px;
    }

    .form-group input, .form-group select {
        padding: 12px;
    }

    .auth-card input {
        width: 100%;
    }
    .auth-card .auth-buttons {
        flex-direction: column;
    }
    .auth-card .btn {
        width: 100%;
    }
    
    .user-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .notification-dropdown {
        right: -10px;
        min-width: 280px;
    }
    
    /* Mobile view: edit and delete button spacing */
    .transaction-item-actions {
        flex-direction: row; /* Keep edit/delete side-by-side on mobile */
        justify-content: flex-end; /* Align to right */
        width: 100%; /* Take full width */
        margin-top: 10px; /* Space from text */
    }
    .transaction-item .edit-btn,
    .transaction-item .delete-btn,
    .payment-item .edit-btn,
    .payment-item .delete-btn {
        margin-left: 5px; /* Add horizontal spacing */
        margin-top: 0; /* Remove vertical spacing */
        width: auto; /* Allow buttons to size naturally */
        flex-shrink: 0; /* Prevent shrinking */
    }
    .transaction-item > div:first-child,
    .payment-item > div:first-child {
        width: 100%; /* Ensure text content takes full width */
        text-align: left;
    }
    .transaction-item, .payment-item {
        flex-direction: column; /* Stack items vertically */
        align-items: flex-start; /* Align content to the left */
        gap: 5px; /* Adjust gap between stacked elements */
    }
    .transaction-loan, .transaction-payment {
        width: 100%; /* Ensure amount and buttons take full width */
        justify-content: flex-start; /* Align to left */
        margin-top: 10px; /* Space between text and buttons */
    }
    /* Ensure text within stat cards doesn't overflow */
    .stat-card .stat-label, .stat-card .value {
        word-break: break-all; /* Allow long words to break */
        overflow-wrap: break-word; /* For better word wrapping */
    }
    .transactions-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    /* Optional: Adjust sort dropdown if many options cause overflow on small screens */
    .sort-controls select {
        /* ... existing styles ... */
        max-width: 200px; /* Prevent it from getting too wide */
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    .dashboard, .transactions, .loan-detail, .chart-card {
        padding: 20px;
    }
    .modal-content {
        padding: 20px;
    }
    .loan-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .header h1 {
        font-size: 2em;
    }
    .header p {
        font-size: 0.9em;
    }
    .stat-value {
        font-size: 1.8em;
    }
    .loan-stat-card {
        padding: 10px;
    }
}


/* ================================================================
   TRANSACTION DISPLAY IMPROVEMENTS
   Add this to the END of your styles.css
   ================================================================ */

/* Payment item structure */
.payment-item {
    position: relative;
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Header with title and buttons */
.payment-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.payment-item-header strong {
    font-size: 16px;
    color: #333;
}

/* Actions at the end */
.payment-item-actions {
    display: flex;
    gap: 8px;
}

.payment-item-actions .edit-btn,
.payment-item-actions .delete-btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.payment-item-actions .edit-btn {
    background: #007bff;
    color: white;
}

.payment-item-actions .edit-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.payment-item-actions .delete-btn {
    background: #dc3545;
    color: white;
}

.payment-item-actions .delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Content area */
.payment-item-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.payment-item-content > div {
    font-size: 14px;
    color: #555;
}

/* Color-coded amounts */
.amount-paid {
    color: #28a745 !important;
    font-weight: 700 !important;
    font-size: 15px !important;
}

.amount-interest {
    color: #D4A017 !important;
    font-weight: 700 !important;
    font-size: 15px !important;
}

.amount-principal {
    color: #007bff !important;
    font-weight: 700 !important;
    font-size: 15px !important;
}

.amount-total {
    color: #333 !important;
    font-weight: 600 !important;
}

/* Info text styling */
.added-by-info {
    font-size: 12px !important;
    color: #999 !important;
    margin-top: 4px;
}

.comment-info {
    font-style: italic;
    color: #666 !important;
    margin-top: 4px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .payment-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .payment-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ================================================================
   END OF TRANSACTION IMPROVEMENTS
   ================================================================ */
   
   
/* ================================================================
   CHART RESPONSIVE FIX - CORRECTED FOR pieChart and barChart
   Add this to the END of your styles.css
   ================================================================ */

/* Fix chart container overflow */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 30px 0;
    width: 100%;
}

.chart-card {
    background: var(--bg-card, rgba(255, 255, 255, 0.95));
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Prevent overflow */
    min-height: 350px;
}

.chart-card h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #333);
    text-align: center;
    word-wrap: break-word; /* Wrap long titles */
}

/* Ensure canvas elements are contained */
#pieChart,
#barChart {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Chart wrapper if you have one */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px;
    overflow: hidden;
    margin: 0 auto;
}

.chart-wrapper canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 15px;
    }
    
    .chart-card {
        padding: 15px;
        min-height: 320px;
        margin-bottom: 15px;
    }
    
    .chart-card h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .chart-wrapper {
        height: 250px; /* Shorter on mobile */
    }
    
    #pieChart,
    #barChart {
        max-height: 250px !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .chart-card {
        padding: 12px;
        min-height: 300px;
    }
    
    .chart-card h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .chart-wrapper {
        height: 220px;
    }
    
    #pieChart,
    #barChart {
        max-height: 220px !important;
    }
}

/* ================================================================
   CHART.JS SPECIFIC FIXES
   ================================================================ */

/* Override any existing chart styles that might cause issues */
canvas {
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Ensure legends and labels are contained */
.chartjs-legend,
.chartjs-legend ul {
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap;
}

/* ================================================================
   END OF CHART FIXES
   ================================================================ */
   
   /* ================================================================
   NOTIFICATION DROPDOWN MOBILE FIX
   ================================================================ */

/* Override notification dropdown positioning for mobile */
@media (max-width: 768px) {
    .notification-dropdown {
        position: fixed !important;
        top: 70px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        min-width: 90vw !important;
        max-width: 90vw !important;
        max-height: 70vh !important;
    }
    
    .notification-bell-container {
        position: relative;
    }
}

/* For very small screens */
@media (max-width: 480px) {
    .notification-dropdown {
        top: 60px !important;
        min-width: 95vw !important;
        max-width: 95vw !important;
        max-height: 75vh !important;
    }
}

/* ================================================================
   END OF NOTIFICATION DROPDOWN FIX
   ================================================================ */