/* General Body & Resets */
:root {
    --primary-color: #4a69bd;
    --secondary-color: #6a89cc;
    --danger-color: #e55039;
    --success-color: #78e08f;
    --light-gray: #f8f9fa;
    --dark-gray: #343a40;
    --text-color: #212529;
    --border-color: #dee2e6;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--light-gray);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Footer */
header, footer {
    background-color: var(--dark-gray);
    color: white;
    padding: 1rem;
    text-align: center;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

footer {
    margin-top: auto;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Cards */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
}

.summary-card {
    text-align: center;
    background-color: var(--primary-color);
    color: white;
}

.summary-amount {
    font-size: 2.5rem;
    font-weight: bold;
}

.card-header-flex {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.login-container {
    max-width: 450px;
    margin-top: 5vh;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row label {
    font-weight: bold;
}

.form-row i {
    margin-right: 8px;
}

.others-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Buttons */
button, .btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s;
}

button:hover, .btn:hover {
    background-color: var(--secondary-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

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

.btn-success {
    background-color: var(--success-color);
    color: var(--dark-gray);
}

.btn.disabled, button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.d-inline {
    display: inline-block;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.mt-3 {
    margin-top: 1rem;
}

/* Tab Styles */
.tab-container {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    font-size: 1rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px; /* Align with container border */
    transition: all 0.2s ease-in-out;
}

.tab-btn:hover {
    background-color: var(--light-gray);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: bold;
}

.tab-content {
    /* Hide by default to prevent flash of unstyled content */
    display: none; 
}

/* This class is added by JS after initialization */
.tabs-ready .tab-content.active {
    display: block; 
}

.tabs-ready .tab-content {
    /* This ensures non-active tabs are hidden after initialization */
    display: none; 
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

table thead {
    /* Hide thead on mobile, it's replaced by data-labels */
    border: none;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

table tr {
    display: block;
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    margin-bottom: 1rem;
}

table td {
    display: block;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left; /* Align text to the left for better readability */
}

table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8em;
    color: #6c757d;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

/* Prevent long text from pushing content and allow wrapping in mobile view */
table td[data-label="Others (Desc)"] {
    white-space: normal;
    word-break: break-word;
}

/* Remove bottom border from the last cell in a mobile row */
table tr td:last-child {
    border-bottom: 0;
}

.expense-locked {
    opacity: 0.7;
}

/* --- Tablet and larger screens (768px and up) --- */
@media (min-width: 768px) {
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 0;
    }

    .container {
        padding: 2rem;
    }

    .login-container {
        max-width: 400px;
    }

    .card-header-flex {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .filter-controls {
        flex-direction: row;
        gap: 1rem;
    }

    .others-inputs {
        flex-direction: row;
        gap: 1rem;
    }

    .others-inputs input {
        flex: 1;
    }

    /* Responsive Table for larger screens */
    table thead {
        display: table-header-group; /* Show table header */
    }

    table thead, table tr {
        /* Reset mobile overrides */
        clip: auto;
        height: auto;
        width: auto;
        margin: 0;
        overflow: visible;
        position: static;
    }

    table tr {
        display: table-row;
        border-bottom: 1px solid var(--border-color);
        box-shadow: none;
    }

    table th, table td {
        display: table-cell;
        text-align: left;
        padding: 0.75rem;
    }

    table td::before {
        display: none; /* Hide data-label pseudo-element */
    }
}

/* --- Desktop screens (1024px and up) --- */
@media (min-width: 1024px) {
    body {
        font-size: 1.1rem;
    }

    input, select, button, .btn {
        font-size: 1rem;
    }
}