/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-dark: #333333;
    --text-light: #666666;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: var(--white);
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Section Styles */
section {
    padding: 30px;
    border-bottom: 1px solid var(--border-color);
}

section:last-child {
    border-bottom: none;
}

section h2 {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
}

/* Budget Section */
.budget-section {
    background: var(--light-bg);
}

.budget-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.budget-input-group label {
    font-weight: 600;
    color: var(--text-dark);
}

.input-with-button {
    display: flex;
    gap: 10px;
}

.budget-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.budget-display p {
    font-size: 1.2rem;
    font-weight: 600;
}

.budget-display span {
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* Form Styles */
.expense-form-section {
    background: var(--white);
}

#expenseForm {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
}

input[type="text"],
input[type="number"],
select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-edit {
    background: var(--warning-color);
    color: var(--text-dark);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-edit:hover {
    background: #e0a800;
}

.btn-delete {
    background: var(--danger-color);
    color: var(--white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-delete:hover {
    background: #c82333;
}

/* Summary Section */
.summary-section {
    background: var(--light-bg);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.summary-card h3 {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.summary-amount {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.summary-category {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
}

/* Warning Styles */
.warning {
    background: var(--danger-color);
    color: var(--white);
    padding: 15px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Category Breakdown */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.category-card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.3s;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.category-card.highest {
    border-left-color: var(--warning-color);
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.category-card h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.category-card .amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.category-card.highest .amount {
    color: var(--warning-color);
}

.category-card .percentage {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

thead {
    background: var(--light-bg);
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--light-bg);
}

.actions {
    display: flex;
    gap: 10px;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-style: italic;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

#editExpenseForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    section {
        padding: 20px;
    }

    section h2 {
        font-size: 1.5rem;
    }

    #expenseForm {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }

    .input-with-button {
        flex-direction: column;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 10px;
    }

    .actions {
        flex-direction: column;
        gap: 5px;
    }

    .btn-edit, .btn-delete {
        width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .summary-amount {
        font-size: 1.5rem;
    }

    .modal-content {
        padding: 20px;
    }
}
