/* 卡密阅读站 —— 登录页与后台共用样式
   配色与阅读器一致：纸色底、墨色字、赭石强调色 */
:root {
  --bg: #faf7f2;
  --paper: #ffffff;
  --ink: #1f2328;
  --ink-soft: #4b5563;
  --muted: #8a8f98;
  --line: #e6dfd3;
  --line-soft: #f0ebe3;
  --accent: #b45309;
  --accent-ink: #8a3f06;
  --accent-weak: #fdf3e7;
  --ok: #15803d;
  --ok-weak: #eaf6ee;
  --bad: #b91c1c;
  --bad-weak: #fdecec;
  --warn-weak: #fff7e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 35, 40, .04), 0 12px 32px -18px rgba(31, 35, 40, .28);
  --font: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ------------------------------------------------------------ 通用控件 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  cursor: pointer; transition: background .18s, border-color .18s, transform .04s;
  white-space: nowrap;
}
.btn:hover { border-color: #d8cec0; background: #fffdfa; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--accent-weak); border-color: transparent; color: var(--accent-ink); }
.btn-danger { color: var(--bad); border-color: #f0d5d5; background: #fff; }
.btn-danger:hover { background: var(--bad-weak); }
.btn-block { width: 100%; }

.input, .select {
  height: 40px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--paper); outline: none; min-width: 0;
  transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.input::placeholder { color: #b3a99b; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.spacer { flex: 1; }
.sub { color: #8a8f98; font-size: 12px; margin-top: 2px; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ 登录页 */
.login-page {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #fff8ec 0%, rgba(255, 248, 236, 0) 70%),
    var(--bg);
}
.login-card {
  width: min(430px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 22px;
  box-shadow: var(--shadow);
}
.login-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(150deg, #c96a12, #8a3f06);
  color: #fff; font-size: 22px; font-weight: 700;
  display: grid; place-items: center; margin-bottom: 14px;
  letter-spacing: 0;
}
.login-title { margin: 0 0 4px; font-size: 23px; letter-spacing: .01em; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.key-input {
  width: 100%; height: 48px; margin-bottom: 12px;
  padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fffdf9; font-size: 17px; letter-spacing: .12em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none; transition: border-color .18s, box-shadow .18s;
}
.key-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.login-err {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 10px;
  background: var(--bad-weak); color: var(--bad); font-size: 13px;
}
.login-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line);
  display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px;
}
.login-foot .dot { color: #cbbfae; }
.quiet-link { color: var(--muted); }
.quiet-link:hover { color: var(--accent); }

/* ------------------------------------------------------------ 后台框架 */
.admin-body { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250, 247, 242, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; color: #fff; font-size: 14px;
  background: linear-gradient(150deg, #c96a12, #8a3f06);
  display: grid; place-items: center;
}
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 2px; }
.tabs { display: flex; gap: 4px; }
.tab {
  height: 34px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-soft); cursor: pointer;
}
.tab:hover { background: #f3ede3; }
.tab.active { background: var(--accent-weak); color: var(--accent-ink); font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 19px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 0 rgba(31, 35, 40, .02);
}
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card-sub { margin: -6px 0 14px; color: var(--muted); font-size: 12.5px; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.accent b { color: var(--accent); }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
table.grid th, table.grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid th { position: sticky; top: 0; background: #fbf8f3; color: var(--muted); font-weight: 400; font-size: 12px; white-space: nowrap; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: #fffdf9; }
.k { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: .04em; }
.actions { display: flex; gap: 6px; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; background: #f3ede3; color: var(--ink-soft); white-space: nowrap; }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.new { background: var(--accent-weak); color: var(--accent-ink); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.warn { background: var(--warn-weak); color: #92400e; }

/* 生成结果 */
.keys-out { margin-top: 14px; border: 1px dashed #e0d3bf; border-radius: 12px; padding: 12px; background: #fffdf8; display: none; }
.keys-out.show { display: block; }
.keys-out h4 { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
.key-lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; margin: 0 0 10px; }
.key-line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; padding: 6px 8px; background: #fff; border: 1px solid var(--line-soft); border-radius: 8px; letter-spacing: .04em; }

/* 二维码 */
.qr-layout { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.qr-box { width: 260px; height: 260px; background: #fff; border: 1px solid var(--line); border-radius: 14px; display: grid; place-items: center; padding: 10px; }
.qr-box img, .qr-box canvas { max-width: 100%; height: auto; }
.qr-tip { color: var(--muted); font-size: 12.5px; line-height: 1.8; }
.qr-tip code { background: #f3ede3; padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* 日志 */
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.log-list li:last-child { border-bottom: 0; }
.log-list time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-list .tag { color: var(--accent-ink); background: var(--accent-weak); border-radius: 6px; padding: 0 6px; font-size: 12px; }

/* 提示条 */
.notice { border-radius: 10px; padding: 10px 12px; font-size: 13px; background: var(--accent-weak); color: var(--accent-ink); margin: 0 0 14px; }
.notice.warn { background: var(--warn-weak); color: #92400e; }
.notice.bad { background: var(--bad-weak); color: var(--bad); }

/* 登录遮罩 */
.login-gate {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(250, 247, 242, .96); padding: 20px;
}
.login-gate .card { width: min(380px, 100%); }
.login-gate h3 { margin: 0 0 4px; font-size: 18px; }
.login-gate p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.form-err { color: var(--bad); font-size: 13px; margin: 8px 0 0; min-height: 18px; }

/* 移动端 */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .qr-layout { grid-template-columns: 1fr; }
  .topbar-inner { gap: 10px; padding: 0 12px; height: 54px; }
  .brand small { display: none; }
  .tabs { overflow-x: auto; }
  .tab { padding: 0 10px; }
  .topbar-right .who { display: none; }
  .wrap { padding: 16px 12px 48px; }
  .card { padding: 14px; }
  .login-card { padding: 24px 18px 16px; }
  .key-input { font-size: 16px; letter-spacing: .08em; }
  table.grid { min-width: 680px; }
}
