/* Pretendard (가변 폰트, 자체 호스팅 — assets/fonts/, 라이선스: SIL OFL 1.1, LICENSE.txt 동봉) */
@font-face {
    font-family: "Pretendard";
    font-weight: 45 920;
    font-style: normal;
    font-display: swap;
    src: url("./assets/fonts/PretendardVariable.woff2") format("woff2-variations");
}

/* ============================================================
   ROOT
============================================================ */

:root {
    --bg: #f6f7fa;
    --white: #ffffff;
    --text: #202939;
    --soft: #687386;
    --light: #9ca5b3;
    --border: #e5e8ef;
    --border-soft: #f0f2f5;

    /* KISA 공식 브랜드 컬러 */
    --kisa-main-blue: #00387f;   /* PANTONE 281 C */
    --kisa-blue: #004ea2;
    --kisa-blue-light: #6fa3d8;
    --kisa-dark-blue: #002b69;
    --kisa-green: #8fc31f;
    --kisa-dark-green: #608709;
    --kisa-green-soft: #eef8da;
    --kisa-blue-soft: #e5edf7;

    --primary: var(--kisa-blue);
    --primary-soft: var(--kisa-blue-soft);

    --pink: #ed729f;
    --pink-dark: #cf5c86;
    --pink-soft: #fff0f5;

    --blue: #6578d8;
    --blue-dark: #5267c3;
    --blue-soft: #eef1ff;

    --sidebar: 270px;

    --sidebar-background: #0f172a;
    --nav-blue: var(--kisa-blue);
    --nav-blue-light: var(--kisa-blue-light);
    --status-green: var(--kisa-green);
    --status-yellow: #f59e0b;
    --status-red: #ef4444;

    --navy: var(--kisa-dark-blue);
    --navy-dark: var(--kisa-main-blue);
    --navbar-height: 90px;
    --header-offset: var(--navbar-height);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    word-break: keep-all;
}

button { font-family: inherit; }

/* ============================================================
   TOP NAVBAR
============================================================ */

.top-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--navbar-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.navbar-logo-wrap {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.navbar-logo {
    height: 34px;
    width: auto;
    display: block;
}

.navbar-logo-wrap.navbar-logo-fallback {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--navy);
    display: grid;
    place-items: center;
}

.navbar-logo-wrap.navbar-logo-fallback::after {
    content: "K";
    color: #ffffff;
    font-size: 17.5px;
    font-weight: 850;
}

.navbar-title {
    color: var(--navy);
    font-size: 23px;
    font-weight: 800;
    letter-spacing: -.3px;
}

.navbar-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-meta-icon {
    width: 20px; height: 20px;
    flex: 0 0 auto;
    color: var(--soft);
}

.navbar-meta > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.navbar-meta-label {
    color: var(--soft);
    font-size: 13.5px;
    font-weight: 600;
}

