/* ============================================================================
 * xenoInvest 공통 테마
 *  - 레이아웃 : 상단 헤더(64px) + 좌측 네이비 사이드바(200px) + 카드형 콘텐츠
 *  - 등락 색상 : 국내 관례에 따라 상승 빨강 / 하락 파랑
 * ========================================================================== */

@font-face {
	font-family: 'Pretendard';
	font-weight: 45 920;
	font-style: normal;
	font-display: swap;
	src: url('/resources/fonts/pretendard/PretendardVariable.woff2') format('woff2-variations');
}

:root {
	--xi-bg: #f2f5fa;
	--xi-card: #ffffff;
	--xi-line: #e7ecf3;
	--xi-line-strong: #d6dee9;
	--xi-text: #18212f;
	--xi-text-2: #3d4757;
	--xi-muted: #7c8799;
	--xi-primary: #1e6ff2;
	--xi-primary-dark: #1557c7;
	--xi-primary-weak: #e9f1fe;
	--xi-up: #e5383b;
	--xi-up-weak: #fdecec;
	--xi-down: #1f6feb;
	--xi-down-weak: #e8f0fe;
	--xi-green: #12b886;
	--xi-green-weak: #e6f8f1;
	--xi-orange: #f59f00;
	--xi-sidebar: #0f1d38;
	--xi-sidebar-2: #15284b;
	--xi-sidebar-text: #b8c4d8;
	--xi-header-h: 64px;
	--xi-sidebar-w: 200px;
	--xi-radius: 12px;
	--xi-shadow: 0 1px 2px rgba(16, 30, 60, .04), 0 4px 16px rgba(16, 30, 60, .05);
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	background: var(--xi-bg);
	color: var(--xi-text);
	font-family: 'Pretendard', -apple-system, 'Malgun Gothic', sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 등락 색상 ---------- */
.up { color: var(--xi-up) !important; }
.down { color: var(--xi-down) !important; }
.flat { color: var(--xi-muted) !important; }
.green { color: var(--xi-green) !important; }
.muted { color: var(--xi-muted) !important; }
.primary { color: var(--xi-primary) !important; }

/* ---------- 헤더 ---------- */
.xi-header {
	position: fixed;
	top: 0; left: 0; right: 0;
	height: var(--xi-header-h);
	background: #fff;
	border-bottom: 1px solid var(--xi-line);
	display: flex;
	align-items: center;
	padding: 0 24px 0 0;
	z-index: 100;
}
.xi-brand {
	width: var(--xi-sidebar-w);
	display: flex;
	align-items: center;
	gap: 8px;
	padding-left: 22px;
	flex-shrink: 0;
}
.xi-brand .logo-mark { display: inline-flex; align-items: flex-end; gap: 3px; height: 24px; }
.xi-brand .logo-mark i { display: block; width: 5px; border-radius: 2px; background: var(--xi-primary); }
.xi-brand .logo-mark i:nth-child(1) { height: 9px; opacity: .55; }
.xi-brand .logo-mark i:nth-child(2) { height: 15px; opacity: .8; }
.xi-brand .logo-mark i:nth-child(3) { height: 22px; }
.xi-brand .logo-text { font-size: 22px; font-weight: 800; letter-spacing: -0.6px; color: #0d1f44; }
.xi-brand .logo-text b { color: var(--xi-primary); font-weight: 800; }
.xi-tagline {
	padding-left: 18px;
	margin-left: 6px;
	border-left: 1px solid var(--xi-line-strong);
	color: var(--xi-muted);
	font-size: 14px;
	white-space: nowrap;
}
.xi-menu-toggle {
	display: none;
	border: 0;
	background: transparent;
	font-size: 22px;
	padding: 6px 10px;
	cursor: pointer;
}
.xi-header-search {
	margin-left: auto;
	position: relative;
	width: 320px;
}
.xi-header-search input {
	width: 100%;
	height: 38px;
	border: 1px solid var(--xi-line-strong);
	border-radius: 20px;
	padding: 0 14px 0 38px;
	background: #fff;
	outline: none;
}
.xi-header-search input:focus { border-color: var(--xi-primary); box-shadow: 0 0 0 3px var(--xi-primary-weak); }
.xi-header-search > i { position: absolute; left: 14px; top: 10px; color: var(--xi-muted); }
.xi-search-result {
	position: absolute;
	top: 44px; left: 0; right: 0;
	background: #fff;
	border: 1px solid var(--xi-line);
	border-radius: 10px;
	box-shadow: var(--xi-shadow);
	max-height: 360px;
	overflow-y: auto;
	display: none;
	z-index: 110;
}
.xi-search-result .item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 14px;
	cursor: pointer;
}
.xi-search-result .item:hover, .xi-search-result .item.on { background: var(--xi-primary-weak); }
.xi-search-result .item .code { color: var(--xi-muted); font-size: 12px; }
.xi-search-result .item .mkt { margin-left: auto; font-size: 11px; color: var(--xi-muted); }
.xi-search-result .empty { padding: 14px; color: var(--xi-muted); text-align: center; }

.xi-header-icons { display: flex; align-items: center; gap: 6px; margin-left: 20px; }
.xi-icon-btn {
	position: relative;
	width: 38px; height: 38px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #5b6577;
	font-size: 19px;
	cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center;
}
.xi-icon-btn:hover { background: var(--xi-bg); }
.xi-icon-btn .dot {
	position: absolute;
	top: 3px; right: 3px;
	min-width: 17px; height: 17px;
	padding: 0 4px;
	border-radius: 9px;
	background: var(--xi-up);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 17px;
	text-align: center;
}
.xi-user {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: 14px;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: 24px;
}
.xi-user:hover { background: var(--xi-bg); }
.xi-avatar {
	width: 36px; height: 36px;
	border-radius: 50%;
	background: linear-gradient(135deg, #c9d4e6, #8fa1bf);
	color: #fff;
	display: inline-flex; align-items: center; justify-content: center;
	font-size: 20px;
}
.xi-user .name { font-weight: 700; }
.xi-dropdown {
	position: absolute;
	right: 0; top: 48px;
	min-width: 190px;
	background: #fff;
	border: 1px solid var(--xi-line);
	border-radius: 10px;
	box-shadow: var(--xi-shadow);
	padding: 6px;
	display: none;
	z-index: 120;
}
.xi-dropdown.show { display: block; }
.xi-dropdown a, .xi-dropdown .info { display: block; padding: 9px 12px; border-radius: 6px; }
.xi-dropdown a:hover { background: var(--xi-bg); }
.xi-dropdown .info { color: var(--xi-muted); font-size: 12px; border-bottom: 1px solid var(--xi-line); margin-bottom: 4px; border-radius: 0; }

/* ---------- 사이드바 ---------- */
.xi-sidebar {
	position: fixed;
	top: var(--xi-header-h); bottom: 0; left: 0;
	width: var(--xi-sidebar-w);
	background: var(--xi-sidebar);
	color: var(--xi-sidebar-text);
	display: flex;
	flex-direction: column;
	z-index: 90;
	transition: transform .2s;
}
.xi-nav { list-style: none; margin: 0; padding: 18px 12px; flex: 1; overflow-y: auto; }
.xi-nav li { margin-bottom: 4px; }
.xi-nav a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 14px;
	border-radius: 8px;
	font-size: 14.5px;
	color: var(--xi-sidebar-text);
}
.xi-nav a i { font-size: 18px; width: 20px; text-align: center; opacity: .9; }
.xi-nav a:hover { background: var(--xi-sidebar-2); color: #fff; }
.xi-nav a.on { background: var(--xi-primary); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(30, 111, 242, .35); }
.xi-side-foot { padding: 16px 22px 20px; font-size: 12px; color: #8b98b0; line-height: 1.9; }
.xi-side-foot .conn { display: flex; align-items: center; gap: 7px; color: #d6deeb; }
.xi-side-foot .conn .led { width: 9px; height: 9px; border-radius: 50%; background: #8b98b0; }
.xi-side-foot .conn .led.ok { background: #2fd27a; box-shadow: 0 0 0 3px rgba(47, 210, 122, .18); }
.xi-side-foot .conn .led.err { background: var(--xi-up); }

/* ---------- 본문 ---------- */
.xi-main {
	margin-left: var(--xi-sidebar-w);
	padding: calc(var(--xi-header-h) + 20px) 22px 24px;
	min-height: 100vh;
}
.xi-page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.xi-page-head h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.4px; }
.xi-page-head .desc { color: var(--xi-muted); }
.xi-page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- 그리드 ---------- */
.xi-row { display: grid; gap: 16px; margin-bottom: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

/* ---------- 카드 ---------- */
.card {
	background: var(--xi-card);
	border-radius: var(--xi-radius);
	box-shadow: var(--xi-shadow);
	border: 1px solid #edf1f6;
	padding: 18px 20px;
	min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-head .title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head .title i { color: var(--xi-primary); font-size: 18px; }
.card-head .more { margin-left: auto; font-size: 12px; color: var(--xi-primary); white-space: nowrap; }
.card-head .more:hover { text-decoration: underline; }
.card-head .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* 상단 요약 카드 */
.stat-card { display: flex; align-items: center; gap: 12px; min-height: 100px; }
.stat-card .label { color: var(--xi-text-2); font-size: 13.5px; }
.stat-card .value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin: 2px 0; }
.stat-card .sub { font-size: 13px; }
.stat-card .side { margin-left: auto; color: var(--xi-muted); font-size: 22px; }
.stat-card .spark { margin-left: auto; width: 110px; height: 50px; }

/* ---------- 버튼 ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	height: 36px;
	padding: 0 14px;
	border-radius: 8px;
	border: 1px solid var(--xi-line-strong);
	background: #fff;
	color: var(--xi-text-2);
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--xi-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--xi-primary); border-color: var(--xi-primary); color: #fff; }
.btn-primary:hover { background: var(--xi-primary-dark); border-color: var(--xi-primary-dark); }
.btn-buy { background: var(--xi-up); border-color: var(--xi-up); color: #fff; }
.btn-buy:hover { background: #c92a2d; }
.btn-sell { background: var(--xi-down); border-color: var(--xi-down); color: #fff; }
.btn-sell:hover { background: #1557c7; }
.btn-soft { background: var(--xi-green-weak); border-color: #bfeadb; color: #0c8a63; }
.btn-soft:hover { background: #d4f3e7; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { height: 44px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }

/* ---------- 입력 ---------- */
.form-control {
	width: 100%;
	height: 38px;
	border: 1px solid var(--xi-line-strong);
	border-radius: 8px;
	padding: 0 12px;
	background: #fff;
	outline: none;
}
textarea.form-control { height: auto; padding: 10px 12px; }
.form-control:focus { border-color: var(--xi-primary); box-shadow: 0 0 0 3px var(--xi-primary-weak); }
.form-control[readonly] { background: #f7f9fc; }
.form-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.form-row > label { width: 110px; flex-shrink: 0; color: var(--xi-text-2); font-weight: 600; }
.form-help { color: var(--xi-muted); font-size: 12px; margin-top: 4px; }
.input-group { display: flex; align-items: stretch; }
.input-group .form-control { border-radius: 0; text-align: center; }
.input-group .btn { border-radius: 0; height: 38px; }
.input-group > :first-child { border-radius: 8px 0 0 8px; }
.input-group > :last-child { border-radius: 0 8px 8px 0; }

/* 토글 스위치 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #c9d2df; border-radius: 26px; cursor: pointer; transition: .2s; }
.switch .slider:before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--xi-green); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ---------- 탭 ---------- */
.tabs { display: inline-flex; gap: 4px; background: #f3f6fb; border-radius: 8px; padding: 3px; }
.tabs button {
	border: 0;
	background: transparent;
	padding: 5px 14px;
	border-radius: 6px;
	color: var(--xi-text-2);
	cursor: pointer;
	font-size: 13px;
}
.tabs button.on { background: #fff; color: var(--xi-primary); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tabs.blue button.on { background: var(--xi-primary-weak); box-shadow: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #f1f4f9; border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 0; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--xi-text-2); }
.seg button.on.buy { background: var(--xi-up); color: #fff; }
.seg button.on.sell { background: var(--xi-down); color: #fff; }
.seg button.on { background: var(--xi-primary); color: #fff; }

/* ---------- 테이블 ---------- */
.xi-table { width: 100%; border-collapse: collapse; }
.xi-table th {
	font-size: 12px;
	font-weight: 600;
	color: var(--xi-muted);
	text-align: left;
	padding: 8px 10px;
	border-bottom: 1px solid var(--xi-line);
	white-space: nowrap;
	background: #fafbfd;
}
.xi-table td {
	padding: 10px 10px;
	border-bottom: 1px solid #f0f3f7;
	vertical-align: middle;
}
.xi-table tbody tr:hover { background: #f8fafd; }
.xi-table tbody tr.clickable { cursor: pointer; }
.xi-table .r, .r { text-align: right; }
.xi-table .c, .c { text-align: center; }
.xi-table td.r, .xi-table th.r { font-variant-numeric: tabular-nums; }
.xi-table.compact td { padding: 7px 8px; }
.xi-table.compact th { padding: 6px 8px; }
.xi-table .empty { text-align: center; color: var(--xi-muted); padding: 30px 0; }
.table-wrap { overflow-x: auto; }

/* 종목 로고 원형 */
.stock-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stock-logo {
	width: 30px; height: 30px; flex-shrink: 0;
	border-radius: 50%;
	display: inline-flex; align-items: center; justify-content: center;
	color: #fff; font-size: 11px; font-weight: 800;
	background: #1f3a68;
}
.stock-cell .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-cell .cd { display: block; font-size: 11.5px; color: var(--xi-muted); }

/* ---------- 배지 ---------- */
.badge {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 2px 8px;
	border-radius: 20px;
	font-size: 11.5px;
	font-weight: 700;
	background: var(--xi-bg);
	color: var(--xi-text-2);
	white-space: nowrap;
}
.badge.blue { background: var(--xi-primary-weak); color: var(--xi-primary); }
.badge.green { background: var(--xi-green-weak); color: #0c8a63; }
.badge.red { background: var(--xi-up-weak); color: var(--xi-up); }
.badge.gray { background: #eef1f5; color: #6c778a; }
.badge.orange { background: #fff4e0; color: #c77a00; }
.badge.solid-green { background: var(--xi-green); color: #fff; }

/* ---------- 모달 ---------- */
.xi-modal-bg {
	position: fixed; inset: 0;
	background: rgba(10, 20, 40, .45);
	display: none;
	align-items: center; justify-content: center;
	z-index: 500;
}
.xi-modal-bg.show { display: flex; }
.xi-modal {
	background: #fff;
	border-radius: 14px;
	width: 520px;
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 40px);
	display: flex; flex-direction: column;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
}
.xi-modal.lg { width: 860px; }
.xi-modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--xi-line); }
.xi-modal-head h3 { margin: 0; font-size: 17px; }
.xi-modal-head .close { margin-left: auto; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--xi-muted); }
.xi-modal-body { padding: 18px 20px; overflow-y: auto; }
.xi-modal-foot { padding: 14px 20px; border-top: 1px solid var(--xi-line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 토스트 ---------- */
.xi-toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 600; }
.xi-toast {
	min-width: 260px; max-width: 380px;
	background: #1b2433; color: #fff;
	padding: 12px 16px;
	border-radius: 10px;
	box-shadow: 0 8px 24px rgba(0,0,0,.2);
	font-size: 13.5px;
	animation: xiToastIn .2s ease-out;
}
.xi-toast.ok { background: #0f8a5f; }
.xi-toast.err { background: #c62828; }
@keyframes xiToastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 로딩 ---------- */
.xi-loading { display: flex; align-items: center; justify-content: center; padding: 24px; color: var(--xi-muted); gap: 8px; }
.xi-spinner { width: 18px; height: 18px; border: 2px solid var(--xi-line-strong); border-top-color: var(--xi-primary); border-radius: 50%; animation: xiSpin .8s linear infinite; }
@keyframes xiSpin { to { transform: rotate(360deg); } }

/* ---------- 기타 ---------- */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; }
.kv dt { color: var(--xi-muted); }
.kv dd { margin: 0; font-weight: 600; }
.divider { height: 1px; background: var(--xi-line); margin: 14px 0; }
.mt0 { margin-top: 0 !important; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb0 { margin-bottom: 0 !important; } .mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-1 { flex: 1; min-width: 0; }
.ml-auto { margin-left: auto; }
.fw7 { font-weight: 700; } .fw8 { font-weight: 800; }
.fs12 { font-size: 12px; } .fs13 { font-size: 13px; } .fs16 { font-size: 16px; } .fs20 { font-size: 20px; } .fs28 { font-size: 28px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.notice-box { background: #f7f9fc; border: 1px solid var(--xi-line); border-radius: 10px; padding: 12px 14px; color: var(--xi-text-2); font-size: 13px; }
.notice-box.warn { background: #fff8e8; border-color: #ffe2a8; color: #8a5a00; }

/* ---------- 반응형 ---------- */
@media (max-width: 1400px) {
	.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.xi-tagline { display: none; }
}
@media (max-width: 1100px) {
	.xi-menu-toggle { display: inline-block; margin-left: 8px; }
	.xi-brand { width: auto; padding-left: 4px; }
	.xi-sidebar { transform: translateX(-100%); }
	.xi-sidebar.open { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
	.xi-main { margin-left: 0; }
	.cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.span-3 { grid-column: span 2; }
	.xi-header-search { width: 220px; }
}
@media (max-width: 720px) {
	.cols-2, .cols-3, .cols-4, .cols-6 { grid-template-columns: minmax(0, 1fr); }
	.span-2, .span-3 { grid-column: auto; }
	.xi-header-search, .xi-user .name { display: none; }
	.xi-main { padding: calc(var(--xi-header-h) + 12px) 12px 16px; }
}
