/* ==========================================================================
   AE · 卡密后台
   暗色软件面板风格：深灰底 + 浅紫蓝强调（#9999FF / #7B61FF）+ 等宽读数
   1px 细描边、无发光、无大面积渐变；含 ≤900px 手机端抽屉与卡片式表格
   ========================================================================== */

:root {
  /* 底色 / 面板 */
  --bg: #17171B;
  --panel: #1F1F26;
  --panel-2: #262631;
  --panel-3: #2C2C38;
  --stroke: #33333F;
  --stroke-soft: #2B2B35;
  --stroke-strong: #3D3D4B;

  /* 强调色 */
  --accent: #9999FF;
  --accent-2: #7B61FF;
  --accent-press: #7C7CE8;
  --accent-soft: rgba(153, 153, 255, .13);
  --accent-soft-2: rgba(153, 153, 255, .07);
  --on-accent: #0A0A14;

  /* 文字 */
  --text: #EDEDF2;
  --text-dim: #8C8CA0;
  --text-mute: #6A6A7A;

  /* 语义色 */
  --ok: #4ADE80;
  --ok-soft: rgba(74, 222, 128, .12);
  --danger: #FF5B6E;
  --danger-soft: rgba(255, 91, 110, .12);
  --warn: #FFC35A;
  --warn-soft: rgba(255, 195, 90, .12);

  /* 兼容旧变量名 */
  --surface: var(--panel);
  --surface2: var(--panel-2);

  /* 尺寸 */
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 220px;
  --topbar-h: 48px;

  --mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
::selection { background: rgba(153, 153, 255, .28); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #31313C; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3E3E4C; }

/* --------------------------------------------------------------------------
   通用控件
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease,
              transform .08s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(153, 153, 255, .55);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, #9E9EFF 0%, #9999FF 55%, #9090F5 100%);
  color: var(--on-accent);
  border-color: rgba(255, 255, 255, .08);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ADADFF 0%, #A2A2FF 55%, #9797FF 100%);
  box-shadow: 0 3px 12px -6px rgba(153, 153, 255, .75);
}

.btn-ghost { background: var(--panel-2); border-color: var(--stroke); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-3); border-color: var(--stroke-strong); }

.btn-danger { background: transparent; border-color: rgba(255, 91, 110, .45); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 40px; font-size: 13.5px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .08s ease;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

/* 按钮 loading */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(10, 10, 20, .4);
  border-top-color: rgba(10, 10, 20, .95);
  animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after,
.btn-danger.is-loading::after {
  border-color: rgba(237, 237, 242, .22);
  border-top-color: var(--text);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 表单控件 */
.input {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
textarea.input { resize: vertical; line-height: 1.7; }
.input::placeholder { color: var(--text-mute); }
.input:hover { border-color: var(--stroke-strong); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-3);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, .13);
}

.select {
  height: 36px;
  padding: 0 30px 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238C8CA0' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  appearance: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.select:hover { border-color: var(--stroke-strong); }
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, .13);
}

.field { display: block; margin-bottom: 14px; }
.field > .field-label,
.field > span:first-child {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: .02em;
}
.field .hint {
  display: block;
  margin-top: 5px;
  color: var(--text-mute);
  font-size: 11px;
  font-style: normal;
}

/* 开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--stroke);
  transition: background .18s ease, border-color .18s ease;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #6E6E80;
  transition: transform .18s cubic-bezier(.3, .8, .3, 1), background .18s ease;
}
.switch input:checked + i,
.switch i.on { background: rgba(153, 153, 255, .28); border-color: var(--accent); }
.switch input:checked + i::after,
.switch i.on::after { transform: translateX(18px); background: var(--accent); }

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
}

/* 徽标 */
.tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-mute);
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}
.pill-active { background: rgba(153, 153, 255, .14); border-color: rgba(153, 153, 255, .35); color: #B9B9FF; }
.pill-unused { background: rgba(140, 140, 160, .12); border-color: rgba(140, 140, 160, .28); color: var(--text-dim); }
.pill-expired { background: rgba(255, 195, 90, .12); border-color: rgba(255, 195, 90, .3); color: var(--warn); }
.pill-banned { background: rgba(255, 91, 110, .12); border-color: rgba(255, 91, 110, .32); color: var(--danger); }
.pill-type { background: var(--panel-3); border-color: var(--stroke); color: var(--text-dim); font-family: var(--mono); font-size: 10.5px; }
.pill-forever { background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .3); color: var(--ok); }

