:root {
	--bg: #06070d;
	--panel: rgba(18, 19, 34, 0.72);
	--panel-hi: rgba(28, 26, 52, 0.55);
	--line: rgba(140, 120, 255, 0.16);
	--line-2: rgba(255, 255, 255, 0.06);
	--text: #eef1fb;
	--muted: #9aa3c4;
	--accent: #8b6dff;
	--accent-2: #38bdf8;
	--radius: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
	background: var(--bg);
	color: var(--text);
	font: 15px/1.6 "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background-image:
		radial-gradient(900px 440px at 8% -14%, rgba(139, 109, 255, 0.18), transparent 62%),
		radial-gradient(720px 400px at 96% -6%, rgba(56, 189, 248, 0.12), transparent 64%);
	background-attachment: fixed;
}

/* ---------- 顶栏 ---------- */

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 12px 20px;
	border-bottom: 1px solid var(--line);
	background: rgba(8, 9, 16, 0.66);
	backdrop-filter: blur(14px);
	flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand h1 {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: 0.03em;
}

.logo {
	width: 24px;
	height: 24px;
	border-radius: 7px;
	flex: 0 0 auto;
	box-shadow: 0 0 14px rgba(139, 109, 255, 0.55);
}

.controls { display: flex; align-items: center; gap: 10px; }

.seg {
	display: inline-flex;
	gap: 3px;
	padding: 3px;
	border: 1px solid var(--line);
	border-radius: 11px;
	background: var(--panel-hi);
}

.seg button {
	border: 0; background: transparent; color: var(--muted);
	font: inherit; font-size: 14px; padding: 6px 15px;
	border-radius: 9px; cursor: pointer; transition: 0.16s;
}
.seg button:hover { color: var(--text); }
.seg button.active {
	background: linear-gradient(180deg, #8b6dff, #6d55dc);
	color: #fff;
	box-shadow: 0 4px 12px -5px rgba(139, 109, 255, 0.95);
}

.icon-btn {
	border: 1px solid var(--line);
	background: var(--panel-hi);
	color: var(--muted);
	font: inherit; font-size: 14px;
	padding: 7px 13px; border-radius: 10px; cursor: pointer; transition: 0.16s;
}
.icon-btn:hover { color: var(--text); border-color: rgba(139, 109, 255, 0.5); }
a.icon-btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- 主网格：一屏放下，不产生整页滚动 ---------- */

main {
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	gap: 13px;
	padding: 13px 20px 6px;
	max-width: 1780px;
	width: 100%;
	margin: 0 auto;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	grid-template-rows: auto 262px minmax(0, 1fr);
}

.stats {
	grid-column: span 12;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 13px;
}

.stat {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 13px 18px;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	position: relative;
	overflow: hidden;
}

.stat::after {
	content: "";
	position: absolute; inset: auto 0 0 0; height: 1px;
	background: linear-gradient(90deg, transparent, rgba(139, 109, 255, 0.55), transparent);
	opacity: 0.55;
}

.stat .k { color: var(--muted); font-size: 14px; white-space: nowrap; }

.stat strong {
	font-size: 30px;
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	background: linear-gradient(135deg, #fff, #c6b8ff);
	-webkit-background-clip: text; background-clip: text; color: transparent;
}

.stat.hl { border-color: rgba(139, 109, 255, 0.36); background: linear-gradient(180deg, rgba(80, 62, 160, 0.34), rgba(18, 19, 34, 0.72)); }
.stat.hl strong { background: linear-gradient(135deg, #cfc2ff, var(--accent-2)); -webkit-background-clip: text; background-clip: text; }

.p-chart { grid-column: span 7; }
.p-refs { grid-column: span 5; }
.p-pages { grid-column: span 5; }
.p-recent { grid-column: span 7; }

.panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 13px 15px;
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}

.panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
	flex: 0 0 auto;
}

.panel-head h2 {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: #d7dcf2;
}

.legend { display: flex; gap: 16px; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.pv { background: var(--accent); }
.sw.uv { background: var(--accent-2); }

.chart-body { flex: 1 1 auto; min-height: 0; }
.chart-body svg { display: block; width: 100%; height: 100%; }

.scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	margin: 0 -5px;
	padding: 0 5px 4px;
	-webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
	mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
}

/* 细滚动条 */
.scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll::-webkit-scrollbar-thumb {
	background: rgba(139, 109, 255, 0.34);
	border-radius: 9px;
	border: 2px solid transparent;
	background-clip: content-box;
}
.scroll::-webkit-scrollbar-thumb:hover { background: rgba(139, 109, 255, 0.6); background-clip: content-box; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ---------- 表格 ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
	position: sticky; top: 0; z-index: 1;
	background: rgba(14, 15, 26, 0.97);
	backdrop-filter: blur(6px);
	text-align: left;
	color: var(--muted);
	font-weight: 600;
	font-size: 12.5px;
	padding: 7px 10px;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}

td {
	padding: 8px 10px;
	border-bottom: 1px solid var(--line-2);
	vertical-align: middle;
	white-space: nowrap;
}

tbody tr:hover td { background: rgba(139, 109, 255, 0.08); }
tbody tr:last-child td { border-bottom: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; color: #d2d9f0; font-weight: 600; }

td.empty { text-align: center; color: var(--muted); padding: 26px 10px; white-space: normal; }

.path-cell {
	max-width: 340px;
	overflow: hidden; text-overflow: ellipsis;
	color: #b9a9ff;
	font-family: ui-monospace, Consolas, monospace;
	font-size: 13px;
}

.sub {
	display: block;
	color: var(--muted);
	font-size: 12px;
	margin-top: 2px;
}

.ua-cell, .ref-cell { color: #b3bbd6; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }

.head-actions { display: flex; align-items: center; gap: 8px; }

input[type="search"] {
	background: rgba(12, 13, 24, 0.85);
	border: 1px solid var(--line);
	border-radius: 10px;
	color: var(--text);
	font: inherit; font-size: 13.5px;
	padding: 6px 11px;
	width: 220px;
	outline: none;
	transition: 0.16s;
}
input[type="search"]:focus { border-color: rgba(139, 109, 255, 0.62); box-shadow: 0 0 0 3px rgba(139, 109, 255, 0.14); }
input[type="search"]::placeholder { color: rgba(154, 163, 196, 0.6); }

footer {
	flex: 0 0 auto;
	padding: 2px 22px 8px;
	color: var(--muted);
	font-size: 12.5px;
	max-width: 1780px;
	width: 100%;
	margin: 0 auto;
}

/* ---------- 窄屏：恢复正常滚动 ---------- */

@media (max-width: 1180px) {
	body { overflow: auto; }
	main {
		grid-template-columns: 1fr;
		grid-template-rows: none;
		height: auto;
		padding: 12px 14px 22px;
	}
	.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.p-chart, .p-refs, .p-pages, .p-recent { grid-column: span 1; }
	.p-chart { height: 250px; }
	.p-refs, .p-pages { height: 300px; }
	.p-recent { height: 460px; }
	input[type="search"] { width: 100%; }
	.head-actions { width: 100%; }
}