.navbar-meta-value {
    color: var(--navy);
    font-size: 16px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   INFO BAR
============================================================ */

.info-bar {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
}

.info-card {
    flex: 0 0 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(16,42,92,.04);
}

.info-card-icon {
    width: 22px; height: 22px;
    flex: 0 0 auto;
    color: var(--navy);
}

.info-card-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.info-card-label { color: var(--soft); font-size: 11.5px; font-weight: 700; }
.info-card-main { font-size: 15px; font-weight: 800; }
.info-card-sub { color: var(--soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.info-card p {
    margin: 0;
    color: var(--soft);
    font-size: 13px;
    line-height: 1.55;
}

.info-card-notice {
    background: #fff5f6;
    border-color: #f6cdd3;
}

.info-card-notice p { color: #a94454; }

.info-highlight {
    color: var(--nav-blue);
    font-weight: 800;
}

/* 통계 기간 카드 우측 상단 장식 원 */
.info-card { position: relative; overflow: hidden; isolation: isolate; }
.info-card::after {
    content: "";
    position: absolute;
    top: -26px;
    right: -22px;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: var(--kisa-blue-soft);
    opacity: .7;
    z-index: -1;
    pointer-events: none;
}

/* ============================================================
   SIDEBAR
============================================================ */

.sidebar {
    position: fixed;
    left: 0; top: var(--header-offset); bottom: 0;
    z-index: 30;
    width: var(--sidebar);
    padding: 28px 22px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;

    background:
        radial-gradient(circle at top left, rgba(59,130,246,.25), transparent 33%),
        radial-gradient(circle at 80% 75%, rgba(139,92,246,.13), transparent 32%),
        var(--sidebar-background);
    color: #ffffff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 4px 24px;
}

.brand-logo {
    flex: 0 0 auto;
    width: 50px; height: 50px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 52%, #7c3aed 100%);
    color: #ffffff;
    font-size: 25px;
    font-weight: 900;
    box-shadow: 0 14px 34px rgba(37,99,235,.38);
}

.brand-subtitle {
    margin: 0 0 4px;
    color: var(--nav-blue-light);
    font-size: 12.5px;
    font-weight: 900;
    letter-spacing: 1.35px;
}

.brand h1 {
    margin: 0;
    color: #ffffff;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.25;
}

.sidebar-navigation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
    flex: 1;
}

.navigation-button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 15px;
    border-radius: 13px;
    background: transparent;
    color: #cbd5e1;
    text-align: left;
    font-size: 15px;
    font-weight: 750;
    cursor: pointer;
    border: none;
    transition: background-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.navigation-button:hover {
    background: rgba(255,255,255,.075);
    color: #ffffff;
    transform: translateX(3px);
}

.navigation-button.active {
    background: linear-gradient(135deg, rgba(59,130,246,.98), rgba(37,99,235,.92));
    color: #ffffff;
    box-shadow: 0 11px 27px rgba(37,99,235,.28);
}

.navigation-button.active::before {
    content: "";
    position: absolute;
    top: 50%; left: 7px;
    width: 3px; height: 21px;
    border-radius: 999px;
    background: #ffffff;
    transform: translateY(-50%);
}

.navigation-icon {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--nav-blue-light);
    font-size: 17.5px;
    font-weight: 900;
    transition: color .2s ease, transform .2s ease;
}

.navigation-button:hover .navigation-icon,
.navigation-button.active .navigation-icon {
    color: #ffffff;
    transform: scale(1.07);
}

.data-status-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    padding: 16px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 15px;
    background: rgba(255,255,255,.05);
}

.status-dot {
    flex: 0 0 auto;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--status-yellow);
    box-shadow: 0 0 0 5px rgba(245,158,11,.13);
}

.status-dot.loading { animation: status-pulse 1.35s ease-in-out infinite; }
.status-dot.connected { background: var(--status-green); box-shadow: 0 0 0 5px rgba(16,185,129,.13); }
.status-dot.error { background: var(--status-red); box-shadow: 0 0 0 5px rgba(239,68,68,.13); }

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

