:root {
  --accent: #fe2c55;
  --accent-dark: #e0234a;
  --sidebar: #17181c;
  --sidebar-soft: #222329;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #646a73;
  --faint: #8f959e;
  --line: #e5e6eb;
  --line-soft: #f0f1f3;
  --green: #2ba471;
  --green-bg: #e8f7f0;
  --red: #f54a45;
  --red-bg: #fdeceb;
  --amber: #b76e00;
  --amber-bg: #fff4e0;
  --blue: #3370ff;
  --blue-bg: #eaf1ff;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(31, 35, 41, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

body.no-scroll {
  overflow: hidden;
}

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

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- login ---------- */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 12% 0%, #ffe9ee 0%, rgba(255, 233, 238, 0) 62%),
    radial-gradient(700px 420px at 92% 100%, #e8eefc 0%, rgba(232, 238, 252, 0) 60%),
    var(--bg);
}

.login-card {
  width: 380px;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(31, 35, 41, 0.1);
  padding: 34px 34px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ---------- shell ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar);
  color: #c9cdd4;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #aeb3bc;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav a::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  flex: 0 0 5px;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav a.active {
  background: var(--sidebar-soft);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav a.active::before {
  background: var(--accent);
  opacity: 1;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-name {
  color: #aeb3bc;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.view {
  padding: 24px 28px 48px;
  max-width: 1440px;
  width: 100%;
}

/* ---------- layout blocks ---------- */

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

.panel + .panel {
  margin-top: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.panel-sub {
  margin: 2px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.panel-body {
  padding: 18px 20px;
}

.panel-body.flush {
  padding: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar .grow {
  flex: 1;
}

.toolbar > input[type="search"] {
  width: auto;
  flex: 1 1 240px;
  max-width: 340px;
}

.toolbar > select {
  width: auto;
  flex: 0 0 auto;
}

.toolbar .field {
  flex: 1 1 240px;
  max-width: 360px;
}

.row > input {
  flex: 1 1 auto;
  min-width: 0;
}

.row > select {
  width: auto;
  flex: 0 0 auto;
  min-width: 120px;
}

.upload-row > input {
  flex: 1 1 180px;
  width: auto;
  min-width: 140px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-size: 13px;
  font-weight: 400;
  color: var(--faint);
}

.stat-meta {
  margin-top: 6px;
  color: var(--faint);
  font-size: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid #d0d3d9;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.btn:hover {
  border-color: #b9bec7;
  background: #fafbfc;
}

.btn:focus-visible {
  outline: 2px solid rgba(254, 44, 85, 0.32);
  outline-offset: 1px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-danger {
  color: var(--red);
  border-color: #f7c6c4;
  background: #fff;
}

.btn-danger:hover {
  background: var(--red-bg);
  border-color: #f2a9a6;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: #aeb3bc;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: transparent;
  color: #fff;
}

.btn-sm {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  height: 38px;
  font-size: 14px;
}

.btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--red);
}

/* ---------- forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
}

.field-full {
  grid-column: 1 / -1;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d0d3d9;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input::placeholder,
textarea::placeholder {
  color: #b3b8c2;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.12);
}

input[type="search"] {
  appearance: none;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238f959e' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.hint {
  color: var(--faint);
  font-size: 12px;
}

.form-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--red-bg);
  color: #c62f2b;
  font-size: 12px;
}

.form-note {
  margin: 0;
  padding: 9px 11px;
  border-radius: 6px;
  background: #f6f7f9;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

.quick-import {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8f9fb;
}

.quick-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.quick-title {
  font-size: 13px;
  font-weight: 500;
}

.quick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px dashed #c9cdd4;
  border-radius: 8px;
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.upload-box:hover,
.upload-box.dragging {
  border-color: var(--accent);
  background: #fff7f9;
}

.upload-box.busy {
  cursor: progress;
  opacity: 0.7;
}

.upload-preview {
  width: 88px;
  height: 56px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #f1f3f5;
}

.upload-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-title {
  font-size: 13px;
}

.upload-box .btn {
  flex: 0 0 auto;
}

.advanced {
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.advanced > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
}

.advanced > summary::-webkit-details-marker {
  display: none;
}

.advanced > summary::before {
  content: "+";
  display: inline-block;
  width: 16px;
  color: var(--faint);
}

.advanced[open] > summary::before {
  content: "-";
}

.advanced .form-grid {
  margin-top: 12px;
}

/* ---------- table ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.overview-table table.table {
  min-width: 1120px;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  background: #fafbfc;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #fafbfc;
}

.table tbody tr.is-selected,
.table tbody tr.is-selected:hover {
  background: #eef4ff;
}

.audit-summary-table table.table {
  min-width: 960px;
}

.table .right {
  text-align: right;
}

.table .nowrap {
  white-space: nowrap;
}

.cell-main {
  font-weight: 500;
}

.cell-sub {
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
  word-break: break-word;
}

.token-key {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.small {
  font-size: 12px;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
  background: #f2f3f5;
  color: var(--muted);
}

.badge-green {
  background: var(--green-bg);
  color: #1f8a5c;
}

.badge-red {
  background: var(--red-bg);
  color: #c62f2b;
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.badge-gray {
  background: #f2f3f5;
  color: var(--muted);
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line-soft);
  padding: 0 20px;
}

.tab {
  position: relative;
  border: 0;
  background: none;
  padding: 13px 12px 12px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  font-weight: 500;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* ---------- pager / states ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
}

.pager-info {
  color: var(--faint);
  font-size: 12px;
}

.pager-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.empty-title {
  color: var(--muted);
  font-size: 14px;
}

.empty p {
  margin: 6px 0 0;
  font-size: 12px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 52px 20px;
  color: var(--faint);
  font-size: 13px;
}

.error-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 20px;
  padding: 12px 14px;
  border: 1px solid #f7c6c4;
  border-radius: 6px;
  background: var(--red-bg);
  color: #a92f2b;
  font-size: 13px;
}

.error-box p {
  margin: 0;
}

.pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: #fafbfc;
  color: #3d4249;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}

.detail-list {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px 14px;
  font-size: 13px;
}

.detail-list dt {
  color: var(--faint);
}

.detail-list dd {
  margin: 0;
  word-break: break-all;
}

/* ---------- layer, drawer, modal ---------- */

.layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.layer-item {
  position: fixed;
  inset: 0;
  pointer-events: auto;
  z-index: 1;
}

.layer-item + .layer-item {
  z-index: 2;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 24, 0.44);
  animation: fadeIn 0.16s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 560px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -16px 0 40px rgba(15, 18, 24, 0.16);
  animation: slideIn 0.18s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(28px);
    opacity: 0.4;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.drawer-head p {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.icon-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  background: #f2f3f5;
  color: var(--text);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}

.drawer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  background: #fafbfc;
}

.modal-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16vh 20px 40px;
  overflow-y: auto;
}

.modal {
  width: 420px;
  max-width: 100%;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 56px rgba(15, 18, 24, 0.24);
  padding: 22px 22px 18px;
  animation: popIn 0.16s ease-out;
}

@keyframes popIn {
  from {
    transform: translateY(-6px) scale(0.99);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.modal p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-line;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #1f2329;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 28px rgba(15, 18, 24, 0.24);
  animation: toastIn 0.18s ease-out;
}

.toast-success {
  background: #10371f;
  border-left: 3px solid var(--green);
}

.toast-error {
  background: #3a1114;
  border-left: 3px solid var(--red);
}

.toast-info {
  background: #1f2329;
  border-left: 3px solid #8f959e;
}

@keyframes toastIn {
  from {
    transform: translateY(-6px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- accounts ---------- */

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setup-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
}

.setup-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.setup-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.setup-card .actions {
  margin-top: 4px;
}

.bind-code {
  padding: 14px 18px;
  border: 1px dashed #c9d3e6;
  border-radius: 10px;
  background: var(--blue-bg);
  color: #23427f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 7px;
  text-align: center;
}

.section-title {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.token-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--line-soft);
}

.token-row:first-child {
  border-top: 0;
}

.token-row .mono {
  min-width: 84px;
  font-weight: 600;
  letter-spacing: 1px;
}

/* ---------- misc ---------- */

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row.between {
  justify-content: space-between;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.thumb {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #f6f7f9;
}

.token-valid {
  color: var(--green);
}

.token-invalid {
  color: var(--red);
}

/* ---------- group chat ---------- */

.chat-layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 16px;
  height: calc(100vh - 134px);
  min-height: 520px;
}

.chat-layout > .panel + .panel {
  margin-top: 0;
}

.chat-side,
.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-side-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.chat-side-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-conv {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-conv:hover {
  background: #fafbfc;
}

.chat-conv.active {
  background: #fff1f4;
}

.chat-conv-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff7a95, var(--accent));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.chat-conv-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.chat-conv-top,
.chat-conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.chat-conv-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conv-time {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 11px;
}

.chat-conv-preview {
  overflow: hidden;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conv-count {
  flex: 0 0 auto;
  padding: 0 7px;
  border-radius: 9px;
  background: #f0f1f3;
  color: var(--faint);
  font-size: 11px;
  line-height: 18px;
}

.chat-head {
  flex: 0 0 auto;
}

.chat-toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}

.chat-toolbar > select {
  width: auto;
}

.chat-toolbar > input[type="search"] {
  flex: 1 1 180px;
  max-width: 280px;
}

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 20px 22px 24px;
  overflow-y: auto;
  background: #f7f8fa;
}

.chat-day {
  align-self: center;
  padding: 2px 10px;
  border-radius: 10px;
  background: #eceef2;
  color: var(--faint);
  font-size: 11px;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 78%;
}

.chat-row.out {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #d9dde5;
  color: #5b636e;
  font-size: 13px;
  font-weight: 600;
}

.chat-avatar.out {
  background: var(--accent);
  color: #fff;
}

.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chat-row.out .chat-bubble-wrap {
  align-items: flex-end;
}

.chat-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 11px;
}

.chat-name {
  color: var(--muted);
  font-weight: 500;
}

.chat-detail-btn {
  font-size: 11px;
  opacity: 0.55;
}

.chat-row:hover .chat-detail-btn {
  opacity: 1;
}

.chat-bubble {
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-row.out .chat-bubble {
  border-color: #cddcff;
  background: var(--blue-bg);
}

.chat-image {
  display: block;
  max-width: 260px;
  max-height: 220px;
  border-radius: 6px;
}

.chat-link {
  color: var(--blue);
  text-decoration: none;
}

.chat-link:hover {
  text-decoration: underline;
}

.chat-placeholder {
  color: var(--faint);
}

.chat-card {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  min-width: 180px;
}

.chat-card-tag {
  color: var(--blue);
  font-size: 11px;
}

.chat-card-title {
  font-weight: 600;
}

.chat-card-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.chat-emoji {
  font-size: 22px;
  line-height: 1.2;
}

.chat-pager {
  flex: 0 0 auto;
  background: #fff;
}

.chat-pager .pager {
  border-top: 1px solid var(--line-soft);
}

@media (max-width: 980px) {
  .chat-layout {
    grid-template-columns: 232px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .chat-side-list {
    max-height: 240px;
  }

  .chat-log {
    min-height: 420px;
    max-height: 60vh;
  }
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .setup-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .sidebar {
    width: 196px;
    flex-basis: 196px;
  }

  .sidebar-brand {
    padding: 18px 14px;
  }

  .nav a {
    margin: 2px 8px;
    padding: 9px 10px;
  }

  .topbar {
    padding: 0 16px;
  }

  .view {
    padding: 16px 16px 40px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 68px;
    flex-basis: 68px;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 18px 8px;
  }

  .sidebar-brand > span:last-child {
    display: none;
  }

  .nav a {
    justify-content: center;
    margin: 2px 8px;
    padding: 10px 0;
  }

  .nav a span {
    display: none;
  }

  .nav a::before {
    display: none;
  }

  .sidebar-foot {
    justify-content: center;
    padding: 12px 8px;
  }

  .admin-name {
    display: none;
  }
}

@media (max-width: 560px) {
  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- mini program editor ---------- */

.mp-text-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.mp-text-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbfc;
}

.mp-text-card.full {
  grid-column: 1 / -1;
}

.mp-text-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mp-text-title {
  font-size: 13px;
  font-weight: 600;
}

.mp-text-card textarea {
  min-height: 88px;
  resize: vertical;
  background: #fff;
}

.mp-pools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.mp-pool {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfbfc;
}

.mp-pool-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.mp-pool-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.mp-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px auto;
  gap: 8px;
  align-items: center;
}

.mp-qr {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px dashed #cfd3da;
  border-radius: 6px;
  background-color: #fff;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: var(--faint);
  font-size: 11px;
  cursor: pointer;
}

.mp-qr.filled {
  border-style: solid;
  border-color: var(--line);
}

.mp-pool-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 460px;
  overflow: auto;
}

.mp-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mp-item.is-off {
  opacity: 0.55;
}

.mp-item-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.mp-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 12px;
}

.mp-item-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.mp-item-side .check {
  font-size: 12px;
}

.mp-share {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.mp-share-preview {
  width: 140px;
  height: 140px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cfd3da;
  border-radius: 8px;
  background-color: #f6f7f9;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: var(--faint);
  font-size: 12px;
}

.mp-share-preview.filled {
  border-style: solid;
  border-color: var(--line);
}

.mp-share-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mp-inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-inline-field > span {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}

.btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .mp-pools,
  .mp-text-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .mp-text-card.full {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .mp-share {
    flex-direction: column;
  }
}
