/* ─── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1419;
  --bg-2: #1a1f2e;
  --bg-3: #232938;
  --fg: #e6e8eb;
  --fg-muted: #8d96a8;
  --fg-dim: #5d6577;
  --accent: #5865F2;
  --accent-hover: #4752c4;
  --green: #43b581;
  --red: #f04747;
  --yellow: #faa61a;
  --pink: #EC4899;
  --border: #2a3142;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ─── Nav ──────────────────────────────────────────────────────────────── */
.nav {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.nav-brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo { font-size: 20px; }
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--fg-muted);
  font-weight: 500;
  transition: all 0.15s;
}
.nav-link:hover { background: var(--bg-3); color: var(--fg); }
.nav-link.active { background: var(--bg-3); color: var(--fg); }
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg-muted);
}
.logout {
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg-3);
  font-size: 12px;
}
.logout:hover { background: var(--red); color: white; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--fg);
  object-fit: cover;
}
.avatar-placeholder { background: var(--accent); color: white; }

/* ─── Main ─────────────────────────────────────────────────────────────── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}
.muted { color: var(--fg-muted); font-size: 13px; }

/* ─── Login ────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-logo {
  font-size: 48px;
  margin-bottom: 16px;
}
.login-card h1 {
  font-size: 22px;
  margin-bottom: 8px;
}
.login-card p {
  margin-bottom: 24px;
}
.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #5865F2;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  width: 100%;
  justify-content: center;
}
.btn-discord:hover { background: #4752c4; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  text-align: left;
}
.alert-error { background: rgba(240, 71, 71, 0.1); color: #f47474; border: 1px solid #5a2424; }
.alert-warning { background: rgba(250, 166, 26, 0.1); color: #f5c971; border: 1px solid #5a4a24; }
.alert-success { background: rgba(67, 181, 129, 0.1); color: #6dcc9c; border: 1px solid #2a5742; }
.alert code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: SFMono-Regular, Monaco, monospace;
  font-size: 12px;
}

/* ─── Tabs ─────────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 8px;
}
.tab {
  padding: 8px 16px;
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--bg-3); color: var(--fg); }
.badge {
  background: rgba(255,255,255,0.1);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ─── Tickets list ─────────────────────────────────────────────────────── */
.ticket-list {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: rgba(255,255,255,0.02); }

.ticket-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.ticket-user .avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
  flex-shrink: 0;
}
.ticket-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.ticket-meta {
  font-size: 12px;
  color: var(--fg-muted);
}

.ticket-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-open { background: rgba(67, 181, 129, 0.15); color: var(--green); }
.status-closed { background: rgba(141, 150, 168, 0.15); color: var(--fg-muted); }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-3); color: var(--fg); }
.btn-secondary:hover { background: #2e3548; }
.btn-danger { background: rgba(240, 71, 71, 0.15); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

/* ─── Empty state ──────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--fg-muted);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ─── Panel form ───────────────────────────────────────────────────────── */
.panel-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .panel-layout { grid-template-columns: 1fr; }
}

.panel-form {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input[type="text"],
.field textarea,
.field select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
}
.field input[type="text"]:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}
.field input[type="color"] {
  width: 50px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  padding: 2px;
}
.field textarea {
  resize: vertical;
  font-family: inherit;
}
.hint {
  font-size: 11px;
  color: var(--fg-dim);
}
.form-actions {
  margin-top: 8px;
}

/* ─── Discord embed preview ────────────────────────────────────────────── */
.panel-preview {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  height: fit-content;
}
.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.discord-embed {
  background: #2f3136;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 14px 18px;
}
.embed-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: white;
}
.embed-desc {
  font-size: 14px;
  color: #dcddde;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.discord-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 14px;
  cursor: default;
}
.embed-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: #dcddde;
}
.embed-fields strong {
  font-size: 12px;
  color: white;
  display: block;
  margin-bottom: 2px;
}

/* ─── Section labels (in forms) ────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 8px 0;
  margin-top: 12px;
  border-bottom: 1px solid var(--border);
}
.req {
  color: var(--red);
  font-weight: 700;
}

/* ─── Toggle switch ────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.toggle-row h2 {
  font-size: 18px;
  margin-bottom: 4px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { display: none; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-3);
  transition: .25s;
  border-radius: 28px;
}
.switch .slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: .25s;
  border-radius: 50%;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ─── Radio card group ─────────────────────────────────────────────────── */
.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}
.radio-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
}
.radio-card span {
  font-size: 13px;
  font-weight: 600;
}
.radio-card small {
  font-size: 11px;
  color: var(--fg-muted);
  font-weight: 400;
}
.radio-card:hover {
  border-color: var(--accent);
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: rgba(88, 101, 242, 0.08);
}
.radio-card:has(input:checked) span {
  color: var(--accent);
}

.local-time-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(88, 101, 242, 0.08);
  border-radius: 6px;
  border-left: 2px solid var(--accent);
}
.local-time-value {
  font-size: 12px;
  color: var(--fg);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ─── Cards (XP page sections) ─────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  margin-bottom: 16px;
}
.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ─── Tiers table ──────────────────────────────────────────────────────── */
.tiers-table {
  margin-bottom: 12px;
}
.tiers-head, .tiers-row {
  display: grid;
  grid-template-columns: 100px 160px 1fr 100px;
  gap: 12px;
  align-items: center;
}
.tiers-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.tiers-row {
  padding: 8px 0;
}
.tiers-row input,
.tiers-row select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}
.tiers-row input:focus, .tiers-row select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── Channel grid ─────────────────────────────────────────────────────── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.channel-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.channel-check:hover {
  border-color: var(--accent);
}
.channel-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}
.channel-check input:checked + span {
  color: var(--accent);
  font-weight: 500;
}

/* ─── Leaderboard ──────────────────────────────────────────────────────── */
.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
}
.lb-rank {
  font-weight: 700;
  width: 36px;
  color: var(--fg-muted);
}
.lb-row:nth-child(1) .lb-rank { color: #FFD700; }
.lb-row:nth-child(2) .lb-rank { color: #C0C0C0; }
.lb-row:nth-child(3) .lb-rank { color: #CD7F32; }
.lb-name {
  flex: 1;
  font-weight: 600;
}
.lb-stats {
  display: flex;
  gap: 14px;
  font-size: 13px;
  align-items: center;
}
.lb-level {
  background: var(--bg-3);
  color: var(--fg);
  padding: 3px 9px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 12px;
}

/* ─── Status badges (extend) ───────────────────────────────────────────── */
.status-pending { background: rgba(250, 166, 26, 0.15); color: var(--yellow); }

/* ─── File upload widget ──────────────────────────────────────────────── */
.upload-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 6px 6px 4px;
}
.file-input { display: none; }
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-3);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.file-btn:hover { background: #2e3548; }
.file-name {
  flex: 1;
  font-size: 12px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clear-file {
  flex-shrink: 0;
}
.url-fallback {
  margin-top: 6px;
}
.url-fallback summary {
  font-size: 11px;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.url-fallback summary:hover { color: var(--fg); }
.url-fallback input {
  margin-top: 6px;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ─── Info list ────────────────────────────────────────────────────────── */
.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
}
.info-list li {
  padding: 6px 0;
  padding-left: 18px;
  position: relative;
}
.info-list li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
}
.info-list strong {
  color: var(--fg);
}
