/* ===== 日本株データ — 设计系统 ===== */
:root {
  --bg: #0b0e14;
  --bg-soft: #11151f;
  --panel: #151a26;
  --panel-2: #1b2233;
  --border: #232c40;
  --border-soft: #1c2335;
  --text: #e8edf6;
  --text-dim: #9aa6bd;
  --text-mute: #6b7690;
  --accent: #e60012; /* 日本红 */
  --accent-2: #3b82f6;
  --up: #ff4d4f; /* 红涨 */
  --down: #16c784; /* 绿跌 */
  --flat: #9aa6bd;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --mono: 'SFMono-Regular', ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
    'Microsoft YaHei', 'PingFang SC', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(230, 0, 18, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(59, 130, 246, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* ---- 顶部导航 ---- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.brand small { color: var(--text-mute); font-weight: 600; font-size: 11px; letter-spacing: 1px; }
.nav-links { display: flex; gap: 4px; margin-left: 8px; }
.nav-links a {
  padding: 7px 13px; border-radius: 9px; color: var(--text-dim);
  font-size: 14px; font-weight: 600; transition: .15s;
}
.nav-links a:hover { color: var(--text); background: var(--panel); }
.nav-links a.active { color: #fff; background: var(--panel-2); }
.nav-spacer { flex: 1; }

/* 语言切换 */
.lang-switch { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.lang-switch a, .lang-switch button {
  padding: 5px 10px; background: transparent; border: 0; color: var(--text-dim);
  font-size: 13px; font-weight: 600; border-radius: 7px; cursor: pointer; transition: .12s; white-space: nowrap; text-decoration: none;
}
.lang-switch a:hover, .lang-switch button:hover { color: var(--text); }
.lang-switch a.active, .lang-switch button.active { background: var(--accent); color: #fff; }

/* 搜索框 */
.search { position: relative; width: 280px; max-width: 42vw; }
.search input {
  width: 100%; padding: 9px 14px 9px 36px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent-2); }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; display: none;
}
.search-results.show { display: block; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 14px; }
.search-results a:hover { background: var(--panel); }
.search-results .sym { font-weight: 700; }
.search-results .ex { color: var(--text-mute); font-size: 12px; align-self: center; }

/* ---- 布局 ---- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 22px; }
.hero { padding: 26px 0 8px; }
.hero h1 { font-size: 28px; margin: 0 0 6px; font-weight: 800; }
.hero p { color: var(--text-dim); margin: 0; font-size: 15px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 14px; font-size: 17px; font-weight: 700; }
.section-title .bar { width: 4px; height: 18px; background: var(--accent); border-radius: 2px; }
.section-title a.more { margin-left: auto; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.section-title a.more:hover { color: var(--text); }

/* 指数条 */
.indices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.idx {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.idx .nm { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.idx .px { font-size: 22px; font-weight: 800; margin: 6px 0 2px; }
.idx .ch { font-size: 13px; font-weight: 700; }
.idx .spark { position: absolute; right: 8px; bottom: 8px; opacity: .85; }

/* 卡片网格 */
.grid { display: grid; gap: 14px; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.panel-head { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-head .tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--panel-2); color: var(--text-dim); font-weight: 600; }

/* 排行表 */
.rank { width: 100%; border-collapse: collapse; }
.rank th, .rank td { text-align: right; padding: 9px 14px; font-size: 14px; }
.rank th { color: var(--text-mute); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border-soft); }
.rank th:first-child, .rank td:first-child { text-align: left; }
.rank tbody tr { border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: .12s; }
.rank tbody tr:last-child { border-bottom: 0; }
.rank tbody tr:hover { background: var(--panel-2); }
.rank .code { color: var(--text-mute); font-size: 12px; }
.rank .nm { font-weight: 600; }
.rank .pill { display: inline-block; min-width: 64px; text-align: center; padding: 3px 8px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.pill.up { background: rgba(255, 77, 79, 0.14); }
.pill.down { background: rgba(22, 199, 132, 0.14); }

/* 工具卡片 */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tool {
  display: block; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; transition: .15s;
}
.tool:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.tool .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--panel-2); margin-bottom: 12px; font-size: 20px; }
.tool h3 { margin: 0 0 4px; font-size: 16px; }
.tool p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* ---- 个股详情 ---- */
.stock-head { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin: 8px 0 18px; }
.stock-head .px { font-size: 40px; font-weight: 800; line-height: 1; }
.stock-head .meta h1 { margin: 0 0 4px; font-size: 24px; }
.stock-head .meta .sub { color: var(--text-dim); font-size: 14px; }
.stock-head .chbox { padding-bottom: 6px; }
.stock-head .chbox .ch { font-size: 18px; font-weight: 700; }

.range-tabs { display: flex; gap: 6px; }
.range-tabs button {
  padding: 6px 14px; background: var(--panel); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; transition: .12s;
}
.range-tabs button:hover { color: var(--text); }
.range-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-wrap { position: relative; width: 100%; height: 380px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.crosshair {
  position: absolute; pointer-events: none; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; display: none; box-shadow: var(--shadow); white-space: nowrap;
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat .k { color: var(--text-mute); font-size: 12px; }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 4px; }

/* ---- 选股器 ---- */
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.controls label { font-size: 13px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
.controls select, .controls input {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 7px 10px; font-size: 13px; outline: none;
}
.screener-table { width: 100%; border-collapse: collapse; }
.screener-table th, .screener-table td { padding: 10px 14px; font-size: 14px; text-align: right; }
.screener-table th:first-child, .screener-table td:first-child,
.screener-table th:nth-child(2), .screener-table td:nth-child(2) { text-align: left; }
.screener-table th { color: var(--text-mute); font-size: 12px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
.screener-table th:hover { color: var(--text); }
.screener-table tbody tr { border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.screener-table tbody tr:hover { background: var(--panel-2); }
.sector-tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--panel-2); color: var(--text-dim); }

/* ---- 杂项 ---- */
.loading { text-align: center; color: var(--text-mute); padding: 40px; font-size: 14px; }
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 8px; }
@keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.foot { text-align: center; color: var(--text-mute); font-size: 12px; padding: 40px 20px; border-top: 1px solid var(--border); margin-top: 50px; line-height: 1.8; }
.foot a { color: var(--text-dim); }
.badge-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.badge-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--down); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

@media (max-width: 900px) {
  .indices { grid-template-columns: repeat(2, 1fr); }
  .cols-3, .cols-2, .tools, .stats { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .search { width: 200px; }
  .stock-head .px { font-size: 32px; }
}
