:root {
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --main-bg: #f1f5f9;
  --card-bg: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --blue: #3b82f6;
  --green: #22c55e;
  --orange: #f59e0b;
  --purple: #a855f7;
  --red: #ef4444;
  --cyan: #06b6d4;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--main-bg);
  color: var(--text);
  font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-brand h1 { margin: 0; font-size: 16px; color: #f8fafc; }
.sidebar-brand small { color: #64748b; font-size: 12px; }
.nav-section { padding: 12px 10px 4px; font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 8px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
}
.nav a:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid #1e293b;
  font-size: 12px;
}
.sidebar-footer .user { color: #f1f5f9; margin-bottom: 4px; }
.sidebar-footer .code { color: #64748b; margin-bottom: 12px; }
.sidebar-footer .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.sidebar-footer .btns a, .sidebar-footer .btns button {
  flex: 1;
  min-width: 80px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.breadcrumb { color: var(--muted); font-size: 13px; }
.breadcrumb strong { color: var(--text); }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.content { padding: 20px 24px 40px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 700; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  background: var(--card-bg);
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.toolbar input, .toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.toolbar .grow { flex: 1; min-width: 200px; }

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-ghost { background: #f8fafc; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.table-wrap {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow-x: auto;
}
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  padding: 12px 14px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin: 2px 2px 2px 0;
}
.tag-blue { background: #dbeafe; color: #1d4ed8; }
.tag-gray { background: #f1f5f9; color: #475569; }
.tag-green { background: #dcfce7; color: #15803d; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-channel { background: #2563eb; color: #fff; font-weight: 600; }

.count-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.count-badge {
  width: 44px;
  text-align: center;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 11px;
  color: #fff;
  line-height: 1.2;
}
.count-badge span { display: block; font-size: 14px; font-weight: 700; }
.cb-events { background: #3b82f6; }
.cb-apps { background: #f59e0b; }
.cb-mnemonic { background: #22c55e; }
.cb-memos { background: #a855f7; }
.cb-photos { background: #ef4444; }
.cb-wallet { background: #06b6d4; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs a {
  padding: 10px 18px;
  border-radius: 8px 8px 0 0;
  background: #e2e8f0;
  color: var(--muted);
  text-decoration: none;
}
.tabs a.active { background: var(--card-bg); color: var(--blue); font-weight: 600; border: 1px solid var(--border); border-bottom-color: var(--card-bg); margin-bottom: -1px; }

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 560px;
}
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="password"],
.form-row input[type="datetime-local"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.form-row .inline { display: flex; gap: 12px; }
.form-row .inline > * { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(30, 27, 75, 0.85);
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 25px 50px rgba(0,0,0,.35);
  color: #e2e8f0;
}
.login-card h1 { margin: 12px 0 4px; text-align: center; font-size: 22px; color: #fff; }
.login-card .sub { text-align: center; color: #94a3b8; font-size: 13px; margin-bottom: 28px; }
.login-shield {
  width: 56px; height: 56px;
  margin: 0 auto;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.login-card .section-title { font-size: 14px; margin-bottom: 4px; }
.login-card .section-hint { font-size: 12px; color: #94a3b8; margin-bottom: 16px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #f8fafc;
}
.login-card button[type="submit"] {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-card .copy { text-align: center; font-size: 11px; color: #64748b; margin-top: 24px; }
.login-error { background: #7f1d1d; color: #fecaca; padding: 10px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* Config page (public) */
.config-page { max-width: 720px; margin: 0 auto; padding: 32px 20px; }
.config-page header { margin-bottom: 24px; }
.config-page header h1 { margin: 0 0 8px; }
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .config-grid { grid-template-columns: 1fr; } .sidebar { display: none; } }

.link-detail { color: var(--blue); text-decoration: none; }
.link-detail:hover { text-decoration: underline; }
.device-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ip-line { font-family: ui-monospace, monospace; font-size: 12px; }

.install-tags { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #334155; }
.install-tags span { display: block; }
.tag-success { font-weight: 600; }
.count-badge.cb-wallet-icon { background: linear-gradient(145deg, #fbbf24, #f59e0b); color: #78350f; min-width: 48px; }
.count-badge.cb-wallet-icon span { font-size: 16px; }

.wallet-hero { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.wallet-title { margin: 0 0 4px; font-size: 18px; }
.stat-warn { border-color: #fed7aa; background: #fffbeb; }
.wallet-usd { color: var(--green); }
.tag-wallet-app { background: #fef3c7; color: #b45309; font-weight: 600; }
.wallet-asset-table .row-highlight { background: #fffbeb; }
.usd-cell { color: var(--green); font-weight: 600; }
.btn-copy {
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--blue);
  background: #eff6ff;
  color: var(--blue);
  cursor: pointer;
}
.btn-copy-red { border-color: #f87171; background: #fef2f2; color: #dc2626; }

.edit-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.edit-table th, .edit-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.edit-table input[type="number"], .edit-table input[type="text"] {
  width: 100%; max-width: 120px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.edit-table input.wide { max-width: 100%; min-width: 140px; }

/* 淡金列表 */
.table-gold {
  background: linear-gradient(180deg, #fffdf7 0%, #fffbeb 100%);
  border: 1px solid #fde68a;
  box-shadow: 0 1px 3px rgba(180, 130, 20, .08);
}
.list-table-gold tbody tr.list-row-gold,
table.data tbody tr.list-row-gold {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}
.list-table-gold tbody tr.list-row-gold:nth-child(even),
table.data tbody tr.list-row-gold:nth-child(even) {
  background: #fef3c7;
}
.list-table-gold tbody tr:hover,
table.data tbody tr.list-row-gold:hover {
  background: #fde68a !important;
}

.cell-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cell-tags.col { flex-direction: column; align-items: flex-start; }
.tag-device-name { background: #f8fafc; border: 1px solid #e2e8f0; color: #0f172a; font-weight: 600; }
.tag-os { background: #e0f2fe; color: #0369a1; font-weight: 600; }
.tag-browser { background: #f1f5f9; color: #475569; }
.tag-ip { font-family: ui-monospace, monospace; background: #fff; border: 1px solid #e2e8f0; color: #334155; }
.tag-country { background: #ffedd5; color: #c2410c; font-weight: 600; }
.tag-channel-sub { background: #eff6ff; color: #1d4ed8; }
.tag-install { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; display: inline-block; margin-top: 4px; }
.tag-time { background: #fafafa; border: 1px solid #eee; color: #64748b; font-size: 11px; }
.tag-duration { background: #f1f5f9; color: #334155; font-weight: 600; }
.tag-mono { font-family: ui-monospace, monospace; font-size: 12px; background: #fff; border: 1px solid #fde68a; }
.tag-chain { background: #ede9fe; color: #5b21b6; }
.tag-token { background: #fff7ed; color: #9a3412; }
.tag-qty { background: #fff; border: 1px solid #e5e7eb; font-weight: 600; }
.mono-id { font-family: ui-monospace, monospace; font-size: 11px; color: #94a3b8; margin-top: 6px; }

.source-url-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-icon { font-size: 11px; opacity: .85; }

.status-pill { font-weight: 600; font-size: 12px; }
.status-online { background: #dcfce7; color: #15803d; }
.status-offline { background: #f1f5f9; color: #64748b; }
.status-success { background: #dcfce7; color: #15803d; }
.status-fail { background: #fee2e2; color: #b91c1c; }
.status-col { gap: 4px; }

.network-cell { min-width: 140px; }

/* 管理后台多页 */
.manage-body { background: var(--main-bg); }
.manage-shell { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.manage-header h1 { margin: 0 0 6px; font-size: 22px; }
.manage-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.manage-tabs a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none;
  font-size: 13px; color: var(--muted); background: #fff; border: 1px solid var(--border);
}
.manage-tabs a.active {
  background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 600;
}
.panel-wide { max-width: 100% !important; }
.textarea-full {
  width: 100%; min-height: 200px; padding: 12px; border: 1px solid var(--border);
  border-radius: 8px; font-family: ui-monospace, monospace; font-size: 13px;
}
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.danger-zone { margin-top: 20px; border-color: #fecaca; background: #fff5f5; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.toolbar.compact { padding: 10px 14px; align-items: center; }
.edit-table-gold tbody tr { background: #fffbeb; }
.edit-table-gold tbody tr:nth-child(even) { background: #fef3c7; }
.visitor-edit-table select, .visitor-edit-table input { max-width: 140px; font-size: 12px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }
.modal-dialog { max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; margin: 0; }
.check-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.check-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid #fde68a;
  background: #fffbeb; font-size: 13px; cursor: pointer;
}
.check-pill input { accent-color: #2563eb; }
.wallet-gen-panel { margin-bottom: 16px; }
