/*
 * Bad Crew — dashboard theme.
 *
 * Deliberately built on the Bad Mickey homepage tokens (same off-black, same
 * #ff2020 red, same heavy uppercase display treatment, same Arial body stack) so
 * the member app reads as one product with the main site rather than a bolt-on.
 * Everything below is additive: the homepage keeps its own inline styles.
 */

:root {
  --bg: #070707;
  --panel: #111111;
  --panel-2: #181818;
  --text: #f4f4f4;
  --muted: #aaaaaa;
  --dim: #7d7d7d;
  --red: #ff2020;
  --red-dark: #7a0000;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);
  --ok: #63d493;
  --ok-bg: rgba(99, 212, 147, 0.12);
  --warn: #f0b429;
  --warn-bg: rgba(240, 180, 41, 0.12);
  --bad-bg: rgba(255, 32, 32, 0.12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 70% 10%, rgba(255, 32, 32, 0.12), transparent 30%),
    linear-gradient(180deg, #050505 0%, #0b0b0b 100%);
  background-attachment: fixed;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Fixed grain layer — never inside a scrolling container. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.container { width: min(1240px, calc(100% - 36px)); margin: auto; position: relative; z-index: 1; }

/* ---------- Navigation (mirrors the homepage bar) ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 7, 0.88);
  backdrop-filter: blur(12px);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 20px;
}
.brand { font-weight: 900; letter-spacing: 2px; font-size: 1.15rem; white-space: nowrap; }
.brand span { color: var(--red); }
.links { display: flex; gap: 20px; color: #ddd; font-size: 0.95rem; align-items: center; }
.links a:hover { color: #fff; }
.links a.here { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  text-align: center;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 0 34px rgba(255, 32, 32, 0.24); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 44px rgba(255, 32, 32, 0.34); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 9px 13px; font-size: 0.8rem; border-radius: 8px; }
/**
 * Destructive actions.
 *
 * The colour is a warning, not the message: every destructive control also says
 * what it does in words, and the delete flow states the member's details, so the
 * meaning survives for anyone who cannot see the red.
 */
.btn.danger {
  background: var(--bad-bg);
  border-color: rgba(255, 32, 32, 0.55);
  color: #ff6a6a;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.btn.danger:hover:not(:disabled) { background: rgba(255, 32, 32, 0.2); border-color: var(--red); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.wallet-choice { min-width: min(100%, 220px); justify-content: center; }

/* ---------- Type ---------- */
.eyebrow {
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 800;
  font-size: 0.74rem;
}
.eyebrow.quiet { color: var(--dim); }
h1, h2, h3 { text-transform: uppercase; letter-spacing: -1.5px; margin: 0; line-height: 0.95; }
.page-title { font-size: clamp(2.6rem, 6.5vw, 4.6rem); letter-spacing: -3px; margin: 12px 0 14px; }
.panel-title { font-size: 1.28rem; letter-spacing: -0.5px; }
.lede { color: #c5c5c5; font-size: 1.06rem; max-width: 62ch; margin: 0; }
.muted { color: var(--muted); }
.tiny { font-size: 0.78rem; color: var(--dim); line-height: 1.5; }
.mono { font-family: var(--mono); }

/* ---------- Cards & layout ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  padding: 26px;
  position: relative;
  z-index: 1;
}
.card.tight { padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.stack { display: grid; gap: 18px; }
.cols { display: grid; gap: 18px; }
.cols.two { grid-template-columns: 1fr 1fr; }
.cols.side { grid-template-columns: 1.25fr 0.75fr; }
section.block { padding: 34px 0; }
.divider { height: 1px; background: var(--line); margin: 20px 0; border: 0; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--ok); background: var(--ok-bg); border-color: rgba(99, 212, 147, 0.32); }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(240, 180, 41, 0.32); }
.chip.bad { color: var(--red); background: var(--bad-bg); border-color: rgba(255, 32, 32, 0.34); }

/* ---------- Identity strip ---------- */
.identity { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.identity > div { background: #0d0d0d; padding: 18px 20px; display: grid; gap: 8px; align-content: start; }
.identity .label { font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
.identity .value { font-weight: 800; font-size: 1rem; overflow-wrap: anywhere; }

/* ---------- Badge artwork ----------
 *
 * The supplied badge illustrations are the centrepiece of every badge card, in
 * all three states. A locked badge is darkened and padlocked but deliberately
 * still legible — a member has to be able to see what they are working toward.
 *
 * Status is never carried by the filter alone: `.badge-art-status` prints the
 * word (LOCKED / WALLET REQUIREMENT MET / EARNED) next to every frame.
 */
.badge-art { display: grid; gap: 8px; justify-items: stretch; width: 100%; max-width: 168px; }
.badge-art.xs { max-width: 64px; }
.badge-art.sm { max-width: 118px; }
.badge-art.md { max-width: 168px; }
.badge-art.lg { max-width: 264px; }

.badge-art-frame {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #080808;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
/* Portraits are 2:3; a 3:4 frame trims the empty top and bottom, never the face. */
.badge-art.portrait .badge-art-frame { aspect-ratio: 3 / 4; }
/*
 * The Bad Crew group artwork is landscape and must keep all five characters, so
 * its frame is wide and its image is letterboxed rather than cropped.
 */
.badge-art.landscape .badge-art-frame { aspect-ratio: 16 / 9; }
/*
 * In the rail and in roster rows the cards must line up, so those two sizes use
 * one frame shape for all five badges. The landscape group image keeps
 * `object-fit: contain`, so it letterboxes inside the taller frame instead of
 * losing characters to a crop.
 */
.badge-art.sm .badge-art-frame { aspect-ratio: 3 / 4; }
.badge-art.xs .badge-art-frame { aspect-ratio: 1 / 1; }

.badge-art-img {
  display: block;
  width: 100%;
  height: 100%;
  /* object-fit / object-position come from shared/badge-art.mjs per image. */
  transition: filter 0.3s ease, opacity 0.3s ease;
}
.badge-art-missing { display: block; width: 100%; height: 100%; background: repeating-linear-gradient(45deg, #111 0 10px, #0d0d0d 10px 20px); }

.badge-art-tier {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #f4f4f4;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.badge-art-lock {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.badge-art-lock svg { display: block; }

.badge-art-status { display: grid; gap: 2px; text-align: center; }
.badge-art-state { font-size: 0.62rem; font-weight: 900; letter-spacing: 1.6px; text-transform: uppercase; }
.badge-art-hint { font-size: 0.58rem; letter-spacing: 0.8px; text-transform: uppercase; color: var(--dim); }
.badge-art.lg .badge-art-state { font-size: 0.74rem; letter-spacing: 2.2px; }
.badge-art.lg .badge-art-hint { font-size: 0.66rem; }

/* State 1 — requirements not met. Dimmed, padlocked, still visible. */
.badge-art.locked .badge-art-img { filter: grayscale(0.85) brightness(0.4) contrast(1.05); }
.badge-art.locked .badge-art-frame { border-color: var(--line); }
.badge-art.locked .badge-art-state { color: var(--dim); }

/*
 * State 2 — wallet/token requirements met, Telegram not verified. Brighter than
 * locked so progress is visible, but amber and padlocked: this badge is NOT
 * earned and must never read as if it were.
 */
.badge-art.awaiting-telegram .badge-art-img { filter: grayscale(0.28) brightness(0.76); }
.badge-art.awaiting-telegram .badge-art-frame {
  border-color: rgba(240, 180, 41, 0.55);
  box-shadow: 0 0 22px rgba(240, 180, 41, 0.16);
}
.badge-art.awaiting-telegram .badge-art-state { color: var(--warn); }
.badge-art.awaiting-telegram .badge-art-hint { color: var(--warn); }

/* State 3 — earned. Full colour, full brightness, and it looks like a trophy. */
.badge-art.earned .badge-art-img { filter: none; }
.badge-art.earned .badge-art-frame {
  border-color: rgba(255, 32, 32, 0.62);
  box-shadow: 0 0 34px rgba(255, 32, 32, 0.26), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.badge-art.earned .badge-art-state { color: var(--red); }
.badge-art.earned .badge-art-hint { color: var(--muted); }
.badge-art.earned.current .badge-art-frame {
  border-color: var(--red);
  box-shadow: 0 0 52px rgba(255, 32, 32, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.node:hover .badge-art.earned .badge-art-frame { transform: translateY(-2px); }

.badge-hero { display: grid; grid-template-columns: 264px 1fr; gap: 30px; align-items: center; }
.badge-hero .tier-label { font-size: 0.74rem; letter-spacing: 3px; text-transform: uppercase; color: var(--red); font-weight: 800; }
.badge-hero .badge-name { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -2px; margin: 8px 0 6px; }
.badge-hero .tagline { color: var(--muted); font-style: italic; }

/* Badge artwork leads the per-badge detail card. */
.tier-detail-head { display: grid; grid-template-columns: 168px 1fr; gap: 22px; align-items: center; }

/* ---------- Meters ---------- */
.meter { height: 8px; border-radius: 999px; background: #1c1c1c; overflow: hidden; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--red-dark), var(--red)); border-radius: 999px; transform-origin: left center; transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.meter.done > span { background: linear-gradient(90deg, #2f7f52, var(--ok)); }
.meter.lg { height: 12px; }

/* ---------- Requirement rows ---------- */
.req-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; padding: 16px 0; border-bottom: 1px dashed var(--line); }
.req-row:last-child { border-bottom: 0; padding-bottom: 0; }
.req-row .req-name { font-weight: 800; letter-spacing: 0.4px; }
.req-row .req-src { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1.4px; color: var(--dim); margin-top: 3px; }
.req-row .req-amount { font-family: var(--mono); font-size: 0.92rem; text-align: right; white-space: nowrap; }
.req-row .req-meter { grid-column: 1 / -1; }
.req-row.met .req-amount { color: var(--ok); }

/* ---------- Progression rail ---------- */
.rail { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; position: relative; }
.rail::before {
  content: "";
  position: absolute;
  top: 46px;
  left: 8%;
  right: 8%;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 10px, transparent 10px 20px);
  z-index: 0;
}
.node {
  position: relative;
  z-index: 1;
  background: #0d0d0d;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 14px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.node:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.node:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.node .node-name { font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.92rem; }
.node .node-req { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }
.node.locked { opacity: 0.5; }
.node.unlocked { border-color: rgba(255, 32, 32, 0.35); background: linear-gradient(180deg, rgba(255, 32, 32, 0.07), rgba(255, 32, 32, 0.01)); }
.node.current { border-color: var(--red); box-shadow: 0 0 40px rgba(255, 32, 32, 0.2); }
.node.selected { border-color: #fff; }
.node .node-tier { font-size: 0.66rem; letter-spacing: 2px; color: var(--dim); text-transform: uppercase; }

/* ---------- Perk lists ---------- */
.perks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.perks li { display: grid; grid-template-columns: 18px 1fr; gap: 12px; align-items: start; color: #cfcfcf; font-size: 0.95rem; }
.perks li svg { margin-top: 3px; flex: none; }
.perks li.off { color: var(--dim); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #0d0d0d; display: grid; gap: 6px; }
.stat .stat-label { font-size: 0.68rem; letter-spacing: 1.8px; text-transform: uppercase; color: var(--dim); }
.stat .stat-value { font-size: 1.7rem; font-weight: 900; letter-spacing: -1px; line-height: 1; }
.stat .stat-value.red { color: var(--red); }
.stat .stat-note { font-size: 0.74rem; color: var(--dim); }

/* ---------- Inputs ---------- */
label.field { display: grid; gap: 7px; font-size: 0.72rem; letter-spacing: 1.6px; text-transform: uppercase; color: var(--dim); }
input, select, textarea {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid #2e2e2e;
  color: var(--text);
  padding: 13px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); }
.input-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.input-row > label.field { flex: 1 1 180px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }

/* ---------- Compact admin workspaces ---------- */
.admin-intro { padding-top: 44px; padding-bottom: 18px; }
.admin-title { margin: 8px 0 6px; font-size: clamp(1.6rem, 4vw, 2.25rem); }
.admin-intro-copy { margin: 0; }
.admin-switcher-wrap { position: sticky; top: 72px; z-index: 25; padding-bottom: 14px; }
.admin-switcher { background: rgba(14, 14, 14, 0.97); box-shadow: 0 16px 35px rgba(0,0,0,.45); }
.admin-switcher .input-row { align-items: center; }
.admin-section-field { flex: 1 1 330px !important; }
.admin-status { margin-top: 6px; color: var(--dim); }
.admin-section { padding-bottom: 28px; scroll-margin-top: 190px; }
.admin-member-table { max-height: min(52vh, 620px); overflow: auto; }
[data-admin-section][hidden] { display: none !important; }

@media (max-width: 720px) {
  .admin-intro { padding-top: 28px; }
  .admin-switcher-wrap { top: 62px; }
  .admin-switcher .input-row > div { width: 100%; }
  .admin-member-table { max-height: 48vh; }
}

/* ---------- Code / callouts ---------- */
.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 0 12px 12px 0;
  padding: 16px 18px;
}
.code-box .code { font-family: var(--mono); font-size: 1.16rem; letter-spacing: 2px; font-weight: 700; overflow-wrap: anywhere; }
.callout { border-left: 3px solid var(--red); background: rgba(255, 32, 32, 0.06); padding: 15px 18px; border-radius: 0 12px 12px 0; color: #c9c9c9; font-size: 0.9rem; }
.callout.quiet { border-left-color: #3a3a3a; background: rgba(255, 255, 255, 0.03); }

/* ---------- Admin danger zone ---------- */
.danger-zone { border-color: rgba(255, 32, 32, 0.42); box-shadow: inset 0 0 0 1px rgba(255, 32, 32, 0.08); }
.danger-confirm { border-left-width: 5px; background: rgba(255, 32, 32, 0.1); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; min-width: 900px; }
th, td { text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 0.68rem; letter-spacing: 1.6px; text-transform: uppercase; color: var(--dim); background: #0d0d0d; position: sticky; top: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
tbody tr.selected { background: rgba(255, 32, 32, 0.08); }
td .sub { display: block; font-size: 0.74rem; color: var(--dim); }

/* ---------- Skeleton loading ---------- */
.skeleton { border-radius: 10px; background: linear-gradient(90deg, #131313 25%, #1c1c1c 37%, #131313 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton.line { height: 13px; margin-bottom: 10px; }
.skeleton.block { height: 150px; }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: grid; gap: 10px; max-width: min(380px, calc(100% - 44px)); }
.toast {
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--red);
  background: #131313;
  padding: 14px 16px;
  border-radius: 0 12px 12px 0;
  font-size: 0.9rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Reveal on load ---------- */
.reveal { animation: reveal 0.5s both cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

footer.site-footer { border-top: 1px solid var(--line); padding: 30px 0 46px; color: #8f8f8f; font-size: 0.88rem; margin-top: 30px; }
.footer-inner { display: flex; justify-content: space-between; gap: 26px; flex-wrap: wrap; }

@media (max-width: 1080px) {
  .cols.side, .cols.two { grid-template-columns: 1fr; }
  .rail { grid-template-columns: repeat(2, 1fr); }
  .rail::before { display: none; }
}

@media (max-width: 720px) {
  .links { gap: 14px; font-size: 0.85rem; }
  .links .hide-sm { display: none; }
  .identity { grid-template-columns: 1fr; }
  .badge-hero { grid-template-columns: 1fr; justify-items: start; gap: 18px; }
  .badge-art.lg { max-width: 220px; }
  .tier-detail-head { grid-template-columns: 1fr; gap: 16px; }
  .tier-detail-head .badge-art { max-width: 190px; }
  .rail { grid-template-columns: 1fr; }
  .rail .badge-art.sm { max-width: 150px; }
  .card { padding: 20px; }
  .page-title { letter-spacing: -2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
