:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

a { color: var(--primary); }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6fa 45%, #ecfdf5 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 21px;
  letter-spacing: .3px;
}

.login-card .sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.login-tip {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------------- 图片验证码 ---------------- */
.captcha-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.captcha-row input {
  flex: 1 1 auto;
  min-width: 0;
  letter-spacing: 5px;
  font-size: 16px;
  text-align: center;
}

.captcha-img {
  flex: 0 0 auto;
  width: 150px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3C/svg%3E") center/24px no-repeat;
  transition: border-color .15s, opacity .15s;
}

.captcha-img:hover { border-color: var(--primary); }
.captcha-img.loading { opacity: .45; }

.lock-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  line-height: 1.6;
}

.lock-banner[hidden] { display: none; }

/* ---------------- 表单控件 ---------------- */
label.field { display: block; margin-bottom: 14px; }

label.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

label.field > span .req { color: var(--red); margin-left: 2px; }
label.field > span .hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

textarea { resize: vertical; line-height: 1.6; }

textarea.mono, input.mono {
  font-family: "JetBrains Mono", Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #c7d2e0; background: #f9fafb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------------- 布局 ---------------- */
.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

.container { max-width: 1240px; margin: 0 auto; padding: 20px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }

.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 4px; }

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar .grow { flex: 1; }
.toolbar input[type=text] { max-width: 260px; }
.toolbar select { max-width: 140px; }

/* ---------------- 表格 ---------------- */
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

th {
  background: #fafbfd;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: none; }

.thumb {
  width: 68px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid var(--border);
  display: block;
}

.thumb-empty {
  width: 68px; height: 44px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: #9aa5b4; font-size: 11px;
}

.cell-title { font-weight: 500; }
.cell-title .sub { color: var(--muted); font-size: 12px; margin-top: 3px; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}

.tag-published { background: #ecfdf5; color: var(--green); border: 1px solid #a7f3d0; }
.tag-draft { background: #fffbeb; color: var(--amber); border: 1px solid #fde68a; }

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

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager .pages { display: flex; gap: 6px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask[hidden] { display: none; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 100;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 860px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
  animation: pop .16s ease-out;
}

.modal.narrow { max-width: 420px; }
.modal.wide { max-width: 1000px; }

@keyframes pop { from { transform: translateY(-8px); opacity: .5; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 { margin: 0; font-size: 16px; }

.modal-body { padding: 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
  border-radius: 0 0 12px 12px;
}

.x-close {
  border: none; background: none; font-size: 22px; line-height: 1;
  color: #9aa5b4; cursor: pointer; padding: 0 4px;
}
.x-close:hover { color: var(--text); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.img-preview {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.img-preview .pv {
  position: relative;
  width: 84px;
}

.img-preview img {
  width: 84px; height: 58px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); background: #f1f5f9;
  display: block;
}

.img-preview .pv .bad { font-size: 11px; color: var(--red); }

.seg { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; margin-bottom: 10px; }
.seg button {
  border: none; background: #fff; padding: 6px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; color: var(--muted); border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button.on { background: #eff6ff; color: var(--primary); font-weight: 500; }

.hint-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.75;
}

pre.json {
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.65;
  overflow: auto;
  max-height: 60vh;
  font-family: Consolas, Monaco, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

iframe.preview-frame {
  width: 100%;
  height: 60vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

/* ---------------- 全局提示 ---------------- */
#toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
  background: #111827;
  color: #fff;
  animation: pop .16s ease-out;
  max-width: 80vw;
}

.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
