:root {
    --primary-blue: #0A3C5F; /* Dark blue from PLAN */
    --primary-red: #E03E3E; /* Standard red */
    --primary-green: #177C3D; /* Dark green from MY EXPENSES */
    --primary-orange: #D47A31; /* Squirrel orange */
    --bg-light: #F4F7F4; /* Very light greenish tint */
    --text-main: #182B21; /* Dark greenish gray */
    --text-muted: #5E7166;
    --card-bg: #FFFFFF;
    --border-color: #D1DFD7;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-lg: 12px;
    --radius-md: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.main-content {
    padding: 2rem;
    height: calc(100vh - 73px);
    overflow: hidden;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr; /* 40% and 60% approx */
    gap: 2rem;
    align-items: start;
    height: 100%;
}

.layout-left {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.layout-right {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-right: 0.5rem;
}

@media (max-width: 1024px) {
    .main-content {
        height: auto;
        overflow: visible;
    }
    .layout-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .layout-left, .layout-right {
        height: auto;
        overflow: visible;
    }
    .categories-section {
        max-height: 600px;
    }
}

/* Header */
.main-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    width: 100%;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    background: var(--primary-blue);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Buttons */
.icon-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.icon-btn:hover {
    background: var(--bg-light);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

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

.btn.primary:hover {
    background: #2563EB;
}

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

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

/* Month Selector */
.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.month-selector.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.month-selector h2 {
    font-size: 1.125rem;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
}

/* Dashboard Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.card-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--primary-blue); }
.card-icon.red { background: rgba(239, 68, 68, 0.1); color: var(--primary-red); }
.card-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--primary-green); }

.card-value {
    font-size: 2rem;
    font-weight: 700;
}

.card-value.green { color: var(--primary-green); }

/* Chart Section */
.chart-section {
    margin-bottom: 2rem;
}

.chart-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
}

.chart-container {
    position: relative;
    height: 250px;
    display: flex;
    margin-bottom: 2rem;
    padding-left: 40px;
}

.y-axis {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 30px;
    width: 35px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 5px;
}

.y-axis-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    transform: translateY(-50%);
}

.chart-grid {
    position: absolute;
    left: 40px;
    right: 0;
    top: 0;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 0;
}

.grid-line {
    border-top: 1px dashed #e5e7eb;
    width: 100%;
    height: 0;
}

.grid-line-base {
    border-top: 1px solid #9ca3af;
    width: 100%;
    height: 0;
}

.chart-data {
    position: absolute;
    left: 40px;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    z-index: 1;
}

.chart-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.hover-bg {
    position: absolute;
    top: 0;
    bottom: 30px;
    left: 0;
    right: 0;
    background-color: transparent;
    transition: background-color 0.2s;
    z-index: -1;
    border-radius: 12px;
}

.chart-column:hover .hover-bg {
    background-color: #f1f5f9;
}

.bars-wrapper {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: calc(100% - 30px);
}

.bar-combined {
    width: 60%;
    max-width: 50px;
    border: 2px solid var(--primary-green);
    border-radius: 50px;
    position: relative;
    background: transparent;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

.bar-fill {
    width: 100%;
    background: var(--primary-red);
    border-radius: 50px;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
}

.bar-fill.over-budget {
    background: #b91c1c;
}

.bar-pct {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.column-label {
    position: absolute;
    bottom: 0;
    height: 30px;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.custom-tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
    min-width: 140px;
    color: white;
}

.chart-column:hover .custom-tooltip {
    opacity: 1;
}

.tt-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: #f8fafc;
}

.tt-row {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #cbd5e1;
}

.tt-row-val {
    margin-left: auto;
    font-weight: 500;
}

.tt-row.green .dot { background: var(--primary-green); }
.tt-row.red .dot { background: var(--primary-red); }

.chart-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
}

.dot.budgeted { background: var(--primary-green); }
.dot.spent { background: var(--primary-blue); }

/* Categories Grid */
.categories-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.categories-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.cat-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--bg-light);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.cat-stats {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.cat-stats span {
    font-weight: 600;
    color: var(--text-main);
}

.progress-container {
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary-green);
    transition: width 0.3s ease;
}

.progress-bar.warning { background: var(--primary-red); }

.cat-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.cat-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.modal {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    position: absolute;
    /* Center it since we changed to absolute */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.stacked-modal {
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.4), var(--shadow-lg);
    z-index: 1010;
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.settings-sticky-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
    flex-shrink: 0;
}

.settings-sticky-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
}

.modal-footer {
    padding: 1.25rem;
    background: var(--bg-light);
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
}

