:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e4e8ef;
  --text: #1f2329;
  --muted: #7a828e;
  --primary: #4f7cff;
  --primary-hover: #3b66e8;
  --ok: #22a06b;
  --err: #e5484d;
  --warn: #e8930c;
  --info: #4f7cff;
  --sidebar-bg: #ffffff;
  --sidebar-active: #eef3ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef4ff 0%, #f6f9ff 45%, #eef7f4 100%);
}
.login-card {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 36px; width: 380px; box-shadow: 0 10px 40px rgba(79, 124, 255, .08);
  text-align: center;
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-card input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; margin-bottom: 14px; outline: none; background: #fafbfd;
}
.login-card input:focus { border-color: var(--primary); background: #fff; }
.login-card .btn { width: 100%; padding: 11px; font-size: 15px; border-radius: 10px; }
#login-msg { margin-top: 12px; color: var(--err); font-size: 13px; min-height: 18px; }

/* ---------- 主布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 10;
}
.sidebar .logo { padding: 22px 20px 14px; font-size: 17px; font-weight: 600; }
.sidebar nav { flex: 1; padding: 6px 10px; }
.sidebar nav a {
  display: block; padding: 10px 14px; border-radius: 9px; color: var(--text);
  text-decoration: none; cursor: pointer; margin-bottom: 4px; font-size: 14px;
}
.sidebar nav a:hover { background: #f3f6fb; }
.sidebar nav a.active { background: var(--sidebar-active); color: var(--primary); font-weight: 600; }
.sidebar-bottom { padding: 14px 20px; border-top: 1px solid var(--border); }
.sidebar-bottom a { color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: none; }
.sidebar-bottom a:hover { color: var(--err); }

.main { flex: 1; margin-left: 210px; padding: 0 24px 60px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 16px; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar h1 { font-size: 20px; }

/* ---------- 卡片/按钮/表格 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin-bottom: 12px; }
.btn {
  display: inline-block; padding: 9px 22px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-family: inherit; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f3f6fb; }
.btn.danger { background: var(--err); }
.btn.danger:hover { background: #c93a3f; }
.btn.small { padding: 4px 12px; font-size: 12px; border-radius: 6px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:hover td { background: #fafbfe; }
td .link { color: var(--primary); word-break: break-all; text-decoration: none; }
td .link:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge.ok { background: #e2f7ec; color: var(--ok); }
.badge.pending { background: #eef3ff; color: var(--info); }
.badge.private { background: #fdf0e3; color: var(--warn); }
.badge.no_videos { background: #f1f3f7; color: var(--muted); }
.badge.not_found, .badge.error { background: #fde8e8; color: var(--err); }

/* ---------- 仪表盘 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; position: relative; overflow: hidden;
}
.stat-card .num { font-size: 26px; font-weight: 700; line-height: 1.3; }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--primary));
}

/* ---------- 分组表格 ---------- */
.group-row { cursor: pointer; }
.group-row.expanded td { background: #fafbfe; }
.group-name { font-weight: 600; }
.arrow { display: inline-block; transition: transform .15s; color: var(--muted); margin-right: 6px; }
.expanded .arrow { transform: rotate(90deg); }
.count-cell { cursor: pointer; font-weight: 600; user-select: none; }
.count-cell:hover { text-decoration: underline; background: #f3f6fb; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; justify-content: flex-end; }
.pager .page-info { color: var(--muted); font-size: 13px; }

/* ---------- 悬浮窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(31, 35, 41, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; border-radius: 14px; padding: 26px; width: 480px; max-width: 92vw;
  max-height: 86vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal h2 { font-size: 17px; margin-bottom: 18px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.modal input[type=text], .modal input[type=file], .modal select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
}
.modal input:focus, .modal select:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal .radio-row { display: flex; gap: 18px; margin-top: 12px; font-size: 13px; }
.modal .radio-row label { margin: 0; color: var(--text); display: flex; align-items: center; gap: 6px; cursor: pointer; }

.progress-wrap { height: 8px; background: #e8ecf3; border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ---------- 表单/开关 ---------- */
input[type=text], input[type=number], input[type=password], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 150px; }
.row label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }

.switch { position: relative; width: 40px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; cursor: pointer; transition: .2s; }
.slider:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider:before { transform: translateX(18px); }

.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
