/* ============================================================
   抖音千川挂车短视频数据看板 —— 红色商务风（参考竞品爆款内容分析系统）
   ============================================================ */
:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --ink: #1a1a2e;
  --ink-2: #4a4a5a;
  --ink-3: #8c8ca0;
  --line: #eaeaea;
  --line-2: #f2f2f6;
  --brand: #c8161d;          /* 抖音红 */
  --brand-dark: #a01018;
  --brand-light: #fff0f0;
  --accent: #ff6b35;
  --up: #e0443e;
  --down: #12a594;
  --warn: #f5a623;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1480px; margin: 0 auto; padding: 0 24px 64px; }

/* ======================== 顶部红色导航栏 ======================== */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  box-shadow: 0 2px 16px rgba(200, 22, 29, .25);
}
.topbar-in {
  max-width: 1480px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  font-size: 17px; font-weight: 700; letter-spacing: .3px;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.brand .sub {
  font-size: 12px; color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.15); padding: 2px 10px; border-radius: 10px;
}
.spacer { flex: 1; }

/* 白色药丸按钮组 */
.seg {
  display: inline-flex; background: rgba(255,255,255,.18);
  border-radius: 20px; padding: 3px; gap: 2px;
  backdrop-filter: blur(4px);
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 16px; border-radius: 17px;
  font-size: 13px; color: rgba(255,255,255,.82); font-weight: 500;
  font-family: inherit; transition: all .2s;
}
.seg button:hover { color: #fff; background: rgba(255,255,255,.12); }
.seg button.on {
  background: #fff; color: var(--brand); font-weight: 650;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

/* 视图容器：投商品 / 投直播 切换 */
.view { display: block; }
.empty-state { text-align: center; padding: 130px 20px; color: var(--ink-3); }
.empty-state .es-ico { font-size: 52px; margin-bottom: 14px; }
.empty-state .es-title { font-size: 20px; font-weight: 700; color: var(--ink); }
.empty-state .es-sub { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

.btn {
  border: 1px solid rgba(255,255,255,.35); background: transparent;
  cursor: pointer; padding: 7px 15px; border-radius: 17px;
  font-size: 13px; color: #fff; font-weight: 500; font-family: inherit;
  transition: all .2s; backdrop-filter: blur(4px);
}
.btn:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.55); }
.btn-primary {
  background: #fff; color: var(--brand); border-color: #fff;
  font-weight: 650; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.btn-primary:hover { background: #fefefe; transform: translateY(-1px); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 4px 11px; border-radius: 14px;
  background: rgba(255,255,255,.22); color: #fff; border: 1px solid rgba(255,255,255,.28);
  font-weight: 500;
}
.pill.live { background: rgba(255,255,255,.95); color: var(--brand); border-color: transparent; }
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: block; }
#srcPill { display: none; } /* 隐藏数据源提示栏（账户固定，无需展示） */

/* ======================== 口径提示条 ======================== */
.notice {
  margin: 18px 0 0; padding: 11px 16px; border-radius: var(--radius);
  background: var(--brand-light); border: 1px solid #ffd6d6;
  color: #8b1a1a; font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start;
}
.notice b { font-weight: 650; }

/* 投直播口径说明：卡片式增强可读性 */
#liveNotice {
  margin: 18px 0 0; padding: 14px 20px; border-radius: var(--radius);
  background: #ffffff; border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
  box-shadow: var(--shadow-sm); line-height: 1.7;
}
#liveNotice b { color: var(--brand); font-size: 13px; }
#liveNotice span { color: var(--ink-2); }

