/* ================================================================
   市场行情 — Bloomberg Terminal Dark Design System
   极致信息密度 · 零圆角 · 等宽数据 · 专业交易终端
   ================================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bg-base: #000000;
    --bg-row: #060606;
    --bg-row-alt: #0c0c0c;
    --bg-elevated: #111111;
    --bg-input: #0a0a0a;
    --bg-header: #080808;
    --text-primary: #dde7f0;
    --text-secondary: #a8b4c2;
    --text-tertiary: #7a8a9c;
    --amber: #ffab00;
    --amber-dim: rgba(255, 171, 0, 0.12);
    --amber-soft: #c68400;
    --red: #ff1744;
    --red-bg: rgba(255, 23, 68, 0.10);
    --green: #00e676;
    --green-bg: rgba(0, 230, 118, 0.08);
    --border: #1a1a1a;
    --border-strong: #282828;
    --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --mono: 'SF Mono', 'Menlo', 'Consolas', 'JetBrains Mono', monospace;
    --header-h: 40px;
    --tab-h: 36px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

/* ---------- Body ---------- */
body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- Header — Terminal Bar ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.header-left h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--amber);
    text-transform: uppercase;
}

.header-subtitle {
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
    line-height: 1;
    white-space: nowrap;
}

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

.header-btn {
    height: 26px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--mono);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    -webkit-tap-highlight-color: transparent;
}

.header-btn:active { background: var(--border-strong); }

/* ---------- Tab Bar — Top Text Tabs ---------- */
.tab-bar {
    display: flex;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    z-index: 98;
}

.tab-btn {
    flex: 1;
    padding: 0;
    height: var(--tab-h);
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn.active {
    color: var(--amber);
    border-bottom-color: var(--amber);
    background: rgba(255, 171, 0, 0.04);
}

.tab-btn:active {
    background: rgba(255, 255, 255, 0.03);
}

/* ---------- Tab Panels ---------- */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Main Content ---------- */
#main-content { padding: 0; }

/* ---------- Cards — Flat Full-Width Sections ---------- */
.card {
    background: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin: 0;
}

.card:first-of-type {
    border-top: none;
}

.empty-state,
.list-empty {
    text-align: center;
    padding: 14px 8px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
    list-style: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-row);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.card[data-collapsible="true"] .card-header { cursor: pointer; }

.card-header:active {
    background: var(--bg-elevated);
}

.card-header h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: var(--mono);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-header h2::before {
    content: '■';
    font-size: 7px;
    color: var(--amber);
    line-height: 1;
}

.collapse-icon {
    font-size: 8px;
    color: var(--text-tertiary);
    transition: transform 0.15s;
    font-family: var(--mono);
}

.card[data-collapsed="true"] .collapse-icon {
    transform: rotate(-90deg);
}

.card-body {
    padding: 0 10px 8px;
}

.card[data-collapsed="true"] .card-body {
    display: none;
}

/* ---------- 大盘指数 — Compact Ticker Grid ---------- */
.index-section .card-body {
    padding: 0;
}

.index-section .card-header {
    display: none;
}

.index-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0;
}

.index-item {
    background: transparent;
    padding: 7px 7px 6px;
    text-align: left;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.index-item:nth-child(4n) {
    border-right: none;
}

.index-item:nth-child(n+3) {
    /* For 4-column single-row, no bottom border on last row */
}

.index-name {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.index-value {
    font-size: 17px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    max-width: 100%;
}

.index-value .trend-arrow {
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.index-value.positive { color: var(--red); }
.index-value.negative { color: var(--green); }
.index-value.neutral  { color: var(--text-primary); }

.index-change {
    font-size: 11px;
    font-weight: 600;
    margin-top: 1px;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.1;
}

.index-change.positive { color: var(--red); }
.index-change.negative { color: var(--green); }
.index-change.neutral  { color: var(--text-tertiary); }

/* ---------- 自选指数（板块/ETF，4 个 slot） ---------- */
.custom-index-section .card-header {
    padding: 8px 14px 4px;
}

.custom-index-section .card-body {
    padding: 0 0 6px;
}

.custom-index-header-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-right: auto;
    margin-left: 8px;
    font-family: var(--mono);
    white-space: nowrap;
}

/* 占用一个 grid 位置的"+"添加按钮 */
.custom-index-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    border: 1px dashed var(--border-card);
    color: var(--text-tertiary);
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    gap: 2px;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.custom-index-add:hover {
    border-color: var(--amber);
    color: var(--amber);
    background: var(--amber-dim);
}

.custom-index-add .add-icon {
    font-size: 18px;
    line-height: 1;
    font-weight: 300;
}

.custom-index-add .add-hint {
    font-size: 10px;
    opacity: 0.8;
    letter-spacing: 0.3px;
}

/* 自选指数已填项：复用 .index-item 布局，叠加删除按钮 */
.custom-index-data {
    position: relative;
}

.custom-index-data .custom-index-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: none;
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-tertiary);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.custom-index-data:hover .custom-index-remove {
    display: flex;
}

.custom-index-data .custom-index-remove:hover {
    background: var(--red-bg);
    color: var(--red);
}

/* 添加股票输入弹层（在卡片标题旁） */
.custom-index-add-form {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.custom-index-add-form input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xs);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font);
    outline: none;
}

