:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1e7e34;
  --primary-dark: #166428;
  --primary-soft: #e8f5ea;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.nowrap { white-space: nowrap; }
.ta-r { text-align: right; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--primary); font-weight: 600; }
.link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e7e34, #14532d);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Songti SC", "SimSun", serif;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -1px;
  flex-shrink: 0;
}

.brand-text strong { display: block; font-size: 15px; line-height: 1.2; }
.brand-text small { display: block; color: var(--muted); font-size: 11px; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }

.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: #374151;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }

.userbox { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 13px; }

/* ---------- 页面 ---------- */
.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 140px);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.head-actions { display: flex; gap: 10px; }

.footer {
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  padding: 20px 0 28px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-head h2 { font-size: 15px; margin: 0; }

/* ---------- 筛选 ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 126, 52, 0.12);
}

.filters input[type="text"] { min-width: 260px; flex: 1 1 260px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost { background: #fff; border-color: #d1d5db; color: #374151; }
.btn-ghost:hover { background: #f9fafb; }

.btn-warn { background: var(--warning); color: #fff; }
.btn-warn:hover { filter: brightness(0.95); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- 表格 ---------- */
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  background: #f9fafb;
  color: #4b5563;
  font-weight: 700;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}

.table tbody tr:hover { background: #fafcfa; }
.table tbody tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 36px 0 !important; }

.detail-table th {
  width: 200px;
  background: #f9fafb;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #f1f3f5;
  color: #4b5563;
}

.detail-table td { border-bottom: 1px solid #f1f3f5; word-break: break-all; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-ok { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfe3c6; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #c7dbfe; }
.badge-warn { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.badge-muted { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

/* ---------- 提示 ---------- */
.alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert-ok { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfe3c6; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #c7dbfe; }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 700; color: #4b5563; }
.field-full { grid-column: 1 / -1; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}

.check input { width: 15px; height: 15px; accent-color: var(--primary); }

.perm-group-title {
  flex-basis: 100%;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-dark);
  border-bottom: 1px dashed #d1d5db;
  padding-bottom: 4px;
}

/* ---------- 材料清单 ---------- */
.materials {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.mat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
  font-size: 12px;
}

.mat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}

.mat-ok { background: #f2fbf4; border-color: #bfe3c6; }
.mat-ok .mat-dot { background: var(--primary); }
.mat-label { flex: 1; }
.mat-state { color: var(--muted); font-weight: 700; }
.mat-ok .mat-state { color: var(--primary-dark); }

/* ---------- 分页 ---------- */
.pager { display: flex; justify-content: flex-end; margin-top: 16px; }
.pager .pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; }
.pager .pagination li a,
.pager .pagination li span {
  display: inline-block;
  min-width: 32px;
  text-align: center;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: #374151;
  font-size: 12px;
}
.pager .pagination li.active span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}
.pager .pagination li.disabled span { color: #c0c4cc; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #e8f5ea 0%, #f3f5f7 45%, #eef2f0 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(16, 24, 40, 0.08);
  padding: 30px;
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; }
.login-tip { color: #9ca3af; font-size: 11px; text-align: center; margin: 16px 0 0; }

/* ---------- 打印 ---------- */
@media print {
  .topbar, .footer, .page-head .head-actions, .pager { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; }
}

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .userbox { margin-left: auto; }
  .page { padding: 16px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .detail-table { display: table; }
}

/* ---------- 报名列表增强 ---------- */
.hidden { display: none !important; }
.table-card { overflow-x: auto; }
.table { min-width: 1180px; table-layout: auto; }
.table th, .table td { white-space: nowrap; }
.detail-table td { white-space: normal; }

/* 操作列固定在右侧，横向滚动时始终可见 */
.table th:last-child,
.table td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.18);
}
.table thead th:last-child { background: #f9fafb; }
.table tbody tr:hover td:last-child { background: #fafcfa; }
.row-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  white-space: nowrap;
}
.search-card { display: block; }
.basic-search {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.basic-search input[type="text"] {
  flex: 1 1 320px;
  min-width: 240px;
}
.advanced-search {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.column-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.column-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
}
.column-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

/* 字段选择面板：可滚动 + 分组标题 */
.column-options {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.column-group-title {
  flex-basis: 100%;
  margin: 8px 0 2px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-dark);
}

/* 高级搜索：三列条件区 */
.advanced-search {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 28px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}
.adv-field {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0;
}
.adv-field > span {
  text-align: right;
  font-size: 12px;
  color: #4b5563;
  white-space: nowrap;
}
.adv-field input,
.adv-field select {
  width: 100%;
  height: 32px;
  padding: 4px 8px;
  font-size: 12px;
}
.adv-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 0 4px;
}
@media (max-width: 1200px) {
  .advanced-search { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .advanced-search { grid-template-columns: 1fr; }
}
