:root {
  --bg: #e9eaec;
  --panel: #ffffff;
  --bar: #f2f3f4;
  --line: #c9cbcf;
  --line-soft: #e0e2e5;
  --text: #1f2225;
  --text-2: #5a6068;
  --text-3: #8b9198;
  --accent: #1c6fb0;
  --accent-lo: #16588c;
  --ok: #2f7d55;
  --warn: #9a6a10;
  --err: #b23b3b;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

/* 关键：作者样式里的 display 会盖掉 UA 的 [hidden]{display:none} */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 12.5px/1.5 "Microsoft YaHei UI", "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- 登录 ---------- */

.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e4e6e8;
}

.login-box {
  width: 320px;
  padding: 22px 22px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgba(20, 26, 34, .12);
}

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-title { font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.login-sub { font-size: 11.5px; color: var(--text-3); }
.login-err { margin: 10px 0 0; color: var(--err); font-size: 11.5px; min-height: 16px; }

.mark {
  width: 26px; height: 26px; flex: 0 0 26px;
  background: #1F5F8B;
  border-radius: 4px;
  position: relative;
}
.mark::after {
  content: "";
  position: absolute; left: 8px; top: 7px;
  width: 0; height: 0;
  border-left: 10px solid #fff;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.lbl {
  display: block;
  font-size: 11.5px;
  color: var(--text-2);
  margin: 0 0 5px;
}

.input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(28, 111, 176, .16);
}
textarea.input { height: auto; padding: 6px 8px; resize: vertical; }
select.input { padding-right: 4px; }