.custom-index-add-form input:focus {
    border-color: var(--amber);
}

.custom-index-add-form button {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-xs);
    background: var(--amber);
    color: #111827;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
}

.custom-index-add-form button:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* .custom-index-status 旧的内嵌提示条已废弃,统一改用顶部 alert-toast 弹窗 */

/* ---------- 自选股 ---------- */
.watchlist-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    min-width: 0;
    overflow: hidden;
}

.watchlist-tabs {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 3px;
    max-width: 100%;
    overflow-x: scroll;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
}

.watchlist-tabs::-webkit-scrollbar { display: none; }
.watchlist-tabs.dragging { cursor: grabbing; scroll-snap-type: none; }

.watchlist-tab,
.watchlist-tab-add {
    min-height: 26px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text-tertiary);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    -webkit-tap-highlight-color: transparent;
}

.watchlist-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 48px;
    padding: 0 6px;
    scroll-snap-align: start;
}

.watchlist-tab.active {
    background: var(--amber-dim);
    border-color: var(--amber-soft);
    color: var(--amber);
}

.watchlist-tab-remove {
    width: 14px;
    height: 14px;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: transparent;
    font-size: 10px;
    line-height: 1;
}

.watchlist-tab-remove:active {
    color: var(--red);
}

.watchlist-tab-add {
    flex: 0 0 auto;
    padding: 0 8px;
    color: var(--amber);
    font-size: 13px;
}

/* Search bar */
.watchlist-add {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.watchlist-add input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font);
    outline: none;
}

.watchlist-add input::placeholder {
    color: var(--text-tertiary);
    font-size: 11px;
}

.watchlist-add input:focus {
    border-color: var(--amber);
}

.add-btn {
    padding: 6px 12px;
    border: 1px solid var(--amber-soft);
    border-radius: 0;
    background: var(--amber-dim);
    color: var(--amber);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
}

.add-btn:active { opacity: 0.7; }
.add-btn:disabled { cursor: wait; opacity: 0.4; }

/* Column headers — table-style */
/* 关键：让"价格/涨跌幅/操作"列在持仓股和非持仓股 tab 下位置和宽度完全一致
   只在"成本价"列和 1fr 区域有差异，避免切换时整张表"抖"一下
   列宽定义：4 列 [1fr, 64, 84, 26] / 5 列 [1fr, 64(cost), 64(price), 84(change), 26]
   gap 一律 12px（之前 4 列 16/5 列 12 也是抖动源头） */
.watchlist-header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px 84px 26px;
    align-items: center;
    padding: 7px 14px;
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 700;
    font-family: var(--mono);
    gap: 12px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-strong);
    border-top: 1px solid var(--border);
    background: var(--bg-row);
    margin: 0 -14px;
}

.watchlist-header-row.with-cost {
    grid-template-columns: minmax(0, 1fr) 64px 64px 84px 26px;
}

.watchlist-header-name { }
.watchlist-header-cost {
    display: none;
    text-align: left;
    padding-left: 8px;
}
.watchlist-header-row.with-cost .watchlist-header-cost {
    display: block;
}
.watchlist-header-price {
    text-align: right;
}
.watchlist-header-change {
    text-align: right;
}
.watchlist-header-action {
    text-align: center;
}

/* Watchlist items — dense table rows */
.watchlist-grid {
    display: grid;
    gap: 0;
    margin: 0 -14px;
}

.watchlist-empty {
    text-align: center;
    padding: 16px 10px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
}

.watchlist-item {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px 84px 26px;
    align-items: center;
    gap: 12px;
    border-radius: 0;
}

.watchlist-grid.with-cost .watchlist-item {
    grid-template-columns: minmax(0, 1fr) 64px 64px 84px 26px;
}

.watchlist-item:nth-child(even) {
    background: var(--bg-row);
}

.watchlist-item:last-child {
    border-bottom: none;
}

.watchlist-item-main {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.watchlist-stock-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    flex-shrink: 1;
    min-width: 0;
}

.watchlist-stock-code {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--mono);
    flex-shrink: 0;
    line-height: 1;
}