.role-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(153, 153, 255, .35);
  background: var(--accent-soft);
  color: #BEBEFF;
  font-size: 11px;
}
.quota-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
}
.demo-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 195, 90, .4);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   登录页
   -------------------------------------------------------------------------- */
.login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(760px 460px at 50% -8%, rgba(123, 97, 255, .16), transparent 70%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 372px; }
.login-card {
  position: relative;
  padding: 30px 28px 22px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
}
.login-logo { display: block; width: 72px; height: 72px; margin: 2px auto 16px; border-radius: 16px; }
.login-title { margin: 0; text-align: center; font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.login-sub {
  margin: 6px 0 22px;
  text-align: center;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.login-err { min-height: 18px; margin: -4px 0 8px; color: var(--danger); font-size: 12px; }
.login-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--stroke-soft);
  color: var(--text-mute);
  font-size: 11px;
}
.login-foot a { font-size: 11px; }

/* --------------------------------------------------------------------------
   骨架
   -------------------------------------------------------------------------- */
.app { display: block; min-height: 100vh; }
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(0, 0, 0, .55);
  animation: fade .18s ease;
}
.scrim.show { display: block; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  border-right: 1px solid var(--stroke);
  background: #141418;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--stroke);
}
.brand-logo { width: 26px; height: 26px; border-radius: 7px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 14px; font-weight: 700; letter-spacing: .04em; }
.brand-text span { color: var(--text-mute); font-size: 10.5px; letter-spacing: .08em; }

