:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #388bfd;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* NAV */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* SEARCH */
.search-bar {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.search-bar input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 12px;
  width: 220px;
  outline: none;
  transition: border-color .2s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  padding: 6px 16px;
  font-size: 14px;
}

/* SEARCH DROPDOWN */
.search-wrapper { position: relative; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.search-dropdown.open { display: block; }
.search-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }
.search-item .code { color: var(--text-muted); font-size: 12px; }
.search-item .market-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--border);
}

/* CONTAINER */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* GRID */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* STAT */
.stat-label { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-value.up { color: var(--red); }
.stat-value.down { color: var(--accent); }
.stat-change { font-size: 13px; margin-top: 4px; }
.up { color: var(--red); }
.down { color: var(--accent); }
.neutral { color: var(--text-muted); }

/* CHART */
#chart-container { height: 420px; position: relative; }
#indicator-container { height: 120px; margin-top: 8px; }

/* TABLE */
table { width: 100%; border-collapse: collapse; }
th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.03); }
.stock-name-cell { display: flex; flex-direction: column; }
.stock-name-cell .name { font-weight: 500; }
.stock-name-cell .code { color: var(--text-muted); font-size: 11px; }

/* SCORE BAR */
.score-bar-wrap { display: flex; align-items: center; gap: 8px; }
.score-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; }
.score-label { font-size: 12px; font-weight: 600; min-width: 28px; text-align: right; }

/* SIGNALS */
.signals { display: flex; flex-wrap: wrap; gap: 4px; }
.signal-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}
.signal-badge.buy { background: rgba(63,185,80,.15); color: var(--green); }
.signal-badge.sell { background: rgba(248,81,73,.15); color: var(--red); }
.signal-badge.neutral { background: rgba(139,148,158,.15); color: var(--text-muted); }

/* BUTTONS */
.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  padding: 8px 16px;
  transition: opacity .2s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--green); color: #000; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline.active { border-color: var(--accent); color: var(--accent); }

/* PERIOD TABS */
.period-tabs { display: flex; gap: 4px; }

/* INDICATOR TABS */
.indicator-tabs { display: flex; gap: 4px; margin-bottom: 8px; }

/* RSI METER */
.rsi-meter {
  position: relative;
  height: 8px;
  background: linear-gradient(to right, #388bfd 0%, #3fb950 30% 70%, #f85149 100%);
  border-radius: 4px;
  margin: 8px 0;
}
.rsi-pointer {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transform: translateX(-50%);
  border: 2px solid var(--bg);
  transition: left .3s;
}

/* LOADING */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* HERO */
.hero {
  text-align: center;
  padding: 60px 24px 40px;
}
.hero h1 { font-size: 36px; font-weight: 700; margin-bottom: 12px; }
.hero p { color: var(--text-muted); font-size: 16px; margin-bottom: 32px; }
.hero-search {
  display: flex;
  justify-content: center;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}
.hero-search input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
}
.hero-search input:focus { border-color: var(--accent); }
.hero-search button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  padding: 10px 24px;
  font-size: 15px;
}

/* POPULAR */
.popular-stocks { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.popular-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .2s;
}
.popular-chip:hover { border-color: var(--accent); color: var(--accent); }

/* SECTION TITLE */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* FILTER ROW */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* PROGRESS */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s;
}

/* FLEX UTIL */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

a { color: inherit; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  nav { gap: 16px; }
  .search-bar input { width: 160px; }
}
