/* ============ TikTok 业绩统计系统 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #fe2c55;
  --primary-dark: #e01e46;
  --cyan: #25f4ee;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --sidebar-w: 224px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #cbd5e1; position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; z-index: 50;
  overflow-y: auto;
}
.main { flex: 1; margin-left: var(--sidebar-w); padding: 24px 28px; min-width: 0; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px; color: #fff; font-size: 17px; font-weight: 700;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: conic-gradient(from 210deg, var(--cyan), var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; box-shadow: 0 2px 10px rgba(254, 44, 85, .35);
}
.brand small { display: block; font-size: 11px; font-weight: 400; color: #94a3b8; letter-spacing: .5px; }

.nav { padding: 8px 10px; flex: 1; }
.nav-title { font-size: 11px; color: #475569; padding: 14px 10px 6px; letter-spacing: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 14px;
  transition: background .15s;
}
.nav a .ico { width: 20px; text-align: center; font-size: 15px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, rgba(254,44,85,.25), rgba(37,244,238,.08)); color: #fff; }
.nav a.active .ico { filter: none; }
.sidebar-foot {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-foot .who {
  font-size: 13px; color: #e2e8f0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sidebar-foot .who .sub { color: #94a3b8; }
.sidebar-foot .btns { display: flex; gap: 6px; }
.sidebar-foot button {
  flex: 1; background: none; border: 1px solid rgba(255,255,255,.15); color: #94a3b8;
  border-radius: 6px; padding: 4px 0; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.sidebar-foot button:hover { color: #fff; border-color: rgba(255,255,255,.4); }

/* ---------- 通用 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 700; }
.page-head .sub { color: var(--text3); font-size: 13px; margin-top: 2px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card h3 .hint { font-size: 12px; color: var(--text3); font-weight: 400; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  border-radius: 8px; padding: 8px 16px; font-size: 14px; font-weight: 500;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text2); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f8fafc; color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.btn.danger:hover { background: var(--red-bg); }

input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: #fff; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(254,44,85,.1); }
input::placeholder { color: var(--text3); }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item label { font-size: 13px; color: var(--text2); font-weight: 500; }
.form-item .tip { font-size: 12px; color: var(--text3); }

/* ---------- 统计卡片 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden; }
.stat-card .label { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-card .value .unit { font-size: 13px; font-weight: 400; color: var(--text3); }
.stat-card .delta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.stat-card .delta .up { color: var(--green); font-weight: 600; }
.stat-card .accent { position: absolute; right: 12px; top: 12px; font-size: 22px; opacity: .8; }
.stat-card.warn { outline: 2px solid #fcd34d; outline-offset: -2px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-weight: 600; color: var(--text2); font-size: 12.5px;
  padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl .sub { color: var(--text3); font-size: 12px; }
.rank { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: #f1f5f9; color: var(--text2); font-size: 12px; font-weight: 600; }
.rank.r1 { background: #fef3c7; color: #b45309; }
.rank.r2 { background: #e2e8f0; color: #475569; }
.rank.r3 { background: #fee2e2; color: #b91c1c; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.gray { background: #f1f5f9; color: var(--text2); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: #eff6ff; color: #2563eb; }

.growth { color: var(--green); font-size: 12px; font-weight: 600; }
.growth.zero { color: var(--text3); font-weight: 400; }

.cover { width: 45px; height: 60px; border-radius: 6px; object-fit: cover; background: #f1f5f9; display: block; }
.video-title-cell { max-width: 320px; }
.video-title-cell a { color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-title-cell a:hover { color: var(--primary); }

.employee-select { max-width: 150px; }

/* ---------- 筛选条 ---------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .spacer { flex: 1; }
.quick-dates { display: flex; gap: 6px; }
.qd-btn { border: 1px solid var(--border); background: #fff; color: var(--text2); border-radius: 7px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.qd-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.qd-btn:hover:not(.active) { background: #f8fafc; color: var(--text); }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 10px; flex-wrap: wrap; }
.pager .info { color: var(--text3); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(15,23,42,.25);
  width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px 24px;
}
.modal h2 { font-size: 17px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal h2 .x { cursor: pointer; color: var(--text3); font-size: 20px; line-height: 1; }
.modal h2 .x:hover { color: var(--text); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-wide { width: 760px; }

/* ---------- 提示 ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: #0f172a; color: #fff; border-radius: 9px; padding: 10px 16px;
  font-size: 13.5px; box-shadow: 0 8px 24px rgba(15,23,42,.25);
  display: flex; align-items: center; gap: 8px; max-width: 380px;
  animation: slide-in .2s ease;
}
.toast.err { background: #7f1d1d; }
.toast.ok::before { content: '✓'; color: #4ade80; font-weight: 700; }
.toast.err::before { content: '✕'; color: #fca5a5; font-weight: 700; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%); padding: 20px; }
.login-box { background: #fff; border-radius: 16px; padding: 36px 34px; width: 380px; max-width: 100%; box-shadow: 0 25px 60px rgba(0,0,0,.4); }
.login-box .logo-big {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 16px;
  background: conic-gradient(from 210deg, var(--cyan), var(--primary));
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.login-box h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--text3); font-size: 13px; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 11px 14px; margin-bottom: 14px; }
.login-box .btn { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.login-err { color: var(--red); font-size: 13px; margin-bottom: 10px; }

/* ---------- 图表 ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.small { height: 260px; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 260px; color: var(--text3); flex-direction: column; gap: 8px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--text3); padding: 46px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty p { margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }

/* ---------- 采集状态 ---------- */
.run-state { display: flex; align-items: center; gap: 8px; }
.spin {
  width: 14px; height: 14px; border: 2px solid #cbd5e1; border-top-color: var(--primary);
  border-radius: 50%; animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }
.dot.gray { background: var(--text3); }
.pulse { animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.msg-block { white-space: pre-wrap; background: var(--red-bg); color: #991b1b; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-top: 10px; max-height: 180px; overflow-y: auto; }

/* ---------- 设置页 ---------- */
.settings-section { margin-bottom: 20px; }
.settings-section .row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap; }
.settings-section .row:last-child { border-bottom: none; }
.settings-section .name { width: 170px; font-weight: 500; flex-shrink: 0; }
.settings-section .name .tip { font-weight: 400; color: var(--text3); font-size: 12px; }
.settings-section .val { flex: 1; min-width: 200px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.settings-section .val input, .settings-section .val select { width: 100%; max-width: 420px; }

.kv { display: flex; gap: 8px; }
.kv b { color: var(--text2); font-weight: 500; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stat-cards, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .main { margin-left: 0; padding: 16px; }
  .layout { flex-direction: column; }
  .nav { display: flex; flex: 1; padding: 4px 8px; flex-wrap: wrap; }
  .nav-title, .sidebar-foot { display: none; }
  .brand { padding: 12px 16px; }
  .grid.cols-2, .grid.cols-3, .stat-cards { grid-template-columns: 1fr; }
}
