/* 모의 운용 ([cooss_stock_sim], 관리자 전용)
   색은 한국 시세 화면의 관례를 따른다: 매수·상승은 빨강, 매도·하락은 파랑 */
.csp {
	--ink: #17202c;
	--muted: #687284;
	--line: #e3e6eb;
	--wash: #f4f6f9;
	--ground: #fff;
	--up: #d2352c;
	--up-wash: #fdf1f0;
	--down: #2257c4;
	--down-wash: #eef3fc;
	--focus: #2257c4;
	font-family: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
	font-size: 15px;
	line-height: 1.55;
	color: var(--ink);
	background: var(--ground);
	max-width: 980px;
	margin: 0 auto;
	font-variant-numeric: tabular-nums;
	word-break: keep-all;
}
.csp *,
.csp *::before,
.csp *::after {
	box-sizing: border-box;
}
.csp p {
	margin: 0;
}
.csp-up { color: var(--up); }
.csp-down { color: var(--down); }
.csp-muted { color: var(--muted); font-size: 0.87em; }
.csp-k { color: var(--muted); font-size: 0.82em; display: block; }

/* 머리 */
.csp-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 12px 24px;
	flex-wrap: wrap;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--ink);
}
.csp-title {
	margin: 0;
	font-size: 1.75em;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.2;
}
.csp-sub { color: var(--muted); margin-top: 2px; }
.csp-recompute { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0; }
.csp-flash {
	margin-top: 14px;
	padding: 10px 14px;
	background: var(--wash);
	border-radius: 6px;
}

/* 버튼·입력 */
.csp button {
	font: inherit;
	font-size: 0.92em;
	font-weight: 600;
	padding: 7px 14px;
	border-radius: 6px;
	border: 1px solid var(--ink);
	background: var(--ink);
	color: #fff;
	cursor: pointer;
	white-space: nowrap;
}
.csp button:hover { opacity: 0.88; }
.csp input,
.csp select,
.csp textarea {
	font: inherit;
	font-size: 0.95em;
	padding: 6px 8px;
	border: 1px solid #cfd4dc;
	border-radius: 6px;
	background: #fff;
	color: var(--ink);
	min-width: 0;
	width: 100%;
}
.csp input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--ink); }
.csp :focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}
.csp-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92em; cursor: pointer; }

/* 계좌 */
.csp-account {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 16px 32px;
	flex-wrap: wrap;
	padding: 22px 0 6px;
}
.csp-equity strong {
	display: block;
	font-size: 2.3em;
	font-weight: 700;
	letter-spacing: -0.03em;
	line-height: 1.15;
}
.csp-equity strong small { font-size: 0.45em; font-weight: 500; margin-left: 3px; }
.csp-live { display: block; margin-top: 6px; font-size: 0.92em; }
.csp-live b { font-weight: 600; }
.csp-slots { text-align: right; }
.csp-slotbar { display: inline-flex; gap: 4px; margin-top: 6px; }
.csp-slotbar i,
.csp-agebar i {
	display: block;
	width: 14px;
	height: 14px;
	border-radius: 3px;
	background: var(--line);
}
.csp-slotbar i.on { background: var(--ink); }

/* 구역 */
.csp-sec { margin-top: 36px; }
.csp-sec h3 {
	margin: 0 0 12px;
	font-size: 1.2em;
	font-weight: 700;
	letter-spacing: -0.01em;
}
.csp-empty {
	color: var(--muted);
	padding: 14px 16px;
	background: var(--wash);
	border-radius: 6px;
}

/* 할 일: 매도(파랑) 먼저, 매수(빨강) */
.csp-group { margin-bottom: 22px; }
.csp-group h4 {
	margin: 0 0 8px;
	font-size: 1em;
	font-weight: 700;
	display: flex;
	align-items: baseline;
	gap: 8px;
}
.csp-group h4 span {
	font-size: 0.8em;
	min-width: 1.6em;
	text-align: center;
	padding: 0 6px;
	border-radius: 999px;
	color: #fff;
}
.csp-group h4 em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 0.87em; }

