/* ============================================================
   THEME — AI Creator Lab brand kit
   Fonts: Hanken Grotesk + Space Mono · near-black / cream / mint
   ============================================================ */
:root {
  --bg:           #050706;   /* brand near-black (green-tinted) */
  --bg-2:         #080b09;
  --surface:      #0d110e;
  --surface-2:    #131813;
  --border:       #20281f;
  --border-soft:  #181f17;

  --text:         #e9e7e2;   /* brand cream */
  --text-dim:     #a7ac9f;
  --muted:        #6f7568;

  --brand:        #88d58d;   /* brand mint green */
  --brand-deep:   #3e7c4b;
  --brand-bright: #a8e8ac;

  --low:          #d8d2c4;   /* low ticket → warm cream */
  --high:         #88d58d;   /* high ticket / AI Creator Lab → mint */
  --both:         #5fc16a;   /* overlap → vivid green */
  --convert:      #e4b363;   /* conversions / lead → warm gold highlight */

  --radius:       16px;
  --radius-sm:    11px;
  --font:         "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:         "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --shadow:       0 18px 48px -20px rgba(0,0,0,.85);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 520px at 84% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 68%),
    radial-gradient(760px 460px at 6% 4%, color-mix(in srgb, var(--brand-deep) 16%, transparent), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

/* ---------- topbar ---------- */
.topbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  height: 42px; width: 42px; border-radius: 11px; flex: none;
  object-fit: cover; display: block;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-family: var(--mono); font-size: 10.5px; color: var(--brand); letter-spacing: .18em; text-transform: uppercase; }