.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  margin-bottom: 2px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 12.5px;
  transition: background .15s ease, color .15s ease, transform .08s ease;
}
.nav-item .ni { width: 16px; font-style: normal; font-size: 13px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item:active { transform: scale(.98); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.active .ni { opacity: 1; }

.side-foot { padding: 12px 16px 14px; border-top: 1px solid var(--stroke); color: var(--text-mute); font-size: 11px; }
.side-status { display: flex; align-items: center; gap: 6px; }
.side-ver { margin-top: 4px; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, .14); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(23, 23, 27, .94);
  backdrop-filter: blur(8px);
}
.hamburger {
  display: none;
  width: 34px;
  height: 30px;
  padding: 6px 7px;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  background: var(--panel-2);
  cursor: pointer;
}
.hamburger:active { transform: scale(.95); }
.hamburger i { display: block; height: 1.5px; margin: 3px 0; background: var(--text-dim); border-radius: 2px; }
.crumb { color: var(--text-dim); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid rgba(153, 153, 255, .3);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.admin-name { color: var(--text); font-size: 12px; }

.content { flex: 1; padding: 20px 22px 40px; }
.page { display: none; max-width: 1320px; }
.page.active { display: block; animation: pageIn .18s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.page-head h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: .2px; }
.page-head h2::before {
  content: "";
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: .2em;
  opacity: .85;
}
#page-overview h2::before { content: "OVERVIEW"; }
#page-add h2::before { content: "NEW KEYS"; }
#page-cards h2::before { content: "LICENSE KEYS"; }
#page-logs h2::before { content: "AUDIT LOG"; }
#page-agents h2::before { content: "AGENTS"; }
#page-announce h2::before { content: "ANNOUNCEMENT"; }
#page-settings h2::before { content: "SYSTEM"; }
.page-head p { margin: 4px 0 0; color: var(--text-dim); font-size: 12px; }
.head-actions { display: flex; gap: 8px; }

/* --------------------------------------------------------------------------
   面板
   -------------------------------------------------------------------------- */
.card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 36px;
  padding: 0 14px;
  border-bottom: 1px solid var(--stroke);
  background: #1C1C22;
}
.card-head > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.card-head h3 {
  margin: 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.card-desc { color: var(--text-mute); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--stroke);
  color: var(--text-mute);
  font-size: 11.5px;
}
.form-body { padding: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat { padding: 13px 14px 12px; transition: border-color .16s ease; }
.stat:hover { border-color: var(--stroke-strong); }
.stat-label { display: flex; align-items: baseline; gap: 7px; color: var(--text-dim); font-size: 11.5px; }
.stat-label em {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
  letter-spacing: .12em;
  opacity: .6;
}
.stat-value {
  margin: 6px 0 4px;
  font-family: var(--mono);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.15;
}
.stat-sub { color: var(--text-mute); font-size: 11px; }

/* 图表 */
.chart-card { margin-bottom: 12px; }
.chart-wrap { position: relative; height: 226px; padding: 10px 12px 6px; }
#trend-canvas { display: block; width: 100%; height: 100%; }
.chart-tip {
  position: absolute;
  z-index: 5;
  padding: 5px 8px;
  border: 1px solid var(--stroke-strong);
  border-radius: 6px;
  background: #101014;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -130%);
}

/* 迷你卡 + 类型分布 */
.mini-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  color: var(--text-dim);
  font-size: 12px;
}
.mini b { color: var(--text); font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; }

.type-dist { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 11.5px;
}
.type-chip b { color: var(--text); font-family: var(--mono); font-size: 12px; }
.type-chip.forever b { color: var(--ok); }

/* --------------------------------------------------------------------------
   表格
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  height: 32px;
  padding: 0 10px;
  border-bottom: 1px solid var(--stroke);
  background: #1B1B21;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--stroke-soft);
  font-size: 12px;
  vertical-align: middle;
}
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: #262631; }
.table tbody tr:last-child td { border-bottom: none; }
.table .col-check { width: 34px; }
.table .col-check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.table .col-ops { width: 1%; white-space: nowrap; }
.table .card-code { font-family: var(--mono); font-size: 12px; }
.table .sub { display: block; margin-top: 2px; color: var(--text-mute); font-family: var(--mono); font-size: 10.5px; }
.table .time { color: var(--text-dim); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.table .ip { color: var(--text-dim); font-family: var(--mono); font-size: 11.5px; }
.table .ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-actions { display: flex; gap: 2px; }
.link-btn {
  height: 24px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, transform .08s ease;
}
.link-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.link-btn:active:not(:disabled) { transform: scale(.94); }
.link-btn.accent { color: var(--accent); }
.link-btn.danger { color: var(--danger); }
.link-btn:disabled { opacity: .38; cursor: not-allowed; }

/* 空状态 / 骨架 */
.empty { padding: 44px 16px; text-align: center; color: var(--text-mute); }
.empty .empty-art {
  margin-bottom: 10px;
  color: var(--stroke-strong);
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: .3em;
}
.empty .empty-title { margin-bottom: 4px; color: var(--text-dim); font-size: 13px; }
.empty .empty-desc { font-size: 11.5px; }

.skeleton-row td { padding: 12px 10px; }
.sk {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #262631 25%, #303040 37%, #262631 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* 筛选栏 */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--stroke);
}
.filters .input, .filters .select { width: auto; }
.filter-search { flex: 1 1 220px; min-width: 160px; }
/* 页面标题右侧的搜索框：定宽，避免挤压标题导致文字重叠 */
.page-head > div:first-child { min-width: 0; }
.page-head .filter-search { flex: 0 1 268px; width: 268px; }
.filters .select { min-width: 118px; }

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--stroke);
  background: var(--accent-soft-2);
  color: var(--text-dim);
  font-size: 12px;
}
.batch-bar span:first-child { margin-right: 4px; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease, transform .08s ease;
}
.page-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.page-btn:active:not(:disabled) { transform: scale(.94); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-gap { padding: 0 2px; color: var(--text-mute); font-size: 11px; }

/* --------------------------------------------------------------------------
   添加卡密：类型选择
   -------------------------------------------------------------------------- */
.type-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.type-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 12px 12px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .1s ease, box-shadow .16s ease;
}
.type-opt:hover { border-color: var(--stroke-strong); background: var(--panel-3); }
.type-opt:active { transform: scale(.98); }
.type-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.type-opt .t-name { font-size: 13px; font-weight: 600; }
.type-opt .t-days { color: var(--accent); font-family: var(--mono); font-size: 11px; letter-spacing: .04em; }
.type-opt .t-desc { color: var(--text-mute); font-size: 11px; }
.type-opt.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, .1);
}
.type-opt.selected .t-name { color: #C6C6FF; }
.type-opt.locked { opacity: .45; cursor: not-allowed; }
.type-opt .t-lock {
  position: absolute;
  top: 8px;
  right: 9px;
  padding: 1px 4px;
  border: 1px solid var(--stroke);
  border-radius: 4px;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
}

.gen-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}
.gen-info { color: var(--text-dim); font-size: 12px; }
.code-area {
  background: #15151A;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.75;
}
.gen-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.updated { margin-top: 12px; color: var(--text-mute); font-size: 11px; }
.switch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   弹窗
   -------------------------------------------------------------------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 6, 10, .62);
  animation: fade .16s ease;
}
.modal {
  display: flex;
  flex-direction: column;
  width: min(92vw, 520px);
  max-height: 86vh;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 40px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--stroke);
  background: #1C1C22;
}
.modal-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; color: var(--text-dim); font-size: 12.5px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--stroke); }
.modal-msg { color: var(--text); font-size: 13px; line-height: 1.6; }
.modal-note { margin-top: 8px; color: var(--text-mute); font-size: 11.5px; }

