:root {
  --bg: #060a11;
  --bg-soft: #0b1220;
  --panel: #0d1522;
  --panel-2: #111b2b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9eef8;
  --muted: #8a9bb5;
  --accent: #56c8ff;
  --accent-2: #8b6cff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5f7a;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 12% -10%, #10243d 0%, transparent 60%),
              radial-gradient(900px 600px at 100% 0%, #1b1338 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

button { font: inherit; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #06101d;
  font-weight: 650;
}
.btn.ghost { background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--bad); border-color: rgba(255, 95, 122, 0.4); }
.btn.danger:hover { background: rgba(255, 95, 122, 0.12); }

.input {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 12, 22, 0.7);
  color: var(--text);
  outline: none;
  min-width: 0;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(86, 200, 255, 0.12); }
.select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > span { color: var(--muted); font-size: 12.5px; }
.field .input, .field input[type="password"], .field input[type="text"],
.field input[type="email"], .field input[type="number"], .field input[type="date"] {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 12, 22, 0.7);
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(86, 200, 255, 0.12); }

.code-block {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #060c15;
  color: #b9d8ff;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}
.textarea { width: 100%; resize: vertical; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 30px 28px 22px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 32, 50, 0.9), rgba(9, 15, 25, 0.95));
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(86, 200, 255, 0.8);
}
.brand strong { display: block; font-size: 18px; letter-spacing: 0.3px; }
.brand em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); letter-spacing: 0.6px; }
.brand.small { margin: 0 0 18px; padding: 0 4px; }
.brand.small strong { font-size: 15px; }
.error { color: var(--bad); min-height: 18px; margin: 10px 2px 0; font-size: 12.5px; }

/* ---------- 布局 ---------- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: rgba(7, 12, 20, 0.65);
  position: sticky;
  top: 0;
  height: 100vh;
}
#nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-btn.active {
  background: linear-gradient(135deg, rgba(86, 200, 255, 0.16), rgba(139, 108, 255, 0.16));
  color: #cfeaff;
  box-shadow: inset 0 0 0 1px rgba(86, 200, 255, 0.25);
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.key-id { font-size: 11px; color: var(--muted); padding: 0 4px; word-break: break-all; }

main { padding: 22px 26px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: 0.2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 30, 47, 0.85), rgba(10, 16, 26, 0.85));
}
.card .label { color: var(--muted); font-size: 12.5px; }
.card .value { font-size: 28px; font-weight: 700; margin-top: 8px; letter-spacing: -0.5px; }
.card .hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.card.accent .value { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- 面板与表格 ---------- */
.panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(10, 17, 28, 0.78);
  padding: 18px;
  margin-bottom: 16px;
  overflow: hidden;
}
.panel h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-head .btn { margin-left: auto; }
.panel p { margin: 6px 0 14px; line-height: 1.7; }
.panel code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input[type="search"] { width: 300px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
td.actions { white-space: nowrap; display: flex; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; line-height: 1.5;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--ok); background: rgba(61, 220, 151, 0.1); border-color: rgba(61, 220, 151, 0.25); }
.badge.revoked { color: var(--bad); background: rgba(255, 95, 122, 0.1); border-color: rgba(255, 95, 122, 0.25); }
.badge.expired { color: var(--warn); background: rgba(255, 181, 71, 0.1); border-color: rgba(255, 181, 71, 0.25); }
.badge.released { color: var(--muted); background: rgba(138, 155, 181, 0.1); border-color: rgba(138, 155, 181, 0.25); }

.key-cell .masked { font-weight: 600; letter-spacing: 0.3px; }
.key-cell .sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.device-list { padding: 4px 0 10px; }
.device {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 6px 0;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.device .name { font-weight: 550; }
.device .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.device .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-top: 12px; color: var(--muted); font-size: 12.5px; }

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

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(3, 6, 12, 0.7);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%; max-width: 520px;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #101a29, #0a111c);
  box-shadow: var(--shadow);
  max-height: 90vh; overflow-y: auto;
}
.modal-card.wide { max-width: 640px; }
.modal-card h2 { margin: 0 0 14px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 100;
  padding: 11px 18px; border-radius: 12px;
  background: rgba(18, 28, 44, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.ok { border-color: rgba(61, 220, 151, 0.45); }
.toast.err { border-color: rgba(255, 95, 122, 0.5); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; padding: 12px 14px; overflow-x: auto; }
  .brand.small { margin: 0; }
  .brand.small em { display: none; }
  #nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .key-id { display: none; }
  main { padding: 16px; }
  .toolbar .input[type="search"] { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
}
