* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Modern, refined color palette */
    --primary-color: #1a1a1a;
    --secondary-color: #1fb112;
    --accent-color: #a78725;
    --background-primary: #ffffff;
    --background-secondary: #f8f9fa;
    --background-tertiary: #f0f1f3;
    --border-color: #e4e4e7;
    --text-primary: #1a1a1a;
    --text-secondary: #71717a;
    --text-tertiary: #a1a1aa;
    --success-color: #16a34a;
    --warning-color: #ea580c;
    --hover-bg: #f4f4f5;
    --selection-bg: rgba(155, 46, 195, 0.289);
}

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Geist', system-ui, -apple-system, sans-serif;
    background: var(--background-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Controls */
.controls {
    background: var(--background-primary);
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

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

.controls select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--background-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    min-width: 200px;
}

.controls select:hover {
    border-color: var(--text-secondary);
    background-color: var(--background-secondary);
}

.controls select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--selection-bg);
}

/* Buttons */
.btn-refresh,
.btn-add-row {
    padding: 0.5rem 1rem;
    background: var(--background-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-refresh:hover,
.btn-add-row:hover {
    background: var(--background-tertiary);
    border-color: var(--text-secondary);
}

.btn-refresh:active,
.btn-add-row:active {
    transform: scale(0.98);
}

.record-count {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    margin-left: auto;
}

.changes-indicator {
    color: var(--warning-color);
    font-weight: 600;
    font-size: 0.8125rem;
}

.btn-submit {
    padding: 0.5rem 1rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-family: inherit;
    margin-left: auto;
}

.btn-submit:hover:not(:disabled) {
    background: #15803d;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.2);
}

.btn-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-submit:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Table Wrapper */
.table-wrapper {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--background-primary);
}

.table-container {
    flex: 1;
    overflow: auto;
    border-bottom: 1px solid var(--border-color);
}

/* Table Styling - Professional Spreadsheet */
#data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

#data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--background-secondary);
}

#data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    user-select: none;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#data-table th:last-child {
    border-right: none;
}

#data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

#data-table tbody tr:hover {
    background-color: var(--selection-bg);
}

#data-table td {
    padding: 0.75rem 1rem;
    border-right: 1px solid var(--border-color);
    word-wrap: break-word;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease;
    color: var(--text-primary);
}

#data-table td:last-child {
    border-right: none;
}

#data-table td:hover {
    background-color: var(--background-secondary);
}

#data-table td.edited {
    background-color: rgba(15, 118, 110, 0.08);
    font-weight: 500;
}

#data-table td.editing {
    padding: 0.5rem;
    overflow: visible;
}

#data-table td.editing input {
    width: 100%;
    border: 2px solid var(--accent-color);
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    font-family: inherit;
    border-radius: 4px;
    background: var(--background-primary);
    color: var(--text-primary);
}

#data-table td.editing input:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--selection-bg);
}

/* Empty/Loading State */
.loading {
    text-align: center;
    color: var(--text-tertiary);
    padding: 3rem !important;
    font-size: 0.9rem;
}

/* Footer/Status Bar */
.footer {
    background: var(--background-secondary);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.8125rem;
    border-top: 1px solid var(--border-color);
}

#status {
    font-weight: 500;
    color: var(--text-primary);
}

#scroll-info {
    color: var(--text-tertiary);
}

/* Scrollbar Styling */
.table-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: transparent;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-tertiary);
    background-clip: content-box;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
    backdrop-filter: blur(2px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--background-primary);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: 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 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--background-secondary);
}

.modal-body {
    padding: 1.5rem;
}

#add-row-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

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

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--selection-bg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--background-secondary);
}

.btn-cancel {
    padding: 0.6rem 1.2rem;
    background: var(--background-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-family: inherit;
}

.btn-cancel:hover {
    background: var(--background-secondary);
    border-color: var(--text-secondary);
}

.btn-submit-add {
    padding: 0.6rem 1.2rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-family: inherit;
}

.btn-submit-add:hover {
    background: #15803d;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.2);
}

.btn-submit-add:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .controls select,
    .controls label {
        width: 100%;
    }

    .record-count {
        margin-left: 0;
        text-align: center;
    }

    #data-table td {
        max-width: 120px;
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    #data-table th {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        padding: 0.5rem 1rem;
    }
}

/* =========================================================
   Opportunity Wizard Overlay
   ========================================================= */

/* Full-screen overlay */
.wizard-overlay {
    position: fixed;
    inset: 0;                         /* top/right/bottom/left: 0 */
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;                    /* above the generic modal at 1000 */
    display: flex;
    flex-direction: column;
    animation: wizardFadeIn 0.25s ease-out;
}

.wizard-overlay.hidden {
    display: none;
}

