:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #161a22; --muted: #6b7280; --line: #e5e7eb;
  --up: #e5394b; --down: #2f6fe4; --stop: #e5394b; --take: #12a36a; --warn: #f59e0b;
  --primary: #161a22; --primary-ink: #fff; --soft: #f0f1f4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1016; --card: #161b24; --ink: #eef0f4; --muted: #9aa3b2; --line: #262d3a;
    --up: #ff5a6a; --down: #5b93ff; --stop: #ff5a6a; --take: #2fd08b; --warn: #fbbf24;
    --primary: #eef0f4; --primary-ink: #0d1016; --soft: #1d2430;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Apple SD Gothic Neo", "AppleSDGothicNeoM00", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--stop); min-height: 1.4em; }
.up { color: var(--up); } .down { color: var(--down); }
.num { font-variant-numeric: tabular-nums; }

/* 로그인 */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box img { border-radius: 18px; }
.login-box h1 { margin: 12px 0 4px; font-size: 26px; }
.login-box input { margin: 18px 0 10px; }

/* 상단·탭 */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 18px; letter-spacing: -0.3px; }
.mkt { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--take); box-shadow: 0 0 0 3px color-mix(in srgb, var(--take) 25%, transparent); }
main { padding: 12px 16px 150px; max-width: 640px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 0 10px; font: inherit; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabs button.on { color: var(--ink); font-weight: 700; }
.tabs .ti { font-size: 19px; }
.badge { position: absolute; top: 4px; left: 50%; margin-left: 8px; background: var(--stop); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 9px; line-height: 18px; padding: 0 5px; }
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; border: 0; border-radius: 28px;
  background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 800; font-size: 16px; padding: 14px 20px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* 카드 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sum .k { font-size: 12px; color: var(--muted); }
.sum .v { font-size: 20px; font-weight: 800; }
.stock-h { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 2px 8px; }
.stock-h .nm { font-weight: 800; font-size: 17px; }
.stock-h .px { font-weight: 700; }
.lot .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lot .pct { font-size: 22px; font-weight: 800; }
.lot .meta { font-size: 13px; color: var(--muted); }
.lines { display: flex; justify-content: space-between; font-size: 13px; margin-top: 8px; }
.lines .s { color: var(--stop); } .lines .t { color: var(--take); }
.gauge { position: relative; height: 10px; margin: 8px 0 4px; border-radius: 5px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--stop) 35%, transparent), var(--soft) 45%, var(--soft) 55%, color-mix(in srgb, var(--take) 35%, transparent)); }
.gauge .buy { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--muted); }
.gauge .cur { position: absolute; top: -4px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--card); }
.gauge .cur.out-s { background: var(--stop); } .gauge .cur.out-t { background: var(--take); }
.gnote { font-size: 12px; color: var(--muted); }
.btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--soft); color: var(--ink); font: inherit; font-weight: 700;
  border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { background: var(--stop); color: #fff; border-color: var(--stop); }
.btn.good { background: var(--take); color: #fff; border-color: var(--take); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.pending { margin-top: 10px; padding: 8px 10px; border-radius: 10px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 15%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.flag { margin-top: 10px; padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.flag.s { background: color-mix(in srgb, var(--stop) 14%, transparent); color: var(--stop); }
.flag.t { background: color-mix(in srgb, var(--take) 14%, transparent); color: var(--take); }

/* 신호 */
.sig { border-width: 2px; }
.sig.stop { border-color: var(--stop); } .sig.take { border-color: var(--take); }
.sig.held { border-style: dashed; }
.sig .big { font-size: 18px; font-weight: 800; margin: 2px 0 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; }
.kv .k { color: var(--muted); }
.notice { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 13px; }
.notice:last-child { border: 0; }
.notice .t { font-weight: 700; }

/* 성적표 */
.score { text-align: center; padding: 18px 14px; }
.score .huge { font-size: 30px; font-weight: 900; margin: 4px 0; }
.list .it { border-bottom: 1px solid var(--line); padding: 9px 0; font-size: 14px; }
.list .it:last-child { border: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 8px; margin-right: 4px; vertical-align: 1px; }
.tag.ok { background: color-mix(in srgb, var(--take) 18%, transparent); color: var(--take); }
.tag.no { background: color-mix(in srgb, var(--stop) 18%, transparent); color: var(--stop); }
.tag.mid { background: var(--soft); color: var(--muted); }
details summary { cursor: pointer; font-weight: 700; padding: 4px 0; }

/* 입력 */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
textarea { min-height: 72px; resize: vertical; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--stop) 10%, transparent); color: var(--ink); font-size: 14px; font-weight: 700; }
.check input { width: 22px; height: 22px; flex: none; margin: 0; }
.preview { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--soft); font-size: 14px; }
.results { border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; overflow: hidden; }
.results button { display: flex; justify-content: space-between; width: 100%; border: 0; border-bottom: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; padding: 11px 12px; text-align: left; }
.results button:last-child { border: 0; }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet .close { float: right; border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 0 4px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 480px;
  background: var(--primary); color: var(--primary-ink); border-radius: 12px; padding: 12px 14px; font-weight: 700; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .e { font-size: 40px; }
