/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --secondary: #7209b7;
    --success: #4cc9f0;
    --danger: #f72585;
    --warning: #f8961e;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --border-radius: 16px;
    --box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    height: 100vh;
    height: -webkit-fill-available;
    overflow-x: hidden;
    position: fixed;
    width: 100%;
}

/* App Container */
#root {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* App Header */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
}

.current-month {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

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

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content - FIXED SCROLLING */
.main-content {
    flex: 1;
    padding: 20px;
    padding-bottom: 100px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
}

/* Dashboard - FIXED 2x2 GRID */
.dashboard {
    min-height: 100%;
    padding-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
    height: 100%;
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-title {
    font-size: 14px;
    color: var(--gray);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

/* Chart Container - FIXED */
.chart-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
    height: 320px;
    position: relative;
    width: 100%;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

#expenseChart {
    width: 100% !important;
    height: 240px !important;
}

/* Recent Section */
.recent-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.expense-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
    gap: 15px;
}

.expense-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.expense-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.expense-details h4 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-details p {
    font-size: 13px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-amount {
    font-size: 18px;
    font-weight: 700;
    color: #d32f2f;
    flex-shrink: 0;
}

/* Expenses Page - FIXED 3 IN ONE ROW */
.expenses {
    min-height: 100%;
    padding-bottom: 20px;
}

.expenses-summary {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    text-align: center;
}

.summary-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
}

.summary-item .label {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 5px;
    font-weight: 500;
}

.summary-item .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
}

/* Filter Section */
.filter-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.filter-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    grid-column: span 2;
}

/* Expenses Container */
.expenses-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: 600;
}

.empty-state p {
    font-size: 14px;
    opacity: 0.8;
}

.expense-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
}

.expense-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.expense-info {
    flex: 1;
    margin-left: 15px;
    min-width: 0;
    overflow: hidden;
}

.expense-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray);
    flex-wrap: wrap;
}

.expense-category {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
}

.expense-amount {
    font-size: 20px;
    font-weight: 700;
    color: #d32f2f;
    flex-shrink: 0;
}

.expense-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #666;
}

.expense-actions {
    display: flex;
    justify-content: flex-end;
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn.delete {
    background: #ffebee;
    color: #d32f2f;
}

.action-btn.delete:active {
    background: #ffcdd2;
}

/* Add Expense - FIXED RESPONSIVENESS */
.add-expense {
    min-height: 100%;
    padding-bottom: 20px;
}

.form-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.form-group {
    margin-bottom: 20px;
    width: 100%;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    background: #f8f9fa;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

textarea.form-input {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
    max-width: 100%;
}

.form-select {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    background: #f8f9fa;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
}

/* Form Row - FIXED for Time field */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
}

/* Quick Add Sections */
.quick-amounts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    width: 100%;
}

.quick-btn {
    padding: 8px 12px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    flex: 1;
    min-width: 60px;
    max-width: calc(25% - 6px);
}

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

/* Quick Categories - FIXED 3x3 */
.quick-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 5px;
    width: 100%;
}

.category-item {
    background: white;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    overflow: hidden;
}

.category-item:active {
    transform: scale(0.98);
}

.category-item.selected {
    border-color: var(--primary);
    background: rgba(67, 97, 238, 0.1);
}

.category-icon {
    font-size: 20px;
    margin-bottom: 5px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--dark);
    line-height: 1.2;
    word-break: break-word;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.quick-payments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    width: 100%;
}

