:root {
  --bg: #0f1216;
  --bg-2: #151a20;
  --bg-3: #1b222a;
  --line: #262f3a;
  --line-2: #34404e;
  --fg: #e6edf3;
  --fg-2: #9aa8b6;
  --fg-3: #6b7a8a;
  --accent: #4aa8ff;
  --accent-2: #1f6feb;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
}

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

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧栏 ---------- */

.side {
  width: 210px;
  flex: 0 0 210px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 16px; border-bottom: 1px solid var(--line); }

.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(140deg, #2f6feb, #7b4dff);
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text span { color: var(--fg-3); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--fg-2);
  cursor: pointer; text-align: left; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-item i { font-style: normal; width: 16px; text-align: center; color: var(--fg-3); font-size: 13px; }
.nav-item:hover { background: var(--bg-3); color: var(--fg); }
.nav-item.active { background: rgba(74,168,255,.13); color: #a9d3ff; }
.nav-item.active i { color: var(--accent); }

.side-foot { border-top: 1px solid var(--line); padding-top: 12px; }

.line-box { font-size: 12px; }
.line-row { display: flex; align-items: center; justify-content: space-between; color: var(--fg-3); margin-bottom: 6px; }
.line-list { display: flex; flex-direction: column; gap: 4px; }
.line-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.line-item .name { color: var(--fg-2); }
.ver { color: var(--fg-3); font-size: 11px; margin-top: 10px; text-align: center; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }

/* ---------- 主区 ---------- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}

.crumb { display: flex; align-items: baseline; gap: 10px; }
.crumb > span:first-child { font-size: 15px; font-weight: 600; }
.crumb .sub { color: var(--fg-3); font-size: 12px; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 12px; padding: 4px 9px; border-radius: 20px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-2);
}
.badge.ok { color: #7ee787; border-color: rgba(63,185,80,.4); background: rgba(63,185,80,.1); }
.badge.bad { color: #ff9c96; border-color: rgba(248,81,73,.4); background: rgba(248,81,73,.1); }

.view { flex: 1; overflow: auto; padding: 20px 22px 40px; }

/* ---------- 通用元件 ---------- */

.btn {
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: #232c36; border-color: #46556a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: #2a7cf5; }
.btn.ok { background: rgba(63,185,80,.16); border-color: rgba(63,185,80,.5); color: #7ee787; }
.btn.danger { background: rgba(248,81,73,.14); border-color: rgba(248,81,73,.45); color: #ff9c96; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.mini {
  border: 0; background: transparent; color: var(--fg-3); cursor: pointer;
  padding: 2px 5px; border-radius: 5px; font-size: 13px;
}
.mini:hover { background: var(--bg-3); color: var(--fg); }

input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--fg);
  padding: 7px 10px; border-radius: 8px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,168,255,.14); }
textarea { resize: vertical; min-height: 90px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }

.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.stat .label { color: var(--fg-3); font-size: 12.5px; }
.stat .num { font-size: 27px; font-weight: 700; letter-spacing: .3px; margin-top: 4px; }
.stat .hint { color: var(--fg-3); font-size: 12px; margin-top: 2px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; color: var(--fg-3); font-weight: 500; font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--bg-2); position: sticky; top: 0; z-index: 1;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--fg); }
tbody td { padding: 9px 10px; border-bottom: 1px solid rgba(38,47,58,.6); vertical-align: middle; }
tbody tr:hover { background: rgba(74,168,255,.05); }
tbody tr.sel { background: rgba(74,168,255,.1); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.muted { color: var(--fg-3); }
.empty { padding: 40px 0; text-align: center; color: var(--fg-3); }

.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 20px; border: 1px solid transparent; white-space: nowrap; }
.tag.unused { color: #7ee787; background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.35); }
.tag.used { color: #a9d3ff; background: rgba(74,168,255,.12); border-color: rgba(74,168,255,.35); }
.tag.banned { color: #ff9c96; background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.35); }
.tag.expired { color: #e3b341; background: rgba(210,153,34,.12); border-color: rgba(210,153,34,.35); }
.tag.dim { color: var(--fg-2); background: var(--bg-3); border-color: var(--line-2); }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--fg-3); font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > label { font-size: 12.5px; color: var(--fg-2); }
.field .tip { font-size: 11.5px; color: var(--fg-3); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--fg-2); padding: 7px 13px; cursor: pointer; font-size: 13px; }
.seg button.on { background: rgba(74,168,255,.16); color: #a9d3ff; }

.note {
  border-left: 3px solid var(--warn); background: rgba(210,153,34,.08);
  padding: 10px 12px; border-radius: 6px; font-size: 12.5px; color: var(--fg-2);
  margin-bottom: 14px;
}
.note.danger { border-color: var(--danger); background: rgba(248,81,73,.08); }

pre.out {
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 12px; max-height: 320px; overflow: auto; font-family: Consolas, monospace;
  font-size: 12.5px; margin: 0; white-space: pre-wrap; word-break: break-all;
}

/* ---------- 弹层 ---------- */

.modal-mask {
  position: fixed; inset: 0; background: rgba(3,6,10,.68);
  display: grid; place-items: center; padding: 24px; z-index: 50;
  backdrop-filter: blur(2px);
}
/* display:grid 会盖掉浏览器默认的 [hidden]{display:none}，必须显式补一条 */
.modal-mask[hidden] { display: none; }
.modal {
  width: min(620px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast {
  min-width: 220px; max-width: 420px; padding: 10px 14px; border-radius: 9px; font-size: 13px;
  background: var(--bg-3); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: slide .18s ease-out;
}
.toast.ok { border-color: rgba(63,185,80,.5); color: #b7f0bf; }
.toast.err { border-color: rgba(248,81,73,.5); color: #ffb4af; }
.toast .t-detail { color: var(--fg-3); font-size: 11.5px; margin-top: 3px; white-space: pre-wrap; word-break: break-all; }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .side { width: 62px; flex: 0 0 62px; }
  .brand-text, .nav-item:not(.active)::after, .line-box, .ver { display: none; }
  .nav-item { justify-content: center; }
}
