/* EGM NEWSMAIL 관리자 */

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

:root {
    --primary: 271 82% 35%;
    --primary-foreground: 270 100% 97%;
    --foreground: 240 10% 3.9%;
    --background: 0 0% 100%;
    --card: 0 0% 100%;
    --border: 240 5.9% 90%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --ring: 271 82% 35%;
    --gradient-from: 271 82% 35%;
    --gradient-to: 271 65% 45%;
    --success: 142 71% 33%;
    --danger: 0 72% 45%;
    --warning: 38 92% 40%;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --topbar-h: 60px;
    --sidebar-w: 236px;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    font-size: 0.9375rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ─── 로그인 : 1열 브랜드 / 2열 폼 ─────────────────────────────────── */

.auth-layout { display: flex; min-height: 100vh; }

.auth-brand-panel {
    flex: 1;
    background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 3rem; color: #fff;
    position: relative; overflow: hidden;
}
.auth-brand-panel::before,
.auth-brand-panel::after {
    content: ''; position: absolute; border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
}
.auth-brand-panel::before { width: 460px; height: 460px; top: -160px; right: -160px; }
.auth-brand-panel::after  { width: 320px; height: 320px; bottom: -120px; left: -110px; }

.auth-brand-logo {
    position: relative; z-index: 1;
    width: 76px; height: 76px; border-radius: 22px;
    background: rgba(255, 255, 255, 0.16);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.5rem; letter-spacing: -0.02em;
    margin-bottom: 1.75rem;
}
.auth-brand-title {
    position: relative; z-index: 1;
    font-size: 2rem; font-weight: 800; letter-spacing: -0.02em;
}
.auth-brand-subtitle {
    position: relative; z-index: 1;
    margin-top: 0.5rem; font-size: 1rem; font-weight: 500;
    color: rgba(255, 255, 255, 0.86);
}
.auth-brand-tagline {
    position: relative; z-index: 1;
    margin-top: 2rem; max-width: 340px; text-align: center;
    font-size: 0.9375rem; line-height: 1.7;
    color: rgba(255, 255, 255, 0.78);
}
.auth-brand-stats {
    position: relative; z-index: 1;
    margin-top: 2.5rem; display: flex; gap: 2.25rem;
}
.auth-brand-stat__num { font-size: 1.375rem; font-weight: 700; }
.auth-brand-stat__lbl { font-size: 0.8125rem; color: rgba(255, 255, 255, 0.7); }

.auth-form-panel {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 2rem; background: hsl(var(--background));
}
.auth-card { width: 100%; max-width: 420px; }
.auth-logo-circle {
    width: 56px; height: 56px; border-radius: 50%;
    background: hsl(var(--muted));
    display: none; align-items: center; justify-content: center;
    font-weight: 800; color: hsl(var(--primary)); margin-bottom: 1.25rem;
}
.auth-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.auth-subtitle {
    margin-top: 0.375rem; margin-bottom: 1.75rem;
    color: hsl(var(--muted-foreground)); font-size: 0.9375rem;
}
.auth-form { display: flex; flex-direction: column; gap: 0.875rem; }
.auth-footer {
    margin-top: 2rem; text-align: center;
    font-size: 0.8125rem; color: hsl(var(--muted-foreground));
}

.input-icon-wrap { position: relative; }
.input-icon {
    position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%);
    color: hsl(var(--muted-foreground)); display: flex; pointer-events: none;
}
.input-with-icon { padding-left: 2.625rem !important; }

/* ─── 공통 폼 ───────────────────────────────────────────────────── */

.form-input, .form-select {
    width: 100%; padding: 0.75rem 1rem;
    border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg);
    font-size: 0.9375rem; font-family: inherit; min-height: 2.75rem;
    color: hsl(var(--foreground)); background: hsl(var(--card));
    outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.form-input:focus, .form-select:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}
.form-input--sm { min-height: 2.25rem; padding: 0.4rem 0.6rem; font-size: 0.875rem; border-radius: var(--radius); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem; border: 1px solid transparent; border-radius: var(--radius-lg);
    font-size: 0.9375rem; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: all .15s ease; min-height: 2.75rem; white-space: nowrap;
}
.btn--primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); width: 100%; }
.btn--primary:hover { background: hsl(var(--primary) / 0.92); }
.btn--sm { min-height: 2.125rem; padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: var(--radius); width: auto; }
.btn--outline { background: hsl(var(--card)); border-color: hsl(var(--border)); color: hsl(var(--foreground)); width: auto; }
.btn--outline:hover { background: hsl(var(--muted)); }
.btn--ghost { background: transparent; color: hsl(var(--muted-foreground)); width: auto; }
.btn--ghost:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.btn--danger { background: hsl(var(--danger)); color: #fff; width: auto; }
.btn--danger:hover { background: hsl(var(--danger) / 0.9); }
.btn--solid { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); width: auto; }
.btn--solid:hover { background: hsl(var(--primary) / 0.92); }

