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

body {
  background: #f5f5f5;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hidden { display: none !important; }

/* ── Auth ── */
.auth-wrap {
  width: 100%;
  max-width: 300px;
}

.auth-form {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.auth-form h1 {
  font-size: 20px;
  font-weight: 700;
  color: #111;
  margin-bottom: 4px;
  letter-spacing: .2px;
}

/* ── Console ── */
.console-wrap {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.label-id {
  font-size: 16px;
  font-weight: 600;
  color: #111;
  flex: 1;
}

.label-role {
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .5px;
  text-transform: uppercase;
  border: 1px solid #bfdbfe;
}

/* ── Balances ── */
.balance-row {
  display: flex;
  gap: 10px;
}

.balance-item {
  flex: 1;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.bal-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.bal-val {
  font-size: 22px;
  font-weight: 700;
  color: #111;
  font-variant-numeric: tabular-nums;
}

/* ── Sections ── */
.section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.section-title {
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#admin-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Inputs ── */
input[type="text"],
input[type="password"],
input[type="number"] {
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #1a1a1a;
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

input::placeholder { color: #c0c4cc; }

.inline-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 90px;
}

/* ── Buttons ── */
button {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}

button:hover { background: #f3f4f6; }

.btn-ghost {
  background: transparent;
  border-color: #e5e7eb;
  color: #9ca3af;
  font-size: 13px;
  padding: 6px 10px;
}

.btn-ghost:hover { color: #374151; background: #f9fafb; }

.btn-credit {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
  font-weight: 600;
}

.btn-credit:hover { background: #dcfce7; border-color: #86efac; }

.btn-debit {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
  font-weight: 600;
}

.btn-debit:hover { background: #ffe4e6; border-color: #fda4af; }

.btn-connect {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  letter-spacing: .3px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(37,99,235,.25);
}

.btn-connect:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ── Messages ── */
.result-msg {
  font-size: 12px;
  min-height: 14px;
  padding-left: 2px;
}

.result-msg.ok  { color: #15803d; }
.result-msg.err { color: #be123c; }

.error-msg {
  color: #be123c;
  font-size: 13px;
  min-height: 16px;
}

/* ── Auth submit button ── */
.auth-form button[type="submit"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(37,99,235,.25);
}

.auth-form button[type="submit"]:hover { background: #1d4ed8; border-color: #1d4ed8; }


.connect-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.btn-connect-proxy {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-connect-proxy:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-connect-direct {
    background: #0f766e;
    border-color: #0f766e;
    box-shadow: 0 1px 4px rgba(15,118,110,.22);
}

.btn-connect-direct:hover { background: #115e59; border-color: #115e59; }

@media (max-width: 480px) {
    .connect-actions {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════ Admin (Final Backoffice) ═══════════════ */

/* 어드민이 보일 때는 body 가운데정렬을 풀어서 풀스크린 레이아웃을 그대로 받는다 */
body:has(#admin-dashboard:not(.hidden)) {
  display: block;
  padding: 0;
  background: #f6f8fb;
}

.admin-wrap {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --text-mute: #94a3b8;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06);
  --radius: 10px;
  --radius-sm: 6px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Pretendard', sans-serif;
  font-size: 14px;
}

/* ── Header ── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(8px);
}
.header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background .12s, border-color .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.header-brand {
  font-weight: 700;
  letter-spacing: .1px;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}
.header-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  display: inline-block;
}
.header-page {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.header-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.header-stat b { color: var(--text); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }

.header-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  max-width: 180px;
}
.header-select-game { max-width: 240px; }
.header-select:hover { border-color: var(--border-strong); }
.header-select:focus { outline: none; border-color: var(--primary); }

.btn-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn-pill:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.btn-pill-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-pill-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }

.header-user {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
}
.user-name { color: var(--text); font-weight: 600; }
.user-role { color: var(--text-mute); font-size: 11.5px; }

/* ── Body shell ── */
.admin-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.admin-wrap.sidebar-collapsed .sidebar { display: none; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 10px 16px;
  gap: 1px;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }
.nav-section {
  padding: 14px 10px 6px 10px;
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--text-mute);
  letter-spacing: .8px;
  font-weight: 700;
}
.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 7px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  white-space: nowrap;
}
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--surface-hover);
  color: var(--text);
  font-weight: 600;
  border-left: 2px solid var(--primary);
  padding-left: 8px;
  border-radius: 0;
}
.nav-badge {
  background: var(--text-mute);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

/* ── Main panel ── */
.main-panel {
  flex: 1;
  padding: 28px 32px 48px;
  overflow-y: auto;
  background: var(--bg);
}
.view { display: none; }
.view.active { display: block; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.1px;
  margin: 0;
}
.page-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.muted-text { color: var(--text-mute); }
.small-text { font-size: 12px; }

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.stat-grid + .stat-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}
.stat-card-accent {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 1px var(--accent, #2563eb) inset;
}
.stat-label {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-3);
}

/* ── Agency tree ── */
.agency-tree-summary {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.agency-tree-summary .tree-viewer {
  font-weight: 600;
  color: var(--text);
}
.agency-tree {
  padding: 6px 0 8px;
}
.tree-row {
  display: grid;
  grid-template-columns: 80px minmax(160px, 1.4fr) minmax(140px, 1fr) minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 7px 16px;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.tree-row:first-child {
  border-top: none;
}
.tree-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2, #eef2f7);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}
.tree-row.tier-hq          .tree-role { background: #1e293b; color: #fff; }
.tree-row.tier-subhq       .tree-role { background: #2563eb; color: #fff; }
.tree-row.tier-distributor .tree-role { background: #7c3aed; color: #fff; }
.tree-row.tier-partner     .tree-role { background: #059669; color: #fff; }
.tree-row.tier-store       .tree-role { background: #d97706; color: #fff; }
.tree-row.tier-member      .tree-role { background: #94a3b8; color: #fff; }
.tree-name b {
  color: var(--text);
}
.tree-nick {
  color: var(--text-3);
  font-size: 12px;
  margin-left: 6px;
}
.tree-wallet, .tree-subtotal {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.tree-subtotal {
  color: var(--text);
  font-weight: 600;
}
.action-card-hint {
  font-size: 12.5px;
  color: var(--text-2);
  margin: 4px 0 10px;
}

/* HQ 한정 — 자식 role + 부모 선택 controls */
.hq-create-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.hq-create-controls .form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
  flex: 1;
  min-width: 200px;
}
.hq-create-controls select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
}
.action-card-hint code {
  background: var(--surface-2, #eef2f7);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ── My Profile ── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.profile-item {
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.profile-label {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.profile-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.profile-apikey-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.profile-apikey-row input {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2, #f8fafc);
}

/* ── API 매뉴얼 인증 안내 ── */
.auth-methods {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 0 16px 14px;
}
.auth-method {
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.auth-method-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-method-desc {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.auth-method-desc code {
  background: #e5e7eb;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}
.auth-example {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre;
}

/* ── Quickstart steps ── */
.quickstart-steps {
  margin: 0;
  padding: 0 16px 14px 36px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
}
.quickstart-steps li {
  margin-bottom: 8px;
}
.quickstart-steps li b {
  color: var(--text);
}
.quickstart-steps code {
  background: #e5e7eb;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* ── Flow diagram ── */
.flow-diagram {
  padding: 0 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flow-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.flow-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.flow-step-body { flex: 1; min-width: 0; }
.flow-step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.flow-call {
  display: inline-block;
  background: #0f172a;
  color: #e2e8f0;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  margin-bottom: 4px;
  word-break: break-all;
}
.flow-step-note {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}

/* ── Param / Error table ── */
.param-table, .error-table {
  font-size: 12.5px;
  margin-top: 4px;
}
.param-table th, .error-table th {
  background: var(--surface-2, #f1f5f9);
  font-size: 11.5px;
  color: var(--text-3);
}
.param-table td:first-child, .error-table td:first-child {
  width: 110px;
  white-space: nowrap;
}
.param-table code, .error-table code {
  background: #e5e7eb;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* ── Grids / Panels ── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-title {
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

/* ── Action bar / cards ── */
.action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.action-bar input[type="text"],
.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 220px;
  transition: border-color .12s, box-shadow .12s;
}
.action-bar input[type="text"]:focus,
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.btn-action {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1px;
  transition: background .12s, border-color .12s;
}
.btn-action:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-3);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.btn-ghost-sm:hover { background: var(--surface-hover); color: var(--text); }
.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 18px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.action-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.auto-refresh-label {
  font-size: 12.5px;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.auto-refresh-label input { cursor: pointer; }

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border-radius: 0;
  overflow-x: auto;
}
.panel .table-wrap { border: none; border-radius: 0; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table thead th {
  background: var(--surface-soft);
  color: var(--text-3);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.data-table tbody td b { color: var(--text); font-weight: 600; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:empty + tr { display: none; }
.amount-pos { color: #059669; font-weight: 600; }
.amount-neg { color: #dc2626; font-weight: 600; }

/* ── Empty state ── */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.7;
}
.empty-state b { color: var(--text); }
.empty-state ul {
  text-align: left;
  display: inline-block;
  margin-top: 12px;
  padding-left: 18px;
  line-height: 1.9;
}

/* ── Badges ── */
.badge-role {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}
.badge-admin { background: #fee2e2; color: #b91c1c; }
.badge-member { background: #f1f5f9; color: var(--text-3); }

/* ── Result message ── */
.result-msg {
  font-size: 12.5px;
  min-height: 14px;
  margin-top: 6px;
}
.result-msg.ok  { color: #047857; }
.result-msg.err { color: #b91c1c; }

/* ── Forms ── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.form-stack input[type="text"],
.form-stack input[type="password"],
.form-stack input[type="number"],
.form-stack textarea,
.form-stack select,
.api-tester input[type="text"],
.api-tester textarea,
.api-tester select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  padding: 9px 11px;
  width: 100%;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.form-stack textarea,
.api-tester textarea {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  resize: vertical;
  line-height: 1.55;
}
.form-stack input:focus,
.form-stack textarea:focus,
.form-stack select:focus,
.api-tester input:focus,
.api-tester textarea:focus,
.api-tester select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-actions { display: flex; gap: 8px; }
.field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: -4px;
}
.check-row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* ── Notices ── */
.notice-list { display: flex; flex-direction: column; gap: 10px; }
.notice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "head actions" "body body";
  gap: 8px 12px;
}
.notice-card.pinned { border-left: 3px solid var(--primary); }
.notice-head { grid-area: head; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.notice-title { font-size: 14px; font-weight: 600; color: var(--text); }
.notice-meta { font-size: 11.5px; color: var(--text-mute); }
.notice-body { grid-area: body; font-size: 13px; color: var(--text-2); white-space: pre-wrap; line-height: 1.7; }
.notice-actions { grid-area: actions; display: flex; gap: 6px; }
.pin-tag {
  background: var(--surface-soft);
  color: var(--text-3);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
}

/* ── API manual ── */
.info-panel { padding: 14px 18px; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
  font-size: 13px;
}
.info-grid > div { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.info-key {
  font-size: 11.5px;
  color: var(--text-mute);
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  min-width: 96px;
}
code, .response-pre {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
}
code {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text);
}

.api-doc-list { display: flex; flex-direction: column; gap: 18px; margin-top: 16px; }
.api-doc-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.api-doc-group-title {
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.api-doc-group-count { font-size: 11.5px; font-weight: 600; color: var(--text-mute); }
.api-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
  cursor: pointer;
  transition: background .1s;
}
.api-row:last-child { border-bottom: none; }
.api-row:hover { background: var(--surface-soft); }
.api-row[hidden] { display: none; }
.method-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
  padding: 4px 0;
  border-radius: 5px;
  width: 64px;
}
.method-GET    { background: #ecfdf5; color: #047857; }
.method-POST   { background: #eff6ff; color: #1d4ed8; }
.method-PUT    { background: #fffbeb; color: #b45309; }
.method-DELETE { background: #fee2e2; color: #b91c1c; }
.api-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
}
.api-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: normal;
  font-family: inherit;
}
.api-tag-list { display: flex; gap: 4px; flex-wrap: wrap; }
.api-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-3);
  letter-spacing: .2px;
  white-space: nowrap;
}
.api-tag.tag-auth   { background: #fee2e2; color: #b91c1c; }
.api-tag.tag-admin  { background: #fef3c7; color: #92400e; }
.api-tag.tag-public { background: #dcfce7; color: #166534; }
.api-row-detail {
  grid-column: 1 / -1;
  background: var(--surface-soft);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  font-size: 12.5px;
  display: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.api-row.expanded + .api-row-detail { display: block; }
.detail-block { margin-bottom: 10px; }
.detail-block:last-child { margin-bottom: 0; }
.detail-key {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 4px;
}
.detail-block pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}
.btn-try-this {
  font-size: 11.5px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid #dbeafe;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.btn-try-this:hover { background: var(--primary-soft); border-color: var(--primary); }

/* ── API tester ── */
.api-tester { margin-top: 16px; }
.api-tester .action-card { margin-bottom: 0; }
.request-line { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; }
.method-select {
  font-weight: 700;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}
.full-width { width: 100%; }
.response-pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  max-height: 460px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: .3px;
  font-variant-numeric: tabular-nums;
}
.status-pill.s-2xx { background: #dcfce7; color: #166534; }
.status-pill.s-3xx { background: #dbeafe; color: #1e40af; }
.status-pill.s-4xx { background: #fef3c7; color: #92400e; }
.status-pill.s-5xx { background: #fee2e2; color: #b91c1c; }
.status-pill.s-net { background: #f1f5f9; color: var(--text-3); }

/* ── API health grid ── */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.health-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.health-card-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.health-card-foot { font-size: 11px; color: var(--text-mute); display: flex; justify-content: space-between; }

/* ── Bet detail (expand row) ── */
.bet-row { cursor: pointer; }
.bet-row .bet-row-chevron {
  display: inline-block;
  margin-right: 6px;
  color: var(--text-mute);
  transition: transform .15s, color .15s;
  font-size: 11px;
}
.bet-row.expanded .bet-row-chevron {
  transform: rotate(90deg);
  color: var(--primary);
}
.bet-row.expanded { background: var(--primary-soft) !important; }
.bet-row.expanded td b { color: var(--primary-strong); }
.bet-detail-row > td {
  background: #fbfdff;
  padding: 18px 22px !important;
  border-bottom: 2px solid var(--border-strong);
  border-top: 1px solid var(--border);
  white-space: normal;
}
.bet-detail-grid {
  display: grid;
  grid-template-columns: 110px 1fr 110px 1fr;
  gap: 7px 18px;
  margin-bottom: 16px;
  font-size: 12.5px;
  align-items: baseline;
}
@media (max-width: 900px) {
  .bet-detail-grid { grid-template-columns: 110px 1fr; }
}
.bd-key {
  color: var(--text-mute);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .4px;
}
.bd-val {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  word-break: break-all;
}
.mono-cell {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}
.bet-detail-h {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  margin: 14px 0 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bet-detail-ledger {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.mini-ledger { overflow-x: auto; }
.mini-ledger .data-table { font-size: 11.5px; }
.mini-ledger .data-table thead th { font-size: 10.5px; }
.bet-detail-raw { margin-top: 14px; }
.bet-detail-raw summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
  user-select: none;
  list-style: none;
}
.bet-detail-raw summary::before {
  content: "▸ ";
  color: var(--text-mute);
  margin-right: 2px;
}
.bet-detail-raw[open] summary::before { content: "▾ "; }
.bet-detail-raw summary:hover { color: var(--text); }
.bet-detail-raw pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 6px;
  overflow: auto;
  font-size: 11.5px;
  line-height: 1.55;
  margin-top: 8px;
  max-height: 300px;
  white-space: pre;
}

/* ── Hidden helper ── */
[hidden] { display: none !important; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .admin-header { padding: 0 14px; height: 52px; gap: 8px; }
  .admin-header .header-page,
  .admin-header .header-divider,
  .header-right .header-stat { display: none; }
  .main-panel { padding: 16px 14px 32px; }
  .sidebar { display: none; }
  .admin-wrap.sidebar-open .sidebar {
    display: flex;
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    z-index: 15;
    width: 240px;
  }
}


/* 데바 일반접속 (member) */
.btn-connect-devaplay {
  background: #7c3aed !important;
  border-color: #7c3aed !important;
  box-shadow: 0 1px 4px rgba(124,58,237,.25);
}
.btn-connect-devaplay:hover { background: #6d28d9 !important; border-color: #6d28d9 !important; }
.connect-actions {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
}