.watchlist-stock-price {
    font-size: 17px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -0.3px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.watchlist-stock-price.positive { color: var(--red); }
.watchlist-stock-price.negative { color: var(--green); }
.watchlist-stock-price.neutral  { color: var(--text-primary); }

/* Change % — colored bar background */
.watchlist-stock-change {
    font-size: 14px;
    font-weight: 700;
    font-family: var(--mono);
    text-align: right;
    letter-spacing: -0.2px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    font-variant-numeric: tabular-nums;
    padding: 3px 6px;
    border-radius: 0;
    line-height: 1;
}

.watchlist-stock-change.positive {
    color: var(--red);
    background: var(--red-bg);
}
.watchlist-stock-change.negative {
    color: var(--green);
    background: var(--green-bg);
}
.watchlist-stock-change.neutral {
    color: var(--text-tertiary);
    background: rgba(255,255,255,0.03);
}

/* 成本价列：上下两行（成本价 + 盈亏值） */
.watchlist-stock-cost {
    text-align: left;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    white-space: nowrap;
}

.watchlist-stock-cost .cost-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.watchlist-stock-cost .cost-value.empty {
    color: var(--text-tertiary);
    font-weight: 500;
}

.watchlist-stock-cost .cost-pnl {
    font-size: 11px;
    font-weight: 600;
    margin-top: 1px;
    color: var(--text-tertiary);
}

.watchlist-stock-cost .cost-pnl.positive { color: var(--red); }
.watchlist-stock-cost .cost-pnl.negative { color: var(--green); }

/* 标题右侧"编辑/保存"切换按钮（默认编辑，展开后变成高亮保存态） */
.watchlist-edit-btn {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 8px;
    margin-left: 6px;
    cursor: pointer;
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
    text-align: center;
    line-height: 1.5;
    /* 默认 visible（HTML 加载即可见），候选股 tab 由 JS 改 hidden
       用 visibility 而非 display: none，避免按钮隐藏/显示时把 card-header 行高
       压缩/撑高，导致下方 .watchlist-item 整体跳动 */
}

.watchlist-edit-btn:hover {
    border-color: var(--amber);
    color: var(--amber);
}

/* "保存"态：金色填充，视觉上像主操作按钮 */
.watchlist-edit-btn.active {
    background: var(--amber);
    border-color: var(--amber);
    color: #111827;
}

.watchlist-edit-btn.active:hover {
    background: var(--amber);
    color: #111827;
    opacity: 0.9;
}

.watchlist-edit-btn:hover {
    border-color: var(--amber);
    color: var(--amber);
}

/* "保存"态：金色填充，视觉上像主操作按钮 */
.watchlist-edit-btn.active {
    background: var(--amber);
    border-color: var(--amber);
    color: #111827;
}

.watchlist-edit-btn.active:hover {
    background: var(--amber);
    color: #111827;
    opacity: 0.9;
}

/* 编辑面板：逐行填成本价/股数 */
.watchlist-edit-panel {
    margin: 8px -14px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--amber);
    border-radius: var(--radius-sm);
    padding: 0;
    overflow: hidden;
}

.watchlist-edit-panel[hidden] { display: none; }

.watchlist-edit-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 8px 12px;
    background: var(--amber-dim);
    border-bottom: 1px solid var(--border-card);
    letter-spacing: 0.3px;
}

.watchlist-edit-panel-title {
    color: var(--text-primary);
}

.watchlist-edit-panel-hint {
    color: var(--amber);
    font-size: 10px;
}

.watchlist-edit-rows {
    display: grid;
    gap: 0;
    padding: 4px 0;
}

.watchlist-edit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 80px;
    gap: 8px;
    align-items: center;
    padding: 4px 12px;
}

.watchlist-edit-row + .watchlist-edit-row {
    border-top: 1px solid var(--border-subtle);
}

.watchlist-edit-row-name {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.watchlist-edit-row-name .edit-row-code {
    color: var(--text-tertiary);
    font-size: 10px;
    font-family: var(--mono);
    flex-shrink: 0;
}

.watchlist-edit-row-field {
    position: relative;
}

.watchlist-edit-row-field-label {
    position: absolute;
    top: 50%;
    left: 6px;
    transform: translateY(-50%);
    font-size: 9px;
    color: var(--text-tertiary);
    font-family: var(--font);
    pointer-events: none;
    letter-spacing: 0.3px;
}

.watchlist-edit-row input {
    padding: 5px 7px;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xs);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--mono);
    text-align: right;
    outline: none;
    min-width: 0;
    width: 100%;
    /* 移除 number input 原生上下调节器（spinner） */
    -moz-appearance: textfield;
    appearance: textfield;
}

.watchlist-edit-row input::-webkit-outer-spin-button,
.watchlist-edit-row input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.watchlist-edit-row input:focus {
    border-color: var(--amber);
}

.watchlist-edit-row input::placeholder {
    color: var(--text-tertiary);
    font-family: var(--font);
}

.trend-arrow {
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0.95;
    line-height: 1;
}

.watchlist-remove-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    -webkit-tap-highlight-color: transparent;
    justify-self: center;
}

