:root {
    --bg-color: #f6f8fa;
    --card-bg: #ffffff;
    --border-color: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --accent-color: #0969da;
    --accent-glow: rgba(9, 105, 218, 0.1);
    --highlight-gradient: linear-gradient(90deg, #0969da, #8250df);
    --glass-border: #d0d7de;
    --shadow: 0 4px 12px rgba(31, 35, 40, 0.08);
}

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

body {
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 2rem;
    text-align: center;
}

.header-actions {
    margin-top: 1.5rem;
}

.update-btn {
    padding: 0.8rem 2rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
    background: #085dc3;
}

.update-btn:active {
    transform: translateY(0);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.highlight {
    background: var(--highlight-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.dashboard-section {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

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

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    background: #eff1f3;
    padding: 0.25rem;
    border-radius: 10px;
}

.tab-btn {
    padding: 0.5rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

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

/* Insight Styles */
.insight-container {
    margin-bottom: 1.5rem;
    padding: 1.2rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(130, 80, 223, 0.05), rgba(9, 105, 218, 0.05));
    border: 1px solid rgba(130, 80, 223, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.insight-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--highlight-gradient);
}

.insight-badge {
    font-size: 0.7rem;
    font-weight: 800;
    color: #8250df;
    padding: 2px 8px;
    background: rgba(130, 80, 223, 0.1);
    border-radius: 4px;
    align-self: flex-start;
    letter-spacing: 0.5px;
}

.insight-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-line;
}

.insight-container.hidden {
    display: none;
}

/* Chart Container */
.chart-container {
    width: 100%;
    height: 500px;
}

/* Table Styles */
.table-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.download-btn {
    padding: 0.6rem 1.2rem;
    background: #238636;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

.download-btn:hover {
    background: #2ea043;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

table {
    width: max-content; /* 내용에 맞춰 너비 확장 */
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 0.5rem 0.7rem; /* 더 콤팩트한 패딩 */
    text-align: right;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    min-width: 80px; /* 월별 데이터 열 최소 너비 */
}

th {
    background: #f8f9fa;
    color: var(--text-primary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: inset 0 -1px 0 var(--border-color);
}

/* Table Column Widths & Sticky */
.col-rank {
    width: 50px;
    min-width: 50px;
    text-align: center !important;
    position: sticky;
    left: 0;
    z-index: 20;
    background: #f8f9fa;
}

.col-station {
    width: 150px;
    min-width: 150px;
    text-align: left !important;
    position: sticky;
    left: 50px; /* col-rank 너비만큼 오프셋 */
    z-index: 20;
    background: #f8f9fa;
}

.col-line {
    width: 100px;
    min-width: 100px;
    text-align: center !important;
    position: sticky;
    left: 200px; /* col-rank + col-station 너비 합계 */
    z-index: 20;
    background: #f8f9fa;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05); /* 마지막 고정 열에 그림자 */
}

td.col-rank, td.col-station, td.col-line {
    background: #ffffff;
    z-index: 10;
}

tr:nth-child(even) td.col-rank, 
tr:nth-child(even) td.col-station, 
tr:nth-child(even) td.col-line {
    background: #fafbfc;
}

tr:hover td.col-rank, 
tr:hover td.col-station, 
tr:hover td.col-line {
    background: #f0f7ff !important;
}

th.col-rank, th.col-station, th.col-line {
    z-index: 30; /* 헤더는 더 높은 z-index */
    background: #f8f9fa;
}

/* Loading Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    display: none;
    opacity: 0;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #eff1f3;
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-content p {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loader-content .sub-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}
