:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2a2f3a;
  --text: #ffffff;
  --muted: #9aa3b2;
  --primary: #ff7761;        /* 메인 코랄 */
  --primary-ink: #ffffff;    /* 코랄 위 텍스트 = 화이트 */
  --primary-soft: rgba(255, 119, 97, .14);
  --secondary: #ff9254;      /* 서브 오렌지 */
  --danger: #ff5b6e;
  --ok: #36d399;
  --warn: #ffb454;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ── 공통 ── */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: var(--primary-ink); border-color: transparent; }
.btn.danger { background: var(--danger); color: #1a0508; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

.input, select.input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}
.input:focus { border-color: var(--primary); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.google { color: #ea4335; }
.badge.apple { color: #e7eaf0; }
.badge.email { color: var(--primary); }
.badge.naver { color: #03c75a; }
.badge.kakao { color: #fee500; }
.badge.ok { color: var(--ok); border-color: rgba(54,211,153,.4); }
.badge.bad { color: var(--danger); border-color: rgba(255,91,110,.4); }
.badge.warn { color: var(--warn); }

.pill {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.pill.claimed { color: var(--ok); }
.pill.claimable { color: var(--warn); }
.pill.pending, .pill.none { color: var(--muted); }

/* ── 인증/센터 화면 ── */
.center-screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 40px; text-align: center;
}
.login-card {
  width: min(380px, 90vw);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 26px;
  display: flex; flex-direction: column; gap: 12px; text-align: left;
}
.login-card h1 { margin: 4px 0 0; font-size: 20px; }
.login-sent { display: none; color: var(--ok); white-space: pre-line; line-height: 1.5; }
.login-sent.show { display: block; }
.brand-badge {
  align-self: flex-start;
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
  color: var(--primary); background: var(--primary-soft);
  padding: 4px 10px; border-radius: 999px;
}

/* 잠금 설정 — 자동 잠금 시간 선택(1/2/5분) */
.lock-idle-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 2px;
}
.lock-idle-label { color: var(--muted); font-size: 12px; margin-right: 2px; }
.lock-idle-row .btn { flex: 1; min-width: 56px; }

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 셸 ── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 6px; }
.brand-mark { font-weight: 800; font-size: 17px; }
.brand-sub { color: var(--secondary); font-weight: 700; font-size: 12px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.admin-email { color: var(--muted); font-size: 12px; }
/* 자동 잠금까지 남은 시간 — 폭이 흔들리지 않게 고정폭 숫자 */
.lock-countdown { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.lock-countdown.urgent { color: var(--danger); font-weight: 700; }

.tabbar { display: flex; gap: 4px; }
.tab-btn {
  appearance: none; border: none; background: transparent;
  color: var(--muted); padding: 8px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tab-btn:hover { color: var(--text); background: var(--panel-2); }
.tab-btn.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--primary); }

.tab-content { flex: 1; padding: 18px; overflow: auto; }

/* 관리 탭 서브 탭바 */
.subtabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }

/* ── 패널/툴바 ── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { width: min(360px, 60vw); }
.toolbar .chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; color: var(--muted); white-space: nowrap; }
.toolbar .chk input { cursor: pointer; margin: 0; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 10px; }
.stat-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.stat b { font-size: 18px; display: block; }
.stat span { color: var(--muted); font-size: 12px; }

/* ── 테이블 ── */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--panel); }
table.tbl tr:hover td { background: rgba(255,255,255,.02); }
table.tbl td.actions { text-align: right; white-space: nowrap; }
.uid-cell { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.social-on { color: var(--ok); font-weight: 600; }
/* 소셜 약관(EULA) 동의 현황 — 동의(최신) 초록 / 동의(구버전) 주황 / 철회 빨강. */
.consent-latest { color: var(--ok); font-weight: 600; }
.consent-old { color: var(--warn); font-weight: 600; }
.consent-withdrawn { color: var(--danger); font-weight: 600; }

.empty { color: var(--muted); padding: 30px; text-align: center; }
.error-box { color: var(--danger); padding: 14px; border: 1px solid rgba(255,91,110,.3); border-radius: 10px; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: min(460px, 92vw); background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
.modal h3 { margin: 0 0 8px; }
.modal-msg { color: var(--muted); margin: 0 0 16px; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* 사이드 상세 패널 */
.detail-wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 920px) { .detail-wrap { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ── 토스트 ── */
.toast-host { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; max-width: 360px;
  opacity: 0; transform: translateX(12px); transition: all .22s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { border-color: rgba(54,211,153,.4); }
.toast-err { border-color: rgba(255,91,110,.5); }

/* ── 채팅 ── */
.chat-wrap { display: grid; grid-template-columns: 300px 1fr 340px; gap: 14px; height: calc(100vh - 110px); }
@media (max-width: 1180px) { .chat-wrap { grid-template-columns: 280px 1fr; } .tpl-panel { display: none; } }
@media (max-width: 820px) { .chat-wrap { grid-template-columns: 1fr; height: auto; } }
.thread-list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.thread-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.thread-item:hover { background: var(--panel-2); }
.thread-item.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--primary); }
.thread-item .t-top { display: flex; align-items: center; gap: 8px; }
.thread-item .t-id { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.thread-item .t-uid { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item .t-last { color: var(--muted); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item .t-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.thread-item .t-foot .t-date { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.unread-dot { flex: none; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }

.chat-room { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.chat-msgs { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 72%; padding: 8px 12px; border-radius: 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.trainer { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 4px; }
.bubble .meta { display: block; font-size: 10px; opacity: .7; margin-top: 4px; }
.bubble img { max-width: 220px; border-radius: 8px; display: block; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-input input { flex: 1; }
.chat-input .chat-textarea { flex: 1; resize: none; min-height: 38px; max-height: 140px; overflow-y: auto; font-family: inherit; line-height: 1.4; }
.chat-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* ── 일괄 발송 ── */
.bc-wrap { display: grid; grid-template-columns: 360px 1fr; gap: 14px; height: calc(100vh - 110px); }
@media (max-width: 820px) { .bc-wrap { grid-template-columns: 1fr; height: auto; } }

.bc-picker { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bc-picker-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.bc-picker-tools { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.bc-paste-row { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; }
/* 숨김(display:none) 시엔 마진이 레이아웃에 영향을 주지 않으므로 항상 지정해도 안전 */
.bc-paste-row textarea { margin-top: 10px; }
.bc-paste-row .btn { align-self: flex-end; margin-bottom: 8px; }
.bc-user-list { flex: 1; overflow: auto; }
.bc-user-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.bc-user-row:hover { background: var(--panel-2); }
.bc-user-row input { cursor: pointer; margin: 0; flex: none; }
.bc-user-row .u-info { min-width: 0; }
.bc-user-row .u-main { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-user-row .u-uid { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bc-compose { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bc-compose-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.bc-compose-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.bc-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 132px; overflow: auto; padding: 2px 0; }
.bc-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px; max-width: 220px; }
.bc-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-chip-x { appearance: none; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.bc-chip-x:hover { color: var(--danger); }
.bc-textarea { resize: vertical; min-height: 96px; font-family: inherit; line-height: 1.5; }
.bc-img-preview { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bc-thumb { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.bc-send-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.bc-progress { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bc-bar { width: 140px; height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bc-bar-fill { height: 100%; background: linear-gradient(135deg, var(--primary), var(--secondary)); transition: width .15s ease; }
.bc-results { padding: 0 14px 14px; }
.bc-result-summary { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.bc-fail-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow: auto; border: 1px solid rgba(255,91,110,.3); border-radius: 8px; padding: 8px; }
.bc-fail-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* ── 답변 템플릿 패널 ── */
.tpl-panel { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tpl-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.tpl-search-row { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tpl-search { font-size: 13px; padding: 8px 10px; }
.tpl-list { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tpl-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tpl-card-head { display: flex; align-items: flex-start; gap: 8px; }
.tpl-title { flex: 1; font-weight: 700; font-size: 13px; word-break: break-word; line-height: 1.4; }
.tpl-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tpl-card-body { position: relative; margin-top: 8px; }
.tpl-body-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; padding-right: 50px; }
.tpl-copy {
  position: absolute; top: 0; right: 0;
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
}
.tpl-copy:hover { color: var(--text); }
.tpl-card.editing { display: flex; flex-direction: column; gap: 8px; }
.tpl-edit-title { font-size: 13px; padding: 8px 10px; }
.tpl-edit-body { font-size: 13px; padding: 8px 10px; resize: vertical; min-height: 96px; font-family: inherit; line-height: 1.5; }
.tpl-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── 서버 상태 탭 ───────────────────────────────────────────────────────── */
.obs-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.obs-status {
  font-size: 12px;
  opacity: 0.65;
  margin-left: auto;
}
.obs-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}
.obs-card {
  padding: 12px 14px 10px;
}
.obs-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.obs-card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.8;
}
.obs-latest {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.obs-hint {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.5;
  opacity: 0.55;
}
/* 지표 서버가 없는 환경(라이브)의 서버 상태 탭 — 오류가 아니라 안내다 */
.obs-absent {
  grid-column: 1 / -1;
  padding: 56px 24px;
  text-align: center;
}
.obs-absent strong {
  display: block;
  font-size: 15px;
  margin-bottom: 8px;
}
.obs-absent p {
  margin: 0 auto;
  max-width: 420px;
  font-size: 12.5px;
  line-height: 1.6;
  opacity: 0.6;
}
.obs-chart {
  display: block;
  width: 100%;
  height: 180px;
  margin-top: 8px;
  color: currentColor;
}
.obs-grid {
  stroke: currentColor;
  stroke-width: 1;
  opacity: 0.12;
  vector-effect: non-scaling-stroke;
}
/* 축·시간 라벨은 svg 밖 HTML 오버레이 — preserveAspectRatio 스트레치에
   글자가 찌그러지지 않는다. 좌표는 chart.js 가 %-로 박는다. */
.obs-axis-o,
.obs-empty-o {
  position: absolute;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
}
.obs-axis-o {
  font-size: 10px;
  opacity: 0.5;
}
/* 막대 위 상시 값 라벨 — 축 라벨과 같은 오버레이 방식, 더 또렷하게 */
.obs-bar-value-o {
  position: absolute;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
  font-size: 10px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
.obs-empty-o {
  font-size: 12px;
  opacity: 0.4;
}
.obs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  opacity: 0.7;
}
.obs-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.obs-legend-item i {
  width: 9px;
  height: 2px;
  border-radius: 1px;
}
.obs-legend-item i.bar {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ── 차트 공통: 호버 밴드/가이드선 + 지점 마커 + 툴팁 ─────────────────── */
.obs-chart-wrap { position: relative; }
.obs-hover-band {
  fill: currentColor;
  opacity: 0.07;
}
.obs-hover-guide {
  stroke: currentColor;
  opacity: 0.35;
}
.obs-dot {
  display: none;
  position: absolute;
  z-index: 4;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.obs-tooltip {
  display: none;
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 150px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.obs-tooltip.show { display: block; }
.obs-tooltip .tt-head { color: var(--muted); margin-bottom: 6px; }
.obs-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.7;
}
.obs-tooltip .tt-row i {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.obs-tooltip .tt-row span {
  flex: 1;
  margin-right: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.obs-tooltip .tt-row b { font-variant-numeric: tabular-nums; }

/* ── 셸 v2: 좌측 세로 네브 + 본문 ─────────────────────────────────────── */
.shell-body { flex: 1; display: flex; min-height: 0; }
.sidenav {
  width: 200px; flex: 0 0 200px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px 10px;
  overflow-y: auto;
  position: sticky; top: 49px;
  height: calc(100vh - 49px);
}
.side-list { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  appearance: none; border: none; background: transparent;
  color: var(--muted); text-align: left;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.side-item:hover { color: var(--text); background: var(--panel-2); }
.side-item.active {
  color: var(--text); background: var(--panel-2);
  box-shadow: inset 2px 0 0 var(--primary);
}
/* 탭이 소유하는 컨트롤 슬롯 — 기간 설정, 지표 전환 등 */
.side-slot { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-slot:empty { display: none; }
.side-slot .side-slot-title { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.side-slot .side-item { padding: 7px 12px; font-weight: 500; }

/* 햄버거 — 좁은 화면에서만 노출(모바일 미디어쿼리에서 display 켬) */
.nav-burger {
  display: none;
  appearance: none; border: 1px solid var(--line); background: transparent;
  color: var(--text); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; font-weight: 600;
  line-height: 1; cursor: pointer;
  align-items: center; gap: 7px; flex: 0 0 auto;
  max-width: 46vw;
}
.nav-burger.active { background: var(--panel-2); border-color: var(--primary); }
.nav-burger-icon { font-size: 14px; }
.nav-burger-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted);
}
.nav-burger.active .nav-burger-label { color: var(--text); }

/* 좁은 화면(태블릿 포함): 사이드바는 햄버거로 여닫고, 항목은 최소폭 + wrap 으로
   유연 배치. 1000px 경계 — 그 아래에선 고정 200px 사이드바가 본문을 짓누른다. */
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  .topbar-right { gap: 8px; }
  .nav-burger { display: inline-flex; }
  .shell-body { flex-direction: column; }
  .sidenav {
    display: none;
    width: auto; flex: none; position: static; height: auto;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .sidenav.open { display: flex; flex-direction: column; }
  .side-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .side-item { flex: 1 1 140px; min-width: 140px; text-align: center; }
  .side-item.active { box-shadow: inset 0 -2px 0 var(--primary); }
  .side-slot { flex-direction: row; flex-wrap: wrap; align-items: center; }
}

/* ── 라이브|개발 환경 토글 ───────────────────────────────────────────── */
.env-toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; flex: 0 0 auto;
}
.env-btn {
  appearance: none; border: none; background: transparent;
  color: var(--muted); padding: 5px 12px;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.env-btn.active { color: var(--text); background: var(--panel-2); }
.env-btn.active.live { color: #fff; background: var(--danger, #e5484d); }

/* ── 지표 대시보드 탭 ────────────────────────────────────────────────── */
.dash-grid {
  display: grid; grid-template-columns: repeat(24, 1fr);
  gap: 12px; align-items: stretch;
}
.dash-panel {
  grid-column: span var(--dash-span, 12);
  padding: 12px 14px 10px; min-width: 0; display: flex; flex-direction: column;
}
/* 중간 폭: 작은 타일(w≤6 — 스탯·성비)을 넓힌 폭(--dash-span-sm)으로 감아 배치.
   1100px 아래는 그리드 자체가 12칸으로 줄어 원래 폭이 다시 맞다. */
@media (max-width: 1600px) and (min-width: 1101px) {
  .dash-panel { grid-column: span var(--dash-span-sm, var(--dash-span, 12)); }
}
.dash-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.dash-panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; opacity: .85; }
.dash-row-title {
  grid-column: 1 / -1; margin: 6px 0 -4px;
  font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .05em;
}
/* 병합 탭에서 멤버 대시보드 사이를 가르는 섹션 제목 (KPI / Ops 등) */
.dash-section-title {
  grid-column: 1 / -1; margin: 16px 0 -2px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px; font-weight: 800; letter-spacing: .04em;
}
.dash-stat-grid { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: stretch; }
.dash-stat { min-width: 110px; }
.dash-stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.dash-stat span { color: var(--muted); font-size: 11px; }
/* 지표 탭 표: 컬럼 폭은 내용 크기(줄바꿈·찌부 없음), 패널보다 넓으면 가로 스크롤.
   극단적으로 긴 셀(에러 원문 등)만 420px에서 말줄임. */
.dash-table-wrap { overflow: auto; max-height: 420px; }
.dash-table-wrap table.tbl { width: max-content; min-width: 100%; }
.dash-table-wrap th, .dash-table-wrap td {
  white-space: nowrap;
  max-width: 420px; overflow: hidden; text-overflow: ellipsis;
}
.dash-pie-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dash-pie { width: 160px; height: 160px; flex: none; }
.dash-pie path { stroke: var(--panel, #171a21); stroke-width: 1; }
.dash-pie-legend { display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; flex: 1; }
.dash-pie-item { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dash-pie-item i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.dash-pie-item .pie-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.dash-pie-item b { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-bar-row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr 64px; gap: 8px; align-items: center; font-size: 12px; }
.dash-bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.dash-bar-track { background: var(--panel-2); border-radius: 4px; height: 14px; overflow: hidden; }
.dash-bar-fill { height: 100%; border-radius: 4px; background: var(--primary); }
.dash-bar-value { text-align: right; font-variant-numeric: tabular-nums; }
/* 표 우상단 필터(id·이름 부분 일치) — Accessed Users 등 searchable 패널 */
.dash-table-toolbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.dash-table-filter { width: min(220px, 100%); padding: 6px 10px; font-size: 12px; }
.dash-empty { color: var(--muted); font-size: 12px; padding: 12px 0; }
.dash-note { color: var(--muted); font-size: 11px; margin-top: 8px; }
.dash-error { color: var(--danger, #e5484d); font-size: 12px; padding: 8px 0; white-space: pre-line; }
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(12, 1fr); }
}
@media (max-width: 760px) {
  .dash-grid { display: flex; flex-direction: column; }
}

/* 지표 테이블의 회원 링크 — 탭하면 사용자 상세 모달 */
.dash-user-link {
  appearance: none; border: none; background: transparent; padding: 0;
  color: var(--primary); font: inherit; font-variant-numeric: tabular-nums;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.dash-user-link:hover { opacity: .8; }
