:root {
    --bg: #f0f2f5;
    --panel: #ffffff;
    --accent: #2f5d50;
    --accent-light: #e8f5f1;
    --muted: #64748b;
    --border: #e2e8f0;
    --text-main: #1e293b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Pretendard", "Noto Sans KR", sans-serif;
    background: url('/bg.webp') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

.header { margin-bottom: 32px; }
.header h1 { font-size: 28px; font-weight: 800; margin: 0; color: #0f172a; }
.subtitle { color: var(--muted); margin-top: 4px; }

/* KPI 요약 카드 */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: var(--panel);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.card .label { font-size: 13px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 8px; }
.card strong { font-size: 24px; color: var(--accent); }

/* 글래스모피즘 패널 */
.panel {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 28px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

/* 통계 패널 */
.stats-panel {
    max-width: 900px;
    margin: 0 auto;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stats-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 테이블 영역 */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.controls input {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-size: 14px;
    color: #ffffff;
    backdrop-filter: blur(10px);
}

.controls input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
}

.controls button {
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.controls button:hover {
    background: rgba(255, 255, 255, 0.35);
}

table { width: 100%; border-collapse: collapse; }
table th { text-align: left; padding: 12px; font-size: 13px; color: var(--muted); border-bottom: 2px solid var(--border); }
table td { padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 막대 그래프 테이블 */
.bar-table {
    width: 100%;
    border-collapse: collapse;
}

.bar-table th {
    text-align: center;
    padding: 14px 12px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.bar-table td {
    padding: 16px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.9);
}

.bar-table .col-name {
    width: 20%;
    text-align: center;
    font-weight: 500;
}

.bar-table .col-bar {
    width: 80%;
    padding: 16px 20px;
}

/* 가로 막대 그래프 */
.bar-bg {
    width: 100%;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    min-width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.bar-label {
    color: white;
    font-size: 13px;
    font-weight: 600;
    padding: 0 12px;
    white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* 순위별 막대 색상 */
.rank-1 .bar-fill { background: linear-gradient(90deg, #dc2626, #ef4444); } /* 빨간색 */
.rank-2 .bar-fill { background: linear-gradient(90deg, #ca8a04, #eab308); } /* 노란색 */
.rank-3 .bar-fill { background: linear-gradient(90deg, #ea580c, #f97316); } /* 주황색 */
.rank-4 .bar-fill { background: linear-gradient(90deg, #16a34a, #22c55e); } /* 초록색 */
.rank-5 .bar-fill { background: linear-gradient(90deg, #2563eb, #3b82f6); } /* 파란색 */
.rank-default .bar-fill { background: linear-gradient(90deg, #4b5563, #6b7280); } /* 회색 */

/* 데이터 없음 */
.no-data {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    padding: 40px !important;
}

/* 통계 푸터 */
.stats-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
}

.stats-footer strong {
    color: #ffffff;
    font-size: 18px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.note { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* 반응형 */
@media (max-width: 1024px) {
    .dashboard-content { grid-template-columns: 1fr; }
    .chart-container { height: 350px; }
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .page {
        padding: 20px 12px;
    }

    .panel {
        padding: 20px 16px;
        border-radius: 20px;
    }

    /* 헤더: 세로 배치 */
    .stats-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .stats-header h1 {
        font-size: 18px;
        line-height: 1.4;
    }

    /* 컨트롤 영역 */
    .controls {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .controls input {
        flex: 1;
        min-width: 0;
    }

    /* 테이블: 컬럼 비율 조정 */
    .bar-table .col-name {
        width: 25%;
        min-width: 70px;
        font-size: 13px;
        padding: 12px 8px;
        word-break: keep-all;
    }

    .bar-table .col-bar {
        width: 75%;
        padding: 12px 8px;
    }

    .bar-table th {
        padding: 12px 8px;
        font-size: 13px;
    }

    .bar-bg {
        height: 28px;
    }

    .bar-label {
        font-size: 12px;
        padding: 0 8px;
    }

    .stats-footer {
        font-size: 14px;
    }

    .stats-footer strong {
        font-size: 16px;
    }
}

/* 더 작은 화면 */
@media (max-width: 480px) {
    .stats-header h1 {
        font-size: 16px;
    }

    .bar-table .col-name {
        width: 30%;
        min-width: 60px;
        font-size: 12px;
    }

    .bar-table .col-bar {
        width: 70%;
    }

    .bar-label {
        font-size: 11px;
        padding: 0 6px;
    }
}