:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d9e2ef;
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --accent: #00796b;
  --warning: #b45309;
  --danger: #c62828;
  --success: #2e7d32;
  --shadow: 0 12px 28px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.login-box p {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-box.auth-wide {
  width: min(760px, 100%);
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.auth-links button {
  background: transparent;
  color: var(--primary);
  min-height: 34px;
  padding: 0;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.captcha-image {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0;
  overflow: hidden;
}

.captcha-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 12px rgba(31, 41, 55, 0.06);
}

.brand {
  font-weight: 700;
  white-space: nowrap;
}

.nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.nav button.active {
  background: var(--primary);
  color: #fff;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(31, 41, 55, 0.04);
  margin-bottom: 16px;
}

.panel-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.panel-body {
  padding: 16px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

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

.metric {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric-label {
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
}

.metric-value.small {
  font-size: 16px;
}

.info-table {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.info-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  min-height: 40px;
  border-bottom: 1px solid var(--line);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-label {
  padding: 10px 12px;
  background: #edf3fb;
  color: #334155;
  font-weight: 700;
}

.info-value {
  padding: 8px 12px;
  min-width: 0;
  word-break: break-all;
}

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

.inline-edit input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.38);
  padding: 16px;
}

.modal {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.modal-body {
  padding: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

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

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

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(21, 101, 192, 0.18);
  border-color: var(--primary);
}

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

.btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

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

.btn.secondary {
  background: #e8eef7;
  color: var(--text);
}

.btn.secondary:hover {
  background: #dbe5f3;
}

.btn.success {
  background: var(--success);
}

.btn.warning {
  background: var(--warning);
}

.btn.danger {
  background: var(--danger);
}

.btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf3fb;
  color: #334155;
  font-weight: 700;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: #e8eef7;
  color: #334155;
}

.badge.success {
  background: #e5f5e8;
  color: var(--success);
}

.badge.warning {
  background: #fff4df;
  color: var(--warning);
}

.badge.danger {
  background: #fde8e8;
  color: var(--danger);
}

.badge.info {
  background: #e4f1ff;
  color: var(--primary);
}

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

.money {
  font-weight: 700;
  color: var(--success);
}

.danger-text {
  color: var(--danger);
}

.warning-text {
  color: var(--warning);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
}

.pagination select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.loading {
  color: var(--muted);
  padding: 18px;
}

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

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  border-left: 3px solid var(--line);
  padding: 0 0 14px 14px;
  margin-left: 6px;
}

.tree-indent {
  display: inline-block;
  width: calc(var(--depth, 0) * 18px);
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .form-grid,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .page {
    padding: 10px;
  }

  .panel-body {
    padding: 12px;
  }

  .captcha-row,
  .info-row {
    grid-template-columns: 1fr;
  }
}
