* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2329;
  background: #f5f6f8;
}
a { color: #2463eb; text-decoration: none; }
.muted { color: #8a8f99; }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.topbar {
  display: flex; align-items: center; gap: 32px;
  height: 56px; padding: 0 24px;
  background: #1f2937; color: #fff;
}
.topbar .brand { font-weight: 600; font-size: 16px; }
.topbar nav { display: flex; gap: 20px; flex: 1; }
.topbar nav a, .topbar .user a { color: #cbd5e1; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; }
.topbar .user { color: #cbd5e1; }

.container { max-width: 1400px; margin: 24px auto; padding: 0 24px; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 24px; }
.card.narrow { max-width: 640px; margin: 0 auto; }
.card h2 { margin: 0 0 20px; font-size: 18px; }

label { display: block; margin-bottom: 16px; color: #4b5563; }
label input:not([type=checkbox]) { display: block; width: 100%; margin-top: 6px; }
label.checkbox { display: flex; align-items: center; gap: 8px; }
input {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit;
}
input:focus { outline: none; border-color: #2463eb; box-shadow: 0 0 0 2px rgba(36,99,235,.15); }

.btn {
  display: inline-block; padding: 7px 14px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; color: #1f2329; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #2463eb; color: #2463eb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: #2463eb; border-color: #2463eb; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1d4fd8; color: #fff; }
.btn.danger:hover:not(:disabled) { border-color: #dc2626; color: #dc2626; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.link { border: none; padding: 0 4px; color: #2463eb; background: none; font-size: 12px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 12px; }

.alert { padding: 8px 12px; margin-bottom: 16px; border-radius: 6px; background: #fef2f2; color: #b91c1c; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 360px; }
.login-card h1 { margin: 0 0 24px; font-size: 20px; text-align: center; }

.toolbar { display: flex; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.search { display: flex; gap: 8px; }
.search input { width: 260px; }

.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: middle; }
th { background: #fafbfc; color: #6b7280; font-weight: 500; white-space: nowrap; }
td.filename { white-space: nowrap; }
td.filename a { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
td.ops { display: flex; flex-wrap: wrap; gap: 6px; min-width: 300px; }
td.empty { text-align: center; color: #8a8f99; padding: 40px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; background: #f3f4f6; color: #6b7280; }
.badge.queued { background: #fef9c3; color: #a16207; }
.badge.running { background: #dbeafe; color: #1d4ed8; }
.badge.done { background: #dcfce7; color: #15803d; }
.badge.skipped { background: #f3f4f6; color: #9ca3af; }
.badge.failed { background: #fee2e2; color: #b91c1c; cursor: help; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; }

.progress { height: 10px; margin: 20px 0 8px; border-radius: 5px; background: #eef0f3; overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: #2463eb; transition: width .2s; }

.toast {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 6px; background: #1f2937; color: #fff; z-index: 10;
}
.toast.error { background: #dc2626; }
[hidden] { display: none !important; }

.strong { font-weight: 500; }
.breadcrumb { margin-bottom: 16px; font-size: 16px; }
.breadcrumb #drama-name { font-weight: 600; }
.upload-card { margin-bottom: 20px; }
.upload-form { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.upload-form label.checkbox { margin: 0; }
.upload-list { display: grid; gap: 10px; }
.upload-list:not(:empty) { margin-top: 12px; }
.upload-item .upload-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.upload-item .upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .upload-status { white-space: nowrap; }
.upload-item .progress { margin: 4px 0 0; height: 6px; }
.upload-item[data-state=done] .progress-bar { background: #16a34a; }
.upload-item[data-state=failed] .progress-bar { background: #dc2626; }
.upload-item[data-state=failed] .upload-status { color: #dc2626; }
.toolbar { align-items: center; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #4b5563; }
.drama-id { margin-left: 16px; }
td .url { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; font-size: 12px; color: #4b5563; }
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); }
.modal-body { width: min(960px, 92vw); padding: 16px; border-radius: 8px; background: #fff; }
.modal-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
.modal video { display: block; width: 100%; max-height: 75vh; background: #000; }

.step-msg { margin-top: 2px; font-size: 11px; color: #6b7280; white-space: nowrap; }
.tag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 400; background: #ecfdf5; color: #047857; }
.actions { align-items: center; }

select { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff; }
label select { display: block; width: 100%; margin-top: 6px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; align-items: start; }
.settings-grid table { margin-top: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form input { flex: 1 1 140px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.wm-preview { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 16px; padding: 16px;
  border: 1px dashed #d1d5db; border-radius: 8px;
  background: repeating-conic-gradient(#f3f4f6 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.wm-preview img { max-width: 100%; max-height: 160px; }

textarea { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; word-break: break-all; }
.section { margin-top: 20px; }
.fetch-form { display: flex; gap: 8px; }
.fetch-form input { flex: 1 1 600px; min-width: 0; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px; }
.crumbs { font-size: 15px; }
.sync-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sync-bar select { max-width: 220px; }
.sync-bar input { width: 180px; }
.section-title { margin: 0; font-size: 16px; }
td.res-name { max-width: 480px; word-break: break-all; }
.task-progress { min-width: 140px; }
.task-progress .progress { margin: 0 0 2px; height: 6px; }
.error-msg { color: #b91c1c; white-space: normal; max-width: 260px; }
