:root {
  --bg: #0f1419;
  --bg2: #1a2332;
  --bg3: #243044;
  --card: #1e2a3a;
  --border: #2d3f56;
  --text: #e8eef6;
  --muted: #8fa3b8;
  --accent: #3d9cf0;
  --accent2: #2dd4a8;
  --danger: #f07178;
  --warn: #e6c07b;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: linear-gradient(160deg, #0c1220 0%, #152238 50%, #0f1a28 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: rgba(15, 22, 35, 0.95);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 0 20px 24px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.5px;
}
.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--muted);
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: all .15s;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--text);
  background: rgba(61, 156, 240, 0.08);
  border-left-color: var(--accent);
  text-decoration: none;
}
.main { flex: 1; padding: 28px 32px; overflow-x: auto; }
.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 8px; }
.page-desc { color: var(--muted); margin-bottom: 24px; font-size: 0.9rem; }
.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.page-title-row .btn { flex-shrink: 0; white-space: nowrap; }

/* 支付方式选择 */
.pay-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}
.pay-method {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  margin: 0;
}
.pay-method:has(input:checked) {
  border-color: var(--accent);
  background: rgba(61, 156, 240, 0.12);
}
.pay-method input { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .label { color: var(--muted); font-size: 0.85rem; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; color: var(--accent2); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { margin-bottom: 14px; font-size: 1.05rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }
tr:hover td { background: rgba(255,255,255,0.02); }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: 0.9; text-decoration: none; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-secondary { background: var(--bg3); color: var(--text); }
.btn-success { background: var(--accent2); color: #0a1a14; }
.btn-danger { background: var(--danger); }
.btn-warn { background: var(--warn); color: #1a1408; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 0.85rem; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}
.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input { width: 16px; height: 16px; }

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-success { background: rgba(45, 212, 168, 0.15); border: 1px solid var(--accent2); color: var(--accent2); }
.alert-error { background: rgba(240, 113, 120, 0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-info { background: rgba(61, 156, 240, 0.15); border: 1px solid var(--accent); color: var(--accent); }

/* 自定义确认框 / Toast（替代系统 confirm / alert） */
.ui-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(4, 10, 18, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity .18s ease;
}
.ui-backdrop.is-open { opacity: 1; }
.ui-modal {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, #243447 0%, #1a2636 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.45);
  padding: 22px 22px 18px;
  transform: translateY(10px) scale(0.98);
  transition: transform .18s ease;
}
.ui-backdrop.is-open .ui-modal { transform: translateY(0) scale(1); }
.ui-modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
  background: rgba(240, 113, 120, 0.15);
  color: var(--danger);
}
.ui-modal-icon.is-warn {
  background: rgba(230, 192, 123, 0.15);
  color: var(--warn);
}
.ui-modal-title {
  font-size: 1.05rem;
  font-weight: 650;
  margin-bottom: 6px;
}
.ui-modal-msg {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 18px;
}
.ui-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.ui-modal-actions .btn { min-width: 76px; }

.ui-toast-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.ui-toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1e2a3a;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  color: var(--text);
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: uiToastIn .22s ease;
}
.ui-toast.is-out { animation: uiToastOut .2s ease forwards; }
.ui-toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--accent);
}
.ui-toast.is-success .ui-toast-dot { background: var(--accent2); }
.ui-toast.is-error .ui-toast-dot { background: var(--danger); }
.ui-toast.is-info .ui-toast-dot { background: var(--accent); }
.ui-toast-body { flex: 1; line-height: 1.45; }
.ui-toast-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.ui-toast-close:hover { color: var(--text); }
@keyframes uiToastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes uiToastOut {
  to { opacity: 0; transform: translateY(-6px); }
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--bg3);
}
.badge-vip { background: rgba(230, 192, 123, 0.2); color: var(--warn); }
.badge-ok { background: rgba(45, 212, 168, 0.2); color: var(--accent2); }
.badge-off { background: rgba(143, 163, 184, 0.2); color: var(--muted); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
}
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 1.4rem; }
.login-box .sub { text-align: center; color: var(--muted); margin-bottom: 28px; font-size: 0.9rem; }
.code-display {
  font-size: 2.4rem;
  letter-spacing: 12px;
  text-align: center;
  font-weight: 700;
  color: var(--accent2);
  padding: 20px;
  background: var(--bg);
  border-radius: 8px;
  margin: 16px 0;
}

.tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 16px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
}
.tabs a.active, .tabs a:hover {
  background: var(--bg3);
  color: var(--text);
  text-decoration: none;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* 可视化按钮编辑器 */
.btn-editor { margin: 12px 0 8px; }
.btn-editor-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.btn-editor-preview {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  min-height: 48px;
}
.btn-preview-line { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.btn-preview-line:last-child { margin-bottom: 0; }
.btn-preview-chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #fff;
  background: var(--accent);
}
.btn-preview-chip.is-success { background: var(--accent2); color: #0a1a14; }
.btn-preview-chip.is-danger { background: var(--danger); }
.btn-preview-chip.is-warn { background: var(--warn); color: #1a1408; }
.btn-preview-chip.is-primary { background: var(--accent); }
.btn-editor-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(0,0,0,0.15);
}
.btn-editor-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-weight: 600;
}
.btn-editor-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-editor-btns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.btn-editor-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.btn-editor-btn .form-group { margin-bottom: 8px; }

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 12px 0; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar nav a.active { border-bottom-color: var(--accent); }
  .main { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}
