/* ===========================================================================
   北抖AI 运营后台 · 样式
   视觉依据：《北抖AI-后台P1~P7》设计稿 + 《北抖AI-设计规范-v1.0》色彩/圆角体系
   - 品牌渐变 #6E5BFF → #3B82F6（0°）
   - 页面底 #F7F7F8；卡片白底 + 1px #ECECF0 + 圆角 12
   - 主文字 #1D1D1F；次文字 #8A8A94；浅紫底 #F3F1FF；紫字 #4F46E5
   =========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
/* 关键：类选择器里的 display 会盖掉 hidden 属性的 display:none，必须显式兜底 */
[hidden] { display: none !important; }

:root {
  --grad: linear-gradient(90deg, #6E5BFF 0%, #3B82F6 100%);
  --violet: #4F46E5;
  --violet-bg: #F3F1FF;
  --ink: #1D1D1F;
  --ink-2: #5A5A66;
  --ink-3: #8A8A94;
  --line: #ECECF0;
  --bg: #F7F7F8;
  --fill: #F5F5F7;
  --green: #22A06B;
  --red: #FF3B30;
  --radius: 12px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------ 布局 ------------------------------ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #F7F7F8;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

.menu { display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  height: 34px; display: flex; align-items: center;
  padding: 0 12px; border-radius: 8px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none;
}
.menu-item:hover { background: #EFEFF2; }
.menu-item.active { background: var(--violet-bg); color: var(--violet); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--line);
  background: #FCFCFD;
}
.crumb { font-size: 15px; font-weight: 600; color: var(--ink); }
.admin { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.admin b { color: var(--ink-2); font-weight: 600; }
.admin .sep { color: #D5D5DC; }
.admin a { color: var(--ink-3); text-decoration: none; cursor: pointer; }
.admin a:hover { color: var(--violet); }

.content { padding: 20px 24px 40px; }

/* ------------------------------ 卡片 ------------------------------ */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }

/* KPI 卡 */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 16px;
}
.kpi-title { font-size: 12px; color: var(--ink-3); }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--ink); margin-top: 8px; line-height: 1.15; }
.kpi-value.warn { color: var(--red); }
.kpi-value.good { color: var(--green); }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* ---------------------------------------------------------------------------
   页面区块：stack / 状态条 / 分段面板（上游对接页 2026-09-22 重构）
   背景：原来顶部是「4 张等宽 KPI + 一排标签 + 一张内容卡」三层横条，
   其中「连接状态」占 1/4 版面却只有一个已配置/未配置，信息密度过低。
   现在：连接状态 → 细状态条（带就地测试）；KPI 从 4 列改 3 列；标签栏并进内容卡。
   --------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 14px; }

