/* 큰손탐지기 대표 대시보드 — 팬투데이 구성 참고(어두운 바탕, 파란 강조, 랭킹 2단). */
:root {
  --bg: #0b0c0f;
  --panel: #14161b;
  --panel-2: #1b1e25;
  --ink: #f2f4f8;
  --muted: #8b93a1;
  --line: #262a33;
  --accent: #3b82f6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --up: #ff5d5d;
  --down: #4d9bff;
  --new: #f5b638;
  --live: #ff3b4f;
  --good: #34d399;
  --bad: #f87171;
  --bar: rgba(59, 130, 246, 0.35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f0f3f8;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e3e7ee;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --up: #e5383b;
  --down: #2563eb;
  --new: #c98a00;
  --live: #e11d48;
  --good: #059669;
  --bad: #dc2626;
  --bar: rgba(37, 99, 235, 0.22);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px;
  padding: 7px 14px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.ghost { background: transparent; }
button.icon { padding: 6px 10px; line-height: 1; }
input {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px;
  padding: 9px 14px; min-width: 0;
}
input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
h1, h2 { letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.num, .value, .hearts { font-variant-numeric: tabular-nums; }
.logo { font-weight: 900; font-size: 20px; color: var(--accent); letter-spacing: -0.03em; }
.logo .sub { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 6px; letter-spacing: 0; }

/* header */
.top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap;
}
.chip.good { color: var(--good); border-color: currentColor; }
.chip.bad { color: var(--bad); border-color: currentColor; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 24px 56px; display: grid; gap: 18px; }

.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.kpi .value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi.small .value { font-size: 19px; }

/* 팬투데이식 숫자 칸 */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.pulse { width: 8px; height: 8px; border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.eyebrow.bad .pulse { animation: none; }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi.big { padding: 18px 20px; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi.big .value { font-size: 28px; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.live-card { background: linear-gradient(135deg, #2563eb, #1d4ed8); border-color: transparent; color: #fff; }
.live-card .label, .live-card .hint, .live-card .eyebrow { color: rgba(255, 255, 255, 0.85); }
.live-card .pulse { background: #4ade80; }
.live-card .eyebrow.bad .pulse { background: #fca5a5; }
.section-title { font-weight: 800; margin: 4px 0 -6px; padding-left: 10px; border-left: 3px solid var(--accent); }

/* 순위 TOP 5 (그림·이름·배지·하트) */
.top-row {
  width: 100%; display: grid; grid-template-columns: 1.6em 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  border: none; border-radius: 0; background: transparent; text-align: left; padding: 12px 6px;
}
.top-row:hover { background: var(--accent-soft); }
.top-row .rank { font-size: 15px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 800; color: var(--muted); overflow: hidden; border: 1px solid var(--line);
}
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 6px; margin-top: 3px; }
.badge.big { color: #f59e0b; background: rgba(245, 158, 11, 0.15); }
.badge.chg-badge { margin-left: 4px; }
.gold { color: #fb923c; font-weight: 800; white-space: nowrap; }
.gold small { color: #fb923c; }

/* filters */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.seg button { border: none; border-radius: 0; background: transparent; padding: 8px 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.search { display: flex; gap: 8px; position: relative; flex: 1; max-width: 420px; min-width: 240px; }
.search input { flex: 1; }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 4; list-style: none; margin: 0; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; max-height: 320px; overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.results[hidden] { display: none; }
.results li button {
  width: 100%; display: flex; gap: 8px; justify-content: space-between; text-align: left;
  border: none; background: transparent; border-radius: 8px; padding: 8px 10px;
}
.results li button:hover { background: var(--accent-soft); }
.note-line { margin: -6px 0 0; font-size: 12px; color: var(--muted); }

/* boards */
.boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.board { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.board > li { border-bottom: 1px solid var(--line); }
.row {
  width: 100%; display: grid; grid-template-columns: 2.4em 3.2em minmax(0, 1fr) auto; gap: 10px; align-items: center;
  border: none; border-radius: 0; background: transparent; text-align: left; padding: 10px 4px;
}
.row:hover { background: var(--accent-soft); }
.rank { font-weight: 800; font-size: 16px; text-align: center; color: var(--muted); }
.board > li:nth-child(-n+3) .rank { color: var(--accent); }
.chg { font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.new { color: var(--new); }
.chg.same, .chg.na { color: var(--muted); }
.who { min-width: 0; }
.who .name { display: flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; }
.who .name .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .id { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { font-size: 10px; font-weight: 800; color: #fff; background: var(--live); border-radius: 4px; padding: 1px 5px; letter-spacing: 0.04em; flex: none; }
.right { text-align: right; }
.hearts { font-weight: 800; white-space: nowrap; }
.hearts small { font-weight: 600; color: var(--muted); font-size: 12px; margin-left: 2px; }
.sub-line { font-size: 12px; color: var(--muted); white-space: nowrap; }
.board-extra { display: flex; justify-content: flex-end; padding: 0 4px 8px; margin-top: -4px; }
.top5-btn { font-size: 12px; padding: 3px 9px; border-radius: 8px; }
.top5 { margin: 0 4px 10px; padding: 6px 12px; background: var(--panel-2); border-radius: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 12px 4px; list-style: none; }

/* recipients list (top5 + drawer) */
.to { list-style: none; margin: 0; padding: 0; }
.to li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.to li:last-child { border-bottom: none; }
.to .name { overflow-wrap: anywhere; }
.to .excel { color: var(--accent); }
.to .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--bar); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.feed li button {
  width: 100%; display: grid; grid-template-columns: 3.4em minmax(0, 1fr) auto; gap: 8px;
  text-align: left; border: none; border-bottom: 1px solid var(--line); border-radius: 0;
  background: transparent; padding: 7px 2px; font-size: 14px;
}
.feed li button:hover { background: var(--accent-soft); }
.feed .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* drawer (후원자 상세) */
.drawer { position: fixed; inset: 0; z-index: 8; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-box {
  width: min(480px, 100%); height: 100%; overflow-y: auto; background: var(--panel);
  border-left: 1px solid var(--line); padding: 22px; position: relative;
}
.close { position: absolute; top: 16px; right: 16px; }
.d-name { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; margin: 6px 40px 2px 0; overflow-wrap: anywhere; }
.d-ids { font-size: 13px; color: var(--muted); margin-bottom: 14px; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 18px; font-weight: 800; white-space: nowrap; }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.d-section { font-size: 14px; font-weight: 800; margin: 18px 0 6px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 6.4em minmax(0, 1fr) auto; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.hist .what { min-width: 0; overflow-wrap: anywhere; }

/* BJ 상세 (팬투데이 /bj/아이디 구성) */
.bjpage { position: fixed; inset: 0; z-index: 7; background: var(--bg); overflow-y: auto; }
.bjpage[hidden] { display: none; }
.bjpage-inner { max-width: 1100px; margin: 0 auto; padding: 18px 24px 56px; display: grid; gap: 16px; }
.bjpage-inner > button { justify-self: start; }
#bj-body { display: grid; gap: 16px; }
.bj-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 22px; }
.bj-head .avatar { width: 88px; height: 88px; font-size: 32px; }
.bj-head .who { flex: 1; min-width: 200px; }
.bj-name { font-size: 26px; font-weight: 900; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.bj-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
a.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; }
a.btn:hover { filter: brightness(1.1); }
.bj-live { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.bj-live .now { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  min-height: 170px; padding: 22px; background: radial-gradient(120% 140% at 50% 0%, var(--accent-soft), transparent 70%), var(--panel); }
.now .tag { font-size: 11px; font-weight: 800; color: #fff; background: var(--live); padding: 2px 8px; border-radius: 6px; }
.now .title { font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.bj-live .side { display: grid; gap: 16px; }
.kpi-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bj-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; }
.seg.small button { padding: 4px 10px; font-size: 13px; }
.cast { display: grid; grid-template-columns: 7.5em 1fr auto; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.cast:last-child { border-bottom: none; }
.cast .when { font-variant-numeric: tabular-nums; }
.cast .mid { color: var(--muted); }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--accent-soft); }

/* login */
.login { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.login[hidden] { display: none; }
.login-box { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; display: grid; gap: 12px; }
.login-box .logo { font-size: 26px; }
.login-box p { margin: 0; color: var(--muted); font-size: 14px; }
.error { color: var(--bad) !important; }

@media (max-width: 900px) {
  .bjpage-inner { padding: 14px 16px 40px; }
  .bj-live, .bj-cols { grid-template-columns: minmax(0, 1fr); }
  .kpi-row.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bj-head .avatar { width: 64px; height: 64px; }
  .bj-name { font-size: 21px; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.big { min-height: 96px; padding: 14px; }
  .kpi.big .value { font-size: 22px; }
  .top { padding: 10px 16px; position: static; }
  .wrap { padding: 16px; }
  .boards { grid-template-columns: minmax(0, 1fr); }
  .feed { grid-template-columns: minmax(0, 1fr); }
  .search { max-width: none; }
  .seg button { padding: 7px 10px; }
}
@media (max-width: 480px) {
  .kpi { padding: 12px; }
  .kpi .value { font-size: 19px; }
  .kpi.small .value { font-size: 15px; }
  .kpi.small { padding: 10px; }
  .row { grid-template-columns: 2em 2.8em minmax(0, 1fr) auto; gap: 6px; }
  .stat .value { font-size: 15px; }
  .seg button { padding: 7px 8px; font-size: 14px; }
}
.login-box[hidden] { display: none; }
button.link { border: none; color: var(--muted); font-size: 13px; padding: 4px; }
button.link:hover { color: var(--accent); }
