/* =========================================================
   展信包装 · 网站管理后台 v2.0 · 访客来源分析（F3）
   ---------------------------------------------------------
   仅包含「访客来源」页面（#/traffic）的模块化样式；
   复用 app.css 的设计变量与公共组件类（page-head / card /
   table / btn / badge / kpi / seg-tabs / empty / toast / modal）。
   零外部依赖：系统字体 + 原生 CSS + 内联 SVG。
   ========================================================= */

/* ---------- 1. 页面骨架 ---------- */

.ext4-page { min-width: 0; }

.ext4-rangebar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.ext4-range-tabs { flex: none; }
.ext4-range-text {
  font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ext4-range-hint {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 0; white-space: nowrap;
}
.ext4-range-hint .icon { color: var(--muted-2); }

/* 双列 / 三列栅格行 */
.ext4-row {
  display: grid; gap: 16px; align-items: start;
  margin-bottom: 16px;
}
.ext4-row > .card + .card { margin-top: 0; }
.ext4-row-trend { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.ext4-row-sources { grid-template-columns: minmax(0, 1fr); }
.ext4-row-pages { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.ext4-row-recent { grid-template-columns: minmax(0, 1fr); }

.ext4-card { min-width: 0; }
.ext4-card .card-head { flex-wrap: wrap; }
.ext4-card-sub {
  margin-left: 2px; margin-right: auto;
  font-size: 11.5px; color: var(--muted-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.ext4-card .card-actions { flex: none; }
.ext4-card.is-flash { animation: ext4-card-flash 1.2s ease; }
@keyframes ext4-card-flash {
  0% { box-shadow: 0 0 0 3px rgba(189, 17, 43, .22); }
  100% { box-shadow: var(--shadow-sm); }
}

/* ---------- 2. KPI 卡片 ---------- */

.ext4-kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ext4-kpi { align-items: flex-start; gap: 12px; padding: 15px 15px; }
.ext4-kpi .kpi-icon { width: 40px; height: 40px; border-radius: 11px; }
.ext4-kpi-main { display: block; min-width: 0; }
.ext4-kpi .kpi-num {
  font-size: 23px; line-height: 1.15;
  letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ext4-kpi .kpi-label { margin-top: 2px; }
.ext4-kpi-sub {
  display: block; margin-top: 3px;
  font-size: 11px; line-height: 1.4; color: var(--muted-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* KPI 仅作展示，不呈现“可点击”的悬浮位移 */
.ext4-kpi-grid .kpi:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--line);
}

/* ---------- 3. 空数据提示条 ---------- */

.ext4-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 15px 18px; margin-bottom: 16px;
  background: linear-gradient(90deg, #FFF7F8 0%, #FFFFFF 68%);
  border-color: var(--brand-soft-2);
}
.ext4-banner-icon {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.ext4-banner-main { flex: 1 1 260px; min-width: 0; }
.ext4-banner-main .hint { margin-top: 4px; max-width: 720px; }
.ext4-banner .btn { flex: none; }

/* ---------- 4. 趋势折线图 ---------- */

.ext4-chart { min-width: 0; }
.ext4-chart-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ext4-trend-svg { display: block; width: 100%; height: auto; min-width: 430px; }

.ext4-grid-line { stroke: #EEF0F2; stroke-width: 1; }
.ext4-grid-line.is-vertical { stroke: #F5F6F8; }
.ext4-axis-line { stroke: var(--line-strong); stroke-width: 1; }
.ext4-axis-text {
  font-size: 11px; fill: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.ext4-trend-area { fill: rgba(189, 17, 43, .075); }
.ext4-trend-line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ext4-trend-line.is-pv { stroke: var(--brand); }
.ext4-trend-line.is-uv { stroke: var(--info); }
.ext4-trend-dot { stroke-width: 2; }
.ext4-trend-dot.is-pv { fill: #fff; stroke: var(--brand); }
.ext4-trend-dot.is-uv { fill: #fff; stroke: var(--info); }

.ext4-legend {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px 20px; margin-top: 10px;
}
.ext4-legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
}
.ext4-legend-line { width: 18px; height: 3px; border-radius: 2px; flex: none; }
.ext4-legend-line.is-pv { background: var(--brand); }
.ext4-legend-line.is-uv { background: var(--info); }
.ext4-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- 5. 渠道占比环形图 ---------- */

.ext4-donut-wrap {
  display: flex; align-items: center; gap: 20px;
  min-height: 190px;
}
.ext4-donut-chart { flex: none; width: 168px; }
.ext4-donut { display: block; width: 100%; height: auto; }
.ext4-donut-track { stroke: #F0F2F3; }
.ext4-donut-seg { transition: opacity .15s ease; }
.ext4-donut-seg:hover { opacity: .82; }
.ext4-donut-num {
  font-size: 24px; font-weight: 700; fill: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ext4-donut-label { font-size: 11.5px; fill: var(--muted); }

.ext4-donut-legend {
  flex: 1 1 auto; min-width: 0;
  display: grid; gap: 9px;
  max-height: 198px; overflow-y: auto; padding-right: 2px;
}
.ext4-donut-legend-item {
  display: grid; grid-template-columns: 9px minmax(0, 1fr) auto auto;
  align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--ink-2);
}
.ext4-donut-legend-label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ext4-donut-legend-num {
  font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600;
}
.ext4-donut-legend-pct {
  min-width: 44px; text-align: right;
  font-size: 11.5px; color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- 6. 表格 / 占比进度条 ---------- */

.ext4-table-scroll {
  max-height: 430px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ext4-table-scroll .table thead th { position: sticky; top: 0; z-index: 2; }
.ext4-table { min-width: 620px; }
.ext4-table .col-num {
  text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ext4-table .col-ratio { width: 168px; min-width: 150px; }
.ext4-table-pages { min-width: 440px; }
.ext4-table-pages .col-ratio { width: 136px; min-width: 120px; }
.ext4-table-pages .ext4-path { max-width: 220px; }
.ext4-table-recent { min-width: 640px; }
.ext4-table-recent .ext4-path { max-width: 280px; }

.ext4-ratio {
  display: flex; align-items: center; gap: 9px; min-width: 120px;
}
.ext4-ratio-track {
  flex: 1 1 auto; min-width: 56px; height: 6px;
  border-radius: 999px; background: #F0F2F3; overflow: hidden;
}
.ext4-ratio-fill {
  display: block; height: 100%; border-radius: 999px;
  background: var(--brand);
  transition: width .3s ease;
}
.ext4-ratio-fill.is-red { background: var(--brand); }
.ext4-ratio-fill.is-blue { background: var(--info); }
.ext4-ratio-fill.is-green { background: var(--ok); }
.ext4-ratio-fill.is-amber { background: var(--warn); }
.ext4-ratio-fill.is-purple { background: var(--purple); }
.ext4-ratio-fill.is-grey { background: #9AA1A8; }
.ext4-ratio-num {
  flex: none; width: 46px; text-align: right;
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ext4-source {
  display: inline-block; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}

/* ---------- 7. 落地页 / 最近访问 ---------- */

.ext4-page-cell {
  display: flex; align-items: center; gap: 9px; min-width: 0;
}
.ext4-rank {
  flex: none; width: 20px; height: 20px; border-radius: 6px;
  display: grid; place-items: center;
  background: #F1F2F4; color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.ext4-path {
  display: block; min-width: 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}

.ext4-recent-time {
  font-size: 12px; color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ext4-recent-page { min-width: 150px; max-width: 280px; }
.ext4-recent-page .cell-sub {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.ext4-device-cell {
  display: flex; align-items: center; gap: 7px; min-width: 92px;
  font-size: 12.5px;
}
.ext4-device-cell .cell-sub { display: block; margin-top: 0; }
.ext4-device-mini {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
}

/* ---------- 8. 设备分布 ---------- */

.ext4-device-list { display: flex; flex-direction: column; gap: 18px; }
.ext4-device-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 7px;
}
.ext4-device-icon {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
}
.ext4-device-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.ext4-device-num {
  margin-left: auto;
  font-size: 13px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ext4-device-unit {
  margin-left: 2px; font-size: 11px; font-weight: 400; color: var(--muted-2);
}
.ext4-device-bar {
  height: 8px; border-radius: 999px; background: #F0F2F3; overflow: hidden;
}
.ext4-device-fill {
  display: block; height: 100%; border-radius: 999px;
  transition: width .3s ease;
}
.ext4-device-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 5px; font-size: 11.5px; color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.ext4-foot-hint {
  display: flex; align-items: center; gap: 5px;
  margin-top: 16px; font-size: 11.5px; color: var(--muted-2);
}
.ext4-foot-hint .icon { flex: none; }

/* ---------- 9. 卡片内空态 ---------- */

.ext4-inline-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 6px;
  padding: 26px 18px;
}
.ext4-inline-empty-icon {
  width: 44px; height: 44px; margin-bottom: 2px;
  border-radius: 12px; background: #F1F2F4; color: var(--muted-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.ext4-inline-empty .btn { margin-top: 8px; }

/* ---------- 10. 跟踪代码卡片 ---------- */

.ext4-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: #F1F2F4; color: var(--muted);
  font-size: 11.5px; white-space: nowrap;
}
.ext4-chip .icon { flex: none; }

.ext4-track-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, .75fr);
  gap: 22px; align-items: start;
}
.ext4-track-main { min-width: 0; }
.ext4-step { display: flex; gap: 12px; }
.ext4-step-no {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 700;
}
.ext4-step-body { min-width: 0; flex: 1 1 auto; }
.ext4-step-title {
  margin-bottom: 3px; font-size: 13.5px; font-weight: 600; color: var(--ink);
}
.ext4-step-body .hint { line-height: 1.7; }
.ext4-step-body .hint code {
  padding: 1px 4px; border-radius: 4px;
  background: #F1F2F4; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
}

.ext4-code-wrap { position: relative; margin: 10px 0 18px 36px; }
.ext4-code {
  margin: 0; padding: 14px 16px; max-height: 240px; overflow: auto;
  background: #23272B; color: #DDE2E7;
  border-radius: 10px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  white-space: pre; tab-size: 2;
}
.ext4-copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .18);
  color: #F3F5F7;
}
.ext4-copy-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
}

.ext4-endpoint {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 9px;
}
.ext4-endpoint code {
  flex: 1 1 260px; min-width: 0;
  padding: 8px 11px;
  background: #FAFBFC; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  word-break: break-all;
}

.ext4-track-side {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px;
  background: #FAFBFC; border: 1px solid var(--line); border-radius: 10px;
}
.ext4-meta-list { margin: 0; display: flex; flex-direction: column; gap: 9px; }
.ext4-meta-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 12.5px; line-height: 1.5;
}
.ext4-meta-row dt { flex: none; color: var(--muted); }
.ext4-meta-row dd {
  margin: 0; min-width: 0; text-align: right;
  color: var(--ink-2); word-break: break-word;
}
.ext4-side-hint {
  display: flex; align-items: flex-start; gap: 6px;
  margin: 0; font-size: 11.5px; line-height: 1.65; color: var(--muted-2);
}
.ext4-side-hint .icon { flex: none; margin-top: 2px; }

.ext4-danger-zone {
  display: flex; flex-direction: column; gap: 7px;
  padding-top: 13px; border-top: 1px dashed var(--line-strong);
}
.ext4-danger-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--brand);
}
.ext4-danger-title .icon { flex: none; }
.ext4-clear-btn { align-self: flex-start; margin-top: 2px; }

/* ---------- 11. Loading 骨架 ---------- */

.ext4-skel {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, #EFF1F3 25%, #F7F8F9 37%, #EFF1F3 63%);
  background-size: 400% 100%;
  animation: ext4-skel-shimmer 1.4s ease infinite;
}
@keyframes ext4-skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
.ext4-skel-icon { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.ext4-skel-block { width: 100%; border-radius: 10px; }
.ext4-kpi-skel { align-items: center; }
.ext4-kpi-skel:hover { transform: none; box-shadow: var(--shadow-sm); }

/* ---------- 12. 响应式 ---------- */

@media (max-width: 1240px) {
  .ext4-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ext4-kpi .kpi-num { font-size: 22px; }
}

@media (max-width: 1100px) {
  .ext4-row-trend,
  .ext4-row-pages,
  .ext4-track-grid { grid-template-columns: minmax(0, 1fr); }
  .ext4-donut-wrap { min-height: 0; }
}

@media (max-width: 900px) {
  .ext4-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ext4-kpi-grid .kpi + .kpi { margin-top: 0; }
  .ext4-donut-legend { max-height: none; }
}

@media (max-width: 640px) {
  .ext4-rangebar { gap: 9px; }
  .ext4-range-hint { display: none; }
  .ext4-kpi { padding: 13px 13px; gap: 10px; }
  .ext4-kpi .kpi-icon { width: 34px; height: 34px; border-radius: 9px; }
  .ext4-kpi .kpi-num { font-size: 20px; }
  .ext4-kpi-sub { font-size: 10.5px; }
  .ext4-banner { align-items: flex-start; }
  .ext4-banner .btn { margin-left: 56px; }
  .ext4-donut-wrap { flex-direction: column; align-items: stretch; gap: 14px; }
  .ext4-donut-chart { margin: 0 auto; }
  .ext4-donut-legend {
    grid-template-columns: 1fr;
    border-top: 1px solid var(--line); padding-top: 12px;
  }
  .ext4-code-wrap { margin-left: 0; }
  .ext4-code { font-size: 11px; padding: 13px 12px; }
  .ext4-track-side { padding: 14px; }
  .ext4-table .col-ratio { width: 140px; min-width: 128px; }
  .ext4-ratio-num { width: 42px; }
}

@media (max-width: 420px) {
  .ext4-kpi .kpi-num { font-size: 19px; }
  .ext4-kpi .kpi-label { font-size: 12px; }
  .ext4-kpi-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ext4-skel { animation: none; }
  .ext4-card.is-flash { animation: none; }
  .ext4-ratio-fill,
  .ext4-device-fill,
  .ext4-donut-seg { transition: none; }
}
