:root {
  --bg: #f0f2f5;
  --card: #fff;
  --line: #e8eaed;
  --text: #1f2329;
  --muted: #8a919e;
  --primary: #2563eb;
  --primary-soft: #eef2ff;
  --primary-hover: #1d4ed8;
  --danger: #e5484d;
  --ok: #16a34a;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ============================================================ 登录/注册 */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 8%);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.auth-brand img { width: 42px; height: 42px; border-radius: 10px; }
.auth-brand h1 { font-size: 22px; font-weight: 700; letter-spacing: .3px; }
.auth-brand .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.auth-card label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.auth-card input {
  display: block; width: 100%; margin-top: 6px;
  padding: 11px 13px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fafbfc; color: var(--text); font-family: inherit;
}
.auth-card input:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
  background: #fff;
}
.code-row { display: block; }
.code-input { display: flex; gap: 8px; margin-top: 6px; }
.code-input input { margin-top: 0; flex: 1; }
.code-input .btn { flex-shrink: 0; }

.auth-links {
  display: flex; justify-content: space-between;
  margin-top: 14px; font-size: 13px;
}
.link {
  background: none; border: none; padding: 0;
  color: var(--primary); cursor: pointer; font-family: inherit; font-size: 13px;
}
.link:hover { text-decoration: underline; }