/* ---- Progress Bar ---- */
.wizard-progress {
    background: var(--background-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wizard-step-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    position: relative;
}

.wizard-step-dot {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--background-secondary);
    color: var(--text-tertiary);
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.wizard-step.active .wizard-step-dot {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(167, 135, 37, 0.2);
}

.wizard-step.completed .wizard-step-dot {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.wizard-step-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.wizard-step.active .wizard-step-label {
    color: var(--accent-color);
    font-weight: 600;
}

.wizard-step.completed .wizard-step-label {
    color: var(--success-color);
}

.wizard-step-connector {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 0.5rem;
    margin-bottom: 1.25rem;   /* vertically align with dot center */
    transition: background 0.3s ease;
}

.wizard-step-connector.completed {
    background: var(--success-color);
}

/* Close button inside progress bar */
.wizard-close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 1.5rem;
}

.wizard-close-btn:hover {
    color: var(--text-primary);
    background: var(--background-secondary);
}

/* ---- Wizard Body (scrollable step area) ---- */
.wizard-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Each panel is full-size, layered; only `.active` is visible */
.wizard-panel {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transform: translateX(40px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.wizard-panel.active {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}

.wizard-panel.exiting-left {
    opacity: 0;
    transform: translateX(-40px);
    pointer-events: none;
}

.wizard-panel.entering-right {
    opacity: 0;
    transform: translateX(40px);
    pointer-events: none;
}

.wizard-panel-inner {
    width: 100%;
    max-width: 680px;
    padding: 2.5rem 2rem;
}

/* ---- Wizard Typography ---- */
.wizard-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

.wizard-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

/* ---- Wizard Fields ---- */
.wizard-fields {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.wizard-fields-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.wizard-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wizard-field-full {
    grid-column: 1 / -1;
}

.wizard-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.wizard-required {
    color: var(--warning-color);
    margin-left: 2px;
}

.wizard-input,
.wizard-select {
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    width: 100%;
}

.wizard-input:focus,
.wizard-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(167, 135, 37, 0.15);
}

.wizard-input.input-error {
    border-color: var(--warning-color);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

.wizard-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2371717a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.wizard-textarea {
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    resize: vertical;
    min-height: 8rem;
    line-height: 1.6;
}

.wizard-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(167, 135, 37, 0.15);
}

/* ---- Validation Error ---- */
.wizard-field-error {
    font-size: 0.8125rem;
    color: var(--warning-color);
    font-weight: 500;
}

.wizard-field-error.hidden {
    display: none;
}

/* ---- Autocomplete Dropdown ---- */
.wizard-autocomplete-container {
    position: relative;
}

.wizard-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background-primary);
    border: 1.5px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.wizard-autocomplete-dropdown.hidden {
    display: none;
}

.wizard-autocomplete-item {
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.15s ease;
    font-size: 0.9375rem;
}

.wizard-autocomplete-item:hover {
    background-color: var(--background-secondary);
}

.wizard-autocomplete-item:first-child {
    border-top: none;
}

/* ---- Confirmation Screen ---- */
.wizard-confirmation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.75rem;
}

.wizard-confirm-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.wizard-confirm-item.full-width {
    grid-column: 1 / -1;
}

.wizard-confirm-key {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
}

.wizard-confirm-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: pre-wrap;
    word-break: break-word;
}

.wizard-confirm-value.empty {
    color: var(--text-tertiary);
    font-style: italic;
    font-weight: 400;
}

/* Submit status / loading message */
.wizard-submit-status {
    margin-top: 1.25rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    background: var(--background-secondary);
    color: var(--text-secondary);
    text-align: center;
}

.wizard-submit-status.hidden {
    display: none;
}

.wizard-submit-status.success {
    background: rgba(22, 163, 74, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(22, 163, 74, 0.3);
}

.wizard-submit-status.error {
    background: rgba(234, 88, 12, 0.08);
    color: var(--warning-color);
    border: 1px solid rgba(234, 88, 12, 0.3);
}

/* ---- Footer Navigation ---- */
.wizard-footer {
    background: var(--background-primary);
    border-top: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wizard-footer-center {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.wizard-btn-back,
.wizard-btn-next {
    padding: 0.75rem 1.75rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.wizard-btn-back {
    background: var(--background-secondary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}

.wizard-btn-back:hover:not(:disabled) {
    background: var(--background-tertiary);
    border-color: var(--text-secondary);
}

.wizard-btn-back:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.wizard-btn-next {
    background: var(--accent-color);
    color: white;
    border: none;
}

.wizard-btn-next:hover:not(:disabled) {
    background: #8a6e1d;
    box-shadow: 0 2px 10px rgba(167, 135, 37, 0.3);
}

.wizard-btn-next:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ---- Wizard Animations ---- */
@keyframes wizardFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- Responsive adjustments ---- */
@media (max-width: 600px) {
    .wizard-panel-inner {
        padding: 1.5rem 1.25rem;
    }

    .wizard-title {
        font-size: 1.5rem;
    }

    .wizard-fields-row {
        grid-template-columns: 1fr;
    }

    .wizard-confirmation {
        grid-template-columns: 1fr;
    }

    .wizard-confirm-item.full-width {
        grid-column: 1;
    }

    .wizard-step-label {
        display: none;   /* too cramped on mobile; dots are enough */
    }

    .wizard-progress {
        padding: 1rem;
    }

    .wizard-footer {
        padding: 1rem 1.25rem;
    }
}

/* =========================================================
   AI Chat Interface - Refined Conversational
   ========================================================= */

.chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--background-primary);
    overflow: hidden;
}

/* Backend Selector */
.backend-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 2rem;
    background: var(--background-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.backend-selector label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.backend-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--background-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.backend-select:hover {
    border-color: var(--text-secondary);
    background-color: var(--background-secondary);
}

.backend-select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(31, 177, 18, 0.12);
}

/* Viewport - Main scrollable area */
.chat-viewport {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--background-primary) 0%, rgba(248, 249, 250, 0.5) 100%);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Welcome State */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    padding: 3rem 2rem;
    margin: auto;
}

.welcome-icon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.chat-welcome h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.3px;
}

