:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #12141a;
  --ink-2: #3d4350;
  --muted: #747b8a;
  --line: #e6e8ee;
  --line-2: #eef0f4;
  --accent: #fe2c55;
  --accent-soft: #fff1f4;
  --ok: #0f9d58;
  --ok-soft: #eaf7f0;
  --warn: #b45309;
  --warn-soft: #fdf3e4;
  --err: #d92d20;
  --err-soft: #fdeceb;
  --blue: #2563eb;
  --blue-soft: #eef3ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .04);
  --sidebar: #0f1115;
  --sidebar-ink: #c9cdd6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, #ffe4ea 0%, transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 30px; box-shadow: 0 24px 60px rgba(16,24,40,.10); }
.login-card .brand { margin-bottom: 6px; }
.login-card p { margin: 0 0 22px; }
.login-hint { color: var(--err); font-size: 12.5px; min-height: 18px; margin: 12px 0 0; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 15.5px;
  padding: 6px 10px 22px; letter-spacing: .2px; }
.brand.big { font-size: 20px; padding: 0 0 4px; color: var(--ink); }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(254,44,85,.18); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 10px;
  color: #aab0bd; font-size: 13.8px; transition: background .15s, color .15s; }
.nav a svg { width: 18px; height: 18px; opacity: .9; }
.nav a:hover { background: #1a1d24; color: #fff; }
.nav a.active { background: #22262f; color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px;
  color: #8d93a1; font-size: 12.5px; border-top: 1px solid #1d2129; }
.sidebar-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sidebar-foot .dot.off { background: #6b7280; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 28px 14px; }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.topbar p { margin: 2px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.pill { background: #fff; border: 1px solid var(--line); padding: 6px 11px; border-radius: 999px;
  font-size: 12px; color: var(--ink-2); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { border-color: #d6d9e0; color: var(--ink); }
.content { padding: 6px 28px 40px; max-width: 1500px; width: 100%; }

/* ---------- primitives ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px; }
.card-head h2 { margin: 0; font-size: 15px; }
.card-body { padding: 0 18px 18px; }
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); padding: 8px 13px; border-radius: 10px; cursor: pointer; font-size: 13px;
  transition: border-color .15s, background .15s, transform .05s; white-space: nowrap; }
.btn:hover { border-color: #cfd4dd; background: #fafbfc; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #e9264d; border-color: #e9264d; }
.btn.dark { background: #171a21; border-color: #171a21; color: #fff; }
.btn.dark:hover { background: #242936; border-color: #242936; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #f3c9c5; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #f4a8b8; box-shadow: 0 0 0 3px rgba(254,44,85,.10); }
.field textarea { min-height: 96px; resize: vertical; font-family: Consolas, monospace; font-size: 12.5px; }
.field .hint { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- kpi ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 680; letter-spacing: -.6px; margin-top: 6px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi .spark { color: var(--accent); }
.kpi.accent { background: linear-gradient(180deg, #fff 0%, #fff7f8 100%); }

/* ---------- charts ---------- */
.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: #ffd3dc; transition: fill .15s; }
.chart .bar:hover { fill: var(--accent); }
.chart .bar.today { fill: var(--accent); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 10px; }
.chart .value { fill: var(--ink-2); font-size: 10px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; color: var(--muted); font-weight: 550; font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 560; }
.cell-sub { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 6px; }
.num { font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.pending { background: var(--blue-soft); color: var(--blue); }
.badge.publishing { background: var(--warn-soft); color: var(--warn); }
.badge.published { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--err-soft); color: var(--err); }
.badge.canceled { background: #f1f2f5; color: #616777; }
.badge.skipped { background: #f4f0ff; color: #6d4bd8; }
.badge.scheduled { background: #f4f0ff; color: #6d4bd8; }
.badge.ready { background: #f1f2f5; color: #616777; }
.badge.queued { background: var(--blue-soft); color: var(--blue); }
.badge.posted { background: var(--ok-soft); color: var(--ok); }
.badge.missing { background: var(--err-soft); color: var(--err); }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: #f1f2f5; color: #616777; }

.avatar { width: 30px; height: 30px; border-radius: 9px; background: #eceef2; color: #555b69;
  display: grid; place-items: center; font-size: 12px; font-weight: 650; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .name { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  color: var(--ink-2); font-size: 13px; }

.tab:hover { background: #f6f7f9; }
.tab.active { background: #171a21; color: #fff; }
.search { display: flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 0 11px; height: 36px; min-width: 220px; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.search input { border: 0; outline: none; background: transparent; width: 100%; }
select.control { height: 36px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 0 10px; outline: none; }
.spacer { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  font-size: 12.5px; color: var(--ink-2); }
.chip b { font-size: 15px; margin-right: 4px; color: var(--ink); }

/* ---------- videos ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; }
.vcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  position: relative; transition: box-shadow .15s, border-color .15s; }
.vcard:hover { box-shadow: 0 8px 22px rgba(16,24,40,.07); }
.vcard.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(254,44,85,.15); }
.vthumb { aspect-ratio: 9 / 12; background: #101216 center/cover no-repeat; position: relative; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .dur { position: absolute; right: 7px; bottom: 7px; background: rgba(0,0,0,.62); color: #fff;
  font-size: 10.5px; padding: 2px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.vthumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  background: rgba(0,0,0,.18); opacity: 0; transition: opacity .15s; }
.vcard:hover .vthumb .play { opacity: 1; }
.vthumb .play svg { width: 38px; height: 38px; fill: rgba(255,255,255,.9); stroke: none; }
.vcheck { position: absolute; left: 8px; top: 8px; width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid #fff; background: rgba(0,0,0,.25); display: grid; place-items: center; cursor: pointer; }
.vcheck.on { background: var(--accent); border-color: var(--accent); }
.vcheck svg { width: 13px; height: 13px; color: #fff; display: none; }
.vcheck.on svg { display: block; }
.vmeta { padding: 9px 10px 10px; }
.vmeta .name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.vmeta .sub { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.selectbar { position: sticky; bottom: 16px; margin-top: 18px; background: #171a21; color: #fff;
  border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 14px 34px rgba(16,24,40,.22); z-index: 5; }
.selectbar .count { font-weight: 650; }
.selectbar .spacer { flex: 1; }
.selectbar .btn { background: transparent; border-color: #3a3f4b; color: #dfe3ea; }
.selectbar .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.selectbar input.control { background: #fff; color: #171a21; border: 1px solid var(--line);
  border-radius: 10px; padding: 0 10px; outline: none; }
.selectbar input.control:focus { border-color: var(--accent); }
.selectbar input.control::placeholder { color: #8b929e; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(12,15,20,.45); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 24px; z-index: 50; animation: fade .12s ease-out; }
.modal { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; background: #fff;
  border-radius: 18px; box-shadow: 0 30px 80px rgba(12,15,20,.28); animation: pop .14s ease-out; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 8px 22px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } }

.link-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.link-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font-size: 12.5px; }
.link-item .idx { width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; font-weight: 650; flex: none; }
.link-item a { color: var(--blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 260px; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.check-item:hover { background: #fafbfc; }
.check-item input { accent-color: var(--accent); }
.check-item .cap { margin-left: auto; color: var(--muted); font-size: 11.5px; }

.acct-copy { cursor: pointer; }
.acct-copy:hover { color: var(--accent); text-decoration: underline; }
.acct-ext { margin-left: 6px; color: var(--muted); font-size: 12px; text-decoration: none; }
.acct-ext:hover { color: var(--accent); }

/* ---------- batch jobs ---------- */
.batch-name { display: flex; align-items: center; gap: 8px; }
.caret { border: 0; background: none; padding: 2px 4px; cursor: pointer; color: var(--muted);
  font-size: 12px; transition: transform .15s; }
.batch-row { cursor: pointer; }
.batch-row:hover { background: #fafbfc; }
.batch-row.open .caret { transform: rotate(90deg); color: var(--accent); }
.batch-detail td { background: #fafbfc; padding: 0 12px 12px; }
.batch-detail-body { padding: 4px 0; }
table.mini th, table.mini td { font-size: 12.5px; padding: 6px 10px; }

/* ---------- video strip ---------- */
.vstrip { display: flex; flex-wrap: nowrap; gap: 6px; max-width: 440px; overflow-x: auto; padding-bottom: 4px; }
.vchip { position: relative; width: 46px; height: 62px; padding: 0; border: 1px solid var(--line);
  border-radius: 7px; overflow: hidden; cursor: pointer; background: #eceef2; flex: none; }
.vchip:hover { border-color: var(--accent); }
.vchip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vchip .vnum { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(17,20,26,.72);
  color: #fff; font-size: 10px; line-height: 15px; text-align: center; letter-spacing: -.2px; }
.v-tip { position: fixed; z-index: 120; width: 230px; background: #171a21; color: #fff;
  border-radius: 10px; padding: 8px; box-shadow: 0 14px 34px rgba(16,24,40,.34); pointer-events: none; }
.v-tip-img { width: 100%; height: 190px; border-radius: 7px; overflow: hidden; background: #000; margin-bottom: 7px; }
.v-tip-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.v-tip-body { font-size: 12px; line-height: 1.6; }
.v-tip-body .muted { color: #aeb4c0; }

/* ---------- manual batch picker ---------- */
.mb-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; }
.mb-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.mb-tools .control { height: 32px; flex: 1; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.pick-list { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 360px; }
.pick-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; font-size: 12.5px;
  border-bottom: 1px solid var(--line-2); cursor: pointer; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: #fafbfc; }
.pick-row input { accent-color: var(--accent); }
.pick-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .sub { color: var(--muted); font-size: 11.5px; }

/* ---------- misc ---------- */
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .35; }
.toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px;
  z-index: 90; }
.toast { background: #171a21; color: #fff; padding: 11px 15px; border-radius: 11px; font-size: 13px;
  box-shadow: 0 12px 30px rgba(16,24,40,.22); animation: pop .15s ease-out; max-width: 380px; }
.toast.err { background: #9f1d16; }
.toast.ok { background: #0d6b3d; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { margin: 0; font-size: 15px; }
.settings-card { padding: 18px; margin-bottom: 14px; }
.settings-card h3 { margin: 0 0 14px; font-size: 14px; }
.split { display: grid; grid-template-columns: 1.35fr .9fr; gap: 14px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 99px; background: #d9dce3;
  border: 0; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(16px); }
.toast a { color: #fff; text-decoration: underline; }
.loading { opacity: .55; pointer-events: none; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-text { color: var(--err); font-size: 12px; }
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.comment-item:last-child { border-bottom: 0; }
.reply { margin: 10px 0 0 32px; padding-left: 12px; border-left: 2px solid var(--line); }
.thread { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.msg-row { display: flex; }
.bubble { max-width: 72%; background: #f3f5f8; border-radius: 14px; padding: 9px 12px; font-size: 13px; }
.bubble.out { background: #171a21; color: #fff; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 12px; }
.composer textarea { flex: 1; min-height: 44px; max-height: 120px; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; resize: vertical; outline: none; }
.composer textarea:focus { border-color: #f4a8b8; box-shadow: 0 0 0 3px rgba(254,44,85,.10); }
.code-big { font: 700 28px/1.1 Consolas, "Courier New", monospace; letter-spacing: 4px; }
.notice { background: var(--warn-soft); color: #7a4a08; border: 1px solid #f2d9b5; border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 68px 1fr; }
  .sidebar { padding: 18px 8px; }
  .brand span:last-child, .nav a { font-size: 0; }
  .nav a { justify-content: center; padding: 12px 0; }
  .nav a svg { width: 20px; height: 20px; }
  .sidebar-foot span { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .topbar h1 { font-size: 18px; }
  .check-grid { grid-template-columns: 1fr; }
  .modal { max-height: 92vh; }
}