.btn {
  height: 28px;
  padding: 0 12px;
  background: linear-gradient(#fdfdfe, #f0f1f3);
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
}
.btn:hover:not(:disabled) { background: linear-gradient(#fff, #e8f2fb); border-color: #a9c4dc; }
.btn:active:not(:disabled) { background: #e6e8ea; padding-top: 1px; }
.btn:disabled { color: var(--text-3); cursor: default; }

.btn-primary {
  background: linear-gradient(#2b7cb8, #1c6fb0);
  border-color: #16588c;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(#3389c8, #1f76ba); border-color: #16588c; }
.btn-primary:active:not(:disabled) { background: #1a669f; }

.btn-block { width: 100%; margin-top: 14px; height: 30px; }
.btn-sm { height: 25px; padding: 0 10px; font-size: 12px; }
.btn-xs { height: 22px; padding: 0 8px; font-size: 11.5px; }
.btn-danger { color: var(--err); }
.btn-danger:hover:not(:disabled) { background: #fdf1f1; border-color: #d9a3a3; }

/* ---------- 框架 ---------- */

.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  flex: 0 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(#fbfcfc, #f0f1f3);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-size: 13px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.ts { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-right: 4px; }

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 统计 ---------- */

.stats {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 9px 11px 10px;
}
.stat-label { font-size: 11px; color: var(--text-3); }
.stat-num {
  font-size: 21px; font-weight: 600; line-height: 1.25;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.stat-num.ok { color: var(--ok); }
.stat-num.warn { color: var(--warn); }
.stat-num.err { color: var(--err); }
.stat-num.dim { color: var(--text-2); }

/* ---------- 面板 ---------- */

.panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
}

.panel-bar {
  flex: 0 0 auto;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 12.5px; font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 6px; }
.input-search { width: 240px; height: 25px; }
.input-sel { width: 118px; height: 25px; }

.table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-2);
  background: #f7f8f9;
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
  white-space: nowrap;
}
.tbl td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  line-height: 1.35;
}
.tbl tbody tr:hover { background: #f6fafd; }
.tbl tbody tr.revoked td { color: var(--text-3); }
.tbl tbody tr.revoked .key-code { text-decoration: line-through; }

.key-code { font-family: var(--mono); font-size: 11.5px; letter-spacing: .2px; user-select: all; }
.cell-dim { color: var(--text-3); font-size: 11.5px; }
.cell-mono { font-family: var(--mono); font-size: 11.5px; }
.note-cell { color: var(--text-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid;
  border-radius: 2px;
  line-height: 15px;
  white-space: nowrap;
}
.badge.active { color: var(--ok); border-color: #a8cdb9; background: #f1f8f4; }
.badge.unused { color: var(--accent-lo); border-color: #aec8de; background: #f2f8fd; }
.badge.expired { color: var(--text-2); border-color: var(--line); background: #f6f7f8; }
.badge.revoked { color: var(--err); border-color: #dcb0b0; background: #fdf3f3; }
.badge.expiring { color: var(--warn); border-color: #dcc38a; background: #fdf8ee; }

.row-ops { display: flex; gap: 4px; flex-wrap: nowrap; }
.row-ops .btn { padding: 0 7px; }

/* 行内下拉菜单 */
.menu {
  position: fixed;
  z-index: 60;
  min-width: 122px;
  padding: 3px;
  background: #fff;
  border: 1px solid #9aa0a8;
  box-shadow: 0 6px 18px rgba(20, 26, 34, .18);
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 10px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  border-radius: 2px;
}
.menu-item:hover { background: #eaf3fb; }
.menu-item.danger { color: var(--err); }
.menu-item.danger:hover { background: #fdf1f1; }

.tbl-log td { font-size: 11.5px; }
.tbl-log .t { font-family: var(--mono); color: var(--text-2); white-space: nowrap; }
.tbl-log .cell-mono {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.empty { padding: 40px 0; text-align: center; color: var(--text-3); font-size: 12px; }

.pager {
  flex: 0 0 auto;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--bar);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-2);
}
.pager-btns { display: flex; gap: 5px; }

/* ---------- 状态栏 ---------- */

.statusbar {
  flex: 0 0 auto;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: #f2f3f4;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-2);
}
.statusbar .sep { width: 1px; height: 12px; background: var(--line); }
.statusbar .grow { flex: 1 1 auto; }

/* ---------- 弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(30, 32, 35, .28);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 72px 16px 16px;
}
.modal[hidden] { display: none !important; }

.modal-box {
  width: 460px;
  max-width: 100%;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid #9aa0a8;
  box-shadow: 0 10px 30px rgba(20, 26, 34, .22);
}
.modal-wide { width: 840px; }
.modal-narrow { width: 380px; }
.modal-body .hint { margin: 8px 0 0; font-size: 11.5px; color: var(--danger, #c0392b); }
.modal-body .hint.ok { color: #2f7d55; }
.modal-body .lbl + .input + .lbl { margin-top: 10px; }

.modal-bar {
  flex: 0 0 auto;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 11px;
  background: linear-gradient(#fbfcfc, #eef0f2);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 12.5px;
}
.modal-bar .x {
  width: 24px; height: 24px;
  border: none; background: none;
  font-size: 16px; line-height: 1;
  color: var(--text-2); cursor: pointer;
}
.modal-bar .x:hover { background: #e2e5e8; }

.modal-body { padding: 14px; overflow: auto; }
.modal-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bar);
  border-top: 1px solid var(--line);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.tip { margin: 4px 0 0; font-size: 11px; color: var(--text-3); }

.result-box {
  margin-top: 14px;
  padding: 10px;
  background: #f7f8f9;
  border: 1px solid var(--line-soft);
}
.result-head { font-size: 11.5px; color: var(--text-2); margin-bottom: 6px; }
.keys-out {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: #fff;
  resize: vertical;
  margin-bottom: 8px;
}

.tbl-log th { top: 0; }

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  z-index: 100;
  padding: 7px 14px;
  background: #2b2f33;
  color: #fff;
  font-size: 12px;
  border-radius: 2px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .24);
  max-width: 70vw;
}
.toast[hidden] { display: none !important; }
.toast.err { background: #9c2f2f; }

/* ---------- 滚动条 ---------- */

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #f0f1f3; }
::-webkit-scrollbar-thumb { background: #c3c6ca; border: 3px solid #f0f1f3; }
::-webkit-scrollbar-thumb:hover { background: #a9adb2; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
