/* ============================================================
   聚宝盆 · 金价台 — 新中式鎏金金融终端
   暗墨底 / 鎏金衬线 / 朱砂印 / 等宽数字 / 涨红跌绿
   ============================================================ */

:root {
    /* 墨 */
    --ink-0: #0d0b09;
    --ink-1: #14110d;
    --ink-2: #1b1712;
    --ink-3: #241f17;
    /* 金 */
    --gold-0: #d4af37;
    --gold-1: #f0d98c;
    --gold-2: #a8842c;
    --gold-dim: #5f4f24;
    --gold-line: rgba(212, 175, 55, 0.22);
    /* 纸 */
    --paper: #ece2c8;
    --paper-2: #b3a888;
    --paper-3: #7d7358;
    /* 朱砂 */
    --cinnabar: #b5342a;
    --cinnabar-2: #d64a3d;
    /* 涨跌（涨红跌绿） */
    --up: #e8544d;
    --up-deep: #b5342a;
    --down: #46cf8e;
    --down-deep: #1d8f5e;

    --mono: "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Roboto Mono", monospace;
    --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;
    --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

    --panel-r: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 13px; overflow-x: hidden; }
body { overflow-x: hidden; }
/* 数字不换行，表格/文本超宽时省略而非撑破布局 */
td, th, .num, .hd-sub { white-space: nowrap; }
td.name, .news-title, .fortune { white-space: normal; }

body {
    background: var(--ink-0);
    /* 铜钱网格暗纹 */
    background-image:
        radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0. 028) 0 1.2px, transparent 1.6px),
        radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.018) 0 3.5px, transparent 4.2px);
    background-size: 28px 28px, 28px 28px;
    color: var(--paper);
    font-family: var(--sans);
    line-height: 1.5;
    min-height: 100vh;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--paper-2); }

/* ============ 顶栏 ============ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    min-height: calc(52px + env(safe-area-inset-top));
    background: linear-gradient(180deg, #16120c 0%, #100e0a 100%);
    border-bottom: 1px solid var(--gold-dim);
    box-shadow: 0 1px 0 rgba(212, 175, 55, 0.08), 0 6px 18px rgba(0, 0, 0, 0.45);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* 朱砂印 */
.seal { width: 38px; height: 38px; flex: none; }
.seal-bg { fill: var(--cinnabar); }
.seal-ring { fill: none; stroke: rgba(255, 235, 225, 0.85); stroke-width: 1; }
.seal-char {
    fill: #f6e9d8;
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
}

.brand-text { min-width: 0; }
.brand-text h1 {
    font-family: var(--serif);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1.2;
    background: linear-gradient(92deg, #8a6d1f 0%, #d4af37 22%, #f6e7b0 45%, #d4af37 68%, #8a6d1f 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 5s linear infinite;
    white-space: nowrap;
}
@keyframes shimmer { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }
.brand-sub { font-size: 13px; }
.brand-en {
    font-size: 9.5px;
    color: var(--paper-3);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sources { display: flex; gap: 12px; font-size: 11px; color: var(--paper-2); }
.src-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--gold-0);
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.8);
}
.dot.off { background: #4a4436; box-shadow: none; }

.status { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.ws-lamp {
    display: flex; align-items: center; gap: 5px;
    font-size: 10.5px; color: var(--paper-3);
}
.ws-lamp i {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--gold-0);
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.9);
    animation: pulse 2s ease-in-out infinite;
}
.ws-lamp.off i { background: #4a4436; box-shadow: none; animation: none; }
.ws-lamp.off b { color: #4a4436; }
/* 横盘监控中：慢呼吸，与实时脉冲区分 */
.ws-lamp.quiet i { animation: breathe 3s ease-in-out infinite; }
.ws-lamp.quiet b { color: var(--gold-1); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes breathe { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.25; } }
.clock { font-size: 12px; color: var(--paper-2); }
.trading-badge {
    font-size: 10px;
    color: var(--gold-1);
    border: 1px solid var(--gold-dim);
    border-radius: 2px;
    padding: 1px 6px;
    white-space: nowrap;
}
.trading-badge.closed { color: var(--paper-3); border-color: #3a3428; }

/* ============ 布局 ============ */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 2.15fr) minmax(300px, 1fr);
    gap: 14px;
    padding: 14px 16px 20px;
    max-width: 1460px;
    margin: 0 auto;
    align-items: start;
}
.col-main, .col-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ============ 面板 ============ */
.panel {
    background: linear-gradient(180deg, var(--ink-1) 0%, #100e0a 100%);
    border: 1px solid var(--gold-dim);
    border-radius: var(--panel-r);
    box-shadow: inset 0 1px 0 rgba(212, 175, 55, 0.06);
}
.panel-hd {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.14);
}
.hd-title {
    font-family: var(--serif);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--gold-1);
}
.hd-title::before {
    content: "";
    display: inline-block;
    width: 3px; height: 13px;
    background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
    margin-right: 8px;
    vertical-align: -1px;
}
.hd-sub { font-size: 10.5px; color: var(--paper-3); }
.panel-hd .ops { margin-left: auto; }
.panel-bd { padding: 12px 14px; }
.panel-bd.pd0 { padding: 0; }