.watchlist-remove-btn:active {
    color: var(--red);
    opacity: 1;
}

/* ---------- 持仓股 "今日资金流" sub-row (4 档 mini bar) — 现在主要用于弹窗 ---------- */
.watchlist-fund-flow {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.watchlist-fund-row {
    display: grid;
    grid-template-columns: 36px 1fr 64px;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11px;
}
.watchlist-fund-label {
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    font-size: 10px;
}
.watchlist-fund-track {
    height: 6px;
    background: var(--bg-surface-alt, rgba(255, 255, 255, 0.04));
    border-radius: 1px;
    position: relative;
    overflow: hidden;
}
.watchlist-fund-fill {
    height: 100%;
    width: 0;
    transition: width 0.4s ease;
    border-radius: 1px;
}
.watchlist-fund-fill.positive { background: var(--red); }
.watchlist-fund-fill.negative { background: var(--green); }
.watchlist-fund-value {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.watchlist-fund-value.positive { color: var(--red); }
.watchlist-fund-value.negative { color: var(--green); }
.watchlist-fund-value.neutral { color: var(--text-tertiary); }

/* ---------- 持仓股行点击反馈 (弹窗触发) ---------- */
.watchlist-item.clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.watchlist-item.clickable:active {
    background: var(--bg-row, rgba(255, 255, 255, 0.04));
}

/* ---------- 单股资金流 Modal ---------- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
}
.modal-overlay[hidden] { display: none !important; }
.modal-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface, #0e0e0e);
    border: 1px solid var(--border-strong, #333);
    z-index: 201;
    width: 92%;
    max-width: 420px;
    padding: 0;
    display: flex;
    flex-direction: column;
}
/* 关键: [hidden] 属性默认是 display:none, 但上面 .modal-panel 的 display:flex 会覆盖它,
   所以默认就显示出来、关闭也关不掉. 强制优先级让 hidden 真正生效 */
.modal-panel[hidden] { display: none !important; }
.modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 0 0 auto;
}
.modal-header-time {
    flex: 1;
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: var(--mono);
    text-align: right;
    margin-right: 4px;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    font-family: var(--mono);
    -webkit-tap-highlight-color: transparent;
}
.modal-close:active { color: var(--text-primary); }
.modal-body {
    padding: 12px;
}
.stock-fund-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-subtle, rgba(255, 255, 255, 0.06));
}
.stock-fund-main {
    flex: 1;
    text-align: right;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.watchlist-status {
    font-size: 10px;
    padding: 4px 0 0;
    color: var(--text-tertiary);
    font-family: var(--mono);
}
.watchlist-status.error { color: var(--red); }

/* ---------- 资金流向 — 6 格子 (主力 4 档 + 北向 2 通道) ---------- */
.capital-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.capital-item {
    background: transparent;
    padding: 8px 10px;
    text-align: left;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.04));
}

/* 3 列布局: 每行末列 (3/6) 拿掉右边框 */
.capital-item:nth-child(3n) { border-right: none; }
/* 第 2 行 (4/5/6 北向) 拿掉底边框, 与第 1 行 (资金 4 档) 用底边框分组 */
.capital-item:nth-child(n+4) { border-bottom: none; padding-top: 10px; }

.capital-label {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    font-weight: 600;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.capital-value {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}

.capital-value.positive { color: var(--red); }
.capital-value.negative { color: var(--green); }

@media (max-width: 480px) {
    .capital-grid { grid-template-columns: repeat(2, 1fr); }
    .capital-item:nth-child(2n) { border-right: none; }
    .capital-item:nth-child(n+5) { border-bottom: none; padding-top: 10px; }
}

/* ---------- 板块排行 — Text Tabs ---------- */
.sector-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 6px;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    border-bottom: 1px solid var(--border);
}

.sector-tab {
    flex: 0 0 auto;
    padding: 6px 12px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--mono);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
}

.sector-tab.active {
    color: var(--amber);
    border-bottom-color: var(--amber);
    background: transparent;
    box-shadow: none;
}

.sector-panel { display: none; }
.sector-panel.active { display: block; }

.sector-list {
    list-style: none;
}

.sector-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.sector-list li:nth-child(even) {
    background: var(--bg-row);
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
}

.sector-list li:last-child { border-bottom: none; }

.sector-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
}

.sector-list .list-empty { border-bottom: none; }

