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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    width: 100%;
    height: 100vh;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
}

.body-area {
    display: flex;
    gap: 0;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
}

.main-area {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
    height: 100%;
}

.chat-container {
    flex: 1;
    min-width: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.report-panel {
    flex: 0 0 38%;
    min-width: 420px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    height: 100%;
}

.report-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #999;
    font-size: 14px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 4px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    gap: 8px;
}

.header-center {
    text-align: center;
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
}

.header-btn {
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 13px;
    cursor: pointer;
    color: #444;
    transition: all 0.2s;
    white-space: nowrap;
}

.header-btn:hover {
    background: #f0f4ff;
    border-color: #1a73e8;
    color: #1a73e8;
}

.header-btn.active {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
}

header h1 {
    color: #1a73e8;
    font-size: 22px;
}

header p {
    color: #666;
    font-size: 13px;
}

/* ─── Body / Sidebar ─── */
.sidebar {
    width: 0;
    overflow: hidden;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: width 0.25s ease;
    flex-shrink: 0;
    margin-right: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar.open {
    width: 260px;
}

.sidebar-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 15px;
    color: #333;
    font-weight: 600;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conv-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}

.conv-item:hover {
    background: #f5f5f5;
}

.conv-item.active {
    background: #e8f0fe;
    color: #1a73e8;
    font-weight: 500;
}

.conv-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-item-del {
    visibility: hidden;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

.conv-item:hover .conv-item-del {
    visibility: visible;
}

.conv-item-del:hover {
    color: #e53935;
}

.conv-empty {
    padding: 24px 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.settings-btn:hover {
    color: #1a73e8;
    background: rgba(26, 115, 232, 0.1);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

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

.modal-header h2 {
    font-size: 18px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 4px 8px;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #1a73e8;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #eee;
    text-align: right;
}

.save-btn {
    padding: 10px 24px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.save-btn:hover {
    background: #1557b0;
}


.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: #1a73e8;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-content table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}

.message-content th {
    background: #e8e8e8;
    font-weight: 600;
}

.message-content code {
    background: #e0e0e0;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
}

.message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.message-content ul,
.message-content ol {
    padding-left: 20px;
    margin: 4px 0;
}

.message-content p {
    margin: 4px 0;
}

.message-content > *:last-child {
    margin-bottom: 0;
}

.input-area {
    display: flex;
    padding: 16px;
    border-top: 1px solid #eee;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.input-area input:focus {
    border-color: #1a73e8;
}

.input-area button {
    margin-left: 12px;
    padding: 12px 24px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.input-area button:hover {
    background: #1557b0;
}

.input-area button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.tool-line {
    margin: 4px 20px 4px 20px;
    padding: 6px 16px;
    font-size: 13px;
    color: #666;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #1a73e8;
}

.tool-line .tool-spinner {
    font-size: 12px;
}

.tool-line .tool-done {
    font-size: 12px;
}

.tool-line .tool-label {
    font-weight: 500;
    color: #444;
}

.message.ai.streaming .message-content::after {
    content: '▊';
    animation: blink 0.8s infinite;
    color: #1a73e8;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ============================================================
   BOM 卡片组件样式
   ============================================================ */

.bom-card {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    font-size: 14px;
    line-height: 1.6;
}

.bom-header {
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    padding: 20px;
}

.bom-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 10px;
}

.bom-summary {
    display: flex;
    gap: 20px;
    font-size: 13px;
    opacity: 0.9;
}

.bom-summary-value {
    font-weight: 700;
    font-size: 18px;
}

.bom-section {
    background: white;
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.bom-section:last-of-type { border-bottom: none; }

.bom-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a73e8;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e8f0fe;
}

/* 产品卡片 */
.bom-product-card {
    display: flex;
    gap: 14px;
    padding: 12px;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
}

.bom-product-card:last-child { margin-bottom: 0; }
.bom-product-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.bom-product-img {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: contain;
    background: #f8f9fa;
    flex-shrink: 0;
}

.bom-product-info { flex: 1; min-width: 0; }

.bom-product-name {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: #1a73e8;
    margin-bottom: 2px;
    text-decoration: none;
    cursor: pointer;
}
.bom-product-name:hover {
    text-decoration: underline;
    color: #1557b0;
}
.bom-table td a {
    color: #1a73e8;
    text-decoration: none;
}
.bom-table td a:hover {
    text-decoration: underline;
    color: #1557b0;
}

.bom-product-id {
    font-size: 11px;
    color: #80868b;
    font-family: monospace;
    margin-bottom: 4px;
}

.bom-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #ea4335;
    margin-bottom: 6px;
}

.bom-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.bom-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    background: #e8f0fe;
    color: #1a73e8;
}

.bom-tag-iface { background: #fce8e6; color: #c5221f; }

.bom-product-desc {
    font-size: 12px;
    color: #5f6368;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bom-wiki-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: #1a73e8;
    text-decoration: none;
}

.bom-wiki-link:hover {
    text-decoration: underline;
}

/* 板载能力 */
.bom-onboard-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    font-size: 13px;
}

.bom-onboard-item + .bom-onboard-item { border-top: 1px solid #f1f3f4; }
.bom-onboard-check { color: #34a853; font-weight: 700; }
.bom-onboard-need { font-weight: 500; }
.bom-onboard-arrow { color: #80868b; }
.bom-onboard-provided { color: #1a73e8; font-weight: 500; }
.bom-onboard-note { color: #80868b; font-size: 11px; }

/* 警告 */
.bom-warnings { padding: 10px 16px; background: #fff8e1; border-bottom: 1px solid #f0f0f0; }
.bom-warning { font-size: 13px; color: #e65100; padding: 3px 0; }

/* BOM 表格 */
.bom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.bom-table th {
    background: #f8f9fa;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #5f6368;
    border-bottom: 2px solid #e8eaed;
}

.bom-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f3f4;
}

.bom-table td code {
    background: #f1f3f4;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}

.bom-table .bom-qty { text-align: center; }
.bom-table .bom-price { text-align: right; font-family: monospace; white-space: nowrap; }

.bom-total-row td {
    font-weight: 700;
    border-top: 2px solid #e8eaed;
    background: #f8f9fa;
}

/* 报告 */
.bom-report { font-size: 13px; color: #333; line-height: 1.6; }
.bom-report h1, .bom-report h2, .bom-report h3 { color: #1a73e8; margin: 8px 0 4px; }
.bom-report h1 { font-size: 16px; }
.bom-report h2 { font-size: 14px; }
.bom-report h3 { font-size: 13px; }
.bom-report p { margin: 3px 0; }
.bom-report strong { color: #1a73e8; }
.bom-report ul, .bom-report ol { padding-left: 18px; margin: 3px 0; }
.bom-report li { margin: 1px 0; }
.bom-report hr { border: none; border-top: 1px solid #e8eaed; margin: 8px 0; }
.bom-report table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.bom-report th, .bom-report td { padding: 4px 8px; border: 1px solid #e8eaed; text-align: left; }
.bom-report th { background: #f8f9fa; font-weight: 600; }

/* 页脚 */
.bom-footer {
    text-align: center;
    padding: 10px;
    font-size: 11px;
    color: #80868b;
    background: #f8f9fa;
    border-top: 1px solid #e8eaed;
}