.auth-error, .alert {
    padding: 0.75rem 1rem; border-radius: var(--radius-lg);
    font-size: 0.875rem; margin-bottom: 1rem;
}
.auth-error, .alert--error {
    background: hsl(var(--danger) / 0.08); color: hsl(var(--danger));
    border: 1px solid hsl(var(--danger) / 0.25);
}
.alert--success {
    background: hsl(var(--success) / 0.08); color: hsl(var(--success));
    border: 1px solid hsl(var(--success) / 0.25);
}
.alert--warn {
    background: hsl(var(--warning) / 0.10); color: hsl(var(--warning));
    border: 1px solid hsl(var(--warning) / 0.3);
}

/* ─── 상단바 ───────────────────────────────────────────────────── */

.topbar {
    position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 40;
    display: flex; align-items: center; gap: 0.75rem; padding: 0 1rem;
    background: hsl(var(--card)); border-bottom: 1px solid hsl(var(--border));
}
.topbar__toggle {
    display: none; width: 38px; height: 38px; border: 1px solid hsl(var(--border));
    background: hsl(var(--card)); border-radius: var(--radius); cursor: pointer;
    align-items: center; justify-content: center; color: hsl(var(--foreground));
}
.topbar__toggle svg { width: 20px; height: 20px; }
.topbar__brand { display: flex; align-items: center; gap: 0.625rem; }
.topbar__mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
    color: #fff; font-weight: 800; font-size: 0.75rem;
    display: flex; align-items: center; justify-content: center; letter-spacing: -0.02em;
}
.topbar__name { font-weight: 700; letter-spacing: -0.01em; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: 0.5rem; }
.topbar__avatar {
    width: 30px; height: 30px; border-radius: 50%; background: hsl(var(--muted));
    color: hsl(var(--primary)); font-weight: 700; font-size: 0.8125rem;
    display: flex; align-items: center; justify-content: center;
}
.topbar__uname { font-size: 0.875rem; font-weight: 500; }
.topbar__logout { display: flex; }

/* ─── 사이드바 + 본문 (본문 폭 100%) ───────────────────────────── */

.shell { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }

.sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
    background: hsl(var(--card)); border-right: 1px solid hsl(var(--border));
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 0.875rem 0.75rem; overflow-y: auto; z-index: 30;
}
.sidenav { display: flex; flex-direction: column; gap: 0.125rem; }
.sidenav__item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.625rem 0.75rem; border-radius: var(--radius);
    font-size: 0.9375rem; font-weight: 500; color: hsl(var(--muted-foreground));
    transition: background .12s ease, color .12s ease;
}
.sidenav__item:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.sidenav__item.is-active { background: hsl(var(--primary) / 0.10); color: hsl(var(--primary)); font-weight: 600; }
.sidenav__icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidenav__foot { padding: 0.75rem; }
.sidenav__meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); line-height: 1.5; }

.sidebar-scrim {
    position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, 0.4);
    z-index: 25; display: none;
}
body.sidebar-open .sidebar-scrim { display: block; }

/* 콘텐츠 영역은 남은 폭을 100% 사용 */
.content { flex: 1; min-width: 0; margin-left: var(--sidebar-w); background: hsl(var(--muted) / 0.45); }
.content__inner { width: 100%; max-width: none; padding: 1.5rem; }