/* ============ 行情表 ============ */
.grp-title {
    font-family: var(--serif);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--gold-2);
    padding: 10px 14px 4px;
}
table.quotes { width: 100%; border-collapse: collapse; }
#quotes-container { overflow-x: auto; scrollbar-width: thin; }
table.quotes th {
    font-size: 10px;
    font-weight: 400;
    color: var(--paper-3);
    text-align: right;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.14);
    letter-spacing: 1px;
    white-space: nowrap;
}
table.quotes th:nth-child(1), table.quotes th:nth-child(2),
table.quotes td:nth-child(1), table.quotes td:nth-child(2) { text-align: left; }
table.quotes td {
    font-size: 12.5px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.07);
    text-align: right;
    white-space: nowrap;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    color: var(--paper);
}
table.quotes tr:last-child td { border-bottom: none; }
table.quotes tbody tr { cursor: pointer; transition: background 0.15s; }
table.quotes tbody tr:hover { background: rgba(212, 175, 55, 0.05); }
table.quotes tbody tr.active { background: rgba(212, 175, 55, 0.08); }
table.quotes tbody tr.active td:first-child { box-shadow: inset 2px 0 0 var(--gold-0); }
td.name { font-family: var(--sans); font-size: 12px; }
td.name .src {
    display: block;
    font-size: 9.5px;
    color: var(--paper-3);
    font-family: var(--mono);
}
td.price { font-weight: 700; font-size: 14px; }
td.price .unit { font-size: 9.5px; color: var(--paper-3); font-family: var(--sans); margin-left: 3px; }
.arrow { font-size: 9px; margin-right: 2px; }
.spark { display: block; }
td.qt { font-size: 10.5px; color: var(--paper-3); }

/* 价格跳动 */
@keyframes flash-up { 0% { background: rgba(232, 84, 77, 0.28); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: rgba(70, 207, 142, 0.22); } 100% { background: transparent; } }
td.flash-up { animation: flash-up 1.2s ease-out; }
td.flash-down { animation: flash-down 1.2s ease-out; }

/* ============ 折算 ============ */
.convert { display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 12px; color: var(--paper-2); }
.convert b { color: var(--paper); font-family: var(--mono); font-weight: 600; }
.convert .premium { font-family: var(--mono); font-weight: 700; }

/* ============ 走势图 ============ */
.chart-wrap { height: 260px; }
#chart { width: 100%; height: 100%; }
.chart-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 10.5px;
    color: var(--paper-3);
    padding-top: 8px;
}

