body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

h1 {
    text-align: center;
    margin-top: 1rem;
}

#addBtn {
    font-size: 2rem;
    border: none;
    background: #4caf50;
    color: white;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

/* Container styles */
#paymentsContainer {
    display: none;
    width: 100%;
    max-width: 800px;
    margin: 1rem auto;
    padding: 0 0.5rem;
    box-sizing: border-box;
}

/* Table styles */
.table-container {
    width: 100%;
    margin: 0 -0.5rem; /* Negative margin to allow full width on mobile */
}

.payments-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 16px;
}

.payments-table th,
.payments-table td {
    padding: 0.75rem;
    text-align: left;
}

.payments-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.payments-table td {
    border-bottom: 1px solid #eee;
}

.payments-table tr:last-child td {
    border-bottom: none;
}

.date-header {
    padding: 1rem 0.75rem 0.5rem 0.75rem;
    font-weight: 600;
    color: #666;
    background: white;
    font-size: 0.9em;
}

/* Mobile optimizations */
@media screen and (max-width: 600px) {
    #paymentsContainer {
        padding: 0 0.25rem;
    }

    .payments-table {
        font-size: 14px;
    }

    .payments-table th,
    .payments-table td {
        padding: 0.5rem 0.25rem;
    }

    /* Mobile column layout optimization */
    .payments-table th:nth-child(2),
    .payments-table td:nth-child(2) {
        width: auto; /* Description gets remaining space */
    }

    .payments-table th:nth-child(3),
    .payments-table td:nth-child(3) {
        width: 70px;
        text-align: right;
    }

    .payments-table th:nth-child(4),
    .payments-table td:nth-child(4) {
        width: 50px;
        text-align: center;
    }

    /* Text overflow handling */
    .payments-table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Adjust date header for mobile */
    .date-header {
        padding: 0.75rem 0.25rem 0.25rem 0.25rem;
    }

    /* Ensure the add button doesn't overlap with content */
    #addBtn {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Category icon styles */
.category-icon {
    font-size: 18px;
}

/* Optimal column layout */
.payments-table th:first-child,
.payments-table td:first-child {
    width: auto; /* Description takes remaining space */
}

.payments-table th:nth-child(2),
.payments-table td:nth-child(2) {
    width: 50px;
    text-align: center;
    padding: 0.5rem;
}

.payments-table th:nth-child(3),
.payments-table td:nth-child(3) {
    width: 80px;
    text-align: right;
}

.payments-table th:nth-child(4),
.payments-table td:nth-child(4) {
    width: 60px;
    text-align: center;
}

@media screen and (max-width: 600px) {
    .category-icon {
        font-size: 14px;
    }

    .payments-table th:nth-child(2),
    .payments-table td:nth-child(2) {
        width: 40px;
        padding: 0.25rem;
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    justify-content: center;
    align-items: center;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-content {
    background: #fff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.5rem;
    font-size: 1rem;
    box-sizing: border-box;
}

.modal-content button {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Ensure no overflow on small screens */
@media (max-width: 600px) {
    .modal-content {
        padding: 1rem;
        margin: 0 1rem;
    }
}

/* Payment highlighting styles */
.payment-row {
    transition: background-color 0.2s ease;
}

/* My payments (most prominent) */
.payment-row.my-payment {
    background-color: #f0fbf0;
}

.payment-row.my-payment:hover {
    background-color: #e6f1dc;
}

/* Shared payments (medium prominence) */
.payment-row.shared-payment {
    background-color: #fff9eb;
}

.payment-row.shared-payment:hover {
    background-color: #ffe9cc;
}

/* Other payments (least prominent) */
.payment-row.other-payment {
    opacity: 0.7;
}

.payment-row.other-payment:hover {
    opacity: 0.85;
}

/* Export section styles */
.export-container {
    display: none; /* Hidden by default (mobile) */
    width: 100%;
    max-width: 800px;
    margin: 2rem auto 1rem auto;
    padding: 1.5rem;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-sizing: border-box;
}

.export-container h2 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.2rem;
}

.export-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.date-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-input-group label {
    font-weight: 600;
    color: #555;
    min-width: 70px;
}

.date-input-group input[type="date"] {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.export-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-primary {
    background: #2196f3;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background: #1976d2;
}

.btn-secondary {
    background: #757575;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background: #616161;
}

.export-feedback {
    min-height: 24px;
    padding: 0.5rem 0;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.export-feedback.success {
    color: #4caf50;
}

.export-feedback.error {
    color: #f44336;
}

/* Show export section only on desktop */
@media (min-width: 769px) {
    .export-container {
        display: block;
    }
}

/* Responsive adjustments for smaller desktop screens */
@media (max-width: 1024px) and (min-width: 769px) {
    .export-container {
        margin: 1.5rem 0.5rem 1rem 0.5rem;
        padding: 1rem;
    }

    .export-buttons {
        justify-content: flex-start;
    }
}