:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2329;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.nav a { margin-left: 18px; color: var(--muted); font-size: 14px; }
.nav a:hover { color: var(--brand); }
main { max-width: 1040px; margin: 24px auto; padding: 0 18px; min-height: 60vh; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0 40px; }

/* 首页工具条 */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar input[type=search] {
  flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 13px;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 卡片网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow); cursor: pointer; transition: transform .08s ease;
}
.card:hover { transform: translateY(-2px); }
.card .icon {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: #eef2ff;
  display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card .summary { font-size: 13px; color: #374151; min-height: 38px; }

/* 详情 */
.detail-head { display: flex; gap: 18px; align-items: flex-start; }
.detail-head .icon { width: 84px; height: 84px; border-radius: 16px; object-fit: cover; background: #eef2ff; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: #eef2ff; color: var(--brand); margin-left: 8px;
}
.badge.pub { background: #dcfce7; color: var(--ok); }
.badge.draft { background: #fef3c7; color: var(--warn); }
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; font-size: 14px;
}
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { background: #fff; color: var(--bad); border-color: #fecaca; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.dl-note {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 12px 14px;
  border-radius: 10px; font-size: 14px; margin: 16px 0;
}
.dl-box { display: flex; gap: 10px; margin: 16px 0 4px; }
.dl-box input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: ui-monospace, Consolas, monospace;
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; margin-top: 14px; }
.gallery img { width: 100%; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.kv { font-size: 13px; color: var(--muted); }
.kv code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; color: #0f172a; word-break: break-all; }
.prose { margin-top: 14px; font-size: 15px; }
.prose h1,.prose h2,.prose h3 { margin: 18px 0 8px; }
.prose pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow:auto; }
.prose code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
.prose a { color: var(--brand); }
.back { margin-bottom: 14px; display: inline-block; }

/* 后台 */
.admin-login { max-width: 360px; margin: 60px auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px; box-shadow: var(--shadow); }
.admin-login h2 { margin-top: 0; }
.admin-login input { width: 100%; padding: 10px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; }
.admin-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; font-size: 16px; }
.form label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.form input, .form select, .form textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
.form textarea { min-height: 90px; resize: vertical; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.admin-item .row1 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.admin-item .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.admin-item .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* 灯箱 */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: none; align-items: center; justify-content: center; z-index: 50; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--bad); }

/* 后台标签页(S4) */
.tabs { display: flex; gap: 8px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 16px; font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* 明文一次性警示 */
.warn-box {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-top: 12px;
}
.code-plain-box {
  max-height: 320px; overflow: auto; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; background: #f9fafb;
}

/* 紧凑表格(码列表 / 批次对账) */
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td {
  padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle;
}
table.mini th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.mini tbody tr:hover { background: #f9fafb; }
table.mini code { font-size: 12px; }
@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr; }
  table.mini { font-size: 12px; }
  table.mini th, table.mini td { padding: 5px 4px; }
}
