:root { --bg:#ffffff; --panel:#ffffff; --muted:#6b7280; --text:#111827; --accent:#2563eb; --grid:#e5e7eb; --card:#ffffff; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, 'Noto Sans KR', sans-serif; margin: 0; background: var(--bg); color: var(--text); }
.container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
header { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; position: sticky; top: 0; padding: 12px 0; background: #ffffffcc; backdrop-filter: blur(6px); border-bottom: 1px solid #e5e7eb; z-index: 2; }
.home-link { color: #2563eb; text-decoration: none; font-size: 14px; font-weight: 500; margin-right: 8px; }
.home-link:hover { text-decoration: underline; }
header h1 { font-size: 18px; font-weight: 600; opacity: .9; margin: 0 8px 0 0; }
.data-info { color: #6b7280; font-size: 12px; font-style: italic; margin-left: 8px; }

/* Gov/Mon Heatmap */
.govmon-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.gm-col { background: #ffffff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; overflow: auto; }
.gm-col canvas { transition: box-shadow .15s ease; }
.gm-col canvas:hover { box-shadow: inset 0 0 0 2px rgba(59,130,246,0.2); }
.gm-title { font-size: 14px; color: #111827; font-weight: 600; margin-bottom: 8px; }
label { color: var(--muted); font-size: 14px; }
input[type="date"] { background: #fff; border: 1px solid #d1d5db; color: var(--text); padding: 6px 8px; border-radius: 8px; }
button { background: linear-gradient(180deg, #60a5fa, #3b82f6); border: 0; color: #fff; padding: 8px 12px; border-radius: 10px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,.15); }
button:hover { filter: brightness(1.05); }
.panel { background: var(--panel); border: 1px solid #e5e7eb; border-radius: 16px; padding: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.canvas-wrap { position: relative; overflow: hidden; border-radius: 12px; cursor: pointer; }
.click-hint { 
	background: rgba(59, 130, 246, 0.1); 
	color: #2563eb; 
	padding: 6px 12px; 
	border-radius: 8px; 
	font-size: 12px; 
	font-weight: 500;
	margin-bottom: 12px;
	text-align: center;
	opacity: 0.8;
	transition: opacity 0.3s ease;
}
.click-hint:hover { opacity: 1; }
.trend-date-range {
	color: var(--muted);
	font-size: 12px;
	margin-bottom: 8px;
	text-align: center;
}
canvas { display: block; width: 100%; height: 520px; background: #fff; }
.canvas-wrap.hoverable { cursor: pointer; }
.legend-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 12px; }
#legendBar { height: 10px; width: 240px; border-radius: 999px; background: linear-gradient(90deg, #ffffcc, #fed976, #fdae61, #f46d43, #d73027, #a50026); border: 1px solid #e5e7eb; }
table { border-collapse: collapse; margin-top: 18px; width: 100%; background: var(--panel); border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; }
td, th { border: 1px solid #e5e7eb; padding: 8px 10px; font-size: 12px; text-align: center; color: var(--text); }
.tooltip { position: absolute; pointer-events: none; background: #ffffff; color: var(--text); border: 1px solid #e5e7eb; padding: 8px 10px; border-radius: 10px; font-size: 12px; box-shadow: 0 8px 20px rgba(0,0,0,.12); opacity: 0; transform: translate(-50%, -120%) scale(.98); transition: opacity .15s ease, transform .15s ease; }

/* Trend sparkline grid */
.spark-item.total-item {
	background: linear-gradient(135deg, #f8fafc, #f1f5f9);
	border: 2px solid #3b82f6;
	border-radius: 12px;
	box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.spark-item.total-item .spark-title span:first-child {
	font-weight: 700;
	color: #1e40af;
	font-size: 14px;
}

.spark-item.total-item .spark-title .value {
	font-weight: 700;
	color: #1e40af;
	font-size: 16px;
}

/* Trend sparkline grid */
.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.spark-item { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.spark-item:hover { box-shadow: 0 10px 24px rgba(0,0,0,.08); transform: translateY(-2px); border-color: #cbd5e1; }
.spark-item:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; box-shadow: 0 0 0 4px rgba(147,197,253,.35); }
.spark-item .sparkline { transition: filter .15s ease; }
.spark-item:hover .sparkline { filter: brightness(1.03); }
.spark-title { font-size: 12px; color: #6b7280; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.spark-title .value { font-size: 14px; color: #111827; font-weight: 600; }
.spark-title .minmax { font-size: 10px; color: #9ca3af; font-weight: 400; }
.sparkline { width: 100%; height: 64px; display: block; }

/* Delta color helpers */
.delta-up { color: #dc2626; font-weight: 700; } /* brighter red */
.delta-down { color: #2563eb; font-weight: 700; } /* brighter blue */
.delta-zero { color: #6b7280; font-weight: 700; }

/* Sector ranking value bold */
.ranking-item .volume .value { font-weight: 700; }

/* Modal */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 50; }
.modal.show { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); }
.modal-panel { position: relative; width: min(1200px, 95vw); max-height: 86vh; overflow: auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e5e7eb; }
.modal-title { font-size: 16px; color: #111827; font-weight: 700; }
.modal-close { background: transparent; border: 0; font-size: 18px; padding: 6px 10px; cursor: pointer; color: #6b7280; }
.modal-body { padding: 12px 14px 16px; }
.bucket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.bucket-item { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 8px 10px; }
.bucket-item .title { font-size: 13px; color: #6b7280; margin-bottom: 8px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.bucket-item .title .minmax { font-size: 11px; color: #9ca3af; font-weight: 400; }
.bucket-item canvas { width: 100%; height: 120px; display: block; }

/* Gov/Mon series list in modal */
.series-controls { display: flex; justify-content: flex-end; gap: 8px; margin: 4px 0 8px; }
.series-controls button { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; padding: 4px 8px; border-radius: 8px; font-weight: 600; box-shadow: none; }
.series-controls button.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.series-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
.series-row { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px 10px; }
.series-date { color: #6b7280; font-size: 12px; font-weight: 600; text-align: right; }
.series-bars { position: relative; height: 22px; background: #f3f4f6; border-radius: 6px; overflow: hidden; }
.bar-sell { position: absolute; right: 50%; top: 0; bottom: 0; background: rgba(180, 83, 135, 0.65); }
.bar-buy { position: absolute; left: 50%; top: 0; bottom: 0; background: rgba(59, 130, 246, 0.75); }
.series-center { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: rgba(17,24,39,0.08); pointer-events: none; }
.series-labels { display: flex; justify-content: space-between; font-size: 11px; color: #111827; margin-top: 4px; }

/* Tab Navigation */
.tab-navigation { display: flex; gap: 8px; margin-bottom: 12px; }
.tab-button { 
	background: #f9fafb; 
	border: 1px solid #e5e7eb; 
	color: #6b7280; 
	padding: 8px 16px; 
	border-radius: 8px; 
	cursor: pointer; 
	font-size: 14px; 
	font-weight: 500; 
	transition: all 0.2s ease;
}
.tab-button:hover { background: #f3f4f6; border-color: #d1d5db; }
.tab-button.active { 
	background: #3b82f6; 
	color: white; 
	border-color: #3b82f6; 
	box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}
.date-controls { display: flex; gap: 12px; align-items: center; }

/* Tab Content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Ranking Grid */
.ranking-header { margin-bottom: 20px; text-align: center; }
.ranking-header h2 { font-size: 20px; font-weight: 600; margin: 0 0 8px 0; color: #111827; }
.ranking-header p { font-size: 14px; color: #6b7280; margin: 0; }
.ranking-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.ranking-sector { 
	background: #fff; 
	border: 1px solid #e5e7eb; 
	border-radius: 12px; 
	padding: 16px; 
	box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.ranking-sector h3 { 
	font-size: 16px; 
	font-weight: 600; 
	margin: 0 0 12px 0; 
	color: #111827; 
	padding-bottom: 8px; 
	border-bottom: 2px solid #3b82f6;
}
.ranking-item { 
	display: flex; 
	justify-content: space-between; 
	align-items: center; 
	padding: 8px 0; 
	border-bottom: 1px solid #f3f4f6;
}
.ranking-item:last-child { border-bottom: none; }
.ranking-item .rank { 
	font-weight: 600; 
	color: #3b82f6; 
	min-width: 20px; 
	text-align: center;
}
.ranking-item .name { 
	flex: 1; 
	margin: 0 12px; 
	font-size: 14px; 
	color: #111827;
}
.ranking-item .volume { 
	font-size: 12px; 
	color: #6b7280; 
	font-weight: 500;
}

/* Trend Chart Styles */
.trend-header { margin-bottom: 20px; text-align: center; }
.trend-header h2 { font-size: 20px; font-weight: 600; margin: 0 0 8px 0; color: #111827; }
.trend-header p { font-size: 14px; color: #6b7280; margin: 0 0 16px 0; }
.trend-controls { margin-bottom: 20px; }
.trend-controls select { 
	padding: 8px 12px; 
	border: 1px solid #d1d5db; 
	border-radius: 6px; 
	background: white; 
	font-size: 14px;
}
.chart-container { 
	background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%); 
	border: 2px solid #e2e8f0; 
	border-radius: 12px; 
	padding: 24px; 
	margin-bottom: 24px;
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
	width: 100%;
	position: relative;
}

.chart-container canvas {
	max-width: 100%;
	height: auto;
}
.trend-legend { 
	display: grid; 
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
	gap: 16px; 
}
.sector-legend { 
	background: linear-gradient(135deg, #f1f5f9 0%, #f8fafc 100%); 
	border: 1px solid #cbd5e1; 
	border-radius: 10px; 
	padding: 16px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.sector-legend h4 { 
	font-size: 14px; 
	font-weight: 600; 
	margin: 0 0 8px 0; 
	color: #111827;
}
.legend-items { display: flex; flex-direction: column; gap: 4px; }
.legend-item { 
	display: flex; 
	align-items: center; 
	gap: 8px; 
	font-size: 12px;
	margin-bottom: 4px;
}
.legend-color { 
	width: 12px; 
	height: 12px; 
	border-radius: 2px; 
	flex-shrink: 0;
}
.legend-name { 
	color: #374151; 
	font-weight: 500; 
	flex: 1;
}
.legend-info { 
	color: #6b7280; 
	font-size: 11px; 
	font-style: italic;
}

/* 모바일 반응형 스타일 */
@media (max-width: 768px) {
	/* Gov/Mon 모바일 최적화: 단일 컬럼 + 더 큰 터치 타겟 */
	.govmon-wrap { grid-template-columns: 1fr; gap: 12px; }
	.gm-col { padding: 10px; }
	.gm-title { font-size: 13px; }
	.gm-col canvas { height: 420px; }
	.series-row { grid-template-columns: 60px 1fr; }
	.series-date { font-size: 11px; }
	.series-bars { height: 26px; }
	.series-labels { font-size: 10px; }
	.chart-container {
		padding: 16px;
		margin-bottom: 16px;
	}
	
	.trend-legend {
		grid-template-columns: 1fr;
		gap: 12px;
	}
	
	.sector-legend {
		padding: 12px;
	}
	
	.sector-legend h4 {
		font-size: 13px;
		margin-bottom: 6px;
	}
	
	.legend-item {
		font-size: 11px;
		margin-bottom: 3px;
	}
	
	.legend-color {
		width: 10px;
		height: 10px;
	}
	
	.trend-header h2 {
		font-size: 18px;
	}
	
	.trend-header p {
		font-size: 13px;
	}
	
	.trend-controls select {
		font-size: 13px;
		padding: 6px 10px;
	}
}

@media (max-width: 480px) {
	.chart-container {
		padding: 12px;
		margin-bottom: 12px;
	}
	
	.trend-legend {
		gap: 8px;
	}
	
	.sector-legend {
		padding: 8px;
	}
	
	.legend-item {
		font-size: 10px;
	}
	
	.legend-info {
		font-size: 9px;
	}
}

/* Realtime Heatmap Styles */
.realtime-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.realtime-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.realtime-date {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.status-indicator {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-indicator.live {
    background-color: #4CAF50;
    color: white;
}

.status-indicator.error {
    background-color: #f44336;
    color: white;
}

.total-trades {
    font-weight: bold;
    color: #333;
}

.last-update {
    font-size: 12px;
    color: #666;
}

#realtime-canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 모바일에서 실시간 정보 레이아웃 조정 */
@media (max-width: 768px) {
    .realtime-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .realtime-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