/* --------------------------------------------------------------------------
   Toast（右上滑入，3 秒消失）
   -------------------------------------------------------------------------- */
.toast-wrap {
  position: fixed;
  /* 顶栏 48px，提示条压在下面，避免挡住角色/额度信息 */
  top: 60px;
  right: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 208px;
  max-width: min(84vw, 360px);
  padding: 10px 13px;
  border: 1px solid var(--stroke-strong);
  border-left-width: 3px;
  border-radius: 9px;
  background: #16161C;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 12px 28px -16px rgba(0, 0, 0, .9);
  animation: toastIn .24s cubic-bezier(.2, .9, .3, 1.1);
}
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(18px); } }
.toast .ti { font-size: 13px; line-height: 1; }
.toast.success { border-left-color: var(--ok); }
.toast.success .ti { color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.error .ti { color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.warn .ti { color: var(--warn); }
.toast.info { border-left-color: var(--accent); }
.toast.info .ti { color: var(--accent); }

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .stat-grid, .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --topbar-h: 52px; }

  /* 侧栏抽屉 */
  .sidebar {
    width: 244px;
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.3, .8, .3, 1);
    box-shadow: 24px 0 48px -30px rgba(0, 0, 0, .9);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .admin-name { display: none; }
  .content { padding: 14px 12px 32px; overflow-x: hidden; }

  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head h2 { font-size: 17px; }
  .head-actions { justify-content: stretch; }
  .head-actions .btn { flex: 1; }

  /* 触控目标 */
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .input, .select { min-height: 42px; height: 42px; }
  textarea.input { height: auto; min-height: 96px; }
  .link-btn { height: 34px; padding: 0 9px; font-size: 12px; }
  .page-btn { min-width: 32px; height: 32px; }
  .nav-item { height: 44px; font-size: 13.5px; }
  .filters { padding: 10px 12px; }
  .filter-search { flex: 1 1 100%; }
  .filters .select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .card-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .toast-wrap { top: 56px; right: 10px; left: 10px; }
  .toast { max-width: none; }
  .modal-foot .btn { flex: 1; }
  .switch-row { flex-direction: column; align-items: stretch; }
  .switch-row .btn { width: 100%; }

  /* 表格 → 卡片堆叠 */
  .table-wrap { overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr { display: block; width: 100%; }
  .table td { display: flex; width: auto; box-sizing: border-box; }
  .table tbody tr {
    box-sizing: border-box;
    margin: 10px 12px;
    padding: 8px 12px;
    border: 1px solid var(--stroke);
    border-radius: 10px;
    background: var(--panel-2);
  }
  .table tbody tr:hover { background: var(--panel-3); }
  /* 标签在上、值在下：窄屏不会把长卡密/批号顶出屏幕 */
  .table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--stroke-soft);
    text-align: left;
  }
  .table td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--text-mute);
    font-size: 10.5px;
    letter-spacing: .04em;
    text-align: left;
  }
  .table td.col-check { justify-content: flex-start; }
  .table td.col-check::before { content: "选择"; }
  /* 长卡密 / 批号在窄屏必须换行，否则会顶出屏幕右侧 */
  .table td { overflow-wrap: anywhere; }
  .table td > * { min-width: 0; }
  .table .row-actions { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  /* 操作列：标签独占一行，按钮左对齐换行，避免被挤成两列 */
  .table td.col-ops { flex-direction: column; align-items: stretch; gap: 4px; }
  .table td.col-ops .row-actions { justify-content: flex-start; }
  .table .ellipsis { max-width: none; white-space: normal; }
  .empty { padding: 32px 14px; }
}

