/* 拉丁字母与数字用内嵌的 Inter（本地文件，不走外网），中文回落到系统字体 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ==========================================================================
   访问统计 · 设计系统 v4
   一套 token：颜色 / 字号 / 间距 / 圆角 / 阴影 / 动效。页面里不写死值。
   ========================================================================== */

:root {
  /* 品牌标底色 */
  --brand-tile: #0e1526;

  /* 画布与表面 */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f0f2f5;
  --surface-glass: rgba(255, 255, 255, 0.9);

  /* 分隔线 */
  --line: rgba(15, 18, 26, 0.07);
  --line-2: rgba(15, 18, 26, 0.12);
  --line-3: rgba(15, 18, 26, 0.2);

  /* 文字 */
  --ink: #101218;
  --ink-2: #565b66;
  --ink-3: #8b8f9a;
  --ink-4: #b6bac4;

  /* 主色 */
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-ring: rgba(37, 99, 235, 0.28);
  --on-accent: #ffffff;

  /* 状态 */
  --ok: #0f7a53;
  --ok-soft: rgba(15, 122, 83, 0.09);
  --danger: #c42035;
  --danger-soft: rgba(196, 32, 53, 0.08);

  /* 圆角：数据后台不用太圆，面板 16、控件 9 */
  --r-1: 6px;
  --r-2: 9px;
  --r-3: 12px;
  --r-4: 16px;
  --r-pill: 999px;

  /* 间距 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 56px;

  /* 阴影 */
  --shadow-1: 0 1px 2px rgba(15, 18, 26, 0.04);
  --shadow-2: 0 1px 2px rgba(15, 18, 26, 0.04), 0 10px 24px -16px rgba(15, 18, 26, 0.24);
  --shadow-3: 0 1px 2px rgba(15, 18, 26, 0.04), 0 24px 48px -28px rgba(15, 18, 26, 0.3);
  --shadow-accent: 0 6px 14px -8px rgba(37, 99, 235, 0.7);
  --backdrop: rgba(16, 18, 27, 0.28);

  /* 字体：拉丁与数字走 Inter，中文走系统字体 */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;

  /* 动效 */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-1: 130ms;
  --t-2: 200ms;
  --t-3: 320ms;

  /* 布局 */
  --side: 244px;
  --content: 100%;

  /* 字号 */
  --fs-1: 11.5px;
  --fs-2: 12.5px;
  --fs-3: 13px;
  --fs-4: 14px;
  --fs-5: 15px;
  --fs-6: 20px;
  --fs-7: 26px;
  --fs-8: 30px;

  color-scheme: light;
}

/* ---------- 深色主题：只换这套变量，组件规则不用重写 ---------- */
[data-theme="dark"] {
  --brand-tile: #232c40;

  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #171b24;
  --surface-3: #1e2330;
  --surface-glass: rgba(18, 21, 28, 0.9);

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --line-3: rgba(255, 255, 255, 0.22);

  --ink: #e9ecf2;
  --ink-2: #a8aeba;
  --ink-3: #838a98;
  --ink-4: #6b7284;

  --accent: #4d8dff;
  --accent-2: #6ba1ff;
  --accent-soft: rgba(77, 141, 255, 0.16);
  --accent-ring: rgba(77, 141, 255, 0.4);
  --on-accent: #ffffff;

  --ok: #35c08a;
  --ok-soft: rgba(53, 192, 138, 0.14);
  --danger: #ff6b7a;
  --danger-soft: rgba(255, 107, 122, 0.14);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -18px rgba(0, 0, 0, 0.8);
  --shadow-3: 0 1px 2px rgba(0, 0, 0, 0.4), 0 28px 56px -30px rgba(0, 0, 0, 0.9);
  --shadow-accent: 0 6px 16px -10px rgba(77, 141, 255, 0.8);

  --backdrop: rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

/* ---------- 基础 ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* 触摸设备：去掉点击高亮，避免双击缩放误触 */
button,
a,
summary { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-4);
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; appearance: none; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

::selection { background: var(--accent-soft); color: var(--accent-2); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 2px solid transparent;
  border-radius: var(--r-pill);
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: content-box; }

/* ---------- 骨架 ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
}

/* ---------- 侧栏 ---------- */

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  height: 100vh;
  padding: var(--sp-6) var(--sp-3) var(--sp-4);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-2) var(--sp-1);
  border-radius: var(--r-2);
}

/* 手机顶栏、抽屉关闭键、抽屉遮罩：桌面端不出现 */
.appbar,
.sidebar-close,
.nav-backdrop { display: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  flex: none;
}

.brand-mark svg { width: 31px; height: 31px; display: block; }

.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-text strong { font-size: var(--fs-5); font-weight: 600; letter-spacing: -0.01em; }
.brand-text em {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* 当前站点 */
.scope { position: relative; display: flex; flex-direction: column; gap: var(--sp-2); }

.scope-card {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  min-width: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}

/* 页头里的站点切换收成一颗小按钮 */
.head-tools .scope { flex: none; }

.head-tools .scope-card {
  width: auto;
  height: 36px;
  padding: 0 var(--sp-2) 0 5px;
  background: var(--surface);
  border-radius: var(--r-2);
}

.head-tools .scope-card .tile { width: 22px; height: 22px; font-size: 10px; }
.head-tools .scope-text { flex-direction: row; align-items: baseline; gap: var(--sp-1); }
.head-tools .scope-name { max-width: 170px; }
.head-tools .scope-domain { display: none; }
.head-tools .scope-caret { margin-left: var(--sp-1); }

.head-tools .scope-menu {
  left: auto;
  right: 0;
  width: 300px;
  max-width: min(84vw, 320px);
}

.scope-card:hover { border-color: var(--line-2); background: var(--surface-3); }
.scope-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scope-card[aria-expanded="true"] { border-color: var(--accent); background: var(--surface); }

.scope-caret {
  flex: none;
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: var(--ink-4);
  transition: transform var(--t-1) var(--ease);
}

.scope-card[aria-expanded="true"] .scope-caret { transform: rotate(180deg); }

.scope-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: min(70vh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
}

.scope-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 6px var(--sp-2);
  border-radius: var(--r-1);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-1) var(--ease);
}

