/* ==========================================================================
   卡密发放后台 · 样式
   ========================================================================== */
:root {
  --bg: #0e0c17;
  --bg-2: #14111f;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #191527;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ece9f7;
  --muted: #8d87a6;
  --accent: #7c5cff;
  --accent-2: #ff5cab;
  --ok: #35d39a;
  --warn: #ffb340;
  --danger: #ff5f6d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --side-w: 232px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mt { margin-top: 22px; }

/* 背景光斑 */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(680px 420px at 8% -6%, rgba(124, 92, 255, 0.22), transparent 62%),
    radial-gradient(560px 380px at 100% 4%, rgba(255, 92, 171, 0.16), transparent 60%),
    radial-gradient(700px 500px at 50% 108%, rgba(53, 211, 154, 0.09), transparent 62%);
}

/* ============================ 通用控件 ============================ */
.input {
  width: 100%; padding: 10px 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .16s, box-shadow .16s, background .16s;
}
.input::placeholder { color: #6b6683; }
.input:focus {
  border-color: rgba(124, 92, 255, .75);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .16);
  background: rgba(0, 0, 0, .38);
}
select.input { appearance: none; background-image: none; cursor: pointer; }
select.input option { background: #191527; color: var(--text); }
textarea.input { resize: vertical; line-height: 1.7; }
.input-sm { padding: 6px 8px; font-size: 12px; width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text); background: rgba(255, 255, 255, .08);
  transition: transform .12s, filter .16s, background .16s, border-color .16s;
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(124, 92, 255, .36);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-line { background: transparent; border-color: var(--line-strong); }
.btn-line:hover { background: rgba(255, 255, 255, .07); }
.btn-ghost { background: rgba(255, 255, 255, .05); }
.btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.btn-danger-ghost { background: transparent; border-color: rgba(255, 95, 109, .45); color: #ff8a94; }
.btn-danger-ghost:hover { background: rgba(255, 95, 109, .13); }
.btn-danger { background: linear-gradient(135deg, #ff5f6d, #ff2d55); }
.btn-icon {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05); color: var(--text); font-size: 16px;
  cursor: pointer; display: none;
}

/* ============================ 登录页 ============================ */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(700px 460px at 50% 0%, rgba(124, 92, 255, .3), transparent 65%),
    radial-gradient(520px 400px at 85% 95%, rgba(255, 92, 171, .22), transparent 62%);
  filter: blur(6px);
}
.login-card {
  position: relative; width: 100%; max-width: 380px; padding: 36px 30px 30px;
  background: linear-gradient(180deg, rgba(32, 27, 51, .92), rgba(20, 17, 31, .95));
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: rise .45s cubic-bezier(.22, 1, .36, 1);
}
@keyframes rise { from { transform: translateY(14px) } to { transform: none } }
.login-logo { font-size: 44px; text-align: center; line-height: 1; margin-bottom: 12px; }
.login-title { margin: 0; font-size: 21px; text-align: center; letter-spacing: .5px; }
.login-sub {
  margin: 6px 0 26px; text-align: center;
  font-size: 11px; letter-spacing: 2.4px; text-transform: uppercase; color: var(--muted);
}
.field { display: block; margin-bottom: 16px; }
.field > span, .field > label, .field span {
  display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--muted); font-weight: 500;
}
.login-msg {
  margin-top: 14px; min-height: 18px; text-align: center;
  font-size: 13px; color: var(--danger);
}
.login-msg.ok { color: var(--ok); }

/* ============================ 布局 ============================ */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  background: linear-gradient(180deg, rgba(24, 20, 40, .96), rgba(14, 12, 23, .98));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px); z-index: 30;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.side-logo {
  width: 40px; height: 40px; display: grid; place-items: center; font-size: 21px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(124, 92, 255, .35);
}
.side-name { font-size: 15px; font-weight: 700; }
.side-sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 12px;
  font-size: 14px; color: var(--muted); cursor: pointer;
  transition: background .16s, color .16s;
  user-select: none;
}
.nav-item i { font-style: normal; font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 92, 255, .28), rgba(255, 92, 171, .16));
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .35);
}

.side-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, #35d39a, #2aa3ff); color: #08131a;
}
.side-user-name { font-size: 13.5px; font-weight: 600; }
.side-user-sub { font-size: 11px; color: var(--muted); }

