/* ===== 后台管理 ===== */

body.admin-body { background: var(--bg); }

.hidden { display: none !important; }

/* --- 登录 --- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 372px;
  padding: 30px 28px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.login-card .brand { justify-content: center; margin-bottom: 6px; }

.login-card h1 {
  font-size: 17px;
  font-weight: 650;
  text-align: center;
  margin: 14px 0 4px;
}

.login-card p.sub {
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
  margin: 0 0 22px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.field textarea { resize: vertical; min-height: 66px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }

.check-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.check-line input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

/* 输入框内嵌按钮（网址自动获取） */
.input-with-btn { position: relative; }
.input-with-btn input { padding-right: 92px; }

.btn-fetch {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}

.btn-fetch:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
}

.btn-fetch:disabled { opacity: 0.55; cursor: default; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, opacity 0.16s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.btn-outline:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }

.btn-danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }

.btn-block { width: 100%; }

.err-msg {
  font-size: 12.5px;
  color: var(--danger);
  min-height: 18px;
  margin-top: -4px;
  margin-bottom: 8px;
}

/* --- 主框架 --- */
.admin-shell {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.side {
  width: 252px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
}

.side .brand { padding: 4px 8px 14px; }

.side-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-3);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.2px;
  transition: background 0.14s, color 0.14s;
}

.cat-item:hover { background: var(--surface-2); color: var(--text); }

/* 分类拖拽排序 */
.cat-item.dragging { opacity: 0.4; }
.cat-item.drop-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.cat-item.drop-after { box-shadow: inset 0 -2px 0 0 var(--accent); }

.cat-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.cat-item .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-item .n { font-size: 11.5px; color: var(--text-3); font-weight: 400; }

.cat-item .private-tag {
  flex: none;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10px;
  line-height: 15px;
}

.cat-item .edit {
  opacity: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  padding: 2px;
  display: grid;
  place-items: center;
  border-radius: 5px;
}

.cat-item:hover .edit { opacity: 0.65; }
.cat-item .edit:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }

.cat-item .move {
  opacity: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  padding: 1px;
  display: grid;
  place-items: center;
  border-radius: 5px;
}

.cat-item .move svg { width: 12px; height: 12px; }
.cat-item:hover .move { opacity: 0.55; }
.cat-item .move:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }
.cat-item .move:disabled { opacity: 0 !important; pointer-events: none; }

.side-foot {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
  display: grid;
  gap: 2px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.14s, color 0.14s;
}

.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link svg { width: 15px; height: 15px; flex: none; opacity: 0.8; }

/* --- 主区 --- */
.main-area {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 80px;
}

.main-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.main-head h1 {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.3px;
  margin: 0;
}

.main-head .sub { color: var(--text-3); font-size: 12.5px; }
.main-head .spacer { flex: 1; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-search {
  height: 38px;
  width: 190px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  font-size: 13px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.admin-search::placeholder { color: var(--text-3); }

.admin-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.admin-filter {
  height: 38px;
  max-width: 132px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  font-size: 13px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.admin-filter:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

/* --- 书签行 --- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 8px;
  transition: border-color 0.14s, box-shadow 0.14s, opacity 0.14s;
}

.row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

/* 拖拽排序 */
.row[draggable='true'] { cursor: default; }
.row.dragging { opacity: 0.4; }
.row.drop-before { box-shadow: 0 -2px 0 0 var(--accent); border-color: var(--accent); }
.row.drop-after { box-shadow: 0 2px 0 0 var(--accent); border-color: var(--accent); }
.row.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

/* 行内复选框 */
.row-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.row-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.row .info { flex: 1; min-width: 0; }

.row .t {
  font-size: 13.6px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .u {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .d {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 16px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-3);
  margin-left: 5px;
  vertical-align: 1px;
}

.check-badge {
  display: inline-block;
  max-width: 168px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 16px;
  vertical-align: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.check-badge.ok {
  color: #15803d;
  background: color-mix(in srgb, #16a34a 13%, transparent);
}

.check-badge.limited {
  color: #b45309;
  background: color-mix(in srgb, #d97706 15%, transparent);
}

.check-badge.bad {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 13%, transparent);
}

[data-theme='dark'] .check-badge.ok { color: #4ade80; }
[data-theme='dark'] .check-badge.limited { color: #fbbf24; }

.row .acts {
  display: flex;
  gap: 2px;
  opacity: 0.45;
  transition: opacity 0.14s;
}

.row:hover .acts { opacity: 1; }

.mini-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.mini-btn:hover { background: var(--surface-2); color: var(--text); }
.mini-btn.del:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.mini-btn svg { width: 14px; height: 14px; }
.mini-btn:disabled { opacity: 0.25; cursor: default; }

.empty-box {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-3);
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  font-size: 13px;
}

/* --- 弹窗 --- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 15, 0.55);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadeIn 0.14s ease;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: pop 0.16s ease;
}

@keyframes pop { from { transform: scale(0.97) translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal-head {
  padding: 16px 20px 12px;
  font-size: 15px;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body { padding: 4px 20px 8px; max-height: 62vh; overflow-y: auto; }

.modal-foot {
  padding: 14px 20px 18px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-foot .spacer { flex: 1; }

.close-x {
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}

.close-x:hover { background: var(--surface-2); color: var(--text); }

/* --- 任务进度弹窗 --- */
.task-modal { max-width: 560px; }

.task-progress {
  height: 8px;
  margin: 8px 0 10px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.task-bar {
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.task-meta { font-size: 12.5px; color: var(--text-2); }
.task-detail { min-height: 18px; margin-top: 4px; font-size: 12px; color: var(--text-3); }

.task-result {
  max-height: 34vh;
  margin-top: 12px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

.task-item a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--accent);
}

.task-item span {
  flex: none;
  font-size: 11.5px;
  color: var(--danger);
}

.task-more { padding: 8px 0 0; font-size: 12px; color: var(--text-3); }

/* --- 批量操作条 --- */
.batch-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 14px);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 40px -12px rgba(16, 24, 40, 0.3);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.batch-bar.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.batch-count {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.batch-count b { color: var(--accent); font-size: 14px; }

.batch-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex: none;
}

.btn.batch-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 9px;
}

.batch-select {
  height: 32px;
  max-width: 160px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: 12.5px;
  outline: none;
}

/* --- 合并分类 --- */
.merge-row { display: flex; gap: 8px; }
.merge-row select {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
}

/* --- Toast --- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: #16181d;
  color: #fff;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 80vw;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #b91c1c; }

/* --- 响应式 --- */
@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .side {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }
  .side-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .cat-item { flex: none; }
  .cat-item .move { opacity: 0.55; }
  .side-foot { display: flex; flex-wrap: wrap; gap: 4px; }
  .side-link { width: auto; }
  .main-area { padding: 18px 16px 60px; }
  .toolbar { width: 100%; }
  .admin-search { flex: 1; min-width: 120px; }
  .row .acts { opacity: 1; }
  .row .d { display: none; }
}