.scope-option:hover { background: var(--surface-3); }
.scope-option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.scope-option[aria-selected="true"] { background: var(--accent-soft); }
.scope-option[aria-selected="true"]:hover { background: var(--accent-soft); }
.scope-option[aria-selected="true"] .scope-name { color: var(--accent-2); }
.scope-option .tile { width: 24px; height: 24px; font-size: var(--fs-1); }

/* 当前站点打勾，右侧对齐，不占额外高度 */
.scope-check {
  flex: none;
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: var(--accent);
  opacity: 0;
  transition: opacity var(--t-1) var(--ease);
}

.scope-option[aria-selected="true"] .scope-check { opacity: 1; }

.scope-text { display: flex; flex-direction: column; min-width: 0; }
.scope-name {
  font-size: var(--fs-3);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scope-domain {
  font-size: var(--fs-1);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--r-2);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: var(--fs-2);
  font-weight: 600;
  text-transform: uppercase;
  overflow: hidden;
}

.tile-letter { line-height: 1; }

.site-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--t-2) var(--ease);
}

.site-icon.is-loaded { opacity: 1; }
.site-icon.is-broken { display: none; }

/* 导航 */
.nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  flex: 1;
  min-height: 0;
  padding-bottom: var(--sp-2);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* 导航滚起来但不出滚动条 */
.nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.nav-block { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-1);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-2);
  font-size: var(--fs-3);
  color: var(--ink-2);
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}

.nav-item .icon { width: 16px; height: 16px; color: var(--ink-3); transition: color var(--t-1) var(--ease); }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item:hover .icon { color: var(--ink-2); }
.nav-item:active { background: var(--surface-3); transform: translateY(0.5px); }

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 500;
}
.nav-item.is-active .icon { color: var(--accent); }


.user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}



.avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: var(--fs-1);
  font-weight: 600;
  text-transform: uppercase;
}

.user-name {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-2);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-out {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px var(--sp-2);
  border-radius: var(--r-1);
  font-size: var(--fs-2);
  color: var(--ink-3);
  transition: color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}
.user-out .icon { width: 14px; height: 14px; }

/* 用户名后面的深浅色切换 */
.theme-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--r-1);
  color: var(--ink-3);
  transition: color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}

.theme-btn .icon { width: 15px; height: 15px; }

.theme-btn:hover { background: var(--surface-3); color: var(--ink); }
.theme-btn:active { background: var(--surface-3); }
.theme-btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }
/* 导航里的小标签：未接入 */
.nav-tag {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-4);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.02em;
  flex: none;
}

/* 还没接入的统计对象：占位说明 */
.stub {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-7);
}

.stub-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-1);
  border-radius: var(--r-3);
  background: var(--accent-soft);
  color: var(--accent);
}

.stub-mark .icon { width: 22px; height: 22px; }

.stub-title {
  font-size: var(--fs-5);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stub-text {
  max-width: 58ch;
  font-size: var(--fs-3);
  color: var(--ink-2);
}

.stub-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin: var(--sp-1) 0 0;
  padding-left: 18px;
  max-width: 60ch;
  list-style: disc;
  font-size: var(--fs-3);
  color: var(--ink-3);
}

.stub-list li::marker { color: var(--ink-4); }

.stub-note { font-size: var(--fs-2); color: var(--ink-4); }

.user-out:hover { color: var(--ink); background: var(--surface-3); }

/* 侧栏底部：账号与退出 */
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: none;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}

/* ---------- 主区 ---------- */

.main {
  min-width: 0;
  padding: var(--sp-6) var(--sp-8) var(--sp-9);
}

/* 右侧主区通栏：不再限制 1180 版心，宽度跟着窗口走 */
.page-head,
.page {
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
}

/* 页头收成一行：标题和辅助信息并排，右侧是工具区 */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.head-text {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  min-width: 0;
}

.page-title {
  font-size: var(--fs-6);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  white-space: nowrap;
}

.page-sub {
  margin: 0;
  font-size: var(--fs-2);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: none;
}

.status {
  font-size: var(--fs-2);
  color: var(--ink-3);
  transition: opacity var(--t-2) var(--ease);
}
.status:empty { display: none; }

/* 分段控件 */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-2);
}

.seg {
  height: 30px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: var(--fs-2);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease),
    box-shadow var(--t-1) var(--ease);
}

.seg:hover { color: var(--ink); }
.seg:active { transform: translateY(0.5px); }

.seg.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow-1);
}

.segmented.small .seg { height: 26px; padding: 0 var(--sp-2); font-size: var(--fs-1); }

/* ---------- 面板 ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.panel + .panel,
.panel + .columns,
.columns + .panel,
.columns + .columns { margin-top: var(--sp-4); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: 54px;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
}

/* 面板里单独一块内容（比如只有一行按钮），跟表单区同一边距 */
.panel-body { padding: var(--sp-5); }

.panel-head h2 {
  font-size: var(--fs-4);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.panel-note { font-size: var(--fs-2); color: var(--ink-3); }

.head-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: start;
}

.columns > .panel { margin-top: 0; }

/* 概览里同一行的两块拉齐，矮的那块补底色，不留空洞 */
.columns.is-tall { align-items: stretch; }
.columns.is-tall > .panel { display: flex; flex-direction: column; }
.columns.is-tall .table-wrap { flex: 1 1 auto; }

/* ---------- 指标条 ---------- */

.kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0;
}

.kpi.is-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi.is-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.kpi-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5);
  min-width: 0;
}

