:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
.dashboard-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
}

@media (min-width: 768px) {
    .dashboard-header {
        flex-direction: row;
        align-items: center;
    }
}

.header-titles h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--primary-color);
}

.header-titles p {
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

h2, h3 {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.hidden {
    display: none !important;
}

/* Controls / Search */
.controls-bar {
    padding: 1rem 1.5rem;
}

.search-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Forms (Used in Modals) */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}
.form-group.half {
    flex: 1;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions.right-align {
    text-align: right;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

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

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

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

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

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

.btn-text:hover {
    color: var(--text-main);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}
.btn-icon {
    padding: 0.4rem;
    font-size: 1rem;
    line-height: 1;
}

/* Accordion Table */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: #f8fafc;
}

td {
    font-size: 0.95rem;
}

.accordion-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.accordion-row:hover {
    background-color: #f1f5f9;
}

.accordion-row.expanded {
    background-color: #f8fafc;
    border-bottom: none;
}

.accordion-row td {
    border-bottom: 1px solid var(--border-color);
}
.accordion-row.expanded td {
    border-bottom: none;
}

/* The Sub-table (Expenses) row */
.expenses-row {
    background-color: #fafafa;
}

.expenses-row > td {
    padding: 0;
    border-bottom: 2px solid var(--primary-color);
}

.expenses-container {
    padding: 1.5rem;
    border-left: 4px solid var(--primary-color);
    background: #ffffff;
}

.expenses-container h4 {
    margin-bottom: 1rem;
    color: var(--text-main);
    font-size: 1rem;
}

.sub-table {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.sub-table th, .sub-table td {
    padding: 0.75rem 1rem;
}

.sub-table th {
    background: var(--bg-color);
    font-size: 0.75rem;
}

.chevron {
    transition: transform 0.3s ease;
    display: inline-block;
    color: var(--text-muted);
    font-weight: bold;
}

.expanded .chevron {
    transform: rotate(90deg);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.close-modal {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    margin: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
}

.modal-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
}

/* Manage Expenses Container inside Modal */
.manage-expenses-container .sub-table th,
.manage-expenses-container .sub-table td {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
