* { box-sizing: border-box; }
:root {
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #202039;
  background: #f6f6fb;
  color-scheme: light;
  --panel: #fff;
  --text: #202039;
  --muted: #61617a;
  --line: #e9e8f1;
  --accent: #5544cf;
  --light-accent: #efedff;
  --teal: #229d8e;
  --radius: 16px;
  font-synthesis: none;
}
body { margin: 0; min-width: 300px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.2rem); letter-spacing: -.045em; line-height: 1.2; }
h2 { font-size: 1.1rem; font-weight: 750; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
:focus-visible { outline: 3px solid #7968f0; outline-offset: 3px; }
.primary, .secondary, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px; border-radius: 9px; border: 1px solid transparent;
  font-size: .875rem; font-weight: 700; white-space: nowrap;
}
.primary { color: white; background: var(--accent); }
.primary:hover:not(:disabled) { background: #4433b3; }
.secondary { background: white; color: var(--text); border-color: #deddeb; }
.secondary:hover:not(:disabled) { background: #f9f8ff; border-color: #c3bcec; }
.danger { color: white; background: #ae2843; }
.danger:hover { background: #8f1e35; }
input, select, textarea {
  color: var(--text); border: 1px solid #dddced; background: white; border-radius: 9px;
  padding: 10px 12px; min-height: 40px; min-width: 0;
}
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #62627a 50%), linear-gradient(135deg, #62627a 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
label { font-size: .875rem; font-weight: 700; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 216px; display: flex; flex-direction: column;
  background: #17152e; color: #f5f3ff; padding: 28px 16px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-size: 1.28rem; font-weight: 790; letter-spacing: -.04em; text-decoration: none; }
.brand small { display: block; margin-top: 2px; font-size: .75rem; font-weight: 500; color: #aaa6c9; letter-spacing: 0; }
.sidebar .brand { margin: 0 8px 39px; }
.logo { flex: none; width: 35px; height: 35px; border-radius: 10px; background: #6654e8; display: flex; gap: 3px; align-items: end; justify-content: center; padding-bottom: 9px; }
.logo i { width: 4px; background: #fff; border-radius: 2px; height: 8px; }
.logo i:nth-child(2) { height: 15px; }
.logo i:nth-child(3) { height: 11px; background: #c1ffed; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a, .sidebar nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; color: #c3bfdb;
  background: transparent; border: 0; border-radius: 8px; text-decoration: none; text-align: left; font-size: .875rem;
}
.sidebar nav [aria-current], .sidebar nav :is(button,a):hover { color: #fff; background: #31275a; }
.nav-icon { font-size: 1.12rem; width: 20px; text-align: center; }
.sidebar-end { display: flex; align-items: center; gap: 11px; border-top: 1px solid #35314d; padding: 17px 8px 0; margin-top: auto; font-size: .875rem; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #3a3263; color: #e3ddff; font-weight: 750; }
.sidebar-end button { display: block; text-align: left; padding: 3px 0; border: 0; background: none; color: #bdb8d7; font-size: .8125rem; }
.sidebar-end button:hover { text-decoration: underline; }
.main { margin-left: 216px; padding: 33px clamp(18px, 3.3vw, 55px) 54px; max-width: 1750px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.page-header p { color: var(--muted); margin-top: 8px; font-size: .92rem; }
.notice { background: #f2eefe; color: #3f307e; border: 1px solid #dbd3fb; border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: .875rem; }
.notice[data-error="true"], .form-error { background: #fff0f2; color: #9c243c; border-color: #f5cbd3; }
#reports { display: grid; gap: 16px; }
#sources, #keywords { scroll-margin-top: 20px; }
.toolbar, .site-toolbar, .date-toolbar { display: flex; align-items: center; gap: 12px; }
.toolbar { justify-content: space-between; flex-wrap: wrap; padding-bottom: 2px; }
.site-toolbar select { max-width: 240px; }
#report-date { font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.segments { display: flex; gap: 2px; padding: 3px; background: #ebebf4; border-radius: 9px; }
.segments button { border: 0; border-radius: 7px; background: transparent; color: #58586e; font-size: .875rem; padding: 8px 10px; white-space: nowrap; }
.segments button[aria-pressed="true"] { color: #4432b3; background: #fff; font-weight: 700; box-shadow: 0 1px 3px #21204015; }
.metrics, .grid { display: grid; gap: 16px; min-width: 0; }
.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 2px 7px #2c254906; }
.metric { padding: 19px 20px; }
.metric p { display: flex; align-items: center; gap: 7px; color: #55556d; font-size: .875rem; font-weight: 700; }
.metric p span { color: #513dbb; background: var(--light-accent); padding: 3px 6px; border-radius: 5px; font-size: .75rem; letter-spacing: .04em; }
.metric strong { display: block; font-variant-numeric: tabular-nums; font-size: clamp(1.65rem, 3.2vw, 2.5rem); letter-spacing: -.04em; line-height: 1.17; margin: 7px 0; overflow-wrap: anywhere; }
.metric small, .muted { color: var(--muted); font-size: .8125rem; }
.panel-heading { padding: 19px 20px 13px; display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.panel-heading p, .dialog-header p { color: var(--muted); margin-top: 5px; font-size: .875rem; line-height: 1.5; }
.panel-actions { align-items: center; flex-wrap: wrap; }
.chart-key { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--swatch, var(--accent)); display: inline-block; flex: none; }
.purple { background: #6752e1; }
.teal { background: #229d8e; }
.trend { padding: 4px 20px 17px; }
.trend-plot { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px; }
.trend-axis { height: 116px; display: flex; flex-direction: column; justify-content: space-between; font-size: .75rem; text-align: right; color: var(--muted); }
.trend-content { min-width: 0; }
.trend-bars { height: 116px; display: flex; justify-content: space-around; background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 33.33%); border-bottom: 1px solid var(--line); }
.trend-group { width: calc(100% / var(--columns)); max-width: 92px; display: flex; justify-content: center; align-items: end; gap: clamp(1px, .45vw, 5px); padding: 0 2px; }
.trend-group span { display: inline-block; width: 35%; height: var(--bar); border-radius: 3px 3px 0 0; }
.trend-dates { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; padding: 8px 0 0; }
.platform-list { display: grid; gap: 11px; max-height: 283px; overflow-y: auto; padding: 3px 20px 19px; }
.platform-row { display: grid; grid-template-columns: minmax(70px, 1fr) minmax(46px, 1fr) minmax(35px, auto); align-items: center; gap: 9px; font-size: .875rem; }
.platform-row b { display: block; overflow-wrap: anywhere; }
.platform-row small { display: block; color: var(--muted); font-size: .75rem; margin-top: 2px; }
.bar-track { height: 7px; border-radius: 6px; background: #eeeafb; overflow: hidden; }
.bar-fill { width: var(--bar); height: 100%; background: #7160dc; border-radius: 6px; }
.browser-chart { display: flex; align-items: center; gap: 18px; padding: 7px 20px 20px; flex-wrap: wrap; }
.ring { width: 116px; height: 116px; border-radius: 50%; background: var(--ring, #eeedf5); display: grid; place-items: center; flex: none; }
.ring-center { border-radius: 50%; width: 83px; height: 83px; background: white; display: grid; place-content: center; text-align: center; font-size: .95rem; font-weight: 800; }
.ring-center small { font-size: .72rem; color: var(--muted); font-weight: 500; }
.legend { flex: 1 1 150px; min-width: 0; display: grid; gap: 8px; }
.legend-item { display: grid; align-items: center; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 7px; font-size: .8125rem; }
.legend-item span { overflow-wrap: anywhere; }
.table-wrap { overflow: auto; max-height: 485px; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: .875rem; }
th { color: #595974; font-weight: 700; white-space: nowrap; background: #f8f8fc; position: sticky; top: 0; z-index: 1; }
th, td { padding: 11px 13px; border-top: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
td small { display: block; color: var(--muted); font-size: .75rem; margin-top: 3px; }
td a { display: inline-block; max-width: 260px; overflow-wrap: anywhere; text-underline-offset: 3px; }
.detail-table { min-width: 820px; }
.detail-table td { max-width: 240px; overflow-wrap: anywhere; }
.detail-table td:nth-child(2), .detail-table td:nth-child(3) { min-width: 170px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 19px; text-align: center; }
.empty p { color: var(--muted); margin: 9px 0 17px; }
.blank { font-size: .875rem; color: var(--muted); padding: 16px 0; }
td.blank { padding: 19px 20px; }
.inline-form, .form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: 73px; padding-left: 8px; }
.inline-status { margin: 3px 20px 13px; color: #4b389d; font-size: .875rem; line-height: 1.5; }
dialog { width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); color: var(--text); padding: 0; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 70px #14102b35; }
dialog::backdrop { background: #17152eb3; }
.dialog-header { border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px; gap: 10px; }
.dialog-header h2 { font-size: 1.25rem; }
.dialog-body { padding: 18px 22px 22px; }
.close { border: 0; font-size: 1.4rem; color: var(--muted); background: #f1eff8; border-radius: 7px; height: 33px; width: 33px; }
.site-row { padding: 10px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.site-row strong, .site-row small { display: block; overflow-wrap: anywhere; }
.site-row small { color: var(--muted); font-size: .81rem; margin-top: 3px; }
.site-row > div:last-child { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.site-row .remove { color: #a12740; }
#show-add, #snippet, #site-form { margin-top: 12px; }
#snippet { padding: 12px; border-radius: 9px; background: #f5f3ff; }
#snippet textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; margin: 7px 0; resize: vertical; }
#site-status { margin: 10px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid input { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
#site-form .form-actions { margin-top: 14px; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 15% 15%, #3a2c73 0%, #1b1634 40%, #141128 80%); }
.login-card { width: min(100%, 440px); padding: 35px; background: #fff; border: 1px solid #f3eefd; border-radius: 21px; box-shadow: 0 24px 90px #100b2880; }
.login-card .brand small { color: var(--muted); }
.login-card h1 { margin-top: 29px; }
.login-card > p { color: var(--muted); font-size: .875rem; margin: 8px 0 20px; }
.login-card form { display: grid; gap: 9px; }
.login-card .primary { margin-top: 6px; }
.form-error { padding: 8px 10px; border: 1px solid #f5cbd3; border-radius: 7px; font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
@media (max-width: 960px) {
  .sidebar { width: 175px; }
  .main { margin-left: 175px; }
  .metric { padding-inline: 14px; }
}
@media (max-width: 730px) {
  .sidebar { position: static; width: 100%; padding: 11px 15px; display: grid; gap: 10px; grid-template-columns: 1fr auto; }
  .sidebar .brand { margin: 0; }
  .sidebar nav { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar nav a, .sidebar nav button { width: auto; padding: 6px 8px; gap: 3px; }
  .sidebar-end { margin: 0; padding: 0; border: 0; }
  .main { margin-left: 0; padding-top: 23px; }
}
@media (max-width: 530px) {
  .grid, .form-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric:last-child { grid-column: 1 / -1; }
  .page-header .secondary { display: none; }
  .date-toolbar { flex-wrap: wrap; }
  .login-card { padding: 25px; }
}

