:root {
  --bg: #f7f6f3; --surface: #ffffff; --text: #1d2125; --muted: #5d6670; --line: #e3e0d9;
  --accent: #b4441f; --up: #d6336c; --down: #1c6fd1; --star: #e8a300; --hl: #fff3cf;
  --ma1: #f59f00; --ma2: #e8590c; --ma3: #2b8a3e; --ma4: #5f3dc4; --ma5: #212529;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131518; --surface: #1b1e22; --text: #e8e8e5; --muted: #a0a7ae; --line: #2d3238;
    --accent: #f08a5d; --up: #ff6b8b; --down: #4dabf7; --star: #ffd43b; --hl: #3a3218;
    --ma1: #ffd43b; --ma2: #ff922b; --ma3: #69db7c; --ma4: #b197fc; --ma5: #f1f3f5;
  }
}
:root[data-theme="dark"] {
  --bg: #131518; --surface: #1b1e22; --text: #e8e8e5; --muted: #a0a7ae; --line: #2d3238;
  --accent: #f08a5d; --up: #ff6b8b; --down: #4dabf7; --star: #ffd43b; --hl: #3a3218;
  --ma1: #ffd43b; --ma2: #ff922b; --ma3: #69db7c; --ma4: #b197fc; --ma5: #f1f3f5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif; word-break: keep-all; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; gap: 16px; align-items: center; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 800; color: var(--text); text-decoration: none; font-size: 17px; white-space: nowrap; }
.search { position: relative; flex: 1; min-width: 220px; display: flex; gap: 6px; margin: 0; }
.search input { flex: 1; min-width: 0; padding: 9px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); }
.sbtn { padding: 0 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px;
  font-weight: 700; cursor: pointer; white-space: nowrap; }
.sbtn:hover { filter: brightness(1.08); }
.smsg { position: absolute; top: 100%; left: 0; margin: 6px 0 0; font-size: 13px; color: var(--accent);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.zoom { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.zoom button { border: 0; background: var(--surface); color: var(--text); padding: 6px 12px; font-size: 13px; cursor: pointer; }
.zoom button + button { border-left: 1px solid var(--line); }
.zoom button:hover { background: var(--hl); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.sugg { position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; max-height: 340px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.sugg li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.sugg li.act, .sugg li:hover { background: var(--hl); }
.sugg .c { color: var(--muted); font-size: 13px; }
.sugg .n { color: var(--accent); font-size: 13px; white-space: nowrap; }

h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
.asof { color: var(--muted); font-size: 13px; margin: 18px 0 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-size: 24px; font-weight: 800; } .stat .l { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; min-width: 0; }
.panel .table-wrap { border: 0; max-height: 440px; overflow-y: auto; }
.years { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.years .yb { flex: 1; background: var(--accent); opacity: .8; border-radius: 3px 3px 0 0; position: relative; min-width: 6px; }
.years .yb span { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); }
.years .yb:hover { opacity: 1; }

.stock-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 20px 0 12px; }
.sub { color: var(--muted); margin: 2px 0 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip b { color: var(--accent); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 7px 16px; font-size: 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
.chk { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.legend i { display: inline-block; width: 18px; vertical-align: middle; margin-right: 4px; border-radius: 2px; }
.chart { width: 100%; height: 480px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05); background: var(--chart-top); }
:root { --chart-top: #ffffff; --chart-bottom: #f4f6fa; --grid: rgba(120,130,150,.12); --arrow: #146c2e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-top: #1e2329; --chart-bottom: #15181c; --grid: rgba(200,210,225,.07); --arrow: #2fb35a; } }
:root[data-theme="dark"] { --chart-top: #1e2329; --chart-bottom: #15181c; --grid: rgba(200,210,225,.07); --arrow: #2fb35a; }
.note { font-size: 12px; color: var(--muted); margin: 6px 2px 0; min-height: 18px; }
.tbl-title { margin-top: 22px; } .tbl-title span { color: var(--muted); font-weight: 500; font-size: 14px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td.t, th.t { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; z-index: 1; }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--hl); }
tbody tr.flash { background: var(--hl); }
.pos { color: var(--up); } .neg { color: var(--down); }
tr.lowp td, tr.lowp td a, tr.lowp .tag { font-size: 10pt; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--accent); border-color: var(--accent); }
a.lk { color: var(--text); text-decoration: none; font-weight: 600; } a.lk:hover { color: var(--accent); }
.empty { color: var(--muted); padding: 16px 4px; }
footer { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 30px 0 40px; border-top: 1px solid var(--line); padding-top: 14px; }

@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .chart { height: 340px; }
  h1 { font-size: 22px; }
}

/* ── SamsungAnalysis 추가 ── */
:root { --ma6: #1098ad; --win: #146c2e; --loss: #868e96; --tout: #e8a300; --pend: #1c6fd1; --good-bg: #e9f5ec; --flat-bg: #fff6e0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ma6: #66d9e8; --win: #2fb35a; --loss: #8b939b; --tout: #ffd43b; --pend: #4dabf7; --good-bg: #16261b; --flat-bg: #2b2516; } }
:root[data-theme="dark"] { --ma6: #66d9e8; --win: #2fb35a; --loss: #8b939b; --tout: #ffd43b; --pend: #4dabf7; --good-bg: #16261b; --flat-bg: #2b2516; }

.pick { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.pick select { font: inherit; font-size: 15px; font-weight: 700; color: var(--text); background: var(--bg);
  border: 1px solid var(--accent); border-radius: 8px; padding: 8px 34px 8px 12px; cursor: pointer; min-width: 220px; }
.pick select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.verdict { border-radius: 10px; padding: 12px 16px; margin: 4px 0 14px; border: 1px solid var(--line); font-size: 15px; }
.verdict.good { background: var(--good-bg); } .verdict.flat { background: var(--flat-bg); }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat .v { font-size: 22px; }
.legend span.on { color: var(--text); font-weight: 700; }
.cmp { margin-top: 18px; } .cmp h2 small { color: var(--muted); font-weight: 500; font-size: 13px; }
#cmp tbody tr.sel { background: var(--hl); font-weight: 700; }
#cmp tbody tr.base { cursor: default; color: var(--muted); font-style: italic; }
#cmp tbody tr.base:hover { background: none; }
.res { display: inline-block; min-width: 46px; text-align: center; font-size: 12px; font-weight: 700; padding: 1px 8px;
  border-radius: 999px; color: var(--c); border: 1px solid var(--c); }
footer b { color: var(--text); }
@media (max-width: 760px) { .pick { width: 100%; } .pick select { flex: 1; min-width: 0; } }
:root { --bad-bg: #fdecec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bad-bg: #2d1a1a; } }
:root[data-theme="dark"] { --bad-bg: #2d1a1a; }
.verdict.bad { background: var(--bad-bg); }
.verdict .warn { color: var(--accent); font-weight: 600; }
td.muted { color: var(--muted); }
.stock-head { margin: 18px 0 10px; }
.pick select { min-width: 200px; }
.defs { margin: -2px 0 10px; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.defs b { color: var(--text); }
.ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 14px; margin: 0 0 12px; }
.ctrl label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ctrl select { font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.ctrl select:disabled { opacity: .45; cursor: not-allowed; }
.ctrl .sbtn { padding: 8px 18px; }
.ctrl .applied { font-size: 12px; color: var(--muted); flex-basis: 100%; }
@media (max-width: 760px) { .ctrl label { width: 100%; } .ctrl select { flex: 1; min-width: 0; } .ctrl .sbtn { width: 100%; } }
