/* ============================================================
   激活授权管理系统 - 全局样式
   设计基线：现代管理后台（Ant Design Pro / shadcn 风格）
   ============================================================ */

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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #f59e0b;
  --gray: #64748b;
  --border: #e8ecf2;
  --border-strong: #dbe2ea;
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --sidebar-bg: #0f1729;
  --sidebar-text: #94a3b8;
  --sidebar-active: #6366f1;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 12px 32px -16px rgba(15, 23, 42, .22);
  --ring: 0 0 0 3px rgba(79, 70, 229, .14);
}

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d5dbe5; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9c2d0; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 按钮 ---------------- */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background .16s, transform .06s, box-shadow .16s;
}
button:hover { background: var(--primary-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button.gray {
  background: #fff;
  color: #334155;
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
button.gray:hover { background: #f8fafc; border-color: #cbd5e1; }
button.red { background: var(--danger); }
button.red:hover { background: var(--danger-hover); }
button.success { background: var(--success); }
button.success:hover { background: #15803d; }
button.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

/* ---------------- 表单控件 ---------------- */
input, select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  width: 100%;
  background: #fff;
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* ============================================================
   登录页
   ============================================================ */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(99, 102, 241, .42), transparent 60%),
    radial-gradient(900px 520px at 92% 8%, rgba(168, 85, 247, .30), transparent 60%),
    linear-gradient(150deg, #eef2ff 0%, #f8fafc 45%, #eef1ff 100%);
}
.login-box {
  width: 396px;
  max-width: 100%;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 20px;
  padding: 40px 36px 32px;
  box-shadow: 0 30px 70px -30px rgba(30, 41, 59, .45);
  animation: rise .28s ease;
}
.login-box h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .5px;
  margin-bottom: 8px;
  color: var(--text);
}
.login-box .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}
.login-box button {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  margin-top: 10px;
  border-radius: 10px;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-item { margin-bottom: 16px; }
.form-item label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 7px;
}

/* ============================================================
   主布局
   ============================================================ */
.header {
  height: 60px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header .logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.header .logo::before {
  content: "激";
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px -6px rgba(99, 102, 241, .8);
}
.header .right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

.sidebar {
  width: 224px;
  flex-shrink: 0;
  padding: 14px 12px;
  background: linear-gradient(180deg, #111a2e 0%, #0d1526 100%);
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 3px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  position: relative;
  transition: background .15s, color .15s;
}
.sidebar a::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #334155;
  flex: none;
  transition: background .15s, box-shadow .15s;
}
.sidebar a:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.sidebar a.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, .22), rgba(99, 102, 241, .06));
  color: #fff;
  font-weight: 500;
}
.sidebar a.active::before {
  background: #818cf8;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .18);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 40px;
  overflow-x: auto;
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  margin-bottom: 16px;
  color: var(--text);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { margin: 0; }

/* ============================================================
   工具条
   ============================================================ */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input, .toolbar select {
  width: auto;
  min-width: 150px;
}

/* ============================================================
   表格
   ============================================================ */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f4f9;
  color: #1e293b;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f9fafc; }

/* ============================================================
   分页
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}
.pagination button {
  background: #fff;
  color: #334155;
  border: 1px solid var(--border-strong);
  box-shadow: none;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
}
.pagination button:hover:not(:disabled) { background: #f8fafc; }
.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ============================================================
   标签
   ============================================================ */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
}
.tag.green { background: #dcfce7; color: #15803d; }
.tag.gray { background: #f1f5f9; color: #475569; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.tag.blue { background: #e0e7ff; color: #3730a3; }
.tag.orange { background: #ffedd5; color: #c2410c; }

/* ============================================================
   模态框
   ============================================================ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .16s ease;
}
.modal {
  background: #fff;
  border-radius: 18px;
  padding: 26px 26px 20px;
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 40px 90px -30px rgba(15, 23, 42, .55);
  animation: pop .18s ease;
}
.modal h3 {
  font-size: 17px;
  font-weight: 650;
  margin-bottom: 20px;
  color: var(--text);
}
.modal .form-item { margin-bottom: 14px; }
.modal .form-item label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal .result-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: ui-monospace, Consolas, Monaco, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   Toast
   ============================================================ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  min-width: 240px;
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 16px 40px -16px rgba(15, 23, 42, .5);
  animation: slideIn .22s ease;
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: #4f46e5; }
.toast.warning { background: #f59e0b; }
@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   详情面板 / 空态 / 辅助
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px 18px;
  font-size: 13.5px;
}
.detail-grid .key { color: var(--text-muted); }
.hint {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 8px;
  line-height: 1.6;
}
.mono {
  font-family: ui-monospace, Consolas, Monaco, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 28px 0;
}

/* ============================================================
   仪表盘
   ============================================================ */
.dash-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.kpi-value {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 7px;
}
.kpi-sub .up { color: var(--success); font-weight: 500; }
.kpi-sub .down { color: var(--danger); font-weight: 500; }
.kpi-sub .flat { color: var(--text-muted); }

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.seg {
  display: inline-flex;
  padding: 3px;
  background: #f1f5f9;
  border-radius: 10px;
  gap: 2px;
}
.seg button {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 8px;
}
.seg button:hover { background: rgba(255, 255, 255, .7); color: #334155; }
.seg button.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.seg button.active:hover { background: #fff; }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.legend div {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}

.bar-item { margin-bottom: 14px; }
.bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: #334155;
}
.bar-top strong { color: var(--text); font-variant-numeric: tabular-nums; }
.bar-bg {
  height: 8px;
  background: #eef2f7;
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #818cf8, #4f46e5);
  transition: width .35s ease;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

/* ============================================================
   激活码列表辅助样式
   ============================================================ */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.batch-bar strong { color: var(--primary); font-variant-numeric: tabular-nums; }

.sw-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.sw-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}
.code-check { cursor: pointer; }

/* ============================================================
   旧版统计卡片（保留兼容）
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .num {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 820px) {
  .header { padding: 0 14px; }
  .header .right span { display: none; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px;
    background: #0f1729;
  }
  .sidebar a {
    margin-bottom: 0;
    white-space: nowrap;
    padding: 8px 12px;
  }
  .sidebar a::before { display: none; }
  .main { padding: 16px 14px 32px; }
  .card { padding: 16px; }
  table { font-size: 12.5px; }
}