.kpi-cell + .kpi-cell::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--sp-4);
  bottom: var(--sp-4);
  width: 1px;
  background: var(--line);
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-2);
  color: var(--ink-3);
}

.kpi-label .icon { width: 14px; height: 14px; color: var(--ink-4); }

.kpi-value {
  font-size: var(--fs-8);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
}

.kpi-sub { font-size: var(--fs-1); color: var(--ink-3); }

/* 首页顶部：左边今日汇总，右边服务器状况，两块一样高 */
.home-top {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: stretch;
}

.home-top + .panel { margin-top: var(--sp-4); }

/* 并排的两块共用一行，不要面板之间的上下间距，否则右边会被顶下去 */
.home-top > .panel + .panel { margin-top: 0; }

.stat-card { display: flex; flex-direction: column; }

.stat-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5) 0;
}

.stat-title { font-size: var(--fs-2); font-weight: 600; color: var(--ink-3); }
.stat-note { margin-left: auto; font-size: var(--fs-1); color: var(--ink-4); }

.stat-card .kpi { flex: 1; }
.stat-card .kpi-cell { min-height: 82px; }

/* 窗口不够宽时两块都变两行两列，避免标签换行、也和左边保持同高 */
@media (max-width: 1380px) {
  .stat-card .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .stat-card .kpi-cell { min-height: 0; padding: var(--sp-4) var(--sp-5); }
  .stat-card .kpi-cell + .kpi-cell::before { display: none; }
}

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

/* 表格容器一律不横向滚动，列宽按比例分，放不下的内容截断 */
.table-wrap { width: 100%; overflow: hidden; }

.data-table { width: 100%; font-size: var(--fs-3); }

/* 列宽写死在 colgroup 里的表用固定布局，数字列才不会把内容挤出去 */
.data-table.fixed { table-layout: fixed; }
.data-table .cell-sub { max-width: 100%; }

.data-table td.empty-cell {
  padding: var(--sp-8) var(--sp-5);
  font-size: var(--fs-2);
  color: var(--ink-4);
  text-align: center;
  letter-spacing: 0.01em;
}

.data-table th,
.data-table td {
  padding: 12px var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table thead th {
  padding-top: 9px;
  padding-bottom: 9px;
  background: var(--surface-2);
  font-size: var(--fs-1);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-3);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.data-table tbody tr:last-child td,
.data-table tbody tr:last-child th { border-bottom: 0; }

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.data-table tbody tr { transition: background var(--t-1) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-2); }

.data-table tr.is-clickable { cursor: pointer; }

.cell-main {
  display: block;
  font-size: var(--fs-3);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-1);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.empty-cell {
  padding: var(--sp-8) var(--sp-4) !important;
  text-align: center;
  font-size: var(--fs-3);
  color: var(--ink-3);
}

/* 首页站点表 */
.home-table { table-layout: fixed; }

.home-table .col-site { width: 26%; }
.data-table .col-num { width: 92px; }
.data-table .col-wide { width: 124px; }
.data-table .col-visitor { width: 112px; }
.data-table .col-ref { width: 146px; }
.data-table .col-env { width: 176px; }
.data-table .col-pages { width: 56px; }
.data-table .col-dur { width: 84px; }

.data-table td .nowrap { white-space: nowrap; }
.data-table .col-time { width: 108px; }

/* 实时访客列多，固定列收窄一点，别让表头把表顶宽 */
.data-table.is-live .col-dur { width: 7%; }
.data-table.is-live .col-pages { width: 7%; }
/* 访问明细：9 列按比例分，宽屏窄屏都不顶出去 */
#sessions .col-time { width: 13%; }
/* 流量质量：原因和 UA 要能看清，时间/IP 收窄 */
#pane-quality .col-when { width: 112px; }
#pane-quality .col-geo { width: 200px; }
#pane-quality .col-reason { width: 214px; }
#pane-quality .col-client { width: 152px; }
#sessions .col-visitor { width: 9%; }
#sessions .col-geo { width: 13.5%; }
#sessions .col-env { width: 18%; }
#sessions .col-ref { width: 9%; }
#sessions .col-entry { width: 17.5%; }
#sessions .col-kw { width: 6%; }
#sessions .col-pages { width: 5%; }
#sessions .col-dur { width: 8.5%; }

/* 浏览器和系统要放下完整版本号，这一列字号小一档 */
#sessions .cell-env .cell-main,
#sessions .cell-env .cell-sub,
.data-table.is-live .cell-env .cell-main,
.data-table.is-live .cell-env .cell-sub { font-size: var(--fs-2); }

