:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #2563eb;
  --primary-soft: #eff4ff;
  --success: #059669;
  --success-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fffaeb;
  --danger: #dc2626;
  --danger-soft: #fef3f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }

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

.sidebar {
  width: 212px;
  flex: 0 0 212px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: #101828; color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: -0.5px;
}
.brand-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--faint); }

.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav-group { font-size: 11px; color: var(--faint); padding: 12px 8px 4px; letter-spacing: 0.4px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  color: #344054; font-size: 13.5px;
}
.nav a:hover { background: #f2f4f7; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav-ico { width: 16px; text-align: center; opacity: 0.75; font-size: 13px; }

.side-foot { padding: 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--faint); }
.side-foot .mock-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-right: 5px; }
.side-foot .live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin-right: 5px; }
.side-foot .warn-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-right: 5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; flex: 0 0 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #eef2ff; color: #3538cd;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}

.content { padding: 20px; max-width: 1320px; width: 100%; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; }
.page-desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.card-head h3 { font-size: 13.5px; }
.card-body { padding: 16px; }

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

.kpi { padding: 14px 16px; }
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 24px; font-weight: 600; letter-spacing: -0.4px; margin-top: 6px; }
.kpi-foot { font-size: 11.5px; color: var(--faint); margin-top: 4px; }

