:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #d8e0ea;
  --text: #1d2a3a;
  --muted: #5f7083;
  --accent: #0057b8;
  --up: #0f8f43;
  --down: #c2352a;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 28px;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, #dce8ff, transparent 28%),
    radial-gradient(circle at 100% 100%, #ffedd9, transparent 20%),
    var(--bg);
}

h1, h2, h3, p {
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#last-updated {
  color: var(--muted);
  font-size: 14px;
}

#refresh-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}

.system-status {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbff;
  color: #2a4769;
  font-size: 14px;
}

.system-status.loading {
  background: #fff8e9;
  border-color: #f0d9a8;
  color: #7a5812;
}

.system-status.ok {
  background: #eefbf2;
  border-color: #bde3c9;
  color: #1d6c39;
}

.system-status.warn {
  background: #fff4f2;
  border-color: #f0c5bf;
  color: #8a3026;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.panel-description {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.stock-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 160px;
  gap: 8px;
}

.stock-controls input,
.stock-controls select {
  width: 100%;
  border: 1px solid #c8d5e5;
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  font: inherit;
}

.stock-summary,
.news-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stock-list,
.news-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stock-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.stock-item.is-selected {
  border-color: #8cb3e8;
  box-shadow: 0 0 0 1px #c8dcf8 inset;
}

.stock-head {
  width: 100%;
  border: 0;
  padding: 12px 14px;
  background: #f8fbff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 15px;
}

.stock-name {
  font-weight: 700;
}

.stock-return.up,
.return-rate.up {
  color: var(--up);
  font-weight: 700;
}

.stock-return.down,
.return-rate.down {
  color: var(--down);
  font-weight: 700;
}

.return-rate.neutral {
  color: #6b7a8d;
  font-weight: 600;
}

.stock-detail {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.stock-detail dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stock-detail div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed #e5ebf2;
  padding-bottom: 4px;
}

.stock-detail dt {
  color: var(--muted);
}

.news-item {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}

.news-item:hover {
  border-color: #bfcfe4;
}

.news-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.source-box {
  margin-top: 16px;
  border: 1px solid #d6e0ec;
  border-radius: 12px;
  padding: 12px;
  background: #f9fcff;
}

.source-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.source-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.source-list li {
  margin: 6px 0;
}

.source-list a {
  color: #1f4f8a;
  text-decoration: none;
  font-size: 13px;
}

.source-list a:hover {
  text-decoration: underline;
}

.source-list span {
  display: block;
  color: #60748b;
  font-size: 12px;
}

.ad-box {
  margin-top: 16px;
  border: 1px dashed #b8c4d4;
  border-radius: 12px;
  padding: 12px;
}

.ad-note {
  margin-top: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

.ad-slot {
  min-height: 80px;
  background: #f7fafc;
}

.empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}

.site-footer {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13px;
}

.site-footer a {
  color: #2c4d78;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 980px) {
  body {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    align-items: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .stock-controls {
    grid-template-columns: 1fr;
  }

  .stock-detail dl {
    grid-template-columns: 1fr;
  }
}
