/* BI dashboard tokens: cool slate workspace + vibrant chart accents */
:root {
  --bg: #eef1f5;
  --bg-subtle: #e4e9ef;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #d0d7e2;
  --border-strong: #b8c2d0;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-subtle: #ecfdf9;
  --accent-border: #99f6e4;
  --warn: #f97316;
  --danger: #ef4444;
  --good: #38bdf8;
  --excellent: #059669;
  --chart-1: #14b8a6;
  --chart-2: #38bdf8;
  --chart-3: #fb7185;
  --chart-4: #fbbf24;
  --chart-5: #22d3ee;
  --chart-6: #a78bfa;
  --persona-1: #e11d48;
  --persona-2: #eab308;
  --persona-3: #2563eb;
  --persona-4: #16a34a;
  --persona-5: #7c3aed;
  --nav-width: 232px;
  --header-h: 52px;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "IBM Plex Sans", "SF Mono", ui-monospace, monospace;
  --transition-fast: 0.05s ease;
  --transition-page: 0s;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  overflow-x: clip;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--nav-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-logo {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-list > li {
  margin: 0 8px 2px;
}

.nav-group {
  margin-bottom: 6px;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
}

.nav-group-toggle:hover {
  background: var(--bg);
}

.nav-group.is-active-group > .nav-group-toggle {
  color: var(--accent-hover);
}

.nav-group-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.nav-group.is-open > .nav-group-toggle .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-sublist {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  display: none;
}

.nav-group.is-open > .nav-sublist {
  display: block;
}

.nav-subitem {
  margin: 0 0 1px;
}

.nav-list a {
  display: block;
  padding: 8px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.nav-sublist a {
  padding: 7px 10px 7px 14px;
  font-size: 13px;
}

.nav-list a small {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.nav-list a:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-list a.active {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  color: var(--accent-hover);
  font-weight: 600;
}

.nav-list a.active small {
  color: var(--text-muted);
  font-weight: 400;
}

/* Main */
.main {
  margin-left: var(--nav-width);
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  min-width: 0;
}

.global-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-width: 160px;
  max-width: 280px;
  flex: 1 1 220px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.global-search-icon {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  flex: 0 0 auto;
}

.global-chart-search {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.global-chart-search::placeholder {
  color: var(--text-muted);
}

.ai-assistant-toggle {
  appearance: none;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
}

.ai-assistant-toggle:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-subtle);
}

.ai-assistant-toggle.is-open {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.ai-assistant-icon {
  width: 18px;
  height: 18px;
  display: block;
  background: currentColor;
  -webkit-mask-image: url("../assets/ai-assistant-icon.png?v=20260911-mirror");
  mask-image: url("../assets/ai-assistant-icon.png?v=20260911-mirror");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transform-origin: center center;
  animation: ai-assistant-icon-spin 30s linear infinite;
}

@keyframes ai-assistant-icon-spin {
  0%,
  98.333% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-assistant-icon {
    animation: none;
  }
}

.ai-assistant-panel {
  position: fixed;
  z-index: 640;
  display: flex;
  flex-direction: column;
  min-width: 300px;
  min-height: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}

.ai-assistant-panel[hidden] {
  display: none !important;
}

.ai-assistant-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  background: #f8fafc;
}

.ai-assistant-head:active {
  cursor: grabbing;
}

.ai-assistant-head-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
  flex: none;
}

.ai-assistant-head-text {
  flex: 1;
  min-width: 0;
}

.ai-assistant-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.ai-assistant-meta {
  margin-top: 1px;
  font-size: 11px;
  color: var(--text-muted);
}

.ai-assistant-close {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.ai-assistant-close:hover {
  background: #e2e8f0;
  color: var(--text);
}

.ai-assistant-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: #fbfcfe;
}

.ai-assistant-empty,
.ai-health-warn {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  padding: 8px 4px 16px;
}

.ai-health-warn {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.ai-msg {
  max-width: 100%;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.ai-msg--user {
  margin-left: 28px;
}

.ai-msg--user .ai-msg-text {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: 8px 8px 4px 8px;
  padding: 8px 10px;
}

.ai-msg--assistant .ai-msg-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px 8px 8px 4px;
  padding: 8px 10px;
}

.ai-msg-text p {
  margin: 0.45em 0;
}

.ai-msg-text p:first-child,
.ai-msg-text ul:first-child,
.ai-msg-text ol:first-child,
.ai-msg-text .ai-md-table-wrap:first-child {
  margin-top: 0;
}

.ai-msg-text p:last-child,
.ai-msg-text ul:last-child,
.ai-msg-text ol:last-child,
.ai-msg-text .ai-md-table-wrap:last-child {
  margin-bottom: 0;
}

.ai-msg-text .ai-md-h {
  font-weight: 650;
  margin: 0.55em 0 0.25em;
}

.ai-msg-text ul,
.ai-msg-text ol {
  margin: 0.4em 0 0.5em;
  padding-left: 1.25em;
}

.ai-msg-text li {
  margin: 0.18em 0;
}

.ai-msg-text code {
  font-size: 12px;
  background: #f1f5f9;
  border-radius: 3px;
  padding: 0.05em 0.3em;
}

.ai-md-table-wrap {
  margin: 0.5em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-msg-text table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
  line-height: 1.45;
}

.ai-msg-text th,
.ai-msg-text td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.ai-msg-text th {
  background: #f8fafc;
  font-weight: 650;
}

.ai-msg.is-error .ai-msg-text,
.ai-msg--assistant.is-error .ai-msg-text {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.ai-msg-pending {
  color: var(--text-muted);
}

.ai-progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ai-progress-step {
  position: relative;
  padding-left: 12px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-muted);
}

.ai-progress-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.ai-progress-step.is-done {
  opacity: 0.55;
}

.ai-progress-step.is-active {
  color: var(--text-secondary);
}

.ai-progress-step.is-active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  animation: ai-progress-pulse 1.1s ease-in-out infinite;
}

@keyframes ai-progress-pulse {
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-progress-step.is-active::before {
    animation: none;
  }
}

.ai-chart-link {
  appearance: none;
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: var(--accent-hover);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-chart-card {
  appearance: none;
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 8px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.ai-chart-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.ai-chart-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.ai-chart-no {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-hover);
}

.ai-chart-card-title {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.ai-chart-card-preview {
  display: block;
  width: 100%;
  margin-top: 8px;
  max-height: 140px;
  object-fit: cover;
  object-position: top;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
}

.ai-chart-card-preview.is-placeholder {
  height: 36px;
  max-height: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  object-fit: unset;
}

.ai-assistant-composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-assistant-input {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
}

.ai-assistant-input:focus {
  border-color: var(--accent);
}

.ai-assistant-send {
  appearance: none;
  flex: none;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ai-assistant-send:hover {
  background: var(--accent-hover);
}

.ai-assistant-send:disabled {
  opacity: 0.55;
  cursor: default;
}

.ai-assistant-resize {
  position: absolute;
  z-index: 2;
}

.ai-assistant-resize--e {
  top: 28px;
  right: 0;
  width: 8px;
  bottom: 12px;
  cursor: ew-resize;
}

.ai-assistant-resize--s {
  left: 8px;
  right: 12px;
  bottom: 0;
  height: 8px;
  cursor: ns-resize;
}

.ai-assistant-resize--se {
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.chart-panel.is-ai-focus {
  outline: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
}

.search-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.search-results-summary {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.search-page-group {
  margin-bottom: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.search-page-group:last-child {
  border-bottom: 0;
}

.search-page-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.search-page-group-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.search-page-group-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.search-page-group-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.search-goto-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: calc(var(--radius-sm) + 1px);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.22);
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-goto-page:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.28);
}

.search-hit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.search-hit-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.search-indexing-note {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.search-chart-pending {
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.search-page-group-mount .page-sticky-controls {
  margin-left: 0;
  margin-right: 0;
}

.load-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 240px;
  min-width: 148px;
  max-width: 280px;
}

.load-progress[hidden] {
  display: none;
}

.load-progress-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.load-progress-track {
  flex: 1;
  height: 4px;
  min-width: 56px;
  background: var(--bg-subtle);
  border-radius: 99px;
  overflow: hidden;
}

.load-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.2s ease;
}

.topbar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Page / chart metric help (? icon + tooltip) */
.heading-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.help-tip-btn {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
  font-family: var(--font-mono);
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.help-tip-btn:hover,
.help-tip-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: var(--accent-subtle);
  outline: none;
}

.help-tip-popover {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1100;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 10px 12px;
  background: var(--text);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.22);
  white-space: normal;
  text-align: left;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.help-tip-popover.is-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.help-tip-list {
  margin: 0;
  padding-left: 1.15em;
  list-style: disc;
}

.help-tip-list li {
  margin: 0;
  padding: 0;
}

.help-tip-list li + li {
  margin-top: 6px;
}

@media (max-width: 768px) {
  .help-tip-popover {
    max-width: min(280px, calc(100vw - 24px));
  }
}

.content {
  padding: 16px 20px 32px;
  min-width: 0;
  overflow-x: clip;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted, #64748b);
  background: rgba(15, 118, 110, 0.06);
  border-left: 3px solid var(--accent, #0f766e);
  border-radius: 0 6px 6px 0;
}

@media (prefers-reduced-motion: reduce) {
  .nav-list a,
  .toggle-btn,
  .menu-toggle,
  .heatmap-link,
  .help-tip-btn,
  .help-tip-popover {
    transition: none;
  }
}

.subsection {
  margin-bottom: 22px;
}

.subsection-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.subsection h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: 12px;
  /* 默认同行等高对齐；单独调高的图卡用 align-self:start 脱离拉伸 */
  align-items: stretch;
  min-width: 0;
}

/* 固定每行两张 */
.chart-grid-2,
#page-baidu_source .chart-grid,
#page-baidu_pages .chart-grid,
#page-wechat_visit .chart-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

#page-survey_ib_compare .chart-grid-ib-compare-full,
#page-survey_siyu_compare .chart-grid-ib-compare-full,
#page-survey_siyu_rate .chart-grid-ib-compare-full,
#page-survey_jianya_compare .chart-grid-ib-compare-full,
#page-survey_channel_compare .chart-grid-ib-compare-full,
#page-survey_life_stage_compare .chart-grid-ib-compare-full,
#page-survey_tier_compare .chart-grid-ib-compare-full,
#page-survey_user_compare .chart-grid-ib-compare-full,
#page-survey_nonresponse_calibrate .chart-grid-ib-compare-full {
  grid-template-columns: minmax(0, 1fr);
}

#page-survey_ib_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_siyu_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_siyu_rate .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_jianya_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_channel_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_life_stage_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_tier_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_user_compare .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel,
#page-survey_nonresponse_calibrate .chart-grid-ib-compare-full.chart-grid--free-width > .chart-panel {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
}

/* 自定义宽度：按行 flex，断行锁定每行张数；图卡宽度之和不超过行宽，避免重叠 */
.chart-grid.chart-grid--free-width,
.chart-grid-2.chart-grid--free-width,
#page-baidu_source .chart-grid.chart-grid--free-width,
#page-baidu_pages .chart-grid.chart-grid--free-width,
#page-wechat_visit .chart-grid-2.chart-grid--free-width {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  grid-template-columns: unset;
}

.chart-grid--free-width > .chart-row-break {
  flex: 0 0 100%;
  width: 100%;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  pointer-events: none;
}

.chart-grid--free-width > .chart-panel {
  flex: 1 1 0;
  min-width: min(100%, 320px);
  box-sizing: border-box;
}

.chart-grid--free-width > .chart-panel.is-custom-width {
  flex: 0 0 auto;
  max-width: none;
  min-width: 0;
}

/* 有自定义高度时取消行内 stretch，避免拖高一张带动同行其它图 */
.chart-grid.chart-grid--free-height,
.chart-grid-2.chart-grid--free-height,
.chart-grid--free-width.chart-grid--free-height,
#page-baidu_source .chart-grid.chart-grid--free-height,
#page-baidu_pages .chart-grid.chart-grid--free-height,
#page-wechat_visit .chart-grid-2.chart-grid--free-height {
  align-items: start;
}

.chart-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  min-width: 0;
  max-width: 100%;
}

