:root {
  --red: #d32f2f;     /* 상승 · 이익 (한국식) */
  --blue: #1565c0;    /* 하락 · 손실 */
  --text: #222;
  --muted: #666;
  --line: #e3e3e3;
  --bg: #f3f4f6;
  --select: #dbe8f8;
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h2 small { font-weight: normal; color: var(--muted); }
button {
  font: inherit; padding: 5px 12px; border: 1px solid #bbb; border-radius: 4px;
  background: #fff; cursor: pointer;
}
button:hover { background: #f0f4fa; }
.muted { color: var(--muted); }
.up { color: var(--red); }
.down { color: var(--blue); }
.fail { color: #999; }

.top {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 14px 16px 6px;
}
.top-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.top-right #status { margin-right: 6px; }

main { padding: 6px 16px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.card-head > div { display: flex; gap: 8px; align-items: center; }

/* 시세 표 */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 980px; }
th, td { padding: 7px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { background: #eee; font-weight: bold; }
th.l, td.l { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fc; }
tbody tr.selected { background: var(--select); }
.summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 15px; }

/* 뉴스 */
.news { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 10px; }
#news-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); }
#news-list li { padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
#news-list li:hover { background: #f7f9fc; }
#news-list li.selected { background: var(--select); }
#news-list .meta { font-size: 12px; color: var(--muted); }
#news-list .title { display: block; margin-top: 2px; }
.news-detail { border: 1px solid var(--line); background: #fafafa; padding: 10px 12px; max-height: 420px; overflow-y: auto; }
.news-detail h3 { margin: 0 0 8px; font-size: 15px; }
.news-detail p { margin: 0 0 8px; line-height: 1.6; }
.news-detail .meta { font-size: 12px; color: var(--muted); }
.news-detail a { display: inline-block; margin-top: 6px; }

/* 입력 폼 */
form { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
form label { display: flex; align-items: center; gap: 6px; }
form input { font: inherit; padding: 5px 7px; border: 1px solid #bbb; border-radius: 4px; width: 140px; }
.form-buttons { display: flex; gap: 6px; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; line-height: 1.6; }

/* 그래프 창 */
dialog { width: min(1000px, 96vw); max-height: 94vh; border: 1px solid #ccc; border-radius: 8px; padding: 14px 18px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.dialog-head > div { display: flex; gap: 8px; align-items: center; }
.dialog-head select { font: inherit; padding: 3px; }
.charts h3 { font-size: 13px; margin: 12px 0 4px; }
.chart-box { position: relative; height: 200px; }

@media (max-width: 800px) {
  main { padding: 6px 8px 16px; }
  .top { padding: 12px 10px 4px; }
  .summary { font-size: 14px; }
  .news { grid-template-columns: minmax(0, 1fr); }
  #news-list { max-height: 320px; }
  form input { width: 120px; }
}
