:root {
  --bg: #0f1115; --card: #171a21; --line: #262a33; --text: #e6e8ec; --muted: #8b919d;
  --up: #f04452; --down: #3182f6; --accent: #3182f6; --warn: #f5a623; --ok: #22c55e;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.r { text-align: right; }
.up { color: var(--up); } .down { color: var(--down); }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 12px;
  font: inherit; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.danger { background: #c62f3b; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.buy { background: var(--up); } button.sell { background: var(--down); }
button.x { background: transparent; color: var(--muted); padding: 2px 6px; }
input, select { background: #0f1218; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font: inherit; width: 100%; }

header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(15,17,21,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 16px; }
.spacer { flex: 1; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #2a2f3a; }
.badge.demo { background: #3b3f4c; } .badge.paper { background: #1d4ed8; } .badge.live { background: #c62f3b; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #666; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.equity b { font-size: 16px; }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.slider { width: 42px; height: 24px; border-radius: 12px; background: #3a3f4b; position: relative; transition: .2s; }
.slider::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::after { left: 21px; }
.lbl { font-weight: 600; }

.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px; background: #3a1d20; color: #ffb4bb;
  border: 1px solid #6b2a31; }
.banner.warn { background: #3a2f17; color: #ffd98a; border-color: #6b5521; }

main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; padding: 14px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 15px; }
.settings { grid-column: 1 / -1; }
.inline { display: flex; gap: 6px; align-items: center; }
.inline input { width: auto; min-width: 0; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { font-weight: 500; color: var(--muted); font-size: 12px; text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
td { padding: 8px 6px; border-bottom: 1px solid #1f232b; white-space: nowrap; }
#watchTbl tbody tr { cursor: pointer; }
#watchTbl tbody tr:hover, #watchTbl tbody tr.sel { background: #1e222b; }
.nm { font-weight: 600; } .code { color: var(--muted); font-size: 12px; margin-left: 4px; }
.sig { font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.sig.BUY { background: rgba(240,68,82,.15); color: var(--up); }
.sig.SELL { background: rgba(49,130,246,.15); color: var(--down); }
.sig.HOLD { background: #252a33; color: var(--muted); }
.closed { font-size: 11px; color: var(--muted); margin-left: 4px; }
.scroll { max-height: 320px; overflow: auto; }
td.reason { white-space: normal; color: var(--muted); font-size: 12px; min-width: 160px; }

#chart { height: 340px; } #rsiChart { height: 110px; margin-top: 4px; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.lg { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.lg.ef { background: #f5a623; } .lg.es { background: #a78bfa; } .lg.bb { background: #4b5563; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.reasons span { background: #222731; padding: 3px 9px; border-radius: 999px; font-size: 12px; }
.order input { width: 80px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 0; min-width: 0; }
legend { color: var(--muted); padding: 0 6px; font-size: 12px; }
fieldset label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
label.chk { flex-direction: row; align-items: center; gap: 6px; grid-column: 1 / -1; }
label.chk input { width: auto; }
.row-btns { margin-top: 12px; }
.update { grid-column: 1 / -1; }
.changes { margin: 8px 0 12px; padding-left: 18px; color: var(--text); font-size: 13px; }
.changes li { margin: 2px 0; }
#updForm input { max-width: 220px; }
.upd-msg { margin: 10px 0 0; white-space: pre-wrap; font-size: 13px; }
.upd-msg.ok { color: #9ee6b0; } .upd-msg.err { color: #ff8a94; }

.logs { font: 12px/1.6 ui-monospace, Menlo, monospace; max-height: 320px; overflow: auto; }
.logs div { border-bottom: 1px solid #1d2128; padding: 2px 0; }
.logs .ERROR { color: #ff8a94; } .logs .WARN { color: var(--warn); } .logs .TRADE { color: #9ee6b0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2b303b; padding: 10px 16px;
  border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }
.login { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: grid; place-items: center; }
.login form { background: var(--card); padding: 24px; border-radius: 14px; width: 300px; display: grid; gap: 10px; }
.err { color: #ff8a94; margin: 0; min-height: 1em; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  #chart { height: 280px; }
  .scroll, .watch { overflow-x: auto; }
}
