:root {
  --bg: #f3f5f7;
  --panel: #fff;
  --ink: #1c2430;
  --ink-2: #3a4453;
  --muted: #6b7585;
  --line: #e6e9ee;
  --accent: #3d4ed7;
  --accent-2: #2f3eb8;
  --accent-soft: #eef1fd;
  --ok: #0f9f6e;
  --ok-soft: #e7f7f1;
  --warn: #c57a09;
  --warn-soft: #fff6e8;
  --bad: #d64545;
  --bad-soft: #fdecec;
  --info: #2b6cb0;
  --info-soft: #e8f2fb;
  --shadow: 0 1px 2px rgba(28, 36, 48, .04);
  --radius: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --side: 196px;
  --top: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink-2);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { color: var(--ink); font-weight: 650; letter-spacing: 0; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

.topnav {
  height: var(--top);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(145deg, #6d7cf0, #3d4ed7);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.brand em { font-style: normal; color: var(--muted); font-weight: 500; }
.topnav-spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }
.who b { color: var(--ink); font-weight: 600; }

.shell { display: flex; min-height: calc(100vh - var(--top)); }
.side {
  width: var(--side);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 14px 10px 24px;
  flex: none;
}
.side a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  margin-bottom: 2px;
}
.side a.active, .side a:hover { background: var(--accent-soft); color: var(--accent); }
.side .sec {
  font-size: 12px;
  color: var(--muted);
  padding: 12px 12px 6px;
}
.main { flex: 1; padding: 22px 24px 48px; min-width: 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.lead { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.panel h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 26px; color: var(--ink); font-weight: 680; line-height: 1.2; margin-top: 4px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.span-2 { grid-column: span 2; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink); }
label.field span.hint, .hint { color: var(--muted); font-weight: 400; font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%;
  border: 1px solid #d9dee7;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #8c97ee; box-shadow: 0 0 0 3px rgba(61, 78, 215, .12); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: var(--accent); color: #fff;
  border-radius: 8px; padding: 8px 14px; cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--accent-2); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: #d9dee7; }
.btn-ghost:hover { background: #f7f8fa; color: var(--ink); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f3c7c7; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters .field { min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #fafbfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 1px 8px; font-size: 12px; line-height: 1.7;
  background: #f2f4f7; color: var(--ink-2);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #f2f4f7; color: var(--muted); }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-soft); color: #0b7a54; }
.flash.err { background: var(--bad-soft); color: #a32626; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.pager-btn {
  min-width: 32px; text-align: center; padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--line); color: var(--ink-2); background: #fff;
}
.pager-btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager-btn.is-disabled { color: #b7bec8; }
.pager-total, .pager-ellipsis { color: var(--muted); font-size: 12px; }

.match-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.match-tools input { max-width: 280px; }
.match-row {
  display: grid;
  grid-template-columns: 28px 1.4fr 90px 120px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.match-row .who-name { color: var(--ink); font-weight: 600; }
.match-row .sub { color: var(--muted); font-size: 12px; }
.match-block { opacity: .85; }
.section-count { font-weight: 500; color: var(--muted); font-size: 12px; }
details.fold { margin-top: 8px; }
details.fold summary { cursor: pointer; color: var(--muted); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 420px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px; box-shadow: var(--shadow); }
.auth-links { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-list a { font-weight: 600; }
.file-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.auth-card h1 { font-size: 20px; }
.auth-brand { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.split { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form .field { min-width: 120px; }

@media (max-width: 980px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .split, .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .shell { display: block; }
  .side {
    width: auto;
    display: flex;
    gap: 4px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px;
  }
  .side .sec { display: none; }
  .side a { white-space: nowrap; margin: 0; }
  .main { padding: 16px 12px 40px; }
  .match-row { grid-template-columns: 28px 1fr; }
  .topnav { padding: 0 12px; }
  .brand em { display: none; }
}
