: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; }
.search input { width: 100%; padding: 9px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); }
.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: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.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); }
.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; }
}
