:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E9ECEF;
  --text: #171A1D;
  --text-2: #5F6670;
  --text-3: #98A0A8;
  --green: #07C160;
  --green-dark: #06AD56;
  --green-soft: #E8F8EF;
  --red: #E5484D;
  --red-soft: #FDECEC;
  --amber: #B7791F;
  --amber-soft: #FFF6E5;
  --blue: #3B6EA5;
  --blue-soft: #EEF4FB;
  --sidebar: #101815;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

code,
.mono {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: -0.1px;
}

code {
  background: #F2F4F6;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-2);
  word-break: break-all;
}

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

.small {
  font-size: 12px;
}

.money {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.money.big {
  font-size: 20px;
}

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

.link {
  color: var(--blue);
}

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

.ta-right {
  text-align: right !important;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wrap {
  word-break: break-all;
}

/* ---------- 布局 ---------- */
.app {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 236px;
  flex: none;
  background: var(--sidebar);
  color: #E8EFEB;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 6px 18px rgba(7, 193, 96, 0.28);
}

.brand-mark.large {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #FFFFFF;
}

.brand-sub {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

.nav {
  margin-top: 8px;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  height: 42px;
  padding: 0 12px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: rgba(232, 239, 235, 0.66);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(7, 193, 96, 0.14);
  color: #FFFFFF;
}

.nav-ico {
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.85;
}

.sidebar-foot {
  margin-top: auto;
  padding: 18px 20px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.admin-name {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.logout-btn {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.logout-btn:hover {
  color: #fff;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: 236px;
}

.topbar {
  height: 76px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.topbar-title p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

.topbar-right {
  margin-left: auto;
}

.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 17px;
  cursor: pointer;
}

.ghost-link {
  font-size: 13px;
  color: var(--green-dark);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
}

.ghost-link:hover {
  background: var(--green-soft);
}

.page-body {
  padding: 24px 30px 40px;
  max-width: 1440px;
}

/* ---------- Flash ---------- */
.flash {
  margin-bottom: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 20px;
  border: 1px solid transparent;
}

.flash-ok {
  background: var(--green-soft);
  color: #067D3F;
  border-color: #C9F0D9;
}

.flash-err {
  background: var(--red-soft);
  color: #B42328;
  border-color: #F6D1D2;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.card-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
}

.card-badge {
  font-size: 13px;
  font-weight: 600;
  color: #067D3F;
  background: var(--green-soft);
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.narrow-card {
  max-width: 520px;
}

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--text-3);
}

.stat-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
}

.stat-value .unit {
  font-size: 14px;
  font-weight: 500;
  margin-left: 2px;
  color: var(--text-2);
}

.stat-foot {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-2);
}

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

/* ---------- 图表 ---------- */
.chart {
  height: 210px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.chart-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.chart-val {
  height: 18px;
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

.chart-track {
  height: 150px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: 60%;
  max-width: 38px;
  min-height: 2px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #35D07F 0%, #07C160 100%);
  transition: height 0.3s ease;
}

.chart-col:hover .chart-bar {
  filter: brightness(1.06);
}

.chart-label {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

/* ---------- 检查清单 ---------- */
.guide-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFFFD 100%);
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.checklist li {
  display: flex;
  gap: 11px;
  font-size: 12px;
  line-height: 19px;
  color: var(--text-2);
}

.checklist b {
  color: var(--text);
  font-weight: 600;
  margin-right: 4px;
}

.check-num {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--green-soft);
  color: #067D3F;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 1px;
}

/* ---------- 表格 ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid #F1F3F5;
  vertical-align: middle;
}

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

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

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-paid {
  background: var(--green-soft);
  color: #067D3F;
}

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

.badge-failed {
  background: var(--red-soft);
  color: #B42328;
}

.badge-closed {
  background: #F1F3F5;
  color: var(--text-2);
}

.badge-on {
  background: var(--green-soft);
  color: #067D3F;
}

.badge-off {
  background: #F1F3F5;
  color: var(--text-2);
}

/* ---------- 商户 ---------- */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.merchant-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.mini-avatar {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  background: #E7E9EC;
  flex: none;
}

.merchant-name {
  font-weight: 500;
  color: var(--text);
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-form {
  display: inline;
  margin: 0;
}

.hint-card {
  padding: 13px 16px;
  border: 1px dashed #D8E1DB;
  background: #F9FCFA;
  border-radius: 10px;
  font-size: 12px;
  line-height: 21px;
  color: var(--text-2);
}

.hint-card b {
  color: var(--text);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  background: transparent;
}

.btn-primary {
  background: var(--green);
  color: #FFFFFF;
}

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

.btn-plain {
  background: #FFFFFF;
  border-color: var(--border);
  color: var(--text);
}

.btn-plain:hover {
  border-color: #CFD6DC;
  background: #FBFCFC;
}

.btn-mini {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
  background: #FFFFFF;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-mini:hover {
  border-color: #C9D1D8;
  color: var(--text);
}

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

.btn-danger:hover {
  border-color: #F3C7C8;
  background: #FFF8F8;
}

.btn-block {
  width: 100%;
  display: flex;
}

.btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-file {
  position: relative;
  overflow: hidden;
}

/* ---------- 表单 ---------- */
.field {
  display: block;
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 7px;
}

.field-label em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 6px;
  font-size: 11px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 17px;
  color: var(--text-3);
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #B7BEC6;
}

.input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}

textarea.input {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 20px;
  align-items: start;
}

.form-side {
  min-width: 0;
}

.avatar-editor {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: #E7E9EC;
  border: 1px solid var(--border);
  flex: none;
}

.avatar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  cursor: pointer;
}

.checkbox input {
  accent-color: var(--green);
}

.mask-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 4px 0 18px;
  flex-wrap: wrap;
}

.mask-demo-name {
  font-size: 14px;
  font-weight: 600;
}

.mask-demo-sub {
  font-size: 11px;
  color: var(--text-2);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 16px;
  border-top: 1px solid #F1F3F5;
  cursor: pointer;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  display: inline-block;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: #D9DEE3;
  border-radius: 20px;
  transition: background 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.form-footer {
  position: sticky;
  bottom: 0;
  margin-top: 22px;
  padding: 14px 22px;
  background: rgba(245, 246, 248, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  z-index: 10;
}

.copy-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 12px;
}

.copy-line code {
  flex: 1;
  background: transparent;
  padding: 0;
  font-size: 11px;
  line-height: 17px;
  word-break: break-all;
}

/* ---------- 筛选 ---------- */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters .input {
  width: 200px;
  height: 36px;
}

.filters .select {
  width: 200px;
}

.filters .btn {
  height: 36px;
}

.filters-count {
  margin-left: auto;
  font-size: 12px;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 50px 24px;
  text-align: center;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
}

.empty-sub {
  margin-top: 7px;
  font-size: 12px;
  line-height: 20px;
  color: var(--text-3);
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.empty .btn {
  margin-top: 16px;
}

.small-empty {
  padding: 26px 16px;
}

/* ---------- 详情 ---------- */
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.detail-side {
  min-width: 0;
}

.detail-merchant {
  margin-bottom: 16px;
}

.kv {
  margin: 0;
}

.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 0;
  border-bottom: 1px solid #F1F3F5;
  font-size: 13px;
}

.kv > div:last-child {
  border-bottom: 0;
}

.kv dt {
  color: var(--text-3);
  flex: none;
  font-size: 12px;
  padding-top: 1px;
}

.kv dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  min-width: 0;
}

.kv.compact > div {
  padding: 8px 0;
}

.code-block {
  margin: 0;
  max-height: 380px;
  overflow: auto;
  padding: 14px;
  background: #0F1512;
  color: #B8E6C9;
  border-radius: 10px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 17px;
  white-space: pre-wrap;
  word-break: break-all;
}

.stack-form .field {
  margin-bottom: 16px;
}

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(7, 193, 96, 0.18), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(7, 193, 96, 0.1), transparent 60%),
    #F2F5F3;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(16, 40, 26, 0.12);
  padding: 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 24px;
}

