:root {
  --bg: #f6f4f0; --card: #ffffff; --line: #e6e2db; --line-strong: #cfc9bf;
  --ink: #1b1a18; --ink-2: #5c5953; --ink-3: #8c8880;
  --accent: #e4560f; --accent-soft: #fdebdf; --accent-ink: #9a3a08;
  --up: #1b7f4b; --down: #c0392b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --r: 12px;
  --font: -apple-system, "PingFang SC", "Helvetica Neue", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px 48px; }

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 28px 0 16px; flex-wrap: wrap; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: .01em; }
.meta { color: var(--ink-3); font-size: 13px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover { color: var(--ink); }

.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; z-index: 5; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lbl { color: var(--ink-3); font-size: 12px; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg button:focus-visible, .chip:focus-visible, .sel:focus-visible, .link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sel { border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 28px 6px 10px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238c8880' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center; color: var(--ink); appearance: none; -webkit-appearance: none; cursor: pointer; }
.divider { width: 1px; height: 20px; background: var(--line); flex: none; }
.custom-range { display: inline-flex; gap: 8px; align-items: center; }
.custom-range[hidden] { display: none; }
.entities { display: contents; }
.quick, .chips { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; line-height: 1.4; }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #999); flex: none; }
.chip .dot.dash { border-radius: 2px; height: 4px; }
.chip.ghost { border-style: dashed; color: var(--ink-3); }
.chip.ghost:hover { color: var(--ink); }
.toggle-entities { display: none; }

.notice { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; background: #fff8e6; border: 1px solid #f3dca0; color: #7a5a00; font-size: 13px; }
.notice.error { background: #fdecea; border-color: #f3b6ad; color: #8a2518; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.kpi .t { color: var(--ink-3); font-size: 12px; }
.kpi .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 4px 0 2px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.kpi .s { color: var(--ink-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.card .sub { color: var(--ink-3); font-size: 12px; margin-bottom: 12px; min-height: 18px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .empty { color: var(--ink-3); padding: 48px 0; text-align: center; }
.axis { font-size: 11px; fill: var(--ink-3); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series.dash { stroke-dasharray: 6 4; }
.end-label { font-size: 12px; fill: var(--ink-2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 2px; background: var(--c); vertical-align: middle; margin-right: 5px; border-radius: 1px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.tip { position: fixed; background: #1b1a18; color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 8px; pointer-events: none; white-space: nowrap; line-height: 1.6; z-index: 20; max-width: 260px; }
.tip .m { color: #c3c2b7; }
.tip .d { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.rank { display: flex; flex-direction: column; gap: 10px; }
.rk { display: grid; grid-template-columns: 18px minmax(56px, auto) 1fr 72px 56px; gap: 8px; align-items: center; font-size: 13px; }
.rk .n { color: var(--ink-3); font-size: 12px; }
.rk .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.rk .bar i { display: block; height: 100%; border-radius: 3px; background: var(--c); }
.rk .val { text-align: right; font-variant-numeric: tabular-nums; }
.rk .pct { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--ink-3); }

.table-card { margin-top: 12px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
td.muted { color: var(--ink-3); }
.details { margin-top: 12px; }
.details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; list-style: none; }
.details summary::-webkit-details-marker { display: none; }
.details summary::before { content: "▸ "; }
.details[open] summary::before { content: "▾ "; }
.details table { margin-top: 10px; }
.details th:first-child, .details td:first-child { position: sticky; left: 0; background: var(--card); }

.foot { color: var(--ink-3); font-size: 12px; margin-top: 24px; display: flex; gap: 16px; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; background: rgba(27, 26, 24, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; }
.modal[hidden] { display: none; }
.modal .box { background: #fff; border-radius: 14px; max-width: 560px; width: 100%; padding: 20px 24px 22px; font-size: 14px; max-height: 90vh; overflow: auto; }
.box-head { display: flex; justify-content: space-between; align-items: center; }
.modal h3 { margin: 0; font-size: 16px; }
.close { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 4px 6px; }
.modal dl { margin: 6px 0 0; }
.modal dt { font-weight: 600; margin-top: 12px; }
.modal dd { margin: 2px 0 0; color: var(--ink-2); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .filters { position: static; }
  .row > .lbl { width: 100%; }
  .custom-range .lbl { width: auto; }
  .divider { display: none; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px 32px; }
  .top { padding-top: 20px; }
  .kpi .v { font-size: 22px; }
  .rk { grid-template-columns: 18px 44px 1fr 64px 48px; }
  .toggle-entities { display: inline-flex; }
  .row-entities > .lbl { width: auto; }
  .entities { display: none; width: 100%; flex-direction: column; gap: 8px; }
  .entities.open { display: flex; }
}
@media (prefers-reduced-motion: no-preference) {
  .rk .bar i { transition: width .25s ease; }
}
