:root {
  --bg: #070b14;
  --bg-2: #0b1220;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-2: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e6edf7;
  --text-dim: #8b98ab;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

svg { display: block; }
.mono { font-family: "SF Mono", "JetBrains Mono", Consolas, monospace; }

/* ==================== 登录 ==================== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(34, 211, 238, 0.12), transparent 60%),
              radial-gradient(1000px 600px at 100% 110%, rgba(99, 102, 241, 0.14), transparent 60%),
              var(--bg);
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(600px 400px at 50% 45%, #000, transparent 75%);
}
.login-box {
  position: relative; width: 380px; max-width: calc(100vw - 40px);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 18px; padding: 38px 34px 26px;
  box-shadow: var(--shadow);
  animation: fadeUp .5s ease;
}
.login-logo {
  width: 60px; height: 60px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; color: var(--accent);
  background: linear-gradient(135deg, rgba(34,211,238,.15), rgba(99,102,241,.15));
  border: 1px solid rgba(34,211,238,.25);
  box-shadow: 0 0 24px rgba(34,211,238,.25);
}
.login-box h1 { font-size: 20px; text-align: center; font-weight: 700; letter-spacing: .5px; }
.login-box .sub { text-align: center; color: var(--text-dim); font-size: 12px; margin: 8px 0 26px; }
.login-foot { text-align: center; color: #55617a; font-size: 11px; margin-top: 20px; letter-spacing: .3px; }

/* ==================== 表单 ==================== */
label { display: block; margin: 16px 0 7px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: .3px; }
input, select, textarea {
  width: 100%; padding: 11px 13px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color .18s, box-shadow .18s;
}
input::placeholder, textarea::placeholder { color: #4d5870; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b98ab' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 13.5px; font-weight: 600; font-family: inherit;
  transition: transform .12s, filter .12s, background .18s, border-color .18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, #0891b2, #22d3ee); color: #04141a; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: rgba(255,255,255,0.04); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: rgba(255,255,255,0.09); }
.btn-danger { background: linear-gradient(135deg, #b91c1c, #ef4444); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-block { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ==================== 布局 ==================== */
.admin-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; font-weight: 700; font-size: 15px; color: var(--text); }
.brand svg { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 12px; border: none; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 13.5px; font-weight: 500; font-family: inherit;
  text-align: left; transition: background .18s, color .18s;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(8,145,178,.2), rgba(34,211,238,.1)); color: var(--accent); }
.nav-item.active svg { filter: drop-shadow(0 0 6px rgba(34,211,238,.5)); }
.sidebar-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 16px; border-top: 1px solid var(--border); }
.side-action {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: none; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: transparent; color: var(--text-dim); font-size: 13px; text-align: left;
  transition: background .18s, color .18s;
}
.side-action:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.side-action.danger:hover { background: rgba(239,68,68,0.12); color: var(--red); }

.main { flex: 1; min-width: 0; padding: 26px 30px 40px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.topbar-badge {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 20px; color: var(--text-dim); font-size: 12px;
  background: var(--panel);
}
.topbar-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }

/* ==================== 统计卡片 ==================== */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.card {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: relative; overflow: hidden; transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--radius);
  background: radial-gradient(300px 80px at 0 0, rgba(255,255,255,0.05), transparent 70%);
  pointer-events: none;
}
.card-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.icon-cyan { background: rgba(34,211,238,.14); color: var(--accent); }
.icon-red { background: rgba(239,68,68,.14); color: var(--red); }
.icon-green { background: rgba(16,185,129,.14); color: var(--green); }
.icon-orange { background: rgba(245,158,11,.14); color: var(--orange); }
.card .num { font-size: 28px; font-weight: 800; letter-spacing: .5px; }
.card .num.green { color: var(--green); }
.card .num.red { color: var(--red); }
.card .label { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

/* ==================== 面板 ==================== */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; animation: fadeUp .35s ease;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.filter { display: flex; gap: 8px; align-items: center; }
.filter input { width: 200px; }

/* ==================== 表格 ==================== */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 14px; text-align: left; font-size: 13px; white-space: nowrap; }
.table th {
  background: rgba(255,255,255,0.03); color: var(--text-dim); font-weight: 600; font-size: 12px;
  letter-spacing: .3px; text-transform: uppercase; border-bottom: 1px solid var(--border);
}
.table td { border-bottom: 1px solid rgba(255,255,255,0.04); }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: rgba(255,255,255,0.025); }
.table tbody tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: #55617a; padding: 36px; white-space: normal; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge.ok { background: rgba(16,185,129,.14); color: var(--green); }
.badge.ok::before { background: var(--green); }
.badge.revoked { background: rgba(239,68,68,.14); color: var(--red); }
.badge.revoked::before { background: var(--red); }
.badge.expired { background: rgba(245,158,11,.14); color: var(--orange); }
.badge.expired::before { background: var(--orange); }

.pk-cell { cursor: pointer; color: var(--text-dim); font-size: 12px; transition: color .15s; }
.pk-cell:hover { color: var(--accent); }

/* ==================== 分页 ==================== */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 18px; }
.pager span { color: var(--text-dim); font-size: 13px; }

/* ==================== 弹窗 ==================== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .2s ease;
}
.modal-box {
  background: #0e1626; border: 1px solid var(--border-strong); border-radius: 16px;
  padding: 24px; width: 480px; max-width: 100%; max-height: 92vh; overflow: auto;
  box-shadow: var(--shadow); animation: fadeUp .28s ease;
}
.modal-box-sm { width: 400px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-dim); padding: 4px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.confirm-text { color: var(--text-dim); font-size: 14px; margin-top: 10px; line-height: 1.6; word-break: break-all; }

/* ==================== 消息 / Toast ==================== */
.msg { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.msg.ok { color: var(--green); }

#toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 13px 18px;
  background: #0e1626; border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow); font-size: 13.5px; color: var(--text);
  animation: slideIn .3s ease; min-width: 220px; max-width: 360px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.hide { animation: slideOut .3s ease forwards; }

/* ==================== 动画 ==================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ==================== 响应式 ==================== */
@media (max-width: 860px) {
  .admin-view { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
  .brand { padding: 0; }
  .nav { flex-direction: row; flex: 1; }
  .nav-item { width: auto; }
  .sidebar-foot { flex-direction: row; border-top: none; padding-top: 0; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 18px 16px 30px; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
}
