/* ── CJM Studios Admin Portal ───────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #050607;
  --panel: rgba(255,255,255,0.025);
  --border: rgba(255,255,255,0.07);
  --border-soft: rgba(255,255,255,0.05);
  --text: #f4f6f7;
  --muted: rgba(255,255,255,0.38);
  --faint: rgba(255,255,255,0.2);
  --cyan: #06b6d4;
  --cyan-bright: #22d3ee;
  --cyan-soft: rgba(6,182,212,0.1);
  --cyan-border: rgba(6,182,212,0.25);
  --red: #ef4444;
  --green: #34d399;
  --amber: #fbbf24;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(ellipse 70% 40% at 50% -10%, rgba(6,182,212,0.06) 0%, transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(6,182,212,0.4); }

:focus-visible { outline: 2px solid var(--cyan-border); outline-offset: 2px; border-radius: 6px; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 300; }
.pad { padding: 18px 22px; line-height: 1.7; }
code {
  font-family: 'Cascadia Code', Consolas, monospace;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12.5px;
  color: var(--cyan-bright);
}

/* ── Brand ──────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; display: block;
  box-shadow: 0 0 24px rgba(6,182,212,0.45);
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); margin-top: 1px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; padding: 11px 20px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.18s ease;
  border: 1px solid transparent;
}
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #fff;
  box-shadow: 0 4px 24px rgba(6,182,212,0.3);
}
.btn-primary:hover { filter: brightness(1.15); box-shadow: 0 4px 32px rgba(6,182,212,0.5); transform: translateY(-1px); }
.btn-ghost {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
  color: rgba(255,255,255,0.65);
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: #fff; }
.btn-link {
  background: none; border: none; color: var(--cyan-bright);
  font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }
.btn:disabled { opacity: 0.5; cursor: wait; }

/* ── Login ──────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.login-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 45% at 50% 38%, rgba(6,182,212,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative; width: 100%; max-width: 400px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 36px;
  box-shadow: 0 0 80px rgba(6,182,212,0.06);
}
.login-card .brand { margin-bottom: 34px; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.login-card .muted { font-size: 13px; line-height: 1.6; margin-bottom: 26px; }
.login-card input {
  width: 100%; padding: 13px 16px; margin-bottom: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: #fff;
  font-size: 14px; font-weight: 500;
  font-family: inherit;
  outline: none; transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--cyan-border); }
#login-code {
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 15px; font-weight: 600; letter-spacing: 0.08em;
}
.mode-toggle { display: block; margin-top: 18px; }
.error { color: var(--red); font-size: 12.5px; margin-top: 14px; }
.fineprint { color: var(--faint); font-size: 11px; margin-top: 22px; line-height: 1.6; }

/* ── App layout ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0;
  border-right: 1px solid var(--border-soft);
  padding: 26px 18px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  background: rgba(255,255,255,0.012);
}
.sidebar .brand { padding: 0 8px; margin-bottom: 34px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(255,255,255,0.18);
  padding: 16px 14px 6px;
}
.nav-label:first-child { padding-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13.5px; font-weight: 500; font-family: inherit;
  transition: all 0.15s ease; text-align: left;
}
.nav-item svg {
  width: 17px; height: 17px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--cyan-bright);
  background: var(--cyan-soft);
}
.badge {
  margin-left: auto;
  background: var(--cyan); color: #000;
  font-size: 10px; font-weight: 800;
  border-radius: 999px; min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer { display: flex; flex-direction: column; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-soft);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(6,182,212,0.35), rgba(6,182,212,0.12));
  border: 1px solid var(--cyan-border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--cyan-bright);
}
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 1px; }

.main { flex: 1; padding: 40px 44px 80px; min-width: 0; }
.page { max-width: 1000px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 28px;
}
.page-head h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 5px; }
.page-head .muted { font-size: 13px; }

/* ── Stats ──────────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 26px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 16px; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card.accent { border-color: var(--cyan-border); background: rgba(6,182,212,0.04); box-shadow: 0 0 40px rgba(6,182,212,0.05); }
.stat-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 27px; font-weight: 800; letter-spacing: -0.03em; }
.stat-card.accent .stat-value { color: var(--cyan-bright); }

/* ── Panels ─────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  margin-bottom: 22px;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-head h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }

/* ── Purchase rows ──────────────────────────────────────────── */
.purchase-list { display: flex; flex-direction: column; }
.purchase-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(140px, 1fr) 90px 110px 110px;
  gap: 14px; align-items: center;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.15s;
}
.purchase-row:last-child { border-bottom: none; }
.purchase-row:hover { background: rgba(255,255,255,0.02); }
.purchase-row.flash { animation: rowflash 2.4s ease; }
@keyframes rowflash {
  0% { background: rgba(6,182,212,0.18); }
  100% { background: transparent; }
}
.p-item { font-weight: 600; font-size: 13.5px; }
.p-sub { color: var(--faint); font-size: 11px; margin-top: 3px; font-weight: 400; }
.p-buyer { font-size: 12.5px; color: rgba(255,255,255,0.6); overflow: hidden; text-overflow: ellipsis; }
.p-amount { font-weight: 700; font-size: 14px; text-align: right; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 999px; padding: 4px 11px;
}
.pill.new { background: rgba(6,182,212,0.12); border: 1px solid var(--cyan-border); color: var(--cyan-bright); }
.pill.delivered { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--green); }
.pill.test { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: var(--amber); }
.p-action button { white-space: nowrap; padding: 7px 13px; font-size: 11.5px; border-radius: 8px; }

