:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #2563eb;
  --accent2: #1d4ed8;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "微软雅黑", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.wrap { max-width: 780px; margin: 0 auto; padding: 26px 18px 60px; }
.wrap-wide { max-width: 1180px; }

h1 { font-size: 21px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

label { display: block; font-size: 13px; margin: 0 0 6px; font-weight: 600; }
.field-tip { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }

input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: "Consolas", "Courier New", monospace;
  resize: vertical;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #5a6272; }
input:disabled, textarea:disabled { opacity: .6; }

.row { margin-bottom: 14px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 150px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: background .15s;
}
button:hover { background: var(--accent2); }
button.ghost { background: var(--panel2); border: 1px solid var(--border); color: var(--text); }
button.ghost:hover { background: #262b35; }
button.danger { background: #7f1d1d; }
button.danger:hover { background: #991b1b; }
button:disabled { opacity: .5; cursor: not-allowed; }
.gen-btn { width: 100%; padding: 13px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.result-box {
  background: #0c1a0f;
  border: 1px solid #1f4d2c;
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
  word-break: break-all;
  font-family: "Consolas", monospace;
  font-size: 13px;
  color: #b7f0c4;
}

.err-msg { color: var(--err); font-size: 13px; margin-top: 8px; }
.ok-msg { color: var(--ok); font-size: 13px; margin-top: 8px; }
.warn-msg { color: var(--warn); font-size: 13px; margin-top: 8px; }
.note { color: var(--muted); font-size: 12px; }
.mono { font-family: "Consolas", monospace; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .03em; }
tbody tr:hover { background: #1c2029; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-unused { background: #14321f; color: #4ade80; }
.badge-used { background: #2a2130; color: #a78bfa; }
.badge-revoked { background: #3a1a1a; color: #f87171; }
.badge-active { background: #12283f; color: #60a5fa; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 13px; }
.stat .num { font-size: 23px; font-weight: 700; font-family: "Consolas", monospace; line-height: 1.2; }
.stat .lbl { color: var(--muted); font-size: 12px; }

.codes-area { width: 100%; min-height: 200px; font-size: 13px; line-height: 1.8; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 10px 15px; border-radius: 8px 8px 0 0; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
}
.tab:hover { background: var(--panel); color: var(--text); }
.tab.active { color: var(--text); background: var(--panel); border-bottom: 2px solid var(--accent); }

.hidden { display: none !important; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input { width: auto; min-width: 120px; }

/* ---- 趋势柱状图 ---- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 8px 0 0; overflow-x: auto; }
.bar-col { flex: 1 0 32px; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 32px; }
.bar-val { font-size: 11px; font-family: "Consolas", monospace; color: var(--muted); height: 16px; line-height: 16px; }
.bar-track {
  flex: 1; width: 100%; display: flex; align-items: flex-end;
  background: var(--panel2); border-radius: 4px 4px 0 0; overflow: hidden;
}
.bar-fill {
  width: 100%; background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s ease;
}
.bar-lbl { font-size: 10px; color: var(--muted); margin-top: 5px; font-family: "Consolas", monospace; white-space: nowrap; }

/* ---- 顶部条 ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 14px; font-size: 13px;
}

/* ---- 参数版本卡片 ---- */
.key-card {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; margin-bottom: 10px;
}
.key-card.is-active { border-color: #2f6fd0; }
.key-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.key-fp { font-family: "Consolas", monospace; font-size: 13px; letter-spacing: .05em; }
.key-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.key-stats b { color: var(--text); font-family: "Consolas", monospace; }

/* ---- 轻提示 ---- */
#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: #1f2937; border: 1px solid var(--border); color: var(--text);
  padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); opacity: 0; transition: opacity .2s;
  pointer-events: none; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.err { border-color: #7f1d1d; color: #fca5a5; }
#toast.ok { border-color: #14532d; color: #86efac; }

.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin-bottom: 4px; }

@media (max-width: 640px) {
  .wrap { padding: 16px 12px 40px; }
  table { font-size: 12px; }
  th, td { padding: 6px; }
  .hide-sm { display: none; }
}
