:root {
  --brand: #fb7299;
  --brand-hover: #e45a84;
  --brand-soft: rgba(251, 114, 153, 0.14);
  --accent: #00a1d6;
  --pink: var(--brand);
  --pink-dark: var(--brand-hover);
  --blue: var(--accent);

  --bg: #0b0f14;
  --bg-elevated: #121822;
  --surface: #161d28;
  --surface-hover: #1c2432;
  --card: var(--surface);
  --border: #2a3344;
  --border-strong: #3a465a;
  --line: var(--border);

  --text: #e8edf4;
  --text-secondary: #9aa6b8;
  --text-tertiary: #6e7b8e;
  --muted: var(--text-secondary);

  --ok: #3dd68c;
  --ok-soft: rgba(61, 214, 140, 0.14);
  --warn: #f5b942;
  --err: #f07178;
  --err-soft: rgba(240, 113, 120, 0.14);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);

  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-20: 20px;

  --sidebar-w: 220px;
  --topbar-h: 56px;
  --control-h: 36px;
  --z-sidebar: 40;
  --z-topbar: 30;
  --z-modal: 100;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

button, input, textarea, select {
  font: inherit;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 14px;
  cursor: pointer;
  font-size: var(--fs-14);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover { background: var(--brand-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 500;
}
button.ghost:hover { background: var(--surface-hover); }
button.danger { background: #d24c4c; border-color: #d24c4c; }
button.danger:hover { background: #bb3d3d; }
button.btn-text,
.more-menu button {
  height: auto;
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: 0;
  color: var(--text);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
button.btn-text:hover,
.more-menu button:hover { background: var(--surface-hover); }
button.danger-text,
.more-menu button.danger-text { color: var(--err); }
button.icon-btn {
  width: var(--control-h);
  padding: 0;
  font-size: 18px;
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  min-height: var(--control-h);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); }
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.sidebar a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.err { color: var(--err); min-height: 1.2em; font-size: var(--fs-13); }
.ok { color: var(--ok); min-height: 1.2em; font-size: var(--fs-13); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* user */
.user-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  overflow-x: hidden;
}
.bg-blob {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.14;
  z-index: 0;
  pointer-events: none;
}
.blob-a { background: var(--brand); top: -80px; left: -80px; }
.blob-b { background: var(--accent); bottom: -80px; right: -80px; }
.user-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: rgba(22, 29, 40, 0.94);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: var(--space-4); }
.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  flex-shrink: 0;
}
.user-card h1 { margin: 0; font-size: var(--fs-20); font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--text-secondary); font-size: var(--fs-13); }
.sub:empty { display: none; }
.state { color: var(--text-secondary); }
.status-block {
  text-align: center;
  padding: 12px 8px 4px;
}
.status-title { margin: 0 0 6px; font-size: var(--fs-16); font-weight: 600; color: var(--text); }
.status-desc { margin: 0; color: var(--text-secondary); font-size: var(--fs-13); }
.status-err .status-title { color: var(--err); }
.phone-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  margin: 8px 0 16px;
}
.phone-box small { color: var(--text-secondary); font-size: var(--fs-12); }
.phone-box strong {
  display: block;
  font-size: 28px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 10px;
}
.remain { color: var(--text-secondary); font-size: var(--fs-13); margin: 0 0 12px; }
.hint-box,
.content-box {
  margin-top: 16px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: var(--text-secondary);
  font-size: var(--fs-13);
  text-align: center;
}
.content-box {
  border-style: solid;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  min-height: 72px;
  text-align: left;
}
.content-box.empty { color: var(--text-secondary); }
.code-panel {
  margin-top: 16px;
  background: var(--ok-soft);
  border: 1px solid rgba(61, 214, 140, 0.35);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
}
.code-panel small { color: var(--text-secondary); }
.code-panel strong {
  display: block;
  font-size: 36px;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 14px;
  color: var(--ok);
}
.sms-raw {
  margin: 12px 0 0;
  color: var(--text-tertiary);
  font-size: var(--fs-12);
  line-height: 1.5;
  word-break: break-all;
}
.msg-ok { color: var(--ok); }
.msg-err { color: var(--err); }
.alert {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-13);
}
.alert-warn {
  background: rgba(245, 185, 66, 0.12);
  color: var(--warn);
}
.full { width: 100%; margin-top: 8px; }
.copy-row { display: flex; gap: 8px; justify-content: center; }

