/* ============ 量化交易系统 · 展示端样式 ============ */
:root {
    --bg: #0b1020;
    --panel: #141b31;
    --panel-2: #1a2340;
    --border: rgba(120, 150, 220, 0.16);
    --text: #e8edfb;
    --text-2: #dbe6ff;  /* 次级标题：亮蓝白，避免继承变暗（曾未定义导致看不清） */
    --muted: #8a94b3;
    --accent: #4f9bff;
    --pos: #35d07f;
    --neg: #ff5d6c;
    --warn: #ffb84d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
    background:
        radial-gradient(1200px 500px at 20% -10%, rgba(79, 155, 255, 0.12), transparent 60%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: rgba(11, 16, 32, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-icon {
    font-size: 22px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

/* 访问令牌输入（手机/公网访问时显示） */
.token-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.token-row input {
    width: 160px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.token-row input:focus {
    border-color: var(--accent);
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--muted);
}

.dot.ok {
    background: var(--pos);
    box-shadow: 0 0 8px rgba(53, 208, 127, 0.7);
}

.dot.err {
    background: var(--neg);
    box-shadow: 0 0 8px rgba(255, 93, 108, 0.7);
}

/* ---------- 主容器 ---------- */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ---------- 双列布局 ---------- */
.layout-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 18px;
    align-items: start;
}

.col-main,
.col-side {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

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

/* 手机端：顶栏换行、令牌框占满、面板间距收紧 */
@media (max-width: 640px) {
    .topbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }

    .token-row {
        flex: 1 1 100%;
    }

    .token-row input {
        flex: 1;
        min-width: 0;
        width: auto;
    }

    .container {
        padding: 14px 10px 40px;
    }

    .panel {
        padding: 14px;
    }
}

/* ---------- 登录遮罩 ---------- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 9, 20, 0.88);
    backdrop-filter: blur(6px);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 26px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.login-card input {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.login-card input:focus {
    border-color: var(--accent);
}

.login-card .btn {
    padding: 11px;
    font-size: 15px;
}

/* ---------- 主导航 Tab ---------- */
.tabs {
    position: sticky;
    top: 57px;
    z-index: 9;
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(11, 16, 32, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    flex: 0 0 auto;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.tab:hover {
    color: var(--text);
    background: var(--panel-2);
}

.tab.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(79, 155, 255, 0.22), rgba(79, 155, 255, 0.08));
    border-color: rgba(79, 155, 255, 0.4);
}

/* ---------- 标的一览卡片 ---------- */
.group-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0 2px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
}

.sym-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s;
}

.sym-card:hover {
    border-color: rgba(79, 155, 255, 0.5);
}

.sym-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.sym-head strong {
    font-size: 15px;
}

.sym-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sym-card .btn {
    align-self: flex-start;
}

/* ---------- 关注搜索确认结果 ---------- */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.search-item:hover {
    border-color: rgba(79, 155, 255, 0.4);
}

/* ---------- 标的详情弹层 ---------- */
.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: rgba(6, 9, 20, 0.78);
    backdrop-filter: blur(4px);
    padding: 30px 16px;
    overflow-y: auto;
}

