:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --bg-color: #F8FAFC;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-border: rgba(0, 0, 0, 0.08);
    --text-primary: #0F172A;
    --text-secondary: #475569;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1rem;
    position: relative;
    overflow-x: hidden;
}

/* Background Shapes */
.background-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 20s infinite alternate;
}

.shape1 {
    width: 400px;
    height: 400px;
    background: rgba(79, 70, 229, 0.3);
    top: -100px;
    left: -100px;
}

.shape2 {
    width: 300px;
    height: 300px;
    background: rgba(16, 185, 129, 0.25);
    bottom: 10%;
    right: 5%;
    animation-delay: -5s;
}

.shape3 {
    width: 350px;
    height: 350px;
    background: rgba(236, 72, 153, 0.2);
    top: 30%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

.container {
    width: 100%;
    max-width: 1400px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 3.5rem;
    animation: fadeInDown 0.8s ease-out;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
    background: linear-gradient(to right, #4F46E5, #9333EA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.search-container {
    position: relative;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
    z-index: 50;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

input[type="text"] {
    width: 100%;
    padding: 1.2rem 1.8rem;
    font-size: 1.2rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    color: var(--text-primary);
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3), 0 4px 20px rgba(0, 0, 0, 0.1);
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.suggestions-list li {
    padding: 1.2rem 1.8rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--surface-border);
}

.suggestions-list li:last-child {
    border-bottom: none;
}

.suggestions-list li:hover {
    background: rgba(0, 0, 0, 0.05);
}

.hidden {
    display: none !important;
}

.chart-container {
    background: #FFFFFF;
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: 2.5rem 3rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.8s ease-out;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.chart-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -0.01em;
}

.chart-help-text {
    font-size: 0.95rem;
    color: #64748B;
    background: #F1F5F9;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    margin-top: -0.5rem;
    display: inline-block;
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.02);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--surface-border);
}

.stat-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
}

.canvas-wrapper {
    position: relative;
    height: 380px;
    width: 100%;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    color: var(--text-secondary);
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}
::-webkit-scrollbar-track {
    background: #F1F5F9;
}
::-webkit-scrollbar-thumb {
    background: #94A3B8;
    border-radius: 6px;
    border: 3px solid #F1F5F9;
}
::-webkit-scrollbar-thumb:hover {
    background: #64748B;
}

@media (max-width: 600px) {
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .canvas-wrapper {
        height: 250px;
    }
}

