:root {
  --bg: #0b100e;
  --panel: #121915;
  --panel-2: #17211b;
  --line: #29372f;
  --text: #eef5f0;
  --muted: #9aaba1;
  --subtle: #6f8177;
  --accent: #19d3a2;
  --up: #f06468;
  --down: #18c993;
  --warn: #f2a640;
  --blue: #55a6ff;
  --cyan: #32c6d4;
  --violet: #a98df5;
  --yellow: #f2d16b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: radial-gradient(circle at 80% -10%, rgba(25,211,162,.07), transparent 32%), var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; }
button { font: inherit; }
.app-shell { max-width: 1880px; margin: 0 auto; padding: 22px 24px 30px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 4px 0 0; font-size: 25px; line-height: 1.2; }
.brand p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.asof { white-space: nowrap; }
.asof strong { color: var(--text); }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(242,166,64,.1); }
.segment { display: inline-flex; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
button { min-height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--panel-2); color: var(--muted); cursor: pointer; font-weight: 700; }
button:hover:not(:disabled) { border-color: #426052; color: var(--text); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .35; }
.segment button { min-width: 62px; border: 0; border-right: 1px solid var(--line); border-radius: 0; }
.segment button:last-child { border-right: 0; }
.segment button.active, button.primary { background: var(--accent); color: #06251b; border-color: var(--accent); }

.data-strip { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(18,25,21,.8); }
.strip-label { color: var(--text); font-size: 12px; font-weight: 800; white-space: nowrap; }
.method-note { margin-left: auto; color: var(--subtle); font-size: 11px; }
.tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { max-width: 360px; border: 1px solid rgba(255,255,255,.09); border-radius: 999px; padding: 4px 8px; color: var(--muted); background: rgba(255,255,255,.035); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag.good { color: var(--accent); border-color: rgba(25,211,162,.3); background: rgba(25,211,162,.07); }
.tag.warn { color: var(--warn); border-color: rgba(242,166,64,.32); background: rgba(242,166,64,.07); }
.tag.bad, .tag.market-up { color: var(--up); border-color: rgba(240,100,104,.32); background: rgba(240,100,104,.07); }
.tag.market-down { color: var(--down); border-color: rgba(24,201,147,.3); background: rgba(24,201,147,.07); }

.layer-nav { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin: 0 0 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.layer-nav a { padding: 10px 8px; background: rgba(18,25,21,.98); color: var(--muted); font-size: 11px; font-weight: 800; text-align: center; text-decoration: none; }
.layer-nav a:hover, .layer-nav a:focus-visible { color: var(--accent); background: #17221c; outline: none; }
.layer-overview { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.layer-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(145deg, rgba(23,33,27,.94), rgba(18,25,21,.94)); }
.layer-card .layer-number { color: var(--subtle); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.layer-card strong { display: block; margin: 6px 0 8px; font-size: 14px; }
.layer-card p { min-height: 32px; margin: 0 0 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.coverage-bar { height: 5px; overflow: hidden; border-radius: 999px; background: #253128; }
.coverage-bar i { display: block; height: 100%; background: var(--accent); }
.layer-card small { display: block; margin-top: 7px; color: var(--subtle); font-size: 10px; }
.analysis-layer { scroll-margin-top: 58px; margin: 0 0 28px; }
.layer-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 2px 10px; padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.layer-heading > div:first-child > span { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.layer-heading h2 { margin: 3px 0 0; font-size: 20px; }
.layer-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.gap-panel { background: linear-gradient(145deg, rgba(18,25,21,.94), rgba(16,22,19,.94)); }
.gap-body { display: grid; gap: 9px; min-height: 130px; padding: 14px; border-top: 1px solid var(--line); }
.gap-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 0; }
.gap-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.component-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.018); }
.component-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.component-top strong { font-size: 13px; }
.status-pill { border-radius: 999px; padding: 3px 7px; font-size: 9px; font-weight: 900; white-space: nowrap; }
.status-pill.ready { color: var(--accent); background: rgba(25,211,162,.1); }
.status-pill.stale, .status-pill.partial { color: var(--warn); background: rgba(242,166,64,.1); }
.status-pill.missing { color: var(--subtle); background: rgba(111,129,119,.12); }
.component-card p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.component-card small { display: block; margin-top: 7px; color: var(--subtle); font-size: 10px; }
.event-feed-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 0 14px 14px; }
.event-group { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.015); }
.event-group h3 { margin: 0; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.event-list { max-height: 310px; overflow: auto; }
.event-group.major-announcements { grid-column: 1 / -1; }
.major-announcements .event-list { max-height: 640px; }
.announcement-row { display: block; }
.announcement-row strong { white-space: normal; overflow: visible; line-height: 1.55; }
.announcement-row small { white-space: normal; overflow: visible; line-height: 1.45; }
.event-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 9px 12px; border-bottom: 1px solid rgba(41,55,47,.65); }
.event-row:last-child { border-bottom: 0; }
.event-row strong { display: block; overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.event-row small { display: block; margin-top: 3px; color: var(--subtle); font-size: 9px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.event-value { color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: repeat(9, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric { min-width: 0; min-height: 92px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(145deg, rgba(23,33,27,.94), rgba(18,25,21,.94)); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: 21px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { display: block; margin-top: 6px; color: var(--subtle); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.good-value { color: var(--accent) !important; }
.warn-value { color: var(--warn) !important; }
.bad-value { color: var(--up) !important; }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }

.dashboard-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: rgba(18,25,21,.94); }
.full { grid-column: 1 / -1; }
.half { grid-column: span 3; }
.third, .one-third { grid-column: span 2; }
.two-thirds { grid-column: span 4; }
.panel-head { min-height: 62px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 14px 15px 9px; }
.panel-head h2 { margin: 0; font-size: 15px; line-height: 1.3; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.panel-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.chart { height: 350px; }
.chart-sm { height: 310px; }
.chart-lg { height: 520px; }
.decision-body { min-height: 132px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: center; padding: 18px; border-top: 1px solid var(--line); }
.score-num { font-size: 54px; font-weight: 900; line-height: .95; }
.score-status { margin-top: 10px; font-size: 15px; font-weight: 800; }
.score-copy { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dimension-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.bar-row { display: grid; grid-template-columns: 92px minmax(80px, 1fr) 62px; gap: 9px; align-items: center; margin: 8px 0; color: var(--muted); font-size: 12px; }
.bar { height: 8px; overflow: hidden; border-radius: 999px; background: #253128; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #12ad83, var(--accent)); }
.bar-row b { color: var(--text); text-align: right; }
.stale-mark { color: var(--warn); }
.controls { display: flex; gap: 6px; flex-wrap: wrap; }
.controls button { min-height: 28px; padding: 0 9px; font-size: 11px; }
.controls button.active { color: var(--accent); border-color: var(--accent); background: rgba(25,211,162,.08); }

.table-wrap { min-height: 280px; max-height: 430px; overflow: auto; padding: 0 14px 14px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: var(--panel); font-weight: 700; }
.stock-name { color: var(--text); font-weight: 700; }
.stock-code { margin-left: 5px; color: var(--subtle); font-size: 10px; }
.basis { color: var(--subtle); }
.empty { min-height: 250px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.risk-box { display: grid; gap: 12px; padding: 18px; border-top: 1px solid var(--line); }
.risk-level { font-size: 38px; font-weight: 900; }
.risk-score { margin-top: 5px; color: var(--muted); font-size: 12px; }
.risk-list { display: grid; gap: 8px; }
.risk-item { padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: rgba(255,255,255,.02); font-size: 12px; line-height: 1.45; }
footer { margin-top: 16px; padding: 12px 2px 0; color: var(--subtle); font-size: 11px; line-height: 1.6; }
footer strong { color: var(--muted); }
.toast { position: fixed; top: 16px; left: 50%; z-index: 50; transform: translateX(-50%) translateY(-10px); opacity: 0; pointer-events: none; transition: .18s ease; padding: 9px 16px; border-radius: 999px; background: var(--accent); color: #06251b; font-size: 13px; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.error { background: var(--up); color: #fff; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1440px) {
  .metrics { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
  .layer-overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .third { grid-column: span 2; }
  .chart-sm { height: 290px; }
}
@media (max-width: 1050px) {
  .app-shell { padding: 18px 16px 26px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .toolbar { justify-content: flex-start; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .full, .half, .third, .two-thirds, .one-third { grid-column: 1 / -1; }
  .data-strip { align-items: flex-start; flex-wrap: wrap; }
  .method-note { width: 100%; margin-left: 0; }
  .layer-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); position: static; }
  .gap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-feed-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .app-shell { padding: 14px 10px 22px; }
  h1 { font-size: 21px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 86px; }
  .toolbar { width: 100%; }
  .segment { order: 3; width: 100%; }
  .segment button { min-width: 0; flex: 1; }
  .decision-body { grid-template-columns: 1fr; }
  .dimension-grid { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; }
  .panel-actions, .tags { justify-content: flex-start; }
  .layer-overview, .gap-grid, .gap-grid.compact { grid-template-columns: 1fr; }
  .layer-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layer-heading { align-items: flex-start; flex-direction: column; }
  .chart, .chart-lg { height: 330px; }
  .chart-sm { height: 280px; }
}