#sessions td,
#sessions th {
  padding-left: var(--sp-3);
  padding-right: var(--sp-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sessions .cell-sub { max-width: none; }
#sessions .cell-main,
.data-table.is-live .cell-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 今日流量、趋势明细也按比例分，窄屏不留横条 */
#today-table .col-time { width: 15%; }
#today-table .col-num { width: 12.5%; }
#today-table .col-wide { width: 15%; }

/* 固定列宽的表：一行一句话，长了截断，不换行打乱行高 */
.data-table.fixed td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table.fixed td .cell-main,
.data-table.fixed td .cell-sub { white-space: nowrap; }

#trend-line-table .col-time { width: 18%; }
#trend-line-table .col-num { width: 15%; }
#trend-line-table .col-wide { width: 20%; }

/* 实时访客：8 列同样按比例分 */
.data-table.is-live .col-time { width: 13%; }
.data-table.is-live .col-geo { width: 13%; }
.data-table.is-live .col-env { width: 18%; }
.data-table.is-live .col-entry { width: 21%; }
.data-table.is-live .col-src { width: 14%; }
.data-table.is-live .col-kw { width: 6%; }
.data-table.is-live .col-dur { width: 8%; }
.data-table.is-live .col-pages { width: 7%; }

.data-table.is-live td,
.data-table.is-live th {
  padding-left: var(--sp-3);
  padding-right: var(--sp-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table.is-live .cell-sub { max-width: none; }

@media (max-width: 1240px) {
  #sessions td,
  #sessions th,
  .data-table.is-live td,
  .data-table.is-live th {
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
  }
}

.data-table .col-ip { width: 128px; }

/* 采集字段：字段名用等宽字，采样值和落库位置各占一列 */
/* 字段分组列表跟在说明面板后面，补上和其他卡片一致的间距 */
#fields-list { margin-top: var(--sp-4); }
/* 说明面板正文只有一行字，行高松一点，不贴着上下边 */
#page-fields .panel-body { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
#page-fields .panel-body .panel-note { line-height: 1.7; }
/* 说明列要能换行，盖掉 .data-table.fixed 的 nowrap */
.data-table.fields-table td { vertical-align: top; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.data-table.fields-table td .cell-sub { max-width: none; white-space: normal; overflow: visible; }
.fields-table code {
  padding: 1px 5px;
  border-radius: var(--r-1);
  background: var(--surface-3);
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: var(--fs-2);
}
.fields-table .col-field { width: 150px; }
.fields-table .col-sample { width: 190px; }
.fields-table .col-column { width: 220px; }
.fields-table .col-page { width: 110px; }

/* 窄屏下 5 列变卡片，按一列竖排，标签和值不串 */
@media (max-width: 740px) {
  .data-table.fields-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .data-table.fields-table td { padding-top: 6px; }
  .data-table.fields-table td:first-child code { font-size: var(--fs-3); }
}
.home-table .col-site { width: 24%; }
.home-table .col-period { width: 76px; }
.home-table .col-pv { width: 104px; }
.home-table .col-uv { width: 100px; }
.home-table .col-ip { width: 76px; }
.home-table .col-bounce { width: 88px; }
.home-table .col-avg { width: 124px; }
.home-table .col-action { width: 122px; }

/* 首页表格排得紧一点，三条时段压在一屏里 */
.home-table td,
.home-table th { padding: 3px var(--sp-4); }

.home-table tbody.site-block tr:first-child > * { padding-top: 12px; }
.home-table tbody.site-block tr:last-child > * { padding-bottom: 12px; }

.home-table .is-blank { color: var(--ink-4); }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: color var(--t-1) var(--ease);
}

.th-sort:hover { color: var(--accent); }

.sort-arrow {
  font-size: 10px;
  line-height: 1;
  color: var(--ink-4);
  transition: color var(--t-1) var(--ease);
}

.th-sort:hover .sort-arrow,
.th-sort[data-active] .sort-arrow { color: var(--accent); }

/* 站内三行不画线，站与站之间留一条线；不加底色不加框（操作列是 rowspan，单独补） */
.home-table tbody.site-block td,
.home-table tbody.site-block th { border-bottom: 0; }
.home-table tbody.site-block:not(:last-child) tr:last-child > * { border-bottom: 1px solid var(--line); }
.home-table tbody.site-block:not(:last-child) tr:first-child > .cell-action { border-bottom: 1px solid var(--line); }

.home-table td.cell-site,
.home-table td.cell-action { vertical-align: middle; }

.site-cell {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.site-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }

.site-name {
  font-size: var(--fs-4);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--t-1) var(--ease);
}

.site-cell:hover .site-name { color: var(--accent-2); }

.site-sub {
  font-size: var(--fs-1);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-table th.period {
  font-weight: 400;
  font-size: var(--fs-2);
  color: var(--ink-3);
  white-space: nowrap;
}

.home-table th.period[data-strong] { color: var(--ink-2); }

/* 今日 / 昨日 / 预计三行拉开对比：今日最实，昨日压灰，预计只留浅灰字，不铺底色 */
.home-table tbody tr.row-today td.num { font-weight: 600; color: var(--ink); }
.home-table tbody tr.row-yesterday td.num { color: var(--ink-3); }
.home-table tbody tr.row-projected th.period { color: var(--ink-4); }
.home-table tbody tr.row-projected td.num { color: var(--ink-3); }

/* 这三行是同一站点的分时段数据，鼠标扫过不需要整行高亮 */
.home-table tbody tr:hover { background: transparent; }

.home-table .cell-action { text-align: right; }

.home-table .row-actions {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.home-table .row-enter {
  padding: 0;
  border-radius: 0;
  font-size: var(--fs-2);
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  transition: color var(--t-1) var(--ease);
}

.home-table .row-enter:hover { background: none; color: var(--accent-2); text-decoration: underline; }

/* 次要入口弱一档，别和「查看报告」抢眼 */
.home-table .row-enter.is-muted { font-weight: 400; color: var(--ink-3); }
.home-table .row-enter.is-muted:hover { color: var(--ink); }

.row-enter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px var(--sp-2) 5px var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-2);
  color: var(--ink-2);
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}

.row-enter .icon { width: 14px; height: 14px; transition: transform var(--t-1) var(--ease); }
.row-enter:hover { background: var(--accent-soft); color: var(--accent-2); }
.row-enter:hover .icon { transform: translateX(2px); }

/* 首页手机卡片 */
.home-cards { display: none; }

/* ---------- 标签 ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-1);
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}

.tag.new { background: var(--accent-soft); color: var(--accent-2); }
.tag.old { background: var(--ok-soft); color: var(--ok); }

/* 新老访客前面加个点，颜色之外形状也能分开 */
.tag-dot {
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
}

.cell-muted { color: var(--ink-4); }

.cell-id { font-size: var(--fs-2); font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* 关键词做成小标签，和左右两列一眼分开 */
.cell-kw {
  display: inline-block;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: var(--fs-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: 1px;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-2);
  color: var(--ink-3);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

/* ---------- 按钮 / 表单 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  font-size: var(--fs-2);
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-1) var(--ease), border-color var(--t-1) var(--ease),
    color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease), transform var(--t-1) var(--ease);
}

.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-3); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--line-2); }

.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

.btn.primary:hover { background: var(--accent-2); color: var(--on-accent); }
.btn.primary:disabled { background: var(--accent); }

.btn.danger { border-color: var(--danger-soft); color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }

.btn.ghost { border-color: var(--line); background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }

.btn.icon { width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent; }
.btn.icon:hover { background: var(--surface-3); }

.search {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--ink-3);
  transition: border-color var(--t-1) var(--ease), background var(--t-1) var(--ease),
    box-shadow var(--t-1) var(--ease);
}

.search .icon { width: 14px; height: 14px; }

.search input {
  width: 190px;
  max-width: 40vw;
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--fs-2);
  color: var(--ink);
}

.search input::placeholder { color: var(--ink-4); }

.search:focus-within {
  border-color: var(--accent-ring);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--line);
}

.pager-info { font-size: var(--fs-2); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-5);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field-label { font-size: var(--fs-2); color: var(--ink-2); }

.field.is-wide { grid-column: 1 / -1; }

.field-hint { font-size: var(--fs-1); color: var(--ink-3); line-height: 1.6; }

.field-textarea {
  height: auto;
  min-height: 84px;
  padding: var(--sp-2) var(--sp-3);
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  resize: vertical;
}

.field-input {
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  font-size: var(--fs-3);
  color: var(--ink);
  transition: border-color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease);
}

.field-input::placeholder { color: var(--ink-4); }

.field-input:hover { border-color: var(--line-3); }

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 单独一页的表单收一下宽度，别拉到整屏 */

/* 新增站点：表单收窄，别拉满整屏 */
#page-new-site .panel { max-width: 720px; }

#page-new-site .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-top: var(--sp-1);
}

.form-status { font-size: var(--fs-2); color: var(--ink-3); }
.form-status[data-state="ok"] { color: var(--ok); }
.form-status[data-state="error"] { color: var(--danger); }

/* 只读字段（站点 ID） */
.field-input[readonly] {
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: default;
}

.field-input[readonly]:hover { border-color: var(--line-2); }
.field-input[readonly]:focus { border-color: var(--line-2); box-shadow: none; }

/* ---------- 当前在线 ---------- */

.live-split {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: var(--sp-7);
  padding: var(--sp-5);
}

.live-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.live-number {
  font-size: 44px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.live-label { font-size: var(--fs-2); color: var(--ink-3); }
.live-time { margin-top: var(--sp-4); font-size: var(--fs-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.live-note { font-size: var(--fs-1); color: var(--ink-4); }

.line-chart { margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }

/* 趋势页的折线单独占一块，图和表之间留条线 */
.trend-line {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line);
}

.line-plot.is-tall { height: 232px; }

.line-title { font-size: var(--fs-2); color: var(--ink-3); }

.line-plot { position: relative; height: 176px; padding-left: var(--sp-7); }

.line-svg { display: block; width: 100%; height: 100%; }

.line-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* X 轴线：实线，比网格线深一档 */
.line-base { stroke: var(--line-3); stroke-width: 1; vector-effect: non-scaling-stroke; }

.line-path {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.line-path.is-pv { stroke: var(--accent); }

/* 折线下面的淡色面积，让曲线有落点 */
.line-area {
  fill: var(--accent-soft);
  stroke: none;
  opacity: 0.75;
}
.line-path.is-uv { stroke: var(--ink-3); }

.line-peak,
.line-zero {
  position: absolute;
  left: 0;
  font-size: var(--fs-1);
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.line-peak { top: 0; }
.line-zero { bottom: 0; }

/* Y 轴刻度：峰值和 0 旁边各一段小横线 */
.line-peak::after,
.line-zero::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: 4px;
  height: 1px;
  margin-left: 3px;
  background: var(--ink-4);
}

.line-axis {
  position: relative;
  height: 14px;
  margin-left: var(--sp-7);
  font-size: var(--fs-1);
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* 刻度按真实位置摆，两端贴边不越界 */
.line-axis span {
  position: absolute;
  left: var(--x, 0%);
  transform: translateX(-50%);
  white-space: nowrap;
}

.line-axis span:first-child { transform: none; }
.line-axis span:last-child { transform: translateX(-100%); }
.line-axis span.is-single { transform: translateX(-50%); }

/* 每个刻度文字上方一条竖线，正好接到轴线上 */
.line-axis span::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 1px;
  height: 5px;
  margin-bottom: 2px;
  background: var(--ink-4);
  transform: translateX(-50%);
}

.line-axis span:first-child::before { left: 0; }
.line-axis span:last-child::before { left: 100%; }

.line-legend { display: flex; gap: var(--sp-4); padding-left: var(--sp-7); font-size: var(--fs-2); color: var(--ink-3); }

.line-key { display: inline-flex; align-items: center; gap: 6px; }

.line-key::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}

.line-key.is-pv::before { background: var(--accent); }

/* ---------- 图表悬停提示 ---------- */

.chart-tip {
  position: fixed;
  left: var(--tip-x, 0);
  top: var(--tip-y, 0);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 116px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-1) var(--ease), transform var(--t-1) var(--ease);
}

.chart-tip.is-on { opacity: 1; transform: none; }

.chart-tip-title {
  font-size: var(--fs-1);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.chart-tip-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.chart-tip-row b {
  margin-left: auto;
  padding-left: var(--sp-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.chart-tip-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.chart-tip-dot.is-uv { background: var(--ink-3); }

/* 折线图上的竖线和圆点 */
.line-hover {
  position: absolute;
  inset: 0 0 0 var(--sp-7);
  pointer-events: none;
  transition: opacity var(--t-1) var(--ease);
}

.line-hover.is-off { opacity: 0; }

.line-guide {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: var(--x, 0%);
  width: 1px;
  background: var(--line-2);
}

.line-dot {
  position: absolute;
  left: var(--x, 0%);
  top: var(--y, 0%);
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.line-dot.is-uv {
  background: var(--ink-3);
  box-shadow: 0 0 0 3px var(--surface-3);
}

/* ---------- 今日流量 ---------- */

#today-table th.period { font-weight: 500; color: var(--ink-2); }
#today-table th.period[data-strong] { font-weight: 600; color: var(--ink); }
#today-table .is-blank { color: var(--ink-4); }

/* ---------- 统计代码 ---------- */

.snippet {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
}

.snippet:first-child { border-top: 0; }

.snippet-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.snippet-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }

.snippet-name {
  font-size: var(--fs-3);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snippet-domain { font-size: var(--fs-1); color: var(--ink-3); }

.snippet-copy { margin-left: auto; flex: none; }

.snippet-code {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: var(--fs-2);
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-all;
}

.copy-helper {
  position: fixed;
  top: -1000px;
  left: -1000px;
  opacity: 0;
}

/* ---------- 抽屉 ---------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: var(--backdrop);
  animation: fade-in var(--t-2) var(--ease);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  animation: drawer-in var(--t-3) var(--ease);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}

.drawer-head h3 { font-size: var(--fs-4); font-weight: 600; }

.drawer-body { padding: var(--sp-5); overflow: auto; }



.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}

.meta-item { min-width: 0; }

.meta-key {
  display: block;
  margin-bottom: 2px;
  font-size: var(--fs-1);
  color: var(--ink-3);
}

.meta-val {
  display: block;
  font-size: var(--fs-3);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer h4 {
  margin: var(--sp-5) 0 var(--sp-2);
  font-size: var(--fs-2);
  font-weight: 600;
  color: var(--ink-2);
}

.mini { font-size: var(--fs-2); }
.mini th, .mini td { padding: 8px var(--sp-2); }
.mini thead th { background: transparent; border-bottom: 1px solid var(--line-2); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- 进入动效 ---------- */

.page { animation: page-in var(--t-3) var(--ease); }

@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1240px) {
  :root { --side: 228px; }
  .main { padding: var(--sp-7) var(--sp-6) var(--sp-9); }
}

@media (max-width: 1080px) {
  :root { --side: 212px; }
  .kpi-cell { padding: var(--sp-4); }
  .kpi-value { font-size: var(--fs-7); }
  .home-table .col-site { width: 22%; }
}

/* 手机/平板：顶部窄栏 + 侧栏抽屉 */
@media (max-width: 900px) {
  body.is-nav-open { overflow: hidden; }

  .appbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    height: 54px;
    padding: 0 var(--sp-3);
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }

  .appbar-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-left: -6px;
    flex: none;
    border-radius: var(--r-1);
    color: var(--ink-2);
    transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
  }
  .appbar-btn:hover { background: var(--surface-3); color: var(--ink); }
  .appbar-btn .icon { width: 18px; height: 18px; }

  .appbar-brand { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
  .appbar-mark { display: grid; place-items: center; width: 24px; height: 24px; flex: none; }
  .appbar-mark svg { width: 24px; height: 24px; display: block; }
  .appbar-name { font-size: var(--fs-5); font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }

  .shell { grid-template-columns: minmax(0, 1fr); }

  /* 侧栏收成左侧抽屉：默认滑出屏幕，打开时浮在内容上 */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(86vw, 300px);
    height: 100%;
    padding: var(--sp-5) var(--sp-3) calc(var(--sp-4) + env(safe-area-inset-bottom));
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-3);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--t-3) var(--ease), visibility var(--t-3) var(--ease);
  }

  .sidebar.is-open { transform: none; visibility: visible; }

  .sidebar-close {
    position: absolute;
    top: var(--sp-3);
    right: var(--sp-2);
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--r-1);
    color: var(--ink-3);
    transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
  }
  .sidebar-close:hover { background: var(--surface-3); color: var(--ink); }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: var(--backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-2) var(--ease);
  }
  .nav-backdrop.is-open { opacity: 1; pointer-events: auto; }

  .brand { padding-right: var(--sp-6); }
  .sidebar-foot { padding-bottom: env(safe-area-inset-bottom); }

  .main {
    padding: var(--sp-4) var(--sp-3) calc(var(--sp-8) + env(safe-area-inset-bottom));
  }

  .page-head { flex-direction: column; align-items: stretch; gap: var(--sp-2); margin-bottom: var(--sp-4); }
  .home-top { grid-template-columns: minmax(0, 1fr); }

  .head-tools { flex-wrap: wrap; justify-content: space-between; row-gap: var(--sp-2); }

  /* 站点切换挪到手机顶栏右上角，固定在顶栏里，滚动也跟着走 */
  .head-tools .scope {
    position: fixed;
    top: 9px;
    right: 10px;
    z-index: 45;
    order: 1;
  }

  .head-tools .scope-card {
    height: 36px;
    max-width: 168px;
    background: var(--surface);
  }

  .head-tools .scope-name { max-width: 96px; }
  .head-tools .scope-menu {
    top: calc(100% + 10px);
    width: min(300px, calc(100vw - 20px));
  }
  #range { order: 3; flex: 1 1 100%; }
  .segmented { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .seg { padding: 0 var(--sp-2); }
  .status { display: none; }

  .kpi,
  .kpi.is-5,
  .kpi.is-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .kpi-cell { padding: var(--sp-4); }
  .kpi-cell:nth-child(odd)::before { display: none; }
  .kpi-cell:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpi-cell:nth-child(n + 3)::before { top: 0; bottom: 0; }

  .columns { grid-template-columns: minmax(0, 1fr); }

  .snippet { padding: var(--sp-3) var(--sp-4); }
  .snippet-code { padding: var(--sp-2) var(--sp-3); }

  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 首页表 → 卡片 */
@media (max-width: 900px) {
  .table-wrap { overflow: visible; }

  .home-table { display: none; }

  .home-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
    padding: var(--sp-4);
  }

  .site-card {
    display: block;
    padding: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    transition: border-color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease);
  }

  .site-card:active { border-color: var(--accent-ring); }

  .site-card-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--line);
  }

  .site-card-head .tile { width: 28px; height: 28px; }
  .site-card-name { font-size: var(--fs-4); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .site-card-meta { margin-left: auto; font-size: var(--fs-1); color: var(--ink-3); white-space: nowrap; }
  .site-card-head .icon { width: 14px; height: 14px; color: var(--ink-4); }

  .mini-grid {
    display: grid;
    grid-template-columns: 46px repeat(3, minmax(0, 1fr));
    gap: 6px var(--sp-1);
    padding-top: var(--sp-3);
    font-size: var(--fs-2);
    font-variant-numeric: tabular-nums;
    align-items: baseline;
  }

  .mini-grid .mg-head { font-size: 10.5px; color: var(--ink-4); text-align: right; }
  .mini-grid .mg-head:first-child { text-align: left; }
  .mini-grid .mg-period { font-size: var(--fs-1); color: var(--ink-3); }
  .mini-grid .mg-val { text-align: right; color: var(--ink); }
  .mini-grid .mg-val.muted { color: var(--ink-4); }
}

