/* ============ 千川数据工作台 · 视觉系统 ============ */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1f2329;
  --ink-2: #646a73;
  --ink-3: #8f959e;
  --line: #eceef2;
  --line-2: #e2e6ee;
  --blue: #2f6bff;
  --blue-soft: #eef3ff;
  --blue-ink: #1a56f0;
  --green: #16a34a;
  --green-bg: #e9f9ef;
  --red: #e5484d;
  --red-bg: #fdecec;
  --orange: #f59e0b;
  --orange-bg: #fdf3e3;
  --purple-1: #6678ee;
  --purple-2: #7c5ac2;
  --shadow: 0 2px 14px rgba(31, 35, 41, 0.06);
  --shadow-lg: 0 12px 40px rgba(31, 35, 41, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.container { max-width: 1240px; margin: 0 auto; padding: 30px 24px 60px; }

/* ============ 顶部标题 ============ */
.page-head { text-align: center; margin-bottom: 28px; }
.page-head h1 { font-size: 38px; font-weight: 800; letter-spacing: 1px; }
.page-head .date { color: var(--ink-2); margin-top: 10px; font-size: 16px; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 14px; margin-bottom: 14px;
}
.back-link:hover { color: var(--blue); }

.dash-title h1 { font-size: 32px; font-weight: 800; }
.dash-title .sub { color: var(--ink-2); margin-top: 6px; }

/* ============ AI 助手卡片（紫色渐变） ============ */
.ai-card {
  background: linear-gradient(135deg, var(--purple-1) 0%, var(--purple-2) 100%);
  border-radius: var(--radius);
  padding: 30px 32px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(102, 120, 238, 0.32);
}
.ai-card .ai-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.ai-card .ai-robot {
  width: 46px; height: 46px; font-size: 28px;
  display: grid; place-items: center;
}
.ai-card .ai-head h2 { font-size: 24px; font-weight: 800; }
.ai-card .ai-head .tip { margin-left: 10px; font-size: 15px; opacity: 0.9; font-weight: 400; }

.ai-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ai-row .lbl { font-size: 15px; opacity: 0.92; }
.ai-card input[type="text"], .ai-card input[type="date"] {
  background: rgba(255, 255, 255, 0.92);
  border: none; border-radius: 10px;
  padding: 10px 14px; font-size: 15px; color: var(--ink);
  outline: none;
}
.ai-card .ask-line { display: flex; gap: 14px; margin: 18px 0 14px; }
.ai-card .ask-line input {
  flex: 1; padding: 15px 18px; font-size: 16px; border-radius: 12px;
}
.ai-card .btn-ask {
  background: #fff; color: var(--blue-ink);
  border: none; border-radius: 12px;
  padding: 0 30px; font-size: 17px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
}
.ai-card .btn-ask:hover { transform: translateY(-1px); }

.chip {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff; border-radius: 999px;
  padding: 7px 18px; font-size: 14px;
}
.chip:hover { background: rgba(255, 255, 255, 0.3); }

/* AI 结果（白地） */
.ai-result-wrap { margin-top: 22px; }
.ai-result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ai-result-head h3 { font-size: 18px; }
.ai-result-head .tools { display: flex; gap: 12px; align-items: center; }
.btn-word {
  background: #fff; color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 7px 14px; font-size: 14px;
  display: inline-flex; gap: 6px; align-items: center;
}
.btn-word:hover { border-color: var(--blue); color: var(--blue); }
.link-arrow { color: #fff; font-weight: 600; }
.ai-result {
  background: #fff; color: var(--ink);
  border-radius: 12px; padding: 26px 28px;
  min-height: 120px; max-height: 560px; overflow: auto;
}
.ai-result h2 { font-size: 20px; margin: 18px 0 12px; }
.ai-result h2:first-child { margin-top: 0; }
.ai-result h3 { font-size: 17px; margin: 16px 0 8px; }
.ai-result p { margin: 10px 0; color: #33383f; }
.ai-result ul { margin: 10px 0 10px 22px; }
.ai-result li { margin: 8px 0; }
.ai-result code {
  background: #f2f4f8; padding: 2px 6px; border-radius: 5px;
  font-size: 13.5px; color: #355;
}
.ai-result .meta-line { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }
.ai-result table { margin: 14px 0; }
.ai-empty { color: var(--ink-3); text-align: center; padding: 30px 0; }
.ai-loading { color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--line-2);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 筛选栏（白底工具条） ============ */
.filter-bar {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.filter-bar .fld { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.filter-bar input[type="date"] {
  border: 1px solid var(--line-2); border-radius: 9px;
  padding: 8px 10px; font-size: 14px; color: var(--ink);
  background: #fafbfc;
}
.filter-bar select {
  border: 1px solid var(--line-2); border-radius: 9px;
  padding: 9px 12px; font-size: 14px; background: #fafbfc; min-width: 110px;
}
.btn {
  border-radius: 9px; padding: 9px 18px; font-size: 14px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-primary {
  background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600;
}
.btn-primary:hover { background: var(--blue-ink); color: #fff; }
.filter-bar .spacer { flex: 1; }
.update-time { color: var(--ink-3); font-size: 13px; }

/* ============ 汇总卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin: 20px 0; }
.stat-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px;
}
.stat-card .label { color: var(--ink-2); font-size: 14px; }
.stat-card .value { font-size: 32px; font-weight: 800; margin: 8px 0; }
.stat-card .delta { display: inline-block; font-size: 13px; border-radius: 999px; padding: 2px 10px; }

/* 涨跌色：红涨 绿跌 */
.delta.up { color: var(--red); background: var(--red-bg); }
.delta.down { color: var(--green); background: var(--green-bg); }
.delta.flat { color: var(--ink-3); background: #f1f2f5; }

/* ============ 区块面板 ============ */
.panel {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.panel-head .side { color: var(--ink-2); font-size: 14px; }
.link-btn {
  background: none; border: none; color: var(--blue); font-size: 13px;
  font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 7px;
}
.link-btn:hover { background: rgba(47, 107, 255, 0.08); }
.chart { width: 100%; height: 320px; }

/* ============ 大 Tab ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs .tab {
  padding: 12px 20px; font-size: 15px; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tabs .tab:hover { color: var(--blue); }
.tabs .tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

.subtabs { display: flex; gap: 10px; margin: 14px 0; }
.subtabs .subtab {
  border: 1px solid var(--line-2); background: #fff; border-radius: 9px;
  padding: 7px 18px; font-size: 14px; color: var(--ink-2);
}
.subtabs .subtab.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th {
  text-align: left; color: var(--ink-2); font-weight: 600;
  padding: 12px 14px; background: #fafbfc;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--blue-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 700;
  background: #f1f2f5; color: var(--ink-2);
}
.rank-badge.r1 { background: #d97426; color: #fff; }
.rank-badge.r2 { background: #c98a2e; color: #fff; }
.rank-badge.r3 { background: #d2a84e; color: #fff; }

/* ROI 标签 */
.tag { display: inline-block; border-radius: 7px; padding: 2px 10px; font-size: 13.5px; font-weight: 600; }
.tag.good { color: var(--green); background: var(--green-bg); }
.tag.warn { color: #d98305; background: var(--orange-bg); }
.tag.bad { color: var(--red); background: var(--red-bg); }
.tag.neutral { color: var(--ink-3); background: #f1f2f5; }
.tag.premium { color: #d98305; background: #fff4e0; border: 1px solid #ffd98a; }
.tag.first { color: #2f8ff0; background: #eaf4ff; border: 1px solid #b9d9ff; }

/* ============ 首页入口卡片 ============ */
.entry-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 26px; }
.entry-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 30px; display: block;
}
.entry-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.entry-card .ico {
  width: 52px; height: 52px; border-radius: 12px; background: #fff3e6;
  display: grid; place-items: center; font-size: 26px; margin-bottom: 18px;
}
.entry-card h3 { font-size: 21px; font-weight: 800; color: var(--ink); }
.entry-card .d { color: var(--ink-2); margin: 8px 0 16px; }
.entry-card .go { color: var(--ink-2); font-weight: 600; }
.entry-card:hover .go { color: var(--blue); }

/* ============ 人员分组 ============ */
.person-group { margin-bottom: 26px; }
.person-group > h3 { font-size: 18px; font-weight: 700; margin: 8px 0 12px; }
.person-videos { margin: 8px 0 20px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.person-videos > .pv-head {
  padding: 12px 16px; background: #fafbfc; cursor: pointer;
  display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.person-videos > .pv-body { padding: 8px 16px 16px; }
.caret { margin-left: auto; transition: transform .2s; color: var(--ink-3); }
.person-videos.open .caret { transform: rotate(180deg); }

/* ============ 素材概览三卡 ============ */
.material-stat { border-radius: 12px; padding: 18px 20px; border: 1px solid var(--line); }
.material-stat.good { background: #f3fcf6; border-color: #cdeed8; }
.material-stat.active { background: #f2f7ff; border-color: #d3e3ff; }
.material-stat.sleep { background: #fafbfc; }
.material-stat .t { font-size: 14px; color: var(--ink-2); display:flex; align-items:center; gap:6px; }
.material-stat .v { font-size: 28px; font-weight: 800; margin: 6px 0; }
.material-stat .s { font-size: 13px; color: var(--ink-2); }

/* ============ 告警 ============ */
.alert-list { display: flex; flex-direction: column; gap: 12px; }
.alert-item { border-radius: 11px; padding: 13px 16px; border: 1px solid; }
.alert-item.roi { background: #fdeeee; border-color: #f6d2d2; }
.alert-item.cost { background: #fff6e8; border-color: #f5dfb8; }
.alert-item.total { background: #fdeeee; border-color: #f6d2d2; }
.alert-item .a-title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.alert-item .a-content { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.alert-item .a-time { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.alert-badge { font-size: 12px; border-radius: 6px; padding: 1px 7px; font-weight: 700; }
.alert-badge.roi { background: var(--red); color: #fff; }
.alert-badge.cost { background: var(--orange); color: #fff; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 24, 32, 0.45);
  display: none; place-items: center; z-index: 100; padding: 30px;
}
.modal-mask.show { display: grid; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 920px;
  max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 1080px; }
.modal-head { padding: 20px 26px; display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 20px; font-weight: 800; }
.modal-x { border: none; background: none; font-size: 24px; color: var(--ink-3); line-height: 1; }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 4px 26px 26px; overflow: auto; }
.modal-body h4 { font-size: 17px; font-weight: 700; margin: 18px 0 10px; padding-left: 10px; border-left: 3px solid var(--blue); }
.modal-chart { width: 100%; height: 300px; }

/* ============ 配置弹窗 ============ */
.config-form .fld { margin-bottom: 16px; }
.config-form label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.config-form input {
  width: 100%; border: 1px solid var(--line-2); border-radius: 9px;
  padding: 10px 12px; font-size: 14px;
}
.config-status { font-size: 13px; margin-bottom: 14px; }

/* 顶部状态条 */
.top-status {
  display: flex; justify-content: flex-end; margin-bottom: 12px;
}
.status-pill { font-size: 13px; color: var(--ink-2); }

.muted { color: var(--ink-3); }
.footer-note { text-align: center; color: var(--ink-3); font-size: 13px; margin-top: 24px; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .entry-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 30px; }
}