.data-status-box strong { display: block; margin-bottom: 2px; color: #ffffff; font-size: 14.5px; }
.data-status-box p { margin: 0; color: #94a3b8; font-size: 14px; }

/* ----- 좌측 정보 패널 ----- */
.side-head { padding: 2px 2px 20px; }

.side-head h1 {
    margin: 0 0 12px;
    color: #ffffff;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.3;
}
.side-head p {
    margin: 0;
    color: #94a3b8;
    font-size: 11.5px;
    line-height: 1.7;
}

.side-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 2px;
    border-top: 1px solid rgba(255,255,255,.09);
    border-bottom: 1px solid rgba(255,255,255,.09);
}
.side-label {
    color: #6fa3d8;
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 1.1px;
}
.side-value { color: #ffffff; font-size: 15.5px; font-weight: 800; }
.side-sub { color: #94a3b8; font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ============================================================
   MAIN
============================================================ */

.main {
    margin-left: var(--sidebar);
    padding: 38px 39px 70px;
    margin-top: var(--header-offset);
}

/* ============================================================
   HEADER
============================================================ */

.page-header-row {
    margin-bottom: 25px;
    padding: 22px 26px;
    border-radius: 16px;
    background: var(--kisa-main-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.page-header {
    flex: 1 1 320px;
    scroll-margin-top: 25px;
    min-width: 0;
}

.eyebrow, .section-label {
    color: var(--primary);
    font-size: 11.5px;
    font-weight: 850;
    letter-spacing: 1.5px;
}

.page-header h2 {
    position: relative;
    margin: 0;
    padding-left: 15px;
    color: #ffffff;
    font-size: 33px;
    line-height: 1.2;
    font-weight: 820;
    letter-spacing: -.8px;
}

.page-header h2::before {
    content: "";
    position: absolute;
    left: 0; top: 3px; bottom: 3px;
    width: 5px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--kisa-green), var(--kisa-dark-green));
}

.page-header p {
    margin: 9px 0 0;
    color: rgba(255,255,255,.72);
    font-size: 13.5px;
    line-height: 1.65;
    white-space: nowrap;
}

.usage-note {
    margin: -8px 0 20px;
    color: var(--soft);
    font-size: 13px;
    line-height: 1.6;
}

/* ============================================================
   SUMMARY
============================================================ */

.summary-grid {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(200px, 260px);
    gap: 10px;
}

.summary-card {
    position: relative;
    min-width: 0;
    min-height: 108px;
    padding: 17px 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.summary-label { margin-bottom: 11px; color: var(--soft); font-size: 11.5px; font-weight: 700; }
.summary-period { margin-bottom: 8px; font-size: 15px; font-weight: 780; }

.summary-card small { margin-top: auto; color: var(--light); font-size: 10.5px; }

/* ============================================================
   CHARTS GRID (좌우 배치)
============================================================ */

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 15px;
}

/* ============================================================
   CARD
============================================================ */

.dashboard-card {
    margin-bottom: 15px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 5px 26px rgba(32,42,65,.025);
    overflow: hidden;
    scroll-margin-top: 25px;
    display: flex;
    flex-direction: column;
}
/* 두 카드가 같은 높이일 때 목록 영역이 남는 공간을 흡수 */
.dashboard-card .top10-list { flex: 1 0 auto; }

.card-header {
    height: 118px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.card-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 810;
    letter-spacing: -.25px;
    display: flex;
    align-items: center;
    gap: 10px;
}
/* 제목 앞 색칠된 네모 (섹션 마커) */
.card-header h2::before {
    content: "";
    flex: 0 0 auto;
    width: 7px;
    height: 19px;
    border-radius: 3px;
    background: var(--kisa-main-blue);
}
#guide .card-header h2::before { background: var(--kisa-dark-green); }

.card-header p { margin: 7px 0 0; color: var(--soft); font-size: 12px; line-height: 1.65; }

.header-badge {
    padding: 6px 9px;
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 10.5px;
    font-weight: 850;
}

/* 카드 우측 상단 장식 원 (이번 주 많이 들어온 상담 / 상담 유형 안내) */
.dashboard-card { position: relative; isolation: isolate; }
.dashboard-card::after {
    content: "";
    position: absolute;
    top: -50px;
    right: -50px;
    width: 138px;
    height: 138px;
    border-radius: 50%;
    background: var(--kisa-blue-soft);
    opacity: .55;
    z-index: -1;
    pointer-events: none;
}
.dashboard-card::before {
    content: "";
    position: absolute;
    top: 16px;
    right: -40px;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 1.5px solid #d9e5f5;
    z-index: -1;
    pointer-events: none;
}
#guide.dashboard-card::after { background: var(--kisa-green-soft); }
#guide.dashboard-card::before { border-color: #e0eec6; }

/* ============================================================
   TOP10 / RANKED LIST
============================================================ */

.top10-list { padding: 4px 21px 12px; }

.top10-row {
    min-height: 60px;
    padding-left: 10px;
    border-bottom: 1px solid var(--border-soft);
    display: grid;
    grid-template-columns: 30px minmax(120px, 1fr);
    align-items: center;
    gap: 10px;
}

.top10-row:last-child { border-bottom: none; }

.rank { color: #aab1bc; font-size: 12.5px; font-weight: 850; }

.top-category { min-width: 0; }

.category-name { display: flex; align-items: center; gap: 8px; }
.category-name strong {
    overflow: hidden;
    font-size: 16px;
    font-weight: 750;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cat-swatch { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 이번 주 많이 들어온 상담: 비중 도넛 영역 (숫자 라벨 없음 — hover 툴팁과 아래 목록으로 값 확인) */
.top10-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 18px;
    height: 266px;
}
.donut { width: 208px; height: 208px; }
.donut path { stroke: #fff; stroke-width: 2; }
.donut path[data-category] { cursor: pointer; }

.top10-row.is-etc { cursor: default; }
.top10-row.is-etc .category-name strong { color: var(--soft); }

/* 차트 hover 툴팁 (도넛) */
.chart-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    max-width: 260px;
    padding: 8px 11px;
    border-radius: 8px;
    background: rgba(17, 24, 39, .93);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-line;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
.chart-tooltip[hidden] { display: none; }

/* 클릭 가능한 목록 행 — 선택된 유형은 안내 패널에 표시됨 */
.top10-row.clickable { cursor: pointer; border-radius: 10px; transition: background .12s ease; }
.top10-row.clickable:hover { background: #fafbfe; }
.top10-row.clickable.selected {
    background: var(--kisa-blue-soft);
    box-shadow: inset 3px 0 0 var(--kisa-main-blue);
}

/* ============================================================
   CONSULTATION GUIDE (인라인 안내 패널)
============================================================ */

.guide-panel {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    padding: 20px 22px;
}

.guide-placeholder {
    margin: auto 0;
    padding: 30px 10px;
    color: var(--light);
    font-size: 13px;
    text-align: center;
}

/* 카드 제목(h2)과 헷갈리지 않도록 "선택된 유형"은 작은 라벨 + 큰 이름으로 표시 */
.guide-title-block { margin: 0 0 16px; }
.guide-title-label {
    display: block;
    margin-bottom: 4px;
    color: var(--soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .4px;
}
.guide-title {
    margin: 0;
    color: var(--text);
    font-size: 19px;
    font-weight: 850;
}

.consultation-guide-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.consultation-guide-section {
    padding: 18px;
    border: 1px solid #dcefc7;
    border-radius: 14px;
    background: var(--kisa-green-soft);
}

/* 목록 기본 불릿(•) 제거 — 텍스트가 좌측에서 바로 시작 */
.consultation-guide-section ul { margin: 0; padding-left: 0; list-style: none; }
.consultation-guide-section li {
    list-style: none;
    margin-bottom: 8px;
    color: var(--soft);
    font-size: 12.5px;
    line-height: 1.7;
    word-break: keep-all;       /* 한글이 음절 단위로 잘려 줄바꿈되는 것 방지 */
    overflow-wrap: break-word;  /* 긴 URL 등은 필요할 때 줄바꿈 허용 */
}
.consultation-guide-section li:last-child { margin-bottom: 0; }

/* "▶ ..." 소제목 항목 */
.consultation-guide-section li.guide-lead {
    margin-bottom: 10px;
}

/* 서로 다른 사례를 나누는 구분 라벨 (색칠된 네모) */
.consultation-guide-section li.guide-case {
    margin-top: 16px;
    margin-bottom: 10px;
}
.consultation-guide-section li.guide-case:first-child { margin-top: 0; }

.consultation-guide-section .guide-case-label {
    display: inline-block;
    padding: 6px 13px;
    border-radius: 8px;
    background: var(--kisa-dark-green);
    color: #ffffff;
    font-size: 15px;
    font-weight: 750;
    line-height: 1.4;
}

/* 소제목 항목: "▶" 글자 대신 왼쪽 초록 강조바로 표시, 첫 줄만 강조 */
.consultation-guide-section .guide-head {
    display: block;
    padding-left: 10px;
    border-left: 3px solid var(--kisa-dark-green);
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
}
.consultation-guide-section .guide-detail {
    display: block;
    margin-top: 4px;
    padding-left: 13px;
    color: var(--soft);
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.7;
}

/* 일반 번호 항목: 번호(1., 2. …)를 그대로 살려 좌측 정렬 */
.consultation-guide-section li.guide-num {
    margin-left: 0;
}

/* "※ ..." 참고 문구 */
.consultation-guide-section li.guide-note {
    margin-top: 10px;
    color: var(--soft);
    font-size: 12px;
}

/* 모든 상담 안내에 공통으로 노출되는 안내 문구 */
.guide-footnote {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--soft);
    font-size: 12.5px;
    line-height: 1.7;
    text-align: center;
}

/* ============================================================
   COMMON
============================================================ */

.hidden { display: none !important; }

.error-state {
    min-height: 160px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--light);
    font-size: 11.5px;
    text-align: center;
}

.error-state strong { color: var(--soft); font-size: 13.5px; }

/* ============================================================
   RESPONSIVE
============================================================ */

@media (max-width: 1250px) {
    :root { --sidebar: 198px; }
    .main { padding: 32px 27px 60px; }
}

@media (max-width: 960px) {
    .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { display: none; }
    .main { width: 100%; margin-left: 0; padding: 25px 16px 50px; }
    .top10-row {
        grid-template-columns: 30px minmax(220px, 1fr);
    }
    .top-navbar { padding: 0 16px; }
    .navbar-title { font-size: 17.5px; }
    .info-bar { padding: 10px; flex-wrap: wrap; }
    .info-card { flex: 1 1 45%; }
    .page-header p { white-space: normal; }
}

@media (max-width: 650px) {
    :root { --navbar-height: 76px; }
    .top10-row { grid-template-columns: 26px 1fr; }
    .consultation-guide-grid { grid-template-columns: 1fr; }
    .navbar-meta-label { display: none; }
    .info-bar { flex-direction: column; }
    .info-card { flex: 1 1 auto; }
}
