/* ============================================================
   AUTHKEY · 设计系统
   风格：Blue & White —— 企业级蓝白，干净、克制、高可读
   ============================================================ */

:root {
  /* 底色 */
  --paper:      #f4f7fb;
  --paper-2:    #eef3fa;
  --sheet:      #ffffff;

  /* 文字 */
  --ink:        #101828;
  --ink-2:      #475467;
  --muted:      #667085;
  --faint:      #98a2b3;

  /* 线条 */
  --line:       #e7ecf3;
  --line-2:     #d3dbe7;

  /* 主色 */
  --accent:     #1668dc;
  --accent-d:   #1155b8;
  --accent-soft:#eaf2fe;
  --accent-2:   #3b8ef0;

  /* 语义 */
  --danger:     #d92d20;
  --danger-soft:#fef3f2;
  --warn:       #b54708;
  --warn-soft:  #fffaeb;
  --ok:         #079455;
  --ok-soft:    #ecfdf3;

  /* 字体 */
  --serif: var(--sans);
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
           "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas,
           "Liberation Mono", monospace;

  --r: 8px;
  --r-lg: 14px;
  --sh: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px -6px rgba(16,24,40,.10);
  --sh-lg: 0 12px 32px -12px rgba(16,24,40,.18);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ---------- 工具 ---------- */
.mono     { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.text-sm  { font-size: 12.5px; }
.faint    { color: var(--faint); }
.nowrap   { white-space: nowrap; }
.head-spacer { flex: 1 1 auto; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--accent);
}

/* ---------- 图标 ---------- */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: -3px;
}
.icon-sm { width: 15px; height: 15px; stroke-width: 1.9; vertical-align: -2px; }
.icon-lg { width: 24px; height: 24px; stroke-width: 1.6; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .005em;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid rgba(22,104,220,.22); outline-offset: 1px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(22,104,220,.24);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-d); border-color: var(--accent-d); }

.btn-ghost {
  background: #fff;
  border-color: var(--line-2);
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) {
  border-color: #a9b8cc;
  color: var(--ink);
  background: #fbfcfe;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #b42318; border-color: #b42318; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--faint); }
.input:hover,
.select:hover { border-color: #b8c4d6; }
.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22,104,220,.13);
}

.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-eye {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: .15s;
}
.pw-eye:hover { color: var(--accent); background: var(--accent-soft); }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 18px;
}

/* ---------- 面板 ---------- */
.panel {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
  padding: 22px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.005em;
  color: var(--ink);
}
.card-head .icon { color: var(--accent); }

.tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-active  { color: var(--ok);     background: var(--ok-soft);     border-color: #abefc6; }
.badge-unused  { color: var(--accent); background: var(--accent-soft); border-color: #c7ddfb; }
.badge-banned  { color: var(--danger); background: var(--danger-soft); border-color: #fecdca; }
.badge-expired { color: var(--warn);   background: var(--warn-soft);   border-color: #fedf89; }

/* ---------- 分段控件 ---------- */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-2);
}
.seg button {
  padding: 6px 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); background: rgba(255,255,255,.7); }
.seg button.on {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(16,24,40,.08);
}

/* ---------- 胶囊 ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 搜索 ---------- */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 250px;
}
.search-box .icon {
  position: absolute;
  left: 12px;
  color: var(--faint);
  pointer-events: none;
}
.search-box .input { padding-left: 36px; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
  overflow: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfd;
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover td { background: #f8fbff; }

.code-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
}
.copy-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  opacity: 0;
  transition: .14s;
}
tr:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--line-2); background: #fff; }

.row-actions { display: flex; gap: 5px; }
.act {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #fff;
  color: #5b6b80;
  cursor: pointer;
  transition: .14s;
}
.act:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.act.warn:hover { border-color: #fdb022; color: var(--warn); background: var(--warn-soft); }
.act.danger:hover { border-color: #fda29b; color: var(--danger); background: var(--danger-soft); }

/* ---------- 日志 ---------- */
.log-list { display: flex; flex-direction: column; }

.log-row {
  display: flex;
  gap: 12px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--line);
}
.log-row:last-child { border-bottom: 0; }

.log-kind {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--paper-2);
  margin-top: 1px;
}
.log-kind.k-activate { color: var(--ok);     border-color: #abefc6; background: var(--ok-soft); }
.log-kind.k-generate { color: var(--accent); border-color: #c7ddfb; background: var(--accent-soft); }
.log-kind.k-ban,
.log-kind.k-delete { color: var(--danger); border-color: #fecdca; background: var(--danger-soft); }
.log-kind.k-unban,
.log-kind.k-reset { color: var(--warn); border-color: #fedf89; background: var(--warn-soft); }

.log-main { min-width: 0; flex: 1; }
.log-detail {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.5;
}
.log-code {
  display: inline-block;
  margin-left: 7px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
}
.log-meta {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--faint);
}

/* ---------- 柱状图 ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 156px;
  padding-top: 6px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  height: 100%;
}
.bar-val {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.bar-track {
  flex: 1;
  width: 100%;
  max-width: 40px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(to top, var(--paper-2), rgba(238,243,250,0));
  border-radius: 6px 6px 0 0;
}
.bar-fill {
  width: 100%;
  background: linear-gradient(to top, var(--accent), var(--accent-2));
  border-radius: 6px 6px 0 0;
  transition: height .45s cubic-bezier(.2,.8,.2,1);
  min-height: 3px;
}
.bar-lbl {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--faint);
}
.empty .icon { width: 30px; height: 30px; stroke-width: 1.4; opacity: .5; }
.empty-title {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- 键值 ---------- */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-align: right; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 210px;
  max-width: 340px;
  padding: 11px 15px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--sh-lg);
  animation: toastIn .24s cubic-bezier(.2,.9,.2,1);
}
.toast.out { animation: toastOut .2s forwards; }
.toast-ok { border-left-color: var(--ok); }
.toast-ok .icon { color: var(--ok); }
.toast-err { border-left-color: var(--danger); }
.toast-err .icon { color: var(--danger); }
.toast-info { border-left-color: var(--accent); }
.toast-info .icon { color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(16,24,40,.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal-mask.show { display: grid; }

.modal {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  box-shadow: var(--sh-lg);
  animation: modalIn .2s cubic-bezier(.2,.9,.2,1);
}
.modal h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 650;
  color: var(--ink);
}
.modal-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 减少动画 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