.trend-up { color: var(--success); font-weight: 500; }
.trend-down { color: var(--danger); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: #fff; color: #344054; font-size: 13px; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { color: var(--danger); border-color: #fda29b; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, .select, textarea.input {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
  outline: none; max-width: 100%;
}
textarea.input { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
.badge-gray { background: #f2f4f7; color: #475467; border-color: #e4e7ec; }
.badge-blue { background: var(--primary-soft); color: #1d4ed8; border-color: #d1e0ff; }
.badge-green { background: var(--success-soft); color: #027a48; border-color: #abefc6; }
.badge-amber { background: var(--warn-soft); color: #b54708; border-color: #fedf89; }
.badge-red { background: var(--danger-soft); color: #b42318; border-color: #fecdca; }
.badge-purple { background: #f4f3ff; color: #5925dc; border-color: #d9d6fe; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--muted);
  font-size: 11.5px; text-transform: none;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: #fcfcfd;
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid #f2f4f7; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fcfcfd; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

.empty { padding: 40px 16px; text-align: center; color: var(--faint); font-size: 13px; }
.loading { padding: 40px; text-align: center; color: var(--faint); }

/* ---------- 图表 ---------- */
.chart-wrap { padding: 8px 4px 0; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); padding: 0 12px 10px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ---------- 日历 ---------- */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.cal-head div { padding: 8px; font-size: 11.5px; color: var(--muted); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 96px; border-right: 1px solid #f2f4f7; border-bottom: 1px solid #f2f4f7; padding: 6px; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.out { background: #fcfcfd; color: var(--faint); }
.cal-date { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.cal-item {
  font-size: 11px; padding: 2px 5px; border-radius: 4px; margin-bottom: 3px;
  background: var(--primary-soft); color: #1d4ed8; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-item.s-published { background: var(--success-soft); color: #027a48; }
.cal-item.s-failed { background: var(--danger-soft); color: #b42318; }
.cal-item.s-pending_review { background: var(--warn-soft); color: #b54708; }
.cal-item.s-draft { background: #f2f4f7; color: #475467; }
.cal-item.s-inbox_ready { background: #f4f3ff; color: #5925dc; }

/* ---------- 素材 ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.media-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.media-thumb { height: 118px; background: #f2f4f7; display: grid; place-items: center; overflow: hidden; position: relative; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb.is-clickable { cursor: pointer; }
.media-thumb.is-clickable:hover .media-play { background: rgba(16, 24, 40, 0.62); transform: translate(-50%, -50%) scale(1.06); }
.media-thumb.is-clickable:hover video { opacity: 0.86; }
.media-thumb video { transition: opacity 0.15s; }
.media-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(16, 24, 40, 0.48); color: #fff;
  display: grid; place-items: center; font-size: 14px; line-height: 1;
  padding-left: 3px; pointer-events: none; transition: background 0.15s, transform 0.15s;
  backdrop-filter: blur(2px);
}
.media-play-img { padding-left: 0; font-size: 15px; }
.media-dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(16, 24, 40, 0.7); color: #fff;
  font-size: 11px; line-height: 1; padding: 3px 5px; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.media-meta { padding: 9px 10px; }
.media-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 素材播放器 */
.player-box {
  width: min(92vw, 880px); background: #171a21; border-radius: 14px;
  overflow: hidden; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.35);
  display: flex; flex-direction: column; max-height: 92vh;
}
.player-head {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid #262b36; flex: none;
}
.player-name {
  font-size: 13px; font-weight: 600; color: #e8eaed; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-head .icon-btn { color: #9aa4b2; }
.player-head .icon-btn:hover { color: #fff; }
.player-stage {
  background: #000; display: grid; place-items: center;
  flex: 1; min-height: 0; overflow: hidden;
}
.player-stage video, .player-stage img {
  max-width: 100%; max-height: calc(92vh - 110px);
  display: block; object-fit: contain;
}
.player-foot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 9px 14px; border-top: 1px solid #262b36;
  font-size: 11.5px; color: #9aa4b2; flex: none;
}
.player-foot .btn-sm { background: #242a35; color: #c2cad6; border-color: #2b3140; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 8px 30px rgba(16, 24, 40, 0.06); }
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-hint { margin-top: 16px; padding: 10px 12px; background: #f9fafb; border: 1px dashed var(--border-strong); border-radius: 8px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45);
  display: grid; place-items: center; padding: 20px; z-index: 100;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(16, 24, 40, 0.2);
}
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.icon-btn { border: none; background: none; font-size: 18px; color: var(--faint); cursor: pointer; line-height: 1; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #101828; color: #fff; padding: 9px 14px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
  animation: toast-in 0.18s ease-out; max-width: 340px;
}
.toast.err { background: #b42318; }
.toast.ok { background: #027a48; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- 进度条 ---------- */
.bar { height: 6px; background: #f2f4f7; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.plan-card.current { border-color: var(--primary); background: var(--primary-soft); }
.plan-price { font-size: 20px; font-weight: 600; margin: 6px 0 2px; }
.plan-price span { font-size: 12px; color: var(--muted); font-weight: 400; }

.notice { padding: 10px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.7; }
.notice-warn { background: var(--warn-soft); border: 1px solid #fedf89; color: #93370d; }
.notice-info { background: var(--primary-soft); border: 1px solid #d1e0ff; color: #1e40af; }
.notice-danger { background: var(--danger-soft); border: 1px solid #fecdca; color: #912018; }

.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-group, .side-foot { display: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

/* ---------- 扫码接入（QR Connect） ---------- */
.qr-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.qr-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; }
.qr-box svg { width: 100%; height: auto; display: block; border-radius: 4px; }
.qr-ticket { font-size: 11px; color: var(--faint); margin-top: 8px; font-variant-numeric: tabular-nums; }
.qr-steps { list-style: none; margin: 0 0 14px; padding: 0; counter-reset: qr; }
.qr-steps li { position: relative; padding: 0 0 12px 26px; font-size: 13px; }
.qr-steps li:last-child { padding-bottom: 0; }
.qr-steps li::before {
  counter-increment: qr; content: counter(qr); position: absolute; left: 0; top: 1px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.qr-steps b { display: block; font-weight: 500; }
.qr-steps span { color: var(--faint); font-size: 12px; }
.qr-status {
  display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 10px 12px;
  border-radius: 8px; background: #f8fafc; border: 1px solid var(--border);
}
.qr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 8px; }
.qr-dot.pulse { animation: qrpulse 1.4s infinite; }
@keyframes qrpulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
.qr-dot.ok { background: var(--success); }
.qr-dot.warn { background: var(--warn); }
.qr-dot.idle { background: var(--faint); }
.qr-link {
  font-size: 11px; color: var(--muted); word-break: break-all; background: #f8fafc;
  border: 1px dashed var(--border-strong); border-radius: 6px; padding: 6px 8px; margin-top: 8px;
}
@media (max-width: 640px) {
  .qr-wrap { grid-template-columns: 1fr; }
  .qr-box { max-width: 230px; margin: 0 auto; }
}
