:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --green: #059669;
  --amber: #b45309;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.05);
  --sidebar: 220px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }

[hidden] { display: none !important; }

.mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.mark.sm { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }

.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.gate-card {
  width: min(400px, 100%); text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 36px 28px; box-shadow: var(--shadow);
}
.gate-card h1 { margin: 14px 0 8px; font-size: 22px; }
.gate-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.gate-link { display: inline-block; margin-top: 14px; color: var(--muted); font-size: 13px; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 20px 12px;
}

.sidebar-brand {
  display: flex; gap: 10px; align-items: center;
  padding: 4px 8px 20px; border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.sidebar-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-user { font-size: 14px; font-weight: 600; margin-top: 2px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: block; padding: 10px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 14px;
  border: none; background: none; text-align: left; width: 100%;
}
.nav-item:hover { background: #f9fafb; color: var(--ink); }
.nav-item.active { background: #f3f4f6; color: var(--ink); font-weight: 600; }
.btn-nav { cursor: pointer; }

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }

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

.topbar {
  height: 60px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; }

.main { padding: 24px 28px 40px; flex: 1; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafafa; }
tr:last-child td { border-bottom: 0; }
code { font-size: 12px; background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.tag.ok { background: #ecfdf5; color: var(--green); }
.tag.warn { background: #fffbeb; color: var(--amber); }
.tag.muted { background: #f3f4f6; color: var(--muted); }

.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 13px;
}
.btn:hover { background: #fafafa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #374151; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
fieldset.field {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  border: none;
}
fieldset.field legend {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 0;
}
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; width: 100%;
}
.field textarea { min-height: 72px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: -4px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.4);
  display: none; place-items: center; z-index: 100; padding: 20px;
  pointer-events: none; visibility: hidden;
}
.modal-backdrop.is-open {
  display: grid;
  pointer-events: auto;
  visibility: visible;
}
.modal {
  width: min(480px, 100%); background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.modal-wide { width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 10px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity 0.2s; z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; pointer-events: auto; }

.secret-note {
  margin-top: 12px; padding: 12px; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 8px; font-size: 12px; word-break: break-all;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.row-actions { white-space: nowrap; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.toolbar-label { font-size: 13px; color: var(--muted); }
.toolbar-select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 200px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 650; }

.page-note {
  padding: 12px 14px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.55;
}
.cell-muted { color: var(--muted); }
.wizard-steps-text { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.row-actions .btn + .btn { margin-left: 6px; }
.kit-steps { display: grid; gap: 10px; margin-bottom: 16px; }
.kit-step { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.kit-step-n { width: 22px; height: 22px; border-radius: 999px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.kit-step p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.kit-block { margin-bottom: 12px; }
.kit-summary { padding: 12px 14px; background: #f0f7ff; border: 1px solid #c7ddf7; border-radius: 8px; }
.kit-summary .kit-steps { margin: 8px 0 8px 18px; padding: 0; font-size: 13px; line-height: 1.6; }
.kit-cred-row { display: grid; grid-template-columns: 72px 1fr; gap: 8px; align-items: start; margin-bottom: 8px; }
.kit-cred-label { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 10px; }
.kit-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.kit-code { display: block; padding: 10px 12px; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; word-break: break-all; }
.kit-pre { margin: 0; padding: 12px; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; line-height: 1.5; max-height: 420px; overflow: auto; white-space: pre-wrap; }
.kit-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.perm-grid { display: grid; gap: 8px; }
.perm-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; cursor: pointer; }
.perm-item small { grid-column: 2; color: var(--muted); font-size: 11px; }
.wizard-steps { margin-bottom: 16px; }
.wizard-step {
  display: inline-block; padding: 0;
  background: none; color: var(--muted); font-size: 13px; font-weight: 500;
}
.wizard-warn {
  margin: 0 0 14px; padding: 12px 14px; background: #f9fafb;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.55; color: var(--muted);
}
.home-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.home-link-card {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.home-link-card:hover { border-color: #c7ddf7; background: #f8fbff; }
.home-link-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.home-link-card span { font-size: 12px; color: var(--muted); }

.wallet-list { display: grid; gap: 16px; }
.wallet-card { padding: 16px; }
.wallet-head h3 { margin: 0 0 4px; font-size: 16px; }
.wallet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 14px 0; }
.wallet-grid .label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.wallet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ledger-table { width: 100%; margin-top: 12px; font-size: 12px; }
.ledger-wrap { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
.gate-btn { display: inline-block; text-decoration: none; margin-bottom: 8px; }