/* ======================== 区块标题 ======================== */
.section { margin-top: 28px; }
.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sec-head h2 { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.sec-head .idx {
  width: 24px; height: 24px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-size: 12.5px; display: grid; place-items: center; font-weight: 700;
  box-shadow: 0 2px 6px rgba(200,22,29,.25);
}
.sec-head .desc { font-size: 12px; color: var(--ink-3); }
.prod-sel { margin-left: auto; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; color: var(--ink); background: #fff; cursor: pointer; font-family: inherit; font-weight: 600; }
.prod-sel:focus { outline: none; border-color: var(--red); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-pad { padding: 20px 22px; }

/* ======================== KPI 卡片 ======================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--brand), var(--accent));
  border-radius: var(--radius) 0 0 var(--radius);
}
.kpi.k2::before { background: linear-gradient(180deg, #00b5a3, #36cfc9); }
.kpi.k3::before { background: linear-gradient(180deg, #7b61ff, #9254de); }
.kpi.k4::before { background: linear-gradient(180deg, #f5a623, #ffc53d); }
.kpi.k5::before { background: linear-gradient(180deg, #c8161d, #ff6b35); }
.kpi.k6::before { background: linear-gradient(180deg, #2f54eb, #597ef7); }
.kpi.k7::before { background: linear-gradient(180deg, #c8161d, #ff6b35); }
.kpi.k8::before { background: linear-gradient(180deg, #2f54eb, #597ef7); }
.kpi .lab { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .lab .mth { font-size: 11px; font-weight: 500; color: var(--brand); background: rgba(200,22,29,.08); padding: 1px 6px; border-radius: 6px; }
.kpi .val .gmv-input {
  width: auto; min-width: 60px; max-width: 180px;
  font-size: 30px; font-weight: 750; letter-spacing: -.8px;
  font-variant-numeric: tabular-nums; color: var(--ink);
  border: none; border-bottom: 2px solid transparent;
  padding: 0 4px; margin: 0; background: none; outline: none;
  border-radius: 0; display: inline; vertical-align: baseline;
  -webkit-appearance: none; -moz-appearance: textfield; appearance: none;
}
/* 去掉 number 输入框原生的上下箭头小框（Safari/Chrome 的丑红框来源） */
.kpi .val .gmv-input::-webkit-outer-spin-button,
.kpi .val .gmv-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; display: none; }
.kpi .val .gmv-input::placeholder { color: var(--ink-3); opacity: .6; }
.kpi .val .gmv-input:focus { border-bottom-color: var(--brand); background: rgba(200,22,29,.04); }
/* 万字后缀：与总消耗卡片的「元」完全一致 —— 纯文字、无边框无背景 */
.kpi .val .gmv-input + small {
  font-size: 16px; font-weight: 600; color: var(--ink-2);
  margin-left: 2px; border: none; background: none; outline: none;
  padding: 0; box-shadow: none; display: inline; vertical-align: baseline;
}
.kpi .val {
  font-size: 30px; font-weight: 750; margin-top: 8px;
  letter-spacing: -.8px; font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi .val small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 4px; border: none; background: none; padding: 0; }
.kpi .cmp { display: flex; gap: 18px; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.kpi .cmp span { display: inline-flex; align-items: center; gap: 4px; }

.up { color: var(--up); font-weight: 650; }
.down { color: var(--down); font-weight: 650; }
.flat { color: var(--ink-3); }

/* ======================== 表格 ======================== */
.tbl-wrap { overflow-x: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right; padding: 12px 14px; font-weight: 600; color: var(--ink-2);
  background: #fafafa; border-bottom: 2px solid var(--line);
  white-space: nowrap; font-size: 12.5px; position: sticky; top: 0; z-index: 2;
}
.drawer-body thead th { position: sticky; top: 0; z-index: 2; }
thead th:first-child, tbody td:first-child { text-align: left; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--brand); background: #fff5f5; }
thead th .arrow { opacity: .3; margin-left: 3px; font-size: 10px; }
thead th.act .arrow { opacity: 1; color: var(--brand); }
tbody td {
  text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--line-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: 0; }

.rank {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 6px; background: var(--line-2); color: var(--ink-2);
  font-size: 11px; font-weight: 700; margin-right: 8px;
}
.rank.top {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
}

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 5px;
  font-size: 11.5px; font-weight: 500;
  background: var(--line-2); color: var(--ink-2);
}
.tag.core { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.tag.aigc { background: #e6fffb; color: #08979c; font-weight: 600; }
.tag.new { background: #fff7e6; color: #d48806; }
.tag.live-ch { background: #f9f0ff; color: #722ed1; font-weight: 600; }

.bar-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.bar-cell .bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--brand), var(--accent)); opacity: .35; min-width: 2px; }

.na { color: var(--ink-3); }

/* ======================== 布局网格 ======================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-37 { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }

.stat-hero { padding: 22px; background: linear-gradient(135deg, #fffaf8 0%, #fff 100%); }
.stat-hero .lab { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.stat-hero .val {
  font-size: 34px; font-weight: 800; margin: 8px 0 2px;
  letter-spacing: -1px; font-variant-numeric: tabular-nums;
  color: var(--brand);
}
.stat-hero .val small { font-size: 15px; font-weight: 500; color: var(--ink-2); }
.stat-hero .rows { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.stat-hero .rw { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12.5px; color: var(--ink-2); }

.chart { width: 100%; }
.h260 { height: 260px; }
.h300 { height: 300px; }
.h320 { height: 320px; }
.h340 { height: 340px; }

.chart-title { font-size: 13.5px; font-weight: 650; color: var(--ink); margin-bottom: 2px; }
.chart-sub { font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; }

/* ======================== 搜索与工具栏 ======================== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.input {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 13px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(200,22,29,.1); }
.input.search { width: 240px; }
select.input { cursor: pointer; }

/* 自定义日期选择器 */
.date-picker-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.15); padding: 4px 8px; border-radius: 20px;
}
.date-picker-row input[type="date"] {
  border: 0; background: rgba(255,255,255,.9); border-radius: 14px;
  padding: 5px 10px; font-size: 12.5px; color: var(--ink); font-family: inherit;
  outline: none; cursor: pointer;
}
.date-picker-row input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer; filter: invert(.3);
}
.date-picker-row label { font-size: 12px; color: rgba(255,255,255,.7); }

