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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

header h1 {
  font-size: 18px;
  color: #58a6ff;
  white-space: nowrap;
}

header nav {
  display: flex;
  gap: 8px;
}

header nav a {
  color: #8b949e;
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14px;
}

header nav a.active,
header nav a:hover {
  color: #c9d1d9;
  background: #21262d;
}

#header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

#btn-refresh {
  background: #238636;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}

#btn-refresh:hover {
  background: #2ea043;
}

#btn-refresh.loading {
  background: #484f58;
  pointer-events: none;
}

#btn-refresh.loading .btn-icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-icon {
  display: inline-block;
  font-size: 15px;
}

#last-update {
  font-size: 11px;
  color: #484f58;
}

/* Settings Panel */
#settings-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 24px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-group label {
  font-size: 10px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-group input {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 13px;
  width: 130px;
  font-family: monospace;
}

.setting-group input:focus {
  outline: none;
  border-color: #58a6ff;
}

.cex-accounts-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cex-account-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #8b949e;
}

.cex-account-item input {
  width: 36px;
  padding: 3px 4px;
  text-align: center;
  font-size: 11px;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  font-family: monospace;
}

.cex-account-item input:focus {
  outline: none;
  border-color: #58a6ff;
}

/* Blacklist */
.setting-group-blacklist {
  min-width: 200px;
}

#blacklist-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 3px 6px;
  min-height: 30px;
  cursor: text;
}

#blacklist-container:focus-within {
  border-color: #58a6ff;
}

#blacklist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.blacklist-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #f8514933;
  color: #f85149;
  border: 1px solid #f8514955;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: monospace;
  white-space: nowrap;
}

.blacklist-chip-remove {
  background: none;
  border: none;
  color: #f85149;
  cursor: pointer;
  font-size: 12px;
  padding: 0 0 0 2px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.blacklist-chip-remove:hover {
  opacity: 1;
}

#blacklist-input {
  background: none;
  border: none;
  color: #c9d1d9;
  font-size: 12px;
  font-family: monospace;
  outline: none;
  width: 100px;
  padding: 2px 0;
}

/* Summary Cards */
#summary-cards {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  overflow-x: auto;
}

.card {
  flex: 1;
  min-width: 140px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px 16px;
}

.card-label {
  font-size: 10px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.card-value {
  font-size: 22px;
  font-weight: 700;
  font-family: monospace;
  color: #c9d1d9;
}

.card-apr .card-value { color: #3fb950; }
.card-profit .card-value { color: #58a6ff; }
.card-unallocated .card-value { color: #f85149; }

/* Type Filter Chips */
#type-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 24px;
  border-bottom: 1px solid #21262d;
}

.filter-chip {
  background: #21262d;
  color: #8b949e;
  border: 1px solid transparent;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  color: #c9d1d9;
  border-color: #30363d;
}

.filter-chip.active {
  background: #388bfd1a;
  color: #58a6ff;
  border-color: #388bfd66;
}

/* Exclude button */
.btn-exclude {
  background: none;
  border: none;
  color: #484f58;
  cursor: pointer;
  font-size: 10px;
  padding: 0 4px 0 0;
  line-height: 1;
  vertical-align: middle;
  transition: color 0.15s;
}

.btn-exclude:hover {
  color: #f85149;
}

.btn-restore {
  background: none;
  border: none;
  color: #484f58;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px 0 0;
  line-height: 1;
  vertical-align: middle;
  transition: color 0.15s;
}

.btn-restore:hover {
  color: #3fb950;
}

/* Exclude bar */
#exclude-bar {
  padding: 6px 24px;
  font-size: 12px;
  color: #8b949e;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
  gap: 8px;
}

#exclude-bar.hidden {
  display: none;
}

#exclude-bar button {
  background: #21262d;
  color: #58a6ff;
  border: 1px solid #30363d;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}

#exclude-bar button:hover {
  background: #30363d;
}

/* Error Banner */
#error-banner {
  background: #f8514922;
  color: #f85149;
  padding: 8px 24px;
  font-size: 12px;
  border-bottom: 1px solid #f8514944;
}

#error-banner.hidden {
  display: none;
}

/* Table */
#table-container {
  padding: 0 24px 24px;
  overflow-x: auto;
}

#strategy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#strategy-table th {
  position: sticky;
  top: 0;
  background: #0d1117;
  color: #8b949e;
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid #30363d;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#strategy-table th:hover {
  color: #c9d1d9;
}

#strategy-table th.sort-asc::after { content: " ▲"; color: #58a6ff; }
#strategy-table th.sort-desc::after { content: " ▼"; color: #58a6ff; }

#strategy-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #21262d;
  white-space: nowrap;
}

#strategy-table tbody tr:hover {
  background: #161b22;
}

/* 배분된 행 vs 미배분 행 */
#strategy-table tbody tr.allocated {
  opacity: 1;
}

#strategy-table tbody tr.allocated td:first-child {
  border-left: 3px solid #3fb950;
}

#strategy-table tbody tr.unallocated {
  opacity: 0.35;
}

#strategy-table tbody tr.unallocated:hover {
  opacity: 0.6;
}

#strategy-table tbody tr.excluded {
  opacity: 0.25;
  text-decoration: line-through;
  text-decoration-color: #484f58;
}

#strategy-table tbody tr.excluded:hover {
  opacity: 0.45;
}

/* 수익률 색상 */
.apr-positive { color: #3fb950; font-weight: 600; }
.apr-negative { color: #f85149; }
.apr-zero { color: #484f58; }

/* 태그 */
.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
}

.tag-unlisted {
  background: #f8514922;
  color: #f85149;
  margin-left: 4px;
}

.tag-soldout {
  background: #da363322;
  color: #da3633;
  margin-left: 4px;
}

.sold-out td {
  opacity: 0.5;
}

.stake-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
}

.stake-input {
  width: 80px;
  padding: 2px 4px;
  font-size: 11px;
  background: #161b22;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
}

.stake-input:focus {
  border-color: #58a6ff;
  outline: none;
}

.stake-cap {
  color: #8b949e;
  font-size: 11px;
  white-space: nowrap;
}

.tag-type {
  background: #21262d;
  color: #8b949e;
}

.tag-type-earn { background: #238636aa; color: #fff; }
.tag-type-defi { background: #1f6feb88; color: #c9d1d9; }
.tag-type-funding { background: #8957e588; color: #d2a8ff; }
.tag-type-launch { background: #da3633aa; color: #fff; }
.tag-type-borrow { background: #f0883e88; color: #ffa657; }
.tag-type-looping { background: #a371f788; color: #d2a8ff; }
.tag-type-pt { background: #f0883e88; color: #ffa657; }
.tag-type-redeem { background: #f59e0baa; color: #fff; }

/* 배분 바 */
.alloc-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.alloc-bar-track {
  width: 40px;
  height: 4px;
  background: #21262d;
  border-radius: 2px;
  overflow: hidden;
}

.alloc-bar-fill {
  height: 100%;
  background: #3fb950;
  border-radius: 2px;
}

/* Empty message */
.empty-msg {
  text-align: center;
  color: #484f58;
  padding: 48px !important;
  font-size: 14px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0d1117;
}

::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    gap: 8px;
  }
  #summary-cards {
    gap: 8px;
    padding: 12px 16px;
  }
  .card {
    min-width: 110px;
    padding: 10px 12px;
  }
  .card-value {
    font-size: 18px;
  }
  #settings-panel {
    padding: 10px 16px;
    gap: 10px;
  }
  #table-container {
    padding: 0 8px 16px;
  }
}