.cred-box {
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.28);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin: 0 0 16px;
}
.cred-tip {
  margin: 0 0 10px;
  color: var(--warn);
  font-size: var(--fs-13);
  line-height: 1.6;
  text-align: left;
}
.cred-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.cred-row small {
  color: var(--text-secondary);
  width: 36px;
  flex-shrink: 0;
  font-size: var(--fs-12);
}
.cred-row strong {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-16);
  word-break: break-all;
  text-align: left;
}
.cred-row button {
  height: 32px;
  padding: 0 10px;
  font-size: var(--fs-13);
}

.guide {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
}
.guide summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  color: var(--text);
  font-size: var(--fs-14);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after {
  content: "▾";
  color: var(--text-secondary);
  font-weight: 400;
  transition: transform 0.15s ease;
}
.guide[open] summary::after { transform: rotate(-180deg); }
.guide ol {
  margin: 0;
  padding: 0 16px 14px 34px;
  color: var(--text-secondary);
  font-size: var(--fs-13);
  line-height: 1.7;
}
.guide li { margin: 0 0 6px; }
.guide li strong { color: var(--text); font-weight: 600; }

/* admin */
.admin-body { background: var(--bg); }
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #101722;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
}
.sidebar-brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
}
.sidebar-brand strong { display: block; font-size: var(--fs-14); }
.sidebar-brand small { color: var(--text-tertiary); font-size: 11px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-14);
  position: relative;
}
.sidebar a:hover { background: var(--surface-hover); color: var(--text); }
.sidebar a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.sidebar a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--brand);
}
.sidebar-mask { display: none; }
.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: var(--fs-13);
}
.pager button {
  height: 32px;
  padding: 0 10px;
  font-size: var(--fs-13);
  min-width: 32px;
  font-weight: 500;
}
.pager button:disabled:not(.ghost) { opacity: 1; cursor: default; }
.pager-ellipsis { color: var(--text-tertiary); padding: 0 4px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(600px 280px at 20% 0%, rgba(251, 114, 153, 0.08), transparent 60%),
    radial-gradient(500px 240px at 90% 100%, rgba(0, 161, 214, 0.08), transparent 60%),
    var(--bg);
}
.login-card, .dialog-form {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.login-card h1, .dialog-form h3 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-18);
}
.login-card .sub { margin: 0 0 16px; }
.login-card label, .dialog-form label {
  display: block;
  margin: 12px 0;
  color: var(--text-secondary);
  font-size: var(--fs-13);
}
.login-card label > input,
.dialog-form label > input,
.dialog-form label > textarea,
.dialog-form label > select {
  margin-top: 6px;
}
.login-card button { width: 100%; margin-top: 8px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--topbar-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: #141b27;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left strong { font-size: var(--fs-16); }
.crumb {
  margin: 2px 0 0;
  color: var(--text-tertiary);
  font-size: var(--fs-12);
}
.topbar-right { display: flex; gap: 12px; align-items: center; color: var(--text-secondary); }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: var(--fs-13);
}
.user-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
}
.btn-menu { display: none; }

