:root {
    --accent: #cd1818;
    --accent-hover: #b01010;
    --btn-default: #475569;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --border-light: #e2e8f0;
    --bg-card: #f5f7fb;
    --bg-page: #f8fafc;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.04);
    --header-height: 0px;
    --radius-card: 0;
}

.dashboard {
    margin: 0 auto;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.stock-card {
    width: 32%;
    min-width: 280px;
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s ease;
    align-self: flex-start;
    position: sticky;
    top: calc(var(--header-height));
    z-index: 10;
}

.main-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    background: var(--bg-card);
}

.stock-title h2 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.toggle-icon {
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: transform 0.25s ease;
    padding: 0 1rem;
    display: none;
}

.stock-details-wrapper {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.stock-details {
    flex: 1;
    padding: 0.4rem 0;
}

.question-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 0.2rem 1rem 0;
}

.question-item {
    display: flex;
    align-items: flex-start;
    padding: 0.9rem 1.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 1.35rem;
    color: var(--text-secondary);
    line-height: 1.5;
    user-select: none;
    border-radius: 0 0.8rem 0.8rem 0;
    margin: 0 0.2rem;
    background: transparent;
}

.question-item:hover {
    background: #fff5f5;
    color: var(--text-primary);
    border-left-color: #fecaca;
}

.question-item.active {
    background: #fff5f5;
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(205, 24, 24, 0.08);
}

.question-item .q-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.pagination-container {
    padding: 1rem 1rem 1.5rem;
    display: flex;
    justify-content: center;
    border-top: 1px solid var(--border-light);
    background: #fff;
}

.pagination-scroll {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.page-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 2rem;
    padding: 0.4rem 1rem;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 3.2rem;
}

.page-btn.active {
    background: var(--accent);
    color: white;
}

.page-btn:hover:not(.active) {
    background: #e2e8f0;
    color: #1e293b;
}

