:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e4e7ec;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #5b5bd6;
  --primary-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #d97706;
  --amber-soft: #fef4e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------------------------------- 布局 ---------------------------------- */

header.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

nav.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav.tabs button {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
}
nav.tabs button:hover { background: var(--panel-2); color: var(--text); }
nav.tabs button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

main { padding: 20px; max-width: 1440px; margin: 0 auto; }

.section { display: none; }
.section.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.panel h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.panel h3 .spacer { flex: 1; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 10px; }
.grow { flex: 1; min-width: 160px; }

/* ---------------------------------- 控件 ---------------------------------- */

button.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
button.btn:hover { border-color: var(--primary); color: var(--primary); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.btn.primary:hover { filter: brightness(1.07); color: #fff; }
button.btn.danger:hover { border-color: var(--red); color: var(--red); }
button.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }

input.inp, select.inp, textarea.inp {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
  width: 100%;
}
input.inp:focus, select.inp:focus, textarea.inp:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 91, 214, .12); }
textarea.inp { resize: vertical; min-height: 90px; line-height: 1.5; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.field.inline { flex-direction: row; align-items: center; gap: 6px; }
label.field.inline input, label.field.inline select { width: auto; }

.hint { color: var(--muted); font-size: 12.5px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.empty { text-align: center; color: var(--muted); padding: 36px 10px; }

/* ---------------------------------- 徽标 ---------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.tag.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.tag.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag.blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* --------------------------------- 资产网格 -------------------------------- */

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.asset-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  transition: .15s;
}
.asset-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.asset-card.dragging { opacity: .4; }
.asset-card .thumb {
  height: 150px;
  background: #f0f1f4 center/contain no-repeat;
  cursor: zoom-in;
  position: relative;
}
.asset-card .thumb .code {
  position: absolute;
  left: 6px; top: 6px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
}
.asset-card .meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.asset-card .meta input.inp { padding: 5px 8px; }
.asset-card .meta .ops { display: flex; gap: 6px; justify-content: space-between; align-items: center; }

/* ---------------------------------- 表格 ---------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table.grid { border-collapse: collapse; width: 100%; min-width: 1100px; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.grid th { background: var(--panel-2); font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
table.grid tr:hover td { background: #fcfcfe; }
table.grid td input.inp, table.grid td select.inp { padding: 4px 7px; min-width: 90px; }
table.grid td.col-no { width: 62px; }
table.grid td.col-dur { width: 72px; }
table.grid tr.dragging { opacity: .4; }
td.handle { cursor: grab; color: var(--muted); width: 30px; }

.shot-thumb {
  width: 62px; height: 36px;
  border-radius: 6px;
  background: #f0f1f4 center/cover no-repeat;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: inline-block;
}

/* --------------------------------- 任务卡片 -------------------------------- */

.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.task-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.task-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(91, 91, 214, .18); }
.task-card video, .task-card .poster {
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: #000;
  display: block;
}
.task-card .body { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.task-card .body .title { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.task-card .body .ops { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.task-card .err { color: var(--red); font-size: 12px; word-break: break-all; max-height: 54px; overflow: auto; }

/* ---------------------------------- 弹窗 ---------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 28, .62);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal.show { display: flex; }
.modal .box {
  background: #fff;
  border-radius: 14px;
  max-width: 92vw;
  max-height: 90vh;
  overflow: auto;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal .box img { max-width: 88vw; max-height: 76vh; display: block; border-radius: 8px; }
.modal .box video { max-width: 88vw; max-height: 76vh; display: block; border-radius: 8px; background: #000; }
.modal .box .cap { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 10px; }

/* ---------------------------------- 提示 ---------------------------------- */

#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2430;
  color: #fff;
  padding: 9px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: fade .2s ease;
  max-width: 380px;
}
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------------------------------- 统计 ---------------------------------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-card .num { font-size: 24px; font-weight: 700; }
.stat-card .lbl { color: var(--muted); font-size: 13px; }

.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); width: 0; transition: .3s; }

.spin {
  width: 14px; height: 14px;
  border: 2px solid rgba(91, 91, 214, .25);
  border-top-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  animation: sp .8s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

.login-wrap { max-width: 380px; margin: 12vh auto; }
.checkline { display: flex; align-items: center; gap: 8px; }
