:root {
  --brand: #23715c;
  --brand-deep: #16483c;
  --brand-soft: #eaf5f0;
  --gold: #c08a1c;
  --gold-soft: #fbf3dd;
  --ink: #1d2f3a;
  --ink-soft: #4e6577;
  --muted: #7c8fa1;
  --line: #e2ece8;
  --line-strong: #d2e0da;
  --bg: #f1f6f4;
  --surface: #ffffff;
  --surface-soft: #f7fbf9;
  --danger: #b44141;
  --shadow: 0 16px 40px -28px rgba(18, 63, 52, 0.35);
  --font-display: "Playfair Display", "Noto Serif SC", "Songti SC", "STZhongsong", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
code { font-family: Consolas, "Courier New", monospace; font-size: 0.92em; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(900px 500px at 12% 0%, rgba(35, 113, 92, .22), transparent 60%),
    radial-gradient(700px 500px at 92% 92%, rgba(192, 138, 28, .14), transparent 60%),
    linear-gradient(160deg, #f2f8f5, #e8f1ed 55%, #eef5f1);
}

.login-card {
  width: min(430px, 100%);
  padding: 34px 34px 28px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 22px;
  box-shadow: 0 30px 80px -30px rgba(17, 63, 52, .45);
  backdrop-filter: blur(14px);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }

/* 品牌徽标：与前台一致的圆形徽标 + 衬线锁定组合 */
.brand-emblem { width: 44px; height: 44px; flex: none; display: block; }
.brand-emblem svg { width: 100%; height: 100%; display: block; }
.brand-emblem.small { width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.22; }
.brand-text strong { font-size: 20px; letter-spacing: .6px; font-weight: 800; font-family: var(--font-display); }
.brand-text span { font-size: 10.5px; color: var(--muted); letter-spacing: .6px; }

.login-card h1 { margin: 0 0 6px; font-size: 25px; letter-spacing: .3px; }
.login-sub { margin: 0 0 24px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }

.login-field { display: block; margin-bottom: 14px; }
.login-field span { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.login-field input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fbfdfc; font-size: 14px; color: var(--ink); outline: none;
  transition: .15s;
}
.login-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(35, 113, 92, .1); background: #fff; }

.login-submit { width: 100%; margin-top: 6px; padding: 12px; font-size: 14px; }
.login-error { min-height: 18px; margin: 10px 0 0; font-size: 12px; color: var(--danger); }
.login-foot { margin: 18px 0 0; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted); line-height: 1.8; }
.login-foot code { background: #eef5f2; padding: 1px 5px; border-radius: 5px; color: var(--brand-deep); }
.back-link { display: inline-flex; align-items: center; min-height: 30px; margin-top: 12px; font-size: 12px; color: var(--brand); text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border: 1px solid transparent; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; line-height: 1.4;
  transition: .15s; white-space: nowrap;
}
.btn.primary { background: linear-gradient(135deg, #23715c, #16483c); color: #fff; box-shadow: 0 10px 20px -14px rgba(22, 72, 60, .8); }
.btn.primary:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-soft); }
.btn.ghost:hover { border-color: #b9d3c9; background: var(--brand-soft); color: var(--brand-deep); }
.btn.small { padding: 5px 10px; min-height: 30px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- 顶栏 ---------- */
.admin-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 12px 26px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand .brand-text strong { font-size: 17px; }
.header-brand .brand-text span { letter-spacing: 1.2px; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.front-link { display: inline-flex; align-items: center; min-height: 30px; font-size: 12px; color: var(--brand); text-decoration: none; }
.front-link:hover { text-decoration: underline; }
.admin-user { padding: 4px 10px; font-size: 11px; color: var(--brand-deep); background: var(--brand-soft); border-radius: 999px; }

/* ---------- 布局 ---------- */
.admin-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: calc(100vh - 61px); min-height: calc(100dvh - 61px); }

.admin-sidebar {
  display: flex; flex-direction: column;
  padding: 18px 14px;
  background: rgba(255, 255, 255, .72);
  border-right: 1px solid var(--line);
}
.admin-nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 11px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink-soft);
  font-size: 13px; font-weight: 600; text-align: left;
  transition: .15s;
}
.nav-item b {
  width: 23px; height: 23px; flex: 0 0 23px;
  display: grid; place-items: center;
  border-radius: 7px; font-size: 11px; font-weight: 700;
  color: var(--brand-deep); background: #edf6f2;
}
.nav-item em {
  margin-left: auto; min-width: 20px; padding: 0 6px;
  border-radius: 999px; background: #f6e7c4; color: #9a6b0f;
  font-style: normal; font-size: 10px; font-weight: 700; text-align: center;
}
.nav-item:hover { background: #f3f9f6; color: var(--brand-deep); }
.nav-item.active { background: var(--brand-soft); border-color: #cfe6dc; color: var(--brand-deep); }
.nav-sep { margin: 14px 11px 5px; font-size: 10px; font-weight: 700; letter-spacing: 1.6px; color: #a2b3ab; text-transform: uppercase; }

.sidebar-vector {
  margin-top: auto; padding: 13px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft);
}
.vector-title { margin-bottom: 8px; font-size: 11px; font-weight: 800; letter-spacing: .8px; color: var(--brand-deep); }
.vector-line { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--muted); line-height: 1.9; }
.vector-line b { color: var(--ink-soft); font-weight: 600; }
.vector-line b.ok { color: #1f7a58; }
.vector-line b.warn { color: #a87312; }
.sidebar-vector .btn { width: 100%; margin-top: 8px; }
.vector-tip { margin: 8px 0 0; font-size: 10px; line-height: 1.6; color: #93a69d; }

.admin-main { width: 100%; min-width: 0; padding: 24px 28px 50px; max-width: 1400px; margin-inline: auto; }
.view { animation: fade-up .3s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; font-size: 10px; font-weight: 800; letter-spacing: 2.4px; color: var(--brand); }
.view-head h1 { margin: 0 0 5px; font-size: 27px; letter-spacing: .3px; }
.view-head p { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- 概览 ---------- */
.overview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.overview-card {
  text-align: left; padding: 16px 17px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 15px;
  box-shadow: var(--shadow); transition: .15s;
}
.overview-card:hover { transform: translateY(-2px); border-color: #bcd8cd; }
.overview-card .oc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.overview-card .oc-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .4px; }
.overview-card .oc-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--brand-deep); background: var(--brand-soft); }
.overview-card b { display: block; margin: 8px 0 2px; font-size: 25px; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.overview-card small { font-size: 10.5px; color: var(--muted); }
.overview-card .oc-pending { color: #a87312; }

.overview-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 17px 10px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; }
.link-btn { min-height: 30px; border: 0; background: transparent; color: var(--brand); font-size: 11.5px; padding: 5px 6px; }
.link-btn:hover { text-decoration: underline; }

.queue-list, .log-list { padding: 8px 10px 12px; max-height: 360px; overflow-y: auto; }
.queue-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 7px; border-bottom: 1px dashed #eaf1ee; }
.queue-item:last-child { border-bottom: 0; }
.queue-main { flex: 1; min-width: 0; }
.queue-main b { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-main span { display: block; margin-top: 2px; font-size: 10.5px; color: var(--muted); }
.queue-actions { display: flex; gap: 5px; flex-shrink: 0; }
.log-item { padding: 8px 7px; border-bottom: 1px dashed #eaf1ee; font-size: 11.5px; color: var(--ink-soft); }
.log-item:last-child { border-bottom: 0; }
.log-item time { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
.empty-inline { margin: 0; padding: 18px 8px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- 统计条 ---------- */
.entity-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-chip { padding: 10px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.stat-chip span { display: block; font-size: 10.5px; color: var(--muted); }
.stat-chip b { display: block; margin-top: 2px; font-size: 19px; font-variant-numeric: tabular-nums; }

/* ---------- 工具栏 / 表格 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.toolbar-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar select {
  padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fbfdfc; font-size: 12px; color: var(--ink); outline: none; min-width: 160px;
}
.toolbar input[type="search"] { min-width: 250px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(35, 113, 92, .09); }
.toolbar-meta { font-size: 11.5px; color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th {
  padding: 9px 14px; text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .6px;
  color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid #eef4f1; vertical-align: top; font-size: 12.5px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f9fcfa; }
.data-table .actions-col { width: 230px; text-align: right; }
.data-table td.actions-col { text-align: right; white-space: nowrap; }

.title-cell b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.55; }
.title-cell span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.cell-clip { max-width: 340px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-muted { color: var(--muted); font-size: 11.5px; }
.cell-mono { font-family: Consolas, monospace; font-size: 11px; color: var(--muted); }

.status-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.status-badge.pending { color: #9a6b0f; background: #fcf3dc; border: 1px solid #f0dfb4; }
.status-badge.approved { color: #1f7a58; background: #e8f6ef; border: 1px solid #c4e6d6; }
.status-badge.rejected { color: #a63f3f; background: #fbecec; border: 1px solid #f0cccc; }

.mini-btn {
  padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: #fff; color: var(--ink-soft); font-size: 10.5px; font-weight: 600; transition: .12s;
}
.mini-btn:hover { border-color: #b9d3c9; background: var(--brand-soft); color: var(--brand-deep); }
.mini-btn.approve { color: #1f7a58; border-color: #c4e6d6; }
.mini-btn.approve:hover { background: #e8f6ef; }
.mini-btn.reject { color: #a63f3f; border-color: #f0cccc; }
.mini-btn.reject:hover { background: #fbecec; }
.mini-btn.danger { color: #a63f3f; }
.action-btns { display: inline-flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 8px; }
.pager span { font-variant-numeric: tabular-nums; }

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

/* ---------- 弹窗表单 ---------- */
.modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(13, 34, 28, .5); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff; border-radius: 17px; box-shadow: 0 40px 90px -30px rgba(9, 33, 26, .6);
  animation: modal-in .18s ease both;
}
.modal-card.narrow { width: min(440px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 17px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); }
.modal-close { width: 30px; height: 30px; border: 0; border-radius: 8px; background: #f2f7f5; color: var(--ink-soft); font-size: 20px; line-height: 1; }
.modal-close:hover { background: var(--brand-soft); color: var(--brand-deep); }

.form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 15px; padding: 18px 20px 4px; }
.form-fields label { display: block; min-width: 0; }
.form-fields label.span2 { grid-column: span 2; }
.form-fields label > span { display: block; margin-bottom: 5px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.form-fields input, .form-fields select, .form-fields textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fbfdfc; font-size: 12.5px; color: var(--ink); outline: none; transition: .15s;
}
.form-fields textarea { resize: vertical; line-height: 1.7; min-height: 110px; }
.form-fields input:focus, .form-fields select:focus, .form-fields textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(35, 113, 92, .09); background: #fff; }
.form-fields .checkbox-field { display: flex; align-items: center; gap: 8px; padding-top: 24px; }
.form-fields .checkbox-field input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-fields .checkbox-field > span { margin: 0; }

.form-error { min-height: 17px; margin: 8px 20px 0; font-size: 11.5px; color: var(--danger); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 10px 20px 18px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  transform: translate(-50%, 14px);
  padding: 9px 18px; border-radius: 999px;
  background: rgba(18, 51, 41, .94); color: #f2fbf7;
  font-size: 12.5px; box-shadow: 0 18px 36px -18px rgba(8, 34, 26, .8);
  opacity: 0; pointer-events: none; transition: .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(139, 45, 45, .95); }
.toast.success { background: rgba(25, 94, 69, .95); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-columns { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; }
  .admin-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-item { width: auto; padding: 7px 10px; }
  .nav-sep { display: none; }
  .nav-item em { margin-left: 4px; }
  .sidebar-vector { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; }
  .vector-title, .vector-line, .vector-tip { grid-column: 1; }
  .sidebar-vector .btn { grid-column: 2; grid-row: 1 / span 4; width: auto; margin: 0; }
  .admin-main { padding: 18px 16px 40px; }
  .header-actions .front-link { display: none; }
}

@media (max-width: 620px) {
  .admin-header { padding: 10px 14px; gap: 10px; }
  .header-actions .admin-user, .header-actions #passwordBtn { display: none; }
  .view-head h1 { font-size: 22px; }
  .overview-grid, .entity-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar input[type="search"] { min-width: 100%; }
  .toolbar-filters { width: 100%; }
  .toolbar-filters select { flex: 1; min-width: 130px; }
  .form-fields { grid-template-columns: 1fr; padding: 15px 15px 2px; }
  .form-fields label.span2 { grid-column: span 1; }
  .modal { padding: 10px; }
  .modal-card { max-height: 94vh; max-height: 94dvh; }
  .login-card { padding: 26px 22px 22px; }
}

@media (max-width: 400px) {
  .brand-emblem.small { width: 34px; height: 34px; }
  .header-brand .brand-text strong { font-size: 15.5px; }
  .header-brand .brand-text span { display: none; }
  .login-brand .brand-text strong { font-size: 19px; }
  .overview-grid, .entity-stats { grid-template-columns: 1fr; }
  .data-table { min-width: 620px; }
}

/* ---------- 求助记录 ---------- */
.sos-msg {
  max-width: 460px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: #16332a;
}
.data-table td.sos-msg { font-weight: 600; }
