/* ==========================================================
   License Platform Console
   ========================================================== */
:root {
  --bg: #0f1115;
  --bg-elev: #161920;
  --bg-elev2: #1c2029;
  --border: #262c38;
  --border-soft: #1e232d;
  --text: #e6e9ef;
  --text-dim: #949cab;
  --text-faint: #626b7b;
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, .14);
  --green: #2ecc71;
  --green-soft: rgba(46, 204, 113, .14);
  --amber: #f5a623;
  --amber-soft: rgba(245, 166, 35, .14);
  --red: #ff5c5c;
  --red-soft: rgba(255, 92, 92, .14);
  --purple: #9b7bff;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
code, .mono { font-family: var(--mono); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #1a2135 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 36px 32px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; letter-spacing: -.2px; }
.login-card .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
.login-card .field { margin-bottom: 14px; }
.login-card .err {
  background: var(--red-soft); color: var(--red); padding: 9px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 14px;
  border: 1px solid rgba(255,92,92,.25);
}

/* ---------- 表单元素 ---------- */
label.fl { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.inp, .sel, .txa {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 9px 12px; border-radius: 8px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus, .sel:focus, .txa:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.inp::placeholder { color: var(--text-faint); }
.txa { resize: vertical; min-height: 80px; line-height: 1.5; }
.sel { cursor: pointer; }
.sel option { background: var(--bg-elev); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elev2); color: var(--text); font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { background: #232834; border-color: #333b4a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #6a8fff; border-color: #6a8fff; }
.btn-danger { color: var(--red); border-color: rgba(255,92,92,.3); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-elev2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }

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

.sidebar {
  width: 216px; flex: 0 0 216px; background: var(--bg-elev);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 20px 18px 18px; border-bottom: 1px solid var(--border-soft);
}
.brand .logo { font-size: 15px; font-weight: 650; letter-spacing: -.2px; display: flex; align-items: center; gap: 8px; }
.brand .logo .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.brand .tag { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; padding-left: 16px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 8px; color: var(--text-dim); font-size: 13.5px;
  cursor: pointer; transition: all .12s; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: var(--bg-elev2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #a9c0ff; font-weight: 550; }
.nav-item .ico { width: 16px; text-align: center; opacity: .85; font-size: 14px; }
.nav-group { font-size: 11px; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: .08em; padding: 14px 11px 6px; font-weight: 600; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-soft); }
.user-box { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 8px; }
.user-box:hover { background: var(--bg-elev2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft);
  color: #a9c0ff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12.5px; flex: 0 0 30px;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta .n { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .r { font-size: 11px; color: var(--text-faint); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; padding: 0 24px; gap: 16px; background: rgba(15,17,21,.8);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
/* 内容区撑满剩余宽度：表格类列表页需要横向空间，
   限制最大宽度会让右侧留大片空白，列也挤在一起 */
.content { padding: 24px; width: 100%; }

/* 阅读/表单类页面限制行宽并居中。
   列表页要全宽，但文档、设置这类页面若拉到 1700px，
   一行文字太长，阅读时会频繁串行。 */
.content.content-narrow > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.content.content-narrow .card { max-width: 1180px; }
/* 文档页是左侧目录 + 右侧内容的双栏，整体限宽即可，内层卡片交给网格 */
.content.content-narrow #docsGrid { max-width: 1180px; }
.content.content-narrow #docsGrid .card { max-width: none; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* ---------- 统计 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat .k { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.5px; line-height: 1.1; }
.stat .d { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.stat.accent .v { color: #7d9dff; }
.stat.green .v { color: var(--green); }
.stat.amber .v { color: var(--amber); }
.stat.red .v { color: var(--red); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.2px; }
table.tbl th {
  text-align: left; padding: 11px 16px; font-weight: 550; font-size: 12px;
  color: var(--text-dim); background: var(--bg-elev2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.tbl td {
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: rgba(255,255,255,.022); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 550; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--green); background: var(--green-soft); border-color: rgba(46,204,113,.22); }
.badge.warn { color: var(--amber); background: var(--amber-soft); border-color: rgba(245,166,35,.22); }
.badge.err { color: var(--red); background: var(--red-soft); border-color: rgba(255,92,92,.22); }
.badge.info { color: #7d9dff; background: var(--accent-soft); border-color: rgba(79,124,255,.22); }
.badge.mute { color: var(--text-faint); background: rgba(255,255,255,.05); border-color: var(--border); }
.badge.purple { color: var(--purple); background: rgba(155,123,255,.14); border-color: rgba(155,123,255,.22); }

/* ---------- 授权码展示 ---------- */
.key-cell {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .3px;
  color: #b9c8e8; cursor: pointer; user-select: all;
}
.key-cell:hover { color: #fff; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; padding: 56px 20px; color: var(--text-faint);
}
.empty .ico { font-size: 34px; opacity: .4; margin-bottom: 12px; }
.empty .t { font-size: 14px; color: var(--text-dim); margin-bottom: 6px; }
.empty .s { font-size: 12.5px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; z-index: 100; overflow-y: auto;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 620px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  animation: slideUp .2s cubic-bezier(.2,.8,.3,1);
  margin: auto 0;
}
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center;
}
.modal-head h3 { font-size: 15.5px; font-weight: 600; }
.modal-head .x {
  margin-left: auto; background: none; border: none; color: var(--text-dim);
  font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.modal-head .x:hover { background: var(--bg-elev2); color: var(--text); }
.modal-body { padding: 22px; max-height: 66vh; overflow-y: auto; }
.modal-foot {
  padding: 16px 22px; border-top: 1px solid var(--border-soft);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------- 表单网格 ---------- */
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- 提示 ---------- */
.hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }
.hint code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.callout {
  padding: 11px 14px; border-radius: 8px; font-size: 12.8px;
  border: 1px solid; line-height: 1.5;
}
.callout.info { background: var(--accent-soft); border-color: rgba(79,124,255,.25); color: #a9c0ff; }
.callout.warn { background: var(--amber-soft); border-color: rgba(245,166,35,.25); color: #ffce7a; }
.callout.err { background: var(--red-soft); border-color: rgba(255,92,92,.25); color: #ff9b9b; }
.callout.ok { background: var(--green-soft); border-color: rgba(46,204,113,.25); color: #7ee2a8; }

/* ---------- toast ---------- */
#toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
}
.toast {
  background: var(--bg-elev2); border: 1px solid var(--border);
  padding: 11px 16px; border-radius: 9px; font-size: 13.2px;
  box-shadow: var(--shadow); max-width: 380px;
  animation: toastIn .22s cubic-bezier(.2,.8,.3,1);
  display: flex; align-items: center; gap: 9px;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.ok { border-color: rgba(46,204,113,.4); }
.toast.ok::before { content: '✓'; color: var(--green); font-weight: 700; }
.toast.err { border-color: rgba(255,92,92,.4); }
.toast.err::before { content: '✕'; color: var(--red); font-weight: 700; }
.toast.info::before { content: 'i'; color: var(--accent); font-weight: 700; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box .inp { padding-left: 32px; min-width: 220px; }
.search-box::before {
  content: '⌕'; position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%); color: var(--text-faint); font-size: 15px;
}

/* ---------- 分页 ---------- */
.pager {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-top: 1px solid var(--border-soft); font-size: 13px; color: var(--text-dim);
}
.pager .spacer { flex: 1; }

/* ---------- 详情键值 ---------- */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 22px; }
.kv .k { font-size: 11.5px; color: var(--text-faint); margin-bottom: 3px; letter-spacing: .03em; }
.kv .v { font-size: 13.5px; word-break: break-all; }
.kv .v.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- 复制框 ---------- */
.copy-row {
  display: flex; gap: 8px; align-items: center; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 8px 8px 12px;
}
.copy-row code { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- tag ---------- */
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  background: rgba(255,255,255,.06); font-size: 11.5px; color: var(--text-dim);
  margin-right: 4px; margin-bottom: 3px;
}

/* ---------- 迷你图表 ---------- */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 42px; }
.spark .bar { flex: 1; max-width: 34px; background: var(--accent-soft); border-radius: 2px 2px 0 0; min-height: 3px;
  transition: background .15s; }
.spark .bar:hover { background: var(--accent); }

/* ---------- 加载 ---------- */
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }
.loading-page { display: flex; align-items: center; justify-content: center; padding: 80px; gap: 12px; color: var(--text-dim); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -216px; z-index: 50; transition: left .22s; height: 100vh; }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .fgrid, .fgrid3 { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 18px; padding: 4px 8px; }

/* ---------- 代码块 ---------- */
pre.code {
  background: #0b0d11; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-family: var(--mono);
  font-size: 12.3px; line-height: 1.65; color: #c3cbd9;
}
pre.code .c { color: #5f6b7d; }
pre.code .s { color: #98c379; }
pre.code .k { color: #c678dd; }
pre.code .n { color: #d19a66; }