/* ---------- 板块排行 — Diverging Bar Chart ---------- */
.sector-header-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-left: auto;
    margin-right: 6px;
    font-family: var(--mono);
}
.sector-chart {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.sector-chart-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sector-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 4px 0;
    font-family: var(--mono);
}
.sector-bars {
    display: flex;
    flex-direction: column;
}
.sector-bar-row {
    display: grid;
    grid-template-columns: 88px 1fr 60px 56px;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-family: var(--mono);
    font-size: 12px;
}
.sector-bar-name {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}
.sector-bar-label {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sector-bar-change {
    font-size: 10px;
    font-family: var(--mono);
    margin-top: 1px;
}
.sector-bar-change.positive { color: var(--red); }
.sector-bar-change.negative { color: var(--green); }
.sector-bar-change.neutral { color: var(--text-tertiary); }
.sector-bar-track {
    height: 8px;
    background: var(--bg-surface-alt, rgba(255, 255, 255, 0.04));
    border-radius: 1px;
    position: relative;
    overflow: hidden;
}
.sector-bar-fill {
    height: 100%;
    width: 0;
    transition: width 0.4s ease;
    border-radius: 1px;
}
.sector-bar-fill.positive { background: var(--red); }
.sector-bar-fill.negative { background: var(--green); }
.sector-bar-value {
    text-align: right;
    font-weight: 700;
    font-size: 12px;
    font-family: var(--mono);
}
.sector-bar-value.positive { color: var(--red); }
.sector-bar-value.negative { color: var(--green); }
.sector-bar-leader {
    font-size: 10px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--mono);
}
@media (max-width: 480px) {
    .sector-bar-row {
        grid-template-columns: 72px 1fr 56px;
    }
    .sector-bar-leader { display: none; }
}
.sector-amount.positive { color: var(--red); font-weight: 700; font-family: var(--mono); font-size: 12px; }
.sector-amount.negative { color: var(--green); font-weight: 700; font-family: var(--mono); font-size: 12px; }

/* ---------- 龙虎榜 ---------- */
.dragon-tiger-header-date,
.watchlist-header-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-right: auto;
    margin-left: 6px;
    font-family: var(--mono);
    white-space: nowrap;
}

.dragon-tiger-list { }
.dragon-tiger-empty {
    text-align: center;
    padding: 14px 8px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
}

.dragon-tiger-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.dragon-tiger-item:nth-child(even) {
    background: var(--bg-row);
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
}

.dragon-tiger-item:last-child { border-bottom: none; }

.dragon-tiger-stock {
    flex: 0 1 80px;
    min-width: 0;
}

.dragon-tiger-stock-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 76px;
}

.dragon-tiger-stock-code {
    font-size: 9px;
    color: var(--text-tertiary);
    font-family: var(--mono);
    margin-top: 0;
}

.dragon-tiger-reason {
    flex: 1;
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dragon-tiger-net {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--mono);
    min-width: 64px;
    text-align: right;
    white-space: nowrap;
}

.dragon-tiger-net.positive { color: var(--red); }
.dragon-tiger-net.negative { color: var(--green); }

/* ---------- 异动提醒 (打板层 4 池) ---------- */
.limit-up-header-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-left: auto;
    margin-right: 6px;
    font-family: var(--mono);
}
.limit-up-summary {
    margin-bottom: 8px;
}
.limit-up-stat-card {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    margin-bottom: 6px;
}
.limit-up-stat-cell {
    padding: 6px 4px;
    text-align: center;
    border-right: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    font-family: var(--mono);
}
.limit-up-stat-cell:last-child { border-right: none; }
.limit-up-stat-label {
    display: block;
    font-size: 9px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}
.limit-up-stat-val {
    display: block;
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.limit-up-stat-val.positive { color: var(--red); }
.limit-up-stat-val.negative { color: var(--green); }
.limit-up-stat-sub {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 400;
    margin-left: 2px;
}
.limit-up-stat-ladder {
    font-size: 10px;
    color: var(--text-secondary);
    font-family: var(--mono);
    padding: 2px 0 6px 0;
    line-height: 1.4;
}
.limit-up-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}
.limit-up-tab {
    background: transparent;
    border: none;
    padding: 5px 10px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.limit-up-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--amber-soft, #ffb340);
}
.limit-up-tab:hover:not(.active) { color: var(--text-secondary); }
.limit-up-list { }
.limit-up-empty {
    text-align: center;
    padding: 14px 8px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
}
.limit-up-row {
    display: grid;
    grid-template-columns: 1fr 56px 60px 76px 60px;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    font-family: var(--mono);
    font-size: 11px;
}
.limit-up-row:nth-child(even) {
    background: var(--bg-row, rgba(255, 255, 255, 0.04));
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
}
.limit-up-row:last-child { border-bottom: none; }
.limit-up-name-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}
.limit-up-name {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.limit-up-code {
    color: var(--text-tertiary);
    font-size: 9px;
}
.limit-up-pct {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.limit-up-pct.positive { color: var(--red); }
.limit-up-pct.negative { color: var(--green); }
.limit-up-pct.neutral { color: var(--text-tertiary); }
.limit-up-stat,
.limit-up-seal {
    text-align: right;
    color: var(--text-secondary);
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.limit-up-ind {
    font-size: 10px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .limit-up-row { grid-template-columns: 1fr 48px 56px 64px; }
    .limit-up-ind { display: none; }
}

/* ---------- 新闻来源 — Text Tabs ---------- */
.news-source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 6px;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    border-bottom: 1px solid var(--border);
}

.news-source-tab {
    flex: 0 0 auto;
    padding: 6px 12px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    -webkit-tap-highlight-color: transparent;
}

.news-source-tab.active {
    color: var(--amber);
    border-bottom-color: var(--amber);
    background: transparent;
    box-shadow: none;
}

/* ---------- 多日资金流向 ---------- */
.multiday-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.multiday-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

.table-title {
    font-size: 10px;
    margin-bottom: 4px;
    padding: 4px 6px;
    border-radius: 0;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-title.positive { background: var(--red-bg); color: var(--red); }
.table-title.negative { background: var(--green-bg); color: var(--green); }

.multiday-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 10px;
    font-family: var(--mono);
}

.multiday-table th,
.multiday-table td {
    padding: 5px 4px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.multiday-table tr:nth-child(even) {
    background: var(--bg-row);
}

.multiday-table th {
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-row);
}

.multiday-table th:first-child { text-align: left; }

.sector-name-cell {
    color: var(--text-primary);
    font-weight: 600;
    text-align: left !important;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font);
}

.flow-positive { color: var(--red); }
.flow-negative { color: var(--green); }

.trend-cell { font-size: 11px; }

.consecutive-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 0;
    font-size: 9px;
    font-weight: 700;
    background: var(--red-bg);
    color: var(--red);
    font-family: var(--mono);
    text-transform: uppercase;
}

