* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f1117;
  color: #e6e8ee;
  min-height: 100vh;
}
.hidden { display: none !important; }
.btn {
  background: #1f2430; color: #e6e8ee; border: 1px solid #2c3342;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.btn:hover { background: #2a3140; }
.btn.primary { background: #4f7cff; border-color: #4f7cff; color: #fff; }
.btn.primary:hover { background: #3d6bf0; }
.btn.danger { background: #d64545; border-color: #d64545; color: #fff; }
.btn.warn { background: #e08a2e; border-color: #e08a2e; color: #fff; }
.btn.ghost { background: transparent; border-color: #2c3342; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #161a24; border: 1px solid #2c3342; border-radius: 16px;
  padding: 40px; width: 380px; text-align: center;
}
.login-logo { font-size: 40px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: #8a93a6; font-size: 13px; margin-bottom: 24px; }
.form input {
  width: 100%; background: #1f2430; border: 1px solid #2c3342; color: #e6e8ee;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px;
}
.form input:focus { outline: none; border-color: #4f7cff; }
.form .btn { width: 100%; padding: 11px; font-size: 15px; }
.msg { margin-top: 10px; font-size: 13px; color: #e08a2e; min-height: 18px; }
.msg.error { color: #d64545; }
.msg.ok { color: #4caf50; }

/* 头部 */
header {
  display: flex; align-items: center; gap: 24px; padding: 14px 24px;
  background: #161a24; border-bottom: 1px solid #2c3342; position: sticky; top: 0; z-index: 10;
}
header .brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.nav-btn {
  background: transparent; color: #8a93a6; border: none; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.nav-btn:hover { background: #1f2430; color: #e6e8ee; }
.nav-btn.active { background: #4f7cff; color: #fff; }
.user-box { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.user-box span { color: #8a93a6; font-size: 13px; }

/* 主区 */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: #161a24; border: 1px solid #2c3342; border-radius: 12px; padding: 18px;
}
.stat-card .num { font-size: 28px; font-weight: 700; color: #4f7cff; }
.stat-card .label { color: #8a93a6; font-size: 13px; margin-top: 4px; }

/* 面板 */
.panel {
  background: #161a24; border: 1px solid #2c3342; border-radius: 12px;
  padding: 20px; margin-bottom: 20px;
}
.panel h2 { font-size: 16px; margin-bottom: 16px; color: #b9c1d4; }

/* 生成表单 */
.gen-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.gen-form select, .gen-form input {
  background: #1f2430; border: 1px solid #2c3342; color: #e6e8ee;
  padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
.gen-form select { min-width: 150px; }
.gen-form input { min-width: 90px; }
.gen-result { margin-top: 14px; background: #10151f; border: 1px solid #2c3342; border-radius: 8px; padding: 12px; }
.gen-result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: #8a93a6; }
.codes { display: flex; flex-wrap: wrap; gap: 8px; max-height: 220px; overflow-y: auto; }
.codes .code {
  font-family: Consolas, monospace; background: #1f2430; border: 1px solid #2c3342;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; user-select: all;
}
.codes .code:hover { border-color: #4f7cff; }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input {
  background: #1f2430; border: 1px solid #2c3342; color: #e6e8ee;
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
}
.spacer { flex: 1; }

/* 表格 */
.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th {
  text-align: left; padding: 10px; color: #8a93a6; font-weight: 500;
  border-bottom: 1px solid #2c3342; white-space: nowrap;
}
.grid td { padding: 10px; border-bottom: 1px solid #1c222f; vertical-align: middle; }
.grid tr:hover td { background: #1a1f2b; }
.grid input[type=checkbox] { accent-color: #4f7cff; }
.tag { padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.tag.unused { background: #3a4256; color: #c7cfe0; }
.tag.active { background: #1e5a2e; color: #6fd38a; }
.tag.expired { background: #5a3a1e; color: #e0b16f; }
.tag.disabled, .tag.revoked { background: #5a1e1e; color: #e06f6f; }
.code-cell { font-family: Consolas, monospace; font-size: 12px; }
.device-cell { font-family: Consolas, monospace; font-size: 11px; color: #8a93a6; word-break: break-all; max-width: 220px; }
.op-cell { display: flex; gap: 6px; }
.op-cell .btn { padding: 4px 8px; font-size: 12px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; color: #8a93a6; font-size: 13px; }

/* 提示 */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #1f2430; border: 1px solid #2c3342; color: #e6e8ee;
  padding: 12px 24px; border-radius: 10px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.ok { border-color: #4caf50; }
.toast.error { border-color: #d64545; }

.panel.narrow { max-width: 480px; }