.updated { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.updated .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 10px var(--brand); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.wrap { position: relative; z-index: 1; width: 100%; max-width: none; margin: 0; padding: 28px clamp(20px, 3.5vw, 56px) 64px; }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.logout-btn {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 16px; cursor: pointer; transition: all .15s ease;
}
.logout-btn:hover { color: var(--bg); background: var(--brand); border-color: var(--brand); }

/* ---------- KPI cards ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.card {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow);
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-c, var(--brand));
}
.card[data-accent="high"]    { --accent-c: var(--high); }
.card[data-accent="low"]     { --accent-c: var(--low); }
.card[data-accent="both"]    { --accent-c: var(--both); }
.card[data-accent="convert"] { --accent-c: var(--convert); }
.card-label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.card-label em { font-family: var(--mono); color: var(--muted); font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.card-value { font-size: 42px; font-weight: 800; line-height: 1; letter-spacing: -1.5px; }
.card-foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-foot span { color: var(--text-dim); font-weight: 600; }
.card-hero { background: linear-gradient(160deg, color-mix(in srgb, var(--convert) 15%, var(--surface)), var(--bg-2)); }
.card-hero .card-value { color: var(--convert); }

/* ---------- panels ---------- */
.panels { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; margin-bottom: 18px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.panel-title { font-size: 14px; font-weight: 700; letter-spacing: .02em; margin-bottom: 18px; color: var(--text); }
.muted { color: var(--muted); font-weight: 500; }

/* donut */
.overlap { display: flex; align-items: center; gap: 26px; }
.donut-wrap { position: relative; width: 150px; height: 150px; flex: none; }
.donut { width: 150px; height: 150px; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 14; }
.donut-track { stroke: var(--border); }
.donut-seg { stroke-linecap: butt; transition: stroke-dasharray .8s cubic-bezier(.4,0,.2,1); }
.seg-low { stroke: var(--low); }
.seg-both { stroke: var(--both); }
.seg-high { stroke: var(--high); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-num { font-size: 30px; font-weight: 800; }
.donut-cap { font-family: var(--mono); font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .12em; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 13.5px; color: var(--text-dim); }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend b { color: var(--text); margin-left: auto; font-family: var(--mono); font-size: 12.5px; }
.swatch { width: 12px; height: 12px; border-radius: 4px; }
.sw-low { background: var(--low); } .sw-both { background: var(--both); } .sw-high { background: var(--high); }

/* lead indicator */
.panel-lead { display: flex; flex-direction: column; }
.lead { display: flex; flex-direction: column; gap: 22px; justify-content: center; flex: 1; }
.lead-figure { display: flex; align-items: baseline; gap: 16px; }
.lead-num { font-size: 64px; font-weight: 800; line-height: 1; color: var(--convert); letter-spacing: -2px; }
.lead-cap { font-size: 13.5px; color: var(--text-dim); max-width: 340px; }
.lead-bar { position: relative; height: 12px; border-radius: 999px; background: var(--border); }
.lead-bar-fill { height: 100%; border-radius: 999px; width: 0; background: linear-gradient(90deg, var(--convert), var(--brand)); transition: width 1s cubic-bezier(.4,0,.2,1); }
.lead-bar-label { display: block; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.lead-bar-label b { font-family: var(--mono); color: var(--convert); }

/* ---------- members ---------- */
.members-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.controls { display: flex; gap: 10px; }
#search, #filter {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13px; font-family: inherit; outline: none;
}
#search { width: 220px; }
#search:focus, #filter:focus { border-color: var(--brand); }
.table-wrap { overflow: auto; max-height: 560px; border-radius: var(--radius-sm); }

/* ---------- custom scrollbars (replace browser default) ---------- */
.table-wrap, .recent-list { scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent; }
.table-wrap::-webkit-scrollbar, .recent-list::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-track, .recent-list::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb, .recent-list::-webkit-scrollbar-thumb {
  background: var(--surface-2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
.table-wrap::-webkit-scrollbar-thumb:hover, .recent-list::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--brand) 55%, var(--surface-2)); background-clip: padding-box;
}
.table-wrap::-webkit-scrollbar-corner, .recent-list::-webkit-scrollbar-corner { background: transparent; }
table.members { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.members thead th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--text-dim);
  text-align: left; font-family: var(--mono); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  padding: 11px 14px; z-index: 1;
}
.members tbody td { padding: 9px 14px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.members tbody tr:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.ta-right { text-align: right; }
.member-cell { display: flex; align-items: center; gap: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.m-name { font-weight: 600; }
.tags { display: flex; gap: 6px; }
.tag { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
.tag-low  { color: var(--low);  background: color-mix(in srgb, var(--low) 12%, transparent);  border-color: color-mix(in srgb, var(--low) 26%, transparent); }
.tag-high { color: var(--high); background: color-mix(in srgb, var(--high) 14%, transparent); border-color: color-mix(in srgb, var(--high) 30%, transparent); }
.first-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px; }
.first-badge .pip { width: 8px; height: 8px; border-radius: 50%; }
.first-low .pip { background: var(--low); } .first-high .pip { background: var(--high); }
.first-low { color: var(--low); } .first-high { color: var(--high); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* ---------- recent joins (two panels) ---------- */
.recent { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.recent-head .panel-title { margin-bottom: 0; }
.recent-search {
  width: 150px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 7px 11px; font-size: 12.5px; font-family: inherit; outline: none;
}
.recent-search:focus { border-color: var(--brand); }
.recent-list { list-style: none; display: flex; flex-direction: column; max-height: 540px; overflow-y: auto; }
.recent-item { display: flex; align-items: flex-start; gap: 11px; padding: 12px 6px 12px 8px; border-top: 1px solid var(--border-soft); }
.recent-item:first-child { border-top: none; }
.recent-item.is-both { box-shadow: inset 3px 0 0 var(--both); border-radius: 3px; }
.avatar.sm { width: 34px; height: 34px; margin-top: 1px; }
.r-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.r-row1 { display: flex; align-items: center; gap: 8px; }
.r-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.r-time { font-family: var(--mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.r-roles { display: flex; flex-wrap: wrap; gap: 5px; }

/* per-server membership squares on the right */
.r-status { display: flex; flex-direction: column; gap: 6px; flex: none; padding-left: 4px; }
.srow { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.slabel { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.smark {
  width: 19px; height: 19px; border-radius: 5px; flex: none;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 800;
}
.smark.in  { background: var(--brand); color: #06210b; }
.smark.out { background: color-mix(in srgb, #ff6b6b 16%, transparent); color: #ff8585; }
.rolechip { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 6px; border: 1px solid transparent; white-space: nowrap; }
.rolechip.rc-high { color: var(--high); background: color-mix(in srgb, var(--high) 12%, transparent); border-color: color-mix(in srgb, var(--high) 26%, transparent); }
.rolechip.rc-low { color: var(--low); background: color-mix(in srgb, var(--low) 10%, transparent); border-color: color-mix(in srgb, var(--low) 24%, transparent); }
.rolechip.more, .rolechip.none { color: var(--muted); background: var(--surface-2); }
.recent-list .empty { padding: 24px; text-align: center; color: var(--muted); border: none; }

/* ---------- export button ---------- */
.export-wrap { position: relative; }
.export-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--bg); background: var(--brand); border: 1px solid var(--brand);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; transition: filter .15s ease;
}
.export-btn:hover { filter: brightness(1.08); }
.export-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  min-width: 200px; padding: 6px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.export-menu[hidden] { display: none; }
.export-menu a {
  display: block; padding: 9px 12px; border-radius: 8px; font-size: 13px; color: var(--text); text-decoration: none;
}
.export-menu a:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }

/* ---------- login page ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 380px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.login-card {
  width: 100%; background: linear-gradient(165deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: 22px; padding: 38px 32px 32px;
  display: flex; flex-direction: column; align-items: center; box-shadow: var(--shadow);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; object-fit: cover; display: block; margin-bottom: 18px;
}
.login-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.login-sub { font-family: var(--mono); font-size: 10.5px; color: var(--brand); text-transform: uppercase; letter-spacing: .18em; margin-top: 4px; margin-bottom: 26px; }
.login-field { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.login-label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.login-field input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 13px 15px; font-size: 14px; font-family: inherit; outline: none; transition: border-color .15s ease;
}
.login-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.login-btn {
  width: 100%; margin-top: 18px; padding: 13px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--brand); color: #06210b; font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: .01em;
  transition: filter .15s ease, transform .05s ease;
}
.login-btn:hover { filter: brightness(1.08); }
.login-btn:active { transform: translateY(1px); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-btn.loading .btn-text::after { content: "…"; }
.login-error { min-height: 18px; margin-top: 14px; font-size: 12.5px; color: #ff8080; text-align: center; }
.login-foot { font-family: var(--mono); font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .panels { grid-template-columns: 1fr; }
  .recent { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .topbar { padding-left: 18px; padding-right: 18px; }
  #search { width: 150px; }
  .logout-btn { padding: 6px 12px; }
}
