:root {
  --bg: #0b0f17;
  --bg2: #111827;
  --card: #151c2c;
  --border: #243047;
  --text: #e8edf7;
  --muted: #8b98b3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 32px;
  padding: 0 8px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(59,130,246,.12);
  color: var(--text);
}
.sidebar-nav a.active { color: var(--primary); font-weight: 600; }

.sidebar-user {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}
.user-name { font-weight: 600; font-size: .9rem; }
.user-role { margin: 6px 0 12px; }

.main { flex: 1; padding: 28px 32px; overflow-x: auto; }

.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.75rem; margin-bottom: 4px; }
.page-header p { color: var(--muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label { color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.stat-value { font-size: 1.5rem; font-weight: 700; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; margin-bottom: 16px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
.form input, .form select, .select-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .95rem;
}
.form input:focus, .form select:focus { outline: 2px solid rgba(59,130,246,.4); border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: rgba(59,130,246,.15);
  color: #93c5fd;
  text-transform: uppercase;
}
.badge.ok { background: rgba(16,185,129,.15); color: #6ee7b7; }
.badge.err { background: rgba(239,68,68,.15); color: #fca5a5; }

.status-pending { background: rgba(245,158,11,.15); color: #fcd34d; }
.status-processing { background: rgba(59,130,246,.15); color: #93c5fd; }
.status-completed { background: rgba(16,185,129,.15); color: #6ee7b7; }
.status-cancelled, .status-expired { background: rgba(239,68,68,.15); color: #fca5a5; }
.status-rejected { background: rgba(239,68,68,.2); color: #f87171; }

.btn-warning { background: var(--warning); color: #111; }
.btn-warning:hover { filter: brightness(1.05); }

.pay-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #1e293b 0%, var(--bg) 60%);
}
.pay-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.pay-card-wide { max-width: 620px; }
.pay-limits {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: .95rem;
}
.pay-note { font-size: .85rem; margin-top: 16px; text-align: center; }
.pay-state { text-align: center; padding: 8px 0; }
.pay-state h2 { margin: 12px 0 8px; font-size: 1.25rem; }
.pay-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pay-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 auto 12px;
}
.pay-icon.success { background: rgba(16,185,129,.2); color: #6ee7b7; }
.pay-icon.error { background: rgba(239,68,68,.2); color: #fca5a5; }
.requisite-box {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}
.req-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.req-row:last-child { border-bottom: none; }
.req-row span { color: var(--muted); }
.pay-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.pay-timer {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(59, 130, 246, .12);
  border: 1px solid rgba(59, 130, 246, .25);
  font-size: .92rem;
}
.pay-timer-urgent {
  background: rgba(239, 68, 68, .12);
  border-color: rgba(239, 68, 68, .3);
  color: #fca5a5;
}
.pay-confirm-form { text-align: left; margin-top: 8px; }
.pay-confirm-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.proof-message { margin-top: 6px; font-size: .88rem; max-width: 280px; word-break: break-word; }
.proof-time { margin-top: 4px; font-size: .8rem; }

.withdraw-form { max-width: 480px; }

.support-lock { font-size: .85rem; color: var(--muted); }
.support-chat-card { display: flex; flex-direction: column; max-width: 720px; min-height: 420px; }
.chat-messages {
  flex: 1;
  min-height: 280px;
  max-height: 480px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
}
.chat-bubble {
  max-width: 85%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .92rem;
}
.chat-bubble-mine {
  margin-left: auto;
  background: rgba(59, 130, 246, .15);
  border: 1px solid rgba(59, 130, 246, .25);
}
.chat-bubble-theirs {
  margin-right: auto;
  background: var(--card);
  border: 1px solid var(--border);
}
.chat-meta { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-form textarea {
  flex: 1;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.chat-preview { max-width: 320px; font-size: .88rem; color: var(--muted); }
.chat-empty { text-align: center; padding: 40px 12px; }
.link-url { font-size: .8rem; word-break: break-all; }

.method-label {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 10px;
  display: block;
}

.pay-methods {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.pay-method-card {
  cursor: pointer;
  display: block;
}

.pay-method-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pay-method-inner {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  transition: .18s ease;
  text-align: center;
}

.pay-method-card input:checked + .pay-method-inner {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .22);
  transform: translateY(-2px);
}

.pay-method-card:hover .pay-method-inner {
  border-color: #64748b;
}

.pay-method-visual {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0f172a;
}

.pay-method-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.pay-method-caption {
  padding: 10px 12px 12px;
}

.pay-method-title {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}

.pay-method-sub {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 2px;
}

.pay-method-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
}

.pay-method-badge img {
  width: 56px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.pay-method-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
}

.pay-method-mini img {
  width: 52px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

#toast.show { opacity: 1; transform: translateY(0); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: rgba(255,255,255,.02); }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: .85em; }

.muted { color: var(--muted); }
.hidden { display: none; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 32px 24px;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(59,130,246,.18) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,.12) 0%, transparent 50%),
    var(--bg);
}

.auth-hero {
  display: none;
  max-width: 440px;
  flex: 1;
}

.auth-hero__desc {
  margin-top: 20px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.auth-hero__desc strong {
  color: var(--text);
  font-weight: 600;
}

.auth-hero__features {
  margin-top: 24px;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-hero__features li {
  color: var(--text);
  font-size: .95rem;
  padding-left: 28px;
  position: relative;
}

.auth-hero__features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  box-shadow: 0 0 12px rgba(59,130,246,.45);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow);
}

.auth-card__head {
  text-align: center;
  margin-bottom: 24px;
}

.auth-card__head h2 {
  margin-top: 14px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.brand-logo--lg {
  gap: 18px;
}

.brand-logo--sm {
  gap: 10px;
}

.brand-logo__icon {
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(59,130,246,.35));
}

.brand-logo__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-logo__name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #e8edf7 0%, #93c5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-logo--lg .brand-logo__name {
  font-size: 2.4rem;
  letter-spacing: 0.1em;
}

.brand-logo--sm .brand-logo__name {
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.brand-logo__tagline {
  font-size: .82rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.brand-logo--lg .brand-logo__tagline {
  font-size: 1.05rem;
}

.brand-logo--with-tagline .brand-logo__tagline {
  background: linear-gradient(90deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-brand .brand-logo {
  width: 100%;
}

.logo { text-align: center; margin-bottom: 28px; }
.logo h1 { font-size: 1.75rem; margin: 8px 0 4px; }
.logo p { color: var(--muted); font-size: .9rem; }
.logo-icon {
  display: inline-flex;
  width: 56px; height: 56px;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 14px;
  font-size: 1.75rem;
  font-weight: 700;
}
.logo-icon.sm { width: 32px; height: 32px; font-size: 1rem; border-radius: 8px; }

.auth-footer { text-align: center; margin-top: 20px; color: var(--muted); font-size: .9rem; }
.download-card { max-width: 440px; }
.download-features {
  text-align: left;
  margin: 16px 0 20px;
  padding-left: 20px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
}
.download-btn { margin-top: 8px; font-size: 1.05rem; padding: 14px; }
.install-hint { font-size: .82rem; margin-top: 12px; }

.register-card { max-width: 460px; }
.register-type-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.register-type-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.register-type-tab input { display: none; }
.register-type-tab span { font-weight: 600; font-size: .95rem; }
.register-type-tab small { color: var(--muted); font-size: .78rem; }
.register-type-tab:has(input:checked) {
  border-color: var(--primary);
  background: rgba(59,130,246,.1);
}
.legal-check { margin: 8px 0 4px; font-size: .88rem; line-height: 1.45; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.stat-value-sm { font-size: 1.1rem; }

.demo-accounts {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
}
.demo-accounts ul { margin-top: 8px; padding-left: 18px; }
.demo-accounts li { margin-bottom: 4px; }

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.alert-error { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(16,185,129,.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }

.calc-preview { padding: 10px; background: var(--bg); border-radius: 8px; font-size: .9rem; }

.api-key-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  margin: 12px 0;
  word-break: break-all;
}

.code-block {
  background: var(--bg);
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.6;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.docs-page { min-height: 100vh; }
.docs-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.logo-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.docs-main { max-width: 800px; margin: 0 auto; padding: 32px 24px; }
.docs-main h1 { margin-bottom: 12px; }
.docs-main > p { color: var(--muted); margin-bottom: 8px; }
.docs-main section { margin-top: 20px; }

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: .25s;
  z-index: 9999;
  pointer-events: none;
}
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 4px; }
.section-hint { margin: -8px 0 16px; font-size: .9rem; }
.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  color: var(--text) !important;
}
.checkbox-row input[type="checkbox"] { width: auto; accent-color: var(--primary); }

.subsection-title {
  margin: 20px 0 4px;
  font-size: 1rem;
  grid-column: 1 / -1;
}

.pm-settings-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  grid-column: 1 / -1;
}

.pm-settings-row {
  display: grid;
  grid-template-columns: 1fr auto 110px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.pm-settings-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pm-settings-icon {
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.pm-settings-label { font-weight: 600; }

.pm-settings-toggle { margin: 0; white-space: nowrap; }

.pm-settings-fee {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .85rem;
  color: var(--muted);
}

.pm-settings-fee input { width: 100%; }

.stat-card-wide { grid-column: span 2; }

.tier-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tier-chip {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .82rem;
}

.pm-create-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.pm-admin-list { display: flex; flex-direction: column; gap: 14px; }

.pm-admin-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.pm-admin-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pm-admin-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
}

.pm-upload-btn { cursor: pointer; text-align: center; }

.pm-admin-fields label { margin-bottom: 8px; }

.pm-admin-meta { margin-bottom: 8px; font-size: .85rem; }

.pm-admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.pm-admin-row label { margin-bottom: 0; min-width: 100px; }

.pm-admin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.presence-map-card { padding: 0; overflow: hidden; }
.presence-map {
  width: 100%;
  height: 480px;
  border-radius: var(--radius);
  background: #0f172a;
}
.presence-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

@media (min-width: 960px) {
  .auth-page {
    justify-content: center;
    padding: 48px 64px;
  }
  .auth-hero {
    display: block;
  }
  .auth-card__head .brand-logo {
    display: none;
  }
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .pay-methods { grid-template-columns: 1fr; }
  .pm-settings-row { grid-template-columns: 1fr; }
  .stat-card-wide { grid-column: span 1; }
  .pm-admin-item { grid-template-columns: 1fr; }
  .pm-admin-actions { flex-direction: row; flex-wrap: wrap; }
}
