:root {
  --bg: #071018;
  --bg-elev: #0c1822;
  --bg-card: #10202c;
  --bg-soft: #173042;
  --line: rgba(56, 189, 188, 0.16);
  --line-strong: rgba(94, 234, 212, 0.42);
  --ink: #e7f4f6;
  --muted: #7f96a8;
  --gold: #2dd4bf;
  --gold-bright: #5eead4;
  --gold-soft: rgba(45, 212, 191, 0.12);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.14);
  --err: #fb7185;
  --err-bg: rgba(251, 113, 133, 0.12);
  --warn: #fbbf24;
  --miss: #64748b;
  --miss-bg: rgba(100, 116, 139, 0.18);
  --on-accent: #042f2e;
  --radius: 14px;
  --rail: 248px;
  --font: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "Consolas", "SF Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(45, 212, 191, 0.16), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(14, 116, 144, 0.18), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: #99f6e4; }
code, .mono { font-family: var(--mono); font-size: 12px; }
code { background: var(--gold-soft); color: var(--gold-bright); padding: 1px 6px; border-radius: 4px; }
h1 { font-size: 22px; margin: 0 0 6px; font-family: var(--display); font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
.err { color: var(--err); }
.okline { color: var(--ok); font-size: 13px; margin: 8px 0 0; }
.warnline { color: var(--warn); font-size: 13px; margin: 8px 0 0; }

pre.log {
  font-size: 11px;
  line-height: 1.45;
  background: #061018;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 8px;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--line);
}
pre.log.mini { max-height: 240px; margin: 0; padding: 8px 10px; }
.lease-box { margin: 10px 0 12px; display: flex; flex-direction: column; gap: 10px; }
.lease-row { font-size: 12px; line-height: 1.6; }
.lease-row code { font-size: 11px; }
.inline-cmd { display: inline; margin: 4px 6px 0 0; }
.inline-cmd button { margin-top: 4px; }
.cmd-form .row { margin-top: 10px; flex-wrap: wrap; }
[hidden] { display: none !important; }
.read-form { margin: 12px 0 10px; max-width: 520px; }
.read-form .row { margin-top: 10px; gap: 12px; }
.cmd-feed {
  max-height: 168px;
  overflow: auto;
  margin: 10px 0 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
}
.cmd-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.cmd-item:last-child { border-bottom: 0; }
.cmd-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.cmd-lab { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}
.admin-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  background: linear-gradient(180deg, #0d1c28 0%, #071018 100%);
  border-right: 1px solid var(--line);
  overflow: auto;
}
.admin-rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}
.admin-rail-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.22);
}
.admin-rail-brand-text strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.08em;
  font-weight: 800;
}
.admin-rail-brand-text span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.admin-sidebar { display: flex; flex-direction: column; flex: 1; gap: 6px; }
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--ink);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.admin-nav-item:hover { background: var(--gold-soft); color: var(--ink); }
.admin-nav-item.is-active {
  background: var(--gold-soft);
  border-color: var(--line-strong);
}
.nav-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nav-title { font-size: 14px; font-weight: 600; }
.nav-en {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}
.admin-rail-foot { margin-top: auto; padding-top: 12px; }
.admin-user-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.admin-user-role {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-transform: uppercase;
}
.admin-user-chip strong { font-size: 14px; font-weight: 700; }
.admin-main { min-width: 0; padding: 0 0 48px; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 8px;
}
.admin-topbar-title h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
}
.admin-topbar-meta {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.admin-main-inner { padding: 8px 28px 0; max-width: 1100px; }

.devices-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.devices-stats .stat-num { color: var(--ink); font-weight: 700; letter-spacing: 0; }
.stat-active { color: var(--ok); }

.device-grid { display: flex; flex-direction: column; gap: 12px; }
.device-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.device-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}
.device-card-main {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 8px 16px 18px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  flex: 1;
}
.device-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
}
.device-body h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  word-break: break-all;
}
.meta { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.arrow { color: var(--gold); font-size: 13px; font-weight: 600; white-space: nowrap; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-bright);
  background: var(--gold-soft);
  border: 1px solid var(--line);
}
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tag.miss { background: var(--miss-bg); color: var(--miss); border-color: transparent; }
.tag.lock { background: var(--gold-soft); color: var(--gold-bright); }
.tag.virt { background: #3a2a18; color: #f0c27a; }
.tag.kc, .tag.keychain { background: #2a1a3a; color: #c4a0e8; }
.tag.file { border-color: rgba(111, 191, 138, 0.35); }
.tag.notes { background: #1a2a3a; color: #8ec8e8; }
.pill {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid var(--line);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  margin: 12px 0;
  border: 1px solid var(--line);
}
.admin-main-inner .card { margin: 12px 0; max-width: none; }
.admin-main > .card { margin: 12px 28px; max-width: 1100px; }
.card.narrow, .login-card {
  max-width: 420px;
  margin: 16vh auto;
  padding: 28px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { font-size: 11px; color: var(--muted); font-weight: 600; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.compact th, table.compact td { padding: 7px 8px; white-space: nowrap; }
table.compact td.clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
table.compact tr.on { background: var(--gold-soft); }
td.path {
  font-family: var(--mono);
  font-size: 11px;
  word-break: break-all;
  white-space: normal;
}
.ops { display: flex; gap: 10px; align-items: center; }
form.inline { display: inline; margin: 0; }

label { display: block; font-size: 13px; margin: 10px 0; color: var(--muted); }
input, textarea, select {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: var(--bg-elev);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--gold-soft);
  border-color: var(--gold);
}
input[readonly] { opacity: 0.7; }

button, .btn {
  appearance: none;
  display: inline-block;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: var(--on-accent);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button.ghost, .btn.ghost {
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
}
button.danger, .link.danger { background: transparent; color: var(--err); padding: 0; border: 0; cursor: pointer; font: inherit; }
.link { background: none; color: var(--gold-bright); text-decoration: none; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.editor { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.device-search { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.device-search input { min-width: 220px; }

.top, .nav, .brand { display: none; }

.wallet-section { margin: 18px 0 8px; }
.wallet-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  margin: 0 0 14px;
}
.wallet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
}
.normal-tag, .real-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.normal-tag { color: var(--muted); background: var(--bg-soft); }
.real-tag { color: var(--ok); background: var(--ok-bg); }
.section-title { font-size: 16px; margin: 4px 0 8px; }
.wallet-note { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.addrs, .chain-addrs {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-all;
}
.addr-box {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}
.explorer-link { margin-left: 6px; font-size: 12px; white-space: nowrap; }
.btn-bal-refresh {
  appearance: none;
  display: inline-block;
  margin-left: 8px;
  border: 1px solid var(--gold-bright);
  background: var(--gold-bright);
  color: var(--on-accent);
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.5;
}
.btn-bal-refresh:hover { background: #99f6e4; border-color: #99f6e4; color: var(--on-accent); }
.pwd {
  flex: 1 1 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: inherit;
}
.mnemonic, .plain {
  margin-top: 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.decrypt-btn { white-space: nowrap; }

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-rail {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px;
  }
  .admin-sidebar { flex-direction: row; flex-wrap: wrap; }
  .admin-rail-foot { margin-top: 0; width: 100%; }
  .admin-main .card, .admin-main-inner, .admin-topbar { margin-left: 12px; margin-right: 12px; padding-left: 12px; padding-right: 12px; }
  .grid { grid-template-columns: 1fr; }
  .device-card { flex-direction: column; align-items: stretch; }
  .device-card-main { grid-template-columns: 44px minmax(0, 1fr); padding: 14px 14px 8px; }
  .arrow { display: none; }
  .note-open { margin: 0 14px 14px; align-self: flex-end; }
}

.note-line {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--gold-bright);
  font-weight: 600;
}
.note-line.empty { color: var(--muted); font-weight: 400; }
.note-open {
  flex: 0 0 auto;
  margin: 0 14px 0 0;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.note-open:hover { background: var(--gold-soft); color: var(--gold-bright); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(4, 16, 24, 0.72);
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.modal-card h2 { margin: 0 0 6px; }
.modal-card textarea { min-height: 84px; resize: vertical; }

.status-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.switch-form { display: inline-flex; margin: 0; }
.switch {
  appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  background: var(--miss);
  border: 0;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: none;
  filter: none;
}
.switch:hover { filter: none; }
.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.switch.is-on { background: var(--ok); }
.switch.is-on .switch-knob { transform: translateX(18px); }
.switch.is-locked, .switch:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}
