@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:         #05070F;
  --s1:         #0B0E1A;
  --s2:         #101420;
  --s3:         #172030;
  --border:     rgba(255,255,255,.07);
  --border-hi:  rgba(255,255,255,.13);

  --blue:       #5AAFFF;
  --blue-dim:   rgba(90,175,255,.1);
  --teal:       #38E5BF;
  --teal-dim:   rgba(56,229,191,.09);
  --red:        #F87171;
  --yellow:     #FCD34D;
  --green:      #4ADE80;
  --purple:     #A78BFA;

  --text-1: #EDF2FF;
  --text-2: #8892A4;
  --text-3: #4A5568;

  --font-ui:      'DM Sans', sans-serif;
  --font-display: 'Syne', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sidebar-w: 232px;
  --topbar-h:  52px;

  --shadow:  0 2px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ui);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; outline: none; }
ul, ol { list-style: none; }

/* scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--s3); border-radius: 99px; }

/* selection */
::selection { background: var(--blue-dim); color: var(--blue); }

/* ── Layout ──────────────────────────────────────────────────── */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--s1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 60;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-logo-fallback {
  width: 28px;
  height: 28px;
  background: var(--blue);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-name {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-scope {
  font-size: .68rem;
  color: var(--text-3);
  letter-spacing: .04em;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 18px;
}

.nav-group-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
  padding: 4px 10px;
  margin-bottom: 4px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .14s;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover  { background: rgba(255,255,255,.05); color: var(--text-1); }
.nav-item.active { background: var(--blue-dim); color: var(--blue); font-weight: 600; }
.nav-item .nav-icon { flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-count {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.sidebar-user {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
}
.user-mc-face {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--s3);
  overflow: hidden;
  flex-shrink: 0;
}
.user-mc-face img { width: 100%; height: 100%; object-fit: cover; }
.user-name  { font-size: .85rem; font-weight: 600; line-height: 1.2; }
.user-role  { font-size: .68rem; color: var(--text-3); text-transform: capitalize; }
.user-role.owner   { color: var(--yellow); }
.user-role.admin   { color: var(--blue); }
.user-role.creator { color: var(--teal); }

.sign-out-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--red);
  width: 100%;
  text-align: left;
  transition: background .14s;
}
.sign-out-btn:hover { background: rgba(248,113,113,.08); }

/* ── Topbar ──────────────────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--s1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Content ─────────────────────────────────────────────────── */
.content {
  padding: 24px;
  flex: 1;
}

/* ── Panels ──────────────────────────────────────────────────── */
.panel { display: none; }
.panel.show { display: block; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  border: none;
}
.btn-primary { background: var(--blue); color: #05070F; }
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--text-1); border: 1px solid var(--border-hi); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost   { background: transparent; color: var(--text-2); }
.btn-ghost:hover   { background: rgba(255,255,255,.05); color: var(--text-1); }
.btn-danger  { background: rgba(248,113,113,.12); color: var(--red); border: 1px solid rgba(248,113,113,.2); }
.btn-danger:hover  { background: rgba(248,113,113,.2); }
.btn-teal    { background: var(--teal-dim); color: var(--teal); border: 1px solid rgba(56,229,191,.2); }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 11px 22px; font-size: .9rem; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title {
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 700;
}

/* ── Stat Grid ───────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 16px;
}
.stat-tile .val {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  display: block;
  line-height: 1;
}
.stat-tile .lbl {
  font-size: .72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-top: 6px;
  display: block;
}

/* ── Tags / Pills ────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-xs);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tag-open     { background: rgba(90,175,255,.1);   color: var(--blue); }
.tag-progress { background: rgba(252,211,77,.08);  color: var(--yellow); }
.tag-closed   { background: rgba(255,255,255,.05); color: var(--text-3); }
.tag-resolved { background: rgba(74,222,128,.1);   color: var(--green); }
.tag-owner    { background: rgba(252,211,77,.1);   color: var(--yellow); }
.tag-admin    { background: rgba(90,175,255,.1);   color: var(--blue); }
.tag-creator  { background: rgba(56,229,191,.1);   color: var(--teal); }
.tag-user     { background: rgba(255,255,255,.05); color: var(--text-3); }
.tag-new      { background: rgba(90,175,255,.1);   color: var(--blue); }
.tag-fix      { background: rgba(74,222,128,.1);   color: var(--green); }
.tag-impr     { background: rgba(252,211,77,.08);  color: var(--yellow); }
.tag-rem      { background: rgba(248,113,113,.1);  color: var(--red); }
.tag-sec      { background: rgba(167,139,250,.1);  color: var(--purple); }

/* ── Table ───────────────────────────────────────────────────── */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  background: var(--s2);
  padding: 10px 14px;
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  font-size: .82rem;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .75rem; font-weight: 600; color: var(--text-2); }
.form-control {
  background: var(--s2);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: .84rem;
  font-family: var(--font-ui);
  transition: border-color .15s;
  width: 100%;
}
.form-control:focus { border-color: var(--blue); }
.form-control::placeholder { color: var(--text-3); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

/* ── Modal ───────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  transform: scale(.96) translateY(8px);
  transition: transform .2s;
}
.overlay.show .modal { transform: scale(1) translateY(0); }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; }
.modal-close {
  padding: 4px;
  color: var(--text-3);
  transition: color .14s;
  cursor: pointer;
  background: none;
  border: none;
}
.modal-close:hover { color: var(--text-1); }

/* ── Message thread ──────────────────────────────────────────── */
.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px 0;
  margin-bottom: 14px;
}
.msg {
  padding: 10px 13px;
  border-radius: var(--r-md);
  max-width: 88%;
}
.msg-user  { background: var(--s2); border: 1px solid var(--border); align-self: flex-start; }
.msg-staff { background: var(--blue-dim); border: 1px solid rgba(90,175,255,.18); align-self: flex-end; }
.msg-who   { font-size: .68rem; font-weight: 700; margin-bottom: 3px; color: var(--text-3); }
.msg-staff .msg-who { color: var(--blue); text-align: right; }
.msg-body  { font-size: .84rem; line-height: 1.55; }
.msg-time  { font-size: .65rem; color: var(--text-3); margin-top: 3px; }
.msg-staff .msg-time { text-align: right; }