.panel {
  padding: 20px 24px 24px;
  flex: 1;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--fs-13);
}
.settings-card {
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.settings-head strong {
  display: block;
  font-size: var(--fs-16);
}
.settings-head .toolbar-hint {
  margin-top: 4px;
}
.settings-field {
  display: block;
  margin: 0;
  padding: 18px 20px 8px;
  color: var(--text-secondary);
  font-size: var(--fs-13);
}
.settings-field span {
  margin-left: 8px;
  color: var(--text-tertiary);
}
.settings-field textarea {
  margin-top: 8px;
  min-height: 180px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  line-height: 1.7;
}
.settings-card .err,
.settings-card .ok {
  margin: 0 20px 8px;
  min-height: 0;
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  flex-shrink: 0;
  font-size: var(--fs-13);
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  min-height: 0;
  pointer-events: none;
}
.switch-ui {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #2a3344;
  position: relative;
  transition: background 0.15s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: var(--fs-18); }

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - var(--topbar-h) - 140px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
table { width: max-content; min-width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-13);
  vertical-align: middle;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  font-weight: 600;
  font-size: var(--fs-12);
  letter-spacing: 0.02em;
}
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: -8px 0 12px -8px rgba(0, 0, 0, 0.45);
}
thead th:last-child {
  z-index: 3;
  background: var(--bg-elevated);
}
tbody tr:hover td:last-child { background: var(--surface-hover); }

.cell-id,
.link-cell code,
.content-cell {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.link-cell code { color: #9cd1ff; max-width: 220px; }
.content-cell { max-width: 240px; color: var(--text-secondary); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag-on { background: var(--ok-soft); color: var(--ok); }
.tag-off { background: var(--err-soft); color: var(--err); }
.tag-vip { background: var(--brand-soft); color: var(--brand); }

.ops { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
.ops > button { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-sm); }
.more { position: relative; }
.more-toggle { height: 28px; padding: 0 10px; font-size: 12px; }
.more-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 132px;
  padding: 6px;
  background: #1a2330;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 120;
}
.more.open .more-menu { display: block; }

.empty {
  padding: 40px 16px;
  text-align: center;
  white-space: normal;
}
.empty p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}
.empty-row td,
.skeleton-row td,
.empty-row td:last-child,
.skeleton-row td:last-child {
  position: static;
  box-shadow: none;
  background: var(--surface);
}
.skel {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #1a2330 25%, #243044 50%, #1a2330 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
  min-width: 64px;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

dialog { border: 0; background: transparent; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-form {
  width: min(520px, 92vw);
  color: var(--text);
  max-height: 88vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.dialog-form h3 {
  margin: 0 -24px 16px;
  padding: 0 24px 14px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-16);
  font-weight: 600;
}
.dialog-form p { color: var(--text-secondary); }
.dialog-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px -24px -24px;
  padding: 12px 24px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.confirm-dialog { width: min(440px, 92vw); }
.confirm-message {
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 12px 0 4px;
  color: var(--text);
}
.check { display: flex; align-items: center; gap: 8px; color: var(--text) !important; }
.check input { width: auto; min-height: auto; }
.raw-box {
  background: var(--bg-elevated);
  color: #e8eef5;
  padding: 12px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: var(--fs-12);
  max-height: 240px;
  overflow: auto;
}
.phone-mini { font-weight: 700; }
.phone-fields {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}
.phone-code {
  color: var(--text-secondary);
  font-size: var(--fs-13);
  margin-right: 6px;
  font-weight: 500;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  background: var(--bg-elevated);
  display: inline-block;
}
.avatar-empty {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 36px;
  text-align: center;
}
.cookie-cell code {
  max-width: 180px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .admin-body.nav-open .sidebar { transform: none; }
  .admin-body.nav-open .sidebar-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: calc(var(--z-sidebar) - 1);
  }
  .btn-menu { display: inline-flex; }
  .topbar, .panel { padding-left: 16px; padding-right: 16px; }
  .table-wrap { max-height: calc(100vh - var(--topbar-h) - 168px); }
  .phone-fields { grid-template-columns: 1fr; }
  .settings-head { flex-wrap: wrap; }
}
