/* ============================================================
   套定额 Web — 全局样式（暗色主题，聊天风格）
   ============================================================ */
:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface2: #0f3460;
    --accent: #e94560;
    --text: #eee;
    --text2: #aaa;
    --border: #2a2a4a;
    --success: #4ecca3;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.loading-screen {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100vh; color: var(--text2);
}

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.layout {
    display: flex; height: 100vh;
}

/* 侧栏 */
.sidebar {
    width: 260px; min-width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 16px;
    overflow-y: auto;
}
.sidebar-logo {
    font-size: 18px; font-weight: bold;
    color: var(--accent); margin-bottom: 16px;
}
.sidebar-section-title {
    font-size: 11px; color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 12px 0 6px;
}
.quick-tag {
    display: block;
    padding: 6px 10px; margin-bottom: 4px;
    border-radius: var(--radius);
    background: var(--surface2);
    cursor: pointer; font-size: 13px;
    transition: background 0.15s;
}
.quick-tag:hover { background: var(--accent); color: #fff; }

.chapter-item {
    padding: 4px 6px; font-size: 12px;
    cursor: pointer; border-radius: 4px;
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis;
}
.chapter-item:hover { background: var(--surface2); }

/* 聊天区 */
.chat-area {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0;
}
.chat-messages {
    flex: 1; overflow-y: auto;
    padding: 20px 24px;
}
.chat-welcome {
    text-align: center; margin-top: 60px; color: var(--text2);
}
.chat-welcome h3 { color: var(--accent); margin-bottom: 8px; }
.chat-welcome p { font-size: 14px; }

.message-row {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-user {
    display: flex; justify-content: flex-end;
}
.message-user .bubble {
    background: var(--accent); color: #fff;
    padding: 10px 16px; border-radius: 16px 16px 4px 16px;
    max-width: 70%; font-size: 14px; line-height: 1.5;
}

.message-assistant {
    display: flex; flex-direction: column;
    align-items: flex-start;
}

.thinking-block {
    color: var(--text2); font-size: 13px;
    padding: 6px 0; font-style: italic;
}

.chat-input-bar {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 10px; background: var(--surface);
}
.chat-input-bar input {
    flex: 1; padding: 10px 14px;
    border-radius: 20px; border: 1px solid var(--border);
    background: var(--bg); color: var(--text);
    font-size: 14px; outline: none;
}
.chat-input-bar input:focus { border-color: var(--accent); }
.chat-input-bar button {
    padding: 10px 20px; border-radius: 20px;
    border: none; background: var(--accent); color: #fff;
    font-size: 14px; cursor: pointer;
    white-space: nowrap;
}
.chat-input-bar button:disabled {
    opacity: 0.5; cursor: default;
}

/* 定额卡片 */
.quota-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px; margin-bottom: 10px;
    background: var(--surface);
    transition: border-color 0.2s;
}
.quota-card:hover { border-color: var(--accent); }
.quota-card .card-header {
    display: flex; justify-content: space-between;
    align-items: baseline; margin-bottom: 8px;
}
.quota-card .card-code {
    color: var(--accent); font-weight: bold; font-size: 15px;
}
.quota-card .card-name { font-size: 14px; }
.quota-card .card-breadcrumb {
    font-size: 11px; color: var(--text2); margin-bottom: 10px;
}
.quota-card .card-numbers {
    display: flex; gap: 20px; flex-wrap: wrap;
    font-size: 13px; margin-bottom: 10px;
}
.quota-card .card-number-item {
    text-align: center;
}
.quota-card .card-number-item .label { font-size: 11px; color: var(--text2); }
.quota-card .card-number-item .value { font-weight: bold; color: var(--success); }
.quota-card .card-expand {
    font-size: 12px; color: var(--accent); cursor: pointer;
}

/* 多方案对比 */
.plans-compare {
    display: flex; flex-direction: column; gap: 16px;
}
.plan-block {
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; background: var(--surface);
}
.plan-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.plan-badge {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 16px; flex-shrink: 0;
}
.plan-name { font-weight: bold; font-size: 14px; }
.plan-desc { font-size: 12px; color: var(--text2); }
.plan-total { font-size: 18px; font-weight: bold; color: var(--success); margin-left: auto; white-space: nowrap; }
.plan-steps {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.plan-steps th, .plan-steps td {
    padding: 8px 12px; text-align: left;
    border-bottom: 1px solid var(--border);
}
.plan-steps th { background: var(--bg); color: var(--text2); font-weight: normal; font-size: 11px; text-align: center; }
.plan-steps td { text-align: center; }
.plan-steps td:first-child, .plan-steps td:nth-child(2) { text-align: left; }
.plan-steps .step-miss td { color: var(--text2); font-style: italic; }
.plan-steps .step-alert-row td {
    padding: 4px 12px; background: rgba(233, 69, 96, 0.08);
    border-bottom: 1px solid var(--border);
    font-size: 11px; text-align: left !important;
}
.plan-steps .step-alert-warn td {
    padding: 4px 12px; background: rgba(255, 193, 7, 0.08);
    border-bottom: 1px solid var(--border);
    font-size: 11px; text-align: left !important;
}
.plan-alert {
    padding: 8px 16px; font-size: 12px;
    background: rgba(255, 152, 0, 0.1);
    border-top: 1px solid var(--border);
    color: #ff9800;
}
.plan-cost-detail {
    display: flex; gap: 20px; padding: 10px 16px;
    font-size: 12px; color: var(--text2);
    border-top: 1px solid var(--border);
}

/* 成本计算表 */
.cost-table {
    width: 100%; border-collapse: collapse;
    margin: 10px 0; font-size: 13px;
}
.cost-table th, .cost-table td {
    padding: 8px 12px; text-align: right;
    border-bottom: 1px solid var(--border);
}
.cost-table th { color: var(--text2); font-weight: normal; text-align: left; }
.cost-table tr:last-child td { font-weight: bold; color: var(--success); }

/* 明细表 */
.detail-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
    margin-top: 12px;
}
.detail-table th, .detail-table td {
    padding: 6px 10px; text-align: right;
    border-bottom: 1px solid var(--border);
}
.detail-table th { background: var(--surface2); color: var(--text2); text-align: center; }

/* 项目特征导航 */
.project-nav {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--surface2);
    border-radius: 8px;
}
.project-nav-title {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 8px;
}
.project-nav-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.project-nav-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border);
    color: var(--text);
}
.chip-has-quota {
    background: rgba(15,132,254,0.15);
    border-color: rgba(15,132,254,0.4);
}
.chip-has-quota:hover {
    background: rgba(15,132,254,0.3);
    transform: translateY(-1px);
}
.chip-no-quota {
    background: rgba(255,255,255,0.04);
    color: var(--text2);
    opacity: 0.6;
}
.chip-count {
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    text-align: center;
}

/* 项目特征分组 */
.project-group {
    margin-bottom: 16px;
    padding: 10px 12px 4px;
    border-left: 3px solid #f59e0b;
    border-radius: 0 8px 8px 0;
    background: rgba(245,158,11,0.05);
    transition: background 0.3s;
}
.project-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.project-group-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #f59e0b;
    flex-shrink: 0;
}
.project-group-qty {
    font-size: 11px;
    font-weight: normal;
    color: var(--text2);
    background: var(--surface2);
    padding: 1px 6px;
    border-radius: 8px;
}
.project-group-note {
    font-size: 11px;
    font-weight: normal;
    color: var(--text2);
    font-style: italic;
}
.project-group-count {
    font-size: 11px;
    font-weight: normal;
    color: var(--accent);
    margin-left: auto;
}
.project-no-quota {
    font-size: 12px;
    color: var(--text2);
    padding: 6px 0;
    opacity: 0.6;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .chat-input-bar { padding: 8px 12px; }
    .chat-messages { padding: 12px 16px; }
}
