:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-card: rgba(26, 26, 36, 0.8);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --sidebar-width: 260px;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at top left, rgba(99, 102, 241, 0.15), transparent 50%), radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.1), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.25s ease;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    inset-block: 0;
    width: 3px;
    background: var(--accent-gradient);
    transform: scaleY(0);
    transition: transform 0.25s ease;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.nav-item.active::before {
    transform: scaleY(1);
}

.nav-icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.sync-status.synced {
    color: var(--color-success);
}

.sync-status.error {
    color: var(--color-danger);
}

.sync-icon {
    animation: spin 2s linear infinite;
}

.sync-status.synced .sync-icon,
.sync-status.error .sync-icon {
    animation: none;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.refresh-btn {
    width: 100%;
    padding: 1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    min-height: 100vh;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.year-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.year-selector label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.year-selector select {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.last-update {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.25rem;
}

.content-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    transition: all 0.25s ease;
}

.card:hover {
    background: rgba(35, 35, 50, 0.9);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card {
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.income-card::before {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.expense-card::before {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.profit-card::before {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.savings-card::before {
    background: var(--accent-gradient);
}

.card-icon {
    font-size: 2.5rem;
    opacity: 0.9;
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.card-trend {
    font-size: 0.875rem;
    font-weight: 600;
}

.card-trend.positive {
    color: var(--color-success);
}

.card-trend.negative {
    color: var(--color-danger);
}

.card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.chart-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
}

.legend-item {
    color: var(--text-secondary);
}

.legend-item.income {
    color: var(--color-success);
}

.legend-item.expense {
    color: var(--color-danger);
}

.chart-container {
    position: relative;
    height: 300px;
}

.pie-chart-card .chart-container {
    height: 280px;
}

.transactions-card {
    padding: 1.5rem;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.data-table .positive {
    color: var(--color-success);
}

.data-table .negative {
    color: var(--color-danger);
}

.status-badge {
    display: inline-flex;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.surplus {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.status-badge.deficit {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

.status-badge.neutral {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-info);
}

.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.analytics-grid .card {
    padding: 1.5rem;
}

.insights-card {
    grid-column: 1 / -1;
}

.top-expenses-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.expense-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.expense-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.875rem;
}

.expense-info {
    flex: 1;
}

.expense-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.expense-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.expense-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.expense-amount {
    font-weight: 600;
    color: var(--color-danger);
}

.insights-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid;
}

.insight-item.positive {
    border-color: var(--color-success);
}

.insight-item.warning {
    border-color: var(--color-warning);
}

.insight-item.negative {
    border-color: var(--color-danger);
}

.insight-item.info {
    border-color: var(--color-info);
}

.insight-icon {
    font-size: 1.5rem;
}

.insight-content h4 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.insight-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: all 0.25s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1rem;
}

@media (max-width: 1024px) {

    .charts-row,
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .header-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .card-value {
        font-size: 1.25rem;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: var(--radius-full);
}

/* ===== CRUD Modal Styles ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--color-danger);
}

#crudForm {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group>label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.month-inputs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
}

.month-input {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.month-input label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 600;
}

.month-input input {
    padding: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-add {
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-sm);
    color: var(--color-success);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add:hover {
    background: rgba(34, 197, 94, 0.25);
    transform: translateY(-1px);
}

.btn-edit,
.btn-delete {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-edit {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-info);
}

.btn-edit:hover {
    background: rgba(59, 130, 246, 0.3);
}

.btn-delete {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.3);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .month-inputs {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal {
        width: 95%;
        max-height: 85vh;
    }

    .form-row {
        flex-direction: column;
    }
}

/* Form Tabs */
.form-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.form-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.form-tab:hover {
    color: var(--text-primary);
}

.form-tab.active {
    background: var(--accent-gradient);
    color: white;
}

.form-section {
    animation: fadeIn 0.2s ease;
}

.form-section.hidden {
    display: none;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.current-value-display {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.current-value-display strong {
    color: var(--accent-primary);
}

.form-hint {
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    color: var(--color-warning);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ===== AI Chat Styles ===== */
.ai-container {
    max-width: 900px;
    margin: 0 auto;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.ai-avatar {
    font-size: 3rem;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: 50%;
}

.ai-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.ai-info p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 350px);
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.ai-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background: var(--accent-gradient);
}

.user-message .message-avatar {
    background: rgba(34, 197, 94, 0.2);
}

.message-content {
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
}

.ai-message .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.user-message .message-content {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.message-content li {
    margin: 0.25rem 0;
}

.quick-prompts {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    flex-wrap: wrap;
}

.quick-prompt {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.quick-prompt:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.chat-input-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.chat-input-form input {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.chat-input-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.typing-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.typing-text {
    color: var(--accent-primary);
    font-weight: 500;
    font-size: 0.9rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.25rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ===== Enhanced Mobile Responsive ===== */
@media (max-width: 768px) {

    /* Sidebar with backdrop */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .header-right {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .page-title {
        font-size: 1.1rem;
    }

    /* Summary Cards - 2 columns */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .summary-card {
        padding: 0.875rem;
    }

    .card-icon {
        font-size: 1.75rem;
    }

    .card-label {
        font-size: 0.7rem;
    }

    .card-value {
        font-size: 1rem;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 220px;
    }

    /* Tables scroll horizontally */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 0.7rem;
        min-width: 500px;
    }

    .data-table th,
    .data-table td {
        padding: 0.4rem 0.35rem;
    }

    .ai-header {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .ai-avatar {
        font-size: 2rem;
        width: 50px;
        height: 50px;
    }

    .chat-container {
        height: calc(100vh - 260px);
    }

    .message {
        max-width: 92%;
    }

    .quick-prompts {
        gap: 0.5rem;
        padding: 0.75rem;
        flex-wrap: wrap;
    }

    .quick-prompt {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }

    .chat-input-form input {
        padding: 0.7rem;
    }

    .send-btn {
        width: 40px;
        height: 40px;
    }

    .btn-add {
        padding: 0.4rem 0.75rem;
        font-size: 0.7rem;
    }

    .modal {
        width: 95%;
        margin: 0.5rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .summary-cards {
        gap: 0.75rem;
    }

    .card-header h3 {
        font-size: 1rem;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .insight-item {
        flex-direction: column;
        text-align: center;
    }
}

/* AI Markdown Formatting */
.ai-heading {
    margin: 1rem 0 0.5rem 0;
    color: var(--accent-primary);
    font-weight: 600;
}

h2.ai-heading {
    font-size: 1.25rem;
}

h3.ai-heading {
    font-size: 1.1rem;
}

h4.ai-heading {
    font-size: 1rem;
}

.ai-divider {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.ai-list-item {
    display: block;
    padding: 0.25rem 0;
    padding-left: 0.5rem;
}