:root {
  --bg: #0e1016;
  --panel: #161a24;
  --panel-2: #1d2230;
  --border: #262c3b;
  --text: #e7eaf3;
  --muted: #8d96ac;
  --accent: #5b6cff;
  --accent-2: #7c8bff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 登录 ---------- */
.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2140 0%, var(--bg) 60%);
}
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.login-logo { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.login-sub { color: var(--muted); font-size: 12px; margin-bottom: 22px; }
.login-err { color: var(--err); font-size: 12px; min-height: 18px; margin-top: 10px; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100%; }
.sidebar {
  width: 212px;
  flex: 0 0 212px;
  background: #11141d;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.brand { font-weight: 700; font-size: 16px; padding: 0 8px 16px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(91,108,255,.22), rgba(91,108,255,.06)); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px;
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 20, 29, .7);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.content { padding: 20px 22px 40px; overflow: auto; }

/* ---------- 通用组件 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel.sub { background: var(--panel-2); margin-bottom: 14px; }
.panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-body { padding: 14px 16px; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #39415a; background: #232a3b; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb4b4; border-color: #4a2a2f; }
.btn.danger:hover { background: #3a1e22; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input {
  background: #12151e;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.field { display: block; margin-bottom: 12px; flex: 1; min-width: 160px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field > em { display: block; font-style: normal; margin-top: 4px; }
.field.inline { max-width: 260px; }
.field.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); max-width: none; }
.field.check > input { width: auto; }
.field.check > span { margin: 0; color: var(--text); font-size: 13px; }

.proxy-settings-panel { margin-bottom: 16px; }
.proxy-summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, .5fr) minmax(180px, .8fr) auto;
  gap: 18px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.proxy-summary strong { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.proxy-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.proxy-config-row { margin-top: 14px; }
.proxy-config-row .field { margin-bottom: 0; }
.proxy-result { min-height: 20px; margin-top: 8px; }
.err-text { color: var(--err); }
@media (max-width: 720px) {
  .proxy-summary { grid-template-columns: 1fr 1fr; }
  .proxy-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; min-width: 150px; }
.toolbar #acc-q { flex: 1; min-width: 200px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.card .v.ok { color: var(--ok); }
.card .v.warn { color: var(--warn); }
.card .v.err { color: var(--err); }

.group-list { padding: 8px 16px 14px; }
.group-item { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.group-item:last-child { border-bottom: none; }
.mini-logs { padding: 6px 16px 14px; font-size: 12.5px; }
.mini-log { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.mini-log:last-child { border-bottom: none; }
.mini-log .t { color: var(--muted); flex: 0 0 122px; }

/* ---------- 表格 ---------- */
.table-panel { overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 500; background: #12151e; position: sticky; top: 0; z-index: 1; }
.table tbody tr:hover { background: #191d29; }
.table td.wrap { white-space: normal; max-width: 320px; word-break: break-all; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); }
.pager-btns { display: flex; align-items: center; gap: 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; border: 1px solid transparent; }
.badge.ok { background: rgba(34,197,94,.14); color: var(--ok); border-color: rgba(34,197,94,.3); }
.badge.err { background: rgba(239,68,68,.14); color: var(--err); border-color: rgba(239,68,68,.3); }
.badge.warn { background: rgba(245,158,11,.14); color: var(--warn); border-color: rgba(245,158,11,.3); }
.badge.info { background: rgba(91,108,255,.14); color: var(--accent-2); border-color: rgba(91,108,255,.3); }
.badge.gray { background: #232838; color: var(--muted); border-color: var(--border); }

.act { display: flex; gap: 6px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(5, 7, 12, .72); backdrop-filter: blur(2px); }
.modal-box {
  position: relative;
  width: 720px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 70px rgba(0,0,0,.6);
}
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 420px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }

.imp-result { font-size: 12.5px; }
.imp-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #12151e; }
.imp-item .h { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.imp-item code { color: var(--accent-2); word-break: break-all; }

pre.code {
  background: #0b0d13;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  font-size: 12.5px;
  margin: 0 0 12px;
  white-space: pre;
}
.kv { display: flex; gap: 8px; padding: 5px 0; font-size: 13px; }
.kv b { color: var(--muted); font-weight: 500; min-width: 110px; }
