/* ============================================================
   EarlySignal · 新版前端样式（v2）
   设计原则（与后端逻辑对齐，不是纯视觉改造）：
     1) 移动优先：底部 Tab + 单列；≥900px 自动变成左侧导航 + 内容双栏。
     2) 证据分级：一条情报分三层 —— 结论行 / 证据条 / 展开详情。
        旧版把 14 个徽标平铺在一行，手机上直接被淹没；这里默认只给结论，
        证据收进第二层，细节收进第三层。
     3) 方向色沿用 A 股口径：红 = 受益/利好，绿 = 受损/利空。
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #080b12;
  --panel: #111826;
  --panel2: #0d1420;
  --panel3: #0a0f18;
  --line: #1e2b3f;
  --line2: #16223380;
  --txt: #dbe6f5;
  --dim: #7b8ca6;
  --faint: #55647d;
  --up: #ff5c7c;      /* 涨 / 受益 / 利好 */
  --down: #00e0a4;    /* 跌 / 受损 / 利空 */
  --blue: #4a9eff;
  --purple: #a78bfa;
  --orange: #ffab4a;
  --code: #0a0f18;

  --r: 10px;
  --nav-h: 58px;
  --top-h: 52px;
}

html, body { height: 100%; }
body {
  background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.65; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h); display: flex; align-items: center; gap: 8px;
  padding: 0 10px; padding-top: env(safe-area-inset-top);
  background: rgba(8,11,18,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tb-brand { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.tb-logo { font-size: 16px; }
.tb-search { position: relative; flex: 1; min-width: 0; }
.tb-search input {
  width: 100%; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); padding: 0 10px; outline: none;
}
.tb-search input:focus { border-color: var(--green, #00e0a4); border-color: var(--blue); }
.tb-drop {
  position: absolute; top: 38px; left: 0; right: 0; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 32px #0009; z-index: 60;
}
.tb-drop .hit { padding: 9px 11px; border-bottom: 1px solid var(--line2); cursor: pointer; }
.tb-drop .hit:last-child { border-bottom: 0; }
.tb-drop .hit:hover { background: #ffffff0a; }
.tb-drop .hit small { color: var(--dim); display: block; font-size: 11px; }
.tb-status {
  font-size: 11px; color: var(--dim); white-space: nowrap; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--panel2);
}

/* 离线数据提示条（见 core.js 的 ES.flagOffline）。
   为什么需要：离线时界面照常渲染（特性），但用户会以为看到的是最新情报。
   放在内容区最上方、随内容走：不用 sticky/fixed —— 实测 sticky 浮起时会盖住页面标题，
   而"用户一进页面就能看见"这一点，靠它是每个视图顶部的第一个元素来保证。 */
.offline-bar {
  padding: 7px 12px; margin-bottom: 10px; text-align: center;
  font-size: 12px; line-height: 1.4;
  background: #b45309; color: #fff;
  border: 1px solid #92400e; border-radius: 8px;
}
.tb-btn {
  height: 34px; min-width: 34px; padding: 0 10px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
}
.tb-btn:hover { background: #ffffff0d; }
.tb-primary { background: linear-gradient(135deg, #00e0a4, #0088ff); color: #04120c; border: 0; font-weight: 700; }
.tb-more { position: relative; }

/* ---------------- 主体布局 ---------------- */
.body { display: flex; flex: 1; min-height: 0; align-items: flex-start; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(10,15,24,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--faint); text-decoration: none; transition: .15s;
}
.nav a .ni { font-size: 19px; line-height: 1; }
.nav a.on { color: var(--txt); }
.nav a.on .ni { filter: drop-shadow(0 0 8px #4a9eff88); }
/* 导航角标：产业网络上有多少待审候选关系（有方向冲突时转红 + ⚠）。
   用户要的是「提醒人工审」—— 不点进去也知道有活等着干。 */
.nav-badge {
  display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 9px;
  font-size: 10px; font-style: normal; line-height: 15px; font-weight: 700;
  background: #4a9eff26; color: var(--blue); border: 1px solid #4a9eff55; vertical-align: top;
}
.nav-badge.hot { background: #ffab4a26; color: var(--orange); border-color: #ffab4a77; }

.main {
  flex: 1; min-width: 0; width: 100%;
  padding: 12px 12px calc(var(--nav-h) + 26px);
}
.viewhead { margin-bottom: 10px; }
.viewhead h1 { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.viewhead p { font-size: 11.5px; color: var(--dim); }

/* ---------------- 视图内页签 ---------------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim); white-space: nowrap;
}
.chip.on { background: #4a9eff1f; border-color: #4a9eff66; color: var(--blue); font-weight: 600; }
.chip .cnt { opacity: .65; margin-left: 4px; font-size: 11px; }

/* ---------------- 标签说明 ---------------- */
.tips { margin: 4px 0 10px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--panel2); }
.tips summary { padding: 7px 11px; font-size: 12px; color: var(--dim); cursor: pointer; }
.tips-body { padding: 0 11px 11px; }
.tips-body dl { margin: 0; }
.tips-body dt { font-size: 12px; font-weight: 700; margin-top: 8px; }
.tips-body dd { font-size: 12px; color: var(--dim); margin: 0; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 10px; overflow: hidden;
}
.card-h {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line2); font-size: 13px; font-weight: 700;
}
.card-h .sub { font-weight: 400; font-size: 11px; color: var(--dim); }
.card-h .sp { margin-left: auto; }
.card-b { padding: 10px 12px; }
.card-b.tight { padding: 0; }
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* 数字条 */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; cursor: pointer; }
.stat .n { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: 11px; color: var(--dim); }
.stat.p0 .n { color: var(--up); }
.stat.p1 .n { color: var(--orange); }
.stat.p2 .n { color: var(--dim); }
.stat:hover { border-color: #4a9eff66; }

/* ---------------- 情报卡（证据分级三层） ---------------- */
.sig { position: relative; display: flex; border-bottom: 1px solid var(--line2); }
.sig:last-child { border-bottom: 0; }
.sig > .bar { width: 3px; flex-shrink: 0; }
.sig.up > .bar { background: var(--up); }
.sig.down > .bar { background: var(--down); }
.sig.flat > .bar { background: #2a3a52; }
.sig-body { flex: 1; min-width: 0; padding: 10px 12px; }
.sig-l1 { display: flex; gap: 8px; align-items: flex-start; }
.sig-l1 .t { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.5; }
.sig-l1 .t.mut { color: var(--dim); font-weight: 400; }
.sig-l1 .sc { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sig-l2 { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
.sig-l3 { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.sig-act { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

/* 窄屏证据条降噪：低优先徽标（信源 / 抽取方式 / 第 2 个以后的公司与主题）
   默认收起，点「展开证据」后一并放出。
   为什么不在 JS 里直接少渲染：桌面端这些信息一眼能扫完、有价值，
   真正的问题只是手机屏幕宽度 —— 所以用 CSS 按宽度分级，而不是砍掉数据。 */
@media (max-width: 620px) {
  .sig-l2 .bd.extra { display: none; }
  .sig.open .sig-l2 .bd.extra { display: inline-block; }
}

/* 徽标 */
.bd {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px; white-space: nowrap;
  background: #ffffff0d; border: 1px solid var(--line); color: var(--dim);
}
.bd.t-up { color: var(--up); border-color: #ff5c7c44; background: #ff5c7c14; }
.bd.t-down { color: var(--down); border-color: #00e0a444; background: #00e0a414; }
.bd.t-blue { color: var(--blue); border-color: #4a9eff44; background: #4a9eff14; }
.bd.t-purple { color: var(--purple); border-color: #a78bfa44; background: #a78bfa14; }
.bd.t-orange { color: var(--orange); border-color: #ffab4a44; background: #ffab4a14; }
.bd.t-hot { color: var(--up); border-color: #ff5c7c66; background: #ff5c7c1f; font-weight: 700; }
.bd.t-warn { color: var(--orange); border-color: #ffab4a66; }
.bd.t-mut { color: var(--faint); }

/* 可点小按钮 */
.mini {
  font-size: 11px; padding: 2px 8px; border-radius: 6px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
}
.mini:hover { color: var(--txt); border-color: #4a9eff66; }
.mini.on { color: var(--blue); border-color: #4a9eff66; background: #4a9eff1a; }
.mini.star { color: var(--orange); border-color: #ffab4a55; }

/* ---------------- 表格 ---------------- */
.tw { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th, table.tbl td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line2); white-space: nowrap; }
table.tbl th { color: var(--dim); font-weight: 600; font-size: 11px; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.num { font-variant-numeric: tabular-nums; }
.t-up { color: var(--up); } .t-down { color: var(--down); } .t-dim { color: var(--dim); }

/* ---------------- 传导链 ---------------- */
.chain { padding: 9px 12px; border-bottom: 1px solid var(--line2); }
.chain:last-child { border-bottom: 0; }
.chain .hops { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; margin-top: 5px; }
.hop { display: flex; align-items: center; gap: 4px; }
.hop .ar { color: var(--faint); }
.hop b { font-weight: 600; }

/* ---------------- 表单 ---------------- */
.fld { display: block; margin-bottom: 10px; }
.fld > span { display: block; font-size: 11.5px; color: var(--dim); margin-bottom: 3px; }
.fld small { color: var(--faint); font-weight: 400; }
.fld input, .fld select, .fld textarea {
  width: 100%; min-height: 34px; padding: 6px 9px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line); outline: none;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--blue); }
.btn {
  height: 34px; padding: 0 13px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
}
.btn:hover { background: #ffffff0d; }
.btn.primary { background: linear-gradient(135deg, #00e0a4, #0088ff); color: #04120c; border: 0; font-weight: 700; }
.btn.block { width: 100%; }
.btn.danger { color: var(--up); border-color: #ff5c7c55; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- 抽屉 / 弹窗 / 提示 ---------------- */
.scrim { position: fixed; inset: 0; background: #000a; z-index: 70; }
.drawer {
  position: fixed; z-index: 80; right: 0; top: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--panel3); border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.drawer-head b { flex: 1; font-size: 13px; }
.drawer-body { flex: 1; overflow: auto; padding: 12px; }
@media (max-width: 560px) {
  .drawer { top: auto; left: 0; width: 100vw; height: 86vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; }
}
.mask { position: fixed; inset: 0; background: #000b; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.modal-head b { flex: 1; font-size: 13px; }
.modal-body { padding: 12px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px); transform: translate(-50%, 12px);
  z-index: 120; background: #1b2436; border: 1px solid var(--line); color: var(--txt);
  padding: 8px 15px; border-radius: 20px; font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: .22s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 标签说明浮层：只读不挡点击 */
.tippop {
  position: fixed; z-index: 130; max-width: 300px; background: #1b2436; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--txt);
  box-shadow: 0 12px 30px #000a; pointer-events: none;
}
.tippop b { display: block; font-size: 12px; margin-bottom: 2px; color: var(--blue); }
.tippop span { color: var(--dim); }
[data-tip] { cursor: help; border-bottom: 1px dotted #ffffff30; }

/* ---------------- 通用零碎 ---------------- */
.empty { padding: 22px 12px; text-align: center; color: var(--faint); font-size: 12.5px; }
.empty b { display: block; color: var(--dim); font-size: 13px; margin-bottom: 4px; }
.skel { height: 46px; border-radius: 8px; background: linear-gradient(90deg, #ffffff08, #ffffff14, #ffffff08); background-size: 200% 100%; animation: sk 1.2s linear infinite; margin-bottom: 8px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 10px; font-size: 12.5px; }
.kv dt { color: var(--dim); }
.kv dd { word-break: break-word; }
.mut { color: var(--dim); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.bar-lite { height: 5px; border-radius: 3px; background: #ffffff12; overflow: hidden; }
.bar-lite > i { display: block; height: 100%; background: linear-gradient(90deg, #00e0a4, #0088ff); }
hr.sep { border: 0; border-top: 1px solid var(--line2); margin: 9px 0; }
.tagline { font-size: 11px; color: var(--faint); margin-top: 5px; }

/* ---------------- 登录 ---------------- */
.login { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 18px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.login-logo { font-size: 16px; font-weight: 700; }
.login-logo small { font-size: 11px; color: var(--dim); font-weight: 400; }
.login-sub { font-size: 12px; color: var(--dim); margin: 6px 0 14px; }
.login input { width: 100%; height: 38px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); padding: 0 11px; outline: none; margin-bottom: 10px; }
.login-err { color: var(--up); font-size: 12px; margin-top: 9px; min-height: 16px; }

/* ---------------- 桌面端：换左侧导航 ---------------- */
@media (min-width: 900px) {
  .nav {
    position: sticky; top: var(--top-h); left: auto; right: auto; bottom: auto;
    height: calc(100vh - var(--top-h)); width: 176px; flex-direction: column; padding: 10px;
    border-top: 0; border-right: 1px solid var(--line); background: var(--panel3); backdrop-filter: none;
    gap: 2px;
  }
  .nav a {
    flex: 0 0 auto; width: 100%; flex-direction: row; justify-content: flex-start;
    gap: 10px; font-size: 13px; padding: 9px 11px; border-radius: 8px;
  }
  .nav a .ni { font-size: 15px; }
  .nav a.on { background: #4a9eff1f; }
  .main { padding: 14px 16px 40px; max-width: 1180px; }
  .viewhead h1 { font-size: 21px; }
  .toast { bottom: 26px; }
}
@media (min-width: 1280px) { .main { max-width: 1320px; } }