@media (max-width: 560px) {
  .stat-grid { gap: 8px; }
  .stat { padding: 11px 12px 10px; }
  .stat-value { font-size: 22px; }
  .mini-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-card { padding: 24px 18px 18px; }
  .login-foot { flex-direction: column; align-items: flex-start; gap: 6px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .role-chip, .quota-chip { font-size: 10px; padding: 0 7px; }
  .gen-bar { flex-direction: column; align-items: stretch; }
  .gen-bar .btn { width: 100%; }
  .form-body { padding: 12px; }
}

/* 批量栏：常驻 + 手机端三列按钮 */
.batch-bar { position: sticky; top: 0; z-index: 6; }
.batch-bar .bulk-check {
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; font-size: 12.5px; color: var(--text);
  padding: 2px 2px; user-select: none;
}
.batch-bar .bulk-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.batch-bar .bulk-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.batch-bar .btn[disabled] { opacity: .42; }

@media (max-width: 900px) {
  /* 操作按钮改成两列栅格：手机上不再挤成一条 */
  .table .row-actions,
  .table td.col-ops .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .table .link-btn {
    height: 32px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--stroke); border-radius: 8px;
    background: rgba(255, 255, 255, .02);
    font-size: 12.5px;
  }
  .table .link-btn.danger { border-color: rgba(255, 91, 110, .38); }
  .table .link-btn.accent { border-color: rgba(153, 153, 255, .38); }
}

@media (max-width: 640px) {
  .batch-bar { padding: 8px 10px; gap: 6px; top: 0; }
  .batch-bar .bulk-actions {
    width: 100%; margin-left: 0;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .batch-bar .btn { width: 100%; height: 34px; }
  .batch-bar .btn.admin-only { grid-column: span 1; }
  .table .row-actions,
  .table td.col-ops .row-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table td.col-ops { padding-top: 6px; }
}

/* 卡片化模式下 td.col-ops 继承了桌面版 width:1%，会把操作按钮挤成 3px 宽 —— 必须覆盖 */
@media (max-width: 900px) {
  .table td.col-ops { width: 100% !important; white-space: normal; }
  .table td.col-ops .row-actions { width: 100%; }
}