/* ============ 分段按钮 ============ */
.seg { display: inline-flex; border: 1px solid var(--gold-dim); border-radius: 3px; overflow: hidden; }
.seg button {
    border: none;
    background: transparent;
    color: var(--paper-2);
    font-size: 10.5px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--sans);
}
.seg button.on { background: linear-gradient(180deg, var(--gold-2), #7a5f1c); color: #f8efd4; }
.seg button:hover:not(.on) { color: var(--gold-1); }

/* ============ 归因 ============ */
.attribution { font-size: 12px; }
.attribution .lead { font-family: var(--serif); font-weight: 700; font-size: 14px; margin-bottom: 8px; letter-spacing: 0.5px; }
.attribution .macro-line {
    color: var(--paper-2);
    margin-bottom: 10px;
    font-family: var(--mono);
    font-size: 11px;
    padding: 6px 8px;
    background: rgba(212, 175, 55, 0.05);
    border-left: 2px solid var(--gold-dim);
    border-radius: 0 3px 3px 0;
}
.attribution ul { list-style: none; }
.attribution li {
    padding: 5px 0 5px 12px;
    border-left: 2px solid var(--gold-dim);
    margin-bottom: 5px;
    color: var(--paper-2);
    font-size: 11.5px;
    transition: border-color 0.15s;
}
.attribution li:hover { border-left-color: var(--gold-0); }
.attribution li .t { color: var(--paper-3); font-family: var(--mono); margin-right: 8px; font-size: 10px; }
.attribution li b { color: var(--paper); font-weight: 600; }
.attribution .empty { color: var(--paper-3); font-size: 11.5px; }

/* ============ 快讯 ============ */
.news-list { max-height: 600px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent; }
.news-list::-webkit-scrollbar { width: 4px; }
.news-list::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }
.news-item {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.07);
    font-size: 11.5px;
    color: var(--paper);
    animation: fade-in 0.4s ease;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.news-item:hover { background: rgba(212, 175, 55, 0.04); }
.news-item:last-child { border-bottom: none; }
.news-item .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--paper-3);
    font-family: var(--mono);
    margin-bottom: 4px;
}
.news-item .tags { display: flex; gap: 4px; flex: none; }
.tag {
    border-radius: 2px;
    padding: 0 5px;
    font-size: 9.5px;
    font-family: var(--sans);
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold-1);
    border: 1px solid rgba(212, 175, 55, 0.25);
    white-space: nowrap;
}
.tag.hot { background: rgba(181, 52, 42, 0.18); color: #f0a099; border-color: rgba(181, 52, 42, 0.45); }

/* ============ 提醒 ============ */
.alert-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.07);
    color: var(--paper-2);
    font-size: 11.5px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .ts { font-family: var(--mono); color: var(--paper-3); font-size: 10px; white-space: nowrap; }
.alert-row .sym { color: var(--gold-1); font-weight: 600; white-space: nowrap; font-family: var(--serif); }
.alert-row .ok { color: var(--down); margin-left: auto; font-size: 10px; white-space: nowrap; }
.alert-row .fail { color: var(--up); margin-left: auto; font-size: 10px; white-space: nowrap; }
.alert-empty, .news-empty { padding: 18px 14px; color: var(--paper-3); font-size: 11.5px; text-align: center; }

/* ============ 页脚 ============ */
.footer {
    padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
    font-size: 10.5px;
    color: var(--paper-3);
    line-height: 1.7;
    max-width: 1460px;
    margin: 0 auto;
}
.footer .fortune {
    font-family: var(--serif);
    font-size: 13px;
    letter-spacing: 6px;
    color: var(--gold-2);
    margin-bottom: 6px;
    text-align: center;
}

/* ============ 响应式 ============ */
@media (max-width: 1020px) {
    .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
    .col-main, .col-side { gap: 12px; }
    .news-list { max-height: 420px; }
}
@media (max-width: 640px) {
    html { font-size: 12.5px; }
    .topbar { gap: 10px; padding: 0 10px; padding-top: env(safe-area-inset-top); }
    .brand-text h1 { font-size: 16px; letter-spacing: 1px; }
    .brand-en { display: none; }
    .seal { width: 32px; height: 32px; }
    .seal-char { font-size: 18px; }
    .sources { display: none; }
    /* 时钟与实时状态保留显示：用户需要随时确认数据新鲜度和连接状态 */
    .status { gap: 8px; }
    .clock { font-size: 11px; }
    .ws-lamp { font-size: 10px; }
    .ws-lamp b { display: inline; }
    .trading-badge { padding: 1px 4px; }
    .layout { padding: 10px; }

    /* 表格精简：隐藏百分比/最高/最低/昨收/走势/时间，只留 品种/最新价/涨跌 */
    table.quotes th.h-xs, table.quotes td.h-xs,
    table.quotes th.h-sm, table.quotes td.h-sm { display: none; }
    table.quotes td { padding: 8px 6px; font-size: 12px; }
    table.quotes td.price { font-size: 13.5px; }
    table.quotes td.name { font-size: 11.5px; }

    .chart-wrap { height: 210px; }
    .convert { gap: 6px 16px; font-size: 11px; }
    .panel-hd { padding: 8px 12px; }
    .panel-bd { padding: 10px 12px; }
    .footer { padding: 6px 12px calc(20px + env(safe-area-inset-bottom)); }
    .footer .fortune { letter-spacing: 4px; }
    .seg button { padding: 6px 9px; }
}
