/* KOECO — 디자인 시스템
 * 색상·간격·모서리는 모두 :root 변수로 관리한다. 브랜드 색을 바꾸려면 --brand-* 만 고치면 된다.
 */
:root {
    --brand-50:  #f0fdfa;
    --brand-100: #ccfbf1;
    --brand-200: #99f6e4;
    --brand-500: #14b8a6;
    --brand-600: #0d9488;
    --brand-700: #0f766e;
    --brand-900: #134e4a;

    --ink:       #0f172a;
    --ink-2:     #334155;
    --muted:     #64748b;
    --line:      #e2e8f0;
    --line-soft: #eef2f6;
    --bg:        #f6f8fb;
    --card:      #ffffff;

    --ok:        #047857;
    --ok-bg:     #ecfdf5;
    --err:       #be123c;
    --err-bg:    #fff1f2;
    --info:      #1d4ed8;
    --info-bg:   #eff6ff;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;

    --sh-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --sh-md: 0 4px 14px rgba(15, 23, 42, .07);
    --sh-lg: 0 18px 40px rgba(15, 23, 42, .12);

    --topbar-h: 60px;
    --font: 'Pretendard Variable', Pretendard, 'Noto Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ───── 회원 홈 (대시보드) ───── */
.dash { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.dcard {
    background: #fff; border: 1px solid var(--line); border-radius: 18px;
    box-shadow: var(--sh-sm); padding: 20px 22px;
}
.d-greet { text-align: center; font-size: 17px; font-weight: 700; line-height: 1.5; }
.d-greet b { display: block; font-size: 19px; }
.d-title { text-align: center; font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.d-title small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.d-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: 14.5px;
}
.d-row:first-of-type { border-top: 0; }
.d-row span { color: var(--ink-2); }
.d-row small { color: var(--muted); font-size: 11.5px; }
.d-row b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.d-row b small { font-weight: 600; margin-left: 4px; }
.d-empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 10px 0 4px; }
.d-banner {
    border-radius: 16px; text-align: center; color: #fff; padding: 18px 16px 16px;
    box-shadow: var(--sh-md);
}
.d-banner span { display: block; font-size: 15px; font-weight: 700; opacity: .92; }
.d-banner b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.d-banner-rank { background: linear-gradient(180deg, #f87171, #ef4444); }
.d-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-btn {
    display: block; width: 100%; text-align: center; border: 0; border-radius: 12px;
    padding: 16px 10px; font-size: 16px; font-weight: 800; color: #fff; cursor: pointer;
    box-shadow: var(--sh-sm); transition: transform .1s, filter .15s;
}
.d-btn:hover { filter: brightness(1.06); }
.d-btn:active { transform: translateY(1px); }
.d-btn-blue { background: #2563eb; }
.d-btn-red { background: #f43f5e; }
.d-btn-teal { background: #0e7490; }
.d-invite { text-align: center; }
.d-qr { display: flex; justify-content: center; margin: 8px 0 4px; min-height: 168px; }
.d-qr img, .d-qr canvas { border-radius: 6px; }
.d-qr-hint { color: var(--ink-2); font-weight: 700; line-height: 1.5; margin: 6px 0 12px; }
.d-code {
    width: 100%; text-align: center; border: 1px solid var(--line); background: var(--bg);
    border-radius: 10px; padding: 9px 12px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px;
}
.d-banner-gold { background: linear-gradient(180deg, #d4a017, #b8860b); }
.cycle-head { display: flex; align-items: baseline; gap: 6px; margin: 2px 0 10px; }
.cycle-head b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: #b45309; }
.cycle-head span { font-size: 14px; font-weight: 700; color: var(--muted); }
.cycle-bar { height: 12px; border-radius: 999px; background: #f3f0e8; overflow: hidden; }
.cycle-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #fbbf24, #d97706); }
.cycle-note { margin: 8px 0 0; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.chk { width: 18px; height: 18px; accent-color: #0f766e; cursor: pointer; }
.amt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.amt-pick { display: block; cursor: pointer; }
.amt-pick input { position: absolute; opacity: 0; pointer-events: none; }
.amt-pick span { display: flex; flex-direction: column; gap: 2px; border: 1px solid #d7dee7; border-radius: 12px; padding: 10px 12px; background: #fff; }
.amt-pick b { font-size: 15px; }
.amt-pick small { color: #64748b; font-size: 12px; }
.amt-pick input:checked + span { border-color: #0f766e; background: #f0fdfa; box-shadow: inset 0 0 0 1px #0f766e; }
.amt-pick input:focus-visible + span { outline: 2px solid #0f766e; }
.amt-total { display: flex; align-items: baseline; gap: 8px; border: 1px solid #d7dee7; border-radius: 12px; padding: 12px 14px; background: #f8fafc; }
.amt-total span { font-size: 13px; font-weight: 700; color: #64748b; }
.amt-total b { margin-left: auto; font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: #0f766e; }
.amt-total small { font-size: 13px; font-weight: 700; color: #64748b; }
.amt-unit { border: 1px solid #d7dee7; border-radius: 12px; padding: 12px; background: #fff; font-size: 15px; font-weight: 800; cursor: pointer; }
.amt-unit.is-on { border-color: #0f766e; background: #f0fdfa; box-shadow: inset 0 0 0 1px #0f766e; }
.amt-ops { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.amt-ops button { border: 0; border-radius: 12px; min-height: 46px; font-weight: 800; cursor: pointer; }
.amt-minus { background: #e2e8f0; color: #334155; font-size: 22px; }
.amt-plus { background: #0f766e; color: #fff; font-size: 16px; }
.d-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.d-form .field { margin: 0; }
.d-form .field input, .d-form .field select, .d-form .field textarea { width: 100%; }
.d-list { list-style: none; margin-top: 4px; }
.d-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px;
}
.d-list li:first-child { border-top: 0; }
.d-list .d-main { min-width: 0; }
.d-list .d-main b { display: block; font-size: 14.5px; }
.d-list .d-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-list .d-right { text-align: right; white-space: nowrap; }
.d-list .d-amt { font-weight: 800; }
.st-pending { color: #b45309; }
.st-confirmed, .st-approved { color: var(--ok); }
.st-rejected { color: var(--err); }
.st-canceled { color: var(--muted); }
.d-notice { display: block; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.d-notice:first-of-type { border-top: 0; }
.d-notice b { display: block; font-size: 14.5px; }
.d-notice span { color: var(--muted); font-size: 12px; }
.notice-body { white-space: pre-wrap; line-height: 1.7; }

/* ───── 상단 바 ───── */
.topbar {
    position: sticky; top: 0; z-index: 100;
    min-height: var(--topbar-h);
    background: rgba(255, 255, 255, .85);
    overflow: visible;
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    position: relative; z-index: 101;
    backdrop-filter: saturate(180%) blur(14px);
    max-width: 1120px; height: 100%; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff; font-weight: 800; font-size: 17px;
    box-shadow: 0 4px 10px rgba(13, 148, 136, .35);
}
.brand-text { font-size: 18px; }
.topnav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav-link {
    padding: 8px 14px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto;
    color: var(--muted); font-weight: 600; font-size: 14px;
    transition: background .15s, color .15s;
}
.topnav-link:hover { background: var(--line-soft); color: var(--ink); }
.nav-badge {
    display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}
.nav-more { position: relative; flex: 0 0 auto; }
.nav-more > summary {
    list-style: none; cursor: pointer; padding: 8px 14px; border-radius: 999px;
    color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary:hover, .nav-more[open] > summary, .nav-more.on > summary { background: var(--line-soft); color: var(--ink); }
.nav-more-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 300; min-width: 168px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--sh-lg); padding: 6px; display: flex; flex-direction: column;
}
.nav-more-menu a { padding: 9px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.nav-more-menu a:hover { background: var(--line-soft); }
.nav-more-menu a.active { background: var(--brand-50); color: var(--brand-700); }
.topnav-link.active { background: var(--brand-50); color: var(--brand-700); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--line-soft); font-weight: 600; font-size: 13px;
}
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-500); }

/* ───── 레이아웃 ───── */
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 56px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title small { font-size: 12px; font-weight: 500; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.1fr .9fr; }
.grid > .card + .card { margin-top: 0; }

/* ───── 버튼 · 알림 ───── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 46px; padding: 0 20px; border: 0; border-radius: var(--r-sm);
    font-weight: 700; cursor: pointer; white-space: nowrap;
    transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    color: #fff; box-shadow: 0 6px 16px rgba(13, 148, 136, .28);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(13, 148, 136, .38); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert ul { padding-left: 18px; }
.alert-ok    { background: var(--ok-bg);   color: var(--ok);   border-color: #a7f3d0; }
.alert-error { background: var(--err-bg);  color: var(--err);  border-color: #fecdd3; }
.alert-info  { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }

/* ───── 폼 ───── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.req { color: var(--err); }
.field input[type=text], .field input[type=password], .field input[type=tel], .field input[type=email], .select {
    width: 100%; height: 46px; padding: 0 14px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .select:focus {
    outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(20, 184, 166, .15);
}
.field input::placeholder { color: #a8b3c4; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.hint.ok { color: var(--ok); font-weight: 600; }
.hint.err { color: var(--err); font-weight: 600; }

/* ───── 로그인 · 가입 화면 ───── */
body.auth-page { background: #fff; }
body.auth-page .wrap { max-width: none; padding: 0; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 5fr) 6fr; }
.auth-brand {
    position: relative; overflow: hidden; color: #fff;
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(94, 234, 212, .35), transparent 60%),
        radial-gradient(700px 500px at 110% 110%, rgba(16, 185, 129, .35), transparent 60%),
        linear-gradient(160deg, var(--brand-900), var(--brand-700));
    display: flex; align-items: center; padding: 56px;
}
.auth-brand::after {
    content: ''; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px;
    border-radius: 50%; border: 60px solid rgba(255, 255, 255, .06);
}
.auth-brand-inner { position: relative; z-index: 1; max-width: 420px; }
.auth-logo { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: .04em; margin-bottom: 44px; }
.auth-logo .brand-mark { background: rgba(255, 255, 255, .18); box-shadow: none; backdrop-filter: blur(4px); }
.auth-brand h1 { font-size: 34px; line-height: 1.3; font-weight: 800; letter-spacing: -.03em; }
.auth-brand p { margin-top: 14px; color: rgba(255, 255, 255, .8); font-size: 15px; }
.auth-points { list-style: none; margin-top: 34px; display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: rgba(255, 255, 255, .92); }
.auth-points li::before {
    content: '✓'; flex: none; width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center; font-size: 12px; font-weight: 800;
    background: rgba(255, 255, 255, .16);
}
.auth-form-wrap { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 88px); }
.auth-form { width: 100%; max-width: 480px; margin: 0 auto; }
.auth-form h2 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.auth-form .sub { color: var(--muted); margin: 6px 0 26px; }
.auth-form .btn-primary { margin-top: 22px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 14px; margin-top: 22px; }
.auth-foot a { color: var(--brand-700); font-weight: 700; }
.auth-foot a:hover { text-decoration: underline; }

/* ───── 홈 ───── */
.hero {
    border: 0; color: #fff;
    background:
        radial-gradient(600px 260px at 100% 0%, rgba(94, 234, 212, .28), transparent 60%),
        linear-gradient(135deg, var(--brand-700), var(--brand-900));
    box-shadow: var(--sh-md);
}
.hero-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-lg {
    width: 56px; height: 56px; border-radius: 18px; flex: none;
    display: grid; place-items: center; font-size: 24px; font-weight: 800;
    background: rgba(255, 255, 255, .18);
}
.hero h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.hero p { color: rgba(255, 255, 255, .78); font-size: 14px; }
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; background: var(--line-soft); color: var(--ink-2);
}
.badge-rank { background: rgba(255, 255, 255, .2); color: #fff; margin-left: 6px; vertical-align: 2px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 20px; }
.stat { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .16); border-radius: var(--r-md); padding: 14px 16px; }
.stat-label { font-size: 12px; color: rgba(255, 255, 255, .75); }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat-value small { font-size: 13px; font-weight: 600; margin-left: 2px; opacity: .8; }
/* 밝은 카드 안에서 쓰는 통계 칸 (히어로의 반투명 흰색 대신) */
.stats-light { margin-top: 0; }
.stats-light .stat { background: var(--brand-50); border-color: var(--brand-100); }
.stats-light .stat-label { color: var(--muted); }
.stats-light .stat-value { color: var(--ink); }

.copy-box { display: flex; gap: 8px; }
.copy-box input {
    flex: 1; min-width: 0; height: 46px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink-2);
}
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.row-link { color: var(--brand-700); font-weight: 600; }
.table a.row-link:hover { text-decoration: underline; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.gen-list { display: grid; gap: 10px; }
.gen-row { display: grid; grid-template-columns: 44px 1fr 56px; align-items: center; gap: 12px; font-size: 13px; }
.gen-row .lv { font-weight: 700; color: var(--ink-2); }
.gen-bar { height: 10px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.gen-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-500), var(--brand-700)); }
.gen-row .cnt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ───── 계보도 ───── */
.tree-options { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tree-options label { font-size: 13px; color: var(--muted); font-weight: 600; }
.select { width: auto; min-width: 110px; height: 38px; padding: 0 12px; }
.genealogy-note { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.genealogy-note strong { color: var(--ink-2); }

.tree-viewer { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fbfcfe; }
.tree-toolbar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line);
    position: relative; z-index: 2;
}
.tree-tool {
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: 9px; background: #fff;
    font-size: 17px; font-weight: 700; line-height: 1; cursor: pointer; color: var(--ink-2);
    -webkit-tap-highlight-color: transparent;
}
.tree-tool:hover { background: var(--line-soft); }
.tree-tool-text { font-size: 12px; }
a.tree-tool-home { display: inline-flex; align-items: center; margin-left: auto; background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }
.tree-zoom-label { min-width: 46px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.tree-viewport {
    position: relative; height: min(66vh, 640px); overflow: hidden;
    touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
    background-image: radial-gradient(#dbe3ee 1px, transparent 1px); background-size: 22px 22px;
}
.tree-viewport:active { cursor: grabbing; }
/* genealogy.js 가 padding 없이 위치를 계산하므로 stage 에는 padding 을 두지 않는다. */
.tree-stage { position: absolute; left: 0; top: 0; width: max-content; transform-origin: 0 0; will-change: transform; }
.tree-viewer.is-fullscreen {
    position: fixed; inset: 0; width: 100%; height: 100dvh; z-index: 2000;
    border: 0; border-radius: 0; display: flex; flex-direction: column;
}
.tree-viewer.is-fullscreen .tree-viewport { flex: 1; height: auto; min-height: 0; }
body.genealogy-fs { overflow: hidden; }
body.genealogy-fs .topbar { visibility: hidden; }

/* 연결선 */
.tree { display: inline-block; }
.tree-branch { display: flex; flex-direction: column; align-items: center; }
.tree-kids { display: flex; justify-content: center; position: relative; padding-top: 20px; }
.tree-kids::before { content: ''; position: absolute; top: 0; left: 50%; height: 20px; border-left: 2px solid var(--brand-200); transform: translateX(-1px); }
.tree-col { position: relative; padding: 20px 9px 0; display: flex; flex-direction: column; align-items: center; }
.tree-col::before, .tree-col::after { content: ''; position: absolute; top: 0; width: 50%; height: 20px; border-top: 2px solid var(--brand-200); }
.tree-col::before { right: 50%; }
.tree-col::after  { left: 50%; border-left: 2px solid var(--brand-200); }
.tree-col:first-child::before, .tree-col:last-child::after { border: 0 none; }
.tree-col:last-child::before { border-right: 2px solid var(--brand-200); border-radius: 0 8px 0 0; }
.tree-col:first-child::after { border-radius: 8px 0 0 0; }
.tree-col:only-child::before { border-top: 0; border-right: 2px solid var(--brand-200); border-radius: 0; }
.tree-col:only-child::after { display: none; }
.tree-col:only-child { padding-left: 0; padding-right: 0; }

/* 회원 카드 */
.tree-node {
    width: 138px; padding: 12px 10px 10px; text-align: center;
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
    box-shadow: var(--sh-sm); display: block;
    transition: transform .12s, box-shadow .15s, border-color .15s;
}
a.tree-node:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--brand-500); }
.tree-node.me { border: 2px solid var(--brand-600); background: var(--brand-50); box-shadow: 0 6px 18px rgba(13, 148, 136, .22); }
.tn-leg {
    display: inline-block; margin: -2px auto 8px; padding: 1px 9px; border-radius: 999px;
    font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
    background: #eef2ff; color: #4338ca;
}
.leg-badge {
    display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 800;
    background: #eef2ff; color: #4338ca; white-space: nowrap;
}
.tn-avatar {
    width: 36px; height: 36px; margin: 0 auto 6px; border-radius: 12px;
    display: grid; place-items: center; font-weight: 800; font-size: 15px;
    background: var(--line-soft); color: var(--ink-2);
}
.tree-node.me .tn-avatar { background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); color: #fff; }
.tn-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-id { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-meta { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 8px; }
.tn-rank { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.tn-rank.has { background: var(--brand-100); color: var(--brand-700); }
.tn-date { font-size: 10px; color: #94a3b8; }
.tn-more { margin-top: 8px; font-size: 11px; font-weight: 700; color: var(--brand-700); background: var(--brand-50); border-radius: 8px; padding: 3px 0; }

.tree-msg { padding: 24px; text-align: center; color: var(--muted); }

/* ───── 마이페이지 ───── */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.info-item { background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px 14px; min-width: 0; }
.info-label { font-size: 12px; color: var(--muted); }
.info-val { font-weight: 700; margin-top: 2px; word-break: break-all; }
a.user-chip:hover { background: var(--line); }

/* ───── 관리자 ───── */
.brand-pill {
    margin-left: 2px; padding: 2px 8px; border-radius: 999px;
    font-size: 10px; font-weight: 800; letter-spacing: .08em;
    background: #0f172a; color: #fff;
}
.admin-page .topbar { background: rgba(15, 23, 42, .96); border-bottom-color: #1e293b; }
.admin-page .brand, .admin-page .topbar .user-chip { color: #fff; }
.admin-page .brand-pill { background: #38bdf8; color: #0f172a; }
.admin-page .topnav-link { color: #94a3b8; }
.admin-page .topnav-link:hover { background: #1e293b; color: #fff; }
.admin-page .topnav-link.active { background: #1e293b; color: #38bdf8; }
.admin-page .nav-more > summary { color: #94a3b8; }
.admin-page .nav-more > summary:hover,
.admin-page .nav-more[open] > summary,
.admin-page .nav-more.on > summary { background: #1e293b; color: #fff; }
.admin-page .nav-more-menu { background: #1e293b; border-color: #334155; }
.admin-page .nav-more-menu a { color: #e2e8f0; }
.admin-page .nav-more-menu a:hover { background: #334155; }
.admin-page .nav-more-menu a.active { background: #0f172a; color: #38bdf8; }
.admin-page .topbar .user-chip { background: #1e293b; }
.admin-page .topbar .btn-ghost { background: transparent; border-color: #334155; color: #e2e8f0; }
.admin-page .topbar .btn-ghost:hover { background: #1e293b; }
.admin-page .wrap { max-width: 1440px; }

.auth-admin .auth-brand {
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(56, 189, 248, .28), transparent 60%),
        linear-gradient(160deg, #020617, #1e293b);
}
.auth-admin .auth-logo .brand-pill { background: #38bdf8; color: #0f172a; }
.auth-admin .btn-primary { background: linear-gradient(135deg, #1e293b, #0f172a); box-shadow: 0 6px 16px rgba(15, 23, 42, .3); }

.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: #fff; border: 1px solid #fecdd3; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }

.panel { padding: 0; }
.panel > summary { cursor: pointer; padding: 16px 24px; font-weight: 700; list-style: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary:hover { color: var(--brand-700); }
.panel[open] > summary { border-bottom: 1px solid var(--line-soft); }
.panel-body { padding: 20px 24px 24px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-count { font-size: 13px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.field input[type=search], input[type=search].select { padding: 0 12px; }

.table-admin { font-size: 13px; }
.table-admin th, .table-admin td { vertical-align: middle; }
.table-admin td { padding: 8px 10px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.cell {
    width: 96px; height: 32px; padding: 0 6px;
    border: 1px solid transparent; border-radius: 8px; background: transparent;
    font-size: 13px; color: var(--ink);
}
.cell-wide { width: 170px; }
.cell-phone { width: 120px; }
.cell-leg { width: 56px; text-align: center; }
.cell-select { width: 74px; appearance: none; -webkit-appearance: none; }
.cell[readonly], select.cell:disabled { cursor: default; color: var(--ink); opacity: 1; }
.editing .cell:not([readonly]), .editing select.cell {
    background: #fff; border-color: var(--line);
}
.editing .cell:not([readonly]):focus, .editing select.cell:focus {
    outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(20, 184, 166, .15);
}
.editing { background: var(--brand-50); }
.row-inactive td { color: #94a3b8; }
.row-inactive .cell { color: #94a3b8; }
.actions form { margin: 0; }
.table-admin td.actions { display: table-cell; }
.actions > *, .actions form { display: inline-flex; vertical-align: middle; margin-right: 4px; }
.badge-admin { background: #e0f2fe; color: #0369a1; margin-left: 4px; }
.badge-off { background: #fee2e2; color: var(--err); margin-left: 4px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 20px; }
.pager a, .pager .gap {
    min-width: 34px; height: 34px; padding: 0 10px; display: inline-grid; place-items: center;
    border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.pager .gap { border: 0; background: transparent; }
.pager a:hover { background: var(--line-soft); }
.pager a.on { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

/* ───── 반응형 ───── */
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { padding: 32px 24px; }
    .auth-logo { margin-bottom: 20px; }
    .auth-brand h1 { font-size: 24px; }
    .auth-points { display: none; }
    .auth-form-wrap { padding: 32px 20px 48px; }
    .grid-2 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .info-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .topbar-inner { gap: 12px; padding: 0 14px; }
    .user-chip { display: none; }
    .brand-text { display: none; }
    .wrap { padding: 20px 14px 48px; }
    .card { padding: 18px; }
    .form-grid, .form-grid-3, .info-grid { grid-template-columns: 1fr; }
    .tree-viewport { height: calc(100dvh - 300px); min-height: 360px; }
}