.detail-card {
    width: 100%;
    max-width: 820px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 22px 26px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.detail-head h2 {
    margin: 0;
    font-size: 19px;
}

.detail-h {
    margin: 16px 0 8px;
    font-size: 15px;
    color: var(--accent);
}

.detail-h:first-child {
    margin-top: 0;
}

/* 手机端 Tab 可横滑、弹层贴边 */
@media (max-width: 640px) {
    .tabs {
        top: 54px;
        padding: 8px 10px;
    }

    .tab {
        padding: 7px 12px;
        font-size: 13px;
    }

    .detail-overlay {
        padding: 12px 8px;
    }

    .detail-card {
        padding: 14px;
    }
}

/* ---------- 回测缓存过期提示 ---------- */
.stale-note {
    background: rgba(255, 184, 77, 0.12);
    border: 1px solid rgba(255, 184, 77, 0.4);
    color: var(--warn);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin: 8px 0;
}

/* ---------- 行内折叠（记录页 AI 历史） ---------- */
.collapse-inline {
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-2);
}
.collapse-inline > summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}
.collapse-inline > summary::-webkit-details-marker {
    display: none;
}
.collapse-inline > summary::before {
    content: '▸ ';
    color: var(--muted);
}
.collapse-inline[open] > summary::before {
    content: '▾ ';
}
.collapse-inline > summary:hover {
    color: var(--accent);
}
.collapse-inline > div {
    padding: 0 12px 12px;
}
.ai-rec-item {
    padding: 8px 0;
    border-top: 1px dashed var(--border);
    font-size: 12px;
}
.ai-rec-item .ai-rec-meta {
    color: var(--muted);
    margin-bottom: 4px;
}
.ai-rec-item .ai-rec-body {
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow: hidden;
    cursor: pointer;
}
.ai-rec-item.open .ai-rec-body {
    max-height: none;
}
.sugg-actions {
    margin-left: 8px;
    white-space: nowrap;
}
.sugg-actions .btn.mini {
    padding: 3px 8px;
    font-size: 11px;
    margin-left: 4px;
}

/* ---------- 面板工具条 ---------- */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
    flex-wrap: wrap;
}

.head-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

.asset-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.asset-label input {
    width: 110px;
    padding: 7px 10px;
    font-size: 13px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}

.asset-label input:focus {
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- 概览卡片 ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.card {
    padding: 18px 20px;
    background: linear-gradient(160deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border);
    border-radius: 14px;
}

.card-label {
    font-size: 12px;
    color: var(--text-2);
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 24px;
    font-weight: 700;
}

.card-value.small {
    font-size: 15px;
    font-weight: 600;
    word-break: break-all;
}

/* 概览卡可点击跳转（2026-08-08） */
.card.jump {
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.card.jump:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(79, 155, 255, .18);
}
.card.jump:active {
    transform: translateY(0);
}

/* ---------- 面板 ---------- */
.panel {
    padding: 20px 22px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

/* ---------- 顶部工具条（总资产 + 刷新） ---------- */
.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin: 4px 0 16px;
    flex-wrap: wrap;
}

/* ---------- 折叠面板（维护与工具 / 旧版参考） ---------- */
.panel.collapse-panel > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    padding: 2px 0;
    user-select: none;
}
.panel.collapse-panel > summary::-webkit-details-marker {
    display: none;
}
.panel.collapse-panel > summary::before {
    content: '▸';
    color: var(--muted);
    font-size: 13px;
    transition: transform 0.15s;
}
.panel.collapse-panel[open] > summary::before {
    transform: rotate(90deg);
}
.panel.collapse-panel > summary:hover {
    color: var(--accent);
}
.panel.collapse-panel .sub-block {
    border-top: 1px dashed var(--border);
    padding: 14px 2px 2px;
    margin-top: 12px;
}
.sub-block .sub-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.sub-block h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 700;
}

.panel-head h2 {
    margin: 0;
}

.panel-head.clickable {
    cursor: pointer;
    user-select: none;
}

.panel-head.clickable:hover h2 {
    color: var(--accent);
}

.chevron {
    color: var(--muted);
    font-size: 14px;
    transition: transform 0.15s;
}

.btn {
    padding: 7px 18px;
    font-size: 13px;
    color: #fff;
    background: linear-gradient(135deg, #4f9bff, #8267ff);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.12s, opacity 0.12s;
}

.btn:hover {
    transform: translateY(-1px);
    opacity: 0.92;
}

.muted {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ---------- 表格 ---------- */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-2);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(120, 150, 220, 0.08);
    white-space: nowrap;
}

tr:hover td {
    background: rgba(79, 155, 255, 0.05);
}

td.empty {
    text-align: center;
    color: var(--muted);
    padding: 24px;
}

