:root {
  --bg: #0d1117;
  --bg2: #131a24;
  --panel: #161e2b;
  --line: #24303f;
  --text: #e6edf6;
  --muted: #8b9bb0;
  --accent: #4f7cff;
  --accent2: #7c5cff;
  --ok: #2ecc8f;
  --warn: #f0b429;
  --danger: #ef5350;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1a2540 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 650; }
h2 { font-size: 20px; }
h3 { font-size: 15px; color: #cdd9e8; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 340px; background: linear-gradient(180deg, #18202e, #121926);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.login-card .logo { font-size: 30px; text-align: center; }
.login-card h1 { text-align: center; font-size: 19px; margin: 8px 0 2px; }
.login-card p { text-align: center; margin: 0 0 18px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: #0f1620; color: var(--text);
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.login-err { color: var(--danger); min-height: 18px; font-size: 13px; margin-top: 10px; }

/* 布局 */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line); background: rgba(13,18,26,.85);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 8px; align-items: center; padding: 4px 8px; font-size: 15px; }
.brand span { font-size: 18px; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav a {
  color: var(--muted); text-decoration: none; padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
  transition: .15s;
}
nav a:hover { background: #16203040; color: var(--text); }
nav a.active { background: linear-gradient(90deg, #1d2b47, #172032); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.main { padding: 26px 30px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 按钮 */
.btn {
  border: 1px solid var(--line); background: #18212e; color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font: inherit; transition: .15s;
}
.btn:hover { border-color: #3a4c66; background: #1c2736; }
.btn.primary { background: linear-gradient(180deg, var(--accent), #3f66e0); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ff8a85; border-color: #4a2626; background: #23171a; }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 概览 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: linear-gradient(180deg, #18212f, #141b27); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.stat.accent .v { color: var(--accent); }
.stat.ok .v { color: var(--ok); }
.stat.warn .v { color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) {
  .grid2 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; width: auto;
    flex-direction: row; align-items: center; gap: 10px;
    padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line);
    background: rgba(13, 18, 26, .97); overflow-x: auto; overflow-y: hidden;
  }
  .sidebar::-webkit-scrollbar { height: 0; }
  .brand { display: none; }
  nav { flex-direction: row; gap: 6px; }
  nav a { white-space: nowrap; padding: 7px 11px; font-size: 13px; }
  nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 8px; padding: 0; }
  .sidebar-foot #whoami { display: none; }
  .main { padding: 14px 12px 48px; }
  .page-head { position: sticky; top: 50px; background: var(--bg); z-index: 10; padding: 8px 0; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .v { font-size: 20px; }
  .toolbar input { width: 100%; }
  .toolbar select { width: calc(50% - 4px); }
  th, td { padding: 8px 10px; }
  .modal-card { width: 100%; }
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* 表格 */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { width: 240px; margin: 0; }
.toolbar select { width: 150px; margin: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #131b27; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #1b2534; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .5px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.badge.unused { color: #9fb3c8; background: #1a2432; border-color: #2a3a4e; }
.badge.active { color: #6ee7b7; background: #10291f; border-color: #1d4d39; }
.badge.expired { color: #f0b429; background: #2a2210; border-color: #4d3d16; }
.badge.banned { color: #ff8a85; background: #2a1616; border-color: #4d2121; }
.badge.revoked { color: #b09ad6; background: #221a2e; border-color: #3a2b50; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--muted); font-size: 13px; }
.pager button { padding: 4px 10px; }
.ckcol { width: 34px; }
.ckcol input, tbody td input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
tr.selected td { background: #1c2940; }

.log-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.log-item { border-left: 2px solid #2b3a4e; padding: 4px 0 4px 10px; font-size: 13px; }
.log-item .t { color: var(--muted); font-size: 12px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(4,8,14,.7); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { width: 520px; max-height: 88vh; overflow: auto; background: #151d2a; border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 8px; }
.code {
  background: #0c121b; border: 1px solid var(--line); border-radius: 9px; padding: 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; max-height: 260px;
}
.gen-result { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1d2a3d; border: 1px solid #2f4360; color: #fff; padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: #5c2b2b; background: #2a1818; }
.fld { display: block; margin-bottom: 12px; }
.fld input, .fld select { width: 100%; }
.chk { display: flex; gap: 8px; align-items: center; color: var(--text); margin-bottom: 10px; font-size: 13.5px; }
.chk input { width: auto; margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