.consecutive-badge.outflow {
    background: var(--green-bg);
    color: var(--green);
}

.hot-sector { background: rgba(255, 23, 68, 0.04) !important; }
.cold-sector { background: rgba(0, 230, 118, 0.04) !important; }

/* ---------- 财经新闻 — 瀑布流分页 ---------- */
.news-list {
    column-count: 1;
    column-gap: 10px;
}

.news-item {
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    background: var(--bg-row);
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    display: inline-block; /* multi-column 兼容 */
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.news-status {
    text-align: center;
    padding: 14px 8px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
    break-inside: avoid;
}
.news-status.news-loading::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border: 1.5px solid var(--text-tertiary);
    border-top-color: transparent;
    border-radius: 50%;
    vertical-align: -1px;
    animation: news-spin 0.8s linear infinite;
}
@keyframes news-spin {
    to { transform: rotate(360deg); }
}
.news-status.news-error { color: var(--red); }
.news-status.news-loadend { color: var(--text-tertiary); opacity: 0.6; }
.news-status.news-loadmore { color: var(--text-secondary); }

.news-item:last-child { border-bottom: none; }
.news-item:active {
    background: var(--bg-row);
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

.news-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    flex: 1;
    color: var(--text-primary);
}

.news-time {
    font-size: 10px;
    color: var(--text-tertiary);
    white-space: nowrap;
    font-family: var(--mono);
    margin-top: 1px;
}

.news-data-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.data-tag {
    background: var(--amber-dim);
    color: var(--amber);
    padding: 1px 5px;
    border-radius: 0;
    font-size: 9px;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
}

.news-summary {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 2px;
}

.news-sectors {
    font-size: 10px;
    color: var(--text-tertiary);
    font-style: normal;
    font-family: var(--mono);
}

/* ---------- Settings / Data Panel ---------- */
.settings-overlay,
.data-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.settings-overlay.open,
.data-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.settings-panel,
.data-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 201;
    background: var(--bg-elevated);
    border-radius: 0;
    border-top: 1px solid var(--amber-soft);
    padding: 0 14px calc(14px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.25s ease;
    max-width: 480px;
    margin: 0 auto;
}

.settings-panel.open,
.data-panel.open {
    transform: translateY(0);
}

.panel-handle {
    width: 32px;
    height: 3px;
    border-radius: 0;
    background: var(--border-strong);
    margin: 6px auto 0;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 8px;
    border-bottom: 1px solid var(--border);
}

.settings-header h3 {
    font-size: 12px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-close {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close:active { background: var(--border-strong); }

.settings-body {
    padding-top: 6px;
}

.settings-section-label {
    font-size: 9px;
    color: var(--text-tertiary);
    padding: 10px 0 3px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    font-family: var(--mono);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.settings-row-stacked {
    display: grid;
    gap: 8px;
}

.settings-row-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

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

.settings-row label:first-child {
    font-size: 13px;
    color: var(--text-primary);
}

.data-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.data-action-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.data-action-desc {
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1.3;
    font-family: var(--mono);
}

.data-action-btn {
    flex: 0 0 auto;
    min-width: 52px;
    height: 28px;
    border: 1px solid var(--amber-soft);
    border-radius: 0;
    background: var(--amber-dim);
    color: var(--amber);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-action-btn:active { opacity: 0.7; }

.data-action-btn.secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.data-status {
    min-height: 16px;
}

/* ---------- Toggle Switch (Terminal style) ---------- */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    cursor: pointer;
}

.toggle input { display: none; }

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 0;
    border: 1px solid var(--border-strong);
    transition: background 0.15s;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-tertiary);
    border-radius: 0;
    transition: transform 0.15s, background 0.15s;
}

.toggle input:checked + .toggle-track {
    background: var(--amber-dim);
    border-color: var(--amber-soft);
}

.toggle input:checked + .toggle-track::after {
    transform: translateX(20px);
    background: var(--amber);
}

.settings-row select {
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--mono);
    outline: none;
}