.login-brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.login-brand p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

.login-form .field {
  margin-bottom: 15px;
}

.login-form .btn {
  height: 42px;
  margin-top: 6px;
  font-size: 14px;
}

.login-note {
  margin-top: 18px;
  font-size: 11px;
  line-height: 18px;
  color: var(--text-3);
}

.login-note code {
  font-size: 10px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  }

  .app.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 20, 0.36);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .app.nav-open .sidebar-mask {
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    margin-left: 0;
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    padding: 0 18px;
    height: 68px;
  }

  .page-body {
    padding: 18px 16px 32px;
  }

  .filters .input,
  .filters .select {
    width: calc(50% - 5px);
  }

  .filters-count {
    margin-left: 0;
  }

  .stat-value {
    font-size: 22px;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .table {
    min-width: 760px;
  }

  .form-footer {
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 520px) {
  .topbar {
    height: auto;
    min-height: 64px;
    padding: 10px 14px;
    gap: 10px;
    align-items: center;
  }

  .menu-btn {
    flex: 0 0 auto;
  }

  .topbar-title {
    min-width: 0;
  }

  .topbar-title h1 {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-title p {
    display: none;
  }

  .ghost-link {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 8px 10px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 15px;
  }

  .stat-value {
    font-size: 20px;
  }

  .filters .input,
  .filters .select {
    width: 100%;
  }

  .page-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .login-card {
    padding: 24px 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .avatar-editor {
    flex-direction: column;
  }

  .detail-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}