/* 明细表 → 两列卡片 */
@media (max-width: 640px) {
  .panel { border-radius: var(--r-3); }
  .panel-head { padding: var(--sp-3) var(--sp-4); min-height: 48px; flex-wrap: wrap; }
  .panel-head h2 { font-size: var(--fs-3); }
  .head-inline { width: 100%; flex-wrap: nowrap; }
  #session-count { flex: none; font-size: var(--fs-1); white-space: nowrap; }

  .search { flex: 1; min-width: 0; }
  .search input { width: 100%; max-width: none; }

  /* 明细表和小表格统一转成带标签的卡片 */
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td,
  .data-table th,
  .mini,
  .mini tbody,
  .mini tr,
  .mini td,
  .mini th { display: block; }

  .data-table thead,
  .mini thead { display: none; }

  .data-table tbody,
  .mini tbody { padding: var(--sp-2); }

  .data-table tbody tr,
  .mini tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--sp-3);
    padding: 8px var(--sp-3) 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-2);
    background: var(--surface);
  }

  .data-table tbody tr + tr,
  .mini tbody tr + tr { margin-top: var(--sp-2); }
  .data-table tbody tr:hover { background: var(--surface); }

  /* 今日流量这类多指标行：3 列排，少占一行 */
  .data-table tbody tr:has(> th.period) { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .data-table td,
  .data-table th,
  .mini td,
  .mini th {
    padding: 4px 0 0;
    border: 0;
    font-size: var(--fs-2);
    text-align: left !important;
  }

  .data-table td::before,
  .data-table th::before,
  .mini td::before,
  .mini th::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0;
    font-size: 10.5px;
    line-height: 1.3;
    color: var(--ink-4);
  }

  .data-table td.cell-action::before { content: none; }

  .data-table td:first-child,
  .mini td:first-child { grid-column: 1 / -1; }

  /* 首页已在上个断点切成卡片，这里强制收起桌面表格 */
  .table-wrap > .home-table,
  .table-wrap > .home-table thead,
  .table-wrap > .home-table tbody,
  .table-wrap > .home-table tr,
  .table-wrap > .home-table td,
  .table-wrap > .home-table th { display: none; }

  /* 流量质量：原因和 UA 占满一行，挤两列会看不全 */
  #pane-quality td[data-label="原因"],
  #pane-quality td[data-label="UA"] { grid-column: 1 / -1; }
  .cell-main { font-size: var(--fs-3); }
  .cell-sub { white-space: normal; max-width: none; }
  .empty-cell { grid-column: 1 / -1; padding: var(--sp-6) 0 !important; }
  .empty-cell::before { content: none !important; }

  .home-cards { grid-template-columns: minmax(0, 1fr); padding: var(--sp-3); }

  .live-split { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); padding: var(--sp-4); }
  .line-plot { height: 148px; }
  .line-plot.is-tall { height: 176px; }
}