.modal-footer .btn {
    justify-content: center;
    padding: 0.75rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.modal-footer .btn.secondary {
    flex: 1;
}

.modal-footer .btn.primary {
    flex: 2;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input, .form-group select,
.timeline-row input, .timeline-row select,
.add-fixed-row input, .add-fixed-row select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-main);
    background: white;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input {
    width: auto;
}

.hidden {
    display: none !important;
}

.large-modal {
    max-width: 900px;
    height: 80vh;
}

.import-table-container {
    height: 100%;
    overflow-y: auto;
}

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

.import-table th {
    background: var(--bg-light);
    padding: 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

.import-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.import-table tr:last-child td {
    border-bottom: none;
}

.import-table select {
    width: 100%;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
}

.import-table .amt-expense {
    color: var(--primary-red);
    font-weight: 500;
}

.import-table .amt-income {
    color: var(--primary-green);
    font-weight: 500;
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.fixed-cat-list {
    margin-bottom: 1.5rem;
}

.fixed-cat-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.fixed-cat-container {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.cat-header-row {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.timeline-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.input-with-symbol {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 10px;
    font-size: 0.875rem;
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-symbol input {
    padding-left: 36px !important;
}

.add-new-fixed-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.sub-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.add-fixed-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.8fr auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.btn.full-width {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
}

.trash-btn {
    background: none;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    width: 40px;
    height: 40px;
    transition: all 0.2s;
    border-radius: 50%;
}

.trash-btn:hover {
    color: var(--primary-red);
    background: rgba(239, 68, 68, 0.1);
}

.btn.sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    .month-selector {
        gap: 1rem;
    }
    
    .month-selector h2 {
        min-width: 100px;
        font-size: 1rem;
    }
    
    .card-value {
        font-size: 1.25rem;
    }

    .dashboard-grid {
        gap: 0.5rem;
    }

    .card {
        padding: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .chart-container {
        gap: 1rem;
    }
}

/* Inline Expenses */
.cat-actions-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toggle-expenses-btn {
    background: var(--bg-light);
    color: var(--text-main);
    border: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-expenses-btn:hover {
    background: #e2e8f0;
}

.expenses-list {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.expenses-list-title {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.expense-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.expense-info {
    display: flex;
    flex-direction: column;
}

.expense-title {
    font-weight: 500;
    font-size: 0.95rem;
}

.expense-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.expense-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.expense-amount {
    font-weight: 600;
    margin-right: 0.5rem;
}

.no-expenses {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Pie Charts Section */
.pies-section {
    margin-bottom: 2rem;
}

.pies-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .pies-grid {
        grid-template-columns: 1fr;
    }
}

.pie-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.pie-wrapper h3 {
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
    width: 100%;
}

.pie-container {
    position: relative;
    width: 350px;
    height: 350px;
    margin: 0 auto 2rem;
}

.pie-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    overflow: visible;
}

.pie-slice {
    transition: transform 0.2s, opacity 0.2s;
    transform-origin: center;
    cursor: pointer;
    stroke: white;
    stroke-width: 2;
}

.pie-slice:hover {
    transform: scale(1.05);
}

.pie-label {
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: none;
}

.pie-tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
    white-space: nowrap;
    color: #f8fafc;
    font-size: 0.875rem;
}

.pie-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

/* AI Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 380px;
    height: 550px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: bottom right;
    overflow: hidden;
}

.chat-widget.hidden {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
}

.chat-widget.fullscreen {
    width: 90vw;
    height: 90vh;
    max-width: 800px;
    bottom: 5vh;
    right: 50%;
    transform: translateX(50%);
    border-radius: var(--radius-lg);
}

.chat-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1));
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #4C1D95;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-title .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #8B5CF6;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-actions .icon-btn {
    border: none;
    color: #6D28D9;
    background: transparent;
}

.chat-actions .icon-btn:hover {
    background: rgba(139, 92, 246, 0.15);
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #FAFAFA;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideUp 0.3s ease-out forwards;
}

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

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message .bubble {
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
    white-space: pre-wrap;
}

.chat-message.assistant .bubble {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.chat-message.user .bubble {
    background: #8B5CF6;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-footer {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0.25rem 0.5rem 0.25rem 1rem;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: #8B5CF6;
    background: white;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
    resize: none;
    max-height: 100px;
    outline: none;
}

.mic-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mic-btn:hover {
    color: #8B5CF6;
    background: rgba(139, 92, 246, 0.1);
}

.mic-btn.recording {
    color: white;
    background: #EF4444;
    animation: pulseRed 1.5s infinite;
}

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #8B5CF6;
    border-color: #8B5CF6;
    color: white;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #7C3AED;
    border-color: #7C3AED;
}

/* --- Mobile / PWA Optimizations --- */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .title-group h1 {
        font-size: 1.2rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .pies-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        width: 95%;
        max-width: none;
        margin: 1rem auto;
        max-height: 90vh;
    }

    .settings-sticky-header {
        flex-direction: column;
    }
    
    .settings-sticky-header > div {
        flex-direction: column;
    }

    .chat-widget {
        width: 100%;
        bottom: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
    }

    .category-card {
        padding: 1rem;
    }

    .cat-actions-left {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cat-actions-left button {
        width: 100%;
        justify-content: center;
    }
}