/* ── Earnings row ────────────────────────────────────────────── */
.earnings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--s2);
  margin-bottom: 8px;
  gap: 12px;
  flex-wrap: wrap;
}
.earnings-row .er-user { display: flex; align-items: center; gap: 9px; }
.earnings-row .er-mc   { width: 26px; height: 26px; border-radius: 5px; background: var(--s3); overflow: hidden; flex-shrink: 0; }
.earnings-row .er-mc img { width: 100%; height: 100%; object-fit: cover; }
.earnings-row .er-name { font-size: .85rem; font-weight: 600; }
.earnings-row .er-type { font-size: .72rem; color: var(--text-3); }
.earnings-row .er-amount { font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; color: var(--green); white-space: nowrap; }
.earnings-edit-wrap { display: flex; gap: 6px; align-items: center; }
.earnings-edit-wrap input { width: 90px; padding: 5px 8px; font-size: .82rem; }

/* ── Cape upload card ────────────────────────────────────────── */
.cape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.cape-card {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color .15s;
}
.cape-card:hover { border-color: var(--border-hi); }
.cape-thumb {
  aspect-ratio: 2/3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.cape-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cape-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--s3);
}
.cape-info { padding: 10px 12px; }
.cape-info .cn { font-size: .82rem; font-weight: 600; margin-bottom: 2px; }
.cape-info .cp { font-size: .72rem; color: var(--text-3); }
.cape-actions { display: flex; gap: 4px; padding: 0 8px 8px; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 24px;
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  opacity: .15;
}
.empty-title { font-family: var(--font-display); font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.empty-body  { font-size: .84rem; color: var(--text-3); max-width: 320px; margin: 0 auto; }

/* ── Alert ───────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: .82rem;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid;
}
.alert-err  { background: rgba(248,113,113,.09); border-color: rgba(248,113,113,.22); color: var(--red); }
.alert-info { background: var(--blue-dim); border-color: rgba(90,175,255,.22); color: var(--blue); }
.alert-ok   { background: rgba(74,222,128,.09); border-color: rgba(74,222,128,.22); color: var(--green); }

/* ── Spinner ─────────────────────────────────────────────────── */
.spin {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: rot .65s linear infinite;
  display: inline-block;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-rack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--border-hi);
  box-shadow: var(--shadow);
  font-size: .82rem;
  animation: slide-up .25s cubic-bezier(.4,0,.2,1);
  pointer-events: auto;
  min-width: 240px;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page-level auth screens ─────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-box {
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  margin: 0 auto 20px;
  object-fit: contain;
}
.auth-logo-fallback {
  width: 52px;
  height: 52px;
  background: var(--blue);
  border-radius: 12px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.auth-sub {
  color: var(--text-2);
  font-size: .875rem;
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ── Changelog editor ────────────────────────────────────────── */
.change-rows { display: flex; flex-direction: column; gap: 7px; }
.change-row  { display: flex; gap: 7px; align-items: center; }
.change-row select { width: 80px; flex-shrink: 0; padding: 7px 8px; font-size: .78rem; }
.change-row input  { flex: 1; }
.change-row button { padding: 7px 9px; flex-shrink: 0; }

/* ── Inline number edit ──────────────────────────────────────── */
.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.inline-edit input {
  width: 80px;
  padding: 4px 8px;
  font-size: .82rem;
  border-radius: var(--r-sm);
}

/* ── Misc helpers ────────────────────────────────────────────── */
.flex     { display: flex; }
.fcol     { flex-direction: column; }
.fwrap    { flex-wrap: wrap; }
.gap-1    { gap: 6px; }
.gap-2    { gap: 10px; }
.gap-3    { gap: 14px; }
.gap-4    { gap: 18px; }
.aicenter { align-items: center; }
.jbetween { justify-content: space-between; }
.jend     { justify-content: flex-end; }
.mt-2     { margin-top: 8px; }
.mt-3     { margin-top: 12px; }
.mt-4     { margin-top: 18px; }
.mb-3     { margin-bottom: 12px; }
.mb-4     { margin-bottom: 18px; }
.w-full   { width: 100%; }
.hidden   { display: none !important; }
.text-sm  { font-size: .78rem; }
.text-muted { color: var(--text-3); }
.mono     { font-family: var(--font-mono); }

/* ── Mobile ──────────────────────────────────────────────────── */
.burger {
  display: none;
  padding: 6px;
  color: var(--text-2);
  cursor: pointer;
}
@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-area { margin-left: 0; }
  .burger { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr; }
}
