:root {
  color-scheme: light;
  --blue: #1769e0;
  --blue-dark: #0f4eaf;
  --cyan: #18b6d9;
  --green: #24a36a;
  --red: #e5484d;
  --orange: #f59e0b;
  --ink: #182338;
  --muted: #6b778c;
  --line: #e4e9f1;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
.app-shell { min-height: 100vh; }

.topbar {
  height: 72px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #1976ed, #11a6db); font-weight: 800; }
.brand p, .section-heading p { margin: 0 0 3px; color: #7c8ba2; font-size: 11px; letter-spacing: .14em; }
.brand h1 { margin: 0; font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.version-switch { display: flex; padding: 3px; border: 1px solid var(--line); background: #f7f9fc; border-radius: 9px; }
.version-switch span, .version-switch a { min-width: 64px; padding: 7px 12px; border-radius: 7px; text-align: center; color: #64748b; text-decoration: none; font-size: 13px; }
.version-switch .active { color: #fff; background: var(--blue); box-shadow: 0 3px 8px rgba(23, 105, 224, .2); }
.user-badge { padding: 8px 12px; border-radius: 18px; color: #40506a; background: #f1f5fa; font-size: 13px; }

main { max-width: 1760px; margin: 0 auto; padding: 18px 24px 60px; }
.filter-card { min-height: 78px; display: grid; grid-template-columns: 120px 180px 230px 210px 160px 110px minmax(220px, 1fr); gap: 12px; align-items: end; padding: 15px 18px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 4px 16px rgba(33, 58, 97, .04); }
.filter-card label { display: grid; gap: 7px; color: #66758c; font-size: 12px; }
.category-filter-field { position: relative; display: grid; gap: 7px; color: #66758c; font-size: 12px; }
.category-filter { position: relative; }
.category-filter summary { height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 11px; border: 1px solid #d9e0eb; border-radius: 8px; color: #25334a; background: #fff; cursor: pointer; list-style: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-filter summary::-webkit-details-marker { display: none; }
.category-filter summary::after { content: ""; flex: 0 0 10px; width: 10px; height: 6px; margin-left: 8px; background: center / 10px 6px no-repeat 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='%23607189' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.category-filter[open] summary { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 224, .1); }
.category-options { position: absolute; z-index: 30; top: 44px; left: 0; width: 240px; padding: 8px; border: 1px solid #dce3ed; border-radius: 9px; background: #fff; box-shadow: 0 12px 30px rgba(31, 50, 82, .16); }
.category-option { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 5px 7px; border-radius: 6px; color: #34445d; cursor: pointer; }
.filter-card .category-option { display: flex; grid-template-columns: none; align-items: center; gap: 8px; height: 36px; min-height: 36px; padding: 5px 7px; }
.category-option:hover { background: #f2f7ff; }
.category-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.filter-card select, .filter-card input { width: 100%; height: 38px; border: 1px solid #d9e0eb; border-radius: 8px; background: #fff; color: #25334a; padding: 0 11px; outline: none; }
.filter-card select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-color: #fff; background-image: 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='%23607189' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 10px 6px; }
.filter-card .category-option input { flex: 0 0 16px; width: 16px; height: 16px; margin: 0; padding: 0; border: 1px solid #b9c4d3; border-radius: 3px; box-shadow: none; accent-color: var(--blue); }
.category-option span { flex: 1 1 auto; line-height: 20px; white-space: nowrap; }
.filter-card select:focus, .filter-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 224, .1); }
.filter-card select:disabled { color: #36465e; background: #f6f8fb; }
.primary-button { height: 38px; border: 0; border-radius: 8px; color: #fff; background: var(--blue); cursor: pointer; }
.primary-button:hover { background: var(--blue-dark); }
.source-note { align-self: stretch; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); padding-left: 18px; color: #66758c; font-size: 12px; }
.source-note strong { margin-bottom: 4px; color: #33445d; }

.page-tabs { display: flex; gap: 6px; margin: 14px 0 0; padding: 0 4px; }
.page-tabs a { padding: 9px 16px; border-radius: 8px; color: #637089; text-decoration: none; font-size: 13px; }
.page-tabs a:hover, .page-tabs a.active { color: var(--blue); background: #eaf2ff; }
.section-block { scroll-margin-top: 88px; margin-top: 16px; }
.section-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading > span, .coverage-badge { color: #6c7b91; font-size: 12px; }
.coverage-badge { padding: 6px 10px; border-radius: 15px; background: #edf5ff; color: #2664b5; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-card { position: relative; overflow: hidden; min-height: 126px; padding: 18px 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 5px 16px rgba(31, 57, 91, .04); }
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone, var(--blue)); }
.kpi-card .label { color: #66758c; font-size: 13px; }
.kpi-card .value { margin-top: 10px; color: #17253b; font-size: 27px; font-weight: 720; letter-spacing: -.02em; }
.kpi-card .value small { margin-left: 5px; color: #718096; font-size: 12px; font-weight: 500; }
.kpi-card .foot { display: flex; gap: 12px; margin-top: 9px; color: #8a97aa; font-size: 12px; }
.change.up { color: var(--red); }
.change.down { color: var(--green); }
.change.flat { color: #7b8798; }
.change.new { color: var(--orange); }

.chart-grid, .ranking-grid { display: grid; gap: 12px; margin-top: 12px; }
.chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ranking-grid { grid-template-columns: 1fr 1.4fr; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 5px 16px rgba(31, 57, 91, .04); }
.panel-heading { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 17px; border-bottom: 1px solid #edf0f5; }
.panel-heading h3 { margin: 0; font-size: 15px; }
.panel-heading p, .panel-heading > span { margin: 5px 0 0; color: #8a96a8; font-size: 11px; }
.chart { position: relative; min-height: 336px; padding: 10px 12px 8px; }
.chart-layout { display: grid; grid-template-columns: 54px minmax(0, 1fr) 48px; align-items: start; width: 100%; }
.chart-y-axis { width: 100%; height: 285px; display: block; overflow: visible; }
.chart-legend { position: absolute; z-index: 4; top: 18px; left: 76px; display: flex; align-items: center; gap: 18px; color: #607089; font-size: 10px; pointer-events: none; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-bar { width: 10px; height: 10px; border-radius: 2px; background: #4aa9ee; }
.legend-line { width: 18px; height: 0; border-top: 2px solid #f59e0b; }
.legend-line.yoy { border-color: #7c5ce6; border-top-style: dashed; }
.chart-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-gutter: stable; scrollbar-color: #aeb7c3 #e5e7eb; scrollbar-width: auto; outline: none; }
.chart-scroll:focus-visible { border-radius: 5px; box-shadow: 0 0 0 2px rgba(23, 105, 224, .18); }
.chart-scroll::-webkit-scrollbar { height: 14px; }
.chart-scroll::-webkit-scrollbar-track { border-radius: 7px; background: #e5e7eb; }
.chart-scroll::-webkit-scrollbar-thumb { min-width: 80px; border: 3px solid #e5e7eb; border-radius: 7px; background: #aeb7c3; }
.chart-scroll::-webkit-scrollbar-thumb:hover { background: #929daa; }
.chart-scroll svg { max-width: none; height: 285px; display: block; }
.chart-empty { min-height: 280px; display: grid; place-items: center; color: #8b97a9; }
.category-panel { margin-top: 12px; }
.category-usage-chart { display: grid; gap: 14px; padding: 18px 20px 22px; }
.category-usage-row { display: grid; grid-template-columns: 130px minmax(140px, 1fr) 130px 72px; align-items: center; gap: 14px; }
.category-usage-name { color: #34445d; font-size: 13px; font-weight: 650; }
.category-usage-track { height: 18px; overflow: hidden; border-radius: 5px; background: #edf2f8; }
.category-usage-bar { height: 100%; min-width: 0; border-radius: 5px; background: var(--category-color, #4aa9ee); transition: width .25s ease; }
.category-usage-value { color: #273a55; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.category-usage-share { color: #6f7d91; text-align: right; font-size: 12px; }

.ranking-list { padding: 12px 16px 16px; }
.ranking-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 43px; border-bottom: 1px solid #f0f2f6; }
.ranking-row:last-child { border-bottom: 0; }
.rank-no { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #58708f; background: #edf2f8; font-size: 11px; }
.ranking-row:nth-child(1) .rank-no { color: #fff; background: #ff6a3d; }
.ranking-row:nth-child(2) .rank-no { color: #fff; background: #ffad14; }
.ranking-row:nth-child(3) .rank-no { color: #fff; background: #2fb7d5; }
.rank-name { min-width: 0; color: #34445d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rank-value { color: var(--blue); font-size: 13px; font-weight: 650; }

.table-panel { overflow: hidden; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 1260px; border-collapse: collapse; }
th, td { padding: 12px 13px; border-bottom: 1px solid #edf0f4; text-align: right; white-space: nowrap; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; color: #617087; background: #f8fafc; font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: #f7faff; }
.name-cell { display: grid; gap: 3px; }
.name-cell strong { color: #283a54; }
.name-cell span { color: #8995a7; font-size: 11px; }
.metric-cell { color: #273a55; font-variant-numeric: tabular-nums; }
.metric-cell small { display: block; margin-top: 3px; color: #98a2b2; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 12px; font-size: 11px; }
.status.normal { color: #23805a; background: #e9f8f1; }
.status.no_bill { color: #66758a; background: #eef1f5; }
.status.usage_missing { color: #b66a00; background: #fff3da; }
.empty-row { padding: 32px; text-align: center !important; color: #8b96a8; }

.loading-mask { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 12px; color: #465873; background: rgba(246, 249, 253, .88); backdrop-filter: blur(2px); }
.loading-mask.hidden { display: none; }
.spinner { width: 25px; height: 25px; border: 3px solid #cfdef4; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: 420px; padding: 12px 16px; border-radius: 9px; color: #fff; background: #293950; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b72e35; }

@media (max-width: 1180px) {
  .filter-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .source-note { border-left: 0; padding-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid, .ranking-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { height: auto; padding: 12px 16px; align-items: flex-start; }
  .brand p, .user-badge { display: none; }
  .brand h1 { font-size: 17px; }
  .topbar-actions { gap: 6px; }
  main { padding: 12px 10px 40px; }
  .filter-card { grid-template-columns: 1fr 1fr; }
  .source-note { grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { min-height: 112px; padding: 15px; }
  .kpi-card .value { font-size: 21px; }
  .page-tabs { overflow-x: auto; }
  .category-usage-row { grid-template-columns: 92px minmax(90px, 1fr) 96px; gap: 8px; }
  .category-usage-share { display: none; }
}