/* 매수 신호 찾기 (전체 날짜) */
.csp-find h4 { flex-wrap: wrap; }
.csp-find h4 span { background: var(--ink); }
.csp-find-form { margin: 0 0 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.csp-find-form label:first-child { flex: 1 1 14em; max-width: 24em; }
.csp .csp-find-pick { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: #cfd4dc; text-underline-offset: 3px; }
.csp .csp-find-pick:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.csp .csp-find-pick[aria-expanded="true"] { font-weight: 700; }
.csp-find-buy td { background: #f7f8fa; }
.csp-find-buy .csp-fill { margin-top: 4px; }
.csp .csp-held-sell { margin-top: 4px; padding: 2px 8px; font-size: 0.8em; border: 1px solid var(--down); border-radius: 6px; background: #fff; color: var(--down); cursor: pointer; white-space: nowrap; }
.csp .csp-held-sell[aria-expanded="true"] { background: var(--down); color: #fff; }
.csp .csp-held-sell:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.csp-held-sell-row td { background: #f7f8fa; text-align: left; }
.csp-table tr[hidden] { display: none; }
.csp-find-table tr[hidden] { display: none; }
.csp-find-table .csp-tag { white-space: nowrap; }
.csp-sell h4 { color: var(--down); }
.csp-sell h4 span { background: var(--down); }
.csp-buy h4 { color: var(--up); }
.csp-buy h4 span { background: var(--up); }

.csp-item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 150px;
	gap: 10px 20px;
	padding: 14px 16px;
	border-left: 4px solid;
	border-radius: 0 8px 8px 0;
	margin-bottom: 8px;
}
.csp-sell .csp-item { border-color: var(--down); background: var(--down-wash); }
.csp-buy .csp-item { border-color: var(--up); background: var(--up-wash); }
.csp-name { font-weight: 700; font-size: 1.05em; }
.csp-name span { font-weight: 400; color: var(--muted); font-size: 0.82em; }
.csp-rank {
	display: inline-grid;
	place-items: center;
	width: 1.6em;
	height: 1.6em;
	margin-right: 8px;
	border-radius: 50%;
	background: var(--up);
	color: #fff;
	font-size: 0.8em;
	vertical-align: 2px;
}
.csp-tag {
	margin-right: 6px;
	padding: 1px 6px;
	border: 1px solid var(--up);
	border-radius: 4px;
	color: var(--up);
	font-style: normal;
	font-size: 0.72em;
	font-weight: 700;
	vertical-align: 2px;
}
.csp-past { margin-top: 12px; }

/* 매수 신호와 매매 기준 */
.csp-guide-lead { margin-bottom: 12px !important; }
.csp-guide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.csp-guide-item { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; background: var(--ground); }
.csp-guide-item header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.csp-guide-item h4 { margin: 0; font-size: 1em; font-weight: 700; }
.csp-guide-item dl { margin: 0; display: grid; grid-template-columns: 4.6em minmax(0, 1fr); gap: 6px 8px; font-size: 0.9em; }
.csp-guide-item dt { color: var(--muted); font-weight: 600; }
.csp-guide-item dd { margin: 0; }
.csp-alert { margin: 0; }
.csp-alert button {
	padding: 4px 10px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--wash);
	color: var(--muted);
	font: inherit;
	font-size: 0.82em;
	cursor: pointer;
	white-space: nowrap;
}
.csp-alert button.on { border-color: var(--up); background: var(--up-wash); color: var(--up); font-weight: 600; }
.csp-alert button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.csp-verdict { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 0.85em; font-weight: 700; }
.csp-verdict.pass { background: var(--up-wash); color: var(--up); }
.csp-verdict.fail { background: var(--wash); color: var(--muted); }
.csp-reason { color: #3d4757; font-size: 0.9em; margin-top: 3px; }
.csp-item-fig { text-align: right; }
.csp-item-fig strong { display: block; font-size: 1.3em; font-weight: 700; letter-spacing: -0.02em; }
.csp-sell .csp-item-fig strong { color: var(--down); }

/* 체결 입력 */
.csp-fill {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: 150px 130px 100px max-content;
	gap: 8px;
	align-items: end;
	margin: 0;
	padding-top: 10px;
	border-top: 1px solid rgba(23, 32, 44, 0.08);
}
.csp-fill label span,
.csp-settings-form label > span {
	display: block;
	font-size: 0.78em;
	color: var(--muted);
	margin-bottom: 2px;
}
.csp-fill-buy button { background: var(--up); border-color: var(--up); }
.csp-fill-sell button { background: var(--down); border-color: var(--down); }

.csp-waits { margin-top: 6px; font-size: 0.92em; }
.csp-waits summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.csp-waits ul { margin: 6px 0 0; padding-left: 1.2em; color: var(--muted); }
.csp-waits li { margin: 3px 0; }
.csp-waits b { color: var(--ink); }

/* 표 */
.csp-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.csp-table { width: 100%; border-collapse: collapse; font-size: 0.93em; }
.csp-table th,
.csp-table td {
	padding: 9px 10px;
	border: 0;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
	background: transparent;
}
.csp-table thead th {
	font-size: 0.82em;
	font-weight: 500;
	color: var(--muted);
	border-bottom-color: var(--ink);
	white-space: nowrap;
}
.csp-table tbody th { font-weight: 500; }
.csp-table .n { text-align: right; white-space: nowrap; }
.csp-table .csp-reason { display: block; font-weight: 400; max-width: 32em; }

.csp-age { display: block; white-space: nowrap; }
.csp-agebar { display: flex; gap: 2px; margin: 4px 0 3px; }
.csp-agebar i { width: 9px; height: 9px; border-radius: 2px; }
.csp-agebar i.on { background: var(--ink); }

/* 수익률 탭 */
.csp-tabs { position: relative; }
.csp-tabs > input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.csp-tabs > label {
	display: inline-block;
	padding: 6px 14px;
	margin: 0 2px 10px 0;
	border-radius: 999px;
	border: 1px solid var(--line);
	font-size: 0.9em;
	cursor: pointer;
}
.csp-tabs > input:checked + label { background: var(--ink); color: #fff; border-color: var(--ink); }
.csp-tabs > input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.csp-panel { display: none; }
#csp-p-month:checked ~ .csp-panel[data-kind="month"],
#csp-p-quarter:checked ~ .csp-panel[data-kind="quarter"],
#csp-p-year:checked ~ .csp-panel[data-kind="year"] { display: block; }

.csp-barcol { width: 34%; min-width: 160px; position: relative; }
td.csp-barcol { vertical-align: middle; }
.csp-legend { display: inline-flex; align-items: center; gap: 4px; }
.csp-legend i { display: inline-block; width: 10px; height: 6px; border-radius: 1px; margin-left: 6px; }
.csp-legend i.me,
.csp-bar.me { background: var(--ink); }
.csp-legend i.ks,
.csp-bar.ks { background: #b4bcc8; }
/* 가운데가 0, 오른쪽이 플러스, 왼쪽이 마이너스 */
td.csp-barcol::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 6px;
	bottom: 6px;
	border-left: 1px solid var(--line);
}
.csp-bar {
	display: block;
	height: 6px;
	width: var(--w);
	margin: 2px 0 2px 50%;
	border-radius: 1px;
}
.csp-bar.neg { margin-left: calc(50% - var(--w)); }

.csp-side { font-size: 0.82em; font-weight: 700; }
.csp-side.b { color: var(--up); }
.csp-side.s { color: var(--down); }
.csp-pending th, .csp-pending td { background: #f7f8fa; }
.csp-del { margin: 0; }
.csp-del button {
	background: transparent;
	color: var(--muted);
	border-color: var(--line);
	font-weight: 400;
	padding: 3px 9px;
}

/* 직접 기록·설정 */
.csp-direct,
.csp-settings { margin: 0 0 14px; }
.csp-direct summary,
.csp-settings summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.csp-direct-form { grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 0; }
.csp-direct-form .csp-wide { grid-column: span 3; }
.csp-settings { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 8px; }
.csp-settings-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; margin: 8px 0 0; }
.csp-settings-form em { font-style: normal; }
.csp-settings-form .csp-check { grid-column: 1 / -1; }
.csp-settings-form button { justify-self: start; }

.csp-foot {
	margin-top: 28px !important;
	padding-top: 12px;
	border-top: 1px solid var(--line);
	color: var(--muted);
	font-size: 0.84em;
}
.csp a { color: var(--down); }

@media (max-width: 640px) {
	.csp { font-size: 14px; }
	.csp-item { grid-template-columns: 1fr; padding: 12px; }
	.csp-item-fig { text-align: left; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
	.csp-item-fig .csp-k { display: inline; }
	.csp-item-fig strong { display: inline; }
	.csp-fill { grid-template-columns: 1fr 1fr; }
	.csp-fill label:first-of-type { grid-column: 1 / -1; }
	.csp-fill button { grid-column: 1 / -1; padding: 10px; }
	.csp-direct-form .csp-wide { grid-column: 1 / -1; }
	.csp-settings-form { grid-template-columns: 1fr; }
	.csp-guide { grid-template-columns: 1fr; }
	.csp-slots { text-align: left; }
	.csp-equity strong { font-size: 1.9em; }
	.csp-barcol { display: none; }
	.csp-table tbody th { min-width: 13em; }
	.csp-ledger tbody th, .csp-ret tbody th, .csp-find-table tbody th { min-width: 0; white-space: nowrap; }
}

.csp-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* 종목 차트 팝업 (paper-chart.js) */
.csp .csp-chart-open { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: #cfd4dc; text-underline-offset: 3px; }
.csp .csp-chart-open > span { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.csp .csp-chart-open:hover { text-decoration-color: currentColor; }
.csp .csp-chart-open:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.csp .csp-chart-mini { margin-left: 6px; padding: 1px 8px; border: 1px solid #cfd4dc; border-radius: 999px; font-size: 0.8em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.csp .csp-chart-mini:hover { border-color: var(--ink); background: #f3f4f6; }
.csp-chart-dlg { width: min(760px, calc(100vw - 32px)); max-width: none; padding: 16px 18px 12px; border: 0; border-radius: 10px; box-shadow: 0 12px 40px rgba(16, 24, 40, 0.25); color: var(--ink); background: var(--ground); }
.csp-chart-dlg::backdrop { background: rgba(16, 24, 40, 0.45); }
.csp-chart-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.csp-chart-head h3 { margin: 0; font-size: 1.1em; flex: 1 1 auto; }
.csp-chart-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.csp .csp-chart-tabs button { all: unset; cursor: pointer; padding: 4px 12px; font-size: 0.9em; }
.csp .csp-chart-tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.csp .csp-chart-tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.csp .csp-chart-close { all: unset; cursor: pointer; font-size: 1.5em; line-height: 1; padding: 0 4px; color: var(--muted); }
.csp-chart-info { margin: 8px 0 4px; min-height: 1.5em; font-size: 0.88em; font-variant-numeric: tabular-nums; }
.csp-chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.csp-chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.csp-chart-svg .axis { fill: var(--muted); font-size: 11px; }
.csp-chart-svg .wick { stroke-width: 1; }
.csp-chart-svg .wick.up, .csp-chart-svg .body.up { stroke: var(--up); fill: var(--up); }
.csp-chart-svg .wick.down, .csp-chart-svg .body.down { stroke: var(--down); fill: var(--down); }
.csp-chart-svg .vol.up { fill: var(--up); opacity: 0.35; }
.csp-chart-svg .vol.down { fill: var(--down); opacity: 0.35; }
.csp-chart-svg .ma { fill: none; stroke-width: 1.4; }
.csp-chart-svg .m5, .csp-chart-legend .m5 { stroke: #e08a00; background: #e08a00; }
.csp-chart-svg .m20, .csp-chart-legend .m20 { stroke: #1f9d55; background: #1f9d55; }
.csp-chart-svg .m60, .csp-chart-legend .m60 { stroke: #8a4fd3; background: #8a4fd3; }
.csp-chart-svg .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.csp-chart-legend { margin: 6px 0 0; font-size: 0.8em; color: var(--muted); }
.csp-chart-legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin: 0 3px 0 6px; }
.csp-chart-svg .mark.up { fill: var(--up); stroke: #fff; stroke-width: 1; }
.csp-chart-svg .mark.down { fill: var(--down); stroke: #fff; stroke-width: 1; }
.csp-chart-svg .markline { stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.55; }
.csp-chart-svg .markline.up { stroke: var(--up); }
.csp-chart-svg .markline.down { stroke: var(--down); }

/* 모의 운용 공개 기록 ([cooss_mystock]) */
.csm .csp-equity strong .csp-up, .csm .csp-equity strong .csp-down { color: inherit; }
.csm .csp-equity strong > span.csp-up { color: var(--up); }
.csm .csp-equity strong > span.csp-down { color: var(--down); }
.csm-note { margin: 6px 0 0; font-size: 0.82em; }
.csm-ad { margin: 28px 0 8px; }
.csm-curve { display: block; width: 100%; height: auto; }
.csm-curve .grid { stroke: var(--line); }
.csm-curve .zero { stroke: #b9bfc9; stroke-dasharray: 3 3; }
.csm-curve .axis { fill: var(--muted); font-size: 11px; }
.csm-curve path { fill: none; stroke-width: 2; }
.csm-curve .me { stroke: var(--up); }
.csm-curve .ks { stroke: #8a93a3; stroke-width: 1.5; }
.csp-chart-legend .me { background: var(--up); }
.csp-chart-legend .ks { background: #8a93a3; }

/* 매도 이유 (매매 복기 글에 실림, 2026-11-27) */
.csp textarea { resize: vertical; min-height: 2.6em; font: inherit; line-height: 1.45; }
.csp-fill .csp-reason-in { grid-column: 1 / -1; grid-row: 2; }
.csp-reason-edit { margin-top: 4px; }
.csp-reason-edit summary { cursor: pointer; color: var(--muted); font-size: 0.95em; }
.csp-reason-form { display: grid; gap: 6px; margin: 6px 0 0; min-width: 16em; }
.csp-reason-form button { justify-self: start; }
/* 신호 분석 글 링크 (tradehistory.php, 2026-11-27) */
.csp-se { margin-top: 4px; font-size: 0.86em; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.csp-se a { font-weight: 600; color: var(--down); }
.csp-se-ai { color: var(--muted); }
