:root {
  --bg: #07080c;
  --bg-soft: #0b0d14;
  --panel: #10121c;
  --panel-2: #151827;
  --panel-3: #1b1f31;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9ebf5;
  --text-dim: #9aa0b8;
  --text-mute: #6b7188;
  --brand: #7c5cff;
  --brand-2: #22d3ee;
  --pink: #ff5c8a;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --gradient: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  --gradient-soft: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.12));
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img, video, canvas { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

::selection { background: rgba(124, 92, 255, 0.4); }

.container { width: min(1200px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.2px;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.35);
  flex: none;
}
.logo-mark svg { width: 18px; height: 18px; }
.logo small {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-mute);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  letter-spacing: 0.4px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-3);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.3);
}
.btn-primary:hover { box-shadow: 0 12px 30px rgba(124, 92, 255, 0.42); }

.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.24); }

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.btn-danger { background: rgba(248, 113, 113, 0.14); color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 26px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--pink); }
.hint { font-size: 11.5px; color: var(--text-mute); }

.input, .select, .textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(124, 92, 255, 0.65); background: rgba(124, 92, 255, 0.06); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.65; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 16px) 51%, calc(100% - 11px) 51%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; cursor: pointer; }
.select option { background: #161a29; }

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

/* ---------- Switch ---------- */
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: rgba(255, 255, 255, 0.14);
  border-radius: 22px; cursor: pointer; transition: 0.2s;
}
.switch span::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Badges / tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600;
  background: rgba(255, 255, 255, 0.07); color: var(--text-dim);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: rgba(52, 211, 153, 0.13); color: #6ee7b7; }
.badge-warn { background: rgba(251, 191, 36, 0.13); color: #fcd34d; }
.badge-danger { background: rgba(248, 113, 113, 0.13); color: #fca5a5; }
.badge-info { background: rgba(34, 211, 238, 0.12); color: #67e8f9; }
.badge-brand { background: rgba(124, 92, 255, 0.16); color: #c4b5fd; }

.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text-dim); font-size: 11.5px;
}

/* ---------- Card ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-title { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4, 5, 10, 0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  overflow-y: auto;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(520px, 100%);
  background: #11131e;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
}
.modal-backdrop.open .modal { transform: none; }
.modal.wide { width: min(860px, 100%); }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; padding: 20px 22px 0;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-desc { font-size: 12.5px; color: var(--text-mute); margin-top: 3px; }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: rgba(255, 255, 255, 0.06); color: var(--text-dim);
  cursor: pointer; display: grid; place-items: center; flex: none;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end;
  border-top: 1px solid var(--line); margin-top: 4px;
}

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: rgba(22, 25, 40, 0.96);
  border: 1px solid var(--line-strong);
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s ease;
}
.toast.success { border-color: rgba(52, 211, 153, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.42); }
.toast .ti { width: 16px; height: 16px; flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty & loading ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 46px 20px; text-align: center; color: var(--text-mute);
}
.empty svg { width: 38px; height: 38px; opacity: 0.5; }
.empty strong { color: var(--text-dim); font-size: 14px; font-weight: 600; }
.empty p { font-size: 12.5px; max-width: 320px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.mono { font-family: 'SFMono-Regular', Consolas, monospace; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.gradient-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- Auth modal ---------- */
.auth-tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.05); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; height: 34px; border: none; border-radius: 8px; background: transparent;
  color: var(--text-dim); font-weight: 600; font-size: 13px; cursor: pointer;
}
.auth-tab.active { background: var(--panel-3); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.auth-note { font-size: 11.5px; color: var(--text-mute); text-align: center; margin-top: 14px; line-height: 1.7; }
.auth-error { display: none; background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); color: #fca5a5; font-size: 12.5px; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.auth-error.show { display: block; }

@media (max-width: 640px) {
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .container { width: calc(100% - 32px); }
}