.chat-welcome p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
    max-width: 320px;
}

.welcome-hints {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    padding: 0.75rem 1rem;
    background: var(--background-secondary);
    border-left: 2px solid var(--secondary-color);
    border-radius: 4px;
    font-style: italic;
    transition: all 0.2s ease;
    cursor: pointer;
}

.hint:hover {
    background: var(--background-tertiary);
    color: var(--text-secondary);
    border-left-color: var(--accent-color);
    transform: translateX(4px);
}

/* Individual Messages */
.chat-message {
    display: flex;
    gap: 0.75rem;
    animation: messageSlide 0.35s cubic-bezier(0.23, 1, 0.320, 1);
    line-height: 1.6;
}

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

/* User Message */
.chat-message.user {
    justify-content: flex-end;
}

.chat-message.user p {
    margin: 0;
    background: var(--secondary-color);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: 16px 16px 4px 16px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 0.9375rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(31, 177, 18, 0.15);
}

/* Assistant Message */
.chat-message.assistant {
    justify-content: flex-start;
}

.assistant-content {
    background: var(--background-secondary);
    color: var(--text-primary);
    padding: 0.875rem 1.25rem;
    border-radius: 16px 16px 16px 4px;
    max-width: 80%;
    border-left: 3px solid var(--accent-color);
    font-size: 0.9375rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.assistant-content p {
    margin: 0.5rem 0;
}

.assistant-content p:first-child {
    margin-top: 0;
}

.assistant-content p:last-child {
    margin-bottom: 0;
}

.assistant-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.assistant-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.assistant-content code {
    background: var(--background-primary);
    color: var(--accent-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Geist Mono', monospace;
    font-size: 0.85em;
    font-weight: 500;
}

/* Error Message */
.chat-message.error p {
    background: rgba(234, 88, 12, 0.08);
    color: var(--warning-color);
    border-radius: 12px;
    border-left: 3px solid var(--warning-color);
    padding: 0.875rem 1.25rem;
    max-width: 80%;
    margin: 0;
    box-shadow: 0 1px 4px rgba(234, 88, 12, 0.1);
}

.error-text {
    margin: 0;
    font-weight: 500;
}

.system-text {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
    padding: 0.5rem 0;
}

/* Footer - Input Area (Fixed at bottom) */
.chat-footer {
    background: var(--background-primary);
    border-top: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: all 0.25s ease;
    resize: none;
    font-weight: 500;
}

.chat-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(31, 177, 18, 0.12);
    background: var(--background-secondary);
}

.chat-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    transition: transform 0.2s ease;
}

.chat-send-btn:hover:not(:disabled) {
    background: #17960d;
    box-shadow: 0 4px 12px rgba(31, 177, 18, 0.25);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.chat-send-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Status Indicator */
.chat-status {
    font-size: 0.8125rem;
    min-height: 1.25rem;
    display: none;
}

.status-loading {
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-loading::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.status-error {
    color: var(--warning-color);
    font-weight: 500;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
    background-clip: content-box;
}

/* Responsive Design */
@media (max-width: 768px) {
    .backend-selector {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .backend-select {
        width: 100%;
    }

    .chat-messages {
        padding: 1.5rem 1rem;
        gap: 1rem;
    }

    .chat-message {
        gap: 0.5rem;
    }

    .chat-message.user p,
    .assistant-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .chat-footer {
        padding: 1rem;
    }

    .chat-input-wrapper {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .chat-input {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .chat-send-btn {
        width: 40px;
        height: 40px;
    }

    .chat-send-btn svg {
        width: 18px;
        height: 18px;
    }

    .chat-welcome {
        padding: 2rem 1rem;
    }

    .chat-welcome h2 {
        font-size: 1.5rem;
    }

    .welcome-hints {
        flex-direction: column;
    }
}
