:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e6eaf0;
  --text: #1a2332;
  --muted: #8b95a8;
  --muted-2: #a8b0bf;
  --red: #e53935;
  --green: #43a047;
  --orange: #f57c00;
  --orange-soft: #fff4e5;
  --blue: #1e88e5;
  --blue-soft: #e8f3fc;
  --amber-banner: #fff8e6;
  --amber-border: #f0d78c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 35, 50, 0.04), 0 4px 12px rgba(26, 35, 50, 0.04);
  --max: 1200px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.banner {
  background: var(--amber-banner);
  border-bottom: 1px solid var(--amber-border);
  color: #8a6d1d;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 16px;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.topbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.module-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(245, 124, 0, 0.18);
}

.date-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}
.date-switch button {
  appearance: none;
  border: none;
  background: transparent;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}
.date-switch button:hover { background: #eef2f7; color: var(--text); }
.date-switch .date {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 10px;
  min-width: 110px;
  text-align: center;
}

.index-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.index-chip .label { color: var(--muted); font-size: 12px; }
.index-chip .val { font-weight: 600; }
.up { color: var(--red); }
.down { color: var(--green); }

.alert-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  cursor: pointer;
}
.switch {
  position: relative;
  width: 40px; height: 22px;
  background: #d5dbe6;
  border-radius: 999px;
  transition: background .2s;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform .2s;
}
.switch.on { background: var(--orange); }
.switch.on::after { transform: translateX(18px); }
.alert-toggle .state { color: var(--orange); font-weight: 600; font-size: 12px; }
.alert-toggle .state.off { color: var(--muted); }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  flex: 0 0 auto;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--orange);
}

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

.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}
.section-hd h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-src {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: #f0f3f8;
  border: 1px solid #e2e7ef;
  border-radius: 999px;
  padding: 1px 7px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.demo-mark {
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 400;
}
.section-bd { padding: 4px 0; }

.stock-list { list-style: none; margin: 0; padding: 0; }
.stock-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(100px, 0.8fr) minmax(90px, 0.7fr) minmax(110px, 0.9fr) minmax(80px, 0.6fr);
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #f0f3f7;
}
.stock-row:last-child { border-bottom: none; }
.stock-row:hover { background: #fafbfd; }

.stock-name {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.stock-code {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.theme-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--orange);
  background: var(--orange-soft);
  border: 1px solid rgba(245, 124, 0, 0.35);
  border-radius: 4px;
  padding: 0 6px;
  line-height: 18px;
}

.metric { font-variant-numeric: tabular-nums; }
.metric .label {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  margin-bottom: 2px;
}
.pct { font-weight: 600; }
.board {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 4px;
  padding: 0 6px;
  line-height: 18px;
}
.trigger {
  color: var(--orange);
  font-weight: 600;
  font-size: 13px;
}
.empty, .pending {
  color: var(--muted);
  font-weight: 500;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.dev-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
.dev-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}
.dev-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f3f7;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.dev-table tr:last-child td { border-bottom: none; }
.dev-table tr:hover td { background: #fafbfd; }

.dev-val {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--red);
}
.rule-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #5a6578;
  background: #eef1f6;
  border-radius: 6px;
  padding: 3px 8px;
}
.lookback { color: var(--muted); font-weight: 500; }
.space-val { font-weight: 600; color: var(--orange); }

.placeholder {
  background: var(--card);
  border: 1px dashed #cfd6e2;
  border-radius: var(--radius);
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
}
.placeholder strong {
  display: block;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
}

.footer-note {
  text-align: center;
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 20px;
  padding: 8px;
}

.error-box {
  background: #fff5f5;
  border: 1px solid #f5c2c2;
  color: #a33;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .stock-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
  }
  .stock-row .stock-name { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .wrap { padding: 12px 12px 40px; }
  .topbar { padding: 12px; }
  .stock-row {
    grid-template-columns: 1fr;
    padding: 14px 14px;
  }
  .section-hd { padding: 12px 14px; flex-wrap: wrap; }
}

.snapshot-info { padding: 14px 18px; margin-bottom: 14px; border: 1px solid #b7cee8; background: #e8f3fc; border-radius: 8px; color: #234a70; font-size: 14px; }
.index-chip { flex-wrap: wrap; }
.index-item { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 8px; }
.fallback-mark { background: #fff0cf; color: #9b3d00; border: 1px solid #e99b31; padding: 3px 8px; font-weight: 700; border-radius: 5px; }
.fallback-section { border: 2px solid #e99b31; }
#watch-placeholder { padding: 20px; text-align: left; }
#watch-note { display: block; margin-bottom: 16px; }

.dev-table th button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: 0; text-align: inherit; }
.space-rule { font-size: 12px; color: #7b8493; margin-top: 5px; }

.recent-filters { display: flex; gap: 8px; padding: 16px 18px 4px; flex-wrap: wrap; }
.recent-filters button { border: 1px solid var(--border); border-radius: 18px; background: #f5f6f8; color: var(--muted); padding: 7px 16px; cursor: pointer; font: inherit; font-size: 13px; }
.recent-filters button.active { color: var(--red); border-color: #f3babb; background: #fff0f0; font-weight: 600; }
.recent-note { margin: 8px 18px 12px; font-size: 12px; color: var(--muted); }
.stock-row.recent-row { grid-template-columns: minmax(140px, 1.4fr) minmax(85px, 1fr) minmax(135px, 1.3fr) minmax(85px, 1fr); }
.recent-row .metric { align-items: flex-start; }
.recent-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.recent-stock .stock-code { margin: 4px 0; }
.halt-status { color: var(--orange); font-weight: 600; }
@media (max-width: 640px) {
  .stock-row.recent-row { grid-template-columns: minmax(70px, 1.2fr) minmax(60px, .8fr) minmax(90px, 1.3fr) minmax(65px, .9fr); gap: 6px; padding: 14px 10px; font-size: 12px; }
  .recent-row .stock-name { font-size: 14px; }
}