.main { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px;
  background: rgba(14, 12, 23, .78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.topbar h2 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: rgba(53, 211, 154, .14); color: #6ee7b7;
  border: 1px solid rgba(53, 211, 154, .28);
}
.pill.empty { background: rgba(255, 95, 109, .14); color: #ff8a94; border-color: rgba(255, 95, 109, .3); }
.content { padding: 24px 26px 60px; flex: 1; }

/* ============================ 卡片 / 面板 ============================ */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
}
.panel.no-pad { padding: 0; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }

.stat-grid {
  display: grid; gap: 16px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.stat-card {
  position: relative; overflow: hidden;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}
.stat-card::after {
  content: ''; position: absolute; inset: 0; opacity: .16; pointer-events: none;
}
.stat-card.c1::after { background: radial-gradient(120px 90px at 88% 12%, #7c5cff, transparent 70%); }
.stat-card.c2::after { background: radial-gradient(120px 90px at 88% 12%, #35d39a, transparent 70%); }
.stat-card.c3::after { background: radial-gradient(120px 90px at 88% 12%, #ff5cab, transparent 70%); }
.stat-card.c4::after { background: radial-gradient(120px 90px at 88% 12%, #ffb340, transparent 70%); }
.stat-card.c5::after { background: radial-gradient(120px 90px at 88% 12%, #ff5f6d, transparent 70%); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value {
  font-size: 30px; font-weight: 800; line-height: 1.25; margin: 6px 0 4px;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.stat-foot { font-size: 12px; color: var(--muted); }
.stat-foot b { color: var(--text); }

.quick-row { display: flex; flex-wrap: wrap; gap: 10px; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li {
  display: flex; justify-content: space-between; padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}
.kv li:last-child { border-bottom: 0; }
.kv li span { color: var(--muted); font-size: 13px; }

/* 趋势图 */
.chart {
  display: flex; align-items: flex-end; gap: 10px;
  height: 172px; padding: 10px 4px 0;
}
.chart-empty { margin: auto; color: var(--muted); font-size: 13px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 52px; border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  min-height: 3px; position: relative;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .3);
}
.bar-num { font-size: 12px; font-weight: 700; }
.bar-day { font-size: 11px; color: var(--muted); }

/* ============================ 表格 ============================ */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; margin-bottom: 16px;
}
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .input { width: auto; min-width: 130px; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 700px; }
.table thead th {
  position: sticky; top: 0;
  padding: 12px 14px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .4px;
  background: rgba(20, 17, 31, .96);
  border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .05);
  vertical-align: middle;
}
.table tbody tr:hover { background: rgba(255, 255, 255, .035); }
.table .col-ck { width: 40px; }
.table .col-op { width: 76px; }
.table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; letter-spacing: .3px; white-space: nowrap;
}
.cell-code { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.copy-mini {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: 6px;
}
.copy-mini:hover { color: var(--accent-2); background: rgba(255, 255, 255, .07); }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tag.on { background: rgba(53, 211, 154, .15); color: #6ee7b7; }
.tag.off { background: rgba(255, 255, 255, .08); color: var(--muted); }
.empty-row { text-align: center; color: var(--muted); padding: 46px 0 !important; }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; flex-wrap: wrap;
}
.pager-btns { display: flex; align-items: center; gap: 10px; font-size: 13px; }

/* ============================ 表单 ============================ */
.form-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .field { margin-bottom: 0; }
.form-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
}

/* ============================ 弹窗 ============================ */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 5, 12, .68); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #211c33, #17131f);
  border: 1px solid var(--line-strong);
  border-radius: 20px; padding: 24px;
  box-shadow: var(--shadow);
  animation: rise .28s cubic-bezier(.22, 1, .36, 1);
}
.modal.wide { max-width: 720px; }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal .modal-sub { margin: 0 0 20px; font-size: 12.5px; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal-actions .btn { min-width: 86px; }
.gen-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.preview {
  margin-top: 14px; padding: 12px; border-radius: 12px; max-height: 150px; overflow-y: auto;
  background: rgba(0, 0, 0, .3); border: 1px dashed var(--line-strong);
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: #c9c4e0;
  line-height: 1.9; white-space: pre-wrap; word-break: break-all;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ============================ Toast ============================ */
.toast-wrap {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: rgba(28, 24, 44, .96); border: 1px solid var(--line-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
  animation: toastIn .26s cubic-bezier(.22, 1, .36, 1);
  backdrop-filter: blur(12px);
}
.toast.ok { border-color: rgba(53, 211, 154, .5); color: #8df0c4; }
.toast.err { border-color: rgba(255, 95, 109, .5); color: #ff9aa2; }
@keyframes toastIn { from { transform: translateY(14px) } }

/* ============================ 响应式 ============================ */
@media (max-width: 900px) {
  .btn-icon { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 14px 60px; }
  .stat-value { font-size: 26px; }
  .table { min-width: 620px; }
  .kv li { font-size: 13px; }
}
@media (max-width: 480px) {
  .login-card { padding: 30px 22px 24px; }
  .toolbar .input { min-width: 100%; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar-right .btn { flex: 1; }
}

/* ============================ 密码池 ============================ */
.cur-pw {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 22px; border-radius: 14px;
  background: rgba(0, 0, 0, .3);
  border: 1px dashed rgba(255, 255, 255, .22);
}
.cur-pw-value {
  flex: 1; min-width: 0;
  font-size: 26px; font-weight: 800; letter-spacing: 3px;
  color: #fff; word-break: break-all;
  text-shadow: 0 6px 22px rgba(124, 92, 255, .55);
}
.pw-progress { margin-top: 18px; }
.pw-progress-bar {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: rgba(0, 0, 0, .35);
}
.pw-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s ease;
}
.pw-progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 9px; font-size: 12.5px; color: var(--muted);
}
.tag.cur { background: rgba(124, 92, 255, .22); color: #c3b1ff; }

/* ============================ 设置页增强 ============================ */
.input.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .4px; }
.field > span .fhint {
  display: inline; margin-left: 8px; font-size: 11.5px;
  color: #6b6683; font-weight: 400;
}
#settingsRoot .panel-head { margin-top: 26px; margin-bottom: 14px; }
#settingsRoot .panel-head:first-child { margin-top: 0; }
#settingsRoot .panel-head h3 { font-size: 14px; color: var(--accent); }
