* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --info: #4299e1;
    --light: #f7fafc;
    --dark: #2d3748;
    --gray: #718096;
    --gray-light: #e2e8f0;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.expense-tracker {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 40px 50px;
}

.header-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-content p {
    opacity: 0.9;
    font-weight: 300;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    min-height: 800px;
}

/* Left Panel */
.left-panel {
    background: var(--light);
    padding: 30px;
    border-right: 1px solid var(--gray-light);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Period Selector - Dropdown */
.period-selector h3 {
    margin-bottom: 15px;
    color: var(--dark);
    font-weight: 600;
    font-size: 1.1rem;
}

.dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dropdown-btn {
    background: white;
    border: 2px solid var(--gray-light);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--dark);
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-btn:hover {
    border-color: var(--primary);
}

.dropdown-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 100;
    margin-top: 5px;
}

.dropdown-content.show {
    display: block;
    animation: dropdownSlide 0.2s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    background: none;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--dark);
    width: 100%;
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--primary);
    color: white;
}

.dropdown-item.active {
    background: var(--primary);
    color: white;
}

.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 99;
    display: none;
}

.dropdown-overlay.show {
    display: block;
}

/* Period Summary */
.period-summary {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.summary-card {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.summary-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.summary-info {
    flex: 1;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
}

.summary-label {
    color: var(--gray);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Categories Section */
.categories-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.categories-section h3 {
    color: var(--dark);
    font-weight: 600;
    font-size: 1.1rem;
}

.add-category-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-category-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.category-item {
    background: white;
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    cursor: pointer;
}

.category-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.category-name {
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.category-amount {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 5px;
}

.category-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--gray);
}

/* Right Panel */
.right-panel {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    background: white;
}

/* Form Section */
.form-section {
    background: var(--light);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.form-header h3 {
    color: var(--dark);
    font-weight: 600;
    font-size: 1.3rem;
}

.cancel-edit-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}

.cancel-edit-btn:hover {
    background: #e53e3e;
    transform: translateY(-1px);
}

.expense-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 14px 16px;
    border: 2px solid var(--gray-light);
    border-radius: 10px;
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
    font-family: 'Poppins', sans-serif;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.category-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.category-select-wrapper select {
    flex: 1;
    padding-right: 50px;
}

.quick-add-btn {
    position: absolute;
    right: 8px;
    background: var(--primary);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-add-btn:hover {
    background: var(--primary-dark);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 10px;
}

.submit-btn {
    background: linear-gradient(135deg, var(--success) 0%, #38a169 100%);
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

.clear-btn {
    background: white;
    color: var(--gray);
    border: 2px solid var(--gray-light);
    padding: 14px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.clear-btn:hover {
    background: var(--gray-light);
    color: var(--dark);
}

/* History Section */
.history-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    color: var(--dark);
    font-weight: 600;
    font-size: 1.3rem;
}

.action-btn {
    background: var(--info);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

.expenses-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.expense-item {
    background: var(--light);
    padding: 20px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
    cursor: pointer;
}

.expense-item:hover {
    background: white;
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.expense-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 15px;
}

.expense-title-section {
    flex: 1;
    min-width: 0;
}

.expense-title {
    font-weight: 600;
    color: var(--dark);
    font-size: 1.1rem;
    margin-bottom: 5px;
    word-wrap: break-word;
}

.expense-amount-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.expense-amount {
    font-weight: 700;
    color: var(--success);
    font-size: 1.3rem;
    white-space: nowrap;
}

.expense-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.expense-item:hover .expense-actions {
    opacity: 1;
}

.edit-btn {
    background: rgba(66, 153, 225, 0.1);
    color: var(--info);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.edit-btn:hover {
    background: var(--info);
    color: white;
    transform: translateY(-1px);
}

.expense-details {
    display: flex;
    gap: 15px;
    color: var(--gray);
    font-size: 0.85rem;
    flex-wrap: wrap;
    align-items: center;
}

.expense-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.expense-category {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--primary);
    font-weight: 500;
}

.expense-date {
    display: flex;
    align-items: center;
    gap: 6px;
}

.expense-subcategory {
    display: flex;
    align-items: center;
    gap: 6px;
    font-style: italic;
}

/* Payment Method Badges */
.payment-method-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
}

.payment-method-badge.cash { 
    background: rgba(72, 187, 120, 0.1); 
    color: var(--success); 
}

.payment-method-badge.upi { 
    background: rgba(66, 153, 225, 0.1); 
    color: var(--info); 
}

.payment-method-badge.card { 
    background: rgba(159, 122, 234, 0.1); 
    color: #9f7aea; 
}

.payment-method-badge.bank { 
    background: rgba(237, 137, 54, 0.1); 
    color: var(--warning); 
}

.payment-method-badge.cheque { 
    background: rgba(245, 101, 101, 0.1); 
    color: var(--danger); 
}

.payment-method-badge.other { 
    background: rgba(113, 128, 150, 0.1); 
    color: var(--gray); 
}

.expense-description {
    margin-top: 8px;
    color: var(--gray);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px;
    border-bottom: 1px solid var(--gray-light);
}

.modal-header h3 {
    color: var(--dark);
    font-weight: 600;
    font-size: 1.4rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: var(--gray-light);
    color: var(--dark);
}

.modal-body {
    padding: 30px;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-picker input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

.cancel-btn {
    background: var(--gray-light);
    color: var(--dark);
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.cancel-btn:hover {
    background: #cbd5e0;
}

/* Export Options */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.export-option {
    background: var(--light);
    border: 2px solid var(--gray-light);
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.export-option:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.export-option i {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.export-option span {
    font-weight: 600;
    color: var(--dark);
}

.export-option small {
    color: var(--gray);
    font-size: 0.85rem;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h4 {
    margin-bottom: 10px;
    color: var(--dark);
    font-weight: 600;
}

.empty-state p {
    max-width: 300px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Scrollbars */
.categories-list::-webkit-scrollbar,
.expenses-list::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.categories-list::-webkit-scrollbar-track,
.expenses-list::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.categories-list::-webkit-scrollbar-thumb,
.expenses-list::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.categories-list::-webkit-scrollbar-thumb:hover,
.expenses-list::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Notification Animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .left-panel {
        border-right: none;
        border-bottom: 1px solid var(--gray-light);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .app-header {
        padding: 30px 25px;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .left-panel,
    .right-panel {
        padding: 20px;
    }
    
    .form-section {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .summary-card {
        padding: 20px;
    }
    
    .summary-value {
        font-size: 1.6rem;
    }
    
    .modal-content {
        margin: 20px;
        width: calc(100% - 40px);
    }
    
    .modal-header,
    .modal-body {
        padding: 20px;
    }
    
    .expense-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .expense-amount-section {
        width: 100%;
        justify-content: space-between;
    }
    
    .expense-actions {
        opacity: 1;
    }
    
    .expense-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 25px 20px;
    }
    
    .header-content h1 {
        font-size: 1.8rem;
    }
    
    .left-panel,
    .right-panel {
        padding: 15px;
    }
    
    .form-section {
        padding: 15px;
    }
    
    .summary-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .summary-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .summary-value {
        font-size: 1.4rem;
    }
    
    .modal-content {
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .modal-header,
    .modal-body {
        padding: 15px;
    }
    
    .form-actions {
        gap: 10px;
    }
    
    .submit-btn,
    .clear-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        padding: 0 !important;
    }
    
    .container {
        max-width: none !important;
        margin: 0 !important;
    }
    
    .expense-tracker {
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    
    .app-header {
        background: #667eea !important;
        -webkit-print-color-adjust: exact;
    }
    
    .no-print {
        display: none !important;
    }
}