:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #17223a;
  --ink-2: #3d4a63;
  --muted: #7a869e;
  --line: #e2e8f2;
  --line-strong: #cfd8e8;
  --navy: #101c31;
  --navy-2: #1b2c4a;
  --accent: #2759c9;
  --accent-soft: #eaf0ff;
  --gold: #a86b12;
  --gold-soft: #fff5e3;
  --green: #17845c;
  --green-soft: #e7f6ef;
  --red: #c0392b;
  --red-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 28, 49, .04), 0 8px 24px rgba(16, 28, 49, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* ---------- top bar ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3a6ee6, #1b3f96);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: .5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.brand-text p { margin: 1px 0 0; font-size: 11px; color: #97a8c7; letter-spacing: 1px; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.asof { font-size: 11px; color: #8fa1c2; white-space: nowrap; }
.sync-badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  padding: 5px 10px; border-radius: 99px; white-space: nowrap;
}
.sync-badge i { width: 7px; height: 7px; border-radius: 50%; background: #eab308; display: block; }
.sync-badge.online i { background: #35d399; }
.sync-badge.offline i { background: #f87171; }
.sync-badge span { color: #dbe5f6; }

/* ---------- tabs ---------- */
.tabs {
  position: sticky; top: 62px; z-index: 20; background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; gap: 2px; padding: 0 20px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; padding: 13px 16px 11px; white-space: nowrap;
  color: var(--muted); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px;
}
.tab.active .count { background: var(--accent-soft); border-color: #cddcff; color: var(--accent); }
.tab.home-tab { font-weight: 700; }

/* ---------- layout ---------- */
.view { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.section { margin-bottom: 24px; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 12px;
}
.section-head h2 { margin: 0; font-size: 18px; font-weight: 750; letter-spacing: .2px; }
.section-head .sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e49aa; color: #fff; }
.btn.ghost { background: transparent; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi { padding: 15px 16px; }
.kpi .label { font-size: 11px; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.kpi .value { font-size: 26px; font-weight: 750; margin-top: 4px; letter-spacing: -.5px; }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi.hl { border-color: #c9d8ff; background: linear-gradient(180deg, #f7faff, #fff); }
.kpi.hl .value { color: var(--accent); }

/* ---------- analyst hero ---------- */
.hero {
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  color: #fff; border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.hero { overflow: hidden; }
.hero > div:first-child { flex: 1 1 340px; min-width: 0; max-width: 100%; }
.hero h2 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: .3px; overflow-wrap: anywhere; }
.hero .en { color: #9fb2d4; font-size: 12px; margin-left: 8px; font-weight: 500; }
.hero p { margin: 5px 0 0; font-size: 12px; color: #a9bbda; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.hero .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.hero .chip {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
  color: #e5edfb; padding: 3px 9px; border-radius: 99px; font-size: 11px;
}
.hero-stat { text-align: right; }
.hero-stat .n { font-size: 32px; font-weight: 800; line-height: 1; }
.hero-stat .t { font-size: 11px; color: #9fb2d4; margin-top: 5px; }
.hero-stat .sel { font-size: 12px; color: #7ee2b8; margin-top: 8px; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 14px;
}
.search {
  flex: 1 1 220px; min-width: 180px; position: relative;
}
.search input {
  width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface-2); outline: none; font-size: 13px;
}
.search input:focus { border-color: var(--accent); background: #fff; }
.search::before {
  content: ""; position: absolute; left: 11px; top: 12px; width: 12px; height: 12px;
  border: 1.6px solid var(--muted); border-radius: 50%;
}
.search::after {
  content: ""; position: absolute; left: 21px; top: 22px; width: 6px; height: 1.6px;
  background: var(--muted); transform: rotate(45deg);
}
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: var(--surface); padding: 7px 11px; font-size: 12px;
  color: var(--muted); font-weight: 600; border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------- stock list ---------- */
.sector-group { margin-bottom: 16px; overflow: hidden; }
.group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 15px; background: linear-gradient(90deg, #f0f4fc, #f8faff);
  border-bottom: 1px solid var(--line);
}
.group-head .name { font-weight: 750; font-size: 13px; color: var(--navy-2); }
.group-head .name small { font-weight: 500; color: var(--muted); margin-left: 8px; font-size: 11px; }
.group-head .n { font-size: 11px; color: var(--muted); }

.stock-row {
  display: grid; grid-template-columns: 54px minmax(0,1fr) 108px;
  gap: 12px; align-items: center; padding: 10px 15px; border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.stock-row:last-child { border-bottom: 0; }
.stock-row:hover { background: #fafcff; }
.stock-row.selected { background: #f5f9ff; }
.stock-row .c-toggle { display: flex; justify-content: center; }
.stock-row .c-company { min-width: 0; }
.stock-row .c-cap { text-align: right; }
.stock-row .c-cap b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stock-row .c-cap small { display: block; font-size: 10px; color: var(--muted); }
.stock-row .c-side { text-align: right; }

.toggle {
  width: 40px; height: 23px; border-radius: 99px; border: 1px solid var(--line-strong);
  background: #e6ebf4; position: relative; padding: 0; transition: background .16s, border-color .16s;
  flex: 0 0 auto;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .16s;
}
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.toggle[aria-pressed="true"]::after { transform: translateX(17px); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cn { font-size: 14px; font-weight: 700; color: var(--ink); }
.cn .full { font-size: 10px; font-weight: 400; color: var(--muted); margin-left: 7px; }
.en { font-size: 12px; color: var(--ink-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
.chip { font-size: 10px; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.chip.sector { background: var(--accent-soft); border-color: #d3e0ff; color: var(--accent); font-weight: 650; }
.chip.sub { color: var(--muted); max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.chip.net { background: var(--gold-soft); border-color: #f2dcb4; color: var(--gold); }
.chip.inpool { background: var(--green-soft); border-color: #c7ebda; color: var(--green); }
.chip.exited { background: var(--red-soft); border-color: #f7cfca; color: var(--red); }
.chip.snapshot { background: #f1f3f7; color: var(--muted); }
.chip.who { background: #eef1fb; border-color: #dde3f7; color: #4055a8; font-weight: 650; }
.code { font-size: 10px; color: #98a3b8; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- overview ---------- */
.overview { width: 100%; border-collapse: collapse; font-size: 12px; }
.overview th, .overview td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.overview th { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--surface-2); }
.overview td.num, .overview th.num { text-align: right; font-variant-numeric: tabular-nums; }
.overview tr:last-child td { border-bottom: 0; }
.overview .bar { height: 5px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; min-width: 70px; }
.overview .bar > i { display: block; height: 100%; background: var(--accent); }
.overview-wrap { overflow-x: auto; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; opacity: .45; margin-bottom: 8px; }
.empty h3 { margin: 0 0 5px; font-size: 15px; color: var(--ink-2); }
.empty p { margin: 0; font-size: 12px; }

.note { font-size: 11px; color: var(--muted); line-height: 1.7; padding: 12px 15px; }
.note b { color: var(--ink-2); }

/* ---------- footer / toast ---------- */
.footer {
  max-width: 1320px; margin: 0 auto; padding: 18px 20px 34px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 10px; color: #9aa5b8; border-top: 1px solid var(--line);
}
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 9px;
  font-size: 12px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 60;
  box-shadow: 0 8px 30px rgba(0,0,0,.22); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .topbar { position: sticky; }
  .tabs { top: 62px; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 14px; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .brand-text h1 { font-size: 15px; }
  .asof { display: none; }
  .tabs { padding: 0 8px; top: 58px; }
  .tab { padding: 12px 12px 10px; font-size: 12px; }
  .view { padding: 16px 12px 44px; }
  .kpis { gap: 9px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 21px; }
  .hero { padding: 16px; }
  .hero > div:first-child { flex-basis: 100%; width: 100%; }
  .hero h2 { font-size: 19px; }
  .hero-stat { text-align: left; display: flex; align-items: baseline; gap: 12px; }
  .hero-stat .n { font-size: 26px; }
  .toolbar { padding: 10px; gap: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; }
  .search { grid-column: 1 / -1; }
  .toolbar .seg { grid-column: 1 / -1; justify-self: start; }
  .toolbar #scope { grid-column: 1 / -1; width: 100%; }
  .toolbar .check { grid-column: span 1; white-space: normal; }
  .chip.sub { max-width: 145px; }
  .list-head { display: none; }
  .stock-row { grid-template-columns: 46px minmax(0,1fr) 88px; gap: 9px; padding: 11px 12px; }
  .stock-row .c-cap b { font-size: 13px; }
  .cn { font-size: 13.5px; }
  .cn .full { display: none; }
  .en { font-size: 11px; }
  .toggle { width: 38px; height: 22px; }
  .toggle::after { width: 16px; height: 16px; }
  .toggle[aria-pressed="true"]::after { transform: translateX(16px); }
  .section-head h2 { font-size: 16px; }
  .footer { padding: 14px 12px 26px; }
}