.answer-area {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.answer-content {
    flex: 1;
    overflow-y: auto;
    min-height: 20rem;
    max-height: none;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    padding: 1.8rem 2rem 2rem 2rem;
    margin-bottom: 12rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.answer-content::-webkit-scrollbar {
    width: 5px;
}
.answer-content::-webkit-scrollbar-track {
    background: transparent;
}
.answer-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 3rem 2rem;
    color: #94a3b8;
    min-height: 20rem;
}
.chat-welcome .welcome-icon {
    font-size: 4.5rem;
    margin-bottom: 1.4rem;
    opacity: 0.7;
}
.chat-welcome h3 {
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.7rem;
}
.chat-welcome p {
    font-size: 1.35rem;
    max-width: 380px;
    line-height: 1.7;
}

.message-row {
    display: flex;
    gap: 1rem;
    animation: fadeInUp 0.35s ease-out;
    max-width: 100%;
}
.message-row.user {
    justify-content: flex-end;
}
.message-row.assistant {
    justify-content: flex-start;
}

.msg-bubble {
    max-width: 90%;
    padding: 1.1rem 1.6rem;
    border-radius: 1.4rem;
    font-size: 1.4rem;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.message-row.user .msg-bubble {
    background: #475569;
    color: #fff;
    border-bottom-right-radius: 0.3rem;
    order: 1;
}
.message-row.assistant .msg-bubble {
    background: #FFF;
    color: var(--text-primary);
    border-bottom-left-radius: 0.3rem;
    order: 2;
    border: 1px solid var(--border-light);
}

.msg-bubble h1 { font-size: 1.9rem; margin: 0.8em 0 0.4em; font-weight: 700; }
.msg-bubble h2 { font-size: 1.6rem; margin: 0.8em 0 0.4em; font-weight: 700; border-left: 3px solid var(--accent); padding-left: 1rem; }
.msg-bubble h3 { font-size: 1.45rem; margin: 0.7em 0 0.3em; font-weight: 600; }
.msg-bubble p { margin: 0.5em 0; }
.msg-bubble ul, .msg-bubble ol { margin: 0.4em 0 0.4em 1.4em; padding-left: 0; }
.msg-bubble li { margin: 0.2em 0; }
.msg-bubble code { background: #f1f5f9; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.88em; font-family: 'SF Mono', 'Consolas', monospace; color: #cd1818; }
.msg-bubble pre { background: #f8fafc; padding: 1rem; border-radius: 0.8rem; overflow-x: auto; margin: 0.8em 0; border: 1px solid #eef2f6; font-size: 1.2rem; }
.msg-bubble pre code { background: transparent; padding: 0; font-size: inherit; color: inherit; }
.msg-bubble blockquote { border-left: 3px solid var(--accent); margin: 0.6em 0; padding-left: 0.9em; color: #64748b; background: #fefaf5; border-radius: 0 0.6rem 0.6rem 0; }
.msg-bubble table { border-collapse: collapse; width: 100%; margin: 0.8em 0; font-size: 1.2rem; }
.msg-bubble th, .msg-bubble td { border: 1px solid #e2e8f0; padding: 0.5rem 0.7rem; text-align: left; }
.msg-bubble th { background: #f8fafc; font-weight: 600; }
.msg-bubble hr { margin: 1.2rem 0; border: none; border-top: 1px solid var(--border-light); }
.msg-bubble strong { color: #0f172a; font-weight: 700; }

.streaming-cursor::after {
    content: '▍';
    animation: blink-cursor 0.8s infinite;
    color: var(--accent);
    font-weight: 400;
    display: inline-block;
}
@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.15; }
}

.loading-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0;
    color: #94a3b8;
    font-size: 1.3rem;
}
.typing-dots {
    display: flex;
    gap: 4px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-7px); opacity: 1; }
}

.chat-input-bar {
    position: fixed;
    bottom: 2.8rem;
    z-index: 100;
    background: #fff;
    border-top: 1px solid var(--border-light);
    border-radius: 0;
    padding: 1.2rem 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
    transition: bottom 0.2s ease;
    left: 0;
    right: 0;
    width: 100%;
    box-sizing: border-box;
}
.chat-input-bar textarea {
    flex: 1;
    border: 1px solid var(--border-light);
    border-radius: 1.4rem;
    padding: 0.9rem 1.4rem;
    font-size: 1.6rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    min-height: 6rem;
    max-height: 13rem;
    line-height: 1.5;
    background: #fafbfc;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.chat-input-bar textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(205, 24, 24, 0.06);
    background: #fff;
}
.send-btn {
    flex-shrink: 0;
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 1.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(205, 24, 24, 0.2);
}
.send-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}
.send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    opacity: 0.65;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    color: #10b981;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 1rem;
}
.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


@media (max-width: 768px) {
    .dashboard {
        gap: 1rem;
        flex-direction: column;
    }
    .stock-card {
        width: 100%;
        min-width: auto;
        position: static;
        align-self: auto;
        top: auto;
    }
    .main-panel {
        min-height: 65vh;
    }
    .toggle-icon {
        display: inline-block !important;
    }
    .stock-details-wrapper.collapsed .stock-details,
    .stock-details-wrapper.collapsed .pagination-container {
        display: none;
    }
    .stock-header.open .toggle-icon {
        transform: rotate(180deg);
    }
    .answer-content {
        padding: 1.2rem 1.4rem;
        padding-bottom: 14rem;
    }
    .chat-input-bar {
        bottom: 6rem;
        padding: 1rem 1.4rem;
    }
    .msg-bubble {
        max-width: 88%;
        font-size: 1.6rem;
    }
    .chat-welcome .welcome-icon { font-size: 3.5rem; }
    .question-item { font-size: 1.6rem; padding: 0.8rem 1.1rem; }
}

@media (max-width: 480px) {
    .question-item { font-size: 1.5rem; padding: 0.7rem 1rem; }
    .msg-bubble { max-width: 92%; font-size: 1.5rem; }
    .chat-input-bar textarea { font-size: 1.5rem; min-height: 3.4rem; }
    .send-btn { width: 3.4rem; height: 3.4rem; }
    .answer-content { padding-bottom: 3rem; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}