* { box-sizing: border-box; }
body {
  font-family: 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  margin: 0;
  background: #f7f8fa;
  color: #222;
}

header {
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
header h1 { font-size: 18px; margin: 0; }

.add-form { display: flex; gap: 8px; }
.add-form input {
  padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; width: 260px; font-size: 13px;
}
.add-form button {
  padding: 8px 14px; border: none; border-radius: 6px; background: #4285F4; color: #fff; font-size: 13px; cursor: pointer;
}
.add-form button:hover { background: #3367d6; }

.toolbar {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: #fff;
  border-bottom: 1px solid #eee;
}
#searchInput {
  padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; width: 220px; font-size: 13px;
}

.tag-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-chip {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #555;
}
.tag-chip.active { background: #4285F4; color: #fff; border-color: #4285F4; }
.tag-chip.small { padding: 2px 8px; margin-right: 4px; cursor: default; background: #eef2ff; color: #3355cc; border: none; display: inline-block; }
.tag-chip.removable { display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; border-radius: 12px; padding: 4px 8px; font-size: 12px; margin: 2px 4px 2px 0; }
.tag-chip.removable .remove-tag { border: none; background: none; cursor: pointer; color: #999; font-size: 11px; }

main { padding: 16px 24px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
thead th {
  text-align: left; padding: 12px; font-size: 12px; color: #666; background: #fafafa; border-bottom: 1px solid #eee; cursor: pointer; user-select: none;
}
thead th[data-key]:hover { color: #4285F4; }
thead th.sorted::after { content: attr(data-dir); margin-left: 4px; font-size: 10px; }
thead th.sorted[data-dir="asc"]::after { content: "▲"; }
thead th.sorted[data-dir="desc"]::after { content: "▼"; }

tbody td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f2f2f2; }
tbody tr.channel-row { cursor: pointer; }
tbody tr.channel-row:hover { background: #f7f9fc; }
.name-cell { font-weight: 500; }
.growth-up { color: #1e7e34; }
.growth-down { color: #c0392b; }
.empty { text-align: center; color: #999; padding: 24px; }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative; background: #fff; border-radius: 10px; padding: 24px;
  width: 560px; max-width: 90vw; max-height: 85vh; overflow-y: auto;
}
.close-btn { position: absolute; top: 12px; right: 12px; border: none; background: none; font-size: 16px; cursor: pointer; color: #999; }

.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.stat-card { background: #f7f8fa; border-radius: 8px; padding: 10px; text-align: center; }
.stat-card .label { display: block; font-size: 11px; color: #888; }
.stat-card .value { display: block; font-size: 15px; font-weight: 600; margin-top: 4px; }

#detailChartContainer { height: 260px; position: relative; margin-bottom: 16px; }

.tag-editor { border-top: 1px solid #eee; padding-top: 12px; }
.tag-chips { margin-bottom: 8px; }
#addTagForm { display: flex; gap: 6px; }
#addTagForm input { flex: 1; padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; }
#addTagForm button { padding: 6px 12px; border: none; border-radius: 6px; background: #4285F4; color: #fff; font-size: 12px; cursor: pointer; }
.no-tags { font-size: 12px; color: #999; }