.season-filter { display: flex; gap: 0.5rem; background: #F1F5F9; padding: 0.25rem; border-radius: 0.5rem; }
.filter-option { padding: 0.5rem 1rem; border-radius: 0.375rem; cursor: pointer; font-size: 0.875rem; font-weight: 600; color: #64748B; transition: all 0.2s; }
.filter-option input { display: none; }
.filter-option.active { background: white; color: #0F172A; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }



.view-tabs { display: flex; gap: 1rem; }
.view-tab { background: transparent; border: 2px solid transparent; padding: 0.5rem 1.2rem; font-size: 1rem; font-weight: 700; color: #64748B; cursor: pointer; border-radius: 9999px; transition: all 0.2s; }
.view-tab:hover { background: rgba(79, 70, 229, 0.1); color: #4F46E5; }
.view-tab.active { background: #4F46E5; color: white; border-color: #4F46E5; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3); }
.table-responsive { width: 100%; overflow-x: auto; margin-top: 1.5rem; border-radius: 12px; border: 1px solid #E2E8F0; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 1rem 1.5rem; border-bottom: 1px solid #E2E8F0; }
.data-table th { background: #F8FAFC; font-weight: 700; color: #475569; font-size: 0.95rem; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #F8FAFC; transition: background 0.2s; }
.data-table td.highlight { font-weight: 800; color: #0F172A; }
.badge-rank { background: #4F46E5; color: white; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; display: inline-block; min-width: 30px; text-align: center; }
.badge-rank-2 { background: #6366F1; }
.badge-rank-3 { background: #818CF8; }
.badge-rank-other { background: #CBD5E1; color: #475569; }


.table-responsive { max-height: 600px; overflow-y: auto; }
.pagination-container { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1.5rem; flex-wrap: wrap; }
.page-btn { padding: 0.4rem 0.8rem; border: 1px solid #CBD5E1; background: white; color: #475569; border-radius: 6px; cursor: pointer; transition: all 0.2s; font-size: 0.9rem; }
.page-btn:hover { background: #F1F5F9; border-color: #94A3B8; }
.page-btn.active { background: #4F46E5; color: white; border-color: #4F46E5; font-weight: bold; }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }


/* Custom Scrollbar for better visibility */
.table-responsive::-webkit-scrollbar { width: 10px; height: 10px; }
.table-responsive::-webkit-scrollbar-track { background: #E2E8F0; border-radius: 5px; }
.table-responsive::-webkit-scrollbar-thumb { background: #64748B; border-radius: 5px; border: 2px solid #E2E8F0; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #475569; }

/* 3개년 추이 테이블 컬럼 정렬 */
.trend-table {
    table-layout: fixed;
    width: 100%;
}
.trend-table th, .trend-table td {
    width: 20%;
}
.trend-table th:first-child, .trend-table td:first-child {
    width: 40%;
}

/* 4번째 테이블(전형 구분 2칸)을 위한 정렬 */
.trend-table-colspan {
    table-layout: fixed;
    width: 100%;
}
.trend-table-colspan th, .trend-table-colspan td {
    width: 20%;
}
.trend-table-colspan th:first-child {
    width: 40%;
}

/* Overall View Styles */
.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid #CBD5E1;
    border-radius: 8px;
    background-color: white;
    font-size: 0.95rem;
    color: #1E293B;
    cursor: pointer;
    outline: none;
}
.filter-select:focus {
    border-color: #4F46E5;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.kpi-icon {
    font-size: 2rem;
    display: flex;
    align-items: flex-start;
}

.kpi-content {
    flex: 1;
}

.kpi-title {
    font-size: 1rem;
    color: #475569;
    margin-bottom: 0.8rem;
    font-weight: 700;
}

.kpi-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kpi-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed #E2E8F0;
}
.kpi-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.kpi-dept {
    font-weight: 600;
    color: #0F172A;
}
.kpi-val {
    color: #4F46E5;
    font-weight: 700;
}

/* Sortable Table */
.sortable-table th {
    user-select: none;
    transition: background-color 0.2s;
}
.sortable-table th:hover {
    background-color: #F1F5F9;
}
.sort-icon::after {
    content: '↕';
    opacity: 0.3;
    margin-left: 0.3rem;
}
.sortable-table th.sort-asc .sort-icon::after {
    content: '↑';
    opacity: 1;
    color: #4F46E5;
}
.sortable-table th.sort-desc .sort-icon::after {
    content: '↓';
    opacity: 1;
    color: #4F46E5;
}

.sparkline-cell {
    position: relative;
    padding-left: 0.5rem;
}
.sparkbar {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    background-color: rgba(79, 70, 229, 0.1);
    border-radius: 4px;
    z-index: 0;
}
.sparkval {
    position: relative;
    z-index: 1;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.modal:not(.hidden) {
    display: flex;
}
.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalFadeIn 0.3s ease-out;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #F1F5F9;
    padding-bottom: 1rem;
}
.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #1E293B;
}
.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #94A3B8;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.close-btn:hover {
    color: #EF4444;
}
.trajectory-stat-card {
    background: #F8FAFC;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    text-align: center;
    flex: 1;
}
.trajectory-stat-card .label {
    display: block;
    font-size: 0.85rem;
    color: #64748B;
    margin-bottom: 0.5rem;
}
.trajectory-stat-card .value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1E293B;
}
