:root {
  --navy: #14205e;
  --navy-2: #1e2f7a;
  --navy-soft: #eef1fa;
  --gold: #b08a3e;
  --ink: #1c2436;
  --muted: #6b7488;
  --line: #e3e8f2;
  --bg: #f5f7fb;
  --green: #16794c;
  --green-bg: #e8f7ef;
  --amber: #a9701a;
  --amber-bg: #fdf4e3;
  --red: #b42318;
  --red-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 32, 94, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1164px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 38px; display: block; }
.brand-divider { width: 1px; height: 22px; background: #d9e0ee; display: inline-block; }
.brand-text { font-size: 15px; color: var(--navy); font-weight: 600; letter-spacing: .5px; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topnav a {
  padding: 8px 15px;
  border-radius: 8px;
  color: #34405a;
  font-size: 14px;
}
.topnav a:hover { background: var(--navy-soft); text-decoration: none; }
.topnav a.active { background: var(--navy); color: #fff; }

/* ---------- 通用容器 ---------- */
.wrap { max-width: 1164px; margin: 0 auto; padding: 28px 20px 60px; }
.wrap-narrow { max-width: 760px; }

.hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(120deg, #0f1850 0%, #1e2f7a 60%, #2a3f96 100%);
  color: #fff;
  padding: 40px 44px;
  margin-bottom: 26px;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px; top: -60px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(176,138,62,.35), transparent 65%);
}
.hero h1 { margin: 0 0 10px; font-size: 26px; letter-spacing: .5px; }
.hero p { margin: 0; color: rgba(255,255,255,.82); font-size: 14.5px; max-width: 620px; }
.hero .hero-meta { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; }
.hero .chip {
  font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.card-head .sub { font-size: 13px; color: var(--muted); }
.card-head .right { margin-left: auto; }

.section-note { font-size: 13px; color: var(--muted); margin: -6px 0 18px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13.5px; color: #3a465f; font-weight: 500; }
.field label .req { color: #d64545; margin-left: 2px; }
.field .hint { font-size: 12px; color: #939cb0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="file"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #dbe2f0;
  border-radius: 9px;
  padding: 10px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%236b7488' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(30, 47, 122, .1);
}
input::placeholder, textarea::placeholder { color: #a9b1c2; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  transition: background .15s, transform .05s;
  text-decoration: none;
}
.btn:hover { background: var(--navy-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 12px 30px; font-size: 15px; }
.btn-ghost { background: #fff; color: var(--navy); border-color: #ccd4e8; }
.btn-ghost:hover { background: var(--navy-soft); }
.btn-danger { background: #fff; color: var(--red); border-color: #f0c9c4; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.form-actions { margin-top: 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.form-actions .tip { font-size: 12.5px; color: var(--muted); }

.alert {
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-error { background: var(--red-bg); color: var(--red); border-color: #f5cfca; }
.alert-ok { background: var(--green-bg); color: var(--green); border-color: #bfe8d4; }
.alert-warn { background: var(--amber-bg); color: var(--amber); border-color: #f0dec0; }
.alert-info { background: var(--navy-soft); color: var(--navy-2); border-color: #d6ddf2; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.pending { background: var(--amber-bg); color: var(--amber); }
.badge.issued { background: var(--green-bg); color: var(--green); }
.badge.gray { background: #eef1f6; color: #5b6578; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #eef1f7; vertical-align: middle; }
table.data th { background: #f8fafd; color: #4d576d; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfe; }
table.data .no { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--navy); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .nowrap { white-space: nowrap; }
table.data td { white-space: normal; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 46px 20px;
  font-size: 14px;
}

/* ---------- 查询结果 ---------- */
.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.result-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px 24px;
  background: linear-gradient(120deg, #14205e, #263a8c);
  color: #fff;
}
.result-head .no { font-family: ui-monospace, Menlo, monospace; font-size: 18px; letter-spacing: .6px; }
.result-head .badge { background: rgba(255,255,255,.15); color: #fff; }
.result-body { padding: 22px 24px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.timeline { list-style: none; margin: 26px 0 0; padding: 0 0 0 6px; }
.timeline li { position: relative; padding: 0 0 22px 26px; border-left: 2px solid #e6eaf3; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px; top: 5px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #ccd4e6;
  border: 2px solid #fff;
}
.timeline li.done::before { background: var(--green); }
.timeline li.now::before { background: var(--navy); box-shadow: 0 0 0 4px rgba(20,32,94,.12); }
.timeline b { display: block; font-size: 14px; font-weight: 600; }
.timeline span { font-size: 12.5px; color: var(--muted); }

.download-box {
  margin-top: 24px;
  padding: 20px 22px;
  border-radius: 12px;
  background: var(--green-bg);
  border: 1px solid #bfe8d4;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.download-box .txt { flex: 1; min-width: 220px; }
.download-box .txt b { display: block; color: var(--green); font-size: 15px; }
.download-box .txt span { font-size: 12.5px; color: #3f6b57; }

.query-search { display: flex; gap: 10px; }
.query-search input { flex: 1; font-family: ui-monospace, Menlo, monospace; letter-spacing: .5px; }

.code-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #f3f6fc;
  border: 1px dashed #c3cee6;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--navy);
}

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 26px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.footer b { color: #3f4a63; }

/* ---------- 后台 ---------- */
body.admin { background: #f2f4f9; }
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px;
  flex: 0 0 218px;
  background: linear-gradient(180deg, #131d55 0%, #1a2770 100%);
  color: #cfd6ee;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .logo img { height: 26px; filter: brightness(0) invert(1); opacity: .95; }
.sidebar .logo div { font-size: 11.5px; color: rgba(255,255,255,.55); margin-top: 8px; letter-spacing: .4px; }
.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #c8d0ea;
  font-size: 14px;
  margin-bottom: 2px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 500; }
.sidebar nav .group { font-size: 11px; color: rgba(255,255,255,.4); padding: 14px 12px 6px; letter-spacing: 1px; }
.sidebar .me { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.sidebar .me b { display: block; color: #fff; font-size: 13.5px; }
.sidebar .me a { color: #9fb0dd; }

.admin-main { flex: 1; min-width: 0; padding: 24px 30px 50px; }
.admin-top { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-top h1 { font-size: 20px; margin: 0; color: var(--navy); }
.admin-top .right { margin-left: auto; display: flex; gap: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 25px; font-weight: 600; color: var(--navy); line-height: 1.3; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .f { display: flex; flex-direction: column; gap: 5px; }
.filters label { font-size: 12px; color: var(--muted); }
.filters input, .filters select { padding: 8px 11px; font-size: 13px; min-width: 130px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .grow input { width: 100%; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 16px; font-size: 13px; color: var(--muted); }
.pager a, .pager span.cur {
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: #34405a;
}
.pager span.cur { background: var(--navy); color: #fff; border-color: var(--navy); }
.pager a:hover { text-decoration: none; background: var(--navy-soft); }

.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 6px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; color: #3a465f; padding: 4px 0; }
.check input { width: 16px; height: 16px; margin-top: 3px; accent-color: var(--navy); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 9px 16px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--navy); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1850 0%, #23347f 55%, #34489f 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 34px 32px;
  box-shadow: 0 20px 50px rgba(8, 14, 45, .25);
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-card .brand img { height: 30px; }
.login-card h1 { font-size: 18px; text-align: center; color: var(--navy); margin: 14px 0 4px; }
.login-card p.sub { text-align: center; font-size: 12.5px; color: var(--muted); margin: 0 0 22px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn { width: 100%; margin-top: 20px; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  .sidebar { width: 62px; flex: 0 0 62px; }
  .sidebar .logo img { height: 18px; }
  .sidebar nav a { justify-content: center; padding: 11px 0; font-size: 0; }
  .sidebar nav a span.ico { font-size: 15px; }
  .sidebar .logo div, .sidebar .me, .sidebar nav .group { display: none; }
  .admin-main { padding: 18px 16px 40px; }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 21px; }
  .card { padding: 20px 18px; }
  .kv { grid-template-columns: 96px 1fr; font-size: 13.5px; }
  .topbar-inner { flex-wrap: wrap; gap: 12px; }
  .brand-text, .brand-divider { display: none; }
  .topnav { margin-left: 0; width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .query-search { flex-direction: column; }
}