:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel2: #f9fafb;
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --border: #e5e7eb;
  --border-2: #f3f4f6;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --up: #ef4444;     /* 涨红（A股惯例） */
  --down: #10b981;   /* 跌绿 */
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #10b981;
  --row-hover: #f3f4f6;
  --row-alt: #fafbfc;
  --row-pushed: #fff7ed;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --mono: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", system-ui, sans-serif;
}

/* ===================== 深色主题 ===================== */
:root[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #181b22;
  --panel2: #20242e;
  --text: #e6e8ee;
  --text-2: #aab1c0;
  --muted: #6b7280;
  --border: #2a2f3a;
  --border-2: #23272f;
  --accent: #818cf8;
  --accent-2: #a5b4fc;
  --up: #f87171;
  --down: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --row-hover: #20242e;
  --row-alt: #1b1f27;
  --row-pushed: #2a2118;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 700 14px/1.6 "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", system-ui, sans-serif;
}
.hidden { display: none !important; }
.num, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; }
.mono { font-family: var(--mono); }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.up-bg { background: rgba(239,68,68,.06); }

/* ===================== 顶栏 ===================== */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  flex-wrap: wrap;
  min-height: 50px;
}
.brand { display: flex; align-items: center; gap: 6px; padding-right: 6px; }
.brand-icon { font-size: 18px; }
.brand-title { font-weight: 700; font-size: 16px; }

.top-tabs { display: flex; gap: 4px; }
.top-tab {
  background: none; border: none; color: var(--text-2);
  padding: 7px 14px; font-size: 14.5px; cursor: pointer; border-radius: 6px;
  font-weight: 700;
}
.top-tab:hover { background: var(--bg); }
.top-tab.active { color: var(--accent); background: rgba(79,70,229,.08); }