/* ─── 페이지 공통 ──────────────────────────────────────────────── */

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { margin-top: 0.25rem; color: hsl(var(--muted-foreground)); font-size: 0.875rem; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card {
    background: hsl(var(--card)); border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg); margin-bottom: 1.25rem;
}
.card__head {
    padding: 0.875rem 1.125rem; border-bottom: 1px solid hsl(var(--border));
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.card__title { font-weight: 650; font-size: 0.9375rem; }
.card__body { padding: 1.125rem; }
.card__body--flush { padding: 0; }

.stat-grid {
    display: grid; gap: 0.875rem; margin-bottom: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.stat {
    background: hsl(var(--card)); border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg); padding: 1rem 1.125rem;
}
.stat__label { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.stat__value { margin-top: 0.375rem; font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; }
.stat__hint { margin-top: 0.25rem; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th, table.data td {
    padding: 0.625rem 0.75rem; text-align: left; border-bottom: 1px solid hsl(var(--border));
    vertical-align: middle;
}
table.data thead th {
    background: hsl(var(--muted) / 0.6); font-weight: 600; font-size: 0.8125rem;
    color: hsl(var(--muted-foreground)); white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr:hover { background: hsl(var(--muted) / 0.45); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .cell-actions { display: flex; gap: 0.375rem; justify-content: flex-end; }
.row-form td { background: hsl(var(--primary) / 0.04); }

.chk { width: 18px; height: 18px; accent-color: hsl(var(--primary)); cursor: pointer; }
.badge {
    display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
}
.badge--on { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); }
.badge--off { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

.tabs { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab {
    padding: 0.4375rem 0.875rem; border-radius: 999px; font-size: 0.875rem; font-weight: 500;
    border: 1px solid hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--muted-foreground));
}
.tab:hover { background: hsl(var(--muted)); }
.tab.is-active { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: #fff; font-weight: 600; }
.tab__count { opacity: .75; margin-left: 0.25rem; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.toolbar .form-input { width: auto; min-width: 220px; }

.bars { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 64px; gap: 0.75rem; align-items: center; font-size: 0.8125rem; }
.bar-track { height: 8px; background: hsl(var(--muted)); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: hsl(var(--primary)); border-radius: 999px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: hsl(var(--muted-foreground)); }

.logbox {
    background: #0f1115; color: #d6d9e0; border-radius: var(--radius-lg);
    padding: 1rem; overflow-x: auto; font-size: 0.8125rem; line-height: 1.55;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    max-height: 65vh; white-space: pre-wrap; word-break: break-all;
}

.empty { padding: 2.5rem 1rem; text-align: center; color: hsl(var(--muted-foreground)); font-size: 0.9375rem; }
.muted { color: hsl(var(--muted-foreground)); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; }

/* ─── 반응형 ───────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .auth-brand-panel { display: none; }
    .auth-logo-circle { display: flex; }
}

@media (max-width: 860px) {
    .topbar__toggle { display: flex; }
    .topbar__name { display: none; }
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .content { margin-left: 0; }
    .content__inner { padding: 1rem; }
    .topbar__uname { display: none; }
}

/* 수집 목록의 글 내용 발췌 */
.excerpt {
    margin-top: 5px;
    font-size: .8125rem;
    line-height: 1.65;
    color: #52525b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}
.excerpt.is-open {
    -webkit-line-clamp: unset;
}

/* 목록 페이징 */
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    padding: 16px 12px;
    border-top: 1px solid var(--line, #e4e4e7);
}
.pager__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border: 1px solid var(--line, #e4e4e7);
    border-radius: 7px;
    font-size: .8125rem;
    line-height: 1;
    color: #3f3f46;
    text-decoration: none;
    background: #fff;
}
.pager__item:hover { background: #fafafa; }
.pager__item.is-current {
    background: var(--brand, #6b21a8);
    border-color: var(--brand, #6b21a8);
    color: #fff;
    font-weight: 600;
}

/* 게시글에 달린 댓글 */
.comments { margin-top: 7px; }
.comments > summary,
.postbody > summary {
    display: inline-block;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 600;
    color: var(--brand, #6b21a8);
    background: #f6effc;
    border-radius: 999px;
    padding: 2px 10px;
    list-style: none;
}
.comments > summary::-webkit-details-marker,
.postbody > summary::-webkit-details-marker { display: none; }
.comments > summary:hover,
.postbody > summary:hover { background: #efe3fa; }
.comment {
    margin-top: 6px;
    padding-left: 10px;
    border-left: 2px solid #e9d5ff;
    font-size: .8125rem;
    line-height: 1.65;
    color: #52525b;
}
.comment--reply { margin-left: 16px; border-left-color: #f1f1f3; }
.comment__who { font-weight: 600; color: #3f3f46; margin-right: 6px; }

/* 수집한 글 본문 (카페·블로그) */
.postbody { margin-top: 7px; }
.postbody__text {
    margin-top: 6px;
    padding: 10px 12px;
    max-height: 420px;
    overflow-y: auto;
    border-left: 2px solid #e9d5ff;
    background: #fafafa;
    font-size: .8125rem;
    line-height: 1.75;
    color: #3f3f46;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* 검색 키워드가 걸린 부분 */
mark {
    background: #fde68a;
    color: #78350f;
    font-weight: 700;
    border-radius: 3px;
    padding: 0 2px;
}

/* ─── 관리자 / 병원 화면 구분 ─────────────────────────────────── */
.topbar__area {
    padding: 0.125rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
    background: hsl(var(--primary) / 0.10); color: hsl(var(--primary));
}
.topbar__area--clinic { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
@media (max-width: 640px) { .topbar__area--clinic { display: none; } }

/* 관리자 대리 로그인 중 */
.imp-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
    margin-bottom: 1.25rem; padding: 0.75rem 1rem; border-radius: var(--radius-lg);
    background: #fff7e6; border: 1px solid #f5c451; color: #5c3d00; font-size: 0.875rem;
}
.imp-banner strong { margin-right: 0.375rem; }

/* 병원 계정: 비밀번호 칸 + 생성 버튼 */
.pw-field { display: flex; gap: 0.25rem; align-items: center; }
.pw-field .form-input { min-width: 9rem; }
.row-form select[name="clinic_srl"] { min-width: 11rem; }
.badge { white-space: nowrap; }

/* ─── 분석 화면 ──────────────────────────────────────────────── */
.card__note { font-weight: 400; font-size: 0.8125rem; margin-left: 0.375rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.375rem; vertical-align: 1px; }

.stat--lead { border-color: hsl(var(--primary) / 0.35); }
.stat__value small { font-size: 0.875rem; font-weight: 500; margin-left: 0.125rem; color: hsl(var(--muted-foreground)); }
.stat__delta { margin-top: 0.25rem; font-size: 0.8125rem; font-weight: 600; color: hsl(var(--foreground)); }
.stat__delta span { font-weight: 400; color: hsl(var(--muted-foreground)); }

.an-filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; margin-bottom: 1.25rem; }
.an-filter { display: flex; align-items: center; gap: 0.5rem; }
.an-filter__label { font-size: 0.8125rem; font-weight: 600; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.an-filter .form-input { width: auto; min-width: 12rem; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: hsl(var(--muted)); max-width: 100%; overflow-x: auto; }
.seg__item {
    padding: 0.3125rem 0.75rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 500;
    color: hsl(var(--muted-foreground)); white-space: nowrap;
}
.seg__item:hover { color: hsl(var(--foreground)); }
.seg__item.is-active { background: hsl(var(--card)); color: hsl(var(--primary)); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.an-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.an-grid--wide-right { grid-template-columns: 2fr 3fr; }
.an-multi { display: grid; gap: 1.5rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.an-multi--1 { grid-template-columns: minmax(0, 1fr); }
.an-multi--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.an-multi__title { font-size: 0.8125rem; font-weight: 650; margin-bottom: 0.5rem; }
.an-note--top { margin: -0.5rem 0 1.25rem; }
.an-note { margin-top: 0.75rem; font-size: 0.75rem; line-height: 1.6; color: hsl(var(--muted-foreground)); word-break: keep-all; }
table.data.an-table { min-width: 36rem; }   /* 좁은 화면에서는 가로로 밀어 본다 */
.an-list { margin: 0; padding-left: 1.1rem; font-size: 0.875rem; line-height: 1.9; }
.an-list b { margin-right: 0.375rem; }
@media (max-width: 1100px) {
    .an-grid, .an-grid--wide-right { grid-template-columns: 1fr; }
    .an-multi, .an-multi--2 { grid-template-columns: 1fr; }
}

/* 최근 언급 목록 */
.feed { list-style: none; margin: 0; padding: 0; }
.feed__item {
    display: grid; grid-template-columns: 5.5rem 1fr; column-gap: 0.75rem;
    padding: 0.625rem 1.125rem; border-bottom: 1px solid hsl(var(--border));
}
.feed__item:last-child { border-bottom: 0; }
.feed__ch { grid-row: span 2; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.feed__title { font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__title:hover { color: hsl(var(--primary)); }
.feed__meta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

/* ─── 차트 (assets/js/charts.js) ─────────────────────────────── */
/* 채널 색: 카페·블로그·유튜브 = 1·2·3번 (색각 이상 검사 통과, 흰 바탕 기준) */
:root {
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --viz-total: #6d3fc4;      /* 채널을 합친 한 계열 */
    --viz-other: #b3aebd;      /* 비교용 회색 (제외 등) */
}
.viz {
    --viz-grid: #eeecf2;
    --viz-base: #cdc9d6;
    --viz-ink: #18181b;
    --viz-muted: #86828f;
    position: relative;
    min-height: 40px;
}
.viz__bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.625rem; }
.viz__legend { display: flex; flex-wrap: wrap; gap: 0.25rem 0.875rem; font-size: 0.8125rem; color: hsl(var(--foreground)); }
.viz__legend-item { display: inline-flex; align-items: center; gap: 0.375rem; }
.viz__swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.viz__toggle {
    margin-left: auto; padding: 0.125rem 0.5rem; border: 1px solid hsl(var(--border)); border-radius: 6px;
    background: hsl(var(--card)); color: hsl(var(--muted-foreground)); font-size: 0.75rem; cursor: pointer; white-space: nowrap;
}
.viz__toggle:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); }
.viz__plot svg { display: block; overflow: visible; }
.viz__plot svg:focus-visible { outline: 2px solid hsl(var(--primary) / .5); outline-offset: 2px; border-radius: 4px; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-base { stroke: var(--viz-base); stroke-width: 1; shape-rendering: crispEdges; }
.viz-tick { font-size: 11px; fill: var(--viz-muted); font-variant-numeric: tabular-nums; }
.viz-peak { font-size: 11px; font-weight: 700; fill: var(--viz-ink); }
.viz-hover { fill: hsl(var(--primary) / 0.06); }
.viz__empty { padding: 2rem 0; text-align: center; font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.viz__table .table-wrap { max-height: 320px; overflow: auto; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }

.viz__tip {
    position: absolute; z-index: 5; pointer-events: none; min-width: 120px; max-width: 260px;
    padding: 0.5rem 0.625rem; border-radius: 8px; background: #fff;
    border: 1px solid rgba(11, 11, 11, .10); box-shadow: 0 8px 24px rgba(20, 10, 40, .14); font-size: 0.75rem;
}
.viz__tip-title { font-weight: 650; margin-bottom: 0.25rem; color: var(--viz-ink); }
.viz__tip-row { display: flex; align-items: center; gap: 0.375rem; line-height: 1.7; }
.viz__tip-row.is-total { border-top: 1px solid hsl(var(--border)); margin-top: 0.125rem; padding-top: 0.125rem; }
.viz__tip-key { width: 12px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.viz__tip-key.is-blank { background: transparent; }
.viz__tip-val { font-variant-numeric: tabular-nums; color: var(--viz-ink); }
.viz__tip-name { color: var(--viz-muted); }

/* 가로 막대 (hbars · hstack) */
.hb { display: flex; flex-direction: column; gap: 0.375rem; }
.hb__row { display: grid; grid-template-columns: minmax(5rem, 34%) 1fr 3rem; align-items: center; gap: 0.625rem; font-size: 0.8125rem; border-radius: 4px; }
.hb__row:hover { background: hsl(var(--primary) / 0.04); }
.hb__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: hsl(var(--foreground)); }
.hb__track { display: block; height: 14px; }
.hb__fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hb__stack { display: flex; gap: 2px; height: 100%; }
.hb__seg { display: block; height: 100%; min-width: 2px; }
.hb__seg:last-child { border-radius: 0 4px 4px 0; }
.hb__seg:hover, .share__seg:hover { filter: brightness(1.08); }
.hb__val { text-align: right; font-variant-numeric: tabular-nums; color: hsl(var(--foreground)); font-weight: 600; }

/* 구성비 한 줄 (share) */
.share { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; }
.share__seg { display: block; height: 100%; min-width: 2px; }
.share__keys { display: flex; flex-direction: column; gap: 0.375rem; margin-top: 0.875rem; }
.share__key { display: grid; grid-template-columns: 10px 1fr auto 3.5rem; align-items: center; gap: 0.5rem; font-size: 0.8125rem; }
.share__val { text-align: right; font-variant-numeric: tabular-nums; }
.share__pct { text-align: right; font-variant-numeric: tabular-nums; color: hsl(var(--muted-foreground)); }

/* 좁은 화면: 숫자 타일은 두 줄로 */
@media (max-width: 640px) {
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.625rem; }
    .stat { padding: 0.875rem; }
    .stat__value { font-size: 1.375rem; }
    .an-filter { max-width: 100%; }
}