.chart-panel-head {
  margin-bottom: 8px;
}

.chart-panel-head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.chart-panel-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
}

.chart-panel-head-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  overflow: visible;
}

.chart-panel-toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 8px;
}

.persona-scatter-axis-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.persona-scatter-axis-row > span {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted, #667085);
  min-width: 2.5em;
}

.persona-scatter-axis-row .toggle-btn {
  padding: 5px 10px;
  font-size: 12px;
}

/* Chart series picker (#baidu_pages) */
.chart-series-bar {
  margin-bottom: 0;
  flex-wrap: nowrap;
  max-width: 100%;
}

.chart-series-bar .series-picker {
  position: relative;
  flex-shrink: 0;
}

.chart-series-bar .series-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chart-series-bar .series-picker-btn[aria-expanded="true"] {
  background: var(--surface);
  color: var(--accent-hover);
  font-weight: 600;
  border: 1px solid var(--accent-border);
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.14);
}

.series-picker-count {
  font-variant-numeric: tabular-nums;
  color: inherit;
  opacity: 0.85;
  font-weight: 600;
}

.series-picker-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 200;
  width: min(280px, calc(100vw - 32px));
  max-height: min(320px, 55vh);
  display: none;
  flex-direction: column;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.series-picker-popover.is-open {
  display: flex;
}

