:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-hover: #1f232c;
  --border: #262b35;
  --text: #e6e8eb;
  --text-muted: #8b93a1;
  --accent: #4f8cff;
  --up: #ff5959;
  --down: #4a9eff;
  --flat: #8b93a1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.2px;
}

header h1 a {
  color: var(--text);
  text-decoration: none;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  width: 220px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

button:hover {
  opacity: 0.85;
}

button.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

main {
  padding: 28px 32px 60px;
  max-width: 1400px;
  margin: 0 auto;
}

main.detail-main {
  max-width: none;
  padding: 28px 16px 60px;
}

.status-bar {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 18px;
}

.recommend-group {
  margin-bottom: 24px;
}

.recommend-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.recommend-group-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card .market-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 8px;
}

.card .name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .code {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.card .price {
  font-size: 17px;
  font-weight: 700;
}

.card .change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change.flat { color: var(--flat); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state button {
  margin-top: 16px;
}

/* detail page */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  max-width: 560px;
  margin: 0 auto;
}

.detail-card.chart-card {
  max-width: none;
  width: 95%;
}

/* backtest page tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
}

.tab-btn:hover {
  opacity: 1;
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* backtest page */
.backtest-form .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}

.backtest-form label,
#strategy-params label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  min-width: 160px;
}

.backtest-form input,
.backtest-form select,
#strategy-params input {
  width: 100%;
}

#strategy-params {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.trades-table th,
.trades-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.trades-table th:first-child,
.trades-table td:first-child {
  text-align: left;
}

.trades-table thead th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}

.detail-card .back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
}

.detail-card .back-link:hover {
  color: var(--accent);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.detail-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.detail-header .code {
  color: var(--text-muted);
  font-size: 13px;
}

.detail-price {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.detail-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.detail-item .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-item .value {
  font-size: 15px;
  font-weight: 600;
}

.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

.page-info {
  font-size: 13px;
  color: var(--text-muted);
}

.page-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-buttons button {
  min-width: 32px;
  padding: 6px 10px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.page-buttons button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.page-buttons button:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-buttons button.page-number.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* news detail panel */
.detail-btn,
.naver-call-btn {
  padding: 6px 12px;
  font-size: 12px;
}

.detail-panel {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: none;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.detail-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

.detail-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.detail-link {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 8px;
}

.detail-link:hover {
  text-decoration: underline;
}

.detail-date {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-error {
  font-size: 13px;
  color: var(--up);
}

.detail-body-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 8px;
}

.detail-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  font-family: inherit;
}
