:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-50: #eff6ff;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --success: #16a34a;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; border-color: var(--line); }
.btn-light:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-danger { background: var(--danger-50); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: #374151; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.6; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--primary-50);
  color: var(--primary);
  line-height: 1.6;
}
.tag-gray { background: #f3f4f6; color: var(--text-2); }
.tag-red { background: #fef2f2; color: var(--danger); }
.tag-green { background: #f0fdf4; color: var(--success); }

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 56px 20px;
  font-size: 14px;
}
.empty .empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .5; }

.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: #111827;
  color: #fff;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: var(--shadow-lg);
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .55);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 880px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.thumb-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.thumb-item { position: relative; width: 92px; }
.thumb-item[draggable="true"] { cursor: grab; }
.thumb-item.dragging { opacity: .35; }
.thumb-item img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f3f4f6;
}
.thumb-item .cover-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
}
.thumb-item .thumb-tools { display: flex; gap: 4px; margin-top: 5px; }
.thumb-item .thumb-tools button {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  font-size: 10.5px;
  padding: 3px 0;
  cursor: pointer;
  color: var(--text-2);
}
.thumb-item .thumb-tools button:hover { background: #f9fafb; color: var(--text); }
.thumb-item .thumb-tools .del:hover { background: var(--danger-50); color: var(--danger); border-color: #fecaca; }

.uploader {
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition: all .18s;
  background: #fafbfc;
  display: block;
}
.uploader:hover { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.uploader.dragover { border-color: var(--primary); background: var(--primary-50); color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.uploader input[type=file] { display: none; }
.uploader .up-icon { font-size: 22px; margin-bottom: 4px; }
.uploader .up-main { font-size: 14px; font-weight: 600; }
.uploader .up-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: .2s;
  cursor: pointer;
}
.switch .slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1e3a8a, #4c1d95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 34px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  margin: 0 auto 14px;
}
.login-card h2 { text-align: center; font-size: 19px; margin-bottom: 4px; }
.login-card .login-sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 22px; }
.login-tip { text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: 14px; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-side {
  width: 224px;
  background: #111827;
  color: #9ca3af;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-side-brand {
  padding: 20px 18px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #1f2937;
}
.admin-side-brand .dot {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.admin-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.admin-nav a:hover { background: #1f2937; color: #e5e7eb; }
.admin-nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.admin-side-foot { padding: 14px; border-top: 1px solid #1f2937; display: flex; flex-direction: column; gap: 8px; }
.admin-side-foot .btn { background: #1f2937; color: #d1d5db; border: none; }
.admin-side-foot .btn:hover { background: #374151; color: #fff; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 15px 26px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-topbar h1 { font-size: 17px; font-weight: 700; }
.admin-topbar .spacer { flex: 1; }
.admin-content { padding: 24px 26px 60px; max-width: 1180px; width: 100%; }

.panel {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(17, 24, 39, .04);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h3 { font-size: 15.5px; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(17, 24, 39, .04);
}
.stat .stat-num { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .stat-label { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.stat.blue .stat-num { color: var(--primary); }
.stat.red .stat-num { color: var(--danger); }
.stat.green .stat-num { color: var(--success); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}
table.data th { background: #f9fafb; font-weight: 600; color: var(--text-2); font-size: 13px; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfc; }
table.data .thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  border: 1px solid var(--line);
}
table.data .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
table.data .name-cell { font-weight: 600; max-width: 260px; }
table.data .name-cell .sub { font-weight: 400; color: var(--text-3); font-size: 12.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar .input { width: auto; min-width: 200px; }
.filter-bar .select { width: auto; }

.storage-note {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #075985;
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

@media (max-width: 980px) {
  .admin-side { width: 72px; }
  .admin-side-brand span.brand-text, .admin-nav a span.nav-text { display: none; }
  .admin-nav a { justify-content: center; padding: 12px 8px; font-size: 18px; }
  .admin-side-brand { justify-content: center; padding: 16px 8px; }
  .admin-side-foot .btn { font-size: 0; padding: 10px 8px; }
  .admin-side-foot .btn::before { content: '⇦'; font-size: 16px; }
  .admin-content { padding: 18px 14px 50px; }
  .admin-topbar { padding: 13px 16px; }
}