.series-picker-popover[hidden] {
  display: none !important;
}

.series-picker-search {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-subtle);
}

.series-picker-search::placeholder {
  color: var(--text-muted);
}

.series-picker-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.series-picker-shortcuts {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.series-picker-shortcut {
  padding: 2px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 11px;
  font-family: var(--font);
  color: var(--accent-hover);
  cursor: pointer;
}

.series-picker-shortcut:hover {
  background: var(--accent-subtle);
  color: var(--accent-hover);
}

.series-picker-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.series-picker-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.series-picker-item:hover {
  background: var(--bg-subtle);
}

.series-picker-item.is-hidden {
  display: none;
}

.series-picker-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 2px 0 0;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
}

.series-picker-item input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' d='M2 6l3 3 5-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px;
}

.series-picker-label {
  flex: 1;
  line-height: 1.35;
  word-break: break-word;
}

.series-picker-total {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.series-picker-empty {
  margin: 0;
  padding: 14px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.series-picker-empty[hidden] {
  display: none;
}

@media (max-width: 768px) {
  .chart-series-bar {
    flex-wrap: wrap;
  }

  .series-picker-popover {
    right: auto;
    left: 0;
    width: min(300px, calc(100vw - 24px));
  }
}

.toggle-bar--inline {
  margin-bottom: 0;
}

.data-end-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-end-label .help-tip-btn {
  width: 14px;
  height: 14px;
  font-size: 10px;
  margin-left: 2px;
}

.archive-coverage {
  margin: 0 0 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
}

.ov-row-end {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
}

.track-kpi-end {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.chart-series-focus-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 6px;
  padding: 0 2px 2px;
}

.chart-series-bulk-btn {
  appearance: none;
  border: 1px solid var(--border-strong, #cbd5e1);
  background: var(--surface, #fff);
  color: var(--text-secondary, #334155);
  font: 500 12px/1.2 var(--font, sans-serif);
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.chart-series-bulk-btn:hover {
  border-color: var(--accent, #0d9488);
  color: var(--accent, #0d9488);
}

.chart-series-focus-hint {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.chart-wrap {
  position: relative;
  height: 260px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.chart-wrap.is-empty > canvas {
  opacity: 1;
  filter: none;
}

.chart-empty-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  color: #334155;
  /* 半透明罩层：底下空图坐标轴/网格仍可见 */
  background: rgba(248, 250, 252, 0.7);
  pointer-events: none;
  border-radius: 4px;
}

.chart-wrap.scatter {
  height: 440px;
}

.chart-wrap.tall {
  height: 320px;
}

.chart-wrap.tall-2x {
  height: 520px;
}

.chart-wrap.path-rank {
  height: 820px;
}

.chart-wrap.funnel-sankey {
  height: 820px;
  min-height: 820px;
}

.chart-wrap.funnel-sankey .echarts-host {
  min-height: 760px;
}

.chart-grid-facet {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.chart-wrap.facet {
  height: 220px;
}

.chart-panel-note {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.chart-wrap.pie {
  height: 300px;
  max-width: 440px;
}

.chart-ymax-host {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: none;
}

.chart-ymax-host--right {
  align-items: flex-end;
}

.chart-ymax-btn,
.chart-ymax-panel,
.chart-ymax-reset {
  pointer-events: auto;
}

.chart-ymax-btn {
  appearance: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong, #cbd5e1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-secondary, #334155);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.chart-ymax-btn:hover,
.chart-ymax-host.is-open .chart-ymax-btn {
  border-color: var(--accent, #0d9488);
  color: var(--accent, #0d9488);
}

.chart-ymax-btn.is-custom {
  border-color: var(--accent, #0d9488);
  background: #ecfdf8;
  color: var(--accent, #0d9488);
}

.chart-ymax-btn-icon {
  display: block;
  transform: translateY(-0.5px);
}

.chart-ymax-panel {
  margin-top: 6px;
  width: 188px;
  padding: 10px 10px 8px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: var(--surface, #fff);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.chart-ymax-host--right .chart-ymax-panel {
  margin-right: 0;
}

.chart-ymax-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text, #0f172a);
  margin-bottom: 8px;
}

.chart-ymax-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.chart-ymax-slider-row .muted {
  font-size: 10px;
  color: var(--text-muted, #64748b);
  flex: 0 0 auto;
}

.chart-ymax-slider {
  flex: 1 1 auto;
  width: 100%;
  accent-color: var(--accent, #14b8a6);
  cursor: pointer;
}

.chart-ymax-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.chart-ymax-input {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  height: 28px;
  padding: 2px 8px;
  border: 1px solid var(--border-strong, #cbd5e1);
  border-radius: 4px;
  font: 500 12px/1.2 var(--font, sans-serif);
  color: var(--text, #0f172a);
}

.chart-ymax-input:focus {
  outline: none;
  border-color: var(--accent, #0d9488);
}

.chart-ymax-unit {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  min-width: 1em;
}

.chart-ymax-reset {
  appearance: none;
  width: 100%;
  border: 1px solid var(--border-strong, #cbd5e1);
  background: var(--surface, #fff);
  color: var(--text-secondary, #334155);
  font: 500 12px/1.2 var(--font, sans-serif);
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.chart-ymax-reset:hover {
  border-color: var(--accent, #0d9488);
  color: var(--accent, #0d9488);
}

.chart-analyze-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 8;
  appearance: none;
  padding: 3px 8px;
  border: 1px solid var(--border-strong, #cbd5e1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-secondary, #334155);
  font: 500 12px/1.2 var(--font, sans-serif);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.chart-analyze-btn:hover,
.chart-analyze-btn.is-open {
  border-color: var(--accent, #0d9488);
  color: var(--accent, #0d9488);
}

.page.is-chart-resize-on .chart-analyze-btn,
body.is-chart-resize-on .page.active .chart-analyze-btn {
  right: 22px;
  bottom: 22px;
}

.chart-insight-float {
  position: fixed;
  z-index: 500;
  display: flex;
  flex-direction: column;
  min-width: 280px;
  min-height: 160px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d0d7e2);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}

.chart-insight-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 10px 8px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  cursor: grab;
  user-select: none;
  background: #f8fafc;
}

.chart-insight-head:active {
  cursor: grabbing;
}

.chart-insight-head-text {
  flex: 1;
  min-width: 0;
}

.chart-insight-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #0f172a);
  line-height: 1.35;
}

.chart-insight-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted, #64748b);
  line-height: 1.35;
}

.chart-insight-close {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted, #64748b);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.chart-insight-close:hover {
  background: #e2e8f0;
  color: var(--text, #0f172a);
}

.chart-insight-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary, #334155);
}

.chart-insight-list {
  margin: 0;
  padding-left: 1.35em;
}

.chart-insight-list li {
  margin: 0 0 0.55em;
}

.chart-insight-list li:last-child {
  margin-bottom: 0;
}

.chart-insight-fallback {
  margin: 0;
}

.chart-insight-body mark {
  background: #fef3c7;
  color: var(--text, #0f172a);
  font-weight: 600;
  padding: 0 0.15em;
  border-radius: 2px;
}

.chart-insight-resize {
  position: absolute;
  z-index: 2;
}

.chart-insight-resize--e {
  top: 28px;
  right: 0;
  width: 8px;
  bottom: 12px;
  cursor: ew-resize;
}

.chart-insight-resize--s {
  left: 0;
  right: 12px;
  bottom: 0;
  height: 8px;
  cursor: ns-resize;
}

.chart-insight-resize--se {
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.chart-insight-resize--se::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--border-strong, #b8c2d0);
  border-bottom: 2px solid var(--border-strong, #b8c2d0);
}

/* 页面全局切换：吸顶在 topbar 下方 */
.page-sticky-controls {
  position: sticky;
  top: var(--header-h);
  z-index: 45;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  margin: -16px -20px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.page-sticky-controls-main {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.page-sticky-controls-end {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.chart-resize-sticky-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.chart-resize-reset-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius-sm) + 1px);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.25;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.chart-resize-reset-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--bg-subtle);
}

.page-sticky-controls .toggle-bar {
  margin-bottom: 0;
}

.chart-resize-handle {
  display: none;
  position: absolute;
  z-index: 6;
  background: transparent;
  touch-action: none;
}

.page.is-chart-resize-on .chart-resize-handle,
body.is-chart-resize-on .page.active .chart-resize-handle {
  display: block;
}

.chart-resize-handle--s {
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 8px;
  cursor: ns-resize;
}

.chart-resize-handle--e {
  top: 14px;
  right: 0;
  bottom: 14px;
  width: 8px;
  cursor: ew-resize;
}

.chart-resize-handle--w {
  top: 14px;
  left: 0;
  bottom: 14px;
  width: 8px;
  cursor: ew-resize;
}

.chart-resize-handle--se {
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.chart-resize-handle--sw {
  left: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
}

.chart-resize-handle--nw {
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.chart-resize-handle--s::after,
.chart-resize-handle--e::after,
.chart-resize-handle--w::after,
.chart-resize-handle--se::after,
.chart-resize-handle--sw::after,
.chart-resize-handle--nw::after {
  content: "";
  position: absolute;
  background: var(--accent, #14b8a6);
  opacity: 0.35;
  border-radius: 2px;
}

.chart-resize-handle--s::after {
  left: 30%;
  right: 30%;
  top: 2px;
  height: 3px;
}

.chart-resize-handle--e::after {
  top: 30%;
  bottom: 30%;
  left: 2px;
  width: 3px;
}

.chart-resize-handle--w::after {
  top: 30%;
  bottom: 30%;
  right: 2px;
  width: 3px;
}

.chart-resize-handle--se::after {
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent, #14b8a6);
  border-bottom: 2px solid var(--accent, #14b8a6);
  background: transparent;
  opacity: 0.7;
  border-radius: 0;
}

.chart-resize-handle--sw::after {
  left: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--accent, #14b8a6);
  border-bottom: 2px solid var(--accent, #14b8a6);
  background: transparent;
  opacity: 0.7;
  border-radius: 0;
}

.chart-resize-handle--nw::after {
  left: 3px;
  top: 3px;
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--accent, #14b8a6);
  border-top: 2px solid var(--accent, #14b8a6);
  background: transparent;
  opacity: 0.7;
  border-radius: 0;
}

body.is-chart-resizing {
  user-select: none;
  cursor: grabbing;
}

body.is-chart-resizing iframe {
  pointer-events: none;
}

/* Segmented controls */
.toggle-bar {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 12px;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  flex-wrap: wrap;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.toggle-btn {
  padding: 6px 14px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: calc(var(--radius-sm) + 1px);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-secondary);
  line-height: 1.25;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.toggle-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--border);
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--accent-hover);
  font-weight: 600;
  border-color: var(--accent-border);
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.14);
}

.heatmap-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.heatmap-embed-panel {
  padding: 0;
  overflow: visible;
}

.heatmap-chart {
  width: 100%;
  height: 520px;
  overflow: visible;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-subtle) 100%);
}

.heatmap-iframe {
  display: block;
  width: 100%;
  height: 520px;
  border: 0;
  background: #fff;
}

.heatmap-embed-footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.heatmap-open-link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
}

.heatmap-open-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.top20-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.top20-panel .data-table-wrap {
  max-height: 420px;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.data-table th:first-child,
.data-table td:first-child,
.data-table td:nth-child(2) {
  text-align: left;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  z-index: 1;
}

.data-table tbody tr:hover {
  background: var(--accent-subtle);
}

.heatmap-link {
  display: block;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.heatmap-link:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.heatmap-link:active {
  transform: translateY(1px);
}

.heatmap-link span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 3px;
}

.loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.page-loading {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heatmap-intro {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.chart-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
}

.error-box {
  padding: 14px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #991b1b;
  font-size: 13px;
}

.error-box code {
  font-size: 12px;
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Overview / home — change board */
.ov-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ov-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-secondary);
}

.ov-summary-sep {
  color: var(--text-muted);
}

.ov-summary-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.ov-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ov-board > .ov-tabs .toggle-bar {
  margin-bottom: 0;
}

.ov-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ov-pane-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.ov-pane-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.ov-pane-empty {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ov-board--enter.ov-board--play .ov-pane:nth-of-type(1) {
  animation: ov-group-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ov-board--enter.ov-board--play .ov-pane:nth-of-type(2) {
  animation: ov-group-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 80ms;
}

.ov-summary-item--excellent strong {
  color: var(--excellent);
}

.ov-summary-item--good strong {
  color: var(--good);
}

.ov-summary-item--watch strong {
  color: var(--warn);
}

.ov-summary-item--alert strong {
  color: var(--danger);
}

.ov-summary-item--flat strong {
  color: var(--text-muted);
}

.ov-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: visible;
}

.ov-board--enter .ov-group {
  opacity: 0;
  transform: translateY(10px);
}

.ov-board--enter.ov-board--play .ov-group {
  animation: ov-group-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ov-board--enter.ov-board--play .ov-group:nth-of-type(1) {
  animation-delay: 0ms;
}

.ov-board--enter.ov-board--play .ov-group:nth-of-type(2) {
  animation-delay: 60ms;
}

.ov-board--enter.ov-board--play .ov-group:nth-of-type(3) {
  animation-delay: 120ms;
}

.ov-board--enter.ov-board--play .ov-group:nth-of-type(4) {
  animation-delay: 180ms;
}

.ov-board--enter.ov-board--play .ov-group:nth-of-type(5) {
  animation-delay: 240ms;
}

@keyframes ov-group-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ov-group-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle, rgba(0, 0, 0, 0.02));
}

.ov-group-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.ov-group-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.ov-group-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ov-table-head,
.ov-row {
  display: grid;
  grid-template-columns: 72px minmax(88px, 120px) 96px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 104px;
  gap: 8px 10px;
  align-items: center;
  padding: 8px 14px;
  width: 100%;
}

.ov-table-head {
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ov-row {
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.ov-row:last-child {
  border-bottom: none;
}

.ov-row:hover {
  background: var(--accent-subtle);
}

.ov-row-insight {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text-muted);
  padding-top: 2px;
}

.ov-row-domain {
  font-size: 11px;
  color: var(--text-muted);
}

.ov-row-label {
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
}

.ov-row-current {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.ov-row-change {
  min-width: 0;
}

.ov-row-change .ov-change {
  gap: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.ov-row-change .ov-change-pct {
  font-size: 12px;
}

.ov-row-change .ov-change-tag {
  font-size: 11px;
  padding: 1px 5px;
}

.ov-change {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.ov-change-arrow {
  font-weight: 700;
}

.ov-change-pct {
  color: var(--text-muted);
  font-size: 11px;
}

.ov-change-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.05);
}

.ov-change--excellent {
  color: var(--excellent);
}

.ov-change--excellent .ov-change-tag {
  background: rgba(5, 150, 105, 0.14);
  color: var(--excellent);
}

.ov-change--good {
  color: var(--good);
}

.ov-change--good .ov-change-tag {
  background: rgba(56, 189, 248, 0.16);
  color: var(--good);
}

.ov-change--watch {
  color: var(--warn);
}

.ov-change--watch .ov-change-tag {
  background: rgba(249, 115, 22, 0.12);
  color: var(--warn);
}

.ov-change--alert {
  color: var(--danger);
}

.ov-change--alert .ov-change-tag {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.ov-change--flat,
.ov-change--na {
  color: var(--text-muted);
}

.ov-change--flat .ov-change-tag,
.ov-change--na {
  background: transparent;
}

.ov-spark {
  position: relative;
  height: 56px;
  overflow: visible;
}

.ov-spark--empty {
  opacity: 0.25;
}

.ov-board--enter:not(.ov-board--play) .ov-spark canvas {
  opacity: 0;
}

.ov-board--enter.ov-board--play .ov-spark canvas {
  animation: ov-spark-in 280ms ease 120ms both;
}

@keyframes ov-spark-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-secondary);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.menu-toggle:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.menu-toggle:active {
  transform: translateY(1px);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 16px rgba(15, 23, 42, 0.08);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    max-width: 100vw;
  }

  .menu-toggle {
    display: inline-block;
  }

  .chart-grid,
  .chart-grid-2,
  .chart-grid-facet,
  .heatmap-links,
  #page-baidu_source .chart-grid,
  #page-baidu_pages .chart-grid,
  #page-wechat_visit .chart-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-grid--free-width > .chart-panel,
  .chart-grid--free-width > .chart-panel.is-custom-width {
    flex: 0 0 100%;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    margin-left: 0 !important;
  }

  .chart-panel,
  .chart-wrap,
  .chart-wrap canvas,
  .echarts-host {
    max-width: 100%;
  }

  .chart-wrap.pie {
    max-width: 100%;
    width: 100%;
  }

  .ov-table-head,
  .ov-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .ov-table-head {
    display: none;
  }

  .ov-row {
    padding: 12px 14px;
  }

  .ov-spark {
    grid-column: 1 / -1;
    height: 56px;
  }

  .content {
    padding: 12px;
  }

  .page-sticky-controls {
    margin: -12px -12px 14px;
    padding: 10px 12px;
  }

  .topbar {
    padding: 0 12px;
    flex-wrap: wrap;
    min-height: var(--header-h);
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .load-progress {
    flex: 1 1 100%;
    max-width: none;
    margin-bottom: 4px;
  }

}

.track-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}

.track-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.track-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.track-kpi-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.track-kpi-delta {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.track-kpi-delta--up {
  color: var(--accent);
}

.track-kpi-delta--down {
  color: var(--chart-3);
}

.track-kpi-delta--flat {
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }

  .ov-board--enter .ov-group,
  .ov-board--enter .ov-spark canvas {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  .ov-row {
    transition: background var(--transition-fast);
  }

  .ov-row:hover {
    transform: none;
  }
}

.persona-intro {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.nr-cal-intro {
  margin: 0 0 18px;
  display: grid;
  gap: 10px;
}

.nr-cal-intro-block {
  padding: 14px 16px 14px 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left-width: 4px;
}

.nr-cal-intro-block--problem {
  border-left-color: #f59e0b;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.06) 0%, #fff 42%);
}

.nr-cal-intro-block--method {
  border-left-color: var(--accent, #14b8a6);
  background: linear-gradient(90deg, var(--accent-subtle, #ecfdf9) 0%, #fff 48%);
}

.nr-cal-intro-block--result {
  border-left-color: #6366f1;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.06) 0%, #fff 42%);
}

.nr-cal-intro-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nr-cal-intro-block p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.nr-cal-intro-block p + p,
.nr-cal-tags + p {
  margin-top: 10px;
}

.nr-cal-intro-note {
  margin-top: 12px !important;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--text-muted) !important;
  font-size: 13px !important;
}

.nr-cal-kw {
  font-weight: 600;
  color: var(--text);
}

.nr-cal-kw--stat {
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
  padding: 0 0.35em;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.nr-cal-kw--warn {
  color: #b45309;
}

.nr-cal-kw--warn-en {
  color: #92400e;
  font-style: italic;
  font-weight: 500;
}

.nr-cal-kw--accent {
  color: var(--accent-hover, #0d9488);
}

.nr-cal-kw--more {
  color: #047857;
  background: rgba(16, 185, 129, 0.12);
  padding: 0 0.3em;
  border-radius: 4px;
}

.nr-cal-kw--muted {
  font-weight: 500;
  color: var(--text-muted);
}

.nr-cal-kw--reassure {
  color: #4338ca;
  background: rgba(99, 102, 241, 0.1);
  padding: 0 0.3em;
  border-radius: 4px;
}

.nr-cal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.nr-cal-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--surface-muted, #f8fafc);
  border: 1px solid var(--border);
}

.nr-cal-shift {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.nr-cal-shift-col {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.nr-cal-shift-col--less {
  background: rgba(248, 113, 113, 0.06);
  border-color: rgba(248, 113, 113, 0.22);
}

.nr-cal-shift-col--more {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.22);
}

.nr-cal-shift-title {
  flex: 0 0 100%;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.nr-cal-tag--less {
  background: rgba(254, 226, 226, 0.7);
  border-color: rgba(248, 113, 113, 0.25);
  color: #b91c1c;
}

.nr-cal-tag--more {
  background: rgba(209, 250, 229, 0.75);
  border-color: rgba(16, 185, 129, 0.28);
  color: #047857;
}

.nr-cal-intro a {
  color: var(--accent-hover, #0d9488);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid var(--accent-border, #99f6e4);
}

.nr-cal-intro a:hover {
  color: var(--accent, #14b8a6);
  border-bottom-color: var(--accent, #14b8a6);
}

@media (max-width: 720px) {
  .nr-cal-shift {
    grid-template-columns: 1fr;
  }
}

.persona-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .persona-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.persona-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--persona-tone, var(--border));
  border-radius: 12px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.persona-card-kicker {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--persona-tone, var(--text-muted, #667085));
  font-weight: 650;
}

.persona-card-name {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  color: var(--text-strong, #101828);
}

.persona-card-share {
  font-size: 13px;
  color: var(--teal, #0f766e);
  font-weight: 600;
}

.persona-card-lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.persona-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.persona-traits span {
  background: #f2f4f7;
  color: #344054;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  line-height: 1.4;
}

.persona-highlights {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: #344054;
}

.persona-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.persona-metrics div {
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.persona-metrics span {
  font-size: 11px;
  color: var(--text-muted, #667085);
}

.persona-metrics strong {
  font-size: 16px;
  font-weight: 650;
  color: var(--text-strong, #101828);
}

.persona-metrics em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-muted, #667085);
}

.persona-metrics em.up {
  color: #0f766e;
}

.persona-metrics em.down {
  color: #b42318;
}

.persona-talk ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
}

.persona-talk {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.persona-talk-title {
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 4px;
}

@media (max-width: 900px) {
  .persona-grid {
    grid-template-columns: 1fr;
  }
}

.ai-msg-usage {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ai-usage-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-usage-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ai-usage-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-usage-kpi span {
  font-size: 12px;
  color: var(--text-muted);
}

.ai-usage-kpi strong {
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.ai-usage-kpi em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-muted);
}

.ai-usage-table-wrap h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.ai-usage-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.ai-usage-table th,
.ai-usage-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 12px;
}

.ai-usage-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
}

.ai-usage-table td.num {
  text-align: right;
}

.ai-usage-table tbody tr:last-child td {
  border-bottom: 0;
}

.ai-usage-empty,
.ai-usage-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}

.ai-usage-note {
  margin: 0;
}

@media (max-width: 768px) {
  .ai-usage-kpis {
    grid-template-columns: 1fr;
  }

  .ai-assistant-panel {
    min-width: 0;
    width: calc(100vw - 16px) !important;
    left: 8px !important;
    right: 8px;
    max-height: calc(100vh - 16px);
  }

  .ai-assistant-toggle {
    width: 32px;
    height: 32px;
  }
}