.settings-range-value {
    color: var(--amber);
    font-size: 12px;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.settings-range-input {
    width: 100%;
    accent-color: var(--amber);
    cursor: pointer;
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 10px 10px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    color: var(--text-tertiary);
    font-size: 9px;
    font-family: var(--mono);
    line-height: 1.8;
    letter-spacing: 0.3px;
    border-top: 1px solid var(--border);
}

/* Sector flow compat */
.sector-flow-container { display: grid; gap: 8px; }
.sector-flow {
    background: var(--bg-row);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 6px 8px 2px;
}
.section-label { margin-bottom: 2px; font-size: 10px; font-weight: 700; font-family: var(--mono); text-transform: uppercase; }
.section-label.positive { color: var(--red); }
.section-label.negative { color: var(--green); }

/* ================================================================
   Desktop (≥768px)
   ================================================================ */
@media (min-width: 768px) {
    body { padding: 0; }

    #main-content {
        max-width: 760px;
        width: 100%;
        margin: 0 auto;
    }

    .header {
        max-width: 760px;
        width: 100%;
        margin: 0 auto;
    }

    .tab-bar {
        max-width: 760px;
        width: 100%;
        margin: 0 auto;
    }

    .footer {
        max-width: 760px;
        margin: 0 auto;
    }

    .header-btn:hover { background: var(--border-strong); }
    .watchlist-remove-btn { opacity: 0; }
    .watchlist-item:hover .watchlist-remove-btn { opacity: 1; }
    .watchlist-item:hover { background: var(--bg-row) !important; }
    .tab-btn:hover:not(.active) { color: var(--text-secondary); background: rgba(255, 171, 0, 0.03); }
    .card-header:hover { background: var(--bg-elevated); }
    .news-item:hover { background: var(--bg-row-alt); border-color: var(--border-strong); }
    .sector-tab:hover:not(.active) { color: var(--text-secondary); }
    .news-source-tab:hover:not(.active) { color: var(--text-secondary); }
}

/* ================================================================
   Small Screen (≤380px)
   ================================================================ */
@media (max-width: 380px) {
    .index-grid {
        grid-template-columns: 1fr 1fr;
    }

    .index-item:nth-child(odd) {
        border-right: 1px solid var(--border);
    }
    .index-item:nth-child(even) {
        border-right: none;
    }

    .watchlist-header-row,
    .watchlist-item {
        grid-template-columns: minmax(0, 1fr) 48px 64px 18px;
        gap: 6px;
    }

    .watchlist-header-row.with-cost,
    .watchlist-grid.with-cost .watchlist-item {
        grid-template-columns: minmax(0, 1fr) 48px 48px 64px 18px;
    }

    .watchlist-stock-price { font-size: 12px; }
    .watchlist-stock-change {
        font-size: 10px;
        padding: 2px 4px;
    }
    .watchlist-stock-name { font-size: 12px; }
    .watchlist-stock-cost .cost-value { font-size: 11px; }
    .watchlist-stock-cost .cost-pnl { font-size: 9px; }
}

@media (min-width: 1280px) {
    #main-content { max-width: 920px; }
    .header { max-width: 920px; }
    .tab-bar { max-width: 920px; }
    .footer { max-width: 920px; }
    .news-list { column-count: 2; }
}

/* ---------- Alert Toast (涨跌幅告警) ---------- */
.alert-toast-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 6px;
    pointer-events: none;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

.alert-toast {
    pointer-events: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--amber);
    color: var(--text-primary);
    padding: 8px 10px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-family: var(--font);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    animation: alert-toast-in 0.25s ease-out;
    position: relative;
}

.alert-toast.alert-up { border-left-color: var(--green); }
.alert-toast.alert-down { border-left-color: var(--red); }
.alert-toast.alert-info { border-left-color: var(--text-secondary); }

.alert-toast.removing {
    animation: alert-toast-out 0.2s ease-in forwards;
}

@keyframes alert-toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes alert-toast-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-8px); }
}

.alert-toast-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.alert-toast-title {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
}