.statusbar {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 14px; font-size: 12px; color: var(--ink-2);
}
.statusbar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.statusbar b { font-size: 13px; font-weight: 600; color: var(--ink); }
.statusbar .sb-meta { color: var(--ink-3); }
.statusbar .sb-meta::before { content: '·'; margin: 0 8px; color: #D5D5DC; }
.statusbar .sb-spacer { flex: 1; }
.statusbar .sb-out { color: var(--ink-2); }
.statusbar .btn { flex: none; }
.statusbar.bad { background: #FFF8F8; border-color: #FFE0DE; }
.statusbar.bad .dot { background: var(--red); }
.statusbar.bad b { color: var(--red); }

.kpis.k3 { grid-template-columns: repeat(3, 1fr); }

.panel { padding: 0; overflow: hidden; }
.panel .tabs {
  display: flex; gap: 2px; padding: 4px 12px 0;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.panel .tab {
  padding: 11px 14px; font-size: 13px; color: var(--ink-2);
  cursor: pointer; user-select: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.panel .tab:hover { color: var(--ink); }
.panel .tab.active { color: var(--violet); font-weight: 600; border-bottom-color: var(--violet); }
.panel-body { padding: 16px 18px; }
.pane { min-width: 0; }

/* ------------------------------ 筛选 / 按钮 ------------------------------ */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; }
.chip {
  height: 30px; padding: 0 14px; border-radius: 15px;
  display: inline-flex; align-items: center;
  font-size: 12px; color: var(--ink-2); background: #fff;
  border: 1px solid var(--line); cursor: pointer; user-select: none;
}
.chip.active { background: var(--violet-bg); color: var(--violet); font-weight: 600; border-color: transparent; }

.btn {
  height: 32px; padding: 0 16px; border-radius: 16px; border: none;
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: #D8D8DF; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.link { color: var(--violet); cursor: pointer; font-size: 12px; }
.link:hover { text-decoration: underline; }
.link.gray { color: var(--ink-3); }
.link + .link { margin-left: 10px; }

/* ------------------------------ 表格 ------------------------------ */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 400; color: var(--ink-3);
  padding: 10px 8px; white-space: nowrap;
}
.table td {
  font-size: 13px; color: var(--ink); padding: 14px 8px;
  border-top: 1px solid #F4F4F7; vertical-align: middle;
}
.table tr:hover td { background: #FCFCFD; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.tag { display: inline-block; font-size: 12px; }
.tag.green { color: var(--green); }
.tag.red { color: var(--red); }
.tag.gray { color: var(--ink-3); }
.tag.violet { color: var(--violet); }
.tag.amber { color: #D97706; }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; font-size: 12px; color: var(--ink-3);
}
.pager .nav { display: flex; align-items: center; gap: 12px; }
.pager .nav span[data-p] { cursor: pointer; }
.pager .nav span[data-p]:hover { color: var(--violet); }
.pager .nav span.disabled { color: #C9C9D2; cursor: default; }

/* ------------------------------ 表单 ------------------------------ */
.form-row { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.form-row > label { width: 132px; flex: 0 0 132px; font-size: 12px; color: var(--ink-3); padding-top: 10px; }
.form-row .ctrl { flex: 1; min-width: 0; }
.form-row .hint { font-size: 11px; color: var(--ink-3); margin-top: 6px; }

.input, .textarea, .select {
  width: 100%; background: var(--fill); border: 1px solid transparent; border-radius: 8px;
  padding: 9px 12px; font-size: 13px; color: var(--ink); font-family: inherit; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: #C9C2FF; background: #fff; }
.textarea { min-height: 130px; line-height: 1.7; resize: vertical; }
.inline { display: flex; gap: 10px; align-items: center; }
.inline .input { width: 120px; }

/* ------------------------------ 进度条 ------------------------------ */
.prog { height: 6px; border-radius: 3px; background: #EFEFF3; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--grad); border-radius: 3px; }

/* ------------------------------ 明细行 ------------------------------ */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-top: 1px solid #F4F4F7;
}
.row-item:first-child { border-top: none; }
.row-item .t { font-size: 13px; color: var(--ink); }
.row-item .s { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.row-item .v { font-size: 13px; font-weight: 600; }
.v.plus { color: var(--green); }

.section-h { font-size: 13px; font-weight: 600; color: var(--ink); margin: 18px 0 10px; }
.section-h:first-child { margin-top: 0; }

/* ------------------------------ 模态 / 提示 ------------------------------ */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box {
  width: 520px; max-width: calc(100vw - 40px); max-height: 86vh; overflow: auto;
  background: #fff; border-radius: 14px; padding: 20px 22px;
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 8px; z-index: 90;
}

/* ------------------------------ 任务监控：视频缩略图 + 预览 ------------------------------ */
.vthumb {
  position: relative; width: 72px; height: 96px; border-radius: 6px;
  overflow: hidden; background: #111; cursor: pointer; border: 1px solid var(--line);
}
.vthumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .vplay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; background: rgba(0,0,0,.18); text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.vthumb.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 11px; background: var(--fill); cursor: default; border-style: dashed;
}
.video-preview video { display: block; }

/* ------------------------------ 抽帧做封面：独立浮层（高于编辑弹窗，互不覆盖） ------------------------------ */
.cf-overlay {
  position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.cf-card {
  width: 560px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
.cf-title { font-size: 15px; font-weight: 600; color: #18191C; margin-bottom: 6px; }
.cf-card video { width: 100%; max-height: 56vh; border-radius: 10px; background: #000; display: block; }
.cf-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* ------------------------------ 登录 ------------------------------ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 420px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 32px 28px; text-align: center;
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; background: var(--grad);
  margin: 0 auto 14px; color: #fff; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.login-title { font-size: 17px; font-weight: 700; }
.login-sub { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.qr {
  width: 176px; height: 176px; margin: 22px auto 12px; border: 1px solid var(--line);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: #fff; position: relative;
}
.qr .ph { font-size: 12px; color: var(--ink-3); padding: 0 18px; line-height: 1.7; }
.login-tip { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* 账号密码登录表单 */
.login-form { margin-top: 22px; text-align: left; }
.login-field { display: block; margin-bottom: 14px; }
.login-field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.login-field input {
  width: 100%; height: 42px; padding: 0 12px; font-size: 14px; color: var(--ink-1);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
  font-family: inherit;
}
.login-field input:focus { border-color: #6E5BFF; box-shadow: 0 0 0 3px rgba(110,91,255,.12); }
.login-btn { width: 100%; height: 44px; margin-top: 6px; font-size: 15px; font-weight: 600; }
.login-err { min-height: 18px; margin-top: 10px; font-size: 12px; color: #E5484D; text-align: center; }

.empty { padding: 40px 0; text-align: center; color: var(--ink-3); font-size: 13px; }
.mt16 { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* 三列等宽（成本页三张实测卡片用）；窄屏回落单列 */
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid3 { grid-template-columns: 1fr; } }
.muted { color: var(--ink-3); }
.right { text-align: right; }

/* 概览图表 */
.chart-wrap { height: 190px; background: var(--fill); border-radius: 10px; padding: 12px; }
.chart-wrap svg { width: 100%; height: 100%; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.todo-item { font-size: 12px; color: var(--ink-2); padding: 5px 0; }
.todo-item::before { content: '·'; margin-right: 6px; color: var(--ink-3); }
.todo-rule {
  margin-top: 12px; background: var(--fill); border-radius: 8px;
  padding: 9px 12px; font-size: 12px; color: var(--ink-3);
}