.asof-box {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.15); padding: 4px 8px; border-radius: 20px;
}
.asof-box label { font-size: 12px; color: rgba(255,255,255,.8); white-space: nowrap; }
.asof-box input[type="date"] {
  border: 0; background: rgba(255,255,255,.9); border-radius: 14px;
  padding: 5px 10px; font-size: 12.5px; color: var(--ink); font-family: inherit;
  outline: none; cursor: pointer; max-width: 138px;
}
.asof-box input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; filter: invert(.3); }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 16px; font-size: 12.5px; color: var(--ink-2); }
.pager button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 5px 12px; cursor: pointer; font-family: inherit; color: var(--ink-2);
  transition: all .15s;
}
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--brand); color: var(--brand); }

/* ======================== 下钻抽屉 ======================== */
.mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .40);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(880px, 92vw);
  background: #fff; z-index: 100; box-shadow: -10px 0 40px rgba(0, 0, 0, .15);
  transform: translateX(100%); transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer-head {
  padding: 20px 24px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.drawer-head h3 { font-size: 15.5px; font-weight: 700; color: #fff; }
.drawer-head .desc { font-size: 12px; color: rgba(255,255,255,.72); }
.drawer-body { flex: 1; overflow: auto; padding: 0 24px 24px; }
.x {
  border: 0; background: rgba(255,255,255,.25); width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; color: #fff; font-size: 16px;
  transition: background .2s;
}
.x:hover { background: rgba(255,255,255,.45); }

.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend-inline i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.foot {
  margin-top: 40px; padding: 20px 22px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3); line-height: 2;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-37 { grid-template-columns: 1fr; }
  .date-picker-row { display: none; }  /* 小屏隐藏自定义日期，保留按钮 */
}
