/* ============================================
   Components - 卡片 / 按钮 / 表单 / 徽章 / 弹窗
   ============================================ */

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
  transition: box-shadow 0.25s, border-color 0.25s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: -0.01em;
}

.card-title svg { width: 17px; height: 17px; color: var(--primary); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.hint {
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.65;
}
.hint b { color: var(--text-primary); font-weight: 600; }
.hint code {
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--text-primary);
}

/* ===== 统计卡 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--gradient-primary);
  opacity: 0.9;
}
.stat-card.ok::before { background: var(--gradient-success); }
.stat-card.warn::before { background: var(--gradient-warn); }
.stat-card.bad::before { background: var(--gradient-danger); }

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card.ok .stat-value { color: var(--success); }
.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.bad .stat-value { color: var(--danger); }

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== 按钮 ===== */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

button svg { width: 15px; height: 15px; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
button:active:not(:disabled) { transform: translateY(0) scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(29, 78, 216, 0.4); }

.btn-success { background: var(--gradient-success); color: #fff; }
.btn-danger { background: var(--gradient-danger); color: #fff; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; gap: 5px; }
.btn-xs svg { width: 12px; height: 12px; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ===== 表单 ===== */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

textarea { resize: vertical; min-height: 90px; line-height: 1.6; font-family: var(--font-mono); font-size: 12.5px; }

select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-group { flex: 1; min-width: 160px; }

/* 复制行 */
.copyline { display: flex; gap: 8px; }
.copyline input { flex: 1; font-family: var(--font-mono); font-size: 12px; }

/* ===== 徽章 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.5;
}

.badge.ok { background: rgba(34, 197, 94, 0.14); color: #15803d; }
.badge.warn { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.badge.bad { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.badge.mute { background: var(--bg-tertiary); color: var(--text-muted); }
.badge.info { background: var(--primary-light); color: var(--primary); }

[data-theme="dark"] .badge.ok { color: #4ade80; }
[data-theme="dark"] .badge.warn { color: #fbbf24; }
[data-theme="dark"] .badge.bad { color: #f87171; }

/* ===== 配额进度条 ===== */
.quota-bar {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
}

.quota-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  background: var(--gradient-success);
}

.quota-fill.warn { background: var(--gradient-warn); }
.quota-fill.bad { background: var(--gradient-danger); }

/* ===== 表格 ===== */
.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-tertiary);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--bg-hover); }

tbody tr.is-active {
  background: linear-gradient(90deg, var(--primary-light), transparent);
  box-shadow: inset 3px 0 0 var(--primary);
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px !important;
  font-size: 13px;
}

.acts { display: flex; gap: 5px; flex-wrap: wrap; }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
  animation: fadeIn 0.18s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal.wide { max-width: 760px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  padding: 0;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 22px 24px; overflow-y: auto; flex: 1; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

/* ===== Toast ===== */
.toast-wrap {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 13px 17px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
  pointer-events: auto;
  line-height: 1.5;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.ok { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warning); }
.toast.bad { border-left-color: var(--danger); }

/* ===== 提示条 ===== */
.warnbar {
  display: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(249, 115, 22, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.3);
  margin-bottom: 18px;
  font-size: 13px;
  flex-wrap: wrap;
}
.warnbar > span { flex: 1; min-width: 200px; }

/* ===== 标签页（卡片内） ===== */
.seg {
  display: inline-flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.seg button {
  background: transparent;
  padding: 7px 14px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  box-shadow: none;
}
.seg button:hover:not(.on) { background: transparent; color: var(--text-primary); transform: none; box-shadow: none; }
.seg button.on {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 52px; height: 52px; margin-bottom: 14px; opacity: 0.35; }
.empty-state h3 { font-size: 15px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.empty-state p { font-size: 13px; }

/* ===== 加载 ===== */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 工具类 */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* hidden 属性必须能覆盖 display:flex */
[hidden] { display: none !important; }