/* ============================================================ 按钮 */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  transition: .15s;
  font-family: inherit;
  white-space: nowrap;
  font-weight: 500;
}
.btn:hover:not(:disabled) { filter: brightness(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: #fff; border-color: var(--line); color: #4b5563; }
.btn.ghost:hover:not(:disabled) { border-color: #c4cdd9; }
.btn.sm { padding: 6px 13px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.danger { color: var(--danger); border-color: #f5c2c4; background: #fff5f5; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }

/* ============================================================ 顶栏 */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.brand .arrow { color: var(--muted); font-weight: 400; }
.brand .cur { color: var(--primary); }

.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs .tab {
  background: none; border: none; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  font-size: 14px; color: #4b5563; font-weight: 500;
}
.tabs .tab:hover { background: #f4f5f7; }
.tabs .tab.active { background: var(--primary-soft); color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }

/* ============================================================ 布局 */
.wrap { max-width: 1600px; margin: 0 auto; padding: 20px 24px 60px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgb(0 0 0 / 5%);
  margin-bottom: 16px;
  overflow: hidden;
}
.card.pad { padding: 22px 24px; }
.pane-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.pane-title + .hint { margin-bottom: 16px; }

.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; flex-wrap: wrap;
}
.spacer { flex: 1; }
.search-box { display: flex; gap: 8px; align-items: center; }
.search-box input {
  width: 300px; padding: 9px 13px;
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; font-family: inherit; background: #fafbfc;
}
.search-box input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #4b5563; cursor: pointer; }
.chk input { width: auto; margin: 0; }

/* ============================================================ 表格 */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 14px 16px;
  color: var(--muted); font-weight: 600; font-size: 13px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fbfcfd;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.expired { color: var(--danger); }
.center { text-align: center; }

/* 卡片预览 */
.card-preview {
  display: flex; gap: 10px; align-items: center;
  background: #f2f3f5; border-radius: 10px; padding: 8px 10px;
  min-width: 210px; max-width: 280px;
}
.card-preview img {
  width: 54px; height: 54px; border-radius: 8px; object-fit: cover;
  background: #e3e5e8; flex-shrink: 0;
}
.card-preview .cp-text { min-width: 0; flex: 1; }
.card-preview .cp-title {
  font-size: 13px; font-weight: 600; color: #1f2329;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-preview .cp-desc {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.plat { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.plat img { width: 20px; height: 20px; border-radius: 5px; object-fit: contain; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--primary); cursor: pointer; font-size: 13.5px; font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.empty { padding: 64px 20px; text-align: center; color: var(--muted); }

/* 徽章 */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.badge.admin { background: #fef3c7; color: #b45309; }
.badge.user { background: #eef2ff; color: #4338ca; }
.badge.on { background: #dcfce7; color: #15803d; }
.badge.off { background: #fee2e2; color: #b91c1c; }

/* ============================================================ 分页 */
.pager { display: flex; gap: 6px; padding: 16px 20px; flex-wrap: wrap; align-items: center; }
.pager button {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--card);
  border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ============================================================ 弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgb(15 20 30 / 45%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal-box {
  background: var(--card); border-radius: 14px;
  width: 100%; max-width: 900px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 22%);
}
.modal-box.narrow { max-width: 470px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--card);
  border-radius: 14px 14px 0 0; z-index: 1;
}
.modal-head h2 { font-size: 17px; font-weight: 600; }
.x {
  border: none; background: none; font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 0 4px;
}
.modal-body { padding: 20px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ============================================================ 表单 */
fieldset {
  border: 1px solid var(--line); border-radius: 11px;
  padding: 16px 18px 8px; margin-bottom: 16px;
}
legend { padding: 0 8px; font-weight: 600; font-size: 14px; color: #374151; }
.row { display: flex; gap: 18px; align-items: flex-start; }
.cover {
  width: 100px; height: 100px; flex-shrink: 0;
  border: 1px dashed #cfd4dc; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #b9c0ca; font-size: 30px; background: #fafbfc;
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.fields { flex: 1; min-width: 0; }
label { display: block; margin-bottom: 13px; font-size: 13px; color: var(--muted); }
input:not([type=hidden]):not([type=checkbox]), select, textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fafbfc; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-soft); border-color: var(--primary); background: #fff;
}
textarea { resize: vertical; }

/* ============================================================ chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 16px; min-width: 92px;
  border: 1px solid var(--line); border-radius: 11px;
  background: #fafbfc; cursor: pointer; font-size: 13px;
  transition: .15s; color: #4b5563;
}
.chip:hover { border-color: #c4cdd9; background: #fff; }
.chip.on {
  border-color: var(--primary); background: var(--primary-soft);
  color: var(--primary); font-weight: 600;
}
.chip img { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; }

.target-fields { margin-top: 16px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.75; }

/* ============================================================ 分享 */
.tabs.line { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs.line .tab {
  flex: 1; padding: 9px; border: 1px solid var(--line);
  background: var(--card); border-radius: 9px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; color: #4b5563;
}
.tabs.line .tab.active {
  background: var(--primary-soft); border-color: var(--primary);
  color: var(--primary); font-weight: 600;
}
.qr-box {
  display: flex; align-items: center; justify-content: center;
  min-height: 210px; padding: 16px;
  background: #fafbfc; border-radius: 11px; margin-bottom: 12px;
}
.qr-box img { width: 190px; height: 190px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; }

/* ============================================================ Token / 代码 */
.token-row { display: flex; gap: 8px; }
.token-row input {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
}
.code {
  background: #1e2430; color: #d7dde8;
  padding: 14px 16px; border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.75;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ============================================================ Cookie */
.cookie-list { margin-bottom: 16px; }
.cookie-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; margin-bottom: 8px; font-size: 13px;
}
.cookie-item .name { font-weight: 600; min-width: 90px; }
.cookie-item .val { color: var(--muted); font-family: ui-monospace, monospace; flex: 1; }

/* ============================================================ 统计 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: #fafbfc; border: 1px solid var(--line);
  border-radius: 11px; padding: 16px 18px;
}
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ============================================================ 提示 */
.msg { font-size: 13px; margin-top: 10px; min-height: 20px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgb(30 35 45 / 94%); color: #fff;
  padding: 11px 24px; border-radius: 10px; font-size: 14px;
  z-index: 100; box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
  max-width: 90vw; text-align: center;
}

/* ============================================================ 响应式 */
@media (max-width: 820px) {
  .topbar { padding: 10px 14px; gap: 12px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  .tabs .tab { white-space: nowrap; }
  .wrap { padding: 14px 12px 40px; }
  .search-box { width: 100%; }
  .search-box input { width: 100%; }
  .row { flex-direction: column; }
  .cover { width: 100%; height: 130px; }
  .modal { padding: 12px 8px; }
  .modal-box { max-width: 100%; }
  .auth-card { padding: 28px 22px 20px; }
}