@media (max-width: 430px) {
  .main { padding: var(--sp-4) var(--sp-3) var(--sp-7); }
  .page-title { font-size: var(--fs-6); }
  .kpi-value { font-size: var(--fs-7); }
  .kpi-cell { padding: var(--sp-3); }
  .mini-grid { grid-template-columns: 42px repeat(3, minmax(0, 1fr)); gap: 5px var(--sp-1); }
  .nav-item { font-size: 11.5px; }
  .site-card { padding: var(--sp-3); }
}

@media (hover: none) {
  .data-table tbody tr:hover { background: transparent; }
  .row-enter:hover .icon { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 转化目标、页面上下游、面板工具（后加） ---------- */

.panel-tools { display: flex; align-items: center; gap: var(--sp-3); }

/* 表格里能点的 URL 统一用主色，鼠标移上去加深并加下划线 */
.cell-link {
  font: inherit;
  color: var(--accent);
  text-align: left;
  border-radius: var(--r-1);
  overflow-wrap: anywhere;
  transition: color var(--t-1) var(--ease);
}

.cell-link:hover { color: var(--accent-2); text-decoration: underline; }
.cell-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 表格里域名/路径后面的小跳转图标，点开新标签 */
.ext-link {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  border-radius: var(--r-1);
  color: var(--ink-3);
  vertical-align: -3px;
  transition: color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}

.ext-link .icon { width: 13px; height: 13px; stroke-width: 2; }
.ext-link:hover { color: var(--accent); }
.ext-link:active { color: var(--accent-2); }
.ext-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 触屏上手指按得到 */
@media (max-width: 900px) {
  .ext-link { width: 22px; height: 22px; margin-left: 4px; vertical-align: -5px; }
  .ext-link .icon { width: 14px; height: 14px; }
}

.flow-head {
  margin-bottom: var(--sp-4);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-2);
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.flow-block + .flow-block { margin-top: var(--sp-5); }

.flow-block h4 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-2);
  font-weight: 600;
  color: var(--ink-3);
}

