:root {
  --bg: #0b0d11; --panel: #13161c; --panel2: #181c24; --line: #232833; --text: #d7dbe3; --muted: #8a93a3;
  --yellow: #facc15; --green: #22c55e; --red: #ef4444; --blue: #3b82f6; --orange: #f59e0b;
  --mono: "JetBrains Mono", Consolas, "D2Coding", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 "Pretendard", "Malgun Gothic", system-ui, sans-serif; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 16px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; color: var(--yellow); letter-spacing: .02em; }
.brand span { color: var(--text); font-weight: 500; margin-left: 4px; }
.hbtns { margin-left: auto; display: flex; gap: 8px; }
.muted { color: var(--muted); }
.srv { font-size: 12px; white-space: nowrap; }
.layout { flex: 1; display: grid; grid-template-columns: 250px minmax(0, 1fr) 300px; min-height: 0; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 12px; overflow: auto; min-height: 0; }
aside.dash { border-right: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
h3 { margin: 0 0 10px; font-size: 14px; }
label { display: block; margin: 0 0 8px; color: var(--muted); font-size: 12px; }
label.chk { display: flex; align-items: center; gap: 6px; color: var(--text); }
input, select { width: 100%; margin-top: 3px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; font: 12px var(--mono); }
input[type=checkbox] { width: auto; margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.three input { margin: 0; }
.sub { color: var(--yellow); font-size: 12px; margin: 6px 0 4px; }
.hint { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.row { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.row select { margin: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.seg button { background: var(--panel2); color: var(--muted); border: 0; padding: 7px; cursor: pointer; font: inherit; }
.seg button.on { background: var(--yellow); color: #111; font-weight: 700; }
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #3a4252; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }
.btn.primary { background: var(--green); color: #07130b; border-color: var(--green); font-weight: 700; }
.btn.warn { border-color: var(--orange); color: var(--orange); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.ghost { background: transparent; }
main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar label { display: flex; align-items: center; gap: 6px; margin: 0; }
.toolbar select { width: auto; margin: 0; }
.sep { width: 1px; height: 22px; background: var(--line); }
.clock { margin-left: auto; font: 12px var(--mono); color: var(--yellow); }
.chartwrap { position: relative; flex: 1; min-height: 300px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.loading { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: #000a; padding: 6px 12px; border-radius: 4px; }
.progress { height: 3px; background: var(--line); }
.progress div { height: 100%; width: 0; background: var(--yellow); transition: width .2s; }
.tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-top: 1px solid var(--line); }
.tabs button { background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; padding: 5px 10px; cursor: pointer; font: inherit; }
.tabopt { margin: 0 0 0 auto; font-size: 12px; color: var(--muted); }
.tabs button.on { color: var(--yellow); border-color: var(--yellow); }
.tabpane { height: 190px; overflow: auto; padding: 6px 10px 10px; font: 12px var(--mono); }
#log div { white-space: nowrap; }
#log .stop { color: var(--red); } #log .hedge, #log .lock { color: var(--orange); } #log .release { color: #a78bfa; } #log .tp { color: var(--green); }
#log .buy { color: var(--blue); } #log .sell { color: #f87171; } #log .info { color: var(--muted); }
table { border-collapse: collapse; width: 100%; font: 12px var(--mono); }
th, td { padding: 3px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--bg); }
td:first-child, th:first-child { text-align: left; }
.pos { color: var(--green); } .neg { color: var(--red); } .red { color: var(--red); }
.card { background: #0f1217; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card hr { border: 0; border-top: 1px dashed #2a303c; margin: 8px 0; }
.card .line { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); display: inline-block; }
.sq { width: 10px; height: 10px; background: var(--red); display: inline-block; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; font-variant-numeric: tabular-nums; }
.kv span { color: var(--text); } .kv span::before { content: "● "; color: var(--yellow); font-size: 10px; }
.kv b { font: 600 12.5px var(--mono); }
.kv.hl { background: #1e2330; border-radius: 3px; padding: 1px 4px; }
.kv.hl b { color: var(--green); }
.side { margin-top: 6px; padding: 6px 8px; border-radius: 5px; background: var(--panel2); font: 12px var(--mono); }
.side .t { font-weight: 700; } .side.buy .t { color: var(--blue); } .side.sell .t { color: #f87171; }
.side .hg { color: var(--orange); }
#dHold { margin-top: 6px; font: 12px var(--mono); color: var(--orange); }
.actions { display: grid; gap: 6px; }
.actions > div { display: grid; gap: 6px; }
.modal { position: fixed; inset: 0; background: #0009; display: grid; place-items: center; z-index: 10; }
.mbox { background: var(--panel); border: 1px solid var(--orange); border-radius: 10px; padding: 18px 20px; width: min(460px, 92vw); }
.mbox h3 { color: var(--orange); }
.mbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.drop { outline: 2px dashed var(--yellow); outline-offset: -6px; }
@media (max-width: 1100px) { .layout { grid-template-columns: 220px minmax(0, 1fr); } aside.dash { display: none; } }
@media (prefers-reduced-motion: reduce) { .progress div { transition: none; } }

.btn.gold { border-color: var(--yellow); color: var(--yellow); }
.opt { position: fixed; inset: 0; background: #000b; z-index: 9; display: grid; place-items: center; }
.obox { width: min(1400px, 96vw); height: min(860px, 92vh); background: var(--panel); border: 1px solid var(--yellow); border-radius: 10px; display: flex; flex-direction: column; }
.ohead { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ohead h3 { margin: 0; color: var(--yellow); }
.ohead .btn { margin-left: auto; }
.obody { flex: 1; display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 0; }
.oform { padding: 12px 14px; overflow: auto; border-right: 1px solid var(--line); }
.ores { padding: 10px 14px; overflow: auto; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; }
.chips label { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--text); font-size: 12.5px; }
.chips input { width: auto; margin: 0; }
.ores table td, .ores table th { padding: 4px 7px; }
.ores tr.top td { background: #22c55e14; }
.ores tr.dead td { opacity: .55; }
.ores tr.stopped td { background: #ef444418; }
.ores tr.stopped td.stop { font-weight: 700; }
.otext { width: 100%; box-sizing: border-box; }
.opinion {border: 1px solid var(--line); border-left: 3px solid var(--yellow); background: var(--panel2); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; line-height: 1.6; }
.opinion h4 { margin: 0 0 6px; color: var(--yellow); font-size: 14px; }
.opinion .verdict { margin: 0 0 6px; font-weight: 600; }
.opinion ul { margin: 0; padding-left: 18px; }
.opinion li { margin: 2px 0; }
.opinion .lv-high { color: var(--green); } .opinion .lv-mid { color: var(--orange); } .opinion .lv-low { color: var(--red); }
.rank { color: var(--yellow); font-weight: 700; }
.release { margin-top: 6px; font: 12px var(--mono); }
.release .ok { color: var(--green); } .release .no { color: #f87171; } .release .h { color: var(--orange); font-weight: 700; }

/* 실계좌 대비 정확도 (첫 화면 상단) */
.accwrap { position: relative; }
.acc { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.acc b { color: var(--yellow); }
.accpop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; width: 340px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; box-shadow: 0 8px 24px #0008; font-size: 12px; line-height: 1.6; }
.accpop table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.accpop td { padding: 2px 4px; border-bottom: 1px solid var(--line); }
.accpop td:last-child { text-align: right; white-space: nowrap; }

/* 최적화만 보는 화면 (?view=opt, 춘식봇 탭 안에 끼워 보여 줄 때) */
body.optonly .layout { display: none; }
body.optonly header .hbtns { display: none; }
body.optonly .opt { position: static; background: none; display: flex; align-items: stretch; flex: 1; min-height: 0; z-index: auto; overflow: hidden; }
body.optonly .obox { width: 100%; height: auto; flex: 1; border: none; border-radius: 0; min-height: 0; }
body.optonly #optClose { display: none; }
@media (max-width: 760px) {
  .obody { grid-template-columns: 1fr; overflow: auto; }
  .oform { border-right: none; border-bottom: 1px solid var(--line); overflow: visible; }
  .ores { overflow: visible; }
  header { flex-wrap: wrap; gap: 8px; }
}