/* ===================== 消息菜单（下架公告） ===================== */
#btn-msg { position: relative; }
.msg-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 5px;
  font-size: 11px; font-weight: 700; line-height: 1; color: #fff;
  background: #e23b3b; border-radius: 9px; vertical-align: middle;
}
.msg-count:empty, .msg-count[data-zero="1"] { display: none; }
.msg-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 95;
  width: min(360px, 92vw); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0,0,0,.18);
  display: none; overflow: hidden;
}
.msg-dropdown.show { display: block; }
.msg-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.msg-title { font-size: 15px; font-weight: 800; }
.msg-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.msg-filter { display: flex; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.msg-filter + .msg-filter { padding-top: 0; border-top: none; } /* 第二行筛选（交易所）紧贴分类行 */
.msg-filter .sm-btn { padding: 3px 10px; font-size: 12.5px; }
.msg-mute-label { font-size: 12px; color: var(--text-2); align-self: center; } /* 「屏蔽交易所」行内标签（checkbox 模式） */
.msg-cat-filter { flex-wrap: wrap; } /* 7 类分类 / 交易所屏蔽 checkbox 较多时换行 */
.msg-cat-filter input[type="checkbox"] { accent-color: var(--accent); } /* 分类屏蔽 checkbox 用主题色（参考截图） */
.msg-cat-filter .checkbox { font-weight: 700; color: var(--text); }
.msg-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.msg-empty { padding: 22px 12px; text-align: center; color: var(--text-2); font-size: 13px; }
.msg-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 7px; text-decoration: none; color: var(--text);
}
.msg-item:hover { background: var(--bg); }
.msg-dot { width: 8px; height: 8px; border-radius: 50%; background: #e23b3b; flex: none; }
.msg-item.ex-bybit .msg-dot { background: #f0a020; }
.msg-item.cat-listing .msg-dot { background: #1f9d55; }                  /* 上新：绿点 */
.msg-item.cat-promo .msg-dot { background: #a855f7; }                     /* 活动（营销）：紫点 */
.msg-item.cat-trading_adjustment .msg-dot { background: #f59e0b; }         /* 交易调整：橙点 */
.msg-item.cat-maintenance .msg-dot { background: #6b7280; }               /* 维护升级：灰点 */
.msg-item.cat-deposit_withdraw .msg-dot { background: #06b6d4; }          /* 充提：青点 */
.msg-item.cat-other .msg-dot { background: #9ca3af; }                     /* 其他：浅灰 */
.msg-item.cat-general .msg-dot { background: #3b82f6; }                   /* 一般（兼容旧数据）：蓝点 */
.msg-item.cat-delist.src-system .msg-dot { background: #9aa3af; }         /* 系统检测下架：灰点 */
.msg-item.cat-delist.src-announce .msg-dot { background: #e23b3b; }       /* 交易所公告下架：红点 */
.msg-text { flex: 1; font-size: 13.5px; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg-ex { font-size: 11px; font-weight: 700; color: var(--text-2); background: var(--bg); padding: 2px 7px; border-radius: 6px; flex: none; }
.msg-time { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; flex: none; }


.search-wrap { flex: 1; min-width: 160px; max-width: 360px; }
.search {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 6px; font-size: 12px; outline: none;
  color: var(--text);
}
.search:focus { border-color: var(--accent); background: var(--panel); }

.controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ctrl-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--text-2);
  padding: 6px 10px; border-radius: 6px; font-size: 13.5px; cursor: pointer;
  font-weight: 700; transition: all .12s;
}
.ctrl-btn:hover { color: var(--accent); border-color: var(--accent); }
.ctrl-btn.icon { padding: 6px 8px; }
.ctrl-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ctrl-btn.sound-off { opacity: .6; }
.ctrl-check { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); cursor: pointer; user-select: none; }
.ctrl-check input { accent-color: var(--accent); cursor: pointer; }
.ctrl-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* 股票 / 代币三段式筛选 */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg .sm-btn {
  background: transparent; border: none; border-right: 1px solid var(--border);
  padding: 5px 10px; font-size: 13.5px; color: var(--text-2); cursor: pointer; font-weight: 700;
}
.seg .sm-btn:last-child { border-right: none; }
.seg .sm-btn:hover { color: var(--accent); background: var(--panel); }
.seg .sm-btn.active { background: var(--accent); color: #fff; }
.seg .sm-btn.active:hover { background: var(--accent-2); }
.card-filters .seg .sm-btn { padding: 3px 8px; font-size: 11px; } /* 卡片筛选行内的分段按钮与 chip 等高 */
.clock { font-size: 13px; color: var(--text-2); display: flex; gap: 4px; align-items: baseline; font-weight: 600; }
.clock b { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.clock em { color: var(--muted); font-style: normal; font-size: 12.5px; }

/* ===================== 视图切换 ===================== */
main.view { display: none; padding: 16px; }
main.view.active { display: block; }

/* ===================== 卡片栅格 ===================== */
.cards-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
@media (max-width: 980px) { .cards-row { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.card-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; }
.card-title em { color: var(--muted); font-style: normal; font-weight: 400; }
.card-info { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 4px var(--ok); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 4px var(--warn); }
.status-dot.err  { background: var(--danger); box-shadow: 0 0 4px var(--danger); }

.card-filters {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 8px 0; font-size: 11.5px; color: var(--text-2);
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 2px;
}
.flabel { color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px; cursor: pointer; user-select: none;
  font-size: 11px; color: var(--text-2);
  transition: all .12s;
}
.chip:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip input { display: none; }
.funit { color: var(--muted); font-size: 11px; }

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; } /* 整体滚动：表格全展开，仅在窄屏横向滚动 */
table.grid { width: 100%; border-collapse: collapse; font-size: 15px; }
table.grid th, table.grid td { padding: 12px 8px; text-align: left; white-space: nowrap; font-weight: 600; border: 1px solid var(--border); height: auto; vertical-align: middle; }
table.grid thead th {
  background: var(--panel2); color: var(--text); font-weight: 800; font-size: 12.5px; letter-spacing: .03em;
  border-bottom: 2px solid var(--border); position: sticky; top: 0; z-index: 5; user-select: none;
}
table.grid tbody tr { border-bottom: 1px solid var(--border); }
table.grid tbody tr:nth-child(even) { background: var(--row-alt); }
table.grid tbody tr:hover { background: var(--row-hover); }
table.grid tbody tr.pushed { background: var(--row-pushed); }
table.grid tbody tr.dismissed { display: none; }
table.grid td.num, table.grid th.num { text-align: left; }
/* 数字可读性：加深颜色、真粗体、轻微字距 */
table.grid td.num { color: var(--text); font-weight: 800; letter-spacing: .01em; font-size: 15px; }
/* 指数差价卡：资金费周期列居中、弱化显示，与资金费数值分组 */
table.grid td.fund-period { text-align: center; color: var(--muted); font-weight: 700; }
table.grid td.right, table.grid th.right { text-align: right; }
table.grid input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }
/* 复选框列保持居中（不受全局左对齐影响） */
table.grid td:has(input[type=checkbox]) { text-align: center; }
table.grid .empty { padding: 28px; text-align: center; color: var(--muted); }

/* 紧凑变体（用于三卡表格）：行距加宽 */
table.tight th, table.tight td { padding: 10px 8px; line-height: 1.6; }
table.tight thead th { padding-top: 11px; padding-bottom: 11px; letter-spacing: 0.03em; }

/* 报警行高亮：超过阈值（基于全部交易所判断，与列是否取消选中无关） */
table.grid tbody tr.alert-row {
  background: rgba(245,158,11,.18);
  box-shadow: inset 3px 0 0 var(--warn);
}
table.grid tbody tr.alert-row td { color: var(--text); }

/* 排序 */
table.sortable-table th.sortable { cursor: pointer; user-select: none; }
table.sortable-table th.sortable:hover { color: var(--text); background: var(--bg); }
table.sortable-table th.sortable .sort-arrow { color: var(--muted); font-size: 9px; margin-left: 3px; opacity: .45; }
table.sortable-table th.sortable.sorted { color: var(--accent); background: rgba(79,70,229,.05); }
table.sortable-table th.sortable.sorted .sort-arrow { color: var(--accent); opacity: 1; }

table.sortable-table .th-check { width: 24px; }

/* 币种 cell（居中） */
.coin-cell { line-height: 1.4; text-align: left; }
/* 涨跌幅/指数差价卡：交易所标签旁的「仅屏蔽该交易所」按钮，鼠标悬停时显示 */
.coin-cell .ex-block {
  border: none; background: transparent; cursor: pointer; font-size: 10px;
  line-height: 1; padding: 0 2px; opacity: 0; transition: opacity .12s; vertical-align: middle;
}
.coin-cell:hover .ex-block { opacity: .55; }
.coin-cell .ex-block:hover { opacity: 1; background: var(--panel2); border-radius: 3px; }
.coin-cell .base { font-weight: 800; font-size: 15px; color: var(--text); }
.coin-cell .ex { font-size: 11px; font-weight: 700; color: var(--text-2); display: block; margin-top: 1px; }
.coin-cell .coin-link { text-decoration: none; color: var(--text); cursor: pointer; }
.coin-cell .coin-link:hover { color: var(--accent); text-decoration: underline; }

/* 涨跌小色块：仅红绿字，无背景；涨跌幅卡 / 指数差价卡与资金费卡同字号 15px、加粗 800 */
.chg-pill {
  display: inline-block; padding: 3px 9px; border-radius: 5px;
  font-size: 15px; font-family: var(--mono); font-weight: 800;
}
.chg-pill.up { color: var(--up); }
.chg-pill.down { color: var(--down); }
.chg-pill.flat { color: var(--muted); font-weight: 600; }
.empty-cell { color: var(--muted); opacity: .45; font-weight: 400; }

/* ===================== 提醒管理 ===================== */
.alert-grid { display: grid; gap: 16px; max-width: 1400px; }
.acard { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.acard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.acard-head h3 { font-size: 14px; }
.aform { display: grid; gap: 10px; }
.arow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.arow.right { justify-content: flex-end; }
.alabel { width: 150px; font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.ainput {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 7px 10px; border-radius: 6px; font-size: 12px; outline: none; flex: 1; min-width: 180px;
}
.ainput:focus { border-color: var(--accent); }
.ainput.num-input { flex: 0 0 100px; }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.abtn { background: #fff; color: var(--text-2); border: 1px solid var(--border); padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.abtn:hover { color: var(--accent); border-color: var(--accent); }
.abtn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.abtn.primary:hover { opacity: .85; color: #fff; }
.abtn.ghost { background: transparent; }
.abtn.sm { padding: 3px 10px; font-size: 11px; }
.aselect { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 6px; font-size: 12px; outline: none; flex: 0 0 auto; min-width: 150px; cursor: pointer; }
.aselect:focus { border-color: var(--accent); }
.hint.sub { font-size: 11px; color: var(--muted); margin-top: 6px; }
/* 资金费卡每格的单所屏蔽按钮 */
.cell-block { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; line-height: 14px; padding: 0; border: none; background: transparent; opacity: 0; cursor: pointer; font-size: 11px; transition: opacity .12s; border-radius: 3px; }
.fund-cell { position: relative; }
.fund-col:hover .cell-block { opacity: .55; }
.cell-block:hover { opacity: 1 !important; background: var(--panel2); }
.atable-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 6px; }

.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; background: var(--panel2); border: 1px solid var(--border); color: var(--muted); }
.tag.on { color: var(--ok); border-color: rgba(16,185,129,.4); }
.tag.off { color: var(--muted); }
.tag.type1 { color: var(--warn); border-color: rgba(245,158,11,.4); }
.tag.type2 { color: var(--accent); border-color: rgba(79,70,229,.4); }
.tag.type3 { color: #8b5cf6; border-color: rgba(139,92,246,.4); }
.tag.type4 { color: var(--up); border-color: rgba(239,68,68,.4); }

.log-list { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.log-item { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 12px; }
.log-item .log-head { display: flex; gap: 8px; align-items: center; }
.log-item .log-time { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.log-item .log-body { margin-top: 4px; color: var(--text-2); white-space: pre-wrap; word-break: break-all; font-size: 11px; }
.log-item.lv-error .log-title { color: var(--danger); }
.log-item.lv-warn .log-title { color: var(--warn); }
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 12px; }

/* ===================== 抽屉 ===================== */
.drawer-mask, .modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-mask.show, .modal-mask.show { opacity: 1; pointer-events: auto; }
/* 消息弹窗：背景板保持可见（仍显示涨跌幅榜），不做深色调遮罩，避免像切换界面 */
/* 消息弹窗：居中卡片（默认 .modal 定位），不使用全屏遮罩，背景榜单保持完整可见 */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(820px, 96vw); background: var(--panel); box-shadow: -4px 0 24px rgba(0,0,0,.15); z-index: 95; transform: translateX(100%); transition: transform .25s; overflow-y: auto; padding: 18px; }
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.drawer-head h2 { font-size: 18px; font-family: var(--mono); }
.close { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 4px 6px; }
.close:hover { color: var(--text); }
.spark-box { margin-bottom: 14px; }
#d-spark { width: 100%; height: 110px; background: var(--bg); border-radius: 6px; display: block; border: 1px solid var(--border); }

/* ===================== 弹窗 ===================== */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(.97); width: min(580px, 94vw); background: var(--panel); border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,.2); z-index: 100; opacity: 0; pointer-events: none; transition: all .2s; max-height: 88vh; display: flex; flex-direction: column; }
.modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===================== 历史资金费率弹窗 ===================== */
#fund-modal { width: min(900px, 96vw); }
#fund-modal .modal-body { padding: 14px 18px 18px; }
.fund-tip { position: fixed; z-index: 300; pointer-events: none; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.18); white-space: nowrap; display: none; }
.fund-tip .ft { color: var(--muted); margin-right: 8px; }
.fund-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.fstat { flex: 1; min-width: 96px; background: rgba(127,127,127,.08); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.fstat .fl { font-size: 11px; color: var(--muted); }
.fstat b { font-size: 15px; }
.fund-chart { margin: 4px 0 12px; }
.fund-chart svg { display: block; background: rgba(127,127,127,.06); border: 1px solid var(--border); border-radius: 8px; }
.fund-list-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; max-height: 220px; overflow-y: auto; }
.fund-list-head { position: sticky; top: 0; background: rgba(127,127,127,.12); color: var(--muted); font-weight: 600; }
.frow, .fund-list-head { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 12px; }
.frow { border-bottom: 1px solid var(--border); }
.frow:last-child { border-bottom: none; }
.frow .ft { color: var(--muted); }
.fund-hist { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.fund-hist:hover { filter: brightness(1.1); }

/* ===================== Toast ===================== */
#toasts { position: fixed; top: 60px; right: 16px; z-index: 200; display: grid; gap: 6px; width: 320px; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.1); animation: ti .25s ease; font-size: 12px; }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--danger); }
.toast .t-title { font-weight: 600; }
.toast .t-body { color: var(--text-2); margin-top: 3px; word-break: break-all; font-size: 11px; }
@keyframes ti { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { animation: to .3s ease forwards; }
@keyframes to { to { opacity: 0; transform: translateX(20px); } }

/* ===================== 报警弹窗（右上角，单一整合面板，最多 5 条） ===================== */
#alert-box { position: fixed; top: 60px; right: 16px; z-index: 195; width: 340px; display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; animation: alertIn .28s ease; font-size: 12px; }
#alert-box.show { display: block; }
.alert-panel-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.alert-panel-title { font-weight: 700; font-size: 13px; }
.alert-count { background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; padding: 3px 8px; border-radius: 10px; }
.alert-clear { margin-left: auto; border: none; background: transparent; color: var(--text-2); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.alert-clear:hover { color: var(--text); }
.alert-list { max-height: 360px; overflow-y: auto; }
.alert-item { border-bottom: 1px solid var(--border); padding: 8px 12px; }
.alert-item:last-child { border-bottom: none; }
.alert-item.lvl-err { border-left: 3px solid var(--danger); }
.alert-item.lvl-warn { border-left: 3px solid var(--warn); }
.alert-item-head { display: flex; align-items: center; gap: 6px; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.alert-item.lvl-err .alert-dot { background: var(--danger); }
.alert-title { font-weight: 600; line-height: 1.4; }
.alert-time { margin-left: auto; font-size: 11px; color: var(--text-2); flex: none; }
.alert-item-close { border: none; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px; flex: none; }
.alert-item-close:hover { color: var(--text); }
.alert-body { margin-top: 4px; color: var(--text-2); font-size: 11px; line-height: 1.4; word-break: break-all; }
@keyframes alertIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===================== 交易所新公告弹窗（右下角，加大加高醒目） ===================== */
#ann-box { position: fixed; right: 16px; bottom: 16px; z-index: 210; display: grid; gap: 10px; width: 440px; }
#ann-box:empty { display: none; }
.ann-card { position: relative; background: var(--panel); border: 1px solid var(--border); border-left: 5px solid var(--accent); border-radius: 10px; padding: 16px 18px; box-shadow: 0 10px 32px rgba(0,0,0,.28); animation: anni .28s ease; font-size: 14px; }
.ann-card.cat-listing { border-left-color: #1f9d55; }
.ann-card.cat-delist { border-left-color: #e23b3b; }
.ann-card.cat-general { border-left-color: #3b82f6; }
.ann-card.ann-out { animation: anno .3s ease forwards; }
.ann-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ann-badge { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 4px; color: #fff; letter-spacing: .5px; }
.ann-card.cat-listing .ann-badge { background: #1f9d55; }
.ann-card.cat-delist .ann-badge { background: #e23b3b; }
.ann-card.cat-general .ann-badge { background: #3b82f6; }
.ann-ex { font-size: 13px; color: var(--text-2); font-weight: 700; }
.ann-time { margin-left: auto; font-size: 12px; color: var(--text-2); margin-right: 20px; }
.ann-close { position: absolute; top: 10px; right: 12px; border: none; background: transparent; color: var(--text-2); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px; }
.ann-close:hover { color: var(--text); }
.ann-title { font-weight: 700; font-size: 15px; line-height: 1.5; word-break: break-word; }
.ann-title-en { margin-top: 6px; color: var(--text-2); font-size: 12px; line-height: 1.45; word-break: break-word; }
.ann-link { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.ann-link:hover { text-decoration: underline; }
@keyframes anni { from { opacity: 0; transform: translateX(30px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes anno { to { opacity: 0; transform: translateX(30px); } }
body.logged-out #ann-box { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===================== 弹出层（筛选 / 主题） ===================== */
.popwrap { position: relative; }
.popover, .menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 12px; z-index: 80;
  display: none; min-width: 220px;
}
.popover.open, .menu.open { display: block; animation: ti .15s ease; }
.menu { min-width: 140px; padding: 6px; }
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text-2); padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 700;
}
.menu-item:hover { background: var(--bg); color: var(--accent); }
.pop-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--text); }
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pop-row label { font-size: 12px; color: var(--text-2); }
.pop-input { display: flex; align-items: center; gap: 4px; }
.pop-input input {
  width: 72px; padding: 5px 7px; font-size: 12px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--panel2); color: var(--text); outline: none; text-align: right; font-family: var(--mono);
}
.pop-input input:focus { border-color: var(--accent); }
.pop-unit { color: var(--muted); font-size: 11px; }
.pop-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; margin-bottom: 6px; user-select: none; }
.pop-check input { accent-color: var(--accent); cursor: pointer; }
.pop-check.inline { display: inline-flex; margin-bottom: 0; margin-left: 8px; }
.pop-check.inline:first-child { margin-left: 0; }
.pop-intervals { display: flex; align-items: center; flex-wrap: wrap; }
#filter-pop { min-width: 340px; }
#filter-pop .seg .sm-btn { padding: 4px 10px; font-size: 12px; }
.pop-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* 顶栏下拉面板（设置 / 提醒），与筛选弹层同款定位：顶栏正下方展开 */
.pop-panel {
  position: absolute; top: calc(100% + 8px);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); z-index: 80;
  display: none; overflow: hidden; max-height: calc(100vh - 80px);
}
.pop-panel.open { display: block; animation: ti .15s ease; }
#settings-modal { right: 0; width: min(560px, 94vw); }
#settings-modal .modal-body { min-height: 320px; max-height: calc(100vh - 220px); }
#alerts-pop { left: 0; right: auto; width: min(780px, 94vw); }
#alerts-pop .modal-body { max-height: calc(100vh - 150px); }
#alerts-pop .alert-grid { display: block; }
#msg-pop { left: 0; right: auto; width: min(620px, 94vw); }
#msg-pop .modal-body { max-height: calc(100vh - 150px); overflow-y: auto; }
#history-pop { left: 0; right: auto; width: min(640px, 94vw); }
#history-pop .modal-body { max-height: calc(100vh - 150px); overflow-y: auto; }
#history-pop .hist-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#history-pop .hist-actions .close { position: static; }
#history-list .log-item { margin-bottom: 0; }

/* ===================== 资金费 cell：费率 + 结算周期（上下两行，居中） ===================== */
.fund-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1.35; }
.fund-cell .chg-pill { font-size: 15px; font-weight: 800; padding: 3px 8px; }
.fund-fi { font-size: 11px; color: var(--muted); font-family: var(--mono); align-self: stretch; text-align: center; }

/* 指数差价卡：持仓 / 交易量 上下两栏（居中） */
.oi-vol-cell { padding-top: 5px !important; padding-bottom: 5px !important; }
.oi-vol-cell .oi-row, .oi-vol-cell .vol-row { display: flex; align-items: baseline; justify-content: flex-start; gap: 5px; line-height: 1.55; }
.oi-vol-cell .sub-label { font-size: 10.5px; color: var(--muted); font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif; }
.oi-vol-cell .sub-val { font-family: var(--mono); font-size: 15px; color: var(--text); font-weight: 800; }
.oi-vol-cell .vol-row .sub-val { color: var(--text-2); }

/* ===================== 股票 / 股权代币徽标 ===================== */
/* 股票 / 股权代币角标（币种右上） */
.coin-link { position: relative; }
.stock-badge {
  position: absolute; right: -25px; top: 0;
  transform: translateY(-2px);
  font: 700 10px/1 "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif;
  color: #fff; background: #2f6fd0;
  border-radius: 3px; padding: 1px 3px;
  letter-spacing: .02em; cursor: default; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}

/* 下架币红色角标（币种右下） */
.coin-link { position: relative; }
.delist-badge {
  position: absolute; right: -25px; top: 100%;
  transform: translateY(-4px);
  font: 700 10px/1 "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif;
  color: #fff; background: #e23b3b;
  border-radius: 3px; padding: 1px 3px;
  cursor: default; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}

/* ===================== 资金费五列：等宽、居中，适配 1/3 卡片宽度 ===================== */
.fund-col-h { width: 86px; }
.fund-col { width: 86px; }
table.tight th.fund-col-h, table.tight td.fund-col { padding-left: 4px; padding-right: 4px; }

/* ===================== 顶栏报警弹层 ===================== */
.notify-hint { font-size: 11px; color: var(--muted); margin-right: auto; line-height: 1.5; }
#alarm-pop .pop-check { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* 阈值输入（报警阈值）加大 */
.threshold { width: 64px; padding: 4px 6px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); border-radius: 4px; background: var(--panel); color: var(--text); outline: none; text-align: center; font-family: var(--mono); }



/* ===================== 登录遮罩 ===================== */
body.logged-out .topbar,
body.logged-out main.view,
body.logged-out #toasts { display: none !important; }
.login-mask {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 60%, #0b1220 100%);
}
.login-mask.show { display: flex; }
.login-box {
  width: 340px; max-width: 90vw; padding: 32px 28px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px; backdrop-filter: blur(8px);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 12px;
}
.login-brand { font-size: 20px; font-weight: 800; color: #fff; text-align: center; }
.login-sub { font-size: 12.5px; color: #cbd5e1; text-align: center; margin-bottom: 6px; line-height: 1.5; }
.login-box .ainput {
  padding: 11px 12px; font-size: 14px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff;
  outline: none;
}
.login-box .ainput::placeholder { color: #94a3b8; }
.login-box .ainput:focus { border-color: #38bdf8; background: rgba(56,189,248,.12); }
.login-err { color: #fca5a5; font-size: 12.5px; min-height: 16px; text-align: center; }
.login-later { margin-top: 6px; font-size: 12.5px; color: #93c5fd; text-align: center; cursor: pointer; text-decoration: underline; }
.login-later:hover { color: #bfdbfe; }

/* ===================== 顶栏用户区 ===================== */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 4px 3px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
}
.user-chip .user-name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; }
.user-chip .ctrl-btn.sm { padding: 3px 9px; font-size: 12px; }

/* ===================== 用户管理弹窗 ===================== */
#user-modal .arow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#user-modal .arow .ainput { flex: 1 1 120px; min-width: 110px; }
#um-add { flex: 0 0 auto; }
.um-hint { font-size: 11.5px; color: var(--muted); }
#users-table th, #users-table td { padding: 9px 10px; font-size: 13px; text-align: left; }
#users-table td.mono { font-family: var(--mono); color: var(--muted); font-size: 12px; }

/* ===================== 币种黑名单 ===================== */
.block-btn {
  border: none; background: transparent; cursor: pointer; font-size: 12px;
  line-height: 1; padding: 0 1px 0 4px; opacity: .35; transition: opacity .15s;
}
.block-btn:hover { opacity: 1; }
.bl-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; max-height: 280px; overflow: auto; }
.bl-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--chip, #f3f4f6); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 5px 4px 12px; font-size: 13px; color: var(--text);
}
.bl-x {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 12px; line-height: 1; padding: 2px; border-radius: 999px;
}
.bl-x:hover { color: var(--danger, #ef4444); background: rgba(239,68,68,.12); }
.bl-foot { margin-top: 12px; color: var(--muted); font-size: 13px; }
.bl-foot b { color: var(--text); }

/* ===================== 设置弹窗 ===================== */
.settings-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px;
}
.stab {
  border: none; background: transparent; cursor: pointer;
  padding: 10px 20px; font-size: 14px; font-weight: 700;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.stab:hover { color: var(--text-2); }
.stab.active { color: var(--accent); border-bottom-color: var(--accent); }
.stab-panel { display: none; }
.stab-panel.active { display: block; }
.sm-account-info { font-size: 14px; }

/* ===================== 手机自适应 ===================== */
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .brand-title { font-size: 14.5px; }
  .top-tabs { flex-wrap: wrap; gap: 2px; }
  .top-tab { padding: 6px 9px; font-size: 13px; }
  .controls { flex: 1 1 100%; order: 5; gap: 5px; }
  .search-wrap { flex: 1 1 100%; max-width: none; order: 6; }
  .ctrl-btn { padding: 5px 8px; font-size: 12.5px; }
  .ctrl-divider { display: none; }
  .clock { margin-left: auto; }
  main.view { padding: 10px; }
  .cards-row { gap: 10px; }
  .card { padding: 10px 10px 6px; }
  .card-head { padding-bottom: 8px; }
  table.grid th, table.grid td { padding: 8px 5px; font-size: 12.5px; }
  table.grid td.num { font-size: 13px; }
  .brand-icon { font-size: 16px; }
}