.flow-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
}

.flow-list li:last-child { border-bottom: 0; }

.flow-path {
  min-width: 0;
  font-size: var(--fs-3);
  overflow-wrap: anywhere;
}

.flow-count { flex: none; white-space: nowrap; font-size: var(--fs-2); color: var(--ink-3); }

select.field-input { cursor: pointer; }

/* ---------- 可排序表头：点一下降序、再点升序、第三下还原 ---------- */
.data-table thead th.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--t-1) var(--ease);
}

.data-table thead th.th-sortable:hover { color: var(--ink); }

.data-table thead th.th-sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  color: var(--ink);
}

.data-table thead th.th-sortable.is-sorted { color: var(--ink); font-weight: 600; }
.data-table thead th.th-sortable.is-sorted .sort-arrow { color: var(--accent); }

/* 明细表列多，窄一点的屏先把定宽数字列收窄，不出现横向滚动 */
@media (max-width: 1380px) {
  .data-table .col-num { width: 84px; }
}

@media (max-width: 1180px) {
  .data-table .col-num { width: 76px; }
  .data-table .col-wide { width: 104px; }
  .data-table thead th { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .data-table th,
  .data-table td { padding-left: var(--sp-3); padding-right: var(--sp-3); }

  /* 列太多放不下时，先把占比、平均浏览页数这类次要列收掉，保证名称列有位置 */
  .data-table .col-secondary { width: 0; }
  .data-table thead th.is-secondary,
  .data-table td.is-secondary { display: none; }
}

/* 平板及以下：占比、平均浏览页数这类次要列直接收掉，只留核心指标 */
@media (max-width: 900px) {
  .data-table .col-num { width: 64px; }
  .data-table .col-wide { width: 96px; }
}

/* 再窄一点：新访客数、会话数这类补充列也收掉，保证名称列不挤成一条 */
@media (max-width: 740px) {
  .data-table .col-compact { width: 0; }
  .data-table thead th.is-compact,
  .data-table td.is-compact { display: none; }
}

/* 转化漏斗：一步一行，条的相对长度就是这一步的留存 */
.funnel-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
}

