/* ============ 悬浮提示 Toast ============ */
#toast-host {
  position: fixed; z-index: 9999;
  left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px;
  width: max-content; max-width: calc(100vw - 28px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 14px;
  background: rgba(22,26,38,.96);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  color: #e9edf6; font-size: 13.5px; line-height: 1.5;
  backdrop-filter: blur(14px);
  animation: toastIn .26s cubic-bezier(.2,.9,.3,1.2);
  pointer-events: auto;
  max-width: 100%;
}
.toast.out { animation: toastOut .22s ease forwards; }
.toast .ic { flex: 0 0 auto; display: flex; margin-top: 1px; }
.toast.ok  { border-color: rgba(47,216,138,.5);  background: rgba(16,42,32,.96); }
.toast.ok  .ic { color: #2fd88a; }
.toast.err { border-color: rgba(255,92,108,.5);  background: rgba(46,18,22,.96); }
.toast.err .ic { color: #ff5c6c; }
.toast.info .ic { color: #6aa7ff; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(8px) scale(.97); } }
@media (min-width: 760px) {
  #toast-host { left: auto; right: 24px; bottom: 24px; transform: none; }
}

/* ============ 确认弹窗 ============ */
#confirm-mask {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(5,7,12,.62); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#confirm-mask.on { display: flex; }
#confirm-box {
  width: 100%; max-width: 380px;
  background: #161a26; border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px; padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: toastIn .24s cubic-bezier(.2,.9,.3,1.2);
}
#confirm-box h4 { font-size: 16px; margin: 0 0 8px; }
#confirm-box p  { color: #9aa4b8; font-size: 13.5px; line-height: 1.6; margin: 0 0 18px; word-break: break-word; }
#confirm-box .ops { display: flex; gap: 10px; justify-content: flex-end; }

/* ============ 按钮加载态 ============ */
.btn.loading { opacity: .65; pointer-events: none; position: relative; }
.btn.loading::after {
  content: ""; width: 12px; height: 12px; margin-left: 6px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; display: inline-block; vertical-align: -1px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 复制浮层 ============ */
.copy-tip {
  position: fixed; z-index: 10001;
  padding: 7px 13px; border-radius: 9px;
  background: rgba(47,216,138,.95); color: #04230f;
  font-size: 12.5px; font-weight: 600; pointer-events: none;
  animation: toastIn .2s ease;
}

/* ============ 密钥页（移动优先） ============ */
.kp-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.kp-head h1 { font-size: 20px; margin: 0 0 4px; line-height: 1.3; }
.kp-head p { margin: 0; font-size: 12.5px; }
.kp-head .btn { flex: 0 0 auto; }

/* 统计条：移动端两列 */
.kp-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px;
}
.kp-stat {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07);
  border-radius: 12px; padding: 10px 11px; min-width: 0;
}
.kp-stat span { display: block; font-size: 11px; color: rgba(255,255,255,.45); margin-bottom: 5px; }
.kp-stat b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kp-stat i { font-style: normal; font-size: 10.5px; color: rgba(255,255,255,.4); margin-left: 2px; }

.kp-list { display: flex; flex-direction: column; gap: 12px; }

.kp-card {
  background: rgba(255,255,255,.028); border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px; padding: 15px 16px 8px; box-sizing: border-box;
}
.kp-card[data-state="revoked"], .kp-card[data-state="expired"] { opacity: .62; }
.kp-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.kp-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-badge {
  flex: 0 0 auto; font-size: 11px; padding: 3px 9px; border-radius: 99px;
  border: 1px solid currentColor; line-height: 1.5;
}
.kp-badge.ok { color: #3ddc97; }
.kp-badge.revoked { color: #ff6b81; }
.kp-badge.expired { color: #ffb648; }

/* 密钥行：可换行，复制按钮足够大 */
.kp-key {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 7px 8px 7px 11px; margin-bottom: 12px;
}
.kp-key-text {
  flex: 1 1 auto; min-width: 0; font-size: 12px; letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: rgba(255,255,255,.72);
}
.kp-copy {
  flex: 0 0 auto; min-width: 62px; min-height: 34px; padding: 0 12px;
  font-size: 12.5px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(120,150,255,.45); background: rgba(120,150,255,.14);
  color: #b8c8ff; font-weight: 600; transition: .15s;
}
.kp-copy:active { transform: scale(.96); background: rgba(120,150,255,.26); }
.kp-copy.loading { opacity: .55; pointer-events: none; }

/* 元数据：两列 */
.kp-meta {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; margin-bottom: 12px;
}
.kp-meta > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kp-meta span { font-size: 10.5px; color: rgba(255,255,255,.38); }
.kp-meta b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kp-quota { margin-bottom: 8px; }
.kp-quota-bar { height: 5px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.kp-quota-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg,#5b8cff,#8f6bff); }
.kp-quota-txt { font-size: 11px; color: rgba(255,255,255,.42); margin-top: 5px; }

/* 操作行：按钮等分、够大 */
.kp-actions {
  display: flex; gap: 8px; padding: 11px 0 8px;
  border-top: 1px solid rgba(255,255,255,.06); margin-top: 10px;
}
.kp-act {
  flex: 1 1 0; min-width: 0; min-height: 38px; padding: 0 8px;
  font-size: 13px; border-radius: 9px; cursor: pointer; font-weight: 500;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.82); transition: .15s;
}
.kp-act:active { transform: scale(.97); background: rgba(255,255,255,.1); }
.kp-act.warn { color: #ffb648; border-color: rgba(255,182,72,.35); }
.kp-act.danger { color: #ff6b81; border-color: rgba(255,107,129,.33); }
.kp-act.ok { color: #3ddc97; border-color: rgba(61,220,151,.35); }

.kp-empty {
  text-align: center; padding: 48px 20px; border: 1px dashed rgba(255,255,255,.12);
  border-radius: 16px; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.kp-empty p { margin: 0; }
.kp-empty .btn { margin-top: 8px; }

/* 弹窗 */
dialog.kp-dlg {
  border: 1px solid rgba(255,255,255,.11); border-radius: 16px; padding: 20px;
  background: #12141c; color: inherit; width: min(400px, calc(100vw - 32px));
  box-sizing: border-box; max-height: 86vh; overflow: auto;
}
dialog.kp-dlg::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
dialog.kp-dlg h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
dialog.kp-dlg label { display: block; margin-bottom: 13px; font-size: 12.5px; color: rgba(255,255,255,.62); }
dialog.kp-dlg label small { font-size: 11px; }
dialog.kp-dlg input, dialog.kp-dlg select {
  display: block; width: 100%; margin-top: 6px; height: 40px; padding: 0 11px;
  box-sizing: border-box; font-size: 14px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.13); background: rgba(0,0,0,.34); color: inherit;
}
dialog.kp-dlg input:focus, dialog.kp-dlg select:focus { outline: none; border-color: rgba(120,150,255,.6); }
.kp-dlg-act { display: flex; gap: 10px; margin-top: 20px; }
.kp-dlg-act .btn { flex: 1 1 0; min-height: 42px; }
.kp-models { max-height: 180px; overflow: auto; border: 1px solid rgba(255,255,255,.09); border-radius: 9px; padding: 8px; margin-bottom: 13px; }
.kp-chk { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 0 0 6px !important; }
.kp-chk input { width: auto !important; height: auto !important; margin: 0 !important; }

@media (max-width: 720px) {
  .kp { padding-left: 14px; padding-right: 14px; }
  .kp-stats { grid-template-columns: repeat(2, 1fr); }
  .kp-stat b { font-size: 16px; }
  .kp-head h1 { font-size: 18px; }
  .kp-card { padding: 14px 14px 6px; }
  .kp-act { min-height: 42px; font-size: 13.5px; }
  .kp-copy { min-height: 38px; min-width: 66px; }
}
@media (max-width: 380px) {
  .kp-key-text { font-size: 11px; }
  .kp-meta { gap: 7px 9px; }
}
