:root {
  --primary: #2f6fed;
  --primary-dark: #245ac2;
  --danger: #e5484d;
  --success: #30a46c;
  --warn: #f5a623;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e3e7ef;
  --text: #1f2937;
  --text-sub: #6b7280;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 40, 80, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
  background: var(--card);
  color: var(--text);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .88; }
.btn-ghost { border-color: var(--border); background: transparent; color: var(--text-sub); }
.btn-ghost:hover:not(:disabled) { border-color: var(--text-sub); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ============ 登录页 ============ */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2f6fed 0%, #1d3f8f 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(10, 30, 80, .25);
  padding: 36px 32px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #5b8def);
  color: #fff;
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 18px; font-weight: 600; }
.login-sub { color: var(--text-sub); font-size: 13px; margin-top: 4px; }

/* ============ 表单 ============ */
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease;
  background: #fafbfc;
}
.field input:focus { border-color: var(--primary); background: #fff; }
.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
  background: #fdecec;
  border-radius: 6px;
  padding: 8px 10px;
}

/* ============ 主视图 ============ */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
}
.topbar-brand { font-weight: 600; font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-name { color: var(--text-sub); font-size: 13px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.tab {
  border: none;
  background: none;
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.content { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 16px; font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f8f9fc; color: var(--text-sub); font-weight: 500; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }
td { vertical-align: middle; }
.code-cell { font-family: Consolas, "Courier New", monospace; letter-spacing: .5px; white-space: nowrap; }
.col-ops { text-align: right; }
.col-ops .btn { margin-left: 6px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-active { background: #e5f6ee; color: var(--success); }
.badge-revoked { background: #fdecec; color: var(--danger); }
.badge-action { background: #e8effd; color: var(--primary); }

.muted { color: var(--text-sub); font-size: 12px; }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-sub);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 0;
  color: var(--text-sub);
  font-size: 13px;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(10, 25, 70, .25);
}
.modal h3 { font-size: 16px; margin-bottom: 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.result-tip { color: var(--text-sub); font-size: 13px; margin-bottom: 8px; }
.result-code {
  background: #f5f7fb;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 16px;
  letter-spacing: 1px;
  text-align: center;
  user-select: all;
  word-break: break-all;
  margin-bottom: 16px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  background: rgba(30, 40, 55, .92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast.error { background: rgba(190, 40, 45, .94); }

/* ============ 概览统计卡片 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-label {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-sub);
}

/* ============ 筛选栏 ============ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fafbfc;
  outline: none;
  color: var(--text);
}
.filter-input {
  flex: 1;
  min-width: 220px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fafbfc;
  outline: none;
}
.filter-input:focus, .filter-select:focus { border-color: var(--primary); background: #fff; }

/* ============ badge / 按钮扩展 ============ */
.badge-warn { background: #fdf3e3; color: var(--warn); }
.badge-danger { background: #fdecec; color: var(--danger); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover:not(:disabled) { opacity: .88; }

/* ============ 日志详情截断 + 展开 ============ */
.detail-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-cell.expandable { cursor: pointer; }
.detail-cell.expanded {
  max-width: 520px;
  white-space: normal;
  word-break: break-all;
  overflow: visible;
  text-overflow: clip;
}

/* ============ 备注行内编辑 ============ */
.note-edit-btn { margin-left: 6px; padding: 2px 8px; font-size: 12px; }
.note-input {
  width: 140px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.note-input + .btn-sm { margin-left: 6px; }

@media (max-width: 640px) {
  .content { padding: 0 12px; }
  .topbar { padding: 0 12px; }
  .tabs { padding: 0 12px; }
}