.funnel-item {
  display: grid;
  grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
}

.funnel-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: var(--fs-3);
}

.funnel-target {
  font-size: var(--fs-2);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.funnel-track {
  height: 22px;
  border-radius: var(--r-1);
  background: var(--surface-3);
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  width: var(--w, 0%);
  border-radius: var(--r-1);
  background: var(--accent);
}

.funnel-meta {
  font-size: var(--fs-2);
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.funnel-empty {
  padding: var(--sp-8) var(--sp-5);
  font-size: var(--fs-2);
  color: var(--ink-3);
}

@media (max-width: 740px) {
  .funnel-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .funnel-track { grid-column: 1 / -1; }
}

/* 维度标签多到十几个，放不下就换行，不横向滚动 */
#dims-tabs {
  flex-wrap: wrap;
  height: auto;
  max-width: 100%;
}

@media (max-width: 740px) {
  #dims-tabs { justify-content: flex-start; }
}

/* ---------- 加载骨架：数据没回来之前先占好版位，别让页面看起来是空的 ---------- */
@keyframes sk-shimmer {
  from { background-position: -180px 0; }
  to { background-position: 220px 0; }
}

.sk {
  display: block;
  height: 10px;
  width: 68%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-2) 37%, var(--surface-2) 63%);
  background-size: 400px 100%;
  animation: sk-shimmer 1.3s linear infinite;
}

.sk-row td:first-child .sk { width: 88%; }
.sk-row td.num .sk { margin-left: auto; width: 56%; }
.sk-row .sk-sm { height: 8px; }

/* 图表容器是 flex 布局，用绝对定位铺满绘图区才不会被压扁 */
.sk-chart {
  position: absolute;
  inset: var(--sp-5) var(--sp-5) 24px;
  border-radius: var(--r-3);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-2) 37%, var(--surface-2) 63%);
  background-size: 600px 100%;
  animation: sk-shimmer 1.6s linear infinite;
}

.sk-kpi .sk { width: 52%; }
.sk-kpi .sk-lg { height: 22px; width: 66%; margin-top: 10px; }
.sk-kpi .sk-sub { height: 8px; width: 40%; margin-top: 10px; opacity: .7; }

@media (prefers-reduced-motion: reduce) {
  .sk,
  .sk-chart { animation: none; }
}
/* 窄屏表格会变成卡片，骨架行只留一条灰条，免得挤成一堆 */
@media (max-width: 640px) {
  .sk-row {
    display: block;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
  }

  .sk-row td { display: none; }

  .sk-row td:first-child {
    display: block;
    padding: 0;
    border: 0;
  }

  .sk-row td:first-child .sk { width: 52%; margin-left: 0; }
}
/* 实时 / 趋势的折线图自身没有内边距，骨架直接铺满绘图区 */
.line-plot .sk-chart { inset: 0; }
/* 列表类容器（采集字段分组等）的占位块 */
.sk-block {
  height: 96px;
  border-radius: var(--r-3);
  margin-bottom: var(--sp-4);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-2) 37%, var(--surface-2) 63%);
  background-size: 600px 100%;
  animation: sk-shimmer 1.6s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .sk-block { animation: none; }
}