.alert-toast-direction {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.5px;
    padding: 1px 4px;
    border: 1px solid currentColor;
}
.alert-toast.alert-up .alert-toast-direction { color: var(--green); }
.alert-toast.alert-down .alert-toast-direction { color: var(--red); }

.alert-toast-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alert-toast-code {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-tertiary);
}

.alert-toast-detail {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11px;
}

.alert-toast-price {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
}

.alert-toast-pct { font-weight: 700; font-size: 12px; }
.alert-toast-pct.positive { color: var(--green); }
.alert-toast-pct.negative { color: var(--red); }

.alert-toast-base {
    color: var(--text-tertiary);
    font-size: 10px;
    margin-left: auto;
}

.alert-toast-time {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--text-tertiary);
    letter-spacing: 0.3px;
}

.alert-toast-close {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    font-family: var(--mono);
}
.alert-toast-close:active { color: var(--text-primary); border-color: var(--amber-soft); }

.settings-number-input {
    width: 80px;
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--mono);
    outline: none;
    text-align: right;
}
.settings-number-input:focus { border-color: var(--amber-soft); }

/* ---------- 自选股 120 日资金流 ---------- */
.fund-flow-header-hint {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-left: auto;
    margin-right: 6px;
    font-family: var(--mono);
}
.fund-flow-empty {
    text-align: center;
    padding: 14px 8px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-family: var(--mono);
}
.fund-flow-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 12px;
}
.fund-flow-table th,
.fund-flow-table td {
    padding: 6px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border-subtle);
}
.fund-flow-table th:first-child,
.fund-flow-table td:first-child { text-align: left; }
.fund-flow-table thead th {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent;
}
.fund-flow-table tbody tr:nth-child(even) {
    background: var(--bg-surface-alt);
}
.fund-flow-name {
    font-weight: 700;
    color: var(--text-primary);
}
.fund-flow-trend {
    font-size: 14px;
    letter-spacing: 1px;
    white-space: nowrap;
}
.fund-flow-trend .flow-positive { color: var(--red); }
.fund-flow-trend .flow-negative { color: var(--green); }
.fund-flow-trend .flow-neutral { color: var(--text-tertiary); }
.flow-neutral { color: var(--text-tertiary); }

/* ---------- 市场热度 (同花顺热榜 + 东财人气榜) ---------- */
.hot-rank-header-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-left: auto;
    margin-right: 6px;
    font-family: var(--mono);
}
.hot-rank-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}
.hot-rank-tab {
    background: transparent;
    border: none;
    padding: 6px 12px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}
.hot-rank-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--amber-soft);
}
.hot-rank-tab:hover:not(.active) { color: var(--text-secondary); }
.hot-rank-panel { display: none; }
.hot-rank-panel.active { display: block; }
.hot-rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.hot-rank-item {
    display: grid;
    grid-template-columns: 24px 1fr 60px 60px 50px;
    align-items: center;
    gap: 8px;
    padding: 7px 4px;
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--mono);
    font-size: 12px;
}
.hot-rank-item:nth-child(even) {
    background: var(--bg-surface-alt);
}
.hot-rank-item:last-child { border-bottom: none; }
.hot-rank-rank {
    text-align: center;
    font-weight: 700;
    color: var(--text-tertiary);
    font-size: 11px;
}
.hot-rank-stock {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.hot-rank-name {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hot-rank-code {
    color: var(--text-tertiary);
    font-size: 10px;
}
.hot-rank-pct {
    text-align: right;
    font-weight: 600;
}
.hot-rank-pct.positive { color: var(--red); }
.hot-rank-pct.negative { color: var(--green); }
.hot-rank-pct.neutral { color: var(--text-tertiary); }
.hot-rank-heat,
.hot-rank-price {
    text-align: right;
    color: var(--text-secondary);
    font-size: 11px;
}
.hot-rank-chg {
    text-align: center;
    font-weight: 700;
    font-size: 11px;
}
.hot-rank-chg.positive { color: var(--red); }
.hot-rank-chg.negative { color: var(--green); }
.hot-rank-chg.neutral { color: var(--text-tertiary); }
.hot-rank-concepts {
    display: none;  /* 移动到第二行 */
}
@media (min-width: 600px) {
    .hot-rank-item {
        grid-template-columns: 24px 1fr 60px 60px 50px auto;
    }
    .hot-rank-concepts {
        display: flex;
        gap: 4px;
        align-items: center;
    }
}
.hot-rank-concept {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    background: var(--amber-soft-bg, rgba(255, 179, 64, 0.12));
    color: var(--amber-soft, #ffb340);
    border-radius: 2px;
    font-family: var(--mono);
    white-space: nowrap;
}
.hot-rank-tag {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    background: var(--red-bg, rgba(255, 23, 68, 0.12));
    color: var(--red, #ff1744);
    border-radius: 2px;
    font-family: var(--mono);
    white-space: nowrap;
}