.payment-item {
    padding: 8px 12px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    color: var(--dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

.payment-item:active {
    background: var(--primary);
    color: white;
}

.payment-item.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Masters Page - IMPROVED UI */
.masters {
    min-height: 100%;
    padding-bottom: 20px;
}

.masters-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.masters-section {
    margin-bottom: 30px;
}

.masters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.masters-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.masters-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.masters-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}

.masters-table th {
    text-align: left;
    padding: 15px;
    background: #f8f9fa;
    color: var(--dark);
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.masters-table td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.master-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.badge {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    display: inline-block;
}

.badge.active {
    background: #e8f5e9;
    color: #4caf50;
}

.badge.normal {
    background: #f5f5f5;
    color: #9e9e9e;
}

.master-actions {
    display: flex;
    gap: 8px;
}

.master-action-btn {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.master-action-btn.edit {
    background: #e3f2fd;
    color: #2196f3;
}

.master-action-btn.delete {
    background: #ffebee;
    color: #d32f2f;
}

.master-action-btn:active {
    transform: scale(0.95);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.btn {
    padding: 15px 25px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:active {
    transform: translateY(-2px);
}

.btn-secondary {
    background: #f0f0f0;
    color: var(--dark);
}

/* FAB */
.fab-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 1000;
}

.fab {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 6px 25px rgba(67, 97, 238, 0.4);
    cursor: pointer;
    transition: var(--transition);
}

.fab:active {
    transform: scale(0.95);
    box-shadow: 0 10px 30px rgba(67, 97, 238, 0.6);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.98);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #8e8e93;
    padding: 8px 12px;
    border-radius: 12px;
    transition: var(--transition);
    min-width: 60px;
    border: none;
    background: none;
    font-family: inherit;
    cursor: pointer;
}

.nav-item:active {
    background: #f0f0f0;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(67, 97, 238, 0.1);
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    transition: transform 0.3s ease;
    max-width: 90%;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast i {
    font-size: 20px;
}

.toast.success {
    border-left: 4px solid #4caf50;
}

.toast.success i {
    color: #4caf50;
}

.toast.error {
    border-left: 4px solid #f44336;
}

.toast.error i {
    color: #f44336;
}

.toast.info {
    border-left: 4px solid #2196f3;
}

.toast.info i {
    color: #2196f3;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast span {
    font-size: 14px;
    font-weight: 500;
}

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--gray);
    min-height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray);
    cursor: pointer;
    padding: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 15px;
        padding-bottom: 90px;
        height: calc(100vh - 130px);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .quick-categories {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .chart-container {
        height: 280px;
        padding: 15px;
    }

    #expenseChart {
        height: 220px !important;
    }

    .filter-actions {
        grid-column: span 1;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 15px;
    }

    .stat-value {
        font-size: 20px;
    }

    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .summary-item .value {
        font-size: 18px;
    }

    .quick-categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .category-item {
        padding: 10px;
        min-height: 70px;
    }

    .category-icon {
        font-size: 18px;
    }

    .category-name {
        font-size: 11px;
    }

    .payment-item {
        min-width: 100px;
        padding: 6px 10px;
        font-size: 12px;
    }

    .masters-table {
        font-size: 13px;
    }

    .masters-table th,
    .masters-table td {
        padding: 12px 10px;
    }
}

@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .summary-item {
        padding: 12px 8px;
    }

    .summary-item .value {
        font-size: 16px;
    }

    .quick-categories {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-btn {
        min-width: 50px;
        padding: 6px 8px;
        font-size: 13px;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .main-content {
        height: -webkit-fill-available;
    }

    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Ensure no horizontal scroll */
html,
body,
#root,
.app-container {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Safe area for modern phones */
@supports (padding: max(0px)) {
    .main-content {
        padding-bottom: max(100px, env(safe-area-inset-bottom) + 100px);
    }

    .bottom-nav {
        padding-bottom: max(12px, env(safe-area-inset-bottom) + 12px);
    }
}

/* Add these styles to your existing style.css file */

/* Charts Container */
.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr 1fr;
    }
}

.chart-type-selector {
    display: flex;
    gap: 5px;
}

.chart-type-btn {
    background: #f0f0f0;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    transition: all 0.3s ease;
}

.chart-type-btn:hover {
    background: #e0e0e0;
}

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

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--gray);
    min-height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Quick Categories Grid - Ensure 3x3 layout */
.quick-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 5px;
    width: 100%;
}

.category-item {
    background: white;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    overflow: hidden;
}

.category-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.category-item.selected {
    border-color: var(--primary);
    background: rgba(67, 97, 238, 0.1);
    transform: translateY(-2px);
}

/* Quick Payments */
.quick-payments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    width: 100%;
}

.payment-item {
    padding: 12px 16px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: var(--dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

.payment-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.payment-item.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Quick Amounts */
.quick-amounts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    width: 100%;
}

.quick-btn {
    padding: 10px 14px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    flex: 1;
    min-width: 60px;
    max-width: calc(25% - 6px);
}

.quick-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-btn:active {
    background: var(--primary);
    color: white;
    transform: translateY(0);
}

/* Form improvements */
.form-input:disabled,
.form-select:disabled,
.quick-btn:disabled,
.category-item:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.category-item:disabled:hover,
.payment-item:disabled:hover,
.quick-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Master Data Tables */
.masters-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    margin-top: 10px;
}

.masters-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}

.masters-table th {
    text-align: left;
    padding: 15px;
    background: #f8f9fa;
    color: var(--dark);
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.masters-table td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 280px;
    }

    .quick-categories {
        grid-template-columns: repeat(3, 1fr);
    }

    .payment-item {
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .quick-categories {
        grid-template-columns: repeat(2, 1fr);
    }

    .payment-item {
        min-width: 80px;
        font-size: 12px;
        padding: 8px 12px;
    }

    .quick-btn {
        min-width: 50px;
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* Chart Container - Responsive */
.chart-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
    height: 350px;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 250px;
}

/* Charts Container - Responsive Grid */
.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 767px) {
    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 320px;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 300px;
        padding: 15px;
    }

    .chart-wrapper {
        min-height: 220px;
    }
}

/* Chart Header */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
}

/* Chart Type Selector */
.chart-type-selector {
    display: flex;
    gap: 5px;
    background: #f8f9fa;
    padding: 4px;
    border-radius: 10px;
}

.chart-type-btn {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    transition: all 0.3s ease;
}

.chart-type-btn:hover {
    background: #e0e0e0;
}

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

/* Fix for Chart.js responsiveness */
canvas {
    display: block;
    max-width: 100%;
    height: auto !important;
}

/* Ensure chart containers maintain aspect ratio */
#categoryChart,
#dailyExpensesChart {
    width: 100% !important;
    height: 100% !important;
}

/* Loading animation for charts */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--gray);
    min-height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Stats Grid Responsive */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-value {
        font-size: 20px;
    }
}

/* Quick Categories Grid - Ensure 3x3 layout */
.quick-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 5px;
    width: 100%;
}

@media (max-width: 480px) {
    .quick-categories {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 360px) {
    .quick-categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .category-item {
        padding: 10px;
        min-height: 70px;
    }
}

/* Ensure proper chart rendering on mobile */
@media (max-width: 767px) {
    .main-content {
        padding-bottom: 120px;
    }

    .chart-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .chart-title {
        font-size: 16px;
    }
}