.sym {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

/* 可点击打开个股详情的股票名称/代码 */
.sym-open {
    cursor: pointer;
    transition: color 0.15s;
}
.sym-open:hover {
    color: var(--accent, #4f9bff);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* 数据时间徽章（各模块展示数据源时间，便于判断刷新/滞后） */
.data-time {
    display: inline-block;
    margin: 4px 0;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(79, 155, 255, 0.12);
    color: var(--accent, #4f9bff);
    font-size: 12px;
    cursor: help;
    white-space: nowrap;
}

/* ---------- 财经快讯（财联社/华尔街见闻） ---------- */
.news-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}
.news-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(120, 150, 220, 0.05);
    border: 1px solid transparent;
    font-size: 13px;
    line-height: 1.5;
    transition: background 0.15s;
}
.news-item:hover {
    background: rgba(79, 155, 255, 0.08);
}
.news-time {
    flex: none;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}
.news-title {
    flex: 1;
    word-break: break-word;
}
.news-item a {
    flex: none;
    text-decoration: none;
    opacity: 0.75;
}
.news-item a:hover {
    opacity: 1;
}
.news-item .tag {
    flex: none;
}

/* ---------- 推荐命中率追踪统计 ---------- */
.rec-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.rec-stat-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    background: rgba(120, 150, 220, 0.04);
    line-height: 1.6;
    word-break: break-all;
}
.rec-stat-box strong {
    font-size: 14px;
}

/* ---------- 数据任务状态面板 ---------- */
.task-row {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: rgba(120, 150, 220, 0.04);
}
.task-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
}
.task-time {
    color: var(--muted);
    font-size: 12px;
    margin-left: auto;
}
.task-detail {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}
.task-error {
    color: var(--neg, #ff5d6c);
    font-size: 12px;
    margin-top: 6px;
    word-break: break-all;
}
.task-retry {
    font-size: 12px;
    color: var(--muted);
}
.task-retry.done {
    color: var(--neg, #ff5d6c);
}
.task-actions {
    margin-top: 8px;
}
.task-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.task-badge.running {
    background: rgba(79, 155, 255, 0.15);
    color: var(--accent, #4f9bff);
}
.task-badge.ok {
    background: rgba(53, 208, 127, 0.15);
    color: var(--pos, #35d07f);
}
.task-badge.fail {
    background: rgba(255, 93, 108, 0.15);
    color: var(--neg, #ff5d6c);
}
.task-badge.retrying {
    background: rgba(255, 193, 66, 0.18);
    color: #ffc142;
}
.task-badge.idle {
    background: rgba(120, 150, 220, 0.12);
    color: var(--muted);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.act-buy {
    background: rgba(53, 208, 127, 0.15);
    color: var(--pos);
}

.act-sell {
    background: rgba(255, 93, 108, 0.15);
    color: var(--neg);
}

.act-hold {
    background: rgba(138, 148, 179, 0.15);
    color: var(--muted);
}

.pos {
    color: var(--pos);
}

.neg {
    color: var(--neg);
}

/* 止损待执行行高亮（open 状态） */
#stops-table tr.stop-pending td {
    background: rgba(255, 93, 108, 0.07);
}
#stops-table tr.stop-pending td:first-child {
    border-left: 3px solid var(--neg);
}
#stops-table tr.stop-pending:hover td {
    background: rgba(255, 93, 108, 0.12);
}

/* 止损统计栏（独立于 block-state 状态位） */
.stops-stats {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* ---------- 风险提示 ---------- */
.warnings {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.warn-item {
    padding: 8px 12px;
    background: rgba(255, 184, 77, 0.1);
    border-left: 3px solid var(--warn);
    border-radius: 6px;
    color: var(--warn);
    font-size: 13px;
}

.risk-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.9;
}

/* ---------- 图表 ---------- */
.chart-box {
    margin-top: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
}

/* K 线时间窗口按钮 */
.kline-tools {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}
.kline-window {
    padding: 1px 8px;
    font-size: 11px;
    border-radius: 4px;
    opacity: 0.75;
}
.kline-window.active {
    opacity: 1;
    background: var(--accent, #3b82f6);
    color: #fff;
}

#equity-chart {
    width: 100%;
    height: 240px;
    display: block;
}

/* ---------- 持仓表单 ---------- */
.hold-form {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.hold-form h3 {
    margin: 10px 0 8px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.form-row input,
.form-row select {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    min-width: 110px;
    flex: 1 1 110px;
}

.form-row input:focus,
.form-row select:focus {
    border-color: var(--accent);
}

.form-row input::placeholder {
    color: #5b6480;
}

.form-row select {
    flex: 0 0 90px;
    min-width: 90px;
    cursor: pointer;
}

.btn.mini {
    padding: 4px 10px;
    font-size: 12px;
}

td.ops .btn.mini {
    margin-right: 4px;
    margin-bottom: 2px;
}

/* ---------- 市场环境解读 ---------- */
.env-interpret-head,
.env-ai-head {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin: 12px 0 6px;
}

.env-interpret-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.env-interpret-list li {
    font-size: 13px;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
}

.env-interpret-list li b {
    margin-right: 8px;
}

.env-i-pos {
    border-left: 3px solid #2ecc71;
}

.env-i-neg {
    border-left: 3px solid #e74c3c;
}

.env-i-neu {
    border-left: 3px solid #95a5a6;
}

.env-interpret-summary {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
    background: rgba(79, 155, 255, 0.06);
    border-radius: 8px;
    padding: 10px 12px;
}

.env-ai-text {
    font-size: 13px;
    line-height: 1.7;
    background: rgba(79, 155, 255, 0.05);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px 12px;
}

/* ---------- AI 助手 ---------- */
.ai-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2f6bff, #4f9bff);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(47, 107, 255, 0.4);
    z-index: 60;
    transition: transform 0.15s;
}

.ai-fab:hover {
    transform: scale(1.08);
}

.ai-chat-card {
    max-width: 560px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 2px;
    min-height: 180px;
}

.ai-chat-item {
    font-size: 13px;
    line-height: 1.7;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 92%;
}

.ai-chat-user {
    align-self: flex-end;
    background: rgba(47, 107, 255, 0.14);
    border: 1px solid rgba(47, 107, 255, 0.3);
}

.ai-chat-ai {
    align-self: flex-start;
    background: var(--panel-2);
    border: 1px solid var(--border);
}

.ai-chat-who {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 3px;
}

.ai-text {
    font-size: 13px;
    line-height: 1.8;
    white-space: normal;
}

/* ---------- 持仓概况与盈利分析 ---------- */
.hold-summary {
    margin: 6px 0 2px;
}

.hold-pnl-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hold-pnl-row {
    display: grid;
    grid-template-columns: 160px 1fr 110px 80px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.hold-pnl-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hold-pnl-bar {
    height: 8px;
    background: rgba(120, 150, 220, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.hold-pnl-bar .bar-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
}

.hold-pnl-bar .bar-fill.pos {
    background: linear-gradient(90deg, #2ecc71, #35d07f);
}

.hold-pnl-bar .bar-fill.neg {
    background: linear-gradient(90deg, #e74c3c, #ff6b6b);
}

.hold-pnl-val,
.hold-pnl-pct {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .hold-pnl-row {
        grid-template-columns: 120px 1fr 90px;
    }

    .hold-pnl-pct {
        display: none;
    }
}

.form-msg {
    min-height: 18px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--pos);
}

.form-msg.err {
    color: var(--neg);
}

/* ---------- 市场环境 ---------- */
.env-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.env-item {
    padding: 12px 14px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.env-label {
    font-size: 13px;
    color: var(--text-2);
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

/* 指标标题带数据源链接时，<a> 默认蓝紫色会覆盖 .env-label 颜色 → 显式继承亮色 */
.env-label a,
.env-label a:visited,
.env-label a:hover {
    color: var(--text-2);
    font-weight: 700;
    text-decoration: none;
}

/* 前值对比表标题 */
.env-compare-head {
    margin: 10px 0 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-2);
    background: rgba(79, 155, 255, 0.12);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

/* 前值对比表：左列指标名加粗亮色，便于辨识（含 visited/hover 防链接默认色覆盖） */
.env-compare-table td:first-child {
    font-weight: 600;
    color: var(--text);
}
.env-compare-table td:first-child a,
.env-compare-table td:first-child a:visited,
.env-compare-table td:first-child a:hover {
    color: var(--text);
    font-weight: 600;
}

.env-value {
    font-size: 16px;
    font-weight: 700;
}

.env-value.pos {
    color: var(--pos);
}

.env-value.neg {
    color: var(--neg);
}

.env-rating {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.env-rating.pos {
    background: rgba(53, 208, 127, 0.15);
    color: var(--pos);
}

.env-rating.warn {
    background: rgba(255, 184, 77, 0.15);
    color: var(--warn);
}

.env-rating.neutral {
    background: rgba(138, 148, 179, 0.18);
    color: var(--text-2);
}

/* ---------- 仓位指引 ---------- */
.guidance-bar {
    padding: 9px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border-left: 3px solid var(--muted);
    background: rgba(138, 148, 179, 0.08);
    color: var(--text);
}

.guidance-bar.g-up {
    border-left-color: var(--pos);
    background: rgba(53, 208, 127, 0.08);
}

.guidance-bar.g-down {
    border-left-color: var(--neg);
    background: rgba(255, 93, 108, 0.08);
}

/* ---------- 个股基本面 ---------- */
.fund-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
}

.fund-card {
    padding: 14px 16px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.fund-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.fund-badges {
    display: flex;
    gap: 6px;
}

.fund-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.fund-metrics b {
    color: var(--text);
}

.fund-flags {
    padding: 8px 10px;
    background: rgba(255, 184, 77, 0.1);
    border-radius: 6px;
    color: var(--warn);
    font-size: 12px;
    line-height: 1.7;
    margin-bottom: 8px;
}

/* 五维加权评分维度条（成长/盈利/财务/估值/排雷） */
.fund-dims {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.fund-dim {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(79, 155, 255, 0.08);
    border: 1px solid rgba(79, 155, 255, 0.18);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
}

.fund-dim i {
    font-style: normal;
    font-weight: 500;
    color: var(--muted);
    margin-right: 2px;
}

.fund-dim em {
    font-style: normal;
    font-weight: 500;
    font-size: 10px;
    color: var(--muted);
}

.fund-clean {
    padding: 8px 10px;
    background: rgba(53, 208, 127, 0.08);
    border-radius: 6px;
    color: var(--pos);
    font-size: 12px;
    margin-bottom: 8px;
}

.fund-date {
    font-size: 11px;
    color: var(--muted);
    text-align: right;
}

.fund-err {
    color: var(--neg);
    font-size: 12px;
}

/* 基本面判断依据与来源 */
.fund-basis {
    padding: 8px 10px;
    background: rgba(79, 155, 255, 0.05);
    border-radius: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
    margin-bottom: 8px;
}

.fund-source {
    font-size: 11px;
    color: #5b6480;
    margin-bottom: 6px;
    line-height: 1.6;
}

/* ---------- 主营业务与行业环境 ---------- */
.ind-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
    flex-wrap: wrap;
}

.ind-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ind-row {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 7px;
    line-height: 1.7;
}

.ind-row b {
    color: var(--text);
}

.ind-biz {
    padding: 8px 10px;
    background: rgba(79, 155, 255, 0.06);
    border-radius: 6px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 8px;
}

.ind-outlook {
    padding: 8px 10px;
    background: rgba(138, 148, 179, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.7;
}

.ind-source {
    font-size: 11px;
    color: #5b6480;
    line-height: 1.6;
    margin-top: 6px;
}

/* ---------- 持仓每日分析 ---------- */
.holda-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.holda-card {
    padding: 14px 16px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.holda-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}

.holda-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.holda-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.holda-metrics b {
    color: var(--text);
}

.holda-fund {
    padding: 8px 10px;
    background: rgba(79, 155, 255, 0.06);
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.holda-reason {
    padding: 8px 10px;
    background: rgba(138, 148, 179, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    font-size: 13px;
}

.trail-hit {
    color: var(--warn);
    font-size: 12px;
    font-weight: 600;
}

.muted-sm {
    color: var(--muted);
    font-size: 12px;
}

/* ---------- 区块请求状态（请求中 / 出错 + 重试） ---------- */
.block-state {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 8px;
    background: rgba(120, 150, 220, 0.08);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}

.block-state.err {
    background: rgba(255, 93, 108, 0.10);
    border-color: rgba(255, 93, 108, 0.4);
    color: var(--neg);
}

.block-state.err .btn {
    margin-left: auto;
}

.ps-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(120, 150, 220, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    flex: none;
    animation: ps-spin 0.8s linear infinite;
}

@keyframes ps-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- 系统风格与偏好 ---------- */
.style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 4px 0 6px;
}

.style-tile {
    background: rgba(120, 150, 220, 0.07);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.st-label {
    color: var(--muted);
    font-size: 12px;
}

.st-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.style-card {
    max-width: 560px;
}

.style-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.style-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--muted);
    font-size: 13px;
}

.style-form input,
.style-form select {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

.style-form input:focus,
.style-form select:focus {
    outline: none;
    border-color: var(--accent);
}

#style-analysis {
    margin-top: 6px;
    line-height: 1.7;
}

#style-analysis ul {
    margin: 4px 0 4px 18px;
    padding: 0;
}

.opt-verdict {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    padding: 9px 12px;
    border-radius: 8px;
    margin: 6px 0;
    font-size: 14px;
    border: 1px solid var(--border);
}

.opt-verdict.opt-ok {
    background: rgba(53, 208, 127, 0.10);
    border-color: rgba(53, 208, 127, 0.35);
}

.opt-verdict.opt-sys {
    background: rgba(255, 184, 77, 0.12);
    border-color: rgba(255, 184, 77, 0.4);
}

.opt-verdict.opt-port {
    background: rgba(255, 93, 108, 0.10);
    border-color: rgba(255, 93, 108, 0.4);
}

.opt-reason {
    color: var(--muted);
    font-size: 13px;
}

.opt-basis,
.hist-issues,
.port-issues,
.opt-suggs {
    margin: 6px 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(120, 150, 220, 0.06);
    border: 1px solid var(--border);
    font-size: 13px;
}

.opt-basis {
    color: var(--muted);
}

.port-issues {
    background: rgba(255, 93, 108, 0.06);
    border-color: rgba(255, 93, 108, 0.25);
}

.hist-line {
    margin: 6px 0;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- AI 快捷指令 ---------- */
.ai-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 10px;
}

.ai-quick button {
    background: rgba(79, 155, 255, 0.10);
    border: 1px solid rgba(79, 155, 255, 0.35);
    color: var(--accent);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-quick button:hover {
    background: rgba(79, 155, 255, 0.22);
}

/* ---------- 页脚 ---------- */
.foot {
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

/* ---------- 内置 K 线 ---------- */
.kline-info {
    margin: 6px 0 4px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

.kline-info b {
    color: var(--fg);
}

#detail-kline svg {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
}

/* ---------- 系统健康 / 备份 / 报告 / 日志 ---------- */
.health-issues {
    margin-top: 6px;
    padding: 6px 10px;
    background: rgba(255, 93, 108, 0.08);
    border: 1px solid rgba(255, 93, 108, 0.25);
    border-radius: 6px;
    font-size: 12px;
    color: var(--neg, #ff8a8a);
    line-height: 1.7;
}

.backup-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px dashed var(--border);
}

.backup-row:last-child {
    border-bottom: none;
}

.report-body,
.log-body {
    max-height: 420px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--fg);
}

.log-body {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 11px;
}

/* ---------- 详情页加载中 ---------- */
.detail-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 30px 10px;
    color: var(--muted);
    font-size: 14px;
}

.spinner {
    width: 18px;
    height: 18px;
    flex: none;
    border: 2px solid rgba(120, 140, 200, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