.empty {
  padding: 44px 22px; text-align: center;
  color: var(--faint); font-size: 13px; font-weight: 300;
}
.empty.tall { padding: 72px 40px; }
.empty.tall p { max-width: 420px; margin: 0 auto 8px; line-height: 1.7; }
.empty.tall strong { color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 14px; opacity: 0.7; }

/* ── Filters ────────────────────────────────────────────────── */
.filter-row { display: flex; gap: 8px; }
.chip {
  padding: 7px 16px; border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.chip:hover { color: #fff; }
.chip.active {
  background: var(--cyan-soft);
  border-color: var(--cyan-border);
  color: var(--cyan-bright);
}

/* ── Access codes ───────────────────────────────────────────── */
.code-form {
  display: flex; gap: 12px; padding: 20px 22px; flex-wrap: wrap;
}
.code-form input, .code-form select {
  padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: #fff;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.code-form input { flex: 1; min-width: 220px; }
.code-form input:focus, .code-form select:focus { border-color: var(--cyan-border); }
.code-form select { cursor: pointer; }
.code-form select option { background: #111; }

.code-reveal {
  margin: 0 22px 20px;
  padding: 16px 18px;
  background: rgba(6,182,212,0.06);
  border: 1px dashed var(--cyan-border);
  border-radius: 12px;
}
.code-reveal p { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.code-line { display: flex; align-items: center; gap: 12px; }
.code-line code { font-size: 17px; font-weight: 700; padding: 8px 14px; letter-spacing: 0.1em; }

.codes-list { display: flex; flex-direction: column; }
.code-row {
  display: grid;
  grid-template-columns: 1.5fr 100px 150px 150px 90px;
  gap: 14px; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.code-row:last-child { border-bottom: none; }
.code-row .muted { font-size: 12px; }
.code-row.revoked { opacity: 0.4; }
.role-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--cyan-bright);
}
.btn-danger {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #f87171;
  padding: 6px 13px; font-size: 11.5px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-family: inherit;
  transition: all 0.15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.16); }

/* ── Tickets ────────────────────────────────────────────────── */
.ticket-list { display: flex; flex-direction: column; }
.ticket-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 120px 100px;
  gap: 14px; align-items: center;
  padding: 15px 22px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border-soft);
  cursor: pointer; text-align: left; font-family: inherit; color: var(--text);
  transition: background 0.15s;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: rgba(6,182,212,0.04); }
.t-subject { font-weight: 600; font-size: 13.5px; }
.t-subject.big { font-size: 17px; letter-spacing: -0.02em; }
.t-preview {
  color: var(--faint); font-size: 12px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px;
}
.t-player { font-size: 12.5px; color: rgba(255,255,255,0.55); }
.t-time { font-size: 11.5px; color: var(--faint); }

.ticket-head {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.ticket-head-info { flex: 1; min-width: 0; }
.t-meta { font-size: 12px; margin-top: 4px; }

.thread {
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px; max-height: 480px; overflow-y: auto;
}
.msg { max-width: 78%; }
.msg.player { align-self: flex-start; }
.msg.staff { align-self: flex-end; text-align: right; }
.msg-head { font-size: 11px; color: var(--faint); margin-bottom: 5px; }
.msg-text {
  display: inline-block; text-align: left;
  padding: 11px 15px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.player .msg-text {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.staff .msg-text {
  background: rgba(6,182,212,0.1);
  border: 1px solid var(--cyan-border);
  border-bottom-right-radius: 4px;
}

.reply-box {
  display: flex; gap: 12px; align-items: flex-end;
  padding: 18px 22px;
  border-top: 1px solid var(--border-soft);
}
.reply-box textarea {
  flex: 1; min-height: 64px; max-height: 180px; resize: vertical;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; color: #fff;
  font-size: 13.5px; font-family: inherit; line-height: 1.6;
  outline: none; transition: border-color 0.2s;
}
.reply-box textarea:focus { border-color: var(--cyan-border); }
.reply-box.locked {
  justify-content: space-between;
  background: rgba(255,255,255,0.015);
}
.reply-locked-note { font-size: 12.5px; color: var(--muted); }

.forward-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.015);
  font-size: 12.5px;
}
.forward-select {
  flex: 0 1 320px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: #fff;
  font-size: 12.5px; font-family: inherit; outline: none; cursor: pointer;
}
.forward-select optgroup, .forward-select option { background: #111; }
.forward-bar .btn { padding: 8px 16px; font-size: 12px; }

.msg.system {
  align-self: center; max-width: 100%;
  font-size: 11px; color: var(--faint);
  padding: 4px 14px; text-align: center;
  border: 1px dashed var(--border);
  border-radius: 999px;
}

.box-accent .panel-head h3 { color: var(--cyan-bright); }

.reply-controls { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.note-toggle {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted); cursor: pointer; user-select: none;
  white-space: nowrap;
}
.note-toggle input { accent-color: var(--amber); cursor: pointer; }
.msg.staff.note .msg-text {
  background: rgba(251,191,36,0.07);
  border: 1px dashed rgba(251,191,36,0.35);
}
.msg.staff.note .msg-head { color: var(--amber); }

/* ── Bans ───────────────────────────────────────────────────── */
.ban-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; padding: 20px 22px;
}
.ban-form input, .ban-form select {
  padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: #fff;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.ban-form input:focus, .ban-form select:focus { border-color: var(--cyan-border); }
.ban-form select option { background: #111; }
.ban-form .ban-reason { grid-column: 1 / 3; }
.ban-form button { grid-column: 4; }

.ban-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) minmax(140px, 1.4fr) 170px 150px 90px;
  gap: 14px; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.ban-row:last-child { border-bottom: none; }
.ban-row.revoked { opacity: 0.45; }
.ban-reason-cell {
  color: rgba(255,255,255,0.55); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill.perm { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.35); color: #f87171; }

.search-input {
  padding: 8px 14px; width: 240px; max-width: 50vw;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px; color: #fff;
  font-size: 12.5px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--cyan-border); }

/* ── Audit log ──────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; max-height: 640px; overflow-y: auto; }
.audit-row {
  display: grid;
  grid-template-columns: 130px 130px 160px 1fr;
  gap: 14px; align-items: baseline;
  padding: 11px 22px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.audit-row:last-child { border-bottom: none; }
.audit-action {
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 11.5px; color: var(--cyan-bright);
}
.audit-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Settings ───────────────────────────────────────────────── */
.status-list { display: flex; flex-direction: column; }
.status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 22px; border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.status-row:last-child { border-bottom: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 9px; }
.dot.on { background: var(--green); box-shadow: 0 0 10px rgba(52,211,153,0.6); }
.dot.off { background: rgba(255,255,255,0.15); }
.setup-steps { padding: 20px 22px 20px 42px; display: flex; flex-direction: column; gap: 12px; font-size: 13.5px; line-height: 1.6; color: rgba(255,255,255,0.6); }

/* ── Toasts ─────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: #0c0e10;
  border: 1px solid var(--cyan-border);
  border-radius: 14px; padding: 15px 18px;
  min-width: 280px; max-width: 360px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 30px rgba(6,182,212,0.12);
  animation: toastin 0.35s cubic-bezier(.22,1,.36,1);
}
@keyframes toastin { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateX(30px); transition: all 0.3s ease; }
.toast-icon { font-size: 18px; line-height: 1.3; }
.toast-title { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.toast-body { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: column; padding: 18px;
  }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .main { padding: 24px 18px 60px; }
  .purchase-row { grid-template-columns: 1fr auto; grid-auto-rows: auto; }
  .p-buyer, .p-amount { text-align: left; }
  .code-row { grid-template-columns: 1fr auto; }
  .code-row .muted { display: none; }
  .ban-form { grid-template-columns: 1fr 1fr; }
  .ban-form .ban-reason { grid-column: 1 / 3; }
  .ban-form button { grid-column: 1 / 3; }
  .ban-row { grid-template-columns: 1fr auto; }
  .ban-row .muted, .ban-reason-cell { display: none; }
  .audit-row { grid-template-columns: auto 1fr; }
  .audit-detail { display: none; }
  .nav-label { display: none; }
}
